becopyopt: Remove the unnecessary attribute name from struct copy_opt_t.
[libfirm] / ir / be / arm / arm_map_regs.c
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief   Register mapping for firm nodes. Stolen from bearch_firm :)
9  * @author  Oliver Richter, Tobias Gneist
10  */
11 #include "config.h"
12
13 #include <stdlib.h>
14
15 #include "arm_map_regs.h"
16 #include "arm_new_nodes.h"
17
18 #include "gen_arm_regalloc_if.h"
19
20
21 static const arch_register_t *gpreg_param_reg_std[] = {
22         &arm_registers[REG_R0],
23         &arm_registers[REG_R1],
24         &arm_registers[REG_R2],
25         &arm_registers[REG_R3],
26 };
27
28 const arch_register_t *arm_get_RegParam_reg(int n)
29 {
30         assert(n < 4 && n >=0 && "register param > 3 angefordert");
31         return gpreg_param_reg_std[n];
32 }
33
34 /* Mapping to store registers in firm nodes */
35
36 typedef struct arm_irn_reg_assoc {
37         const ir_node *irn;
38         const arch_register_t *reg;
39 } arm_irn_reg_assoc;
40
41 int arm_cmp_irn_reg_assoc(const void *a, const void *b, size_t size)
42 {
43         const arm_irn_reg_assoc *x = (const arm_irn_reg_assoc*)a;
44         const arm_irn_reg_assoc *y = (const arm_irn_reg_assoc*)b;
45         (void) size;
46
47         return x->irn != y->irn;
48 }
49
50 static arm_irn_reg_assoc *get_irn_reg_assoc(const ir_node *irn, set *reg_set)
51 {
52         arm_irn_reg_assoc templ;
53         unsigned int hash;
54
55         templ.irn = irn;
56         templ.reg = NULL;
57         hash = hash_ptr(irn);
58
59         return set_insert(arm_irn_reg_assoc, reg_set, &templ, sizeof(templ), hash);
60 }
61
62 void arm_set_firm_reg(ir_node *irn, const arch_register_t *reg, set *reg_set)
63 {
64         arm_irn_reg_assoc *assoc = get_irn_reg_assoc(irn, reg_set);
65         assoc->reg = reg;
66 }
67
68 const arch_register_t *arm_get_firm_reg(const ir_node *irn, set *reg_set)
69 {
70         const arm_irn_reg_assoc *assoc = get_irn_reg_assoc(irn, reg_set);
71         return assoc->reg;
72 }