annotate gcc/config/riscv/riscv.h @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Definition of RISC-V target for GNU compiler.
kono
parents:
diff changeset
2 Copyright (C) 2011-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
3 Contributed by Andrew Waterman (andrew@sifive.com).
kono
parents:
diff changeset
4 Based on MIPS target for GNU compiler.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 This file is part of GCC.
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 GCC is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
10 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
11 any later version.
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 GCC is distributed in the hope that it will be useful,
kono
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
16 GNU General Public License for more details.
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
19 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
20 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 #ifndef GCC_RISCV_H
kono
parents:
diff changeset
23 #define GCC_RISCV_H
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 #include "config/riscv/riscv-opts.h"
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 /* Target CPU builtins. */
kono
parents:
diff changeset
28 #define TARGET_CPU_CPP_BUILTINS() riscv_cpu_cpp_builtins (pfile)
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 /* Default target_flags if no switches are specified */
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 #ifndef TARGET_DEFAULT
kono
parents:
diff changeset
33 #define TARGET_DEFAULT 0
kono
parents:
diff changeset
34 #endif
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 #ifndef RISCV_TUNE_STRING_DEFAULT
kono
parents:
diff changeset
37 #define RISCV_TUNE_STRING_DEFAULT "rocket"
kono
parents:
diff changeset
38 #endif
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 /* Support for a compile-time default CPU, et cetera. The rules are:
kono
parents:
diff changeset
41 --with-arch is ignored if -march is specified.
kono
parents:
diff changeset
42 --with-abi is ignored if -mabi is specified.
kono
parents:
diff changeset
43 --with-tune is ignored if -mtune is specified. */
kono
parents:
diff changeset
44 #define OPTION_DEFAULT_SPECS \
kono
parents:
diff changeset
45 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
kono
parents:
diff changeset
46 {"arch", "%{!march=*:-march=%(VALUE)}" }, \
kono
parents:
diff changeset
47 {"abi", "%{!mabi=*:-mabi=%(VALUE)}" }, \
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 #ifdef IN_LIBGCC2
kono
parents:
diff changeset
50 #undef TARGET_64BIT
kono
parents:
diff changeset
51 /* Make this compile time constant for libgcc2 */
kono
parents:
diff changeset
52 #define TARGET_64BIT (__riscv_xlen == 64)
kono
parents:
diff changeset
53 #endif /* IN_LIBGCC2 */
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 #undef ASM_SPEC
kono
parents:
diff changeset
56 #define ASM_SPEC "\
kono
parents:
diff changeset
57 %(subtarget_asm_debugging_spec) \
kono
parents:
diff changeset
58 %{" FPIE_OR_FPIC_SPEC ":-fpic} \
kono
parents:
diff changeset
59 %{march=*} \
kono
parents:
diff changeset
60 %{mabi=*} \
kono
parents:
diff changeset
61 %(subtarget_asm_spec)"
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 #define TARGET_DEFAULT_CMODEL CM_MEDLOW
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 #define LOCAL_LABEL_PREFIX "."
kono
parents:
diff changeset
66 #define USER_LABEL_PREFIX ""
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 /* Offsets recorded in opcodes are a multiple of this alignment factor.
kono
parents:
diff changeset
69 The default for this in 64-bit mode is 8, which causes problems with
kono
parents:
diff changeset
70 SFmode register saves. */
kono
parents:
diff changeset
71 #define DWARF_CIE_DATA_ALIGNMENT -4
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 /* The mapping from gcc register number to DWARF 2 CFA column number. */
kono
parents:
diff changeset
74 #define DWARF_FRAME_REGNUM(REGNO) \
kono
parents:
diff changeset
75 (GP_REG_P (REGNO) || FP_REG_P (REGNO) ? REGNO : INVALID_REGNUM)
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 /* The DWARF 2 CFA column which tracks the return address. */
kono
parents:
diff changeset
78 #define DWARF_FRAME_RETURN_COLUMN RETURN_ADDR_REGNUM
kono
parents:
diff changeset
79 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (VOIDmode, RETURN_ADDR_REGNUM)
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 /* Describe how we implement __builtin_eh_return. */
kono
parents:
diff changeset
82 #define EH_RETURN_DATA_REGNO(N) \
kono
parents:
diff changeset
83 ((N) < 4 ? (N) + GP_ARG_FIRST : INVALID_REGNUM)
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, GP_ARG_FIRST + 4)
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 /* Target machine storage layout */
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 #define BITS_BIG_ENDIAN 0
kono
parents:
diff changeset
90 #define BYTES_BIG_ENDIAN 0
kono
parents:
diff changeset
91 #define WORDS_BIG_ENDIAN 0
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 #define MAX_BITS_PER_WORD 64
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 /* Width of a word, in units (bytes). */
kono
parents:
diff changeset
96 #define UNITS_PER_WORD (TARGET_64BIT ? 8 : 4)
kono
parents:
diff changeset
97 #ifndef IN_LIBGCC2
kono
parents:
diff changeset
98 #define MIN_UNITS_PER_WORD 4
kono
parents:
diff changeset
99 #endif
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 /* The `Q' extension is not yet supported. */
kono
parents:
diff changeset
102 #define UNITS_PER_FP_REG (TARGET_DOUBLE_FLOAT ? 8 : 4)
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 /* The largest type that can be passed in floating-point registers. */
kono
parents:
diff changeset
105 #define UNITS_PER_FP_ARG \
kono
parents:
diff changeset
106 (riscv_abi == ABI_ILP32 || riscv_abi == ABI_LP64 ? 0 : \
kono
parents:
diff changeset
107 riscv_abi == ABI_ILP32F || riscv_abi == ABI_LP64F ? 4 : 8) \
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 /* Set the sizes of the core types. */
kono
parents:
diff changeset
110 #define SHORT_TYPE_SIZE 16
kono
parents:
diff changeset
111 #define INT_TYPE_SIZE 32
kono
parents:
diff changeset
112 #define LONG_LONG_TYPE_SIZE 64
kono
parents:
diff changeset
113 #define POINTER_SIZE (riscv_abi >= ABI_LP64 ? 64 : 32)
kono
parents:
diff changeset
114 #define LONG_TYPE_SIZE POINTER_SIZE
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 #define FLOAT_TYPE_SIZE 32
kono
parents:
diff changeset
117 #define DOUBLE_TYPE_SIZE 64
kono
parents:
diff changeset
118 #define LONG_DOUBLE_TYPE_SIZE 128
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
kono
parents:
diff changeset
121 #define PARM_BOUNDARY BITS_PER_WORD
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 /* Allocation boundary (in *bits*) for the code of a function. */
kono
parents:
diff changeset
124 #define FUNCTION_BOUNDARY (TARGET_RVC ? 16 : 32)
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 /* There is no point aligning anything to a rounder boundary than this. */
kono
parents:
diff changeset
127 #define BIGGEST_ALIGNMENT 128
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 /* The user-level ISA permits unaligned accesses, but they are not required
kono
parents:
diff changeset
130 of the privileged architecture. */
kono
parents:
diff changeset
131 #define STRICT_ALIGNMENT TARGET_STRICT_ALIGN
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 /* Define this if you wish to imitate the way many other C compilers
kono
parents:
diff changeset
134 handle alignment of bitfields and the structures that contain
kono
parents:
diff changeset
135 them.
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 The behavior is that the type written for a bit-field (`int',
kono
parents:
diff changeset
138 `short', or other integer type) imposes an alignment for the
kono
parents:
diff changeset
139 entire structure, as if the structure really did contain an
kono
parents:
diff changeset
140 ordinary field of that type. In addition, the bit-field is placed
kono
parents:
diff changeset
141 within the structure so that it would fit within such a field,
kono
parents:
diff changeset
142 not crossing a boundary for it.
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 Thus, on most machines, a bit-field whose type is written as `int'
kono
parents:
diff changeset
145 would not cross a four-byte boundary, and would force four-byte
kono
parents:
diff changeset
146 alignment for the whole structure. (The alignment used may not
kono
parents:
diff changeset
147 be four bytes; it is controlled by the other alignment
kono
parents:
diff changeset
148 parameters.)
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 If the macro is defined, its definition should be a C expression;
kono
parents:
diff changeset
151 a nonzero value for the expression enables this behavior. */
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 #define PCC_BITFIELD_TYPE_MATTERS 1
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 /* If defined, a C expression to compute the alignment for a static
kono
parents:
diff changeset
156 variable. TYPE is the data type, and ALIGN is the alignment that
kono
parents:
diff changeset
157 the object would ordinarily have. The value of this macro is used
kono
parents:
diff changeset
158 instead of that alignment to align the object.
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 If this macro is not defined, then ALIGN is used.
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 One use of this macro is to increase alignment of medium-size
kono
parents:
diff changeset
163 data to make it all fit in fewer cache lines. Another is to
kono
parents:
diff changeset
164 cause character arrays to be word-aligned so that `strcpy' calls
kono
parents:
diff changeset
165 that copy constants to character arrays can be done inline. */
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 #define DATA_ALIGNMENT(TYPE, ALIGN) \
kono
parents:
diff changeset
168 ((((ALIGN) < BITS_PER_WORD) \
kono
parents:
diff changeset
169 && (TREE_CODE (TYPE) == ARRAY_TYPE \
kono
parents:
diff changeset
170 || TREE_CODE (TYPE) == UNION_TYPE \
kono
parents:
diff changeset
171 || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 /* We need this for the same reason as DATA_ALIGNMENT, namely to cause
kono
parents:
diff changeset
174 character arrays to be word-aligned so that `strcpy' calls that copy
kono
parents:
diff changeset
175 constants to character arrays can be done inline, and 'strcmp' can be
kono
parents:
diff changeset
176 optimised to use word loads. */
kono
parents:
diff changeset
177 #define LOCAL_ALIGNMENT(TYPE, ALIGN) \
kono
parents:
diff changeset
178 DATA_ALIGNMENT (TYPE, ALIGN)
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 /* Define if operations between registers always perform the operation
kono
parents:
diff changeset
181 on the full register even if a narrower mode is specified. */
kono
parents:
diff changeset
182 #define WORD_REGISTER_OPERATIONS 1
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 /* When in 64-bit mode, move insns will sign extend SImode and CCmode
kono
parents:
diff changeset
185 moves. All other references are zero extended. */
kono
parents:
diff changeset
186 #define LOAD_EXTEND_OP(MODE) \
kono
parents:
diff changeset
187 (TARGET_64BIT && (MODE) == SImode ? SIGN_EXTEND : ZERO_EXTEND)
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 /* Define this macro if it is advisable to hold scalars in registers
kono
parents:
diff changeset
190 in a wider mode than that declared by the program. In such cases,
kono
parents:
diff changeset
191 the value is constrained to be within the bounds of the declared
kono
parents:
diff changeset
192 type, but kept valid in the wider mode. The signedness of the
kono
parents:
diff changeset
193 extension may differ from that of the type. */
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
kono
parents:
diff changeset
196 if (GET_MODE_CLASS (MODE) == MODE_INT \
kono
parents:
diff changeset
197 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
kono
parents:
diff changeset
198 { \
kono
parents:
diff changeset
199 if ((MODE) == SImode) \
kono
parents:
diff changeset
200 (UNSIGNEDP) = 0; \
kono
parents:
diff changeset
201 (MODE) = word_mode; \
kono
parents:
diff changeset
202 }
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 /* Pmode is always the same as ptr_mode, but not always the same as word_mode.
kono
parents:
diff changeset
205 Extensions of pointers to word_mode must be signed. */
kono
parents:
diff changeset
206 #define POINTERS_EXTEND_UNSIGNED false
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 /* Define if loading short immediate values into registers sign extends. */
kono
parents:
diff changeset
209 #define SHORT_IMMEDIATES_SIGN_EXTEND 1
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 /* Standard register usage. */
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 /* Number of hardware registers. We have:
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 - 32 integer registers
kono
parents:
diff changeset
216 - 32 floating point registers
kono
parents:
diff changeset
217 - 2 fake registers:
kono
parents:
diff changeset
218 - ARG_POINTER_REGNUM
kono
parents:
diff changeset
219 - FRAME_POINTER_REGNUM */
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221 #define FIRST_PSEUDO_REGISTER 66
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 /* x0, sp, gp, and tp are fixed. */
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 #define FIXED_REGISTERS \
kono
parents:
diff changeset
226 { /* General registers. */ \
kono
parents:
diff changeset
227 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
kono
parents:
diff changeset
228 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
kono
parents:
diff changeset
229 /* Floating-point registers. */ \
kono
parents:
diff changeset
230 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
kono
parents:
diff changeset
231 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
kono
parents:
diff changeset
232 /* Others. */ \
kono
parents:
diff changeset
233 1, 1 \
kono
parents:
diff changeset
234 }
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 /* a0-a7, t0-a6, fa0-fa7, and ft0-ft11 are volatile across calls.
kono
parents:
diff changeset
237 The call RTLs themselves clobber ra. */
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 #define CALL_USED_REGISTERS \
kono
parents:
diff changeset
240 { /* General registers. */ \
kono
parents:
diff changeset
241 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, \
kono
parents:
diff changeset
242 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, \
kono
parents:
diff changeset
243 /* Floating-point registers. */ \
kono
parents:
diff changeset
244 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, \
kono
parents:
diff changeset
245 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, \
kono
parents:
diff changeset
246 /* Others. */ \
kono
parents:
diff changeset
247 1, 1 \
kono
parents:
diff changeset
248 }
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 /* Internal macros to classify an ISA register's type. */
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 #define GP_REG_FIRST 0
kono
parents:
diff changeset
253 #define GP_REG_LAST 31
kono
parents:
diff changeset
254 #define GP_REG_NUM (GP_REG_LAST - GP_REG_FIRST + 1)
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 #define FP_REG_FIRST 32
kono
parents:
diff changeset
257 #define FP_REG_LAST 63
kono
parents:
diff changeset
258 #define FP_REG_NUM (FP_REG_LAST - FP_REG_FIRST + 1)
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 /* The DWARF 2 CFA column which tracks the return address from a
kono
parents:
diff changeset
261 signal handler context. This means that to maintain backwards
kono
parents:
diff changeset
262 compatibility, no hard register can be assigned this column if it
kono
parents:
diff changeset
263 would need to be handled by the DWARF unwinder. */
kono
parents:
diff changeset
264 #define DWARF_ALT_FRAME_RETURN_COLUMN 64
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 #define GP_REG_P(REGNO) \
kono
parents:
diff changeset
267 ((unsigned int) ((int) (REGNO) - GP_REG_FIRST) < GP_REG_NUM)
kono
parents:
diff changeset
268 #define FP_REG_P(REGNO) \
kono
parents:
diff changeset
269 ((unsigned int) ((int) (REGNO) - FP_REG_FIRST) < FP_REG_NUM)
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 #define FP_REG_RTX_P(X) (REG_P (X) && FP_REG_P (REGNO (X)))
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 /* Use s0 as the frame pointer if it is so requested. */
kono
parents:
diff changeset
274 #define HARD_FRAME_POINTER_REGNUM 8
kono
parents:
diff changeset
275 #define STACK_POINTER_REGNUM 2
kono
parents:
diff changeset
276 #define THREAD_POINTER_REGNUM 4
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 /* These two registers don't really exist: they get eliminated to either
kono
parents:
diff changeset
279 the stack or hard frame pointer. */
kono
parents:
diff changeset
280 #define ARG_POINTER_REGNUM 64
kono
parents:
diff changeset
281 #define FRAME_POINTER_REGNUM 65
kono
parents:
diff changeset
282
kono
parents:
diff changeset
283 /* Register in which static-chain is passed to a function. */
kono
parents:
diff changeset
284 #define STATIC_CHAIN_REGNUM (GP_TEMP_FIRST + 2)
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 /* Registers used as temporaries in prologue/epilogue code.
kono
parents:
diff changeset
287
kono
parents:
diff changeset
288 The prologue registers mustn't conflict with any
kono
parents:
diff changeset
289 incoming arguments, the static chain pointer, or the frame pointer.
kono
parents:
diff changeset
290 The epilogue temporary mustn't conflict with the return registers,
kono
parents:
diff changeset
291 the frame pointer, the EH stack adjustment, or the EH data registers. */
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 #define RISCV_PROLOGUE_TEMP_REGNUM (GP_TEMP_FIRST + 1)
kono
parents:
diff changeset
294 #define RISCV_PROLOGUE_TEMP(MODE) gen_rtx_REG (MODE, RISCV_PROLOGUE_TEMP_REGNUM)
kono
parents:
diff changeset
295
kono
parents:
diff changeset
296 #define MCOUNT_NAME "_mcount"
kono
parents:
diff changeset
297
kono
parents:
diff changeset
298 #define NO_PROFILE_COUNTERS 1
kono
parents:
diff changeset
299
kono
parents:
diff changeset
300 /* Emit rtl for profiling. Output assembler code to FILE
kono
parents:
diff changeset
301 to call "_mcount" for profiling a function entry. */
kono
parents:
diff changeset
302 #define PROFILE_HOOK(LABEL) \
kono
parents:
diff changeset
303 { \
kono
parents:
diff changeset
304 rtx fun, ra; \
kono
parents:
diff changeset
305 ra = get_hard_reg_initial_val (Pmode, RETURN_ADDR_REGNUM); \
kono
parents:
diff changeset
306 fun = gen_rtx_SYMBOL_REF (Pmode, MCOUNT_NAME); \
kono
parents:
diff changeset
307 emit_library_call (fun, LCT_NORMAL, VOIDmode, ra, Pmode); \
kono
parents:
diff changeset
308 }
kono
parents:
diff changeset
309
kono
parents:
diff changeset
310 /* All the work done in PROFILE_HOOK, but still required. */
kono
parents:
diff changeset
311 #define FUNCTION_PROFILER(STREAM, LABELNO) do { } while (0)
kono
parents:
diff changeset
312
kono
parents:
diff changeset
313 /* Define this macro if it is as good or better to call a constant
kono
parents:
diff changeset
314 function address than to call an address kept in a register. */
kono
parents:
diff changeset
315 #define NO_FUNCTION_CSE 1
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 /* Define the classes of registers for register constraints in the
kono
parents:
diff changeset
318 machine description. Also define ranges of constants.
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 One of the classes must always be named ALL_REGS and include all hard regs.
kono
parents:
diff changeset
321 If there is more than one class, another class must be named NO_REGS
kono
parents:
diff changeset
322 and contain no registers.
kono
parents:
diff changeset
323
kono
parents:
diff changeset
324 The name GENERAL_REGS must be the name of a class (or an alias for
kono
parents:
diff changeset
325 another name such as ALL_REGS). This is the class of registers
kono
parents:
diff changeset
326 that is allowed by "g" or "r" in a register constraint.
kono
parents:
diff changeset
327 Also, registers outside this class are allocated only when
kono
parents:
diff changeset
328 instructions express preferences for them.
kono
parents:
diff changeset
329
kono
parents:
diff changeset
330 The classes must be numbered in nondecreasing order; that is,
kono
parents:
diff changeset
331 a larger-numbered class must never be contained completely
kono
parents:
diff changeset
332 in a smaller-numbered class.
kono
parents:
diff changeset
333
kono
parents:
diff changeset
334 For any two classes, it is very desirable that there be another
kono
parents:
diff changeset
335 class that represents their union. */
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 enum reg_class
kono
parents:
diff changeset
338 {
kono
parents:
diff changeset
339 NO_REGS, /* no registers in set */
kono
parents:
diff changeset
340 SIBCALL_REGS, /* registers used by indirect sibcalls */
kono
parents:
diff changeset
341 JALR_REGS, /* registers used by indirect calls */
kono
parents:
diff changeset
342 GR_REGS, /* integer registers */
kono
parents:
diff changeset
343 FP_REGS, /* floating-point registers */
kono
parents:
diff changeset
344 FRAME_REGS, /* arg pointer and frame pointer */
kono
parents:
diff changeset
345 ALL_REGS, /* all registers */
kono
parents:
diff changeset
346 LIM_REG_CLASSES /* max value + 1 */
kono
parents:
diff changeset
347 };
kono
parents:
diff changeset
348
kono
parents:
diff changeset
349 #define N_REG_CLASSES (int) LIM_REG_CLASSES
kono
parents:
diff changeset
350
kono
parents:
diff changeset
351 #define GENERAL_REGS GR_REGS
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 /* An initializer containing the names of the register classes as C
kono
parents:
diff changeset
354 string constants. These names are used in writing some of the
kono
parents:
diff changeset
355 debugging dumps. */
kono
parents:
diff changeset
356
kono
parents:
diff changeset
357 #define REG_CLASS_NAMES \
kono
parents:
diff changeset
358 { \
kono
parents:
diff changeset
359 "NO_REGS", \
kono
parents:
diff changeset
360 "SIBCALL_REGS", \
kono
parents:
diff changeset
361 "JALR_REGS", \
kono
parents:
diff changeset
362 "GR_REGS", \
kono
parents:
diff changeset
363 "FP_REGS", \
kono
parents:
diff changeset
364 "FRAME_REGS", \
kono
parents:
diff changeset
365 "ALL_REGS" \
kono
parents:
diff changeset
366 }
kono
parents:
diff changeset
367
kono
parents:
diff changeset
368 /* An initializer containing the contents of the register classes,
kono
parents:
diff changeset
369 as integers which are bit masks. The Nth integer specifies the
kono
parents:
diff changeset
370 contents of class N. The way the integer MASK is interpreted is
kono
parents:
diff changeset
371 that register R is in the class if `MASK & (1 << R)' is 1.
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373 When the machine has more than 32 registers, an integer does not
kono
parents:
diff changeset
374 suffice. Then the integers are replaced by sub-initializers,
kono
parents:
diff changeset
375 braced groupings containing several integers. Each
kono
parents:
diff changeset
376 sub-initializer must be suitable as an initializer for the type
kono
parents:
diff changeset
377 `HARD_REG_SET' which is defined in `hard-reg-set.h'. */
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 #define REG_CLASS_CONTENTS \
kono
parents:
diff changeset
380 { \
kono
parents:
diff changeset
381 { 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \
kono
parents:
diff changeset
382 { 0xf00000c0, 0x00000000, 0x00000000 }, /* SIBCALL_REGS */ \
kono
parents:
diff changeset
383 { 0xffffffc0, 0x00000000, 0x00000000 }, /* JALR_REGS */ \
kono
parents:
diff changeset
384 { 0xffffffff, 0x00000000, 0x00000000 }, /* GR_REGS */ \
kono
parents:
diff changeset
385 { 0x00000000, 0xffffffff, 0x00000000 }, /* FP_REGS */ \
kono
parents:
diff changeset
386 { 0x00000000, 0x00000000, 0x00000003 }, /* FRAME_REGS */ \
kono
parents:
diff changeset
387 { 0xffffffff, 0xffffffff, 0x00000003 } /* ALL_REGS */ \
kono
parents:
diff changeset
388 }
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 /* A C expression whose value is a register class containing hard
kono
parents:
diff changeset
391 register REGNO. In general there is more that one such class;
kono
parents:
diff changeset
392 choose a class which is "minimal", meaning that no smaller class
kono
parents:
diff changeset
393 also contains the register. */
kono
parents:
diff changeset
394
kono
parents:
diff changeset
395 #define REGNO_REG_CLASS(REGNO) riscv_regno_to_class[ (REGNO) ]
kono
parents:
diff changeset
396
kono
parents:
diff changeset
397 /* A macro whose definition is the name of the class to which a
kono
parents:
diff changeset
398 valid base register must belong. A base register is one used in
kono
parents:
diff changeset
399 an address which is the register value plus a displacement. */
kono
parents:
diff changeset
400
kono
parents:
diff changeset
401 #define BASE_REG_CLASS GR_REGS
kono
parents:
diff changeset
402
kono
parents:
diff changeset
403 /* A macro whose definition is the name of the class to which a
kono
parents:
diff changeset
404 valid index register must belong. An index register is one used
kono
parents:
diff changeset
405 in an address where its value is either multiplied by a scale
kono
parents:
diff changeset
406 factor or added to another register (as well as added to a
kono
parents:
diff changeset
407 displacement). */
kono
parents:
diff changeset
408
kono
parents:
diff changeset
409 #define INDEX_REG_CLASS NO_REGS
kono
parents:
diff changeset
410
kono
parents:
diff changeset
411 /* We generally want to put call-clobbered registers ahead of
kono
parents:
diff changeset
412 call-saved ones. (IRA expects this.) */
kono
parents:
diff changeset
413
kono
parents:
diff changeset
414 #define REG_ALLOC_ORDER \
kono
parents:
diff changeset
415 { \
kono
parents:
diff changeset
416 /* Call-clobbered GPRs. */ \
kono
parents:
diff changeset
417 15, 14, 13, 12, 11, 10, 16, 17, 6, 28, 29, 30, 31, 5, 7, 1, \
kono
parents:
diff changeset
418 /* Call-saved GPRs. */ \
kono
parents:
diff changeset
419 8, 9, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, \
kono
parents:
diff changeset
420 /* GPRs that can never be exposed to the register allocator. */ \
kono
parents:
diff changeset
421 0, 2, 3, 4, \
kono
parents:
diff changeset
422 /* Call-clobbered FPRs. */ \
kono
parents:
diff changeset
423 47, 46, 45, 44, 43, 42, 32, 33, 34, 35, 36, 37, 38, 39, 48, 49, \
kono
parents:
diff changeset
424 60, 61, 62, 63, \
kono
parents:
diff changeset
425 /* Call-saved FPRs. */ \
kono
parents:
diff changeset
426 40, 41, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, \
kono
parents:
diff changeset
427 /* None of the remaining classes have defined call-saved \
kono
parents:
diff changeset
428 registers. */ \
kono
parents:
diff changeset
429 64, 65 \
kono
parents:
diff changeset
430 }
kono
parents:
diff changeset
431
kono
parents:
diff changeset
432 /* True if VALUE is a signed 12-bit number. */
kono
parents:
diff changeset
433
kono
parents:
diff changeset
434 #define SMALL_OPERAND(VALUE) \
kono
parents:
diff changeset
435 ((unsigned HOST_WIDE_INT) (VALUE) + IMM_REACH/2 < IMM_REACH)
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437 /* True if VALUE can be loaded into a register using LUI. */
kono
parents:
diff changeset
438
kono
parents:
diff changeset
439 #define LUI_OPERAND(VALUE) \
kono
parents:
diff changeset
440 (((VALUE) | ((1UL<<31) - IMM_REACH)) == ((1UL<<31) - IMM_REACH) \
kono
parents:
diff changeset
441 || ((VALUE) | ((1UL<<31) - IMM_REACH)) + IMM_REACH == 0)
kono
parents:
diff changeset
442
kono
parents:
diff changeset
443 /* Stack layout; function entry, exit and calling. */
kono
parents:
diff changeset
444
kono
parents:
diff changeset
445 #define STACK_GROWS_DOWNWARD 1
kono
parents:
diff changeset
446
kono
parents:
diff changeset
447 #define FRAME_GROWS_DOWNWARD 1
kono
parents:
diff changeset
448
kono
parents:
diff changeset
449 #define RETURN_ADDR_RTX riscv_return_addr
kono
parents:
diff changeset
450
kono
parents:
diff changeset
451 #define ELIMINABLE_REGS \
kono
parents:
diff changeset
452 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
kono
parents:
diff changeset
453 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
kono
parents:
diff changeset
454 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
kono
parents:
diff changeset
455 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}} \
kono
parents:
diff changeset
456
kono
parents:
diff changeset
457 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
kono
parents:
diff changeset
458 (OFFSET) = riscv_initial_elimination_offset (FROM, TO)
kono
parents:
diff changeset
459
kono
parents:
diff changeset
460 /* Allocate stack space for arguments at the beginning of each function. */
kono
parents:
diff changeset
461 #define ACCUMULATE_OUTGOING_ARGS 1
kono
parents:
diff changeset
462
kono
parents:
diff changeset
463 /* The argument pointer always points to the first argument. */
kono
parents:
diff changeset
464 #define FIRST_PARM_OFFSET(FNDECL) 0
kono
parents:
diff changeset
465
kono
parents:
diff changeset
466 #define REG_PARM_STACK_SPACE(FNDECL) 0
kono
parents:
diff changeset
467
kono
parents:
diff changeset
468 /* Define this if it is the responsibility of the caller to
kono
parents:
diff changeset
469 allocate the area reserved for arguments passed in registers.
kono
parents:
diff changeset
470 If `ACCUMULATE_OUTGOING_ARGS' is also defined, the only effect
kono
parents:
diff changeset
471 of this macro is to determine whether the space is included in
kono
parents:
diff changeset
472 `crtl->outgoing_args_size'. */
kono
parents:
diff changeset
473 #define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
kono
parents:
diff changeset
474
kono
parents:
diff changeset
475 #define STACK_BOUNDARY 128
kono
parents:
diff changeset
476
kono
parents:
diff changeset
477 /* Symbolic macros for the registers used to return integer and floating
kono
parents:
diff changeset
478 point values. */
kono
parents:
diff changeset
479
kono
parents:
diff changeset
480 #define GP_RETURN GP_ARG_FIRST
kono
parents:
diff changeset
481 #define FP_RETURN (UNITS_PER_FP_ARG == 0 ? GP_RETURN : FP_ARG_FIRST)
kono
parents:
diff changeset
482
kono
parents:
diff changeset
483 #define MAX_ARGS_IN_REGISTERS 8
kono
parents:
diff changeset
484
kono
parents:
diff changeset
485 /* Symbolic macros for the first/last argument registers. */
kono
parents:
diff changeset
486
kono
parents:
diff changeset
487 #define GP_ARG_FIRST (GP_REG_FIRST + 10)
kono
parents:
diff changeset
488 #define GP_ARG_LAST (GP_ARG_FIRST + MAX_ARGS_IN_REGISTERS - 1)
kono
parents:
diff changeset
489 #define GP_TEMP_FIRST (GP_REG_FIRST + 5)
kono
parents:
diff changeset
490 #define FP_ARG_FIRST (FP_REG_FIRST + 10)
kono
parents:
diff changeset
491 #define FP_ARG_LAST (FP_ARG_FIRST + MAX_ARGS_IN_REGISTERS - 1)
kono
parents:
diff changeset
492
kono
parents:
diff changeset
493 #define CALLEE_SAVED_REG_NUMBER(REGNO) \
kono
parents:
diff changeset
494 ((REGNO) >= 8 && (REGNO) <= 9 ? (REGNO) - 8 : \
kono
parents:
diff changeset
495 (REGNO) >= 18 && (REGNO) <= 27 ? (REGNO) - 16 : -1)
kono
parents:
diff changeset
496
kono
parents:
diff changeset
497 #define LIBCALL_VALUE(MODE) \
kono
parents:
diff changeset
498 riscv_function_value (NULL_TREE, NULL_TREE, MODE)
kono
parents:
diff changeset
499
kono
parents:
diff changeset
500 #define FUNCTION_VALUE(VALTYPE, FUNC) \
kono
parents:
diff changeset
501 riscv_function_value (VALTYPE, FUNC, VOIDmode)
kono
parents:
diff changeset
502
kono
parents:
diff changeset
503 #define FUNCTION_VALUE_REGNO_P(N) ((N) == GP_RETURN || (N) == FP_RETURN)
kono
parents:
diff changeset
504
kono
parents:
diff changeset
505 /* 1 if N is a possible register number for function argument passing.
kono
parents:
diff changeset
506 We have no FP argument registers when soft-float. When FP registers
kono
parents:
diff changeset
507 are 32 bits, we can't directly reference the odd numbered ones. */
kono
parents:
diff changeset
508
kono
parents:
diff changeset
509 /* Accept arguments in a0-a7, and in fa0-fa7 if permitted by the ABI. */
kono
parents:
diff changeset
510 #define FUNCTION_ARG_REGNO_P(N) \
kono
parents:
diff changeset
511 (IN_RANGE ((N), GP_ARG_FIRST, GP_ARG_LAST) \
kono
parents:
diff changeset
512 || (UNITS_PER_FP_ARG && IN_RANGE ((N), FP_ARG_FIRST, FP_ARG_LAST)))
kono
parents:
diff changeset
513
kono
parents:
diff changeset
514 typedef struct {
kono
parents:
diff changeset
515 /* Number of integer registers used so far, up to MAX_ARGS_IN_REGISTERS. */
kono
parents:
diff changeset
516 unsigned int num_gprs;
kono
parents:
diff changeset
517
kono
parents:
diff changeset
518 /* Number of floating-point registers used so far, likewise. */
kono
parents:
diff changeset
519 unsigned int num_fprs;
kono
parents:
diff changeset
520 } CUMULATIVE_ARGS;
kono
parents:
diff changeset
521
kono
parents:
diff changeset
522 /* Initialize a variable CUM of type CUMULATIVE_ARGS
kono
parents:
diff changeset
523 for a call to a function whose data type is FNTYPE.
kono
parents:
diff changeset
524 For a library call, FNTYPE is 0. */
kono
parents:
diff changeset
525
kono
parents:
diff changeset
526 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
kono
parents:
diff changeset
527 memset (&(CUM), 0, sizeof (CUM))
kono
parents:
diff changeset
528
kono
parents:
diff changeset
529 #define EPILOGUE_USES(REGNO) ((REGNO) == RETURN_ADDR_REGNUM)
kono
parents:
diff changeset
530
kono
parents:
diff changeset
531 /* ABI requires 16-byte alignment, even on RV32. */
kono
parents:
diff changeset
532 #define RISCV_STACK_ALIGN(LOC) (((LOC) + 15) & -16)
kono
parents:
diff changeset
533
kono
parents:
diff changeset
534 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
kono
parents:
diff changeset
535 the stack pointer does not matter. The value is tested only in
kono
parents:
diff changeset
536 functions that have frame pointers.
kono
parents:
diff changeset
537 No definition is equivalent to always zero. */
kono
parents:
diff changeset
538
kono
parents:
diff changeset
539 #define EXIT_IGNORE_STACK 1
kono
parents:
diff changeset
540
kono
parents:
diff changeset
541
kono
parents:
diff changeset
542 /* Trampolines are a block of code followed by two pointers. */
kono
parents:
diff changeset
543
kono
parents:
diff changeset
544 #define TRAMPOLINE_CODE_SIZE 16
kono
parents:
diff changeset
545 #define TRAMPOLINE_SIZE \
kono
parents:
diff changeset
546 ((Pmode == SImode) \
kono
parents:
diff changeset
547 ? TRAMPOLINE_CODE_SIZE \
kono
parents:
diff changeset
548 : (TRAMPOLINE_CODE_SIZE + POINTER_SIZE * 2))
kono
parents:
diff changeset
549 #define TRAMPOLINE_ALIGNMENT POINTER_SIZE
kono
parents:
diff changeset
550
kono
parents:
diff changeset
551 /* Addressing modes, and classification of registers for them. */
kono
parents:
diff changeset
552
kono
parents:
diff changeset
553 #define REGNO_OK_FOR_INDEX_P(REGNO) 0
kono
parents:
diff changeset
554 #define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \
kono
parents:
diff changeset
555 riscv_regno_mode_ok_for_base_p (REGNO, MODE, 1)
kono
parents:
diff changeset
556
kono
parents:
diff changeset
557 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
kono
parents:
diff changeset
558 and check its validity for a certain class.
kono
parents:
diff changeset
559 We have two alternate definitions for each of them.
kono
parents:
diff changeset
560 The usual definition accepts all pseudo regs; the other rejects them all.
kono
parents:
diff changeset
561 The symbol REG_OK_STRICT causes the latter definition to be used.
kono
parents:
diff changeset
562
kono
parents:
diff changeset
563 Most source files want to accept pseudo regs in the hope that
kono
parents:
diff changeset
564 they will get allocated to the class that the insn wants them to be in.
kono
parents:
diff changeset
565 Some source files that are used after register allocation
kono
parents:
diff changeset
566 need to be strict. */
kono
parents:
diff changeset
567
kono
parents:
diff changeset
568 #ifndef REG_OK_STRICT
kono
parents:
diff changeset
569 #define REG_MODE_OK_FOR_BASE_P(X, MODE) \
kono
parents:
diff changeset
570 riscv_regno_mode_ok_for_base_p (REGNO (X), MODE, 0)
kono
parents:
diff changeset
571 #else
kono
parents:
diff changeset
572 #define REG_MODE_OK_FOR_BASE_P(X, MODE) \
kono
parents:
diff changeset
573 riscv_regno_mode_ok_for_base_p (REGNO (X), MODE, 1)
kono
parents:
diff changeset
574 #endif
kono
parents:
diff changeset
575
kono
parents:
diff changeset
576 #define REG_OK_FOR_INDEX_P(X) 0
kono
parents:
diff changeset
577
kono
parents:
diff changeset
578 /* Maximum number of registers that can appear in a valid memory address. */
kono
parents:
diff changeset
579
kono
parents:
diff changeset
580 #define MAX_REGS_PER_ADDRESS 1
kono
parents:
diff changeset
581
kono
parents:
diff changeset
582 #define CONSTANT_ADDRESS_P(X) \
kono
parents:
diff changeset
583 (CONSTANT_P (X) && memory_address_p (SImode, X))
kono
parents:
diff changeset
584
kono
parents:
diff changeset
585 /* This handles the magic '..CURRENT_FUNCTION' symbol, which means
kono
parents:
diff changeset
586 'the start of the function that this code is output in'. */
kono
parents:
diff changeset
587
kono
parents:
diff changeset
588 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
kono
parents:
diff changeset
589 if (strcmp (NAME, "..CURRENT_FUNCTION") == 0) \
kono
parents:
diff changeset
590 asm_fprintf ((FILE), "%U%s", \
kono
parents:
diff changeset
591 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \
kono
parents:
diff changeset
592 else \
kono
parents:
diff changeset
593 asm_fprintf ((FILE), "%U%s", (NAME))
kono
parents:
diff changeset
594
kono
parents:
diff changeset
595 #define JUMP_TABLES_IN_TEXT_SECTION 0
kono
parents:
diff changeset
596 #define CASE_VECTOR_MODE SImode
kono
parents:
diff changeset
597 #define CASE_VECTOR_PC_RELATIVE (riscv_cmodel != CM_MEDLOW)
kono
parents:
diff changeset
598
kono
parents:
diff changeset
599 /* The load-address macro is used for PC-relative addressing of symbols
kono
parents:
diff changeset
600 that bind locally. Don't use it for symbols that should be addressed
kono
parents:
diff changeset
601 via the GOT. Also, avoid it for CM_MEDLOW, where LUI addressing
kono
parents:
diff changeset
602 currently results in more opportunities for linker relaxation. */
kono
parents:
diff changeset
603 #define USE_LOAD_ADDRESS_MACRO(sym) \
kono
parents:
diff changeset
604 (!TARGET_EXPLICIT_RELOCS && \
kono
parents:
diff changeset
605 ((flag_pic \
kono
parents:
diff changeset
606 && ((SYMBOL_REF_P (sym) && SYMBOL_REF_LOCAL_P (sym)) \
kono
parents:
diff changeset
607 || ((GET_CODE (sym) == CONST) \
kono
parents:
diff changeset
608 && SYMBOL_REF_P (XEXP (XEXP (sym, 0),0)) \
kono
parents:
diff changeset
609 && SYMBOL_REF_LOCAL_P (XEXP (XEXP (sym, 0),0))))) \
kono
parents:
diff changeset
610 || riscv_cmodel == CM_MEDANY))
kono
parents:
diff changeset
611
kono
parents:
diff changeset
612 /* Define this as 1 if `char' should by default be signed; else as 0. */
kono
parents:
diff changeset
613 #define DEFAULT_SIGNED_CHAR 0
kono
parents:
diff changeset
614
kono
parents:
diff changeset
615 #define MOVE_MAX UNITS_PER_WORD
kono
parents:
diff changeset
616 #define MAX_MOVE_MAX 8
kono
parents:
diff changeset
617
kono
parents:
diff changeset
618 #define SLOW_BYTE_ACCESS 0
kono
parents:
diff changeset
619
kono
parents:
diff changeset
620 #define SHIFT_COUNT_TRUNCATED 1
kono
parents:
diff changeset
621
kono
parents:
diff changeset
622 /* Specify the machine mode that pointers have.
kono
parents:
diff changeset
623 After generation of rtl, the compiler makes no further distinction
kono
parents:
diff changeset
624 between pointers and any other objects of this machine mode. */
kono
parents:
diff changeset
625
kono
parents:
diff changeset
626 #define Pmode word_mode
kono
parents:
diff changeset
627
kono
parents:
diff changeset
628 /* Give call MEMs SImode since it is the "most permissive" mode
kono
parents:
diff changeset
629 for both 32-bit and 64-bit targets. */
kono
parents:
diff changeset
630
kono
parents:
diff changeset
631 #define FUNCTION_MODE SImode
kono
parents:
diff changeset
632
kono
parents:
diff changeset
633 /* A C expression for the cost of a branch instruction. A value of 2
kono
parents:
diff changeset
634 seems to minimize code size. */
kono
parents:
diff changeset
635
kono
parents:
diff changeset
636 #define BRANCH_COST(speed_p, predictable_p) \
kono
parents:
diff changeset
637 ((!(speed_p) || (predictable_p)) ? 2 : riscv_branch_cost)
kono
parents:
diff changeset
638
kono
parents:
diff changeset
639 #define LOGICAL_OP_NON_SHORT_CIRCUIT 0
kono
parents:
diff changeset
640
kono
parents:
diff changeset
641 /* Control the assembler format that we output. */
kono
parents:
diff changeset
642
kono
parents:
diff changeset
643 /* Output to assembler file text saying following lines
kono
parents:
diff changeset
644 may contain character constants, extra white space, comments, etc. */
kono
parents:
diff changeset
645
kono
parents:
diff changeset
646 #ifndef ASM_APP_ON
kono
parents:
diff changeset
647 #define ASM_APP_ON " #APP\n"
kono
parents:
diff changeset
648 #endif
kono
parents:
diff changeset
649
kono
parents:
diff changeset
650 /* Output to assembler file text saying following lines
kono
parents:
diff changeset
651 no longer contain unusual constructs. */
kono
parents:
diff changeset
652
kono
parents:
diff changeset
653 #ifndef ASM_APP_OFF
kono
parents:
diff changeset
654 #define ASM_APP_OFF " #NO_APP\n"
kono
parents:
diff changeset
655 #endif
kono
parents:
diff changeset
656
kono
parents:
diff changeset
657 #define REGISTER_NAMES \
kono
parents:
diff changeset
658 { "zero","ra", "sp", "gp", "tp", "t0", "t1", "t2", \
kono
parents:
diff changeset
659 "s0", "s1", "a0", "a1", "a2", "a3", "a4", "a5", \
kono
parents:
diff changeset
660 "a6", "a7", "s2", "s3", "s4", "s5", "s6", "s7", \
kono
parents:
diff changeset
661 "s8", "s9", "s10", "s11", "t3", "t4", "t5", "t6", \
kono
parents:
diff changeset
662 "ft0", "ft1", "ft2", "ft3", "ft4", "ft5", "ft6", "ft7", \
kono
parents:
diff changeset
663 "fs0", "fs1", "fa0", "fa1", "fa2", "fa3", "fa4", "fa5", \
kono
parents:
diff changeset
664 "fa6", "fa7", "fs2", "fs3", "fs4", "fs5", "fs6", "fs7", \
kono
parents:
diff changeset
665 "fs8", "fs9", "fs10","fs11","ft8", "ft9", "ft10","ft11", \
kono
parents:
diff changeset
666 "arg", "frame", }
kono
parents:
diff changeset
667
kono
parents:
diff changeset
668 #define ADDITIONAL_REGISTER_NAMES \
kono
parents:
diff changeset
669 { \
kono
parents:
diff changeset
670 { "x0", 0 + GP_REG_FIRST }, \
kono
parents:
diff changeset
671 { "x1", 1 + GP_REG_FIRST }, \
kono
parents:
diff changeset
672 { "x2", 2 + GP_REG_FIRST }, \
kono
parents:
diff changeset
673 { "x3", 3 + GP_REG_FIRST }, \
kono
parents:
diff changeset
674 { "x4", 4 + GP_REG_FIRST }, \
kono
parents:
diff changeset
675 { "x5", 5 + GP_REG_FIRST }, \
kono
parents:
diff changeset
676 { "x6", 6 + GP_REG_FIRST }, \
kono
parents:
diff changeset
677 { "x7", 7 + GP_REG_FIRST }, \
kono
parents:
diff changeset
678 { "x8", 8 + GP_REG_FIRST }, \
kono
parents:
diff changeset
679 { "x9", 9 + GP_REG_FIRST }, \
kono
parents:
diff changeset
680 { "x10", 10 + GP_REG_FIRST }, \
kono
parents:
diff changeset
681 { "x11", 11 + GP_REG_FIRST }, \
kono
parents:
diff changeset
682 { "x12", 12 + GP_REG_FIRST }, \
kono
parents:
diff changeset
683 { "x13", 13 + GP_REG_FIRST }, \
kono
parents:
diff changeset
684 { "x14", 14 + GP_REG_FIRST }, \
kono
parents:
diff changeset
685 { "x15", 15 + GP_REG_FIRST }, \
kono
parents:
diff changeset
686 { "x16", 16 + GP_REG_FIRST }, \
kono
parents:
diff changeset
687 { "x17", 17 + GP_REG_FIRST }, \
kono
parents:
diff changeset
688 { "x18", 18 + GP_REG_FIRST }, \
kono
parents:
diff changeset
689 { "x19", 19 + GP_REG_FIRST }, \
kono
parents:
diff changeset
690 { "x20", 20 + GP_REG_FIRST }, \
kono
parents:
diff changeset
691 { "x21", 21 + GP_REG_FIRST }, \
kono
parents:
diff changeset
692 { "x22", 22 + GP_REG_FIRST }, \
kono
parents:
diff changeset
693 { "x23", 23 + GP_REG_FIRST }, \
kono
parents:
diff changeset
694 { "x24", 24 + GP_REG_FIRST }, \
kono
parents:
diff changeset
695 { "x25", 25 + GP_REG_FIRST }, \
kono
parents:
diff changeset
696 { "x26", 26 + GP_REG_FIRST }, \
kono
parents:
diff changeset
697 { "x27", 27 + GP_REG_FIRST }, \
kono
parents:
diff changeset
698 { "x28", 28 + GP_REG_FIRST }, \
kono
parents:
diff changeset
699 { "x29", 29 + GP_REG_FIRST }, \
kono
parents:
diff changeset
700 { "x30", 30 + GP_REG_FIRST }, \
kono
parents:
diff changeset
701 { "x31", 31 + GP_REG_FIRST }, \
kono
parents:
diff changeset
702 { "f0", 0 + FP_REG_FIRST }, \
kono
parents:
diff changeset
703 { "f1", 1 + FP_REG_FIRST }, \
kono
parents:
diff changeset
704 { "f2", 2 + FP_REG_FIRST }, \
kono
parents:
diff changeset
705 { "f3", 3 + FP_REG_FIRST }, \
kono
parents:
diff changeset
706 { "f4", 4 + FP_REG_FIRST }, \
kono
parents:
diff changeset
707 { "f5", 5 + FP_REG_FIRST }, \
kono
parents:
diff changeset
708 { "f6", 6 + FP_REG_FIRST }, \
kono
parents:
diff changeset
709 { "f7", 7 + FP_REG_FIRST }, \
kono
parents:
diff changeset
710 { "f8", 8 + FP_REG_FIRST }, \
kono
parents:
diff changeset
711 { "f9", 9 + FP_REG_FIRST }, \
kono
parents:
diff changeset
712 { "f10", 10 + FP_REG_FIRST }, \
kono
parents:
diff changeset
713 { "f11", 11 + FP_REG_FIRST }, \
kono
parents:
diff changeset
714 { "f12", 12 + FP_REG_FIRST }, \
kono
parents:
diff changeset
715 { "f13", 13 + FP_REG_FIRST }, \
kono
parents:
diff changeset
716 { "f14", 14 + FP_REG_FIRST }, \
kono
parents:
diff changeset
717 { "f15", 15 + FP_REG_FIRST }, \
kono
parents:
diff changeset
718 { "f16", 16 + FP_REG_FIRST }, \
kono
parents:
diff changeset
719 { "f17", 17 + FP_REG_FIRST }, \
kono
parents:
diff changeset
720 { "f18", 18 + FP_REG_FIRST }, \
kono
parents:
diff changeset
721 { "f19", 19 + FP_REG_FIRST }, \
kono
parents:
diff changeset
722 { "f20", 20 + FP_REG_FIRST }, \
kono
parents:
diff changeset
723 { "f21", 21 + FP_REG_FIRST }, \
kono
parents:
diff changeset
724 { "f22", 22 + FP_REG_FIRST }, \
kono
parents:
diff changeset
725 { "f23", 23 + FP_REG_FIRST }, \
kono
parents:
diff changeset
726 { "f24", 24 + FP_REG_FIRST }, \
kono
parents:
diff changeset
727 { "f25", 25 + FP_REG_FIRST }, \
kono
parents:
diff changeset
728 { "f26", 26 + FP_REG_FIRST }, \
kono
parents:
diff changeset
729 { "f27", 27 + FP_REG_FIRST }, \
kono
parents:
diff changeset
730 { "f28", 28 + FP_REG_FIRST }, \
kono
parents:
diff changeset
731 { "f29", 29 + FP_REG_FIRST }, \
kono
parents:
diff changeset
732 { "f30", 30 + FP_REG_FIRST }, \
kono
parents:
diff changeset
733 { "f31", 31 + FP_REG_FIRST }, \
kono
parents:
diff changeset
734 }
kono
parents:
diff changeset
735
kono
parents:
diff changeset
736 /* Globalizing directive for a label. */
kono
parents:
diff changeset
737 #define GLOBAL_ASM_OP "\t.globl\t"
kono
parents:
diff changeset
738
kono
parents:
diff changeset
739 /* This is how to store into the string LABEL
kono
parents:
diff changeset
740 the symbol_ref name of an internal numbered label where
kono
parents:
diff changeset
741 PREFIX is the class of label and NUM is the number within the class.
kono
parents:
diff changeset
742 This is suitable for output with `assemble_name'. */
kono
parents:
diff changeset
743
kono
parents:
diff changeset
744 #undef ASM_GENERATE_INTERNAL_LABEL
kono
parents:
diff changeset
745 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
kono
parents:
diff changeset
746 sprintf ((LABEL), "*%s%s%ld", (LOCAL_LABEL_PREFIX), (PREFIX), (long)(NUM))
kono
parents:
diff changeset
747
kono
parents:
diff changeset
748 /* This is how to output an element of a case-vector that is absolute. */
kono
parents:
diff changeset
749
kono
parents:
diff changeset
750 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \
kono
parents:
diff changeset
751 fprintf (STREAM, "\t.word\t%sL%d\n", LOCAL_LABEL_PREFIX, VALUE)
kono
parents:
diff changeset
752
kono
parents:
diff changeset
753 /* This is how to output an element of a PIC case-vector. */
kono
parents:
diff changeset
754
kono
parents:
diff changeset
755 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL) \
kono
parents:
diff changeset
756 fprintf (STREAM, "\t.word\t%sL%d-%sL%d\n", \
kono
parents:
diff changeset
757 LOCAL_LABEL_PREFIX, VALUE, LOCAL_LABEL_PREFIX, REL)
kono
parents:
diff changeset
758
kono
parents:
diff changeset
759 /* This is how to output an assembler line
kono
parents:
diff changeset
760 that says to advance the location counter
kono
parents:
diff changeset
761 to a multiple of 2**LOG bytes. */
kono
parents:
diff changeset
762
kono
parents:
diff changeset
763 #define ASM_OUTPUT_ALIGN(STREAM,LOG) \
kono
parents:
diff changeset
764 fprintf (STREAM, "\t.align\t%d\n", (LOG))
kono
parents:
diff changeset
765
kono
parents:
diff changeset
766 /* Define the strings to put out for each section in the object file. */
kono
parents:
diff changeset
767 #define TEXT_SECTION_ASM_OP "\t.text" /* instructions */
kono
parents:
diff changeset
768 #define DATA_SECTION_ASM_OP "\t.data" /* large data */
kono
parents:
diff changeset
769 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata"
kono
parents:
diff changeset
770 #define BSS_SECTION_ASM_OP "\t.bss"
kono
parents:
diff changeset
771 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\",@nobits"
kono
parents:
diff changeset
772 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\",@progbits"
kono
parents:
diff changeset
773
kono
parents:
diff changeset
774 #define ASM_OUTPUT_REG_PUSH(STREAM,REGNO) \
kono
parents:
diff changeset
775 do \
kono
parents:
diff changeset
776 { \
kono
parents:
diff changeset
777 fprintf (STREAM, "\taddi\t%s,%s,-8\n\t%s\t%s,0(%s)\n", \
kono
parents:
diff changeset
778 reg_names[STACK_POINTER_REGNUM], \
kono
parents:
diff changeset
779 reg_names[STACK_POINTER_REGNUM], \
kono
parents:
diff changeset
780 TARGET_64BIT ? "sd" : "sw", \
kono
parents:
diff changeset
781 reg_names[REGNO], \
kono
parents:
diff changeset
782 reg_names[STACK_POINTER_REGNUM]); \
kono
parents:
diff changeset
783 } \
kono
parents:
diff changeset
784 while (0)
kono
parents:
diff changeset
785
kono
parents:
diff changeset
786 #define ASM_OUTPUT_REG_POP(STREAM,REGNO) \
kono
parents:
diff changeset
787 do \
kono
parents:
diff changeset
788 { \
kono
parents:
diff changeset
789 fprintf (STREAM, "\t%s\t%s,0(%s)\n\taddi\t%s,%s,8\n", \
kono
parents:
diff changeset
790 TARGET_64BIT ? "ld" : "lw", \
kono
parents:
diff changeset
791 reg_names[REGNO], \
kono
parents:
diff changeset
792 reg_names[STACK_POINTER_REGNUM], \
kono
parents:
diff changeset
793 reg_names[STACK_POINTER_REGNUM], \
kono
parents:
diff changeset
794 reg_names[STACK_POINTER_REGNUM]); \
kono
parents:
diff changeset
795 } \
kono
parents:
diff changeset
796 while (0)
kono
parents:
diff changeset
797
kono
parents:
diff changeset
798 #define ASM_COMMENT_START "#"
kono
parents:
diff changeset
799
kono
parents:
diff changeset
800 #undef SIZE_TYPE
kono
parents:
diff changeset
801 #define SIZE_TYPE (POINTER_SIZE == 64 ? "long unsigned int" : "unsigned int")
kono
parents:
diff changeset
802
kono
parents:
diff changeset
803 #undef PTRDIFF_TYPE
kono
parents:
diff changeset
804 #define PTRDIFF_TYPE (POINTER_SIZE == 64 ? "long int" : "int")
kono
parents:
diff changeset
805
kono
parents:
diff changeset
806 /* If a memory-to-memory move would take MOVE_RATIO or more simple
kono
parents:
diff changeset
807 move-instruction pairs, we will do a movmem or libcall instead. */
kono
parents:
diff changeset
808
kono
parents:
diff changeset
809 #define MOVE_RATIO(speed) (CLEAR_RATIO (speed) / 2)
kono
parents:
diff changeset
810
kono
parents:
diff changeset
811 /* For CLEAR_RATIO, when optimizing for size, give a better estimate
kono
parents:
diff changeset
812 of the length of a memset call, but use the default otherwise. */
kono
parents:
diff changeset
813
kono
parents:
diff changeset
814 #define CLEAR_RATIO(speed) ((speed) ? 16 : 6)
kono
parents:
diff changeset
815
kono
parents:
diff changeset
816 /* This is similar to CLEAR_RATIO, but for a non-zero constant, so when
kono
parents:
diff changeset
817 optimizing for size adjust the ratio to account for the overhead of
kono
parents:
diff changeset
818 loading the constant and replicating it across the word. */
kono
parents:
diff changeset
819
kono
parents:
diff changeset
820 #define SET_RATIO(speed) (CLEAR_RATIO (speed) - ((speed) ? 0 : 2))
kono
parents:
diff changeset
821
kono
parents:
diff changeset
822 #ifndef USED_FOR_TARGET
kono
parents:
diff changeset
823 extern const enum reg_class riscv_regno_to_class[];
kono
parents:
diff changeset
824 #endif
kono
parents:
diff changeset
825
kono
parents:
diff changeset
826 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
kono
parents:
diff changeset
827 (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4)
kono
parents:
diff changeset
828
kono
parents:
diff changeset
829 #define XLEN_SPEC \
kono
parents:
diff changeset
830 "%{march=rv32*:32}" \
kono
parents:
diff changeset
831 "%{march=rv64*:64}" \
kono
parents:
diff changeset
832
kono
parents:
diff changeset
833 #define ABI_SPEC \
kono
parents:
diff changeset
834 "%{mabi=ilp32:ilp32}" \
kono
parents:
diff changeset
835 "%{mabi=ilp32f:ilp32f}" \
kono
parents:
diff changeset
836 "%{mabi=ilp32d:ilp32d}" \
kono
parents:
diff changeset
837 "%{mabi=lp64:lp64}" \
kono
parents:
diff changeset
838 "%{mabi=lp64f:lp64f}" \
kono
parents:
diff changeset
839 "%{mabi=lp64d:lp64d}" \
kono
parents:
diff changeset
840
kono
parents:
diff changeset
841 #define STARTFILE_PREFIX_SPEC \
kono
parents:
diff changeset
842 "/lib" XLEN_SPEC "/" ABI_SPEC "/ " \
kono
parents:
diff changeset
843 "/usr/lib" XLEN_SPEC "/" ABI_SPEC "/ " \
kono
parents:
diff changeset
844 "/lib/ " \
kono
parents:
diff changeset
845 "/usr/lib/ "
kono
parents:
diff changeset
846
kono
parents:
diff changeset
847 /* ISA constants needed for code generation. */
kono
parents:
diff changeset
848 #define OPCODE_LW 0x2003
kono
parents:
diff changeset
849 #define OPCODE_LD 0x3003
kono
parents:
diff changeset
850 #define OPCODE_AUIPC 0x17
kono
parents:
diff changeset
851 #define OPCODE_JALR 0x67
kono
parents:
diff changeset
852 #define OPCODE_LUI 0x37
kono
parents:
diff changeset
853 #define OPCODE_ADDI 0x13
kono
parents:
diff changeset
854 #define SHIFT_RD 7
kono
parents:
diff changeset
855 #define SHIFT_RS1 15
kono
parents:
diff changeset
856 #define SHIFT_IMM 20
kono
parents:
diff changeset
857 #define IMM_BITS 12
kono
parents:
diff changeset
858
kono
parents:
diff changeset
859 #define IMM_REACH (1LL << IMM_BITS)
kono
parents:
diff changeset
860 #define CONST_HIGH_PART(VALUE) (((VALUE) + (IMM_REACH/2)) & ~(IMM_REACH-1))
kono
parents:
diff changeset
861 #define CONST_LOW_PART(VALUE) ((VALUE) - CONST_HIGH_PART (VALUE))
kono
parents:
diff changeset
862
kono
parents:
diff changeset
863 #endif /* ! GCC_RISCV_H */