]> Nishi Git Mirror - gwion.git/commitdiff
:art: Introduce RegPushBase
authorfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 20 Jan 2019 20:14:32 +0000 (21:14 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 20 Jan 2019 20:14:32 +0000 (21:14 +0100)
include/instr.h
src/emit/emit.c
src/lib/instr.c

index e35dd61051b5666f8516e74d956855af67152319..a1df23e1515c6b0c229540606eb915d65c128cd7 100644 (file)
@@ -47,6 +47,10 @@ INSTR(RegPushMem);
 INSTR(RegPushMem2);
 INSTR(RegPushMem3);
 INSTR(RegPushMem4);
+INSTR(RegPushBase);
+INSTR(RegPushBase2);
+INSTR(RegPushBase3);
+INSTR(RegPushBase4);
 INSTR(RegPushPtr);
 INSTR(RegPushCode);
 INSTR(RegDup);
index 4524f71c5d6af78a3e6f7fc832d2ec549380d4d3..d9b357c56beb4185bedd61fd67d31527fe667f2d 100644 (file)
@@ -237,6 +237,7 @@ ANN static Instr emit_kind(Emitter emit, const m_uint size, const uint addr, con
 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 };
@@ -289,9 +290,8 @@ ANN static m_bool emit_symbol(const Emitter emit, const Exp_Primary* prim) { GWD
       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;
 }
 
index 5671a30cb504caaef6eb3abef4d57a6471b9b173..b7c7c7edf5168a915bdfc23bd3e5b9419bdcbe5a 100644 (file)
@@ -87,25 +87,39 @@ INSTR(MemSetImm) { GWDEBUG_EXE
 
 #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;
 }