Fixed register allocation for fp != sp
[libfirm] / ir / be / arm / arm_nodes_attr.h
1 #ifndef _ARM_NODES_ATTR_H_
2 #define _ARM_NODES_ATTR_H_
3
4 #include "../bearch.h"
5 #include "../../common/firm_types.h"
6
7 /** A register requirement. */
8 typedef struct _arm_register_req_t {
9         const arch_register_req_t req;
10         int same_pos;        /**< in case of "should be same" we need to remember the pos to get the irn */
11         int different_pos;   /**< in case of "should be different" we need to remember the pos to get the irn */
12 } arm_register_req_t;
13
14 /**
15  * Possible ARM register shift types.
16  */
17 typedef enum _arm_shift_modifier {
18         ARM_SHF_NONE = 0,   /**< no shift */
19         ARM_SHF_IMM  = 1,   /**< immediate operand with implicit ROR */
20         ARM_SHF_ASR  = 2,   /**< arithmetic shift right */
21         ARM_SHF_LSL  = 3,   /**< logical shift left */
22         ARM_SHF_LSR  = 4,   /**< logical shift right */
23         ARM_SHF_ROR  = 5,   /**< rotate right */
24         ARM_SHF_RRX  = 6,   /**< rotate with sign extend */
25 } arm_shift_modifier;
26
27 /** True, if the modifier implies a shift argument */
28 #define ARM_HAS_SHIFT(mod)          ((mod) > ARM_SHF_IMM)
29
30 /** get the shift modifier from flags */
31 #define ARM_GET_SHF_MOD(attr)       ((attr)->instr_fl & 7)
32
33 /** set the shift modifier to flags */
34 #define ARM_SET_SHF_MOD(attr, mod)  ((attr)->instr_fl = (((attr)->instr_fl & ~7) | (mod)))
35
36
37 /**
38  * Possible ARM condition codes.
39  */
40 typedef enum _arm_condition {
41         ARM_COND_EQ = 0,   /**< Equal, Z set. */
42         ARM_COND_NE = 1,   /**< Not Equal, Z clear */
43         ARM_COND_CS = 2,   /**< Carry set, unsigned >=, C set */
44         ARM_COND_CC = 3,   /**< Carry clear, unsigned <, C clear */
45         ARM_COND_MI = 4,   /**< Minus/Negativ, N set */
46         ARM_COND_PL = 5,   /**< Plus/Positiv or Zero, N clear */
47         ARM_COND_VS = 6,   /**< Overflow, V set */
48         ARM_COND_VC = 7,   /**< No overflow, V clear */
49         ARM_COND_HI = 8,   /**< unsigned >, C set and Z clear */
50         ARM_COND_LS = 9,   /**< unsigned <=, C clear or Z set */
51         ARM_COND_GE = 10,  /**< signed >=, N == V */
52         ARM_COND_LT = 11,  /**< signed <, N != V */
53         ARM_COND_GT = 12,  /**< signed >, Z clear and N == V */
54         ARM_COND_LE = 13,  /**< signed <=, Z set or N != V */
55         ARM_COND_AL = 14,  /**< Always (unconditional) */
56         ARM_COND_NV = 15   /**< forbidden */
57 } arm_condition;
58
59 /** Get the condition code from flags */
60 #define ARM_GET_COND(attr)        (((attr)->instr_fl >> 3) & 15)
61
62 /** Set the condition code to flags */
63 #define ARM_SET_COND(attr, code)  ((attr)->instr_fl = (((attr)->instr_fl & ~(15 << 3)) | ((code) << 3)))
64
65 typedef struct _arm_attr_t {
66         arch_irn_flags_t flags;             /**< indicating if spillable, rematerializeable ... etc. */
67         int              n_res;             /**< number of results for this node */
68
69         const arm_register_req_t **in_req;  /**< register requirements for arguments */
70         const arm_register_req_t **out_req; /**< register requirements for results */
71
72         const arch_register_t **slots;      /**< register slots for assigned registers */
73
74         unsigned instr_fl;                                                                      /**< condition code, shift modifier */
75         tarval *value;                                                                                  /**< immediate */
76         const char *symconst_label;
77         int proj_num;
78         int n_projs;
79         long default_proj_num;
80 } arm_attr_t;
81
82 /**
83  * Returns the shift modifier string.
84  */
85 const char *arm_shf_mod_name(arm_shift_modifier mod);
86
87 #endif /* _ARM_NODES_ATTR_H_ */