Remove IR_OPND_VAR

This commit is contained in:
Dmitry Stogov 2023-05-19 13:00:55 +03:00
parent d3640495a2
commit c93abd79b2
6 changed files with 9 additions and 23 deletions

2
ir.c
View File

@ -201,7 +201,7 @@ void ir_print_const(const ir_ctx *ctx, const ir_insn *insn, FILE *f)
#define ir_op_kind_str IR_OPND_STR #define ir_op_kind_str IR_OPND_STR
#define ir_op_kind_num IR_OPND_NUM #define ir_op_kind_num IR_OPND_NUM
#define ir_op_kind_fld IR_OPND_STR #define ir_op_kind_fld IR_OPND_STR
#define ir_op_kind_var IR_OPND_VAR #define ir_op_kind_var IR_OPND_DATA
#define ir_op_kind_prb IR_OPND_PROB #define ir_op_kind_prb IR_OPND_PROB
#define ir_op_kind_opt IR_OPND_PROB #define ir_op_kind_opt IR_OPND_PROB

View File

@ -95,8 +95,7 @@ bool ir_check(const ir_ctx *ctx)
use_insn = &ctx->ir_base[use]; use_insn = &ctx->ir_base[use];
switch (IR_OPND_KIND(flags, j)) { switch (IR_OPND_KIND(flags, j)) {
case IR_OPND_DATA: case IR_OPND_DATA:
if (use_insn->op == IR_VAR if (!(ir_op_flags[use_insn->op] & IR_OP_FLAG_DATA)) {
|| !(ir_op_flags[use_insn->op] & IR_OP_FLAG_DATA)) {
if (!(ir_op_flags[use_insn->op] & IR_OP_FLAG_MEM) if (!(ir_op_flags[use_insn->op] & IR_OP_FLAG_MEM)
|| use_insn->type == IR_VOID) { || use_insn->type == IR_VOID) {
fprintf(stderr, "ir_base[%d].ops[%d] reference (%d) must be DATA\n", i, j, use); fprintf(stderr, "ir_base[%d].ops[%d] reference (%d) must be DATA\n", i, j, use);
@ -200,16 +199,6 @@ bool ir_check(const ir_ctx *ctx)
ok = 0; ok = 0;
} }
break; break;
case IR_OPND_VAR:
if (ctx->ir_base[use].op != IR_VAR) {
fprintf(stderr, "ir_base[%d].ops[%d] reference (%d) must be VAR\n", i, j, use);
ok = 0;
}
if (use >= i) {
fprintf(stderr, "ir_base[%d].ops[%d] invalid forward reference (%d)\n", i, j, use);
ok = 0;
}
break;
default: default:
fprintf(stderr, "ir_base[%d].ops[%d] reference (%d) of unsupported kind\n", i, j, use); fprintf(stderr, "ir_base[%d].ops[%d] reference (%d) of unsupported kind\n", i, j, use);
ok = 0; ok = 0;

View File

@ -105,7 +105,6 @@ void ir_dump_dot(const ir_ctx *ctx, FILE *f)
if (ref) { if (ref) {
switch (IR_OPND_KIND(flags, j)) { switch (IR_OPND_KIND(flags, j)) {
case IR_OPND_DATA: case IR_OPND_DATA:
case IR_OPND_VAR:
if (IR_IS_CONST_REF(ref)) { if (IR_IS_CONST_REF(ref)) {
fprintf(f, "\tc%d -> n%d [color=blue,weight=%d];\n", -ref, i, DATA_WEIGHT); fprintf(f, "\tc%d -> n%d [color=blue,weight=%d];\n", -ref, i, DATA_WEIGHT);
} else if (insn->op == IR_PHI } else if (insn->op == IR_PHI

View File

@ -801,10 +801,9 @@ IR_ALWAYS_INLINE bool ir_const_is_true(const ir_insn *v)
#define IR_OPND_CONTROL 0x2 #define IR_OPND_CONTROL 0x2
#define IR_OPND_CONTROL_DEP 0x3 #define IR_OPND_CONTROL_DEP 0x3
#define IR_OPND_CONTROL_REF 0x4 #define IR_OPND_CONTROL_REF 0x4
#define IR_OPND_VAR 0x5 #define IR_OPND_STR 0x5
#define IR_OPND_STR 0x6 #define IR_OPND_NUM 0x6
#define IR_OPND_NUM 0x7 #define IR_OPND_PROB 0x7
#define IR_OPND_PROB 0x8
#define IR_OP_FLAGS(op_flags, op1_flags, op2_flags, op3_flags) \ #define IR_OP_FLAGS(op_flags, op1_flags, op2_flags, op3_flags) \
((op_flags) | ((op1_flags) << 20) | ((op2_flags) << 24) | ((op3_flags) << 28)) ((op_flags) | ((op1_flags) << 20) | ((op2_flags) << 24) | ((op3_flags) << 28))
@ -818,7 +817,7 @@ IR_ALWAYS_INLINE bool ir_const_is_true(const ir_insn *v)
(((flags) >> (16 + (4 * (((i) > 3) ? 3 : (i))))) & 0xf) (((flags) >> (16 + (4 * (((i) > 3) ? 3 : (i))))) & 0xf)
#define IR_IS_REF_OPND_KIND(kind) \ #define IR_IS_REF_OPND_KIND(kind) \
((kind) >= IR_OPND_DATA && (kind) <= IR_OPND_VAR) ((kind) >= IR_OPND_DATA && (kind) <= IR_OPND_CONTROL_REF)
IR_ALWAYS_INLINE ir_ref ir_operands_count(const ir_ctx *ctx, const ir_insn *insn) IR_ALWAYS_INLINE ir_ref ir_operands_count(const ir_ctx *ctx, const ir_insn *insn)
{ {

View File

@ -70,7 +70,6 @@ void ir_save(const ir_ctx *ctx, FILE *f)
if (ref) { if (ref) {
switch (opnd_kind) { switch (opnd_kind) {
case IR_OPND_DATA: case IR_OPND_DATA:
case IR_OPND_VAR:
if (IR_IS_CONST_REF(ref)) { if (IR_IS_CONST_REF(ref)) {
fprintf(f, "%sc_%d", first ? "(" : ", ", -ref); fprintf(f, "%sc_%d", first ? "(" : ", ", -ref);
} else { } else {

View File

@ -737,21 +737,21 @@ int ir_sccp(ir_ctx *ctx)
_values[i+j+1].optx = IR_BOTTOM; /* keep the tail of a long multislot instruction */ _values[i+j+1].optx = IR_BOTTOM; /* keep the tail of a long multislot instruction */
} }
for (j = 2, p = insn->ops + j; j <= n; j++, p++) { for (j = 2, p = insn->ops + j; j <= n; j++, p++) {
IR_ASSERT(IR_OPND_KIND(flags, j) == IR_OPND_DATA || IR_OPND_KIND(flags, j) == IR_OPND_VAR); IR_ASSERT(IR_OPND_KIND(flags, j) == IR_OPND_DATA);
use = *p; use = *p;
if (use > 0 && UNEXPECTED(_values[use].optx == IR_TOP)) { if (use > 0 && UNEXPECTED(_values[use].optx == IR_TOP)) {
ir_bitqueue_add(&worklist, use); ir_bitqueue_add(&worklist, use);
} }
} }
} else if (n >= 2) { } else if (n >= 2) {
IR_ASSERT(IR_OPND_KIND(flags, 2) == IR_OPND_DATA || IR_OPND_KIND(flags, 2) == IR_OPND_VAR); IR_ASSERT(IR_OPND_KIND(flags, 2) == IR_OPND_DATA);
use = insn->op2; use = insn->op2;
if (use > 0 && UNEXPECTED(_values[use].optx == IR_TOP)) { if (use > 0 && UNEXPECTED(_values[use].optx == IR_TOP)) {
ir_bitqueue_add(&worklist, use); ir_bitqueue_add(&worklist, use);
} }
if (n > 2) { if (n > 2) {
IR_ASSERT(n == 3); IR_ASSERT(n == 3);
IR_ASSERT(IR_OPND_KIND(flags, 3) == IR_OPND_DATA || IR_OPND_KIND(flags, 3) == IR_OPND_VAR); IR_ASSERT(IR_OPND_KIND(flags, 3) == IR_OPND_DATA);
use = insn->op3; use = insn->op3;
if (use > 0 && UNEXPECTED(_values[use].optx == IR_TOP)) { if (use > 0 && UNEXPECTED(_values[use].optx == IR_TOP)) {
ir_bitqueue_add(&worklist, use); ir_bitqueue_add(&worklist, use);