#include <stdlib.h>
+#include "pmap.h"
+
#include "ia32_map_regs.h"
#include "ia32_new_nodes.h"
#include "gen_ia32_regalloc_if.h"
};
const arch_register_t *fpreg_param_reg_std[] = {
- &ia32_fp_regs[REG_XMM0],
- &ia32_fp_regs[REG_XMM1],
- &ia32_fp_regs[REG_XMM2],
- &ia32_fp_regs[REG_XMM3],
- &ia32_fp_regs[REG_XMM4],
- &ia32_fp_regs[REG_XMM5],
- &ia32_fp_regs[REG_XMM6],
- &ia32_fp_regs[REG_XMM7]
+ &ia32_xmm_regs[REG_XMM0],
+ &ia32_xmm_regs[REG_XMM1],
+ &ia32_xmm_regs[REG_XMM2],
+ &ia32_xmm_regs[REG_XMM3],
+ &ia32_xmm_regs[REG_XMM4],
+ &ia32_xmm_regs[REG_XMM5],
+ &ia32_xmm_regs[REG_XMM6],
+ &ia32_xmm_regs[REG_XMM7]
};
const arch_register_t *fpreg_param_reg_this[] = {
NULL, /* in case of a "this" pointer, the first parameter must not be a float */
- &ia32_fp_regs[REG_XMM0],
- &ia32_fp_regs[REG_XMM1],
- &ia32_fp_regs[REG_XMM2],
- &ia32_fp_regs[REG_XMM3],
- &ia32_fp_regs[REG_XMM4],
- &ia32_fp_regs[REG_XMM5],
- &ia32_fp_regs[REG_XMM6],
- &ia32_fp_regs[REG_XMM7]
+ &ia32_xmm_regs[REG_XMM0],
+ &ia32_xmm_regs[REG_XMM1],
+ &ia32_xmm_regs[REG_XMM2],
+ &ia32_xmm_regs[REG_XMM3],
+ &ia32_xmm_regs[REG_XMM4],
+ &ia32_xmm_regs[REG_XMM5],
+ &ia32_xmm_regs[REG_XMM6],
+ &ia32_xmm_regs[REG_XMM7]
};
return assoc->reg;
}
-
-
-/* Mapping to store proj numbers for registers */
-
-struct ia32_reg_projnum_assoc {
- const arch_register_t *reg;
- long proj_num;
-};
-
-int ia32_cmp_reg_projnum_assoc(const void *a, const void *b, size_t len) {
- const struct ia32_reg_projnum_assoc *x = a;
- const struct ia32_reg_projnum_assoc *y = b;
-
- return !(x->reg == y->reg);
+void ia32_build_16bit_reg_map(pmap *reg_map) {
+ pmap_insert(reg_map, &ia32_gp_regs[REG_EAX], "ax");
+ pmap_insert(reg_map, &ia32_gp_regs[REG_EBX], "bx");
+ pmap_insert(reg_map, &ia32_gp_regs[REG_ECX], "cx");
+ pmap_insert(reg_map, &ia32_gp_regs[REG_EDX], "dx");
+ pmap_insert(reg_map, &ia32_gp_regs[REG_ESI], "si");
+ pmap_insert(reg_map, &ia32_gp_regs[REG_EDI], "di");
+ pmap_insert(reg_map, &ia32_gp_regs[REG_EBP], "bp");
+ pmap_insert(reg_map, &ia32_gp_regs[REG_ESP], "sp");
}
-static struct ia32_reg_projnum_assoc *get_reg_projnum_assoc(const arch_register_t *reg, set *reg_set) {
- struct ia32_reg_projnum_assoc templ;
- unsigned int hash;
-
- templ.reg = reg;
- templ.proj_num = -1;
- hash = HASH_PTR(reg);
-
- return set_insert(reg_set, &templ, sizeof(templ), hash);
+void ia32_build_8bit_reg_map(pmap *reg_map) {
+ pmap_insert(reg_map, &ia32_gp_regs[REG_EAX], "al");
+ pmap_insert(reg_map, &ia32_gp_regs[REG_EBX], "bl");
+ pmap_insert(reg_map, &ia32_gp_regs[REG_ECX], "cl");
+ pmap_insert(reg_map, &ia32_gp_regs[REG_EDX], "dl");
}
-void ia32_set_reg_projnum(const arch_register_t *reg, long proj_num, set *reg_set) {
- struct ia32_reg_projnum_assoc *assoc = get_reg_projnum_assoc(reg, reg_set);
- assoc->proj_num = proj_num;
-}
-
-long ia32_get_reg_projnum(const arch_register_t *reg, set *reg_set) {
- struct ia32_reg_projnum_assoc *assoc = get_reg_projnum_assoc(reg, reg_set);
- return assoc->proj_num;
-}
+char *ia32_get_mapped_reg_name(pmap *reg_map, const arch_register_t *reg) {
+ pmap_entry *e = pmap_find(reg_map, (void *)reg);
+ assert(e && "missing map init?");
+ return e->value;
+}
/**
* Check all parameters and determine the maximum number of parameters
int ia32_get_n_regparam_class(int n, ir_mode **modes, int *n_int, int *n_float) {
int i, finished = 0;
+ *n_int = 0;
+ *n_float = 0;
+
for (i = 0; i < n && !finished; i++) {
- if (mode_is_int(modes[i])) {
+ if (mode_is_int(modes[i]) || mode_is_reference(modes[i])) {
*n_int = *n_int + 1;
}
else if (mode_is_float(modes[i])) {
/* loop over all parameters and determine whether its a int or float register parameter */
for (i = 0; i < nr && !done && (cc & cc_reg_param); i++) {
- if (mode_is_int(modes[i]) && cur_gp_idx < maxnum_gpreg_args) {
+ if ((mode_is_int(modes[i]) || mode_is_reference(modes[i])) && cur_gp_idx < maxnum_gpreg_args) {
/* param can be passed in general purpose register and we have some registers left */
cur_gp_idx++;
}
}
/* now: i == nr, that's the parameter requirement we want */
- if (mode_is_int(modes[i]) && cur_gp_idx < maxnum_gpreg_args) {
+ if ((mode_is_int(modes[i]) || mode_is_reference(modes[i])) && cur_gp_idx < maxnum_gpreg_args) {
/* parameter #nr can be passed in general purpose register */
param_reg = current_gpreg_param_reg[i];
}
* requirements dependend on the predecessor.
*/
long ia32_translate_proj_pos(const ir_node *proj) {
- ir_node *first;
ir_node *pred = get_Proj_pred(proj);
long nr = get_Proj_proj(proj);
- if (is_ia32_Load(pred)) {
- if (nr == pn_Load_res)
+ if (is_ia32_Ld(pred)) {
+ if (nr == pn_Load_res || nr == 0)
return 0;
assert(0 && "unsupported Proj(Load) number");
}
- else if (is_ia32_Store(pred)) {
+ else if (is_ia32_St(pred)) {
return 0;
}
else if (is_ia32_CondJmp(pred)) {
return 1;
}
else if (is_ia32_DivMod(pred)) {
- if (nr == pn_DivMod_res_div || pn_Div_res)
+ if (nr == pn_DivMod_res_div)
return 0;
- if (nr == pn_DivMod_res_mod || pn_Mod_res)
+ if (nr == pn_DivMod_res_mod)
return 1;
+ assert(0 && "unsupported DivMod");
}
- else if (is_ia32_fDiv(pred)) {
+ else if (is_ia32_xDiv(pred)) {
if (nr == pn_Quot_res)
return 0;
else
- assert(0 && "there should be no more Projs for a fDiv");
- }
- else if (is_ia32_Call(pred)) {
- return 0;
+ assert(0 && "there should be no more Projs for a xDiv");
}
else if (get_irn_mode(proj) == mode_X && nr == pn_Start_X_initial_exec) {
return 0;
}
else if (is_Proj(pred)) {
- first = get_Proj_pred(pred);
-
- if (is_ia32_Call(first))
- return 0;
-
- assert(0 && "unsupported proj-pos translation Proj(Proj)");
- return -1;
+ return nr;
}
else if (get_irn_opcode(pred) == iro_Start) {
return nr;