2 * Register mapping for firm nodes. Stolen from bearch_firm :)
8 #include "ia32_map_regs.h"
9 #include "ia32_new_nodes.h"
11 struct irn_reg_assoc {
13 const arch_register_t *reg;
16 int cmp_irn_reg_assoc(const void *a, const void *b, size_t len) {
17 const struct irn_reg_assoc *x = a;
18 const struct irn_reg_assoc *y = b;
20 return !(x->irn == y->irn);
23 static struct irn_reg_assoc *get_irn_reg_assoc(const ir_node *irn, set *reg_set) {
24 struct irn_reg_assoc templ;
31 return set_insert(reg_set, &templ, sizeof(templ), hash);
34 void ia32_set_firm_reg(const arch_irn_ops_t *self, ir_node *irn,
35 const arch_register_t *reg, set *reg_set)
37 struct irn_reg_assoc *assoc = get_irn_reg_assoc(irn, reg_set);
41 const arch_register_t *ia32_get_firm_reg(const arch_irn_ops_t *self,
42 const ir_node *irn, set *reg_set)
44 struct irn_reg_assoc *assoc = get_irn_reg_assoc(irn, reg_set);
50 * Translates the projnum into a "real" argument position for register
51 * requirements dependend on the predecessor.
53 long translate_proj_pos(const ir_node *proj) {
55 ir_node *pred = get_Proj_pred(proj);
56 long nr = get_Proj_proj(proj);
58 if (is_ia32_Load(pred)) {
59 if (nr == pn_Load_res)
61 assert(0 && "unsupported Proj(Load) number");
63 else if (is_ia32_Store(pred)) {
66 else if (is_ia32_CondJmp(pred) || is_ia32_CondJmp_i(pred)) {
69 else if (is_ia32_SwitchJmp(pred)) {
72 else if (is_ia32_Cltd(pred) || is_ia32_Mul(pred)) {
78 else if (is_ia32_DivMod(pred)) {
79 if (nr == pn_DivMod_res_div || pn_Div_res)
81 if (nr == pn_DivMod_res_mod || pn_Mod_res)
84 else if (is_ia32_Call(pred)) {
87 else if (get_irn_mode(proj) == mode_X && nr == pn_Start_X_initial_exec) {
90 else if (is_Proj(pred)) {
91 // return nr + translate_proj_pos(pred);
92 first = get_Proj_pred(pred);
94 if (is_ia32_Call(first))
97 assert(0 && "unsupported proj-pos translation Proj(Proj)");
100 else if (get_irn_opcode(pred) == iro_Start) {
104 // assert(0 && "unsupported Proj(X)");