added nolea option to switch of LEA optimization
[libfirm] / ir / be / arm / bearch_arm_t.h
1 #ifndef _BEARCH_ARM_T_H_
2 #define _BEARCH_ARM_T_H_
3
4 #include <stdio.h>
5
6 #include "debug.h"
7 #include "bearch_arm.h"
8 #include "arm_nodes_attr.h"
9 #include "../be.h"
10 #include "set.h"
11
12 typedef struct _arm_isa_t arm_isa_t;
13
14 /** The following bitmasks control CPU extensions:  */
15 enum arm_cpu_extensions {
16         ARM_EXT_V1    = 0x00000001,  /**< All processors (core set). */
17         ARM_EXT_V2    = 0x00000002,  /**< Multiply instructions. */
18         ARM_EXT_V2S   = 0x00000004,  /**< SWP instructions. */
19         ARM_EXT_V3    = 0x00000008,  /**< MSR MRS. */
20         ARM_EXT_V3M   = 0x00000010,  /**< Allow long multiplies. */
21         ARM_EXT_V4    = 0x00000020,  /**< Allow half word loads. */
22         ARM_EXT_V4T   = 0x00000040,  /**< Thumb v1. */
23         ARM_EXT_V5    = 0x00000080,  /**< Allow CLZ, etc. */
24         ARM_EXT_V5T   = 0x00000100,  /**< Thumb v2.ยด*/
25         ARM_EXT_V5ExP = 0x00000200,  /**< DSP core set. */
26         ARM_EXT_V5E   = 0x00000400,  /**< DSP Double transfers. */
27         ARM_EXT_V5J   = 0x00000800,  /**< Jazelle extension.   */
28
29         /* Co-processor space extensions.  */
30         ARM_CEXT_XSCALE   = 0x00800000, /**< Allow MIA etc. */
31         ARM_CEXT_MAVERICK = 0x00400000, /**< Use Cirrus/DSP coprocessor. */
32         ARM_CEXT_IWMMXT   = 0x00200000, /**< Intel Wireless MMX technology coprocessor. */
33 };
34
35 /**
36  * Architectures are the sum of the base and extensions.  The ARM ARM (rev E)
37  * defines the following: ARMv3, ARMv3M, ARMv4xM, ARMv4, ARMv4TxM, ARMv4T,
38  * ARMv5xM, ARMv5, ARMv5TxM, ARMv5T, ARMv5TExP, ARMv5TE.  To these we add
39  * three more to cover cores prior to ARM6.  Finally, there are cores which
40  * implement further extensions in the co-processor space.
41  */
42 enum arm_architectiures {
43         ARM_ARCH_V1     = ARM_EXT_V1,
44         ARM_ARCH_V2     = ARM_ARCH_V1 | ARM_EXT_V2,
45         ARM_ARCH_V2S    = ARM_ARCH_V2 | ARM_EXT_V2S,
46         ARM_ARCH_V3     = ARM_ARCH_V2S | ARM_EXT_V3,
47         ARM_ARCH_V3M    = ARM_ARCH_V3 | ARM_EXT_V3M,
48         ARM_ARCH_V4xM   = ARM_ARCH_V3 | ARM_EXT_V4,
49         ARM_ARCH_V4     = ARM_ARCH_V3M | ARM_EXT_V4,
50         ARM_ARCH_V4TxM  = ARM_ARCH_V4xM | ARM_EXT_V4T,
51         ARM_ARCH_V4T    = ARM_ARCH_V4 | ARM_EXT_V4T,
52         ARM_ARCH_V5xM   = ARM_ARCH_V4xM| ARM_EXT_V5,
53         ARM_ARCH_V5     = ARM_ARCH_V4 | ARM_EXT_V5,
54         ARM_ARCH_V5TxM  = ARM_ARCH_V5xM | ARM_EXT_V4T | ARM_EXT_V5T,
55         ARM_ARCH_V5T    = ARM_ARCH_V5 | ARM_EXT_V4T | ARM_EXT_V5T,
56         ARM_ARCH_V5TExP = ARM_ARCH_V5T | ARM_EXT_V5ExP,
57         ARM_ARCH_V5TE   = ARM_ARCH_V5TExP | ARM_EXT_V5E,
58         ARM_ARCH_V5TEJ  = ARM_ARCH_V5TE | ARM_EXT_V5J,
59
60         /* Processors with specific extensions in the co-processor space.  */
61         ARM_ARCH_XSCALE = ARM_ARCH_V5TE | ARM_CEXT_XSCALE,
62         ARM_ARCH_IWMMXT = ARM_ARCH_XSCALE | ARM_CEXT_IWMMXT,
63
64         ARM_ARCH_MASK   = 0x00ffffff,
65 };
66
67 /** Floating point instruction set. */
68 enum arm_fp_architectures {
69         ARM_FPU_FPA_EXT_V1     = 0x80000000, /**< Base FPA instruction set. */
70         ARM_FPU_FPA_EXT_V2     = 0x40000000, /**< LFM/SFM. */
71         ARM_FPU_VFP_EXT_NONE   = 0x20000000, /**< Use VFP word-ordering. */
72         ARM_FPU_VFP_EXT_V1xD   = 0x10000000, /**< Base VFP instruction set. */
73         ARM_FPU_VFP_EXT_V1     = 0x08000000, /**< Double-precision insns. */
74         ARM_FPU_VFP_EXT_V2     = 0x04000000, /**< ARM10E VFPr1. */
75
76         ARM_FPU_SOFTFLOAT      = 0x01000000, /**< soft float library */
77         ARM_FPU_NONE           = 0,
78
79         ARM_FPU_ARCH_FPE       = ARM_FPU_FPA_EXT_V1,
80         ARM_FPU_ARCH_FPA       = ARM_FPU_ARCH_FPE | ARM_FPU_FPA_EXT_V2,
81
82         ARM_FPU_ARCH_VFP       = ARM_FPU_VFP_EXT_NONE,
83         ARM_FPU_ARCH_VFP_V1xD  = ARM_FPU_VFP_EXT_V1xD | ARM_FPU_VFP_EXT_NONE,
84         ARM_FPU_ARCH_VFP_V1    = ARM_FPU_ARCH_VFP_V1xD | ARM_FPU_VFP_EXT_V1,
85         ARM_FPU_ARCH_VFP_V2    = ARM_FPU_ARCH_VFP_V1 | ARM_FPU_VFP_EXT_V2,
86
87         ARM_FPU_ARCH_SOFTFLOAT = ARM_FPU_SOFTFLOAT,
88
89         ARM_FPU_MASK           = 0xff000000,
90 };
91
92 /** Returns non-zero if FPA instructions should be issued. */
93 #define USE_FPA(cg)      ((cg)->fpu_arch & ARM_FPU_FPA_EXT_V1)
94
95 /** Returns non-zero if VFP instructions should be issued. */
96 #define USE_VFP(cg)      ((cg)->fpu_arch & ARM_FPU_VFP_EXT_V1xD)
97
98 /** Types of processor to generate code for. */
99 enum arm_processor_types {
100         ARM_1      = ARM_ARCH_V1,
101         ARM_2      = ARM_ARCH_V2,
102         ARM_3      = ARM_ARCH_V2S,
103         ARM_250    = ARM_ARCH_V2S,
104         ARM_6      = ARM_ARCH_V3,
105         ARM_7      = ARM_ARCH_V3,
106         ARM_8      = ARM_ARCH_V4,
107         ARM_9      = ARM_ARCH_V4T,
108         ARM_STRONG = ARM_ARCH_V4,
109 };
110
111 typedef struct _arm_code_gen_t {
112         const arch_code_generator_if_t *impl;           /**< implementation */
113         ir_graph                       *irg;            /**< current irg */
114         const arch_env_t               *arch_env;       /**< the arch env */
115         set                            *reg_set;        /**< set to memorize registers for FIRM nodes (e.g. phi) */
116         int                             emit_decls;     /**< flag indicating if decls were already emitted */
117         arm_isa_t                      *isa;            /**< the isa instance */
118         const be_irg_t                 *birg;           /**< The be-irg (contains additional information about the irg) */
119         ir_type                        *int_tp;         /**< the int type, needed for Call conversion */
120         int                             have_fp;        /**< non-zero, if fp hardware instructions are emitted */
121         DEBUG_ONLY(firm_dbg_module_t   *mod;)            /**< debugging module */
122 } arm_code_gen_t;
123
124
125 struct _arm_isa_t {
126         const arch_isa_if_t   *impl;
127         const arch_register_t *sp;            /**< The stack pointer register. */
128         const arch_register_t *bp;            /**< The base pointer register. */
129         const int              stack_dir;     /**< -1 for decreasing, 1 for increasing. */
130         int                    num_codegens;
131         int                    gen_reg_names; /**< use generic register names instead of SP, LR, PC */
132         arm_code_gen_t        *cg;            /**< current code generator */
133         FILE                  *out;           /**< output file */
134
135         unsigned               fpu_arch;      /**< FPU architecture */
136 };
137
138
139 typedef struct _arm_irn_ops_t {
140         const arch_irn_ops_if_t *impl;
141         arm_code_gen_t     *cg;
142 } arm_irn_ops_t;
143
144
145 #endif /* _BEARCH_ARM_T_H_ */