static const f_instr regpushimm[] = { RegPushImm, RegPushImm2, RegPushImm3, RegPushDeref }; // caution last
static const f_instr regpushderef[] = { RegPushDeref, RegPushDeref2, RegPushDeref3, RegPushDeref }; // caution last
static const f_instr regpushmem[] = { RegPushMem, RegPushMem2, RegPushMem3, RegPushMem4 };
+static const f_instr regpushbase[] = { RegPushBase, RegPushBase2, RegPushBase3, RegPushBase4 };
static const f_instr dotstatic[] = { DotStatic, DotStatic2, DotStatic3, DotStatic4 };
static const f_instr dotimport[] = { DotImport, DotImport2, DotImport3, DotImport4 };
static const f_instr dotmember[] = { DotMember, DotMember2, DotMember3, DotMember4 };
GET_FLAG(v, union))
return emit_symbol_builtin(emit, prim);
const m_uint size = v->type->size;
- const Instr instr = emit_kind(emit, size, prim->self->emit_var, regpushmem);
+ const Instr instr = emit_kind(emit, size, prim->self->emit_var, !GET_FLAG(v, global) ? regpushmem : regpushbase);
instr->m_val = v->offset;
- *(m_uint*)instr->ptr = GET_FLAG(v, global);
return GW_OK;
}
#define describe_regpushxxx(name, type, size) \
INSTR(RegPush##name) { GWDEBUG_EXE \
- const m_bit* data = *(m_uint*)instr->ptr ? shred->base : shred->mem; \
- *(type*)REG(0) = *(type*)(data + instr->m_val); \
+ *(type*)REG(0) = *(type*)(shred->mem + instr->m_val); \
PUSH_REG(shred, size); \
}
describe_regpushxxx(Mem, m_int, SZ_INT)
describe_regpushxxx(Mem2, m_float, SZ_FLOAT)
INSTR(RegPushMem3) { GWDEBUG_EXE
- const m_bit* data = *(m_uint*)instr->ptr ? shred->base : shred->mem;
- memcpy(REG(0), (data + instr->m_val), instr->m_val2);
+ memcpy(REG(0), (shred->mem + instr->m_val), instr->m_val2);
PUSH_REG(shred, instr->m_val2);
}
INSTR(RegPushMem4) { GWDEBUG_EXE
- const m_bit* data = *(m_uint*)instr->ptr ? shred->base : shred->mem;
- *(m_bit**)REG(0) = (m_bit*)(data + instr->m_val);
+ *(m_bit**)REG(0) = (m_bit*)(shred->mem + instr->m_val);
PUSH_REG(shred, SZ_INT);
}
+#define describe_regpushbase(name, type, size) \
+INSTR(RegPush##name) { GWDEBUG_EXE \
+ *(type*)REG(0) = *(type*)(shred->base + instr->m_val); \
+ PUSH_REG(shred, size); \
+}
+
+describe_regpushbase(Base, m_int, SZ_INT)
+describe_regpushbase(Base2, m_float, SZ_FLOAT)
+INSTR(RegPushBase3) { GWDEBUG_EXE
+ memcpy(REG(0), (shred->base + instr->m_val), instr->m_val2);
+ PUSH_REG(shred, instr->m_val2);
+}
+INSTR(RegPushBase4) { GWDEBUG_EXE
+ *(m_bit**)REG(0) = (m_bit*)(shred->base + instr->m_val);
+ PUSH_REG(shred, SZ_INT);
+}
+
INSTR(RegPushPtr) { GWDEBUG_EXE
*(m_uint*)REG(-SZ_INT) = instr->m_val;
}