[PATCH 2/2] OP_SYMADDR is simply an unop

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

 



Currently OP_SYMADDR are defined the same as OP_SETVAL.
However, OP_SYMADDRs don't need the field 'struct expression *val'
and OP_SETVALs don't need the field 'pseudo_t symbol' which
suggest that those two should be splitted. In fact, OP_SYMADDR,
having just one pseudo as operand and producing one pseudo, is
simply an unary op like OP_NOT, OP_NEG, ...

Change this by letting OP_SYMADDRs use the field 'src' as
the others unops do.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 Documentation/IR.md | 10 +++++-----
 cse.c               | 11 ++---------
 linearize.c         |  8 ++------
 linearize.h         |  5 ++---
 liveness.c          |  5 +----
 simplify.c          |  2 +-
 6 files changed, 13 insertions(+), 28 deletions(-)

diff --git a/Documentation/IR.md b/Documentation/IR.md
index 03fa3f807..c2972e371 100644
--- a/Documentation/IR.md
+++ b/Documentation/IR.md
@@ -219,6 +219,11 @@ Floating-point negation.
 - .target: result of the operation (must be a floating-point type)
 - .type: type of .target
 
+#### 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_COPY
 Copy (only needed after out-of-SSA).
 - .src: operand (type must be compatible with .target)
@@ -273,11 +278,6 @@ Store.
 - .type: type of .target
 
 ### Others
-#### OP_SYMADDR
-Create a pseudo corresponding to the address of a symbol.
-- .symbol: (pseudo_t) input symbol (alias .src)
-- .target: symbol's address
-
 #### OP_SETFVAL
 Create a pseudo corresponding to a floating-point literal.
 - .fvalue: the literal's value (long double)
diff --git a/cse.c b/cse.c
index 79d37cfd1..6e521f12b 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);
 		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_CAST:
 	case OP_SCAST:
 	case OP_PTRCAST:
@@ -214,15 +211,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 be0e811f2..980664270 100644
--- a/linearize.c
+++ b/linearize.c
@@ -343,11 +343,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));
@@ -469,6 +464,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;
 
@@ -1028,7 +1024,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 8790b7e58..da2c6806d 100644
--- a/linearize.h
+++ b/linearize.h
@@ -117,8 +117,7 @@ struct instruction {
 			pseudo_t base;
 			unsigned from, len;
 		};
-		struct /* setval and symaddr */ {
-			pseudo_t symbol;		/* Subtle: same offset as "src" !! */
+		struct /* setval */ {
 			struct expression *val;
 		};
 		struct /* setfval */ {
@@ -216,6 +215,7 @@ enum opcode {
 	OP_NOT,
 	OP_NEG,
 	OP_FNEG,
+	OP_SYMADDR,
 
 	/* Select - three input values */
 	OP_SEL,
@@ -225,7 +225,6 @@ enum opcode {
 	OP_STORE,
 	OP_SETVAL,
 	OP_SETFVAL,
-	OP_SYMADDR,
 
 	/* Other */
 	OP_PHI,
diff --git a/liveness.c b/liveness.c
index e0e583292..d51e52132 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_NOT: case OP_NEG: case OP_FNEG:
+	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 */
diff --git a/simplify.c b/simplify.c
index cafa6e2c8..d777588bb 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1219,7 +1219,7 @@ int simplify_instruction(struct instruction *insn)
 	case OP_SYMADDR:
 		if (dead_insn(insn, NULL, NULL, NULL))
 			return REPEAT_CSE | REPEAT_SYMBOL_CLEANUP;
-		return replace_with_pseudo(insn, insn->symbol);
+		return replace_with_pseudo(insn, insn->src);
 	case OP_CAST:
 	case OP_SCAST:
 	case OP_FPCAST:
-- 
2.16.3

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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