From a89ce28d527ba6d9ae4069d1f86ae0f5edbb1f71 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Mon, 4 Jun 2007 15:14:42 +0000 Subject: [PATCH] new ia32_asm_attr attribute, beware: attribute comparison does not take asm_attr into account yet [r14330] --- ir/be/ia32/ia32_emitter.c | 9 +++++---- ir/be/ia32/ia32_new_nodes.c | 17 +++++++++-------- ir/be/ia32/ia32_new_nodes.h | 1 + ir/be/ia32/ia32_nodes_attr.h | 14 ++++++++++---- ir/be/ia32/ia32_spec.pl | 11 +++++++++++ ir/be/ia32/ia32_transform.c | 9 +++++---- ir/be/scripts/generate_new_opcodes.pl | 6 ++++-- 7 files changed, 45 insertions(+), 22 deletions(-) diff --git a/ir/be/ia32/ia32_emitter.c b/ir/be/ia32/ia32_emitter.c index bb1648cdb..2a3db45ba 100644 --- a/ir/be/ia32/ia32_emitter.c +++ b/ir/be/ia32/ia32_emitter.c @@ -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); diff --git a/ir/be/ia32/ia32_new_nodes.c b/ir/be/ia32/ia32_new_nodes.c index 2da3d88d4..508745534 100644 --- a/ir/be/ia32/ia32_new_nodes.c +++ b/ir/be/ia32/ia32_new_nodes.c @@ -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 diff --git a/ir/be/ia32/ia32_new_nodes.h b/ir/be/ia32/ia32_new_nodes.h index 83e724315..74093d3fb 100644 --- a/ir/be/ia32/ia32_new_nodes.h +++ b/ir/be/ia32/ia32_new_nodes.h @@ -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. diff --git a/ir/be/ia32/ia32_nodes_attr.h b/ir/be/ia32/ia32_nodes_attr.h index b40413b05..37ad31045 100644 --- a/ir/be/ia32/ia32_nodes_attr.h +++ b/ir/be/ia32/ia32_nodes_attr.h @@ -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 diff --git a/ir/be/ia32/ia32_spec.pl b/ir/be/ia32/ia32_spec.pl index 0582f82e7..c019c54fd 100644 --- a/ir/be/ia32/ia32_spec.pl +++ b/ir/be/ia32/ia32_spec.pl @@ -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", }, #-----------------------------------------------------------------# diff --git a/ir/be/ia32/ia32_transform.c b/ir/be/ia32/ia32_transform.c index 90194922d..5e8e60eb4 100644 --- a/ir/be/ia32/ia32_transform.c +++ b/ir/be/ia32/ia32_transform.c @@ -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); diff --git a/ir/be/scripts/generate_new_opcodes.pl b/ir/be/scripts/generate_new_opcodes.pl index 7f40f2bde..52c903973 100755 --- a/ir/be/scripts/generate_new_opcodes.pl +++ b/ir/be/scripts/generate_new_opcodes.pl @@ -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)) { -- 2.20.1