mirror of
https://github.com/danog/ir.git
synced 2024-11-30 04:39:43 +01:00
Add type checks for LOAD/STORE and VLOAD/VSTORE
This commit is contained in:
parent
1773bb81aa
commit
aada927840
23
ir_check.c
23
ir_check.c
@ -72,6 +72,7 @@ bool ir_check(ir_ctx *ctx)
|
||||
{
|
||||
ir_ref i, j, n, *p, use;
|
||||
ir_insn *insn, *use_insn;
|
||||
ir_type type;
|
||||
uint32_t flags;
|
||||
bool ok = 1;
|
||||
|
||||
@ -232,6 +233,28 @@ bool ir_check(ir_ctx *ctx)
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
switch (insn->op) {
|
||||
case IR_LOAD:
|
||||
case IR_STORE:
|
||||
type = ctx->ir_base[insn->op2].type;
|
||||
if (type != IR_ADDR
|
||||
&& (!IR_IS_TYPE_INT(type) || ir_type_size[type] != ir_type_size[IR_ADDR])) {
|
||||
fprintf(stderr, "ir_base[%d].op2 must have ADDR type (%s)\n",
|
||||
i, ir_type_name[type]);
|
||||
ok = 0;
|
||||
}
|
||||
break;
|
||||
case IR_VLOAD:
|
||||
case IR_VSTORE:
|
||||
if (ctx->ir_base[insn->op2].op != IR_VAR) {
|
||||
fprintf(stderr, "ir_base[%d].op2 must be 'VAR' (%s)\n",
|
||||
i, ir_op_name[ctx->ir_base[insn->op2].op]);
|
||||
ok = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (ctx->use_lists) {
|
||||
ir_use_list *use_list = &ctx->use_lists[i];
|
||||
ir_ref count;
|
||||
|
Loading…
Reference in New Issue
Block a user