2 * Register mapping for firm nodes. Stolen from bearch_firm :)
11 #include "arm_map_regs.h"
12 #include "arm_new_nodes.h"
14 #include "gen_arm_regalloc_if.h"
17 static const arch_register_t *gpreg_param_reg_std[] = {
18 &arm_general_purpose_regs[REG_R0],
19 &arm_general_purpose_regs[REG_R1],
20 &arm_general_purpose_regs[REG_R2],
21 &arm_general_purpose_regs[REG_R3],
24 const arch_register_t *arm_get_RegParam_reg(int n) {
25 assert(n < 4 && n >=0 && "register param > 3 angefordert");
26 return gpreg_param_reg_std[n];
29 /* Mapping to store registers in firm nodes */
31 struct arm_irn_reg_assoc {
33 const arch_register_t *reg;
36 int arm_cmp_irn_reg_assoc(const void *a, const void *b, size_t len) {
37 const struct arm_irn_reg_assoc *x = a;
38 const struct arm_irn_reg_assoc *y = b;
40 return x->irn != y->irn;
43 static struct arm_irn_reg_assoc *get_irn_reg_assoc(const ir_node *irn, set *reg_set) {
44 struct arm_irn_reg_assoc templ;
51 return set_insert(reg_set, &templ, sizeof(templ), hash);
54 void arm_set_firm_reg(ir_node *irn, const arch_register_t *reg, set *reg_set) {
55 struct arm_irn_reg_assoc *assoc = get_irn_reg_assoc(irn, reg_set);
59 const arch_register_t *arm_get_firm_reg(const ir_node *irn, set *reg_set) {
60 struct arm_irn_reg_assoc *assoc = get_irn_reg_assoc(irn, reg_set);
67 * Translates the projnum into a "real" argument position for register
68 * requirements dependend on the predecessor.
70 long arm_translate_proj_pos(const ir_node *proj) {
71 ir_node *pred = get_Proj_pred(proj);
72 long nr = get_Proj_proj(proj);
74 if (is_arm_Load(pred) || is_arm_fLoadd(pred) || is_arm_fLoads(pred)) {
75 if (nr == pn_Load_res)
77 assert(0 && "unsupported Proj(Load) number");
79 else if (is_arm_Store(pred) || is_arm_fStores(pred) || is_arm_fStored(pred)) {
82 else if (is_arm_fDiv(pred)) {
83 if (nr == pn_Quot_res)
86 assert(0 && "there should be no more Projs for a fDiv");
89 // assert(0 && "unsupported Proj(X)");