From ba873a5483697d4ff93e3980d7b6a1b5cbc491b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20W=C3=BCrdig?= Date: Fri, 13 Jan 2006 13:34:44 +0000 Subject: [PATCH] refactored nodes interface, completed set/get attr methods added addr mode attributes --- ir/be/ia32/bearch_ia32.c | 8 +- ir/be/ia32/ia32_emitter.c | 2 +- ir/be/ia32/ia32_new_nodes.c | 277 ++++++++++++++++++++++++----------- ir/be/ia32/ia32_new_nodes.h | 227 +++++++++++++++++++++++++--- ir/be/ia32/ia32_nodes_attr.h | 41 ++++-- ir/be/ia32/ia32_transform.c | 8 +- 6 files changed, 430 insertions(+), 133 deletions(-) diff --git a/ir/be/ia32/bearch_ia32.c b/ir/be/ia32/bearch_ia32.c index f62378363..0e9f54b39 100644 --- a/ir/be/ia32/bearch_ia32.c +++ b/ir/be/ia32/bearch_ia32.c @@ -56,7 +56,7 @@ static ir_node *my_skip_proj(const ir_node *n) { * will be asked for this information. */ static const arch_register_req_t *ia32_get_irn_reg_req(const arch_irn_ops_t *self, arch_register_req_t *req, const ir_node *irn, int pos) { - const arch_register_req_t **irn_req; + const arch_register_req_t *irn_req; long node_pos = pos == -1 ? 0 : pos; ir_mode *mode = get_irn_mode(irn); firm_dbg_module_t *mod = firm_dbg_register(DEBUG_MODULE); @@ -81,16 +81,16 @@ static const arch_register_req_t *ia32_get_irn_reg_req(const arch_irn_ops_t *sel if (is_ia32_irn(irn)) { if (pos >= 0) { - irn_req = get_ia32_in_req(irn); + irn_req = get_ia32_in_req(irn, pos); } else { - irn_req = get_ia32_out_req(irn); + irn_req = get_ia32_out_req(irn, pos); pos = node_pos; } DBG((mod, LEVEL_1, "returning reqs for %+F at pos %d\n", irn, pos)); - memcpy(req, irn_req[pos], sizeof(*req)); + memcpy(req, irn_req, sizeof(*req)); return req; } else { diff --git a/ir/be/ia32/ia32_emitter.c b/ir/be/ia32/ia32_emitter.c index f3059a1da..e9f9f651e 100644 --- a/ir/be/ia32/ia32_emitter.c +++ b/ir/be/ia32/ia32_emitter.c @@ -56,7 +56,7 @@ const char *node_const_to_str(ir_node *n) { */ char *node_offset_to_str(ir_node *n) { char *buf; - tarval *tv = get_ia32_offs(n); + tarval *tv = get_ia32_am_offs(n); if (tv) { buf = malloc(SNPRINTF_BUF_LEN); diff --git a/ir/be/ia32/ia32_new_nodes.c b/ir/be/ia32/ia32_new_nodes.c index bfc0f2303..56687b5ac 100644 --- a/ir/be/ia32/ia32_new_nodes.c +++ b/ir/be/ia32/ia32_new_nodes.c @@ -148,7 +148,7 @@ static int dump_node_ia32(ir_node *n, FILE *F, dump_reason_t reason) { /* dump IN requirements */ if (get_irn_arity(n) > 0) { - reqs = get_ia32_in_req(n); + reqs = get_ia32_in_req_all(n); if (reqs) { for (i = 0; i < get_irn_arity(n); i++) { @@ -169,7 +169,7 @@ static int dump_node_ia32(ir_node *n, FILE *F, dump_reason_t reason) { /* dump OUT requirements */ if (attr->n_res > 0) { - reqs = get_ia32_out_req(n); + reqs = get_ia32_out_req_all(n); if (reqs) { for (i = 0; i < attr->n_res; i++) { @@ -201,13 +201,9 @@ static int dump_node_ia32(ir_node *n, FILE *F, dump_reason_t reason) { /* special for LEA */ if (is_ia32_Lea(n) || is_ia32_Lea_i(n)) { - tarval *o = get_ia32_offs(n); + tarval *o = get_ia32_am_offs(n); tarval *tv = get_ia32_Immop_tarval(n); - if (is_ia32_AddrMode(n)) { - fprintf(F, "AddrMode "); - } - fprintf(F, "LEA "); if (o) { fprintf_tv(F, o, 0); @@ -249,100 +245,80 @@ static int dump_node_ia32(ir_node *n, FILE *F, dump_reason_t reason) { * Firm was made by people hating const :-( */ asmop_attr *get_ia32_attr(const ir_node *node) { - return (asmop_attr *)get_irn_generic_attr((ir_node *)node); + assert(is_ia32_irn(node) && "need ia32 node to get ia32 attributes"); + return (asmop_attr *)get_irn_generic_attr((ir_node *)node); } /** - * Return the tarval of an immediate operation or NULL in case of SymConst + * Gets the type of an ia32 node. */ -tarval *get_ia32_Immop_tarval(const ir_node *node) { - asmop_attr *attr = get_ia32_attr(node); - if (attr->tp == asmop_Const) - return attr->tv; - else - return NULL; +asmop_type_t get_ia32_op_type(const ir_node *node) { + asmop_attr *attr = get_ia32_attr(node); + return attr->tp; } /** - * Return the old_ir attribute. + * Sets the type of an ia32 node. */ -ir_node *get_ia32_old_ir(const ir_node *node) { - asmop_attr *attr = get_ia32_attr(node); - return attr->old_ir; +void set_ia32_op_type(const ir_node *node, asmop_type_t tp) { + asmop_attr *attr = get_ia32_attr(node); + attr->tp = tp; } /** - * Copy the attributes from an ia32_Const to an Immop (Add_i, Sub_i, ...) node + * Gets the addr mode type of an ia32 node */ -void set_ia32_Immop_attr(ir_node *node, ir_node *cnst) { - asmop_attr *na = get_ia32_attr(node); - asmop_attr *ca = get_ia32_attr(cnst); - - assert((is_ia32_Const(cnst) || is_ia32_fConst(cnst)) && "Need ia32_Const to set Immop attr"); - - na->tp = ca->tp; - na->tv = ca->tv; - - if (ca->old_ir) { - na->old_ir = calloc(1, sizeof(*(ca->old_ir))); - memcpy(na->old_ir, ca->old_ir, sizeof(*(ca->old_ir))); - } - else - na->old_ir = NULL; +addrmode_type_t get_ia32_am_type(const ir_node *node) { + asmop_attr *attr = get_ia32_attr(node); + return attr->am_tp; } /** - * Copy the attributes from a Const to an ia32_Const + * Sets the addr mode type of an ia32 node */ -void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst) { - asmop_attr *attr = get_ia32_attr(ia32_cnst); - - assert((is_ia32_Const(ia32_cnst) || is_ia32_fConst(ia32_cnst)) && "Need ia32_Const to set Const attr"); - - switch (get_irn_opcode(cnst)) { - case iro_Const: - attr->tp = asmop_Const; - attr->tv = get_Const_tarval(cnst); - break; - case iro_SymConst: - attr->tp = asmop_SymConst; - attr->old_ir = calloc(1, sizeof(*cnst)); - memcpy(attr->old_ir, cnst, sizeof(*cnst)); - break; - case iro_Unknown: - assert(0 && "Unknown Const NYI"); - break; - default: - assert(0 && "Cannot create ia32_Const for this opcode"); - } +void set_ia32_am_type(const ir_node *node, addrmode_type_t am_tp) { + asmop_attr *attr = get_ia32_attr(node); + attr->am_tp = am_tp; } /** - * Sets the type of an ia32_Const. + * Gets the addr mode offset. */ -void set_ia32_Const_type(ir_node *node, int type) { +tarval *get_ia32_am_offs(const ir_node *node) { asmop_attr *attr = get_ia32_attr(node); + return attr->am_offs; +} - assert((is_ia32_Const(node) || is_ia32_fConst(node)) && "Need ia32_Const to set type"); - assert((type == asmop_Const || type == asmop_SymConst) && "Unsupported ia32_Const type"); +/** + * Sets the offset for addr mode. + */ +void set_ia32_am_offs(ir_node *node, tarval *am_offs) { + asmop_attr *attr = get_ia32_attr(node); + attr->am_offs = am_offs; +} - attr->tp = type; +/** + * Gets the addr mode const. + */ +tarval *get_ia32_am_const(const ir_node *node) { + asmop_attr *attr = get_ia32_attr(node); + return attr->am_const; } /** - * Sets the AddrMode attribute + * Sets the const for addr mode. */ -void set_ia32_AddrMode(ir_node *node) { +void set_ia32_am_const(ir_node *node, tarval *am_const) { asmop_attr *attr = get_ia32_attr(node); - attr->tp = asmop_AddrMode; + attr->am_const = am_const; } /** - * Returns whether or not the node is an AddrMode node. + * Return the tarval of an immediate operation or NULL in case of SymConst */ -int is_ia32_AddrMode(ir_node *node) { +tarval *get_ia32_Immop_tarval(const ir_node *node) { asmop_attr *attr = get_ia32_attr(node); - return (attr->tp == asmop_AddrMode); + return attr->tv; } /** @@ -350,31 +326,29 @@ int is_ia32_AddrMode(ir_node *node) { */ void set_ia32_Immop_tarval(ir_node *node, tarval *tv) { asmop_attr *attr = get_ia32_attr(node); - - attr->tp = asmop_Const; attr->tv = tv; } /** - * Sets the offset for a Lea. + * Return the old_ir attribute. */ -void set_ia32_offs(ir_node *node, tarval *offs) { - asmop_attr *attr = get_ia32_attr(node); - attr->offset = offs; +ir_node *get_ia32_old_ir(const ir_node *node) { + asmop_attr *attr = get_ia32_attr(node); + return attr->old_ir; } /** - * Gets the offset for a Lea. + * Sets the old_ir attribute. */ -tarval *get_ia32_offs(const ir_node *node) { - asmop_attr *attr = get_ia32_attr(node); - return attr->offset; +void set_ia32_old_ir(ir_node *node, ir_node *old_ir) { + asmop_attr *attr = get_ia32_attr(node); + attr->old_ir = old_ir; } /** * Returns the argument register requirements of an ia32 node. */ -const arch_register_req_t **get_ia32_in_req(const ir_node *node) { +const arch_register_req_t **get_ia32_in_req_all(const ir_node *node) { asmop_attr *attr = get_ia32_attr(node); return attr->in_req; } @@ -382,15 +356,31 @@ const arch_register_req_t **get_ia32_in_req(const ir_node *node) { /** * Returns the result register requirements of an ia32 node. */ -const arch_register_req_t **get_ia32_out_req(const ir_node *node) { +const arch_register_req_t **get_ia32_out_req_all(const ir_node *node) { asmop_attr *attr = get_ia32_attr(node); return attr->out_req; } +/** + * Returns the argument register requirement at position pos of an ia32 node. + */ +const arch_register_req_t *get_ia32_in_req(const ir_node *node, int pos) { + asmop_attr *attr = get_ia32_attr(node); + return attr->in_req[pos]; +} + +/** + * Returns the result register requirement at position pos of an ia32 node. + */ +const arch_register_req_t *get_ia32_out_req(const ir_node *node, int pos) { + asmop_attr *attr = get_ia32_attr(node); + return attr->out_req[pos]; +} + /** * Sets the OUT register requirements at position pos. */ -void set_ia32_regreq_out(ir_node *node, const arch_register_req_t *req, int pos) { +void set_ia32_req_out(ir_node *node, const arch_register_req_t *req, int pos) { asmop_attr *attr = get_ia32_attr(node); attr->out_req[pos] = req; } @@ -398,7 +388,7 @@ void set_ia32_regreq_out(ir_node *node, const arch_register_req_t *req, int pos) /** * Sets the IN register requirements at position pos. */ -void set_ia32_regreq_in(ir_node *node, const arch_register_req_t *req, int pos) { +void set_ia32_req_in(ir_node *node, const arch_register_req_t *req, int pos) { asmop_attr *attr = get_ia32_attr(node); attr->in_req[pos] = req; } @@ -411,6 +401,14 @@ arch_irn_flags_t get_ia32_flags(const ir_node *node) { return attr->flags; } +/** + * Sets the register flag of an ia32 node. + */ +void set_ia32_flags(const ir_node *node, arch_irn_flags_t flags) { + asmop_attr *attr = get_ia32_attr(node); + attr->flags = flags; +} + /** * Returns the result register slots of an ia32 node. */ @@ -429,7 +427,7 @@ const char *get_ia32_out_reg_name(const ir_node *node, int pos) { assert(pos < attr->n_res && "Invalid OUT position."); assert(attr->slots[pos] && "No register assigned"); - return attr->slots[pos]->name; + return arch_register_get_name(attr->slots[pos]); } /** @@ -442,7 +440,7 @@ int get_ia32_out_regnr(const ir_node *node, int pos) { assert(pos < attr->n_res && "Invalid OUT position."); assert(attr->slots[pos] && "No register assigned"); - return attr->slots[pos]->index; + return arch_register_get_index(attr->slots[pos]); } /** @@ -463,7 +461,7 @@ const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos) { */ void set_ia32_n_res(ir_node *node, int n_res) { asmop_attr *attr = get_ia32_attr(node); - attr->n_res = n_res; + attr->n_res = n_res; } /** @@ -474,6 +472,14 @@ int get_ia32_n_res(const ir_node *node) { return attr->n_res; } +/** + * Returns the flavour of an ia32 DivMod, + */ +divmod_flavour_t get_ia32_DivMod_flavour(const ir_node *node) { + asmop_attr *attr = get_ia32_attr(node); + return attr->dm_flav; +} + /** * Sets the flavour of an ia32 DivMod node to flavour_Div/Mod/DivMod. */ @@ -495,7 +501,106 @@ long get_ia32_pncode(const ir_node *node) { */ void set_ia32_pncode(ir_node *node, long code) { asmop_attr *attr = get_ia32_attr(node); - attr->pn_code = code; + attr->pn_code = code; +} + + +/****************************************************************************************************** + * _ _ _ _ __ _ _ + * (_) | | | | | | / _| | | (_) + * ___ _ __ ___ ___ _ __ _| | __ _| |_| |_ _ __ | |_ _ _ _ __ ___| |_ _ ___ _ __ ___ + * / __| '_ \ / _ \/ __| |/ _` | | / _` | __| __| '__| | _| | | | '_ \ / __| __| |/ _ \| '_ \ / __| + * \__ \ |_) | __/ (__| | (_| | | | (_| | |_| |_| | | | | |_| | | | | (__| |_| | (_) | | | | \__ \ + * |___/ .__/ \___|\___|_|\__,_|_| \__,_|\__|\__|_| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/ + * | | + * |_| + ******************************************************************************************************/ + +/** + * Gets the type of an ia32_Const. + */ +unsigned get_ia32_Const_type(ir_node *node) { + asmop_attr *attr = get_ia32_attr(node); + + assert((is_ia32_Const(node) || is_ia32_fConst(node)) && "Need ia32_Const to get type"); + + return attr->tp; +} + +/** + * Sets the type of an ia32_Const. + */ +void set_ia32_Const_type(ir_node *node, int type) { + asmop_attr *attr = get_ia32_attr(node); + + assert((is_ia32_Const(node) || is_ia32_fConst(node)) && "Need ia32_Const to set type"); + assert((type == asmop_Const || type == asmop_SymConst) && "Unsupported ia32_Const type"); + + attr->tp = type; +} + +/** + * Copy the attributes from an ia32_Const to an Immop (Add_i, Sub_i, ...) node + */ +void set_ia32_Immop_attr(ir_node *node, ir_node *cnst) { + asmop_attr *na = get_ia32_attr(node); + asmop_attr *ca = get_ia32_attr(cnst); + + assert((is_ia32_Const(cnst) || is_ia32_fConst(cnst)) && "Need ia32_Const to set Immop attr"); + + na->tp = ca->tp; + na->tv = ca->tv; + + if (ca->old_ir) { + na->old_ir = calloc(1, sizeof(*(ca->old_ir))); + memcpy(na->old_ir, ca->old_ir, sizeof(*(ca->old_ir))); + } + else { + na->old_ir = NULL; + } +} + +/** + * Copy the attributes from a Const to an ia32_Const + */ +void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst) { + asmop_attr *attr = get_ia32_attr(ia32_cnst); + + assert((is_ia32_Const(ia32_cnst) || is_ia32_fConst(ia32_cnst)) && "Need ia32_Const to set Const attr"); + + switch (get_irn_opcode(cnst)) { + case iro_Const: + attr->tp = asmop_Const; + attr->tv = get_Const_tarval(cnst); + break; + case iro_SymConst: + attr->tp = asmop_SymConst; + attr->tv = NULL; + attr->old_ir = calloc(1, sizeof(*cnst)); + memcpy(attr->old_ir, cnst, sizeof(*cnst)); + break; + case iro_Unknown: + assert(0 && "Unknown Const NYI"); + break; + default: + assert(0 && "Cannot create ia32_Const for this opcode"); + } +} + +/** + * Sets the AddrMode attribute + */ +void set_ia32_AddrMode(ir_node *node) { + asmop_attr *attr = get_ia32_attr(node); + attr->tp = asmop_AddrMode; +} + +/** + * Returns whether or not the node is an AddrMode node. + */ +int is_ia32_AddrMode(ir_node *node) { + asmop_attr *attr = get_ia32_attr(node); + return (attr->tp == asmop_AddrMode); } /* Include the generated functions */ diff --git a/ir/be/ia32/ia32_new_nodes.h b/ir/be/ia32/ia32_new_nodes.h index 7de92b38d..82f1b3f77 100644 --- a/ir/be/ia32/ia32_new_nodes.h +++ b/ir/be/ia32/ia32_new_nodes.h @@ -9,44 +9,225 @@ #include "ia32_nodes_attr.h" +/** + * Returns the name of a firm symconst. + */ +const char *get_sc_name(ir_node *symc); + + + +/*************************************************************************************************** + * _ _ _ __ _ _ _ _ + * | | | | | | / / | | | | | | | | + * __ _| |_| |_ _ __ ___ ___| |_ / /_ _ ___| |_ _ __ ___ ___| |_| |__ ___ __| |___ + * / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __| + * | (_| | |_| |_| | \__ \ __/ |_ / / (_| | __/ |_ | | | | | | __/ |_| | | | (_) | (_| \__ \ + * \__,_|\__|\__|_| |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/ + * __/ | + * |___/ + ***************************************************************************************************/ + +/** + * Returns the attributes of an ia32 node. + */ asmop_attr *get_ia32_attr(const ir_node *node); -ir_node *get_ia32_old_ir(const ir_node *node); +/** + * Gets the type of an ia32 node. + */ +asmop_type_t get_ia32_op_type(const ir_node *node); -const char *get_sc_name(ir_node *symc); +/** + * Sets the type of an ia32 node. + */ +void set_ia32_op_type(const ir_node *node, asmop_type_t tp); + +/** + * Gets the addr mode type of an ia32 node + */ +addrmode_type_t get_ia32_am_type(const ir_node *node); + +/** + * Sets the addr mode type of an ia32 node + */ +void set_ia32_am_type(const ir_node *node, addrmode_type_t am_tp); + +/** + * Gets the addr mode offset. + */ +tarval *get_ia32_am_offs(const ir_node *node); -void set_ia32_Immop_attr(ir_node *node, ir_node *imm); +/** + * Sets the offset for addr mode. + */ +void set_ia32_am_offs(ir_node *node, tarval *am_offs); + +/** + * Gets the addr mode const. + */ +tarval *get_ia32_am_const(const ir_node *node); + +/** + * Sets the const for addr mode. + */ +void set_ia32_am_const(ir_node *node, tarval *am_const); + +/** + * Return the tarval of an immediate operation or NULL in case of SymConst + */ tarval *get_ia32_Immop_tarval(const ir_node *node); -void set_ia32_Immop_tarval(ir_node *node, tarval *tv); -void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst); -void set_ia32_Const_type(ir_node *node, int type); +/** + * Sets the attributes of an immediate operation to the specified tarval + */ +void set_ia32_Immop_tarval(ir_node *node, tarval *tv); -void set_ia32_AddrMode(ir_node *node); -int is_ia32_AddrMode(ir_node *node); +/** + * Return the old_ir attribute. + */ +ir_node *get_ia32_old_ir(const ir_node *node); -void set_ia32_pncode(ir_node *node, long code); -long get_ia32_pncode(const ir_node *node); +/** + * Sets the old_ir attribute. + */ +void set_ia32_old_ir(ir_node *node, ir_node *old_ir); -void set_ia32_offs(ir_node *node, tarval *offs); -tarval *get_ia32_offs(const ir_node *node); -void set_ia32_n_res(ir_node *node, int n_res); -int get_ia32_n_res(const ir_node *node); +/** + * Returns the argument register requirements of an ia32 node. + */ +const arch_register_req_t **get_ia32_in_req_all(const ir_node *node); -void set_ia32_DivMod_flavour(ir_node *node, divmod_flavour_t dm_flav); +/** + * Returns the result register requirements of an ia32 node. + */ +const arch_register_req_t **get_ia32_out_req_all(const ir_node *node); + +/** + * Returns the argument register requirements of an ia32 node. + */ +const arch_register_req_t *get_ia32_in_req(const ir_node *node, int pos); + +/** + * Returns the result register requirements of an ia32 node. + */ +const arch_register_req_t *get_ia32_out_req(const ir_node *node, int pos); + +/** + * Sets the OUT register requirements at position pos. + */ +void set_ia32_req_out(ir_node *node, const arch_register_req_t *req, int pos); + +/** + * Sets the IN register requirements at position pos. + */ +void set_ia32_req_in(ir_node *node, const arch_register_req_t *req, int pos); + +/** + * Returns the register flag of an ia32 node. + */ +arch_irn_flags_t get_ia32_flags(const ir_node *node); + +/** + * Sets the register flag of an ia32 node. + */ +void set_ia32_flags(const ir_node *node, arch_irn_flags_t flags); + +/** + * Returns the result register slots of an ia32 node. + */ +const arch_register_t **get_ia32_slots(const ir_node *node); -arch_irn_flags_t get_ia32_flags(const ir_node *node); -const arch_register_req_t **get_ia32_in_req(const ir_node *node); -const arch_register_req_t **get_ia32_out_req(const ir_node *node); -const arch_register_t **get_ia32_slots(const ir_node *node); +/** + * Returns the name of the OUT register at position pos. + */ +const char *get_ia32_out_reg_name(const ir_node *node, int pos); -void set_ia32_regreq_out(ir_node *node, const arch_register_req_t *req, int pos); -void set_ia32_regreq_in(ir_node *node, const arch_register_req_t *req, int pos); +/** + * Returns the index of the OUT register at position pos within its register class. + */ +int get_ia32_out_regnr(const ir_node *node, int pos); -const char *get_ia32_out_reg_name(const ir_node *node, int pos); -int get_ia32_out_regnr(const ir_node *node, int pos); +/** + * Returns the OUT register at position pos. + */ const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos); +/** + * Sets the number of results. + */ +void set_ia32_n_res(ir_node *node, int n_res); + +/** + * Returns the number of results. + */ +int get_ia32_n_res(const ir_node *node); + +/** + * Returns the flavour of an ia32 DivMod, + */ +divmod_flavour_t get_ia32_DivMod_flavour(const ir_node *node); + +/** + * Sets the flavour of an ia32 DivMod node to flavour_Div/Mod/DivMod. + */ +void set_ia32_DivMod_flavour(ir_node *node, divmod_flavour_t dm_flav); + +/** + * Returns the projnum code. + */ +long get_ia32_pncode(const ir_node *node); + +/** + * Sets the projnum code + */ +void set_ia32_pncode(ir_node *node, long code); + + + +/****************************************************************************************************** + * _ _ _ _ __ _ _ + * (_) | | | | | | / _| | | (_) + * ___ _ __ ___ ___ _ __ _| | __ _| |_| |_ _ __ | |_ _ _ _ __ ___| |_ _ ___ _ __ ___ + * / __| '_ \ / _ \/ __| |/ _` | | / _` | __| __| '__| | _| | | | '_ \ / __| __| |/ _ \| '_ \ / __| + * \__ \ |_) | __/ (__| | (_| | | | (_| | |_| |_| | | | | |_| | | | | (__| |_| | (_) | | | | \__ \ + * |___/ .__/ \___|\___|_|\__,_|_| \__,_|\__|\__|_| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/ + * | | + * |_| + ******************************************************************************************************/ + +/** + * Gets the type of an ia32_Const. + */ +unsigned get_ia32_Const_type(ir_node *node); + +/** + * Sets the type of an ia32_Const. + */ +void set_ia32_Const_type(ir_node *node, int type); + +/** + * Copy the attributes from an ia32_Const to an Immop (Add_i, Sub_i, ...) node + */ +void set_ia32_Immop_attr(ir_node *node, ir_node *cnst); + +/** + * Copy the attributes from a Const to an ia32_Const + */ +void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst); + +/** + * Sets the AddrMode attribute + */ +void set_ia32_AddrMode(ir_node *node); + +/** + * Returns whether or not the node is an AddrMode node. + */ +int is_ia32_AddrMode(ir_node *node); + +/** + * Checks whether or not an ir_node is an ia32 node + */ int is_ia32_irn(const ir_node *node); /* Include the generated headers */ diff --git a/ir/be/ia32/ia32_nodes_attr.h b/ir/be/ia32/ia32_nodes_attr.h index 520cb3327..cc92ca202 100644 --- a/ir/be/ia32/ia32_nodes_attr.h +++ b/ir/be/ia32/ia32_nodes_attr.h @@ -4,29 +4,40 @@ #include "firm_types.h" #include "../bearch.h" -typedef enum { flavour_Div, flavour_Mod, flavour_DivMod } divmod_flavour_t; +typedef enum { flavour_Div = 1, flavour_Mod, flavour_DivMod } divmod_flavour_t; typedef enum { pn_EAX, pn_EDX } pn_ia32_Register; +typedef enum { asmop_Normal, asmop_Const, asmop_SymConst, asmop_AddrMode } asmop_type_t; +typedef enum { + am_Reg = 1, /**<< (%reg) */ + am_OffsReg, /**<< o(%reg) */ + am_RegReg, /**<< (%reg, %reg) */ + am_RegConst, /**<< ( , %reg, const) */ + am_OffsRegConst, /**<< o( , %reg, const) */ + am_OffsRegReg, /**<< o(%reg, %reg) */ + am_RegRegConst, /**<< (%reg, %reg, const) */ + am_OffsRegRegConst /**<< o(%reg, %reg, const) */ +} addrmode_type_t; -typedef struct { - enum { asmop_Const, asmop_SymConst, asmop_AddrMode } tp; - - tarval *tv; /**<< tarval for immediate operations */ - tarval *offset; /**<< offset for AddrMode */ - ir_node *old_ir; /**<< old ir node to avoid duplicating information (symconst in case of asmop_SymConst) */ - divmod_flavour_t dm_flav; /**<< flavour of a DivMod (flavour_Div/Mod/DivMod) */ +typedef struct { + asmop_type_t tp; /**<< ia32 node type */ + addrmode_type_t am_tp; /**<< addr mode type */ - long pn_code; /**<< projnum "types" (e.g. indicates the compare operator of a conditional jump - or an argument number) */ + tarval *am_offs; /**<< offset for AddrMode */ + tarval *am_const; /**<< shift const for AddrMode */ - unsigned n_res; /**<< number of results */ + tarval *tv; /**<< tarval for immediate operations */ + ir_node *old_ir; /**<< old ir node to avoid duplicating information (symconst in case of asmop_SymConst) */ - arch_irn_flags_t flags; /**<< indicating if spillable and/or rematerializeable */ + divmod_flavour_t dm_flav; /**<< flavour of a DivMod (flavour_Div/Mod/DivMod) */ + long pn_code; /**<< projnum "types" (e.g. indicate compare operators and argument numbers) */ + long n_res; /**<< number of results */ + arch_irn_flags_t flags; /**<< indicating if spillable and/or rematerializeable */ - const arch_register_req_t **in_req; /**<< register requirements for arguments */ - const arch_register_req_t **out_req; /**<< register requirements for results */ + const arch_register_req_t **in_req; /**<< register requirements for arguments */ + const arch_register_req_t **out_req; /**<< register requirements for results */ - const arch_register_t **slots; /**<< register slots for assigned registers */ + const arch_register_t **slots; /**<< register slots for assigned registers */ } asmop_attr; #endif /* _IA32_NODES_ATTR_H_ */ diff --git a/ir/be/ia32/ia32_transform.c b/ir/be/ia32/ia32_transform.c index 5647fa9b6..f39c8e253 100644 --- a/ir/be/ia32/ia32_transform.c +++ b/ir/be/ia32/ia32_transform.c @@ -182,7 +182,7 @@ static ir_node *gen_Add(firm_dbg_module_t *mod, dbg_info *dbg, ir_node *block, i new_op = new_rd_ia32_Lea(dbg, current_ir_graph, block, expr_op, get_irn_n(shli_op, 0), mode); set_ia32_Immop_tarval(new_op, tv); - set_ia32_offs(new_op, offs); + set_ia32_am_offs(new_op, offs); break; default: @@ -199,7 +199,7 @@ static ir_node *gen_Add(firm_dbg_module_t *mod, dbg_info *dbg, ir_node *block, i if (normal_add) { new_op = new_rd_ia32_Lea(dbg, current_ir_graph, block, op1, op2, mode); set_ia32_Immop_tarval(new_op, get_tarval_one(mode_Iu)); - set_ia32_offs(new_op, NULL); + set_ia32_am_offs(new_op, NULL); } return new_op; @@ -1264,14 +1264,14 @@ static ir_node *gen_Proj_Start(firm_dbg_module_t *mod, ir_node *block, ir_node * /* parameter got passed in general purpose register */ irn = new_rd_ia32_RegParam(get_irn_dbg_info(proj), current_ir_graph, block, proj, mode); set_ia32_pncode(irn, i); - set_ia32_regreq_out(irn, current_gpreg_param_req[cur_gp_idx], 0); + set_ia32_req_out(irn, current_gpreg_param_req[cur_gp_idx], 0); cur_gp_idx++; } else if (mode_is_float(mode) && cur_fp_idx < maxnum_fpreg_args) { /* parameter got passed in floating point register*/ irn = new_rd_ia32_RegParam(get_irn_dbg_info(proj), current_ir_graph, block, proj, mode); set_ia32_pncode(irn, i); - set_ia32_regreq_out(irn, current_fpreg_param_req[cur_fp_idx], 0); + set_ia32_req_out(irn, current_fpreg_param_req[cur_fp_idx], 0); cur_fp_idx++; } -- 2.20.1