make if-conversion and archdep optimisations get their information directly from...
[libfirm] / ir / be / arm / arm_nodes_attr.h
1 /*
2  * Copyright (C) 1995-2008 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, Michael Beck
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.h"
32
33 /**
34  * Possible ARM "shifter operand" addressing mode types.
35  */
36 typedef enum arm_shift_modifier_t {
37         ARM_SHF_INVALID,   /**< invalid shift */
38         ARM_SHF_REG,       /**< simple register operand */
39         ARM_SHF_IMM,       /**< immediate operand with implicit ROR */
40         ARM_SHF_ASR_IMM,   /**< arithmetic shift right */
41         ARM_SHF_ASR_REG,   /**< arithmetic shift right */
42         ARM_SHF_LSL_IMM,   /**< logical shift left */
43         ARM_SHF_LSL_REG,   /**< logical shift left */
44         ARM_SHF_LSR_IMM,   /**< logical shift right */
45         ARM_SHF_LSR_REG,   /**< logical shift right */
46         ARM_SHF_ROR_IMM,   /**< rotate right */
47         ARM_SHF_ROR_REG,   /**< rotate right */
48         ARM_SHF_RRX,       /**< rotate right through carry bits */
49 } arm_shift_modifier_t;
50
51 /** Encoding for fpa immediates */
52 enum fpa_immediates {
53         fpa_null = 0,
54         fpa_one,
55         fpa_two,
56         fpa_three,
57         fpa_four,
58         fpa_five,
59         fpa_ten,
60         fpa_half,
61         fpa_max
62 };
63
64 /** Generic ARM node attributes. */
65 typedef struct arm_attr_t {
66         except_attr                 exc;                /**< the exception attribute. MUST be the first one. */
67         const arch_register_req_t **in_req;             /**< register requirements for arguments */
68         bool                        is_load_store : 1;  /**< if set, this is a load or store instruction */
69 } arm_attr_t;
70
71 /**
72  * This struct holds information needed to produce the arm
73  * "data processing operands" also called "shifter operand" addressing modes
74  */
75 typedef struct arm_shifter_operand_t {
76         arm_attr_t            base;
77         arm_shift_modifier_t  shift_modifier;
78         unsigned char         immediate_value;
79         unsigned char         shift_immediate;
80 } arm_shifter_operand_t;
81
82 typedef struct arm_cmp_attr_t {
83         arm_shifter_operand_t  base;
84         bool                   ins_permuted : 1;
85         bool                   is_unsigned  : 1;
86 } arm_cmp_attr_t;
87
88 /**
89  * this struct holds information needed to produce the arm addressing modes
90  * for "Load and Store Word or Unsigned Byte", "Miscellaneous Loads and Stores"
91  * and "Load and Store Multiple" */
92 typedef struct arm_load_store_attr_t {
93         arm_attr_t  base;
94         ir_mode    *load_store_mode;
95         ir_entity  *entity;
96         long        offset;
97         bool        is_frame_entity : 1;
98         bool        entity_sign     : 1;
99 } arm_load_store_attr_t;
100
101 /** Attributes for a SymConst */
102 typedef struct arm_SymConst_attr_t {
103         arm_attr_t  base;
104         ir_entity  *entity;
105         int         fp_offset;
106 } arm_SymConst_attr_t;
107
108 /** Attributes for a CondJmp */
109 typedef struct arm_CondJmp_attr_t {
110         arm_attr_t  base;
111         pn_Cmp      pnc;
112 } arm_CondJmp_attr_t;
113
114 /** Attributes for a SwitchJmp */
115 typedef struct arm_SwitchJmp_attr_t {
116         arm_attr_t  base;
117         int         n_projs;
118         long        default_proj_num;
119 } arm_SwitchJmp_attr_t;
120
121 /** CopyB attributes */
122 typedef struct arm_CopyB_attr_t {
123         arm_attr_t  base;
124         unsigned    size;
125 } arm_CopyB_attr_t;
126
127 /** Attributes for a fConst */
128 typedef struct arm_fConst_attr_t {
129         arm_attr_t  base;
130         tarval     *tv;              /**< the tarval representing the FP const */
131 } arm_fConst_attr_t;
132
133 /** attributes for floatingpoint arithmetic operations */
134 typedef struct arm_farith_attr_t {
135         arm_attr_t  base;
136         ir_mode    *mode; /* operation mode */
137 } arm_farith_attr_t;
138
139 /**
140  * Return the fpa immediate from the encoding.
141  */
142 const char *arm_get_fpa_imm_name(long imm_value);
143
144 #define CAST_ARM_ATTR(type,ptr)        ((type *)(ptr))
145 #define CONST_CAST_ARM_ATTR(type,ptr)  ((const type *)(ptr))
146
147 #endif