From: Wolfgang Bumiller Date: Tue, 1 May 2012 09:58:52 +0000 (+0200) Subject: ir_block_create_storep for storing through pointers, the IR does not implicitly creat... X-Git-Tag: 0.1-rc1~543 X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=340daeabc43b7ef290797ed3c791ef2d08dd2a12;p=xonotic%2Fgmqcc.git ir_block_create_storep for storing through pointers, the IR does not implicitly create conversions for now when using pointers, but it could --- diff --git a/ir.c b/ir.c index f2e0cae..7e66459 100644 --- a/ir.c +++ b/ir.c @@ -623,6 +623,56 @@ bool ir_block_create_store(ir_block *self, ir_value *target, ir_value *what) op = INSTR_STORE_ENT; #endif break; + default: + /* Unknown type */ + return false; + } + return ir_block_create_store_op(self, op, target, what); +} + +bool ir_block_create_storep(ir_block *self, ir_value *target, ir_value *what) +{ + int op = 0; + int vtype; + if (target->vtype == TYPE_VARIANT) + vtype = what->vtype; + else + vtype = target->vtype; + + if (vtype != what->vtype) + { + /* Cannot implicitly convert when storing through a pointer */ + return false; + } + + switch (vtype) { + case TYPE_FLOAT: + op = INSTR_STOREP_F; + break; + case TYPE_VECTOR: + op = INSTR_STOREP_V; + break; + case TYPE_ENTITY: + op = INSTR_STOREP_ENT; + break; + case TYPE_STRING: + op = INSTR_STOREP_S; + break; +#if 0 + case TYPE_INTEGER: + op = INSTR_STOREP_I; + break; +#endif + case TYPE_POINTER: +#if 0 + op = INSTR_STOREP_I; +#else + op = INSTR_STOREP_ENT; +#endif + break; + default: + /* Unknown type */ + return false; } return ir_block_create_store_op(self, op, target, what); } diff --git a/ir.h b/ir.h index 592f69c..bcc590b 100644 --- a/ir.h +++ b/ir.h @@ -150,6 +150,7 @@ ir_value* ir_block_create_binop(ir_block*, const char *label, int op, ir_value *left, ir_value *right); bool GMQCC_WARN ir_block_create_store_op(ir_block*, int op, ir_value *target, ir_value *what); bool GMQCC_WARN ir_block_create_store(ir_block*, ir_value *target, ir_value *what); +bool GMQCC_WARN ir_block_create_storep(ir_block*, ir_value *target, ir_value *what); ir_value* ir_block_create_add(ir_block*, const char *label, ir_value *l, ir_value *r); ir_value* ir_block_create_sub(ir_block*, const char *label, ir_value *l, ir_value *r);