- Allocate register slots array separately on obstack
[libfirm] / ir / be / arm / arm_nodes_attr.h
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   declarations for arm node attributes
23  * @author  Oliver Richter, Tobias Gneist
24  * @version $Id$
25  */
26 #ifndef FIRM_BE_ARM_ARM_NODES_ATTR_H
27 #define FIRM_BE_ARM_ARM_NODES_ATTR_H
28
29 #include "../bearch_t.h"
30 #include "firm_types.h"
31
32 /**
33  * Possible ARM register shift types.
34  */
35 typedef enum _arm_shift_modifier {
36         ARM_SHF_NONE = 0,   /**< no shift */
37         ARM_SHF_IMM  = 1,   /**< immediate operand with implicit ROR */
38         ARM_SHF_ASR  = 2,   /**< arithmetic shift right */
39         ARM_SHF_LSL  = 3,   /**< logical shift left */
40         ARM_SHF_LSR  = 4,   /**< logical shift right */
41         ARM_SHF_ROR  = 5,   /**< rotate right */
42         ARM_SHF_RRX  = 6,   /**< rotate with sign extend */
43 } arm_shift_modifier;
44
45 /** True, if the modifier implies a shift argument */
46 #define ARM_HAS_SHIFT(mod)          ((mod) > ARM_SHF_IMM)
47
48 /** get the shift modifier from flags */
49 #define ARM_GET_SHF_MOD(attr)       ((attr)->instr_fl & 7)
50
51 /** set the shift modifier to flags */
52 #define ARM_SET_SHF_MOD(attr, mod)  ((attr)->instr_fl = (((attr)->instr_fl & ~7) | (mod)))
53
54
55 /**
56  * Possible ARM condition codes.
57  */
58 typedef enum _arm_condition {
59         ARM_COND_EQ = 0,   /**< Equal, Z set. */
60         ARM_COND_NE = 1,   /**< Not Equal, Z clear */
61         ARM_COND_CS = 2,   /**< Carry set, unsigned >=, C set */
62         ARM_COND_CC = 3,   /**< Carry clear, unsigned <, C clear */
63         ARM_COND_MI = 4,   /**< Minus/Negativ, N set */
64         ARM_COND_PL = 5,   /**< Plus/Positiv or Zero, N clear */
65         ARM_COND_VS = 6,   /**< Overflow, V set */
66         ARM_COND_VC = 7,   /**< No overflow, V clear */
67         ARM_COND_HI = 8,   /**< unsigned >, C set and Z clear */
68         ARM_COND_LS = 9,   /**< unsigned <=, C clear or Z set */
69         ARM_COND_GE = 10,  /**< signed >=, N == V */
70         ARM_COND_LT = 11,  /**< signed <, N != V */
71         ARM_COND_GT = 12,  /**< signed >, Z clear and N == V */
72         ARM_COND_LE = 13,  /**< signed <=, Z set or N != V */
73         ARM_COND_AL = 14,  /**< Always (unconditional) */
74         ARM_COND_NV = 15   /**< forbidden */
75 } arm_condition;
76
77 /** Get the condition code from flags */
78 #define ARM_GET_COND(attr)        (((attr)->instr_fl >> 3) & 15)
79
80 /** Set the condition code to flags */
81 #define ARM_SET_COND(attr, code)  ((attr)->instr_fl = (((attr)->instr_fl & ~(15 << 3)) | ((code) << 3)))
82
83 typedef struct _arm_attr_t {
84         arch_irn_flags_t flags;             /**< indicating if spillable, rematerializeable ... etc. */
85
86         const arch_register_req_t **in_req;  /**< register requirements for arguments */
87         const arch_register_req_t **out_req; /**< register requirements for results */
88
89         ir_mode *op_mode;                   /**< operation mode */
90         unsigned instr_fl;                  /**< condition code, shift modifier */
91         tarval *value;                      /**< immediate */
92         ident *symconst_id;                 /**< for SymConsts: its ident */
93         int proj_num;
94         int n_projs;
95         long default_proj_num;
96
97         const arch_register_t **slots;      /**< register slots for assigned registers */
98 } arm_attr_t;
99
100 /**
101  * Returns the shift modifier string.
102  */
103 const char *arm_shf_mod_name(arm_shift_modifier mod);
104
105 #endif