diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-02-26 00:04:27 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-02-28 22:41:40 +0100 |
commit | 04c02822a0750e3eb8ef2487e2407b3aa0b66245 (patch) | |
tree | 41df68494a291077409eb45763e33b8cd4bca39b | |
parent | fc5213b3f0040d21d0579b20cea9c4212e7cb504 (diff) | |
download | sparse-04c02822a0750e3eb8ef2487e2407b3aa0b66245.tar.gz |
slice: OP_SLICE needs the source's type: make it a kind of unop
OP_SLICE's source's type is needed for some simplifications.
For example, in some cases it can be simplified into OP_TRUNC.
So, merge its representation with the one for unops which also
need the source's type.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | linearize.c | 5 | ||||
-rw-r--r-- | linearize.h | 5 | ||||
-rw-r--r-- | liveness.c | 5 |
3 files changed, 5 insertions, 10 deletions
diff --git a/linearize.c b/linearize.c index 96a717bc..7ab69d3a 100644 --- a/linearize.c +++ b/linearize.c @@ -470,7 +470,7 @@ const char *show_instruction(struct instruction *insn) break; case OP_SLICE: - buf += sprintf(buf, "%s <- %s, %d", show_pseudo(insn->target), show_pseudo(insn->base), insn->from); + buf += sprintf(buf, "%s <- %s, %d", show_pseudo(insn->target), show_pseudo(insn->src), insn->from); break; case OP_NOT: case OP_NEG: @@ -1239,7 +1239,8 @@ static pseudo_t linearize_slice(struct entrypoint *ep, struct expression *expr) insn->target = new; insn->from = expr->r_bitpos; - use_pseudo(insn, pre, &insn->base); + insn->orig_type = expr->base->ctype; + use_pseudo(insn, pre, &insn->src); add_one_insn(ep, insn); return new; } diff --git a/linearize.h b/linearize.h index 4d83675c..429f4797 100644 --- a/linearize.h +++ b/linearize.h @@ -113,6 +113,7 @@ struct instruction { }; struct /* unops */ { pseudo_t src; + unsigned from; /* slice */ struct symbol *orig_type; /* casts */ }; struct /* memops */ { @@ -127,10 +128,6 @@ struct instruction { pseudo_t _src1, _src2; // alias .src[12] struct symbol *itype; // input operands' type }; - struct /* slice */ { - pseudo_t base; - unsigned from; - }; struct /* setval */ { struct expression *val; }; @@ -76,6 +76,7 @@ static void track_instruction_usage(struct basic_block *bb, struct instruction * /* Uni */ case OP_UNOP ... OP_UNOP_END: case OP_SYMADDR: + case OP_SLICE: USES(src1); DEFINES(target); break; @@ -121,10 +122,6 @@ static void track_instruction_usage(struct basic_block *bb, struct instruction * } END_FOR_EACH_PTR(pseudo); break; - case OP_SLICE: - USES(base); DEFINES(target); - break; - case OP_ASM: asm_liveness(bb, insn, def, use); break; |