[PATCH 3/4] slice: OP_SLICE needs the source's type: make it a kind of unop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 linearize.c | 5 +++--
 linearize.h | 5 +----
 liveness.c  | 5 +----
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/linearize.c b/linearize.c
index 96a717bc2909..7ab69d3ac968 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 4d83675caaf1..429f4797e359 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;
 		};
diff --git a/liveness.c b/liveness.c
index 30a9a5b6b169..755509e59b52 100644
--- a/liveness.c
+++ b/liveness.c
@@ -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;
-- 
2.30.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux