return vreg;
}
+static inline guint32
+alloc_xreg (MonoCompile *cfg)
+{
+ return alloc_ireg (cfg);
+}
+
static inline guint32
alloc_dreg (MonoCompile *cfg, MonoStackType stack_type)
{
}
}
+/*
+ * Macros used to generate intermediate representation macros
+ *
+ * The macros use a `MonoConfig` object as its context, and among other
+ * things it is used to associate instructions with the memory pool with
+ * it.
+ *
+ * The macros come in three variations with slightly different
+ * features, the patter is: NEW_OP, EMIT_NEW_OP, MONO_EMIT_NEW_OP,
+ * the differences are as follows:
+ *
+ * `NEW_OP`: these are the basic macros to setup an instruction that is
+ * passed as an argument.
+ *
+ * `EMIT_NEW_OP`: these macros in addition to creating the instruction
+ * add the instruction to the current basic block in the `MonoConfig`
+ * object passed. Usually these are used when further customization of
+ * the `inst` parameter is desired before the instruction is added to the
+ * MonoConfig current basic block.
+ *
+ * `MONO_EMIT_NEW_OP`: These variations of the instructions are used when
+ * you are merely interested in emitting the instruction into the `MonoConfig`
+ * parameter.
+ */
#undef MONO_INST_NEW
/*
* FIXME: zeroing out some fields is not needed with the new IR, but the old
* JIT code still uses the left and right fields, so it has to stay.
*/
+
+/*
+ * MONO_INST_NEW: create a new MonoInst instance that is allocated on the MonoConfig pool.
+ *
+ * @cfg: the MonoConfig object that will be used as the context for the
+ * instruction.
+ * @dest: this is the place where the instance of the `MonoInst` is stored.
+ * @op: the value that should be stored in the MonoInst.opcode field
+ *
+ * This initializes an empty MonoInst that has been nulled out, it is allocated
+ * from the memory pool associated with the MonoConfig, but it is not linked anywhere.
+ * the cil_code is set to the cfg->ip address.
+ */
#define MONO_INST_NEW(cfg,dest,op) do { \
- (dest) = mono_mempool_alloc ((cfg)->mempool, sizeof (MonoInst)); \
+ (dest) = (MonoInst *)mono_mempool_alloc ((cfg)->mempool, sizeof (MonoInst)); \
(dest)->inst_c0 = (dest)->inst_c1 = 0; \
(dest)->next = (dest)->prev = NULL; \
(dest)->opcode = (op); \
#define NEW_AOTCONST(cfg,dest,patch_type,cons) do { \
MONO_INST_NEW ((cfg), (dest), cfg->compile_aot ? OP_AOTCONST : OP_PCONST); \
(dest)->inst_p0 = (cons); \
- (dest)->inst_i1 = (gpointer)(patch_type); \
+ (dest)->inst_i1 = (MonoInst *)(patch_type); \
(dest)->type = STACK_PTR; \
(dest)->dreg = alloc_dreg ((cfg), STACK_PTR); \
} while (0)
#define NEW_LDSTRLITCONST(cfg,dest,val) NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_LDSTR_LIT, (val))
-#define NEW_TYPE_FROM_HANDLE_CONST(cfg,dest,image,token,generic_context) NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_TYPE_FROM_HANDLE, (image), (token), (generic_context), STACK_OBJ, mono_defaults.monotype_class)
+#define NEW_TYPE_FROM_HANDLE_CONST(cfg,dest,image,token,generic_context) NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_TYPE_FROM_HANDLE, (image), (token), (generic_context), STACK_OBJ, mono_defaults.runtimetype_class)
#define NEW_LDTOKENCONST(cfg,dest,image,token,generic_context) NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_LDTOKEN, (image), (token), (generic_context), STACK_PTR, NULL)
-#define NEW_TLS_OFFSETCONST(cfg,dest,key) do { \
- if (cfg->compile_aot) { \
- NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_TLS_OFFSET, GINT_TO_POINTER (key)); \
- } else { \
- int _offset = mini_get_tls_offset ((key)); \
- NEW_PCONST ((cfg), (dest), GINT_TO_POINTER (_offset)); \
- } \
- } while (0)
-
#define NEW_DECLSECCONST(cfg,dest,image,entry) do { \
if (cfg->compile_aot) { \
NEW_AOTCONST_TOKEN (cfg, dest, MONO_PATCH_INFO_DECLSEC, image, (entry).index, NULL, STACK_OBJ, NULL); \
type_to_eval_stack_type ((cfg), (vartype), (dest)); \
(dest)->klass = var->klass; \
(dest)->sreg1 = var->dreg; \
- (dest)->dreg = alloc_dreg ((cfg), (dest)->type); \
+ (dest)->dreg = alloc_dreg ((cfg), (MonoStackType)(dest)->type); \
if ((dest)->opcode == OP_VMOVE) (dest)->klass = mono_class_from_mono_type ((vartype)); \
} while (0)
(dest)->dreg = alloc_dreg ((cfg), STACK_MP); \
(cfg)->has_indirection = TRUE; \
if (G_UNLIKELY (cfg->gsharedvt) && mini_is_gsharedvt_variable_type ((var)->inst_vtype)) { handle_gsharedvt_ldaddr ((cfg)); } \
- if (SIZEOF_REGISTER == 4 && DECOMPOSE_INTO_REGPAIR ((var)->type)) { MonoInst *var1 = get_vreg_to_inst (cfg, (var)->dreg + 1); MonoInst *var2 = get_vreg_to_inst (cfg, (var)->dreg + 2); g_assert (var1); g_assert (var2); var1->flags |= MONO_INST_INDIRECT; var2->flags |= MONO_INST_INDIRECT; } \
+ if (SIZEOF_REGISTER == 4 && DECOMPOSE_INTO_REGPAIR ((var)->type)) { MonoInst *var1 = get_vreg_to_inst (cfg, MONO_LVREG_LS ((var)->dreg)); MonoInst *var2 = get_vreg_to_inst (cfg, MONO_LVREG_MS ((var)->dreg)); g_assert (var1); g_assert (var2); var1->flags |= MONO_INST_INDIRECT; var2->flags |= MONO_INST_INDIRECT; } \
} while (0)
#define NEW_VARSTORE(cfg,dest,var,vartype,inst) do { \
(dest)->type = STACK_MP; \
(dest)->klass = cfg->ret->klass; \
(dest)->sreg1 = cfg->vret_addr->dreg; \
- (dest)->dreg = alloc_dreg ((cfg), (dest)->type); \
+ (dest)->dreg = alloc_dreg ((cfg), (MonoStackType)(dest)->type); \
} while (0)
#define NEW_ARGLOADA(cfg,dest,num) NEW_VARLOADA ((cfg), (dest), arg_array [(num)], param_types [(num)])
#define NEW_LOAD_MEMBASE_TYPE(cfg,dest,ltype,base,offset) do { \
NEW_LOAD_MEMBASE ((cfg), (dest), mono_type_to_load_membase ((cfg), (ltype)), 0, (base), (offset)); \
type_to_eval_stack_type ((cfg), (ltype), (dest)); \
- (dest)->dreg = alloc_dreg ((cfg), (dest)->type); \
+ (dest)->dreg = alloc_dreg ((cfg), (MonoStackType)(dest)->type); \
} while (0)
#define NEW_STORE_MEMBASE_TYPE(cfg,dest,ltype,base,offset,sr) do { \
#define EMIT_NEW_LDSTRLITCONST(cfg,dest,val) do { NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_LDSTR_LIT, (val)); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
-#define EMIT_NEW_TYPE_FROM_HANDLE_CONST(cfg,dest,image,token,generic_context) do { NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_TYPE_FROM_HANDLE, (image), (token), (generic_context), STACK_OBJ, mono_defaults.monotype_class); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
+#define EMIT_NEW_TYPE_FROM_HANDLE_CONST(cfg,dest,image,token,generic_context) do { NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_TYPE_FROM_HANDLE, (image), (token), (generic_context), STACK_OBJ, mono_defaults.runtimetype_class); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
#define EMIT_NEW_LDTOKENCONST(cfg,dest,image,token,generic_context) do { NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_LDTOKEN, (image), (token), (generic_context), STACK_PTR, NULL); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
* block_num: unique ID assigned at bblock creation
*/
#define NEW_BBLOCK(cfg,bblock) do { \
- (bblock) = mono_mempool_alloc0 ((cfg)->mempool, sizeof (MonoBasicBlock)); \
+ (bblock) = (MonoBasicBlock *)mono_mempool_alloc0 ((cfg)->mempool, sizeof (MonoBasicBlock)); \
(bblock)->block_num = cfg->num_bblocks++; \
} while (0)
MONO_ADD_INS ((cfg)->cbb, ins); \
MONO_START_BB ((cfg), falsebb); \
} else { \
- ins->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); \
+ ins->inst_many_bb = (MonoBasicBlock **)mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); \
ins->inst_true_bb = (truebb); \
ins->inst_false_bb = NULL; \
mono_link_bblock ((cfg), (cfg)->cbb, (truebb)); \
#define MONO_EMIT_NEW_BRANCH_BLOCK2(cfg,op,truebb,falsebb) do { \
MonoInst *ins; \
MONO_INST_NEW ((cfg), (ins), (op)); \
- ins->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); \
+ ins->inst_many_bb = (MonoBasicBlock **)mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); \
ins->inst_true_bb = (truebb); \
ins->inst_false_bb = (falsebb); \
mono_link_bblock ((cfg), (cfg)->cbb, (truebb)); \