diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-05-06 16:05:52 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-25 17:20:23 +0200 |
| commit | b01160b296a2c0810b5b9acc39c44de083533601 (patch) | |
| tree | 61baf42803805159ac764e59f32b942ae31f1859 | |
| parent | 96f388f0f55cfa1984daa70d7dc4faa63a85c590 (diff) | |
| download | sparse-dev-b01160b296a2c0810b5b9acc39c44de083533601.tar.gz | |
symaddr: s/insn->symbol/insn->src/
OP_SYMADDR take a single operand 'symbol' but this instruction
is very much like other unops and using the same operand's name
allow to avoid some special cases.
So, s/symbol/src/ for OP_SYMADDRs.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | Documentation/IR.rst | 12 | ||||
| -rw-r--r-- | cse.c | 11 | ||||
| -rw-r--r-- | linearize.c | 8 | ||||
| -rw-r--r-- | linearize.h | 3 | ||||
| -rw-r--r-- | liveness.c | 5 | ||||
| -rw-r--r-- | simplify.c | 6 |
6 files changed, 14 insertions, 31 deletions
diff --git a/Documentation/IR.rst b/Documentation/IR.rst index 0419ac41..8ffc921a 100644 --- a/Documentation/IR.rst +++ b/Documentation/IR.rst @@ -241,6 +241,12 @@ Unary ops * .target: result of the operation (must be a floating-point type) * .type: type of .target +.. op:: OP_SYMADDR + Create a pseudo corresponding to the address of a symbol. + + * .src: input symbol (must be a PSEUDO_SYM) + * .target: symbol's address + .. op:: OP_COPY Copy (only needed after out-of-SSA). @@ -327,12 +333,6 @@ Memory ops Others ------ -.. op:: OP_SYMADDR - Create a pseudo corresponding to the address of a symbol. - - * .symbol: (pseudo_t) input symbol (alias .src) - * .target: symbol's address - .. op:: OP_SETFVAL Create a pseudo corresponding to a floating-point literal. @@ -76,6 +76,7 @@ void cse_collect(struct instruction *insn) /* Unary */ case OP_NOT: case OP_NEG: case OP_FNEG: + case OP_SYMADDR: hash += hashval(insn->src1); break; @@ -87,10 +88,6 @@ void cse_collect(struct instruction *insn) hash += hashval(insn->fvalue); break; - case OP_SYMADDR: - hash += hashval(insn->symbol); - break; - case OP_SEXT: case OP_ZEXT: case OP_TRUNC: case OP_PTRCAST: @@ -213,15 +210,11 @@ static int insn_compare(const void *_i1, const void *_i2) /* Unary */ case OP_NOT: case OP_NEG: case OP_FNEG: + case OP_SYMADDR: if (i1->src1 != i2->src1) return i1->src1 < i2->src1 ? -1 : 1; break; - case OP_SYMADDR: - if (i1->symbol != i2->symbol) - return i1->symbol < i2->symbol ? -1 : 1; - break; - case OP_SETVAL: if (i1->val != i2->val) return i1->val < i2->val ? -1 : 1; diff --git a/linearize.c b/linearize.c index a56c272f..cf6f581b 100644 --- a/linearize.c +++ b/linearize.c @@ -351,11 +351,6 @@ const char *show_instruction(struct instruction *insn) buf += sprintf(buf, "%s", show_label(insn->bb_true)); break; - case OP_SYMADDR: - buf += sprintf(buf, "%s <- ", show_pseudo(insn->target)); - buf += sprintf(buf, "%s", show_pseudo(insn->symbol)); - break; - case OP_SETVAL: { struct expression *expr = insn->val; buf += sprintf(buf, "%s <- ", show_pseudo(insn->target)); @@ -481,6 +476,7 @@ const char *show_instruction(struct instruction *insn) case OP_NOT: case OP_NEG: case OP_FNEG: + case OP_SYMADDR: buf += sprintf(buf, "%s <- %s", show_pseudo(insn->target), show_pseudo(insn->src1)); break; @@ -1104,7 +1100,7 @@ static pseudo_t add_symbol_address(struct entrypoint *ep, struct symbol *sym) pseudo_t target = alloc_pseudo(insn); insn->target = target; - use_pseudo(insn, symbol_pseudo(ep, sym), &insn->symbol); + use_pseudo(insn, symbol_pseudo(ep, sym), &insn->src); add_one_insn(ep, insn); return target; } diff --git a/linearize.h b/linearize.h index 413bf013..d1fe7a2f 100644 --- a/linearize.h +++ b/linearize.h @@ -122,9 +122,6 @@ struct instruction { pseudo_t base; unsigned from, len; }; - struct /* symaddr */ { - pseudo_t symbol; /* Subtle: same offset as "src" !! */ - }; struct /* setval */ { struct expression *val; }; @@ -72,6 +72,7 @@ static void track_instruction_usage(struct basic_block *bb, struct instruction * /* Uni */ case OP_UNOP ... OP_UNOP_END: + case OP_SYMADDR: USES(src1); DEFINES(target); break; @@ -93,10 +94,6 @@ static void track_instruction_usage(struct basic_block *bb, struct instruction * DEFINES(target); break; - case OP_SYMADDR: - USES(symbol); DEFINES(target); - break; - /* Other */ case OP_PHI: /* Phi-nodes are "backwards" nodes. Their def doesn't matter */ @@ -305,7 +305,7 @@ int kill_insn(struct instruction *insn, int force) break; case OP_SYMADDR: - kill_use(&insn->symbol); + kill_use(&insn->src); repeat_phase |= REPEAT_SYMBOL_CLEANUP; break; @@ -1704,9 +1704,9 @@ int simplify_instruction(struct instruction *insn) case OP_STORE: return simplify_memop(insn); case OP_SYMADDR: - if (dead_insn(insn, &insn->symbol, NULL, NULL)) + if (dead_insn(insn, &insn->src, NULL, NULL)) return REPEAT_CSE | REPEAT_SYMBOL_CLEANUP; - return replace_with_pseudo(insn, insn->symbol); + return replace_with_pseudo(insn, insn->src); case OP_SEXT: case OP_ZEXT: case OP_TRUNC: return simplify_cast(insn); |
