2 * Register mapping for firm nodes. Stolen from bearch_firm :)
11 #include "ppc32_map_regs.h"
12 #include "ppc32_new_nodes.h"
14 /* Mapping to store registers in firm nodes */
16 struct ppc32_irn_reg_assoc {
18 const arch_register_t *reg;
21 int ppc32_cmp_irn_reg_assoc(const void *a, const void *b, size_t len) {
22 const struct ppc32_irn_reg_assoc *x = a;
23 const struct ppc32_irn_reg_assoc *y = b;
25 return x->irn != y->irn;
28 static struct ppc32_irn_reg_assoc *get_irn_reg_assoc(const ir_node *irn, set *reg_set) {
29 struct ppc32_irn_reg_assoc templ;
36 return set_insert(reg_set, &templ, sizeof(templ), hash);
39 void ppc32_set_firm_reg(ir_node *irn, const arch_register_t *reg, set *reg_set) {
40 struct ppc32_irn_reg_assoc *assoc = get_irn_reg_assoc(irn, reg_set);
44 const arch_register_t *ppc32_get_firm_reg(const ir_node *irn, set *reg_set) {
45 struct ppc32_irn_reg_assoc *assoc = get_irn_reg_assoc(irn, reg_set);
50 int is_ppc32_Load(const ir_node *n)
52 ir_op *op = get_irn_op(n);
53 if(op == op_ppc32_Lbz) return 1;
54 if(op == op_ppc32_Lhz) return 1;
55 if(op == op_ppc32_Lha) return 1;
56 if(op == op_ppc32_Lwz) return 1;
57 if(op == op_ppc32_Lfd) return 1;
58 if(op == op_ppc32_Lfs) return 1;
63 int is_ppc32_Store(const ir_node *n)
65 ir_op *op = get_irn_op(n);
66 if(op == op_ppc32_Stb) return 1;
67 if(op == op_ppc32_Sth) return 1;
68 if(op == op_ppc32_Stw) return 1;
69 if(op == op_ppc32_Stfd) return 1;
70 if(op == op_ppc32_Stfs) return 1;
77 * Translates the projnum into a "real" argument position for register
78 * requirements dependend on the predecessor.
80 long ppc32_translate_proj_pos(const ir_node *proj) {
81 ir_node *pred = get_Proj_pred(proj);
82 long nr = get_Proj_proj(proj);
85 if (is_ppc32_Load(pred)) {
86 if (nr == pn_Load_res)
88 assert(0 && "unsupported Proj(Load) number");
90 else if (is_ppc32_Store(pred)) {
93 else if (is_ppc32_fDiv(pred)) {
94 if (nr == pn_Quot_res)
97 assert(0 && "there should be no more Projs for a fDiv");
99 else if (is_ppc32_Divw(pred) || is_ppc32_Divwu(pred)) {
100 if (nr == pn_DivMod_res_div)
103 assert(0 && "there should be no more Projs for a ppc32_Divw or ppc32_Divwu");
106 else if(is_ppc32_Cmp(pred))
108 else if(is_ppc32_Cmpi(pred))
110 else if(is_ppc32_Cmpl(pred))
112 else if(is_ppc32_Cmpli(pred))
117 // assert(0 && "unsupported Proj(X)");