1 /* Definitions of target machine for GNU compiler. TMS320C[34]x
2 Copyright (C) 1994-98, 1999 Free Software Foundation, Inc.
4 Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz)
5 and Herman Ten Brugge (Haj.Ten.Brugge@net.HCC.nl).
7 This file is part of GNU CC.
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING. If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
24 /* RUN-TIME TARGET SPECIFICATION */
28 /* Name of the c4x assembler */
30 #define ASM_PROG "c4x-as"
32 /* Name of the c4x linker */
34 #define LD_PROG "c4x-ld"
36 /* Define assembler options. */
39 %{!mcpu=30:%{!mcpu=31:%{!mcpu=32:%{!mcpu=40:%{!mcpu=44:\
40 %{!m30:%{!m40:-m40}}}}}}} \
51 %{mmemparm:-p} %{mregparm:-r} \
52 %{!mmemparm:%{!mregparm:-r}} \
53 %{mbig:-b} %{msmall:-s} \
54 %{!msmall:%{!mbig:-b}}"
56 /* Define linker options. */
59 %{m30:--architecture c3x} \
60 %{m31:--architecture c3x} \
61 %{m32:--architecture c3x} \
62 %{mcpu=30:--architecture c3x} \
63 %{mcpu=31:--architecture c3x} \
64 %{mcpu=32:--architecture c3x}"
66 /* Define C preprocessor options. */
69 %{!m30:%{!m31:%{!m32:%{!mcpu=30:%{!mcpu=31:%{!mcpu=32:%{!mcpu=40:%{!mcpu=44:\
70 %{!m40:%{!m44:-D_TMS320C4x -D_C4x -D_TMS320C40 -D_C40 }}}}}}}}}} \
71 %{mcpu=30:-D_TMS320C3x -D_C3x -D_TMS320C30 -D_C30 } \
72 %{m30:-D_TMS320C3x -D_C3x -D_TMS320C30 -D_C30 } \
73 %{mcpu=31:-D_TMS320C3x -D_C3x -D_TMS320C31 -D_C31 } \
74 %{m31:-D_TMS320C3x -D_C3x -D_TMS320C31 -D_C31 } \
75 %{mcpu=32:-D_TMS320C3x -D_C3x -D_TMS320C32 -D_C32 } \
76 %{m32:-D_TMS320C3x -D_C3x -D_TMS320C32 -D_C32 } \
77 %{mcpu=40:-D_TMS320C4x -D_C4x -D_TMS320C40 -D_C40 } \
78 %{m40:-D_TMS320C4x -D_C4x -D_TMS320C40 -D_C40 } \
79 %{mcpu=44:-D_TMS320C4x -D_C4x -D_TMS320C44 -D_C44 } \
80 %{m44:-D_TMS320C4x -D_C4x -D_TMS320C44 -D_C44 } \
81 %{mmemparm:-U_REGPARM }%{mregparm:-D_REGPARM } \
82 %{!mmemparm:%{!mregparm:-D_REGPARM }} \
83 %{msmall:-U_BIGMODEL } %{mbig:-D_BIGMODEL } \
84 %{!msmall:%{!mbig:-D_BIGMODEL }} \
85 %{finline-functions:-D_INLINE }"
87 /* Specify the end file to link with. */
89 #define ENDFILE_SPEC ""
91 /* Target compilation option flags. */
93 #define SMALL_MEMORY_FLAG 0x0000001 /* small memory model */
94 #define MPYI_FLAG 0x0000002 /* use 24-bit MPYI for C3x */
95 #define FAST_FIX_FLAG 0x0000004 /* fast fixing of floats */
96 #define RPTS_FLAG 0x0000008 /* allow use of RPTS */
97 #define C3X_FLAG 0x0000010 /* emit C3x code */
98 #define TI_FLAG 0x0000020 /* be compatible with TI assembler */
99 #define PARANOID_FLAG 0x0000040 /* be paranoid about DP reg. in ISRs */
100 #define MEMPARM_FLAG 0x0000080 /* pass arguments on stack */
101 #define DEVEL_FLAG 0x0000100 /* enable features under development */
102 #define RPTB_FLAG 0x0000200 /* enable repeat block */
103 #define BK_FLAG 0x0000400 /* use BK as general register */
104 #define DB_FLAG 0x0000800 /* use decrement and branch for C3x */
105 #define DEBUG_FLAG 0x0001000 /* enable debugging of GCC */
106 #define HOIST_FLAG 0x0002000 /* force constants into registers */
107 #define LOOP_UNSIGNED_FLAG 0x0004000 /* allow unsigned loop counters */
108 #define FORCE_FLAG 0x0008000 /* force op0 and op1 to be same */
109 #define PRESERVE_FLOAT_FLAG 0x0010000 /* save all 40 bits for floats */
110 #define PARALLEL_PACK_FLAG 0x0020000 /* allow parallel insn packing */
111 #define PARALLEL_MPY_FLAG 0x0040000 /* allow MPY||ADD, MPY||SUB insns */
112 #define ALIASES_FLAG 0x0080000 /* assume mem refs possibly aliased */
114 #define C30_FLAG 0x0100000 /* emit C30 code */
115 #define C31_FLAG 0x0200000 /* emit C31 code */
116 #define C32_FLAG 0x0400000 /* emit C32 code */
117 #define C40_FLAG 0x1000000 /* emit C40 code */
118 #define C44_FLAG 0x2000000 /* emit C44 code */
120 /* Run-time compilation parameters selecting different hardware subsets.
122 Macro to define tables used to set the flags.
123 This is a list in braces of triplets in braces,
124 each pair being { "NAME", VALUE, "DESCRIPTION" }
125 where VALUE is the bits to set or minus the bits to clear.
126 An empty string NAME is used to identify the default VALUE. */
128 #define TARGET_SWITCHES \
129 { { "small", SMALL_MEMORY_FLAG, \
130 "Small memory model" }, \
131 { "big", -SMALL_MEMORY_FLAG, \
132 "Big memory model" }, \
133 { "mpyi", MPYI_FLAG, \
134 "Use MPYI instruction for C3x" }, \
135 { "no-mpyi", -MPYI_FLAG, \
136 "Do not use MPYI instruction for C3x" }, \
137 { "fast-fix", FAST_FIX_FLAG, \
138 "Use fast but approximate float to integer conversion" }, \
139 { "no-fast-fix", -FAST_FIX_FLAG, \
140 "Use slow but accurate float to integer conversion" }, \
141 { "rpts", RPTS_FLAG, \
142 "Enable use of RTPS instruction" }, \
143 { "no-rpts", -RPTS_FLAG, \
144 "Disable use of RTPS instruction" }, \
145 { "rptb", RPTB_FLAG, \
146 "Enable use of RTPB instruction" }, \
147 { "no-rptb", -RPTB_FLAG, \
148 "Disable use of RTPB instruction" }, \
150 "Generate code for C30 CPU"}, \
152 "Generate code for C31 CPU"}, \
154 "Generate code for C32 CPU"}, \
156 "Generate code for C40 CPU"}, \
158 "Generate code for C44 CPU"}, \
160 "Emit code compatible with TI tools"}, \
161 { "no-ti", -TI_FLAG, \
162 "Emit code to use GAS extensions"}, \
163 { "paranoid", PARANOID_FLAG, \
164 "Save DP across ISR in small memory model" }, \
165 { "no-paranoid", -PARANOID_FLAG, \
166 "Don't save DP across ISR in small memory model" }, \
167 { "isr-dp-reload", PARANOID_FLAG, \
168 "Save DP across ISR in small memory model" }, \
169 { "no-isr-dp-reload", -PARANOID_FLAG, \
170 "Don't save DP across ISR in small memory model" }, \
171 { "memparm", MEMPARM_FLAG, \
172 "Pass arguments on the stack" }, \
173 { "regparm", -MEMPARM_FLAG, \
174 "Pass arguments in registers" }, \
175 { "devel", DEVEL_FLAG, \
176 "Enable new features under development" }, \
177 { "no-devel", -DEVEL_FLAG, \
178 "Disable new features under development" }, \
180 "Use the BK register as a general purpose register" }, \
181 { "no-bk", -BK_FLAG, \
182 "Do not allocate BK register" }, \
184 "Enable use of DB instruction" }, \
185 { "no-db", -DB_FLAG, \
186 "Disable use of DB instruction" }, \
187 { "debug", DEBUG_FLAG, \
188 "Enable debugging" }, \
189 { "no-debug", -DEBUG_FLAG, \
190 "Disable debugging" }, \
191 { "hoist", HOIST_FLAG, \
192 "Force constants into registers to improve hoisting" }, \
193 { "no-hoist", -HOIST_FLAG, \
194 "Don't force constants into registers" }, \
195 { "force", FORCE_FLAG, \
196 "Force RTL generation to emit valid 3 operand insns" }, \
197 { "no-force", -FORCE_FLAG, \
198 "Allow RTL generation to emit invalid 3 operand insns" }, \
199 { "loop-unsigned", LOOP_UNSIGNED_FLAG, \
200 "Allow unsigned interation counts for RPTB/DB" }, \
201 { "no-loop-unsigned", -LOOP_UNSIGNED_FLAG, \
202 "Disallow unsigned iteration counts for RPTB/DB" }, \
203 { "preserve-float", PRESERVE_FLOAT_FLAG, \
204 "Preserve all 40 bits of FP reg across call" }, \
205 { "no-preserve-float", -PRESERVE_FLOAT_FLAG, \
206 "Only preserve 32 bits of FP reg across call" }, \
207 { "parallel-insns", PARALLEL_PACK_FLAG, \
208 "Enable parallel instructions" }, \
209 { "no-parallel-mpy", -PARALLEL_MPY_FLAG, \
210 "Disable parallel instructions" }, \
211 { "parallel-mpy", PARALLEL_MPY_FLAG, \
212 "Enable MPY||ADD and MPY||SUB instructions" }, \
213 { "no-parallel-insns", -PARALLEL_PACK_FLAG, \
214 "Disable MPY||ADD and MPY||SUB instructions" }, \
215 { "aliases", ALIASES_FLAG, \
216 "Assume that pointers may be aliased" }, \
217 { "no-aliases", -ALIASES_FLAG, \
218 "Assume that pointers not aliased" }, \
219 { "", TARGET_DEFAULT, ""} }
221 /* Default target switches */
223 /* Play safe, not the fastest code. */
224 #define TARGET_DEFAULT ALIASES_FLAG | PARALLEL_PACK_FLAG \
225 | PARALLEL_MPY_FLAG | RPTB_FLAG
228 Max iteration count for RPTB/RPTS is 2^31 + 1.
229 Max iteration count for DB is 2^31 + 1 for C40, but 2^23 + 1 for C30.
230 RPTS blocks interrupts. */
233 extern int target_flags
;
235 #define TARGET_INLINE 1 /* Inline MPYI. */
236 #define TARGET_PARALLEL 1 /* Enable parallel insns in MD. */
237 #define TARGET_SMALL_REG_CLASS 0
239 #define TARGET_SMALL (target_flags & SMALL_MEMORY_FLAG)
240 #define TARGET_MPYI (!TARGET_C3X || (target_flags & MPYI_FLAG))
241 #define TARGET_FAST_FIX (target_flags & FAST_FIX_FLAG)
242 #define TARGET_RPTS (target_flags & RPTS_FLAG)
243 #define TARGET_TI (target_flags & TI_FLAG)
244 #define TARGET_PARANOID (target_flags & PARANOID_FLAG)
245 #define TARGET_MEMPARM (target_flags & MEMPARM_FLAG)
246 #define TARGET_DEVEL (target_flags & DEVEL_FLAG)
247 #define TARGET_RPTB (target_flags & RPTB_FLAG \
249 #define TARGET_BK (target_flags & BK_FLAG)
250 #define TARGET_DB (! TARGET_C3X || (target_flags & DB_FLAG))
251 #define TARGET_DEBUG (target_flags & DEBUG_FLAG)
252 #define TARGET_HOIST (target_flags & HOIST_FLAG)
253 #define TARGET_LOOP_UNSIGNED (target_flags & LOOP_UNSIGNED_FLAG)
254 #define TARGET_FORCE (target_flags & FORCE_FLAG)
255 #define TARGET_PRESERVE_FLOAT (target_flags & PRESERVE_FLOAT_FLAG)
256 #define TARGET_PARALLEL_PACK (TARGET_RPTB \
257 && (target_flags & PARALLEL_PACK_FLAG) \
259 #define TARGET_PARALLEL_MPY (TARGET_PARALLEL_PACK \
260 && (target_flags & PARALLEL_MPY_FLAG))
261 #define TARGET_ALIASES (target_flags & ALIASES_FLAG)
263 #define TARGET_C3X (target_flags & C3X_FLAG)
264 #define TARGET_C30 (target_flags & C30_FLAG)
265 #define TARGET_C31 (target_flags & C31_FLAG)
266 #define TARGET_C32 (target_flags & C32_FLAG)
267 #define TARGET_C40 (target_flags & C40_FLAG)
268 #define TARGET_C44 (target_flags & C44_FLAG)
270 /* Define some options to control code generation. */
271 #define TARGET_LOAD_ADDRESS (1 || (! TARGET_C3X && ! TARGET_SMALL))
272 #define TARGET_EXPOSE_LDP 0
274 /* -mrpts allows the use of the RPTS instruction irregardless.
275 -mrpts=max-cycles will use RPTS if the number of cycles is constant
276 and less than max-cycles. */
278 #define TARGET_RPTS_CYCLES(CYCLES) (TARGET_RPTS || (CYCLES) < c4x_rpts_cycles)
280 #define BCT_CHECK_LOOP_ITERATIONS !(TARGET_LOOP_UNSIGNED)
282 /* -mcpu=XX with XX = target DSP version number */
284 /* This macro is similar to `TARGET_SWITCHES' but defines names of
285 command options that have values. Its definition is an
286 initializer with a subgrouping for each command option.
288 Each subgrouping contains a string constant, that defines the
289 fixed part of the option name, and the address of a variable.
290 The variable, type `char *', is set to the variable part of the
291 given option if the fixed part matches. The actual option name
292 is made by appending `-m' to the specified name.
294 Here is an example which defines `-mshort-data-NUMBER'. If the
295 given option is `-mshort-data-512', the variable `m88k_short_data'
296 will be set to the string `"512"'.
298 extern char *m88k_short_data;
299 #define TARGET_OPTIONS { { "short-data-", &m88k_short_data } } */
301 extern const char *c4x_rpts_cycles_string
, *c4x_cpu_version_string
;
303 #define TARGET_OPTIONS \
304 { {"rpts=", &c4x_rpts_cycles_string, \
305 "Specify maximum number of iterations for RPTS" }, \
306 {"cpu=", &c4x_cpu_version_string, \
307 "Select CPU to generate code for" } }
309 /* Sometimes certain combinations of command options do not make sense
310 on a particular target machine. You can define a macro
311 `OVERRIDE_OPTIONS' to take account of this. This macro, if
312 defined, is executed once just after all the command options have
315 #define OVERRIDE_OPTIONS c4x_override_options ()
317 /* Define this to change the optimizations performed by default. */
319 #define OPTIMIZATION_OPTIONS(LEVEL,SIZE) c4x_optimization_options(LEVEL, SIZE)
321 /* Run Time Target Specification */
323 #define TARGET_VERSION fprintf (stderr, " (TMS320C[34]x, TI syntax)");
327 #define BITS_BIG_ENDIAN 0
328 #define BYTES_BIG_ENDIAN 0
329 #define WORDS_BIG_ENDIAN 0
331 /* Technically, we are little endian, but we put the floats out as
332 whole longs and this makes GCC put them out in the right order. */
334 #define FLOAT_WORDS_BIG_ENDIAN 1
336 /* Note the ANSI C standard requires sizeof(char) = 1. On the C[34]x
337 all integral and floating point data types are stored in memory as
338 32-bits (floating point types can be stored as 40-bits in the
339 extended precision registers), so sizeof(char) = sizeof(short) =
340 sizeof(int) = sizeof(long) = sizeof(float) = sizeof(double) = 1. */
342 #define BITS_PER_UNIT 32
343 #define BITS_PER_WORD 32
344 #define UNITS_PER_WORD 1
345 #define POINTER_SIZE 32
346 #define PARM_BOUNDARY 32
347 #define STACK_BOUNDARY 32
348 #define FUNCTION_BOUNDARY 32
349 #define BIGGEST_ALIGNMENT 32
350 #define EMPTY_FIELD_BOUNDARY 32
351 #define STRICT_ALIGNMENT 0
352 #define TARGET_FLOAT_FORMAT C4X_FLOAT_FORMAT
353 #define MAX_FIXED_MODE_SIZE 64 /* HImode */
355 /* Number of bits in the high and low parts of a two stage
356 load of an immediate constant. */
357 #define BITS_PER_HIGH 16
358 #define BITS_PER_LO_SUM 16
360 /* Use the internal floating point stuff in the compiler and not the
361 host floating point stuff. */
363 #define REAL_ARITHMETIC
365 /* Define register numbers */
367 /* Extended-precision registers */
378 /* Auxiliary (address) registers */
389 /* Data page register */
393 /* Index registers */
398 /* Block size register */
406 /* Status register */
410 /* Misc. interrupt registers */
412 #define DIE_REGNO 22 /* C4x only */
413 #define IE_REGNO 22 /* C3x only */
414 #define IIE_REGNO 23 /* C4x only */
415 #define IF_REGNO 23 /* C3x only */
416 #define IIF_REGNO 24 /* C4x only */
417 #define IOF_REGNO 24 /* C3x only */
419 /* Repeat block registers */
425 /* Additional extended-precision registers */
427 #define R8_REGNO 28 /* C4x only */
428 #define R9_REGNO 29 /* C4x only */
429 #define R10_REGNO 30 /* C4x only */
430 #define R11_REGNO 31 /* C4x only */
432 #define FIRST_PSEUDO_REGISTER 32
434 /* Extended precision registers (low set) */
436 #define IS_R0R1_REG(r) ((((r) >= R0_REGNO) && ((r) <= R1_REGNO)))
437 #define IS_R2R3_REG(r) ((((r) >= R2_REGNO) && ((r) <= R3_REGNO)))
438 #define IS_EXT_LOW_REG(r) ((((r) >= R0_REGNO) && ((r) <= R7_REGNO)))
440 /* Extended precision registers (high set) */
442 #define IS_EXT_HIGH_REG(r) (! TARGET_C3X \
443 && ((r) >= R8_REGNO) && ((r) <= R11_REGNO))
444 /* Address registers */
446 #define IS_AUX_REG(r) (((r) >= AR0_REGNO) && ((r) <= AR7_REGNO))
447 #define IS_ADDR_REG(r) IS_AUX_REG(r)
448 #define IS_DP_REG(r) ((r) == DP_REGNO)
449 #define IS_INDEX_REG(r) (((r) == IR0_REGNO) || ((r) == IR1_REGNO))
450 #define IS_SP_REG(r) ((r) == SP_REGNO)
451 #define IS_BK_REG(r) (TARGET_BK && (r) == BK_REGNO)
455 #define IS_ST_REG(r) ((r) == ST_REGNO)
456 #define IS_RC_REG(r) ((r) == RC_REGNO)
457 #define IS_REPEAT_REG(r) (((r) >= RS_REGNO) && ((r) <= RC_REGNO))
459 /* Composite register sets */
461 #define IS_ADDR_OR_INDEX_REG(r) (IS_ADDR_REG(r) || IS_INDEX_REG(r))
462 #define IS_EXT_REG(r) (IS_EXT_LOW_REG(r) || IS_EXT_HIGH_REG(r))
463 #define IS_STD_REG(r) (IS_ADDR_OR_INDEX_REG(r) || IS_REPEAT_REG(r) \
464 || IS_SP_REG(r) || IS_BK_REG(r))
465 #define IS_INT_REG(r) (IS_EXT_REG(r) || IS_STD_REG(r))
466 #define IS_GROUP1_REG(r) (IS_ADDR_OR_INDEX_REG(r) || IS_BK_REG(r))
469 #define IS_PSEUDO_REG(r) ((r) >= FIRST_PSEUDO_REGISTER)
470 #define IS_R0R1_OR_PSEUDO_REG(r) (IS_R0R1_REG(r) || IS_PSEUDO_REG(r))
471 #define IS_R2R3_OR_PSEUDO_REG(r) (IS_R2R3_REG(r) || IS_PSEUDO_REG(r))
472 #define IS_EXT_OR_PSEUDO_REG(r) (IS_EXT_REG(r) || IS_PSEUDO_REG(r))
473 #define IS_STD_OR_PSEUDO_REG(r) (IS_STD_REG(r) || IS_PSEUDO_REG(r))
474 #define IS_INT_OR_PSEUDO_REG(r) (IS_INT_REG(r) || IS_PSEUDO_REG(r))
475 #define IS_ADDR_OR_PSEUDO_REG(r) (IS_ADDR_REG(r) || IS_PSEUDO_REG(r))
476 #define IS_INDEX_OR_PSEUDO_REG(r) (IS_INDEX_REG(r) || IS_PSEUDO_REG(r))
477 #define IS_EXT_LOW_OR_PSEUDO_REG(r) (IS_EXT_LOW_REG(r) || IS_PSEUDO_REG(r))
478 #define IS_DP_OR_PSEUDO_REG(r) (IS_DP_REG(r) || IS_PSEUDO_REG(r))
479 #define IS_SP_OR_PSEUDO_REG(r) (IS_SP_REG(r) || IS_PSEUDO_REG(r))
480 #define IS_ST_OR_PSEUDO_REG(r) (IS_ST_REG(r) || IS_PSEUDO_REG(r))
481 #define IS_RC_OR_PSEUDO_REG(r) (IS_RC_REG(r) || IS_PSEUDO_REG(r))
483 #define IS_PSEUDO_REGNO(op) (IS_PSEUDO_REG(REGNO(op)))
484 #define IS_ADDR_REGNO(op) (IS_ADDR_REG(REGNO(op)))
485 #define IS_INDEX_REGNO(op) (IS_INDEX_REG(REGNO(op)))
486 #define IS_GROUP1_REGNO(r) (IS_GROUP1_REG(REGNO(op)))
488 #define IS_R0R1_OR_PSEUDO_REGNO(op) (IS_R0R1_OR_PSEUDO_REG(REGNO(op)))
489 #define IS_R2R3_OR_PSEUDO_REGNO(op) (IS_R2R3_OR_PSEUDO_REG(REGNO(op)))
490 #define IS_EXT_OR_PSEUDO_REGNO(op) (IS_EXT_OR_PSEUDO_REG(REGNO(op)))
491 #define IS_STD_OR_PSEUDO_REGNO(op) (IS_STD_OR_PSEUDO_REG(REGNO(op)))
492 #define IS_EXT_LOW_OR_PSEUDO_REGNO(op) (IS_EXT_LOW_OR_PSEUDO_REG(REGNO(op)))
493 #define IS_INT_OR_PSEUDO_REGNO(op) (IS_INT_OR_PSEUDO_REG(REGNO(op)))
495 #define IS_ADDR_OR_PSEUDO_REGNO(op) (IS_ADDR_OR_PSEUDO_REG(REGNO(op)))
496 #define IS_INDEX_OR_PSEUDO_REGNO(op) (IS_INDEX_OR_PSEUDO_REG(REGNO(op)))
497 #define IS_DP_OR_PSEUDO_REGNO(op) (IS_DP_OR_PSEUDO_REG(REGNO(op)))
498 #define IS_SP_OR_PSEUDO_REGNO(op) (IS_SP_OR_PSEUDO_REG(REGNO(op)))
499 #define IS_ST_OR_PSEUDO_REGNO(op) (IS_ST_OR_PSEUDO_REG(REGNO(op)))
500 #define IS_RC_OR_PSEUDO_REGNO(op) (IS_RC_OR_PSEUDO_REG(REGNO(op)))
502 /* 1 for registers that have pervasive standard uses
503 and are not available for the register allocator. */
505 #define FIXED_REGISTERS \
507 /* R0 R1 R2 R3 R4 R5 R6 R7 AR0 AR1 AR2 AR3 AR4 AR5 AR6 AR7 */ \
508 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
509 /* DP IR0 IR1 BK SP ST DIE IIE IIF RS RE RC R8 R9 R10 R11 */ \
510 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 \
513 /* 1 for registers not available across function calls.
514 These must include the FIXED_REGISTERS and also any
515 registers that can be used without being saved.
516 The latter must include the registers where values are returned
517 and the register where structure-value addresses are passed.
518 Aside from that, you can include as many other registers as you like.
520 Note that the extended precision registers are only saved in some
521 modes. The macro HARD_REGNO_CALL_CLOBBERED specifies which modes
522 get clobbered for a given regno. */
524 #define CALL_USED_REGISTERS \
526 /* R0 R1 R2 R3 R4 R5 R6 R7 AR0 AR1 AR2 AR3 AR4 AR5 AR6 AR7 */ \
527 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, \
528 /* DP IR0 IR1 BK SP ST DIE IIE IIF RS RE RC R8 R9 R10 R11 */ \
529 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 \
532 /* Macro to conditionally modify fixed_regs/call_used_regs. */
534 #define CONDITIONAL_REGISTER_USAGE \
538 fixed_regs[BK_REGNO] = 1; \
539 call_used_regs[BK_REGNO] = 1; \
540 c4x_regclass_map[BK_REGNO] = NO_REGS; \
546 reg_names[DIE_REGNO] = "ie"; /* clobber die */ \
547 reg_names[IF_REGNO] = "if"; /* clobber iie */ \
548 reg_names[IOF_REGNO] = "iof"; /* clobber iif */ \
550 for (i = R8_REGNO; i <= R11_REGNO; i++) \
552 fixed_regs[i] = call_used_regs[i] = 1; \
553 c4x_regclass_map[i] = NO_REGS; \
556 if (TARGET_PRESERVE_FLOAT) \
558 c4x_caller_save_map[R6_REGNO] = HFmode; \
559 c4x_caller_save_map[R7_REGNO] = HFmode; \
563 /* Order of Allocation of Registers */
565 /* List the order in which to allocate registers. Each register must be
566 listed once, even those in FIXED_REGISTERS.
568 First allocate registers that don't need preservation across calls,
569 except index and address registers. Then allocate data registers
570 that require preservation across calls (even though this invokes an
571 extra overhead of having to save/restore these registers). Next
572 allocate the address and index registers, since using these
573 registers for arithmetic can cause pipeline stalls. Finally
574 allocated the fixed registers which won't be allocated anyhow. */
576 #define REG_ALLOC_ORDER \
577 {R0_REGNO, R1_REGNO, R2_REGNO, R3_REGNO, \
578 R9_REGNO, R10_REGNO, R11_REGNO, \
579 RS_REGNO, RE_REGNO, RC_REGNO, BK_REGNO, \
580 R4_REGNO, R5_REGNO, R6_REGNO, R7_REGNO, R8_REGNO, \
581 AR0_REGNO, AR1_REGNO, AR2_REGNO, AR3_REGNO, \
582 AR4_REGNO, AR5_REGNO, AR6_REGNO, AR7_REGNO, \
583 IR0_REGNO, IR1_REGNO, \
584 SP_REGNO, DP_REGNO, ST_REGNO, IE_REGNO, IF_REGNO, IOF_REGNO}
587 /* Determine which register classes are very likely used by spill registers.
588 local-alloc.c won't allocate pseudos that have these classes as their
589 preferred class unless they are "preferred or nothing". */
591 #define CLASS_LIKELY_SPILLED_P(CLASS) ((CLASS) == INDEX_REGS)
593 /* CCmode is wrongly defined in machmode.def It should have a size
594 of UNITS_PER_WORD. */
596 #define HARD_REGNO_NREGS(REGNO, MODE) \
597 (((MODE) == CCmode || (MODE) == CC_NOOVmode) ? 1 : ((MODE) == HFmode) ? 1 : \
598 ((GET_MODE_SIZE(MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
601 /* A C expression that is nonzero if the hard register REGNO is preserved
602 across a call in mode MODE. This does not have to include the call used
605 #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO, MODE) \
606 ((((REGNO) == R6_REGNO || (REGNO) == R7_REGNO) && ! ((MODE) == QFmode)) \
607 || (((REGNO) == R4_REGNO || (REGNO) == R5_REGNO || (REGNO == R8_REGNO)) \
608 && ! ((MODE) == QImode || (MODE) == HImode || (MODE) == Pmode)))
610 /* Specify the modes required to caller save a given hard regno. */
612 #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS) (c4x_caller_save_map[REGNO])
614 #define HARD_REGNO_MODE_OK(REGNO, MODE) c4x_hard_regno_mode_ok(REGNO, MODE)
616 /* A C expression that is nonzero if it is desirable to choose
617 register allocation so as to avoid move instructions between a
618 value of mode MODE1 and a value of mode MODE2.
620 Value is 1 if it is a good idea to tie two pseudo registers
621 when one has mode MODE1 and one has mode MODE2.
622 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
623 for any hard reg, then this must be 0 for correct output. */
625 #define MODES_TIEABLE_P(MODE1, MODE2) 0
628 /* Define the classes of registers for register constraints in the
629 machine description. Also define ranges of constants.
631 One of the classes must always be named ALL_REGS and include all hard regs.
632 If there is more than one class, another class must be named NO_REGS
633 and contain no registers.
635 The name GENERAL_REGS must be the name of a class (or an alias for
636 another name such as ALL_REGS). This is the class of registers
637 that is allowed by "g" or "r" in a register constraint.
638 Also, registers outside this class are allocated only when
639 instructions express preferences for them.
641 The classes must be numbered in nondecreasing order; that is,
642 a larger-numbered class must never be contained completely
643 in a smaller-numbered class.
645 For any two classes, it is very desirable that there be another
646 class that represents their union. */
653 EXT_LOW_REGS
, /* 'q' */
656 INDEX_REGS
, /* 'x' */
662 GENERAL_REGS
, /* 'r' */
669 #define N_REG_CLASSES (int) LIM_REG_CLASSES
671 #define REG_CLASS_NAMES \
691 /* Define which registers fit in which classes.
692 This is an initializer for a vector of HARD_REG_SET
693 of length N_REG_CLASSES. RC is not included in GENERAL_REGS
694 since the register allocator will often choose a general register
695 in preference to RC for the decrement_and_branch_on_count pattern. */
697 #define REG_CLASS_CONTENTS \
699 {0x00000000}, /* No registers */ \
700 {0x00000003}, /* 't' R0-R1 */ \
701 {0x0000000c}, /* 'u' R2-R3 */ \
702 {0x000000ff}, /* 'q' R0-R7 */ \
703 {0xf00000ff}, /* 'f' R0-R11 */ \
704 {0x0000ff00}, /* 'a' AR0-AR7 */ \
705 {0x00060000}, /* 'x' IR0-IR1 */ \
706 {0x00080000}, /* 'k' BK */ \
707 {0x00100000}, /* 'b' SP */ \
708 {0x08000000}, /* 'v' RC */ \
709 {0x0800ff00}, /* RC,AR0-AR7 */ \
710 {0x0e1eff00}, /* 'c' AR0-AR7, IR0-IR1, BK, SP, RS, RE, RC */ \
711 {0xfe1effff}, /* 'r' R0-R11, AR0-AR7, IR0-IR1, BK, SP, RS, RE, RC */\
712 {0x00010000}, /* 'z' DP */ \
713 {0x00200000}, /* 'y' ST */ \
714 {0xffffffff}, /* All registers */ \
717 /* The same information, inverted:
718 Return the class number of the smallest class containing
719 reg number REGNO. This could be a conditional expression
720 or could index an array. */
722 #define REGNO_REG_CLASS(REGNO) (c4x_regclass_map[REGNO])
724 /* When SMALL_REGISTER_CLASSES is defined, the lifetime of registers
725 explicitly used in the rtl is kept as short as possible.
727 We only need to define SMALL_REGISTER_CLASSES if TARGET_PARALLEL_MPY
728 is defined since the MPY|ADD insns require the classes R0R1_REGS and
729 R2R3_REGS which are used by the function return registers (R0,R1) and
730 the register arguments (R2,R3), respectively. I'm reluctant to define
731 this macro since it stomps on many potential optimisations. Ideally
732 it should have a register class argument so that not all the register
733 classes gets penalised for the sake of a naughty few... For long
734 double arithmetic we need two additional registers that we can use as
737 #define SMALL_REGISTER_CLASSES (TARGET_SMALL_REG_CLASS && TARGET_PARALLEL_MPY)
739 #define BASE_REG_CLASS ADDR_REGS
740 #define INDEX_REG_CLASS INDEX_REGS
743 Register constraints for the C4x
745 a - address reg (ar0-ar7)
747 c - other gp int-only reg
748 d - data/int reg (equiv. to f)
750 h - data/long double reg (equiv. to f)
755 v - repeat count (rc)
756 x - index register (ir0-ir1)
757 y - status register (st)
760 Memory/constant constraints for the C4x
762 G - short float 16-bit
763 I - signed 16-bit constant (sign extended)
764 J - signed 8-bit constant (sign extended) (C4x only)
765 K - signed 5-bit constant (sign extended) (C4x only for stik)
766 L - unsigned 16-bit constant
767 M - unsigned 8-bit constant (C4x only)
768 N - ones complement of unsigned 16-bit constant
769 Q - indirect arx + 9-bit signed displacement
770 (a *-arx(n) or *+arx(n) is used to account for the sign bit)
771 R - indirect arx + 5-bit unsigned displacement (C4x only)
772 S - indirect arx + 0, 1, or irn displacement
773 T - direct symbol ref
774 > - indirect with autoincrement
775 < - indirect with autodecrement
776 } - indirect with post-modify
777 { - indirect with pre-modify
780 #define REG_CLASS_FROM_LETTER(CC) \
781 ( ((CC) == 'a') ? ADDR_REGS \
782 : ((CC) == 'b') ? SP_REG \
783 : ((CC) == 'c') ? INT_REGS \
784 : ((CC) == 'd') ? EXT_REGS \
785 : ((CC) == 'f') ? EXT_REGS \
786 : ((CC) == 'h') ? EXT_REGS \
787 : ((CC) == 'k') ? BK_REG \
788 : ((CC) == 'q') ? EXT_LOW_REGS \
789 : ((CC) == 't') ? R0R1_REGS \
790 : ((CC) == 'u') ? R2R3_REGS \
791 : ((CC) == 'v') ? RC_REG \
792 : ((CC) == 'x') ? INDEX_REGS \
793 : ((CC) == 'y') ? ST_REG \
794 : ((CC) == 'z') ? DP_REG \
797 /* These assume that REGNO is a hard or pseudo reg number.
798 They give nonzero only if REGNO is a hard reg of the suitable class
799 or a pseudo reg currently allocated to a suitable hard reg.
800 Since they use reg_renumber, they are safe only once reg_renumber
801 has been allocated, which happens in local-alloc.c. */
803 #define REGNO_OK_FOR_BASE_P(REGNO) \
804 (IS_ADDR_REG(REGNO) || IS_ADDR_REG((unsigned)reg_renumber[REGNO]))
806 #define REGNO_OK_FOR_INDEX_P(REGNO) \
807 (IS_INDEX_REG(REGNO) || IS_INDEX_REG((unsigned)reg_renumber[REGNO]))
809 #define PREFERRED_RELOAD_CLASS(X, CLASS) (CLASS)
811 #define LIMIT_RELOAD_CLASS(X, CLASS) (CLASS)
813 #define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) 0
815 #define CLASS_MAX_NREGS(CLASS, MODE) \
816 (((MODE) == CCmode || (MODE) == CC_NOOVmode) ? 1 : ((MODE) == HFmode) ? 1 : \
817 ((GET_MODE_SIZE(MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
819 #define IS_INT5_CONST(VAL) (((VAL) <= 15) && ((VAL) >= -16)) /* 'K' */
821 #define IS_UINT5_CONST(VAL) (((VAL) <= 31) && ((VAL) >= 0)) /* 'R' */
823 #define IS_INT8_CONST(VAL) (((VAL) <= 127) && ((VAL) >= -128)) /* 'J' */
825 #define IS_UINT8_CONST(VAL) (((VAL) <= 255) && ((VAL) >= 0)) /* 'M' */
827 #define IS_INT16_CONST(VAL) (((VAL) <= 32767) && ((VAL) >= -32768)) /* 'I' */
829 #define IS_UINT16_CONST(VAL) (((VAL) <= 65535) && ((VAL) >= 0)) /* 'L' */
831 #define IS_NOT_UINT16_CONST(VAL) IS_UINT16_CONST(~(VAL)) /* 'N' */
833 #define IS_HIGH_CONST(VAL) (! TARGET_C3X && (((VAL) & 0xffff) == 0)) /* 'O' */
836 #define IS_DISP1_CONST(VAL) (((VAL) <= 1) && ((VAL) >= -1)) /* 'S' */
838 #define IS_DISP8_CONST(VAL) (((VAL) <= 255) && ((VAL) >= -255)) /* 'Q' */
840 #define IS_DISP1_OFF_CONST(VAL) (IS_DISP1_CONST (VAL) \
841 && IS_DISP1_CONST (VAL + 1))
843 #define IS_DISP8_OFF_CONST(VAL) (IS_DISP8_CONST (VAL) \
844 && IS_DISP8_CONST (VAL + 1))
846 #define CONST_OK_FOR_LETTER_P(VAL, C) \
847 ( ((C) == 'I') ? (IS_INT16_CONST (VAL)) \
848 : ((C) == 'J') ? (! TARGET_C3X && IS_INT8_CONST (VAL)) \
849 : ((C) == 'K') ? (! TARGET_C3X && IS_INT5_CONST (VAL)) \
850 : ((C) == 'L') ? (IS_UINT16_CONST (VAL)) \
851 : ((C) == 'M') ? (! TARGET_C3X && IS_UINT8_CONST (VAL)) \
852 : ((C) == 'N') ? (IS_NOT_UINT16_CONST (VAL)) \
853 : ((C) == 'O') ? (IS_HIGH_CONST (VAL)) \
856 #define CONST_DOUBLE_OK_FOR_LETTER_P(OP, C) \
857 ( ((C) == 'G') ? (fp_zero_operand (OP, QFmode)) \
858 : ((C) == 'H') ? (c4x_H_constant (OP)) \
861 #define EXTRA_CONSTRAINT(OP, C) \
862 ( ((C) == 'Q') ? (c4x_Q_constraint (OP)) \
863 : ((C) == 'R') ? (c4x_R_constraint (OP)) \
864 : ((C) == 'S') ? (c4x_S_constraint (OP)) \
865 : ((C) == 'T') ? (c4x_T_constraint (OP)) \
866 : ((C) == 'U') ? (c4x_U_constraint (OP)) \
869 #define SMALL_CONST(VAL, insn) \
870 ( ((insn == NULL_RTX) || (get_attr_data (insn) == DATA_INT16)) \
871 ? IS_INT16_CONST (VAL) \
872 : ( (get_attr_data (insn) == DATA_NOT_UINT16) \
873 ? IS_NOT_UINT16_CONST (VAL) \
874 : ( (get_attr_data (insn) == DATA_HIGH_16) \
875 ? IS_HIGH_CONST (VAL) \
876 : IS_UINT16_CONST (VAL) \
882 I. Routine calling with arguments in registers
883 ----------------------------------------------
885 The TI C3x compiler has a rather unusual register passing algorithm.
886 Data is passed in the following registers (in order):
888 AR2, R2, R3, RC, RS, RE
890 However, the first and second floating point values are always in R2
891 and R3 (and all other floats are on the stack). Structs are always
892 passed on the stack. If the last argument is an ellipsis, the
893 previous argument is passed on the stack so that its address can be
894 taken for the stdargs macros.
896 Because of this, we have to pre-scan the list of arguments to figure
897 out what goes where in the list.
899 II. Routine calling with arguments on stack
900 -------------------------------------------
902 Let the subroutine declared as "foo(arg0, arg1, arg2);" have local
903 variables loc0, loc1, and loc2. After the function prologue has
904 been executed, the stack frame will look like:
906 [stack grows towards increasing addresses]
908 5 I saved reg1 I <= SP points here
918 0 I old FP I <= FP (AR3) points here
929 All local variables (locn) are accessible by means of +FP(n+1)
930 addressing, where n is the local variable number.
932 All stack arguments (argn) are accessible by means of -FP(n-2).
934 The stack pointer (SP) points to the last register saved in the
937 Note that a push instruction performs a preincrement of the stack
938 pointer. (STACK_PUSH_CODE == PRE_INC)
940 III. Registers used in function calling convention
941 --------------------------------------------------
943 Preserved across calls: R4...R5 (only by PUSH, i.e. lower 32 bits)
944 R6...R7 (only by PUSHF, i.e. upper 32 bits)
947 (Because of this model, we only assign FP values in R6, R7 and
948 only assign integer values in R4, R5.)
950 These registers are saved at each function entry and restored at
951 the exit. Also it is expected any of these not affected by any
952 call to user-defined (not service) functions.
954 Not preserved across calls: R0...R3
955 R4...R5 (upper 8 bits)
956 R6...R7 (lower 8 bits)
957 AR0...AR2, IR0, IR1, BK, ST, RS, RE, RC
959 These registers are used arbitrary in a function without being preserved.
960 It is also expected that any of these can be clobbered by any call.
962 Not used by GCC (except for in user "asm" statements):
963 IE (DIE), IF (IIE), IOF (IIF)
965 These registers are never used by GCC for any data, but can be used
966 with "asm" statements. */
971 /* Basic Stack Layout */
973 /* The stack grows upward, stack frame grows upward, and args grow
976 #define STARTING_FRAME_OFFSET C4X_LOC0
977 #define FIRST_PARM_OFFSET(FNDECL) (C4X_ARG0 + 1)
978 #define ARGS_GROW_DOWNWARD
979 #define STACK_POINTER_OFFSET 1
981 /* Define this if pushing a word on the stack
982 makes the stack pointer a smaller address. */
984 /* #define STACK_GROWS_DOWNWARD */
985 /* Like the dsp16xx, i370, i960, and we32k ports */
987 /* Define this if the nominal address of the stack frame
988 is at the high-address end of the local variables;
989 that is, each additional local variable allocated
990 goes at a more negative offset in the frame. */
992 /* #define FRAME_GROWS_DOWNWARD */
995 /* Registers That Address the Stack Frame */
997 #define STACK_POINTER_REGNUM SP_REGNO /* SP */
998 #define FRAME_POINTER_REGNUM AR3_REGNO /* AR3 */
999 #define ARG_POINTER_REGNUM AR3_REGNO /* AR3 */
1000 #define STATIC_CHAIN_REGNUM AR0_REGNO /* AR0 */
1002 /* Eliminating Frame Pointer and Arg Pointer */
1004 #define FRAME_POINTER_REQUIRED 0
1006 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) \
1010 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) \
1011 if (regs_ever_live[regno] && ! call_used_regs[regno]) \
1012 offset += TARGET_PRESERVE_FLOAT \
1013 && ((regno == R6_REGNO) || (regno == R7_REGNO)) \
1015 (DEPTH) = -(offset + get_frame_size ()); \
1018 /* This is a hack... We need to specify a register. */
1019 #define ELIMINABLE_REGS \
1020 {{ FRAME_POINTER_REGNUM, FRAME_POINTER_REGNUM }}
1022 #define CAN_ELIMINATE(FROM, TO) \
1023 (! (((FROM) == FRAME_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \
1024 || ((FROM) == FRAME_POINTER_REGNUM && (TO) == FRAME_POINTER_REGNUM)))
1026 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1030 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) \
1031 if (regs_ever_live[regno] && ! call_used_regs[regno]) \
1032 offset += TARGET_PRESERVE_FLOAT \
1033 && ((regno == R6_REGNO) || (regno == R7_REGNO)) \
1035 (OFFSET) = -(offset + get_frame_size ()); \
1039 /* Passing Function Arguments on the Stack */
1042 #define PUSH_ROUNDING(BYTES) (BYTES)
1044 #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACK_SIZE) 0
1046 /* The following structure is used by calls.c, function.c, c4x.c */
1048 typedef struct c4x_args
1061 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
1062 (c4x_init_cumulative_args (&CUM, FNTYPE, LIBNAME))
1064 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1065 (c4x_function_arg_advance (&CUM, MODE, TYPE, NAMED))
1067 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1068 (c4x_function_arg(&CUM, MODE, TYPE, NAMED))
1070 /* Define the profitability of saving registers around calls.
1071 We disable caller save to avoid a bug in flow.c (this also affects
1072 other targets such as m68k). Since we must use stf/sti,
1073 the profitability is marginal anyway. */
1075 /* #define CALLER_SAVE_PROFITABLE(REFS,CALLS) 0 */
1077 /* Never pass data by reference. */
1079 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) 0
1081 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) 0
1083 /* 1 if N is a possible register number for function argument passing. */
1085 #define FUNCTION_ARG_REGNO_P(REGNO) \
1086 ( ( ((REGNO) == AR2_REGNO) /* AR2 */ \
1087 || ((REGNO) == R2_REGNO) /* R2 */ \
1088 || ((REGNO) == R3_REGNO) /* R3 */ \
1089 || ((REGNO) == RC_REGNO) /* RC */ \
1090 || ((REGNO) == RS_REGNO) /* RS */ \
1091 || ((REGNO) == RE_REGNO)) /* RE */ \
1095 /* How Scalar Function Values Are Returned */
1097 #define FUNCTION_VALUE(VALTYPE, FUNC) \
1098 gen_rtx(REG, TYPE_MODE(VALTYPE), R0_REGNO) /* Return in R0 */
1100 #define LIBCALL_VALUE(MODE) \
1101 gen_rtx(REG, MODE, R0_REGNO) /* Return in R0 */
1103 #define FUNCTION_VALUE_REGNO_P(REGNO) ((REGNO) == R0_REGNO)
1105 /* How Large Values Are Returned */
1107 #define DEFAULT_PCC_STRUCT_RETURN 0
1108 #define STRUCT_VALUE_REGNUM AR0_REGNO /* AR0 */
1110 /* Varargs handling. */
1112 #define EXPAND_BUILTIN_VA_START(stdarg, valist, nextarg) \
1113 c4x_va_start (stdarg, valist, nextarg)
1115 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
1116 c4x_va_arg (valist, type)
1118 /* Function Entry and Exit */
1120 #define FUNCTION_PROLOGUE(FILE, SIZE) c4x_function_prologue(FILE, SIZE)
1121 #define FUNCTION_EPILOGUE(FILE, SIZE) c4x_function_epilogue(FILE, SIZE)
1124 /* Generating Code for Profiling */
1126 /* Note that the generated assembly uses the ^ operator to load the 16
1127 MSBs of the address. This is not supported by the TI assembler.
1128 The FUNCTION profiler needs a function mcount which gets passed
1129 a pointer to the LABELNO. */
1131 #define FUNCTION_PROFILER(FILE, LABELNO) \
1134 fprintf (FILE, "\tpush\tar2\n"); \
1135 fprintf (FILE, "\tldhi\t^LP%d,ar2\n", (LABELNO)); \
1136 fprintf (FILE, "\tor\t#LP%d,ar2\n", (LABELNO)); \
1137 fprintf (FILE, "\tcall\tmcount\n"); \
1138 fprintf (FILE, "\tpop\tar2\n"); \
1142 fprintf (FILE, "\tpush\tar2\n"); \
1143 fprintf (FILE, "\tldiu\t^LP%d,ar2\n", (LABELNO)); \
1144 fprintf (FILE, "\tlsh\t16,ar2\n"); \
1145 fprintf (FILE, "\tor\t#LP%d,ar2\n", (LABELNO)); \
1146 fprintf (FILE, "\tcall\tmcount\n"); \
1147 fprintf (FILE, "\tpop\tar2\n"); \
1150 /* There are three profiling modes for basic blocks available.
1151 The modes are selected at compile time by using the options
1152 -a or -ax of the gnu compiler.
1153 The variable `profile_block_flag' will be set according to the
1156 profile_block_flag == 0, no option used:
1160 profile_block_flag == 1, -a option used.
1162 Count frequency of execution of every basic block.
1164 profile_block_flag == 2, -ax option used.
1166 Generate code to allow several different profiling modes at run time.
1167 Available modes are:
1168 Produce a trace of all basic blocks.
1169 Count frequency of jump instructions executed.
1170 In every mode it is possible to start profiling upon entering
1171 certain functions and to disable profiling of some other functions.
1173 The result of basic-block profiling will be written to a file `bb.out'.
1174 If the -ax option is used parameters for the profiling will be read
1179 #define FUNCTION_BLOCK_PROFILER(FILE, BLOCKNO) \
1180 if (profile_block_flag == 2) \
1184 fprintf (FILE, "\tpush\tst\n"); \
1185 fprintf (FILE, "\tpush\tar2\n"); \
1186 fprintf (FILE, "\tpush\tr2\n"); \
1187 fprintf (FILE, "\tldhi\t^LPBX0,ar2\n"); \
1188 fprintf (FILE, "\tor\t#LPBX0,ar2\n"); \
1189 if (BLOCKNO > 32767) \
1191 fprintf (FILE, "\tldhi\t%d,r2\n", (BLOCKNO) >> 16); \
1192 fprintf (FILE, "\tor\t%d,r2\n", (BLOCKNO)); \
1196 fprintf (FILE, "\tldiu\t%d,r2\n", (BLOCKNO)); \
1198 fprintf (FILE, "\tcall\t___bb_init_trace_func\n"); \
1199 fprintf (FILE, "\tpop\tr2\n"); \
1200 fprintf (FILE, "\tpop\tar2\n"); \
1201 fprintf (FILE, "\tpop\tst\n"); \
1205 fprintf (FILE, "\tpush\tst\n"); \
1206 fprintf (FILE, "\tpush\tar2\n"); \
1207 fprintf (FILE, "\tpush\tr2\n"); \
1208 fprintf (FILE, "\tldiu\t^LPBX0,ar2\n"); \
1209 fprintf (FILE, "\tlsh\t16,ar2\n"); \
1210 fprintf (FILE, "\tor\t#LPBX0,ar2\n"); \
1211 if (BLOCKNO > 32767) \
1213 fprintf (FILE, "\tldi\t%d,r2\n", (BLOCKNO) >> 16); \
1214 fprintf (FILE, "\tlsh\t16,r2\n"); \
1215 fprintf (FILE, "\tor\t%d,r2\n", (BLOCKNO)); \
1219 fprintf (FILE, "\tldiu\t%d,r2\n", (BLOCKNO)); \
1221 fprintf (FILE, "\tcall\t___bb_init_trace_func\n"); \
1222 fprintf (FILE, "\tpop\tr2\n"); \
1223 fprintf (FILE, "\tpop\tar2\n"); \
1224 fprintf (FILE, "\tpop\tst\n"); \
1231 fprintf (FILE, "\tpush\tst\n"); \
1232 fprintf (FILE, "\tpush\tar2\n"); \
1233 fprintf (FILE, "\tldhi\t^LPBX0,ar2\n"); \
1234 fprintf (FILE, "\tor\t#LPBX0,ar2\n"); \
1235 fprintf (FILE, "\tcmpi\t0,*ar2\n"); \
1236 fprintf (FILE, "\tbne\t$+2\n"); \
1237 fprintf (FILE, "\tcall\t___bb_init_func\n"); \
1238 fprintf (FILE, "\tpop\tar2\n"); \
1239 fprintf (FILE, "\tpop\tst\n"); \
1243 fprintf (FILE, "\tpush\tst\n"); \
1244 fprintf (FILE, "\tpush\tar2\n"); \
1245 fprintf (FILE, "\tpush\tr2\n"); \
1246 fprintf (FILE, "\tldiu\t^LPBX0,ar2\n"); \
1247 fprintf (FILE, "\tlsh\t16,ar2\n"); \
1248 fprintf (FILE, "\tor\t#LPBX0,ar2\n"); \
1249 fprintf (FILE, "\tldi\t*ar2,r2\n"); \
1250 fprintf (FILE, "\tbne\t$+2\n"); \
1251 fprintf (FILE, "\tcall\t___bb_init_func\n"); \
1252 fprintf (FILE, "\tpop\tr2\n"); \
1253 fprintf (FILE, "\tpop\tar2\n"); \
1254 fprintf (FILE, "\tpop\tst\n"); \
1258 #define BLOCK_PROFILER(FILE, BLOCKNO) \
1259 if (profile_block_flag == 2) \
1263 fprintf (FILE, "\tpush\tst\n"); \
1264 fprintf (FILE, "\tpush\tar2\n"); \
1265 fprintf (FILE, "\tpush\tar0\n"); \
1266 fprintf (FILE, "\tldhi\t^___bb,ar2\n"); \
1267 fprintf (FILE, "\tor\t#___bb,ar2\n"); \
1268 if (BLOCKNO > 32767) \
1270 fprintf (FILE, "\tldhi\t%d,ar0\n", (BLOCKNO) >> 16);\
1271 fprintf (FILE, "\tor\t%d,ar0\n", (BLOCKNO)); \
1275 fprintf (FILE, "\tldiu\t%d,ar0\n", (BLOCKNO)); \
1277 fprintf (FILE, "\tsti\tar0,*ar2\n"); \
1278 fprintf (FILE, "\tldhi\t^LPBX0,ar0\n"); \
1279 fprintf (FILE, "\tor\t#LPBX0,ar0\n"); \
1280 fprintf (FILE, "\tsti\tar0,*+ar2(1)\n"); \
1281 fprintf (FILE, "\tcall\t___bb_trace_func\n"); \
1282 fprintf (FILE, "\tpop\tar0\n"); \
1283 fprintf (FILE, "\tpop\tar2\n"); \
1284 fprintf (FILE, "\tpop\tst\n"); \
1288 fprintf (FILE, "\tpush\tst\n"); \
1289 fprintf (FILE, "\tpush\tar2\n"); \
1290 fprintf (FILE, "\tpush\tar0\n"); \
1291 fprintf (FILE, "\tldiu\t^___bb,ar2\n"); \
1292 fprintf (FILE, "\tlsh\t16,ar2\n"); \
1293 fprintf (FILE, "\tor\t#___bb,ar2\n"); \
1294 if (BLOCKNO > 32767) \
1296 fprintf (FILE, "\tldi\t%d,ar0\n", (BLOCKNO) >> 16); \
1297 fprintf (FILE, "\tlsh\t16,ar0\n"); \
1298 fprintf (FILE, "\tor\t%d,ar0\n", (BLOCKNO)); \
1302 fprintf (FILE, "\tldiu\t%d,ar0\n", (BLOCKNO)); \
1304 fprintf (FILE, "\tsti\tar0,*ar2\n"); \
1305 fprintf (FILE, "\tldiu\t^LPBX0,ar0\n"); \
1306 fprintf (FILE, "\tlsh\t16,ar0\n"); \
1307 fprintf (FILE, "\tor\t#LPBX0,ar0\n"); \
1308 fprintf (FILE, "\tsti\tar0,*+ar2(1)\n"); \
1309 fprintf (FILE, "\tcall\t___bb_trace_func\n"); \
1310 fprintf (FILE, "\tpop\tar0\n"); \
1311 fprintf (FILE, "\tpop\tar2\n"); \
1312 fprintf (FILE, "\tpop\tst\n"); \
1319 fprintf (FILE, "\tpush\tar2\n"); \
1320 fprintf (FILE, "\tpush\tar0\n"); \
1321 fprintf (FILE, "\tldhi\t^LPBX2+%d,ar2\n", (BLOCKNO)); \
1322 fprintf (FILE, "\tor\t#LPBX2+%d,ar2\n", (BLOCKNO)); \
1323 fprintf (FILE, "\taddi3\t1,*ar2,ar0\n"); \
1324 fprintf (FILE, "\tsti\tar0,*ar2\n"); \
1325 fprintf (FILE, "\tpop\tar0\n"); \
1326 fprintf (FILE, "\tpop\tar2\n"); \
1330 fprintf (FILE, "\tpush\tar2\n"); \
1331 fprintf (FILE, "\tpush\tar0\n"); \
1332 fprintf (FILE, "\tldiu\t^LPBX2+%d,ar2\n", (BLOCKNO)); \
1333 fprintf (FILE, "\tlsh\t16,ar2\n"); \
1334 fprintf (FILE, "\tor\t#LPBX2+%d,ar2\n", (BLOCKNO)); \
1335 fprintf (FILE, "\tldiu\t*ar2,ar0\n"); \
1336 fprintf (FILE, "\taddi\t1,ar0\n"); \
1337 fprintf (FILE, "\tsti\tar0,*ar2\n"); \
1338 fprintf (FILE, "\tpop\tar0\n"); \
1339 fprintf (FILE, "\tpop\tar2\n"); \
1343 #define FUNCTION_BLOCK_PROFILER_EXIT(FILE) \
1345 fprintf (FILE, "\tpush\tst\n"); \
1346 fprintf (FILE, "\tpush\tar2\n"); \
1347 fprintf (FILE, "\tcall\t___bb_trace_ret\n"); \
1348 fprintf (FILE, "\tpop\tar2\n"); \
1349 fprintf (FILE, "\tpop\tst\n"); \
1352 #define MACHINE_STATE_SAVE(ID) \
1363 asm(" .if .BIGMODEL"); \
1372 asm(" .if .tms320C40"); \
1376 asm(" pushf r10"); \
1378 asm(" pushf r11"); \
1381 #define MACHINE_STATE_RESTORE(ID) \
1382 asm(" .if .tms320C40"); \
1396 asm(" .if .BIGMODEL"); \
1410 /* Implicit Calls to Library Routines */
1412 #define MULQI3_LIBCALL "__mulqi3"
1413 #define DIVQI3_LIBCALL "__divqi3"
1414 #define UDIVQI3_LIBCALL "__udivqi3"
1415 #define MODQI3_LIBCALL "__modqi3"
1416 #define UMODQI3_LIBCALL "__umodqi3"
1418 #define DIVQF3_LIBCALL "__divqf3"
1420 #define MULHF3_LIBCALL "__mulhf3"
1421 #define DIVHF3_LIBCALL "__divhf3"
1423 #define MULHI3_LIBCALL "__mulhi3"
1424 #define SMULHI3_LIBCALL "__smulhi3_high"
1425 #define UMULHI3_LIBCALL "__umulhi3_high"
1426 #define DIVHI3_LIBCALL "__divhi3"
1427 #define UDIVHI3_LIBCALL "__udivhi3"
1428 #define MODHI3_LIBCALL "__modhi3"
1429 #define UMODHI3_LIBCALL "__umodhi3"
1431 #define FLOATHIQF2_LIBCALL "__floathiqf2"
1432 #define FLOATUNSHIQF2_LIBCALL "__ufloathiqf2"
1433 #define FIX_TRUNCQFHI2_LIBCALL "__fix_truncqfhi2"
1434 #define FIXUNS_TRUNCQFHI2_LIBCALL "__ufix_truncqfhi2"
1436 #define FLOATHIHF2_LIBCALL "__floathihf2"
1437 #define FLOATUNSHIHF2_LIBCALL "__ufloathihf2"
1438 #define FIX_TRUNCHFHI2_LIBCALL "__fix_trunchfhi2"
1439 #define FIXUNS_TRUNCHFHI2_LIBCALL "__ufix_trunchfhi2"
1441 #define FFS_LIBCALL "__ffs"
1443 #define TARGET_MEM_FUNCTIONS
1445 /* Add any extra modes needed to represent the condition code.
1447 On the C4x, we have a "no-overflow" mode which is used when an ADD,
1448 SUB, NEG, or MPY insn is used to set the condition code. This is
1449 to prevent the combiner from optimising away a following CMP of the
1450 result with zero when a signed conditional branch or load insn
1453 The problem is a subtle one and deals with the manner in which the
1454 negative condition (N) flag is used on the C4x. This flag does not
1455 reflect the status of the actual result but of the ideal result had
1456 no overflow occured (when considering signed operands).
1458 For example, 0x7fffffff + 1 => 0x80000000 Z=0 V=1 N=0 C=0. Here
1459 the flags reflect the untruncated result, not the actual result.
1460 While the actual result is less than zero, the N flag is not set
1461 since the ideal result of the addition without truncation would
1464 Note that the while the N flag is handled differently to most other
1465 architectures, the use of it is self consistent and is not the
1466 cause of the problem.
1468 Logical operations set the N flag to the MSB of the result so if
1469 the result is negative, N is 1. However, integer and floating
1470 point operations set the N flag to be the MSB of the result
1471 exclusive ored with the overflow (V) flag. Thus if an overflow
1472 occurs and the result does not have the MSB set (i.e., the result
1473 looks like a positive number), the N flag is set. Conversely, if
1474 an overflow occurs and the MSB of the result is set, N is set to 0.
1475 Thus the N flag represents the sign of the result if it could have
1476 been stored without overflow but does not represent the apparent
1477 sign of the result. Note that most architectures set the N flag to
1478 be the MSB of the result.
1480 The C4x approach to setting the N flag simplifies signed
1481 conditional branches and loads which only have to test the state of
1482 the N flag, whereas most architectures have to look at both the N
1483 and V flags. The disadvantage is that there is no flag giving the
1484 status of the sign bit of the operation. However, there are no
1485 conditional load or branch instructions that make use of this
1486 feature (e.g., BMI---branch minus) instruction. Note that BN and
1487 BLT are identical in the C4x.
1489 To handle the problem where the N flag is set differently whenever
1490 there is an overflow we use a different CC mode, CC_NOOVmode which
1491 says that the CC reflects the comparison of the result against zero
1492 if no overflow occured.
1496 [(set (reg:CC_NOOV 21)
1497 (compare:CC_NOOV (minus:QI (match_operand:QI 1 "src_operand" "")
1498 (match_operand:QI 2 "src_operand" ""))
1500 (set (match_operand:QI 0 "ext_reg_operand" "")
1501 (minus:QI (match_dup 1)
1504 Note that there is no problem for insns that don't return a result
1505 like CMP, since the CC reflects the effect of operation.
1507 An example of a potential problem is when GCC
1508 converts (LTU (MINUS (0x80000000) (0x7fffffff) (0x80000000)))
1509 to (LEU (MINUS (0x80000000) (0x7fffffff) (0x7fffffff)))
1510 to (GE (MINUS (0x80000000) (0x7fffffff) (0x00000000)))
1512 Now (MINUS (0x80000000) (0x7fffffff)) returns 0x00000001 but the
1513 C4x sets the N flag since the result without overflow would have
1514 been 0xffffffff when treating the operands as signed integers.
1515 Thus (GE (MINUS (0x80000000) (0x7fffffff) (0x00000000))) sets the N
1516 flag but (GE (0x00000001)) does not set the N flag.
1518 The upshot is that we can not use signed branch and conditional
1519 load instructions after an add, subtract, neg, abs or multiply.
1520 We must emit a compare insn to check the result against 0. */
1522 #define EXTRA_CC_MODES CC(CC_NOOVmode, "CC_NOOV")
1524 /* CC_NOOVmode should be used when the first operand is a PLUS, MINUS, NEG
1526 CCmode should be used when no special processing is needed. */
1527 #define SELECT_CC_MODE(OP,X,Y) \
1528 ((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS \
1529 || GET_CODE (X) == NEG || GET_CODE (X) == MULT \
1530 || GET_MODE (X) == ABS \
1531 || GET_CODE (Y) == PLUS || GET_CODE (Y) == MINUS \
1532 || GET_CODE (Y) == NEG || GET_CODE (Y) == MULT \
1533 || GET_MODE (Y) == ABS) \
1534 ? CC_NOOVmode : CCmode)
1536 /* Addressing Modes */
1538 #define HAVE_POST_INCREMENT 1
1539 #define HAVE_PRE_INCREMENT 1
1540 #define HAVE_POST_DECREMENT 1
1541 #define HAVE_PRE_DECREMENT 1
1542 #define HAVE_PRE_MODIFY_REG 1
1543 #define HAVE_POST_MODIFY_REG 1
1544 #define HAVE_PRE_MODIFY_DISP 1
1545 #define HAVE_POST_MODIFY_DISP 1
1547 /* The number of insns that can be packed into a single opcode. */
1548 #define PACK_INSNS 2
1550 /* Recognize any constant value that is a valid address.
1551 We could allow arbitrary constant addresses in the large memory
1552 model but for the small memory model we can only accept addresses
1553 within the data page. I suppose we could also allow
1554 CONST PLUS SYMBOL_REF. */
1555 #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == SYMBOL_REF)
1557 /* Maximum number of registers that can appear in a valid memory
1559 #define MAX_REGS_PER_ADDRESS 2
1561 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1562 and check its validity for a certain class.
1563 We have two alternate definitions for each of them.
1564 The usual definition accepts all pseudo regs; the other rejects
1565 them unless they have been allocated suitable hard regs.
1566 The symbol REG_OK_STRICT causes the latter definition to be used.
1568 Most source files want to accept pseudo regs in the hope that
1569 they will get allocated to the class that the insn wants them to be in.
1570 Source files for reload pass need to be strict.
1571 After reload, it makes no difference, since pseudo regs have
1572 been eliminated by then. */
1574 #ifndef REG_OK_STRICT
1576 /* Nonzero if X is a hard or pseudo reg that can be used as an base. */
1578 #define REG_OK_FOR_BASE_P(X) IS_ADDR_OR_PSEUDO_REG(REGNO(X))
1580 /* Nonzero if X is a hard or pseudo reg that can be used as an index. */
1582 #define REG_OK_FOR_INDEX_P(X) IS_INDEX_OR_PSEUDO_REG(REGNO(X))
1584 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1586 if (c4x_check_legit_addr (MODE, X, 0)) \
1592 /* Nonzero if X is a hard reg that can be used as an index. */
1594 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
1596 /* Nonzero if X is a hard reg that can be used as a base reg. */
1598 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
1600 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1602 if (c4x_check_legit_addr (MODE, X, 1)) \
1608 #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
1611 new = c4x_legitimize_address (X, MODE); \
1612 if (new != NULL_RTX) \
1619 #define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
1622 new = c4x_legitimize_reload_address (X, MODE, insn); \
1623 if (new != NULL_RTX) \
1626 /* We do not have to call push_reload because we do not require \
1627 any more reloads. */ \
1633 /* No mode-dependent addresses on the C4x are autoincrements. */
1635 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \
1636 if (GET_CODE (ADDR) == PRE_DEC \
1637 || GET_CODE (ADDR) == POST_DEC \
1638 || GET_CODE (ADDR) == PRE_INC \
1639 || GET_CODE (ADDR) == POST_INC \
1640 || GET_CODE (ADDR) == POST_MODIFY \
1641 || GET_CODE (ADDR) == PRE_MODIFY) \
1645 /* Nonzero if the constant value X is a legitimate general operand.
1646 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
1648 The C4x can only load 16-bit immediate values, so we only allow a
1649 restricted subset of CONST_INT and CONST_DOUBLE. Disallow
1650 LABEL_REF and SYMBOL_REF (except on the C40 with the big memory
1651 model) so that the symbols will be forced into the constant pool.
1652 On second thoughts, let's do this with the move expanders since
1653 the alias analysis has trouble if we force constant addresses
1657 #define LEGITIMATE_CONSTANT_P(X) \
1658 ((GET_CODE (X) == CONST_DOUBLE && c4x_H_constant (X)) \
1659 || (GET_CODE (X) == CONST_INT) \
1660 || (GET_CODE (X) == SYMBOL_REF) \
1661 || (GET_CODE (X) == LABEL_REF) \
1662 || (GET_CODE (X) == CONST) \
1663 || (GET_CODE (X) == HIGH && ! TARGET_C3X) \
1664 || (GET_CODE (X) == LO_SUM && ! TARGET_C3X))
1666 #define LEGITIMATE_DISPLACEMENT_P(X) IS_DISP8_CONST (INTVAL (X))
1668 /* Define this macro if references to a symbol must be treated
1669 differently depending on something about the variable or
1670 function named by the symbol (such as what section it is in).
1672 The macro definition, if any, is executed immediately after the
1673 rtl for DECL or other node is created.
1674 The value of the rtl will be a `mem' whose address is a
1677 The usual thing for this macro to do is to a flag in the
1678 `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified
1679 name string in the `symbol_ref' (if one bit is not enough
1682 On the C4x we use this to indicate if a symbol is in text or
1685 #define ENCODE_SECTION_INFO(DECL) c4x_encode_section_info (DECL);
1687 /* Descripting Relative Cost of Operations */
1689 /* Provide the costs of a rtl expression. This is in the body of a
1692 Note that we return, rather than break so that rtx_cost doesn't
1693 include CONST_COSTS otherwise expand_mult will think that it is
1694 cheaper to synthesise a multiply rather than to use a multiply
1695 instruction. I think this is because the algorithm synth_mult
1696 doesn't take into account the loading of the operands, whereas the
1697 calculation of mult_cost does.
1701 #define RTX_COSTS(RTX, CODE, OUTER_CODE) \
1710 return COSTS_N_INSNS (1); \
1712 return COSTS_N_INSNS (GET_MODE_CLASS (GET_MODE (RTX)) == MODE_FLOAT \
1713 || TARGET_MPYI ? 1 : 14); \
1718 return COSTS_N_INSNS (GET_MODE_CLASS (GET_MODE (RTX)) == MODE_FLOAT \
1721 /* Compute the cost of computing a constant rtl expression RTX
1722 whose rtx-code is CODE. The body of this macro is a portion
1723 of a switch statement. If the code is computed here,
1724 return it with a return statement. Otherwise, break from the switch.
1726 An insn is assumed to cost 4 units.
1727 COSTS_N_INSNS (N) is defined as (N) * 4 - 2.
1729 Some small integers are effectively free for the C40. We should
1730 also consider if we are using the small memory model. With
1731 the big memory model we require an extra insn for a constant
1734 This is used by expand_binop to decide whether to force a constant
1735 into a register. If the cost is greater than 2 and the constant
1736 is used within a short loop, it gets forced into a register.
1737 Ideally, there should be some weighting as to how mnay times it is used
1740 #define SHIFT_CODE_P(C) ((C) == ASHIFT || (C) == ASHIFTRT || (C) == LSHIFTRT)
1742 #define LOGICAL_CODE_P(C) ((C) == NOT || (C) == AND \
1743 || (C) == IOR || (C) == XOR)
1745 #define NON_COMMUTATIVE_CODE_P ((C) == MINUS || (C) == COMPARE)
1747 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
1749 if (c4x_J_constant (RTX)) \
1752 && OUTER_CODE == AND \
1753 && GET_CODE (RTX) == CONST_INT \
1754 && (INTVAL (RTX) == 255 || INTVAL (RTX) == 65535)) \
1757 && (OUTER_CODE == ASHIFTRT || OUTER_CODE == LSHIFTRT) \
1758 && GET_CODE (RTX) == CONST_INT \
1759 && (INTVAL (RTX) == 16 || INTVAL (RTX) == 24)) \
1761 if (TARGET_C3X && SHIFT_CODE_P (OUTER_CODE)) \
1763 if (LOGICAL_CODE_P (OUTER_CODE) \
1764 ? c4x_L_constant (RTX) : c4x_I_constant (RTX)) \
1770 case CONST_DOUBLE: \
1771 if (c4x_H_constant (RTX)) \
1773 if (GET_MODE (RTX) == QFmode) \
1778 /* Compute the cost of an address. This is meant to approximate the size
1779 and/or execution delay of an insn using that address. If the cost is
1780 approximated by the RTL complexity, including CONST_COSTS above, as
1781 is usually the case for CISC machines, this macro should not be defined.
1782 For aggressively RISCy machines, only one insn format is allowed, so
1783 this macro should be a constant. The value of this macro only matters
1784 for valid addresses. We handle the most common address without
1785 a call to c4x_address_cost. */
1787 #define ADDRESS_COST(ADDR) (REG_P (ADDR) ? 1 : c4x_address_cost (ADDR))
1789 #define CANONICALIZE_COMPARISON(CODE, OP0, OP1) \
1790 if (REG_P (OP1) && ! REG_P (OP0)) \
1792 rtx tmp = OP0; OP0 = OP1 ; OP1 = tmp; \
1793 CODE = swap_condition (CODE); \
1796 #define EXT_CLASS_P(CLASS) (reg_class_subset_p (CLASS, EXT_REGS))
1797 #define ADDR_CLASS_P(CLASS) (reg_class_subset_p (CLASS, ADDR_REGS))
1798 #define INDEX_CLASS_P(CLASS) (reg_class_subset_p (CLASS, INDEX_REGS))
1799 #define EXPENSIVE_CLASS_P(CLASS) (ADDR_CLASS_P(CLASS) \
1800 || INDEX_CLASS_P(CLASS) || (CLASS) == SP_REG)
1802 /* Compute extra cost of moving data between one register class
1805 #define REGISTER_MOVE_COST(FROM, TO) 2
1807 /* Memory move cost is same as fast register move. Maybe this should
1810 #define MEMORY_MOVE_COST(M,C,I) 4
1812 /* Branches are kind of expensive (even with delayed branching) so
1813 make their cost higher. */
1815 #define BRANCH_COST 8
1817 /* Adjust the cost of dependencies. */
1819 #define ADJUST_COST(INSN,LINK,DEP,COST) \
1820 (COST) = c4x_adjust_cost (INSN, LINK, DEP, COST)
1822 #define WORD_REGISTER_OPERATIONS
1824 /* Dividing the Output into Sections. */
1826 #define TEXT_SECTION_ASM_OP "\t.text"
1828 #define DATA_SECTION_ASM_OP "\t.data"
1830 #define USE_CONST_SECTION 1
1832 #define CONST_SECTION_ASM_OP "\t.sect\t\".const\""
1834 /* Do not use .init section so __main will be called on startup. This will
1835 call __do_global_ctors and prepare for __do_global_dtors on exit. */
1838 #define INIT_SECTION_ASM_OP "\t.sect\t\".init\""
1841 #define FINI_SECTION_ASM_OP "\t.sect\t\".fini\""
1843 /* Support const sections and the ctors and dtors sections for g++.
1844 Note that there appears to be two different ways to support const
1845 sections at the moment. You can either #define the symbol
1846 READONLY_DATA_SECTION (giving it some code which switches to the
1847 readonly data section) or else you can #define the symbols
1848 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
1849 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
1851 /* Define a few machine-specific details of the implementation of
1854 The __CTORS_LIST__ goes in the .ctors section. Define CTOR_LIST_BEGIN
1855 and CTOR_LIST_END to contribute to the .ctors section an instruction to
1856 push a word containing 0 (or some equivalent of that).
1858 Define ASM_OUTPUT_CONSTRUCTOR to push the address of the constructor. */
1860 #define CTORS_SECTION_ASM_OP "\t.sect\t\".ctors\""
1861 #define DTORS_SECTION_ASM_OP "\t.sect\t\".dtors\""
1863 /* Constructor list on stack is in reverse order. Go to the end of the
1864 list and go backwards to call constructors in the right order. */
1866 #define DO_GLOBAL_CTORS_BODY \
1868 extern func_ptr __CTOR_LIST__[]; \
1869 func_ptr *p, *beg = __CTOR_LIST__ + 1; \
1870 for (p = beg; *p ; p++) ; \
1875 #undef EXTRA_SECTIONS
1876 #define EXTRA_SECTIONS in_const, in_init, in_fini, in_ctors, in_dtors
1878 #undef EXTRA_SECTION_FUNCTIONS
1879 #define EXTRA_SECTION_FUNCTIONS \
1880 CONST_SECTION_FUNCTION \
1881 INIT_SECTION_FUNCTION \
1882 FINI_SECTION_FUNCTION \
1883 CTORS_SECTION_FUNCTION \
1884 DTORS_SECTION_FUNCTION
1886 #define INIT_SECTION_FUNCTION \
1890 if (in_section != in_init) \
1892 fprintf (asm_out_file, ";\t.init\n"); \
1893 in_section = in_init; \
1897 #define FINI_SECTION_FUNCTION \
1901 if (in_section != in_fini) \
1903 fprintf (asm_out_file, "\t%s\n", FINI_SECTION_ASM_OP); \
1904 in_section = in_fini; \
1908 #define READONLY_DATA_SECTION() const_section ()
1910 #define CONST_SECTION_FUNCTION \
1914 if (! USE_CONST_SECTION) \
1916 else if (in_section != in_const) \
1918 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
1919 in_section = in_const; \
1923 #define ASM_STABS_OP "\t.stabs"
1925 /* The ctors and dtors sections are not normally put into use
1926 by EXTRA_SECTIONS and EXTRA_SECTION_FUNCTIONS as defined in svr3.h,
1927 but it can't hurt to define these macros for whatever systems use them. */
1929 #define CTORS_SECTION_FUNCTION \
1933 if (in_section != in_ctors) \
1935 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
1936 in_section = in_ctors; \
1940 #define DTORS_SECTION_FUNCTION \
1944 if (in_section != in_dtors) \
1946 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
1947 in_section = in_dtors; \
1951 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
1952 fprintf (FILE, "\t.sect\t\"%s\"\n", NAME);
1954 /* This is machine-dependent because it needs to push something
1957 /* A C statement (sans semicolon) to output an element in the table of
1958 global constructors. */
1959 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
1962 fprintf (FILE, "\t.word\t "); \
1963 assemble_name (FILE, NAME); \
1964 fprintf (FILE, "\n"); \
1967 /* A C statement (sans semicolon) to output an element in the table of
1968 global destructors. */
1969 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
1972 fprintf (FILE, "\t.word\t "); \
1973 assemble_name (FILE, NAME); \
1974 fprintf (FILE, "\n"); \
1977 /* A C statement or statements to switch to the appropriate
1978 section for output of DECL. DECL is either a `VAR_DECL' node
1979 or a constant of some sort. RELOC indicates whether forming
1980 the initial value of DECL requires link-time relocations. */
1982 #define SELECT_SECTION(DECL, RELOC) \
1984 if (TREE_CODE (DECL) == STRING_CST) \
1986 if (! flag_writable_strings) \
1991 else if (TREE_CODE (DECL) == VAR_DECL) \
1993 if ((0 && RELOC) /* should be (flag_pic && RELOC) */ \
1994 || ! TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
1995 || ! DECL_INITIAL (DECL) \
1996 || (DECL_INITIAL (DECL) != error_mark_node \
1997 && ! TREE_CONSTANT (DECL_INITIAL (DECL)))) \
2006 /* A C statement or statements to switch to the appropriate
2007 section for output of RTX in mode MODE. RTX is some kind
2008 of constant in RTL. The argument MODE is redundant except
2009 in the case of a `const_int' rtx. Currently, these always
2010 go into the const section. */
2012 #define SELECT_RTX_SECTION(MODE, RTX) const_section()
2015 /* Overall Framework of an Assembler File */
2017 #define ASM_FILE_START(FILE) \
2019 int dspversion = 0; \
2020 if (TARGET_C30) dspversion = 30; \
2021 if (TARGET_C31) dspversion = 31; \
2022 if (TARGET_C32) dspversion = 32; \
2023 if (TARGET_C40) dspversion = 40; \
2024 if (TARGET_C44) dspversion = 44; \
2025 fprintf (FILE, "\t.version\t%d\n", dspversion); \
2026 fprintf (FILE, "\t.file\t"); \
2030 char *after_dir = main_input_filename; \
2031 for (p = main_input_filename; *p; p++) \
2033 after_dir = p + 1; \
2034 output_quoted_string (FILE, after_dir); \
2037 output_quoted_string (FILE, main_input_filename); \
2038 fprintf (FILE, "\n"); \
2041 #define ASM_FILE_END(FILE) fprintf (FILE, "\t.end\n")
2043 /* We need to have a data section we can identify so that we can set
2044 the DP register back to a data pointer in the small memory model.
2045 This is only required for ISRs if we are paranoid that someone
2046 may have quietly changed this register on the sly. */
2048 #define ASM_IDENTIFY_GCC(FILE) \
2049 if (! TARGET_TI) fputs ("gcc2_compiled.:\n", FILE); \
2050 fputs ("\t.data\ndata_sec:\n", FILE);
2052 #define ASM_COMMENT_START ";"
2054 #define ASM_APP_ON ""
2055 #define ASM_APP_OFF ""
2057 /* Output float/double constants QFmode. */
2059 #define ASM_OUTPUT_BYTE_FLOAT(FILE, VALUE) \
2063 REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
2064 REAL_VALUE_TO_DECIMAL (VALUE, "%20lf", str); \
2065 if (sizeof (int) == sizeof (long)) \
2066 fprintf (FILE, "\t.word\t0%08xh\t; %s\n", l, str);\
2068 fprintf (FILE, "\t.word\t0%08lxh\t; %s\n", l, str);\
2071 /* Output long double constants HFmode.
2072 The first word contains the exponent and first part of the mantissa
2073 in the same manner as QFmode. The second word contains the full
2074 mantissa. We should ensure that the two words are allocated within
2075 the same page for the large memory model since we only output a single
2076 LDP instruction. FIXME. The simplest solution probably is to output
2077 a LDP for each load. */
2079 #define ASM_OUTPUT_SHORT_FLOAT(FILE, VALUE) \
2083 REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \
2084 REAL_VALUE_TO_DECIMAL (VALUE, "%20lf", str); \
2085 l[1] = (l[0] << 8) | ((l[1] >> 24) & 0xff); \
2086 if (sizeof (int) == sizeof (long)) \
2087 fprintf (FILE, "\t.word\t0%08xh\t; %s\n\t.word\t0%08xh\n", \
2090 fprintf (FILE, "\t.word\t0%08lxh\t; %s\n\t.word\t0%08lxh\n", \
2094 #define ASM_OUTPUT_CHAR(FILE, VALUE) \
2096 fprintf (FILE, "\t.word\t"); \
2097 output_addr_const (FILE, VALUE); \
2098 if (GET_CODE (VALUE) != SYMBOL_REF) \
2099 fprintf (FILE, " ; 0%08xh\n", INTVAL (VALUE)); \
2101 fputc ('\n', FILE); \
2104 #define ASM_OUTPUT_BYTE(FILE, VALUE) \
2105 fprintf (FILE, "\t.word\t0%xh\n", (VALUE))
2107 #define ASM_OUTPUT_ASCII(FILE, PTR, LEN) c4x_output_ascii (FILE, PTR, LEN)
2109 #define ASM_OPEN_PAREN "("
2110 #define ASM_CLOSE_PAREN ")"
2113 /* Output and Generation of Labels */
2115 #define NO_DOT_IN_LABEL /* Only required for TI format */
2117 #define ASM_OUTPUT_LABEL(FILE, NAME) \
2118 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0);
2120 #define ASM_GLOBALIZE_LABEL(FILE, NAME) \
2122 fprintf (FILE, "\t.global\t"); \
2123 assemble_name (FILE, NAME); \
2124 fputs ("\n", FILE); \
2127 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
2129 fprintf (FILE, "\t.ref\t"); \
2130 assemble_name (FILE, NAME); \
2131 fputc ('\n', FILE); \
2134 /* A C statement to output on FILE an assembler pseudo-op to
2135 declare a library function named external.
2136 (Only needed to keep asm30 happy for ___divqf3 etc.) */
2138 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
2140 fprintf (FILE, "\t.ref\t"); \
2141 assemble_name (FILE, XSTR (FUN, 0)); \
2142 fprintf (FILE, "\n"); \
2145 /* The prefix to add to user-visible assembler symbols. */
2147 #define USER_LABEL_PREFIX "_"
2149 /* This is how to output an internal numbered label where
2150 PREFIX is the class of label and NUM is the number within the class. */
2152 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \
2153 asm_fprintf (FILE, "%s%d:\n", PREFIX, NUM)
2155 /* This is how to store into the string LABEL
2156 the symbol_ref name of an internal numbered label where
2157 PREFIX is the class of label and NUM is the number within the class.
2158 This is suitable for output with `assemble_name'. */
2160 #define ASM_GENERATE_INTERNAL_LABEL(BUFFER, PREFIX, NUM) \
2161 sprintf (BUFFER, "*%s%d", PREFIX, NUM)
2163 /* Store in OUTPUT a string (made with alloca) containing
2164 an assembler-name for a local static variable named NAME.
2165 LABELNO is an integer which is different for each call. */
2167 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
2168 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
2169 sprintf ((OUTPUT), "%s%d", (NAME), (LABELNO)))
2172 /* Output of Dispatch Tables */
2174 /* This is how to output an element of a case-vector that is absolute. */
2176 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
2177 fprintf (FILE, "\t.long\tL%d\n", VALUE);
2179 /* This is how to output an element of a case-vector that is relative. */
2181 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
2182 fprintf (FILE, "\t.long\tL%d-L%d\n", VALUE, REL);
2185 #define SIZE_TYPE "unsigned int"
2188 #define PTRDIFF_TYPE "int"
2191 #define WCHAR_TYPE "long int"
2193 #undef WCHAR_TYPE_SIZE
2194 #define WCHAR_TYPE_SIZE 32
2196 #define INT_TYPE_SIZE 32
2197 #define LONG_LONG_TYPE_SIZE 64
2198 #define FLOAT_TYPE_SIZE 32
2199 #define DOUBLE_TYPE_SIZE 32
2200 #define LONG_DOUBLE_TYPE_SIZE 64 /* actually only 40 */
2202 /* Allow #sccs in preprocessor. */
2204 #define SCCS_DIRECTIVE
2206 /* Output #ident as a .ident. */
2208 #define ASM_OUTPUT_IDENT(FILE, NAME) \
2209 fprintf (FILE, "\t.ident \"%s\"\n", NAME);
2211 #define CPP_PREDEFINES ""
2213 /* Output of Uninitialized Variables */
2215 /* This says how to output an assembler line to define a local
2216 uninitialized variable. */
2218 #undef ASM_OUTPUT_LOCAL
2219 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
2220 ( fputs ("\t.bss\t", FILE), \
2221 assemble_name (FILE, (NAME)), \
2222 fprintf (FILE, ",%u\n", (ROUNDED)))
2224 /* This says how to output an assembler line to define a global
2225 uninitialized variable. */
2227 #undef ASM_OUTPUT_COMMON
2228 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
2229 ( fputs ("\t.globl\t", FILE), \
2230 assemble_name (FILE, (NAME)), \
2231 fputs ("\n\t.bss\t", FILE), \
2232 assemble_name (FILE, (NAME)), \
2233 fprintf (FILE, ",%u\n", (ROUNDED)))
2235 /* Macros Controlling Initialization Routines */
2237 #define OBJECT_FORMAT_COFF
2238 #define REAL_NM_FILE_NAME "c4x-nm"
2240 /* Output of Assembler Instructions */
2242 /* Register names when used for integer modes. */
2244 #define REGISTER_NAMES \
2246 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
2247 "ar0", "ar1", "ar2", "ar3", "ar4", "ar5", "ar6", "ar7", \
2248 "dp", "ir0", "ir1", "bk", "sp", "st", "die", "iie", \
2249 "iif", "rs", "re", "rc", "r8", "r9", "r10", "r11" \
2252 /* Alternate register names when used for floating point modes. */
2254 #define FLOAT_REGISTER_NAMES \
2256 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
2257 "ar0", "ar1", "ar2", "ar3", "ar4", "ar5", "ar6", "ar7", \
2258 "dp", "ir0", "ir1", "bk", "sp", "st", "die", "iie", \
2259 "iif", "rs", "re", "rc", "f8", "f9", "f10", "f11" \
2262 #define PRINT_OPERAND(FILE, X, CODE) c4x_print_operand(FILE, X, CODE)
2264 /* Determine which codes are valid without a following integer. These must
2265 not be alphabetic. */
2267 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) ((CODE) == '#')
2269 #define PRINT_OPERAND_ADDRESS(FILE, X) c4x_print_operand_address(FILE, X)
2271 /* Define this macro if you want to implement any pragmas. If defined, it
2272 should be a C expression to be executed when #pragma is seen. The
2273 argument STREAM is the stdio input stream from which the source
2274 text can be read. CH is the first character after the #pragma. The
2275 result of the expression is the terminating character found
2276 (newline or EOF). */
2277 #define HANDLE_PRAGMA(GETC, UNGETC, NAME) \
2278 c4x_handle_pragma (GETC, UNGETC, NAME)
2280 #define SET_DEFAULT_DECL_ATTRIBUTES(DECL, ATTRIBUTES) \
2281 c4x_set_default_attributes (DECL, &ATTRIBUTES)
2283 #define VALID_MACHINE_TYPE_ATTRIBUTE(TYPE, ATTRIBUTES, NAME, ARGS) \
2284 (c4x_valid_type_attribute_p (TYPE, ATTRIBUTES, NAME, ARGS))
2286 /* Assembler Commands for Alignment */
2288 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
2290 for (; c > 0; --c) \
2291 fprintf (FILE,"\t.word\t0\n"); \
2294 #define ASM_NO_SKIP_IN_TEXT 1
2296 /* I'm not sure about this one. FIXME. */
2298 #define ASM_OUTPUT_ALIGN(FILE, LOG) \
2300 fprintf (FILE, "\t.align\t%d\n", (1 << (LOG)))
2303 /* Macros for SDB and DWARF Output (use .sdef instead of .def
2304 to avoid conflict with TI's use of .def) */
2306 #define SDB_DELIM "\n"
2307 #define SDB_DEBUGGING_INFO
2309 #define PUT_SDB_DEF(A) \
2310 do { fprintf (asm_out_file, "\t.sdef\t"); \
2311 ASM_OUTPUT_LABELREF (asm_out_file, A); \
2312 fprintf (asm_out_file, SDB_DELIM); } while (0)
2314 #define PUT_SDB_PLAIN_DEF(A) \
2315 fprintf (asm_out_file,"\t.sdef\t.%s%s", A, SDB_DELIM)
2317 #define PUT_SDB_BLOCK_START(LINE) \
2318 fprintf (asm_out_file, \
2319 "\t.sdef\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
2320 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
2322 #define PUT_SDB_BLOCK_END(LINE) \
2323 fprintf (asm_out_file, \
2324 "\t.sdef\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
2325 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
2327 #define PUT_SDB_FUNCTION_START(LINE) \
2328 fprintf (asm_out_file, \
2329 "\t.sdef\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
2330 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
2332 #define PUT_SDB_FUNCTION_END(LINE) \
2333 fprintf (asm_out_file, \
2334 "\t.sdef\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
2335 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
2337 #define PUT_SDB_EPILOGUE_END(NAME) \
2338 do { fprintf (asm_out_file, "\t.sdef\t"); \
2339 ASM_OUTPUT_LABELREF (asm_out_file, NAME); \
2340 fprintf (asm_out_file, \
2341 "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n", \
2342 SDB_DELIM, SDB_DELIM, SDB_DELIM); } while (0)
2345 /* Define results of standard character escape sequences. */
2347 #define TARGET_BELL 007
2348 #define TARGET_BS 010
2349 #define TARGET_TAB 011
2350 #define TARGET_NEWLINE 012
2351 #define TARGET_VT 013
2352 #define TARGET_FF 014
2353 #define TARGET_CR 015
2355 /* This is the kind of divide that is easiest to do in the general case. */
2357 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
2359 /* Define this as 1 if `char' should by default be signed; else as 0. */
2361 #define DEFAULT_SIGNED_CHAR 1
2363 /* A function address in a call instruction is a byte address (for
2364 indexing purposes) so give the MEM rtx a byte's mode. */
2366 #define FUNCTION_MODE QImode
2368 #define SLOW_BYTE_ACCESS 0
2370 /* Specify the machine mode that pointers have. After generation of
2371 RTL, the compiler makes no further distinction between pointers and
2372 any other objects of this machine mode. */
2374 #define Pmode QImode
2376 /* On the C4x we can write the following code. We have to clear the cache
2377 every time we execute it because the data in the stack could change.
2390 On the c3x this is a bit more difficult. We have to write self
2391 modifying code here. So we have to clear the cache every time
2392 we execute it because the data in the stack could change.
2394 ldiu TOP_OF_FUNCTION,ar1
2396 or BOTTOM_OF_FUNCTION,ar1
2397 ldiu TOP_OF_STATIC,ar0
2400 or BOTTOM_OF_STATIC,ar0
2405 #define TRAMPOLINE_SIZE (TARGET_C3X ? 8 : 10)
2407 #define TRAMPOLINE_TEMPLATE(FILE) \
2411 asm_fprintf (FILE, "\tldiu\t0,ar1\n"); \
2412 asm_fprintf (FILE, "\tlsh\t16,ar1\n"); \
2413 asm_fprintf (FILE, "\tor\t0,ar1\n"); \
2414 asm_fprintf (FILE, "\tldiu\t0,ar0\n"); \
2415 asm_fprintf (FILE, "\tbud\tar1\n"); \
2416 asm_fprintf (FILE, "\tlsh\t16,ar0\n"); \
2417 asm_fprintf (FILE, "\tor\t0,ar0\n"); \
2418 asm_fprintf (FILE, "\tor\t1000h,st\n"); \
2422 asm_fprintf (FILE, "\tlaj\t$+4\n"); \
2423 asm_fprintf (FILE, "\taddi3\t4,r11,ar0\n"); \
2424 asm_fprintf (FILE, "\tlda\t*ar0,ar1\n"); \
2425 asm_fprintf (FILE, "\tlda\t*+ar0(1),ar0\n"); \
2426 asm_fprintf (FILE, "\tbud\tar1\n"); \
2427 asm_fprintf (FILE, "\tnop\n"); \
2428 asm_fprintf (FILE, "\tnop\n"); \
2429 asm_fprintf (FILE, "\tor\t1000h,st\n"); \
2430 asm_fprintf (FILE, "\t.word\t0\n"); \
2431 asm_fprintf (FILE, "\t.word\t0\n"); \
2435 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
2440 tmp1 = expand_shift (RSHIFT_EXPR, QImode, FNADDR, \
2441 size_int (16), 0, 1); \
2442 tmp2 = expand_shift (LSHIFT_EXPR, QImode, \
2443 gen_rtx (CONST_INT, VOIDmode, 0x5069), \
2444 size_int (16), 0, 1); \
2445 emit_insn (gen_iorqi3 (tmp1, tmp1, tmp2)); \
2446 emit_move_insn (gen_rtx (MEM, QImode, \
2447 plus_constant (tramp, 0)), tmp1); \
2448 tmp1 = expand_and (FNADDR, gen_rtx (CONST_INT, VOIDmode, \
2450 tmp2 = expand_shift (LSHIFT_EXPR, QImode, \
2451 gen_rtx (CONST_INT, VOIDmode, 0x1069), \
2452 size_int (16), 0, 1); \
2453 emit_insn (gen_iorqi3 (tmp1, tmp1, tmp2)); \
2454 emit_move_insn (gen_rtx (MEM, QImode, \
2455 plus_constant (tramp, 2)), tmp1); \
2456 tmp1 = expand_shift (RSHIFT_EXPR, QImode, CXT, \
2457 size_int (16), 0, 1); \
2458 tmp2 = expand_shift (LSHIFT_EXPR, QImode, \
2459 gen_rtx (CONST_INT, VOIDmode, 0x5068), \
2460 size_int (16), 0, 1); \
2461 emit_insn (gen_iorqi3 (tmp1, tmp1, tmp2)); \
2462 emit_move_insn (gen_rtx (MEM, QImode, \
2463 plus_constant (tramp, 3)), tmp1); \
2464 tmp1 = expand_and (CXT, gen_rtx (CONST_INT, VOIDmode, \
2466 tmp2 = expand_shift (LSHIFT_EXPR, QImode, \
2467 gen_rtx (CONST_INT, VOIDmode, 0x1068), \
2468 size_int (16), 0, 1); \
2469 emit_insn (gen_iorqi3 (tmp1, tmp1, tmp2)); \
2470 emit_move_insn (gen_rtx (MEM, QImode, \
2471 plus_constant (tramp, 6)), tmp1); \
2475 emit_move_insn (gen_rtx (MEM, QImode, \
2476 plus_constant (TRAMP, 8)), FNADDR); \
2477 emit_move_insn (gen_rtx (MEM, QImode, \
2478 plus_constant (TRAMP, 9)), CXT); \
2482 /* Specify the machine mode that this machine uses for the index in
2483 the tablejump instruction. */
2485 #define CASE_VECTOR_MODE Pmode
2487 /* Max number of (32-bit) bytes we can move from memory to memory
2488 in one reasonably fast instruction. */
2492 /* MOVE_RATIO is the number of move instructions that is better than a
2495 #define MOVE_RATIO 2 /* Default value */
2497 #define BSS_SECTION_ASM_OP ".bss"
2499 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO) \
2500 asm_fprintf (FILE, "\tpush\t%s\n", reg_names[REGNO])
2502 /* This is how to output an insn to pop a register from the stack.
2503 It need not be very fast code. */
2505 #define ASM_OUTPUT_REG_POP(FILE, REGNO) \
2506 asm_fprintf (FILE, "\tpop\t%s\n", reg_names[REGNO])
2508 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
2509 is done just by pretending it is already truncated. */
2511 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
2513 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
2515 /* We need to use direct addressing for large constants and addresses
2516 that cannot fit within an instruction. We must check for these
2517 after after the final jump optimisation pass, since this may
2518 introduce a local_move insn for a SYMBOL_REF. This pass
2519 must come before delayed branch slot filling since it can generate
2520 additional instructions. */
2522 #define MACHINE_DEPENDENT_REORG(INSNS) c4x_process_after_reload(INSNS)
2524 #define DBR_OUTPUT_SEQEND(FILE) \
2525 if (final_sequence != NULL_RTX) \
2528 int laj = GET_CODE (XVECEXP (final_sequence, 0, 0)) == CALL_INSN; \
2530 count = dbr_sequence_length(); \
2531 while (count < (laj ? 2 : 3)) \
2533 fputs("\tnop\n", FILE); \
2537 fputs("\tpush\tr11\n", FILE); \
2540 #define NO_FUNCTION_CSE
2542 /* We don't want a leading tab. */
2544 #define ASM_OUTPUT_ASM(FILE, STRING) fprintf (FILE, "%s\n", STRING)
2546 /* Define the codes that are matched by predicates in c4x.c. */
2548 #define PREDICATE_CODES \
2549 {"fp_zero_operand", {CONST_DOUBLE}}, \
2550 {"const_operand", {CONST_INT, CONST_DOUBLE}}, \
2551 {"stik_const_operand", {CONST_INT}}, \
2552 {"not_const_operand", {CONST_INT}}, \
2553 {"reg_operand", {REG, SUBREG}}, \
2554 {"reg_or_const_operand", {REG, SUBREG, CONST_INT, CONST_DOUBLE}},\
2555 {"r0r1_reg_operand", {REG, SUBREG}}, \
2556 {"r2r3_reg_operand", {REG, SUBREG}}, \
2557 {"ext_low_reg_operand", {REG, SUBREG}}, \
2558 {"ext_reg_operand", {REG, SUBREG}}, \
2559 {"std_reg_operand", {REG, SUBREG}}, \
2560 {"addr_reg_operand", {REG, SUBREG}}, \
2561 {"index_reg_operand", {REG, SUBREG}}, \
2562 {"dp_reg_operand", {REG}}, \
2563 {"sp_reg_operand", {REG}}, \
2564 {"st_reg_operand", {REG}}, \
2565 {"rc_reg_operand", {REG}}, \
2566 {"call_address_operand", {REG, SYMBOL_REF, LABEL_REF, CONST}}, \
2567 {"dst_operand", {SUBREG, REG, MEM}}, \
2568 {"src_operand", {SUBREG, REG, MEM, CONST_INT, CONST_DOUBLE}}, \
2569 {"src_hi_operand", {SUBREG, REG, MEM, CONST_DOUBLE}}, \
2570 {"lsrc_operand", {SUBREG, REG, MEM, CONST_INT, CONST_DOUBLE}}, \
2571 {"tsrc_operand", {SUBREG, REG, MEM, CONST_INT, CONST_DOUBLE}}, \
2572 {"any_operand", {SUBREG, REG, MEM, CONST_INT, CONST_DOUBLE}}, \
2573 {"par_ind_operand", {MEM}}, \
2574 {"parallel_operand", {SUBREG, REG, MEM}}, \
2575 {"symbolic_address_operand", {SYMBOL_REF, LABEL_REF, CONST}}, \
2576 {"mem_operand", {MEM}},
2579 /* Variables in c4x.c */
2581 extern enum reg_class c4x_regclass_map
[];/* smallest class containing REGNO */
2582 extern enum machine_mode c4x_caller_save_map
[];
2584 extern struct rtx_def
*c4x_compare_op0
; /* operand 0 for comparisons */
2585 extern struct rtx_def
*c4x_compare_op1
; /* operand 1 for comparisons */
2587 extern int c4x_rpts_cycles
; /* max cycles for RPTS */
2588 extern int c4x_cpu_version
; /* cpu version C30/31/32/40/44 */