Reverted r27079. Seems to be wrong.
[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 {
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;
50
51 /** fpa immediate bit */
52 #define ARM_FPA_IMM  (1 << 3)   /**< fpa floating point immediate */
53
54 #define ARM_GET_FPA_IMM(attr)        ((attr)->instr_fl & ARM_FPA_IMM)
55 #define ARM_SET_FPA_IMM(attr)        ((attr)->instr_fl |= ARM_FPA_IMM)
56 #define ARM_CLR_FPA_IMM(attr)        ((attr)->instr_fl &= ~ARM_FPA_IMM)
57
58 /** Encoding for fpa immediates */
59 enum fpa_immediates {
60         fpa_null = 0,
61         fpa_one,
62         fpa_two,
63         fpa_three,
64         fpa_four,
65         fpa_five,
66         fpa_ten,
67         fpa_half,
68         fpa_max
69 };
70
71 /** Generic ARM node attributes. */
72 typedef struct _arm_attr_t {
73         except_attr      exc;                /**< the exception attribute. MUST be the first one. */
74
75         const arch_register_req_t **in_req;  /**< register requirements for arguments */
76
77         ir_mode  *op_mode;                   /**< operation mode if different from node's mode (used for fpa nodes) */
78         unsigned  instr_fl;                  /**< deprecated (was sometimes used for shift modifiers) */
79         bool      is_load_store : 1;
80 } arm_attr_t;
81
82 /**
83  * This struct holds information needed to produce the arm
84  * "data processing operands" also called "shifter operand" addressing modes
85  */
86 typedef struct arm_shifter_operand_t {
87         arm_attr_t          base;
88         arm_shift_modifier  shift_modifier;
89         unsigned char       immediate_value;
90         unsigned char       shift_immediate;
91 } arm_shifter_operand_t;
92
93 typedef struct arm_cmp_attr_t {
94         arm_shifter_operand_t  base;
95         bool                   ins_permuted : 1;
96         bool                   is_unsigned  : 1;
97 } arm_cmp_attr_t;
98
99 /**
100  * this struct holds information needed to produce the arm addressing modes
101  * for "Load and Store Word or Unsigned Byte", "Miscellaneous Loads and Stores"
102  * and "Load and Store Multiple" */
103 typedef struct arm_load_store_attr_t {
104         arm_attr_t  base;
105         ir_mode    *load_store_mode;
106         ir_entity  *entity;
107         long        offset;
108         bool        is_frame_entity : 1;
109         bool        entity_sign     : 1;
110 } arm_load_store_attr_t;
111
112 /** Attributes for a SymConst */
113 typedef struct _arm_SymConst_attr_t {
114         arm_attr_t  base;
115         ir_entity  *entity;
116         int         fp_offset;
117 } arm_SymConst_attr_t;
118
119 /** Attributes for a CondJmp */
120 typedef struct _arm_CondJmp_attr_t {
121         arm_attr_t  base;
122         int         proj_num;
123 } arm_CondJmp_attr_t;
124
125 /** Attributes for a SwitchJmp */
126 typedef struct _arm_SwitchJmp_attr_t {
127         arm_attr_t  base;
128         int         n_projs;
129         long        default_proj_num;
130 } arm_SwitchJmp_attr_t;
131
132 /** CopyB attributes */
133 typedef struct {
134         arm_attr_t  base;
135         unsigned    size;
136 } arm_CopyB_attr_t;
137
138 /** Attributes for a fpaConst */
139 typedef struct _arm_fpaConst_attr_t {
140         arm_attr_t  base;
141         tarval     *tv;              /**< the tarval representing the FP const */
142 } arm_fpaConst_attr_t;
143
144 /**
145  * Return the fpa immediate from the encoding.
146  */
147 const char *arm_get_fpa_imm_name(long imm_value);
148
149 #define CAST_ARM_ATTR(type,ptr)        ((type *)(ptr))
150 #define CONST_CAST_ARM_ATTR(type,ptr)  ((const type *)(ptr))
151
152 #endif