Commit a89ce28d authored by Matthias Braun's avatar Matthias Braun
Browse files

new ia32_asm_attr attribute, beware: attribute comparison does not take asm_attr into account yet

[r14330]
parent 242d96db
......@@ -276,7 +276,6 @@ void ia32_emit_immediate(ia32_emit_env_t *env, const ir_node *node)
id = get_entity_ld_ident(ent);
be_emit_ident(env, id);
return;
case ia32_ImmAsm:
case ia32_ImmNone:
break;
}
......@@ -1449,9 +1448,11 @@ const char* emit_asm_operand(ia32_emit_env_t *env, const ir_node *node,
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);
......
......@@ -124,7 +124,6 @@ static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
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;
......@@ -228,10 +227,6 @@ static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
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;
......@@ -1184,6 +1179,15 @@ init_ia32_x87_attributes(ir_node *res)
#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;
......@@ -1220,9 +1224,6 @@ int ia32_compare_attr(const ia32_attr_t *a, const ia32_attr_t *b) {
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
......
......@@ -491,6 +491,7 @@ void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
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.
......
......@@ -44,8 +44,7 @@ typedef enum {
typedef enum {
ia32_ImmNone = 0,
ia32_ImmConst = 1,
ia32_ImmSymConst = 2,
ia32_ImmAsm = 3
ia32_ImmSymConst = 2
} ia32_immop_type_t;
typedef enum {
......@@ -91,6 +90,7 @@ 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
......@@ -128,7 +128,6 @@ struct ia32_attr_t {
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
......@@ -155,15 +154,22 @@ struct ia32_attr_t {
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
......
......@@ -294,6 +294,16 @@ $default_attr_type = "ia32_attr_t";
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 = (
......@@ -320,6 +330,7 @@ Asm => {
mode => "mode_T",
arity => "variable",
out_arity => "variable",
attr_type => "ia32_asm_attr_t",
},
#-----------------------------------------------------------------#
......
......@@ -2769,7 +2769,8 @@ ir_node *gen_ASM(ir_node *node)
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;
......@@ -2848,9 +2849,9 @@ ir_node *gen_ASM(ir_node *node)
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);
......
......@@ -41,6 +41,7 @@ our %cpu;
our $default_cmp_attr;
our $default_attr_type;
our %init_attr;
our %compare_attr;
# include spec file
......@@ -98,14 +99,15 @@ if(defined($default_cmp_attr)) {
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)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment