On 25/08/18 16:43, Luc Van Oostenryck wrote: > 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@xxxxxxxxx> > --- > Documentation/IR.rst | 12 ++++++------ > cse.c | 11 ++--------- > linearize.c | 8 ++------ > linearize.h | 3 --- > liveness.c | 5 +---- > simplify.c | 6 +++--- > 6 files changed, 14 insertions(+), 31 deletions(-) > > diff --git a/Documentation/IR.rst b/Documentation/IR.rst > index 0419ac411..8ffc921ab 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. > > diff --git a/cse.c b/cse.c > index 1395a8af3..22dfd4ba5 100644 > --- a/cse.c > +++ b/cse.c > @@ -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); s/src1/src/ ? (We fall through from the binary cases above, so this compares to the use of the 'src2' field there. However, I would even prefer divorcing the binary and unary cases, use 'src' here and _add_ a 'break' and 'src1' there! ;-) ). > 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; ditto, s/src1/src/, divorcing binary/unary, etc., > 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 a56c272f7..cf6f581ba 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)); s/src1/src/ > 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 413bf0132..d1fe7a2f0 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; > }; > diff --git a/liveness.c b/liveness.c > index d1968ce4b..93a7cc300 100644 > --- a/liveness.c > +++ b/liveness.c > @@ -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); s/src1/src/ > 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 */ > diff --git a/simplify.c b/simplify.c > index 52910876c..a786579e9 100644 > --- a/simplify.c > +++ b/simplify.c > @@ -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);> ATB, Ramsay Jones