2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief declarations for ARM node attributes
23 * @author Oliver Richter, Tobias Gneist, Michael Beck
26 #ifndef FIRM_BE_ARM_ARM_NODES_ATTR_H
27 #define FIRM_BE_ARM_ARM_NODES_ATTR_H
29 #include "firm_types.h"
31 #include "../bearch_t.h"
34 * Possible ARM register shift types.
36 typedef enum _arm_shift_modifier {
37 ARM_SHF_NONE = 0, /**< no shift */
38 ARM_SHF_IMM = 1, /**< immediate operand with implicit ROR */
39 ARM_SHF_ASR = 2, /**< arithmetic shift right */
40 ARM_SHF_LSL = 3, /**< logical shift left */
41 ARM_SHF_LSR = 4, /**< logical shift right */
42 ARM_SHF_ROR = 5, /**< rotate right */
43 ARM_SHF_RRX = 6, /**< rotate right through carry bits */
46 /** True, if the modifier implies a shift argument */
47 #define ARM_HAS_SHIFT(mod) ((mod) > ARM_SHF_IMM)
49 /** get the shift modifier from flags */
50 #define ARM_GET_SHF_MOD(attr) ((attr)->instr_fl & 7)
52 /** set the shift modifier to flags */
53 #define ARM_SET_SHF_MOD(attr, mod) ((attr)->instr_fl = (((attr)->instr_fl & ~7) | (mod)))
55 /** fpa immediate bit */
56 #define ARM_FPA_IMM (1 << 3) /**< fpa floating point immediate */
58 #define ARM_GET_FPA_IMM(attr) ((attr)->instr_fl & ARM_FPA_IMM)
59 #define ARM_SET_FPA_IMM(attr) ((attr)->instr_fl |= ARM_FPA_IMM)
60 #define ARM_CLR_FPA_IMM(attr) ((attr)->instr_fl &= ~ARM_FPA_IMM)
63 * Possible ARM condition codes.
65 typedef enum _arm_condition {
66 ARM_COND_EQ = 0, /**< Equal, Z set. */
67 ARM_COND_NE = 1, /**< Not Equal, Z clear */
68 ARM_COND_CS = 2, /**< Carry set, unsigned >=, C set */
69 ARM_COND_CC = 3, /**< Carry clear, unsigned <, C clear */
70 ARM_COND_MI = 4, /**< Minus/Negative, N set */
71 ARM_COND_PL = 5, /**< Plus/Positive or Zero, N clear */
72 ARM_COND_VS = 6, /**< Overflow, V set */
73 ARM_COND_VC = 7, /**< No overflow, V clear */
74 ARM_COND_HI = 8, /**< unsigned >, C set and Z clear */
75 ARM_COND_LS = 9, /**< unsigned <=, C clear or Z set */
76 ARM_COND_GE = 10, /**< signed >=, N == V */
77 ARM_COND_LT = 11, /**< signed <, N != V */
78 ARM_COND_GT = 12, /**< signed >, Z clear and N == V */
79 ARM_COND_LE = 13, /**< signed <=, Z set or N != V */
80 ARM_COND_AL = 14, /**< Always (unconditional) */
81 ARM_COND_NV = 15 /**< forbidden */
84 /** Get the condition code from flags */
85 #define ARM_GET_COND(attr) (((attr)->instr_fl >> 4) & 15)
87 /** Set the condition code to flags */
88 #define ARM_SET_COND(attr, code) ((attr)->instr_fl = (((attr)->instr_fl & ~(15 << 4)) | ((code) << 4)))
90 /** Encoding for fpa immediates */
103 /** Generic ARM node attributes. */
104 typedef struct _arm_attr_t {
105 except_attr exc; /**< the exception attribute. MUST be the first one. */
106 arch_irn_flags_t flags; /**< indicating if spillable, rematerializeable ... etc. */
108 const arch_register_req_t **in_req; /**< register requirements for arguments */
109 const arch_register_req_t **out_req; /**< register requirements for results */
111 ir_mode *op_mode; /**< operation mode if different from node's mode */
112 unsigned instr_fl; /**< condition code, shift modifier */
113 long imm_value; /**< immediate */
114 int *out_flags; /**< flags for each produced value */
116 const arch_register_t **slots; /**< register slots for assigned registers */
119 /** Attributes for a SymConst */
120 typedef struct _arm_SymConst_attr_t {
121 arm_attr_t attr; /**< base attributes */
122 ident *symconst_id; /**< for SymConsts: its ident */
123 } arm_SymConst_attr_t;
125 /** Attributes for a CondJmp */
126 typedef struct _arm_CondJmp_attr_t {
127 arm_attr_t attr; /**< base attributes */
129 } arm_CondJmp_attr_t;
131 /** Attributes for a SwitchJmp */
132 typedef struct _arm_SwitchJmp_attr_t {
133 arm_attr_t attr; /**< base attributes */
135 long default_proj_num;
136 } arm_SwitchJmp_attr_t;
138 /** Attributes for a fpaConst */
139 typedef struct _arm_fpaConst_attr_t {
140 arm_attr_t attr; /**< base attributes */
141 tarval *tv; /**< the tarval representing the FP const */
142 } arm_fpaConst_attr_t;
145 * Returns the shift modifier string.
147 const char *arm_shf_mod_name(arm_shift_modifier mod);
150 * Return the fpa immediate from the encoding.
152 const char *arm_get_fpa_imm_name(long imm_value);
154 #define CAST_ARM_ATTR(type,ptr) ((type *)(ptr))
155 #define CONST_CAST_ARM_ATTR(type,ptr) ((const type *)(ptr))