add support for 2 return registers
[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 "firm_types.h"
30 #include "irnode_t.h"
31 #include "../bearch_t.h"
32
33 /**
34  * Possible ARM register shift types.
35  */
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 with sign extend */
44 } arm_shift_modifier;
45
46 /** True, if the modifier implies a shift argument */
47 #define ARM_HAS_SHIFT(mod)          ((mod) > ARM_SHF_IMM)
48
49 /** get the shift modifier from flags */
50 #define ARM_GET_SHF_MOD(attr)       ((attr)->instr_fl & 7)
51
52 /** set the shift modifier to flags */
53 #define ARM_SET_SHF_MOD(attr, mod)  ((attr)->instr_fl = (((attr)->instr_fl & ~7) | (mod)))
54
55
56 /**
57  * Possible ARM condition codes.
58  */
59 typedef enum _arm_condition {
60         ARM_COND_EQ = 0,   /**< Equal, Z set. */
61         ARM_COND_NE = 1,   /**< Not Equal, Z clear */
62         ARM_COND_CS = 2,   /**< Carry set, unsigned >=, C set */
63         ARM_COND_CC = 3,   /**< Carry clear, unsigned <, C clear */
64         ARM_COND_MI = 4,   /**< Minus/Negativ, N set */
65         ARM_COND_PL = 5,   /**< Plus/Positiv or Zero, N clear */
66         ARM_COND_VS = 6,   /**< Overflow, V set */
67         ARM_COND_VC = 7,   /**< No overflow, V clear */
68         ARM_COND_HI = 8,   /**< unsigned >, C set and Z clear */
69         ARM_COND_LS = 9,   /**< unsigned <=, C clear or Z set */
70         ARM_COND_GE = 10,  /**< signed >=, N == V */
71         ARM_COND_LT = 11,  /**< signed <, N != V */
72         ARM_COND_GT = 12,  /**< signed >, Z clear and N == V */
73         ARM_COND_LE = 13,  /**< signed <=, Z set or N != V */
74         ARM_COND_AL = 14,  /**< Always (unconditional) */
75         ARM_COND_NV = 15   /**< forbidden */
76 } arm_condition;
77
78 /** Get the condition code from flags */
79 #define ARM_GET_COND(attr)        (((attr)->instr_fl >> 3) & 15)
80
81 /** Set the condition code to flags */
82 #define ARM_SET_COND(attr, code)  ((attr)->instr_fl = (((attr)->instr_fl & ~(15 << 3)) | ((code) << 3)))
83
84 /** Generic ARM node attributes. */
85 typedef struct _arm_attr_t {
86         except_attr      exc;                /**< the exception attribute. MUST be the first one. */
87         arch_irn_flags_t flags;              /**< indicating if spillable, rematerializeable ... etc. */
88
89         const arch_register_req_t **in_req;  /**< register requirements for arguments */
90         const arch_register_req_t **out_req; /**< register requirements for results */
91
92         ir_mode  *op_mode;                   /**< operation mode if different from node's mode */
93         unsigned instr_fl;                   /**< condition code, shift modifier */
94         tarval   *value;                     /**< immediate */
95         int      *out_flags;                 /**< flags for each produced value */
96
97         const arch_register_t **slots;       /**< register slots for assigned registers */
98 } arm_attr_t;
99
100 /** Attributes for a SymConst */
101 typedef struct _arm_SymConst_attr_t {
102         arm_attr_t  attr;
103         ident       *symconst_id;           /**< for SymConsts: its ident */
104 } arm_SymConst_attr_t;
105
106 /** Attributes for a CondJmp */
107 typedef struct _arm_CondJmp_attr_t {
108         arm_attr_t  attr;
109         int         proj_num;
110 } arm_CondJmp_attr_t;
111
112 /** Attributes for a SwitchJmp */
113 typedef struct _arm_SwitchJmp_attr_t {
114         arm_attr_t  attr;
115         int         n_projs;
116         long default_proj_num;
117 } arm_SwitchJmp_attr_t;
118
119 /**
120  * Returns the shift modifier string.
121  */
122 const char *arm_shf_mod_name(arm_shift_modifier mod);
123
124 #endif