id = get_entity_ld_ident(ent);
be_emit_ident(env, id);
return;
- case ia32_ImmAsm:
case ia32_ImmNone:
break;
}
static
void emit_ia32_Asm(ia32_emit_env_t *env, const ir_node *node)
{
- const ia32_attr_t *attr = get_ia32_attr_const(node);
- ident *asm_text = attr->cnst_val.asm_text;
- const char *s = get_id_str(asm_text);
+ const void *gen_attr = get_irn_generic_attr_const(node);
+ const ia32_asm_attr_t *attr
+ = CONST_CAST_IA32_ATTR(ia32_asm_attr_t, gen_attr);
+ ident *asm_text = attr->asm_text;
+ const char *s = get_id_str(asm_text);
be_emit_cstring(env, "# Begin ASM \t");
be_emit_finish_line_gas(env, node);
ir_mode *mode = NULL;
int bad = 0;
int i, n_res, am_flav, flags;
- const ia32_attr_t *attr = get_ia32_attr_const(n);
const arch_register_req_t **reqs;
const arch_register_t **slots;
case ia32_ImmSymConst:
fprintf(F, "SymConst");
break;
- case ia32_ImmAsm:
- fprintf(F, "Asm '%s'\n",
- get_id_str(attr->cnst_val.asm_text));
- break;
default:
fprintf(F, "unknown (%d)", get_ia32_immop_type(n));
break;
#endif
}
+void
+init_ia32_asm_attributes(ir_node *res)
+{
+#ifndef NDEBUG
+ ia32_attr_t *attr = get_ia32_attr(res);
+ attr->attr_type |= IA32_ATTR_ia32_asm_attr_t;
+#endif
+}
+
ir_node *get_ia32_result_proj(const ir_node *node)
{
const ir_edge_t *edge;
if (a->data.imm_tp == ia32_ImmSymConst
&& a->cnst_val.sc != b->cnst_val.sc)
return 1;
- if(a->data.imm_tp == ia32_ImmAsm
- && a->cnst_val.asm_text != b->cnst_val.asm_text)
- return 1;
if (a->data.am_flavour != b->data.am_flavour
|| a->data.am_scale != b->data.am_scale
int n_res, unsigned latency);
void init_ia32_x87_attributes(ir_node *node);
+void init_ia32_asm_attributes(ir_node *node);
/**
* Registers the ia32_copy_attr function for all ia32 opcodes.
typedef enum {
ia32_ImmNone = 0,
ia32_ImmConst = 1,
- ia32_ImmSymConst = 2,
- ia32_ImmAsm = 3
+ ia32_ImmSymConst = 2
} ia32_immop_type_t;
typedef enum {
IA32_ATTR_INVALID = 0,
IA32_ATTR_ia32_attr_t = 1 << 0,
IA32_ATTR_ia32_x87_attr_t = 1 << 1,
+ IA32_ATTR_ia32_asm_attr_t = 1 << 2,
} ia32_attr_type_t;
#endif
union {
tarval *tv; /**< tarval for immediate operations */
ir_entity *sc; /**< the symconst ident */
- ident *asm_text; /**< used by asm node */
} cnst_val;
ir_mode *ls_mode; /**< Load/Store mode: This is the mode of the value
typedef struct ia32_x87_attr_t ia32_x87_attr_t;
struct ia32_x87_attr_t {
- ia32_attr_t attr;
+ ia32_attr_t attr;
const arch_register_t *x87[3]; /**< register slots for x87 register */
};
+typedef struct ia32_asm_attr_t ia32_asm_attr_t;
+struct ia32_asm_attr_t {
+ ia32_x87_attr_t x87_attr;
+ ident *asm_text;
+};
+
/* the following union is necessary to indicate to the compiler that we might want to cast
* the structs (we use them to simulate OO-inheritance) */
union allow_casts_attr_t_ {
ia32_attr_t attr;
ia32_x87_attr_t x87_attr;
+ ia32_asm_attr_t asm_attr;
};
#ifndef NDEBUG
ia32_x87_attr_t =>
"\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
"\tinit_ia32_x87_attributes(res);",
+ ia32_asm_attr_t =>
+ "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
+ "\tinit_ia32_x87_attributes(res);".
+ "\tinit_ia32_asm_attributes(res);"
+);
+
+%compare_attr = (
+ ia32_attr_t => "return ia32_compare_attr(attr_a, attr_b);",
+ ia32_x87_attr_t => "return ia32_compare_x87_attr(attr_a, attr_b);",
+ ia32_asm_attr_t => "return ia32_compare_asm_attr(attr_a, attr_b);"
);
%operands = (
mode => "mode_T",
arity => "variable",
out_arity => "variable",
+ attr_type => "ia32_asm_attr_t",
},
#-----------------------------------------------------------------#
int out_arity;
int n_outs;
int n_clobbers;
- ia32_attr_t *attr;
+ void *generic_attr;
+ ia32_asm_attr_t *attr;
const arch_register_req_t **out_reqs;
const arch_register_req_t **in_reqs;
struct obstack *obst;
res = new_rd_ia32_Asm(dbgi, irg, block, arity, in, out_arity);
- attr = get_ia32_attr(res);
- attr->cnst_val.asm_text = get_ASM_text(node);
- attr->data.imm_tp = ia32_ImmAsm;
+ generic_attr = get_irn_generic_attr(res);
+ attr = CAST_IA32_ATTR(ia32_asm_attr_t, generic_attr);
+ attr->asm_text = get_ASM_text(node);
set_ia32_out_req_all(res, out_reqs);
set_ia32_in_req_all(res, in_reqs);
our $default_cmp_attr;
our $default_attr_type;
our %init_attr;
+our %compare_attr;
# include spec file
my $cmpcode = $default_cmp_attr;
push(@obst_cmp_attr, "static int default_cmp_attr(ir_node *a, ir_node *b) {\n");
if($cmpcode =~ m/attr_a/) {
- push(@obst_cmp_attr, "\t${default_attr_type} *attr_a = get_irn_generic_attr(a);\n");
+ push(@obst_cmp_attr, "\tconst ${default_attr_type} *attr_a = get_irn_generic_attr_const(a);\n");
}
if($cmpcode =~ m/attr_b/) {
- push(@obst_cmp_attr, "\t${default_attr_type} *attr_b = get_irn_generic_attr(b);\n");
+ push(@obst_cmp_attr, "\tconst ${default_attr_type} *attr_b = get_irn_generic_attr_const(b);\n");
}
push(@obst_cmp_attr, "\t${cmpcode}\n");
push(@obst_cmp_attr, "}\n\n");
}
+# TODO: create compare functions
push(@obst_enum_op, "typedef enum _$arch\_opcodes {\n");
foreach my $op (keys(%nodes)) {