3 @@ -10779,7 +10779,7 @@ validate_arglist (const_tree callexpr, .
7 - code = va_arg (ap, enum tree_code);
8 + code = va_arg (ap, int);
14 @@ -3496,7 +3496,7 @@ emit_library_call_value_1 (int retval, r
15 for (; count < nargs; count++)
17 rtx val = va_arg (p, rtx);
18 - enum machine_mode mode = va_arg (p, enum machine_mode);
19 + enum machine_mode mode = va_arg (p, int);
21 /* We cannot convert the arg value to the mode the library wants here;
22 must do it earlier where we know the signedness of the arg. */
24 +++ b/gcc/config/avr32/avr32.c
27 + Target hooks and helper functions for AVR32.
28 + Copyright 2003,2004,2005,2006,2007,2008,2009,2010 Atmel Corporation.
30 + This file is part of GCC.
32 + This program is free software; you can redistribute it and/or modify
33 + it under the terms of the GNU General Public License as published by
34 + the Free Software Foundation; either version 2 of the License, or
35 + (at your option) any later version.
37 + This program is distributed in the hope that it will be useful,
38 + but WITHOUT ANY WARRANTY; without even the implied warranty of
39 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 + GNU General Public License for more details.
42 + You should have received a copy of the GNU General Public License
43 + along with this program; if not, write to the Free Software
44 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
48 +#include "coretypes.h"
54 +#include "hard-reg-set.h"
56 +#include "insn-config.h"
57 +#include "conditions.h"
59 +#include "insn-attr.h"
62 +#include "function.h"
69 +#include "c-pragma.h"
70 +#include "integrate.h"
72 +#include "langhooks.h"
77 +#include "target-def.h"
83 +/* Global variables. */
84 +typedef struct minipool_node Mnode;
85 +typedef struct minipool_fixup Mfix;
87 +/* Obstack for minipool constant handling. */
88 +static struct obstack minipool_obstack;
89 +static char *minipool_startobj;
90 +static rtx minipool_vector_label;
92 +/* True if we are currently building a constant table. */
93 +int making_const_table;
95 +tree fndecl_attribute_args = NULL_TREE;
98 +/* Function prototypes. */
99 +static unsigned long avr32_isr_value (tree);
100 +static unsigned long avr32_compute_func_type (void);
101 +static tree avr32_handle_isr_attribute (tree *, tree, tree, int, bool *);
102 +static tree avr32_handle_acall_attribute (tree *, tree, tree, int, bool *);
103 +static tree avr32_handle_fndecl_attribute (tree * node, tree name, tree args,
104 + int flags, bool * no_add_attrs);
105 +static void avr32_reorg (void);
106 +bool avr32_return_in_msb (tree type);
107 +bool avr32_vector_mode_supported (enum machine_mode mode);
108 +static void avr32_init_libfuncs (void);
109 +static void avr32_file_end (void);
110 +static void flashvault_decl_list_add (unsigned int vector_num, const char *name);
115 +avr32_add_gc_roots (void)
117 + gcc_obstack_init (&minipool_obstack);
118 + minipool_startobj = (char *) obstack_alloc (&minipool_obstack, 0);
122 +/* List of all known AVR32 parts */
123 +static const struct part_type_s avr32_part_types[] = {
124 + /* name, part_type, architecture type, macro */
125 + {"none", PART_TYPE_AVR32_NONE, ARCH_TYPE_AVR32_AP, "__AVR32__"},
126 + {"ap7000", PART_TYPE_AVR32_AP7000, ARCH_TYPE_AVR32_AP, "__AVR32_AP7000__"},
127 + {"ap7001", PART_TYPE_AVR32_AP7001, ARCH_TYPE_AVR32_AP, "__AVR32_AP7001__"},
128 + {"ap7002", PART_TYPE_AVR32_AP7002, ARCH_TYPE_AVR32_AP, "__AVR32_AP7002__"},
129 + {"ap7200", PART_TYPE_AVR32_AP7200, ARCH_TYPE_AVR32_AP, "__AVR32_AP7200__"},
130 + {"uc3a0128", PART_TYPE_AVR32_UC3A0128, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3A0128__"},
131 + {"uc3a0256", PART_TYPE_AVR32_UC3A0256, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3A0256__"},
132 + {"uc3a0512", PART_TYPE_AVR32_UC3A0512, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3A0512__"},
133 + {"uc3a0512es", PART_TYPE_AVR32_UC3A0512ES, ARCH_TYPE_AVR32_UCR1, "__AVR32_UC3A0512ES__"},
134 + {"uc3a1128", PART_TYPE_AVR32_UC3A1128, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3A1128__"},
135 + {"uc3a1256", PART_TYPE_AVR32_UC3A1256, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3A1256__"},
136 + {"uc3a1512", PART_TYPE_AVR32_UC3A1512, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3A1512__"},
137 + {"uc3a1512es", PART_TYPE_AVR32_UC3A1512ES, ARCH_TYPE_AVR32_UCR1, "__AVR32_UC3A1512ES__"},
138 + {"uc3a3revd", PART_TYPE_AVR32_UC3A3REVD, ARCH_TYPE_AVR32_UCR2NOMUL, "__AVR32_UC3A3256S__"},
139 + {"uc3a364", PART_TYPE_AVR32_UC3A364, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3A364__"},
140 + {"uc3a364s", PART_TYPE_AVR32_UC3A364S, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3A364S__"},
141 + {"uc3a3128", PART_TYPE_AVR32_UC3A3128, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3A3128__"},
142 + {"uc3a3128s", PART_TYPE_AVR32_UC3A3128S, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3A3128S__"},
143 + {"uc3a3256", PART_TYPE_AVR32_UC3A3256, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3A3256__"},
144 + {"uc3a3256s", PART_TYPE_AVR32_UC3A3256S, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3A3256S__"},
145 + {"uc3b064", PART_TYPE_AVR32_UC3B064, ARCH_TYPE_AVR32_UCR1, "__AVR32_UC3B064__"},
146 + {"uc3b0128", PART_TYPE_AVR32_UC3B0128, ARCH_TYPE_AVR32_UCR1, "__AVR32_UC3B0128__"},
147 + {"uc3b0256", PART_TYPE_AVR32_UC3B0256, ARCH_TYPE_AVR32_UCR1, "__AVR32_UC3B0256__"},
148 + {"uc3b0256es", PART_TYPE_AVR32_UC3B0256ES, ARCH_TYPE_AVR32_UCR1, "__AVR32_UC3B0256ES__"},
149 + {"uc3b0512", PART_TYPE_AVR32_UC3B0512, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3B0512__"},
150 + {"uc3b0512revc", PART_TYPE_AVR32_UC3B0512REVC, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3B0512REVC__"},
151 + {"uc3b164", PART_TYPE_AVR32_UC3B164, ARCH_TYPE_AVR32_UCR1, "__AVR32_UC3B164__"},
152 + {"uc3b1128", PART_TYPE_AVR32_UC3B1128, ARCH_TYPE_AVR32_UCR1, "__AVR32_UC3B1128__"},
153 + {"uc3b1256", PART_TYPE_AVR32_UC3B1256, ARCH_TYPE_AVR32_UCR1, "__AVR32_UC3B1256__"},
154 + {"uc3b1256es", PART_TYPE_AVR32_UC3B1256ES, ARCH_TYPE_AVR32_UCR1, "__AVR32_UC3B1256ES__"},
155 + {"uc3b1512", PART_TYPE_AVR32_UC3B1512, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3B1512__"},
156 + {"uc3b1512revc", PART_TYPE_AVR32_UC3B1512REVC, ARCH_TYPE_AVR32_UCR2, "__AVR32_UC3B1512REVC__"},
157 + {"uc3c0512crevc", PART_TYPE_AVR32_UC3C0512CREVC, ARCH_TYPE_AVR32_UCR3, "__AVR32_UC3C0512CREVC__"},
158 + {"uc3c1512crevc", PART_TYPE_AVR32_UC3C1512CREVC, ARCH_TYPE_AVR32_UCR3, "__AVR32_UC3C1512CREVC__"},
159 + {"uc3c2512crevc", PART_TYPE_AVR32_UC3C2512CREVC, ARCH_TYPE_AVR32_UCR3, "__AVR32_UC3C2512CREVC__"},
160 + {"uc3l0256", PART_TYPE_AVR32_UC3L0256, ARCH_TYPE_AVR32_UCR3, "__AVR32_UC3L0256__"},
161 + {"uc3l0128", PART_TYPE_AVR32_UC3L0128, ARCH_TYPE_AVR32_UCR3, "__AVR32_UC3L0128__"},
162 + {"uc3l064", PART_TYPE_AVR32_UC3L064, ARCH_TYPE_AVR32_UCR3, "__AVR32_UC3L064__"},
163 + {"uc3l032", PART_TYPE_AVR32_UC3L032, ARCH_TYPE_AVR32_UCR3, "__AVR32_UC3L032__"},
164 + {"uc3l016", PART_TYPE_AVR32_UC3L016, ARCH_TYPE_AVR32_UCR3, "__AVR32_UC3L016__"},
165 + {"uc3l064revb", PART_TYPE_AVR32_UC3L064, ARCH_TYPE_AVR32_UCR3, "__AVR32_UC3L064REVB__"},
166 + {"uc3c064c", PART_TYPE_AVR32_UC3C064C, ARCH_TYPE_AVR32_UCR3FP, "__AVR32_UC3C064C__"},
167 + {"uc3c0128c", PART_TYPE_AVR32_UC3C0128C, ARCH_TYPE_AVR32_UCR3FP, "__AVR32_UC3C0128C__"},
168 + {"uc3c0256c", PART_TYPE_AVR32_UC3C0256C, ARCH_TYPE_AVR32_UCR3FP, "__AVR32_UC3C0256C__"},
169 + {"uc3c0512c", PART_TYPE_AVR32_UC3C0512C, ARCH_TYPE_AVR32_UCR3FP, "__AVR32_UC3C0512C__"},
170 + {"uc3c164c", PART_TYPE_AVR32_UC3C164C, ARCH_TYPE_AVR32_UCR3FP, "__AVR32_UC3C164C__"},
171 + {"uc3c1128c", PART_TYPE_AVR32_UC3C1128C, ARCH_TYPE_AVR32_UCR3FP, "__AVR32_UC3C1128C__"},
172 + {"uc3c1256c", PART_TYPE_AVR32_UC3C1256C, ARCH_TYPE_AVR32_UCR3FP, "__AVR32_UC3C1256C__"},
173 + {"uc3c1512c", PART_TYPE_AVR32_UC3C1512C, ARCH_TYPE_AVR32_UCR3FP, "__AVR32_UC3C1512C__"},
174 + {"uc3c264c", PART_TYPE_AVR32_UC3C264C, ARCH_TYPE_AVR32_UCR3FP, "__AVR32_UC3C264C__"},
175 + {"uc3c2128c", PART_TYPE_AVR32_UC3C2128C, ARCH_TYPE_AVR32_UCR3FP, "__AVR32_UC3C2128C__"},
176 + {"uc3c2256c", PART_TYPE_AVR32_UC3C2256C, ARCH_TYPE_AVR32_UCR3FP, "__AVR32_UC3C2256C__"},
177 + {"uc3c2512c", PART_TYPE_AVR32_UC3C2512C, ARCH_TYPE_AVR32_UCR3FP, "__AVR32_UC3C2512C__"},
178 + {"mxt768e", PART_TYPE_AVR32_MXT768E, ARCH_TYPE_AVR32_UCR3, "__AVR32_MXT768E__"},
182 +/* List of all known AVR32 architectures */
183 +static const struct arch_type_s avr32_arch_types[] = {
184 + /* name, architecture type, microarchitecture type, feature flags, macro */
185 + {"ap", ARCH_TYPE_AVR32_AP, UARCH_TYPE_AVR32B,
186 + (FLAG_AVR32_HAS_DSP
187 + | FLAG_AVR32_HAS_SIMD
188 + | FLAG_AVR32_HAS_UNALIGNED_WORD
189 + | FLAG_AVR32_HAS_BRANCH_PRED | FLAG_AVR32_HAS_RETURN_STACK
190 + | FLAG_AVR32_HAS_CACHES),
192 + {"ucr1", ARCH_TYPE_AVR32_UCR1, UARCH_TYPE_AVR32A,
193 + (FLAG_AVR32_HAS_DSP | FLAG_AVR32_HAS_RMW),
195 + {"ucr2", ARCH_TYPE_AVR32_UCR2, UARCH_TYPE_AVR32A,
196 + (FLAG_AVR32_HAS_DSP | FLAG_AVR32_HAS_RMW
197 + | FLAG_AVR32_HAS_V2_INSNS),
199 + {"ucr2nomul", ARCH_TYPE_AVR32_UCR2NOMUL, UARCH_TYPE_AVR32A,
200 + (FLAG_AVR32_HAS_DSP | FLAG_AVR32_HAS_RMW
201 + | FLAG_AVR32_HAS_V2_INSNS | FLAG_AVR32_HAS_NO_MUL_INSNS),
203 + {"ucr3", ARCH_TYPE_AVR32_UCR3, UARCH_TYPE_AVR32A,
204 + (FLAG_AVR32_HAS_DSP | FLAG_AVR32_HAS_RMW
205 + | FLAG_AVR32_HAS_V2_INSNS),
207 + {"ucr3fp", ARCH_TYPE_AVR32_UCR3FP, UARCH_TYPE_AVR32A,
208 + (FLAG_AVR32_HAS_DSP | FLAG_AVR32_HAS_RMW | FLAG_AVR32_HAS_FPU
209 + | FLAG_AVR32_HAS_V2_INSNS),
211 + {NULL, 0, 0, 0, NULL}
214 +/* Default arch name */
215 +const char *avr32_arch_name = "none";
216 +const char *avr32_part_name = "none";
218 +const struct part_type_s *avr32_part;
219 +const struct arch_type_s *avr32_arch;
222 +/* FIXME: needs to use GC. */
223 +struct flashvault_decl_list
225 + struct flashvault_decl_list *next;
226 + unsigned int vector_num;
230 +static struct flashvault_decl_list *flashvault_decl_list_head = NULL;
233 +/* Set default target_flags. */
234 +#undef TARGET_DEFAULT_TARGET_FLAGS
235 +#define TARGET_DEFAULT_TARGET_FLAGS \
236 + (MASK_HAS_ASM_ADDR_PSEUDOS | MASK_MD_REORG_OPTIMIZATION | MASK_COND_EXEC_BEFORE_RELOAD)
239 +avr32_optimization_options (int level, int size)
241 + if (AVR32_ALWAYS_PIC)
244 + /* Enable section anchors if optimization is enabled. */
245 + if (level > 0 || size)
246 + flag_section_anchors = 1;
250 +/* Override command line options */
252 +avr32_override_options (void)
254 + const struct part_type_s *part;
255 + const struct arch_type_s *arch;
257 + /*Add backward compability*/
258 + if (strcmp ("uc", avr32_arch_name)== 0)
260 + fprintf (stderr, "Warning: Deprecated arch `%s' specified. "
261 + "Please use '-march=ucr1' instead. "
262 + "Converting to arch 'ucr1'\n",
264 + avr32_arch_name="ucr1";
267 + /* Check if arch type is set. */
268 + for (arch = avr32_arch_types; arch->name; arch++)
270 + if (strcmp (arch->name, avr32_arch_name) == 0)
275 + if (!arch->name && strcmp("none", avr32_arch_name) != 0)
277 + fprintf (stderr, "Unknown arch `%s' specified\n"
278 + "Known arch names:\n"
279 + "\tuc (deprecated)\n",
281 + for (arch = avr32_arch_types; arch->name; arch++)
282 + fprintf (stderr, "\t%s\n", arch->name);
283 + avr32_arch = &avr32_arch_types[ARCH_TYPE_AVR32_AP];
286 + /* Check if part type is set. */
287 + for (part = avr32_part_types; part->name; part++)
288 + if (strcmp (part->name, avr32_part_name) == 0)
294 + fprintf (stderr, "Unknown part `%s' specified\nKnown part names:\n",
296 + for (part = avr32_part_types; part->name; part++)
298 + if (strcmp("none", part->name) != 0)
299 + fprintf (stderr, "\t%s\n", part->name);
301 + /* Set default to NONE*/
302 + avr32_part = &avr32_part_types[PART_TYPE_AVR32_NONE];
305 + /* NB! option -march= overrides option -mpart
306 + * if both are used at the same time */
308 + avr32_arch = &avr32_arch_types[avr32_part->arch_type];
310 + /* If optimization level is two or greater, then align start of loops to a
311 + word boundary since this will allow folding the first insn of the loop.
312 + Do this only for targets supporting branch prediction. */
313 + if (optimize >= 2 && TARGET_BRANCH_PRED)
317 + /* Enable fast-float library if unsafe math optimizations
319 + if (flag_unsafe_math_optimizations)
320 + target_flags |= MASK_FAST_FLOAT;
322 + /* Check if we should set avr32_imm_in_const_pool
323 + based on if caches are present or not. */
324 + if ( avr32_imm_in_const_pool == -1 )
326 + if ( TARGET_CACHES )
327 + avr32_imm_in_const_pool = 1;
329 + avr32_imm_in_const_pool = 0;
334 + avr32_add_gc_roots ();
339 +If defined, a function that outputs the assembler code for entry to a
340 +function. The prologue is responsible for setting up the stack frame,
341 +initializing the frame pointer register, saving registers that must be
342 +saved, and allocating size additional bytes of storage for the
343 +local variables. size is an integer. file is a stdio
344 +stream to which the assembler code should be output.
346 +The label for the beginning of the function need not be output by this
347 +macro. That has already been done when the macro is run.
349 +To determine which registers to save, the macro can refer to the array
350 +regs_ever_live: element r is nonzero if hard register
351 +r is used anywhere within the function. This implies the function
352 +prologue should save register r, provided it is not one of the
353 +call-used registers. (TARGET_ASM_FUNCTION_EPILOGUE must likewise use
356 +On machines that have ``register windows'', the function entry code does
357 +not save on the stack the registers that are in the windows, even if
358 +they are supposed to be preserved by function calls; instead it takes
359 +appropriate steps to ``push'' the register stack, if any non-call-used
360 +registers are used in the function.
362 +On machines where functions may or may not have frame-pointers, the
363 +function entry code must vary accordingly; it must set up the frame
364 +pointer if one is wanted, and not otherwise. To determine whether a
365 +frame pointer is in wanted, the macro can refer to the variable
366 +frame_pointer_needed. The variable's value will be 1 at run
367 +time in a function that needs a frame pointer. (see Elimination).
369 +The function entry code is responsible for allocating any stack space
370 +required for the function. This stack space consists of the regions
371 +listed below. In most cases, these regions are allocated in the
372 +order listed, with the last listed region closest to the top of the
373 +stack (the lowest address if STACK_GROWS_DOWNWARD is defined, and
374 +the highest address if it is not defined). You can use a different order
375 +for a machine if doing so is more convenient or required for
376 +compatibility reasons. Except in cases where required by standard
377 +or by a debugger, there is no reason why the stack layout used by GCC
378 +need agree with that used by other compilers for a machine.
381 +#undef TARGET_ASM_FUNCTION_PROLOGUE
382 +#define TARGET_ASM_FUNCTION_PROLOGUE avr32_target_asm_function_prologue
384 +#undef TARGET_ASM_FILE_END
385 +#define TARGET_ASM_FILE_END avr32_file_end
387 +#undef TARGET_DEFAULT_SHORT_ENUMS
388 +#define TARGET_DEFAULT_SHORT_ENUMS hook_bool_void_false
390 +#undef TARGET_PROMOTE_FUNCTION_ARGS
391 +#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true
393 +#undef TARGET_PROMOTE_FUNCTION_RETURN
394 +#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
396 +#undef TARGET_PROMOTE_PROTOTYPES
397 +#define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true
399 +#undef TARGET_MUST_PASS_IN_STACK
400 +#define TARGET_MUST_PASS_IN_STACK avr32_must_pass_in_stack
402 +#undef TARGET_PASS_BY_REFERENCE
403 +#define TARGET_PASS_BY_REFERENCE avr32_pass_by_reference
405 +#undef TARGET_STRICT_ARGUMENT_NAMING
406 +#define TARGET_STRICT_ARGUMENT_NAMING avr32_strict_argument_naming
408 +#undef TARGET_VECTOR_MODE_SUPPORTED_P
409 +#define TARGET_VECTOR_MODE_SUPPORTED_P avr32_vector_mode_supported
411 +#undef TARGET_RETURN_IN_MEMORY
412 +#define TARGET_RETURN_IN_MEMORY avr32_return_in_memory
414 +#undef TARGET_RETURN_IN_MSB
415 +#define TARGET_RETURN_IN_MSB avr32_return_in_msb
417 +#undef TARGET_ENCODE_SECTION_INFO
418 +#define TARGET_ENCODE_SECTION_INFO avr32_encode_section_info
420 +#undef TARGET_ARG_PARTIAL_BYTES
421 +#define TARGET_ARG_PARTIAL_BYTES avr32_arg_partial_bytes
423 +#undef TARGET_STRIP_NAME_ENCODING
424 +#define TARGET_STRIP_NAME_ENCODING avr32_strip_name_encoding
426 +#define streq(string1, string2) (strcmp (string1, string2) == 0)
428 +#undef TARGET_NARROW_VOLATILE_BITFIELD
429 +#define TARGET_NARROW_VOLATILE_BITFIELD hook_bool_void_false
431 +#undef TARGET_ATTRIBUTE_TABLE
432 +#define TARGET_ATTRIBUTE_TABLE avr32_attribute_table
434 +#undef TARGET_COMP_TYPE_ATTRIBUTES
435 +#define TARGET_COMP_TYPE_ATTRIBUTES avr32_comp_type_attributes
438 +#undef TARGET_RTX_COSTS
439 +#define TARGET_RTX_COSTS avr32_rtx_costs
441 +#undef TARGET_CANNOT_FORCE_CONST_MEM
442 +#define TARGET_CANNOT_FORCE_CONST_MEM avr32_cannot_force_const_mem
444 +#undef TARGET_ASM_INTEGER
445 +#define TARGET_ASM_INTEGER avr32_assemble_integer
447 +#undef TARGET_FUNCTION_VALUE
448 +#define TARGET_FUNCTION_VALUE avr32_function_value
450 +#undef TARGET_MIN_ANCHOR_OFFSET
451 +#define TARGET_MIN_ANCHOR_OFFSET (0)
453 +#undef TARGET_MAX_ANCHOR_OFFSET
454 +#define TARGET_MAX_ANCHOR_OFFSET ((1 << 15) - 1)
455 +#undef TARGET_SECONDARY_RELOAD
456 +#define TARGET_SECONDARY_RELOAD avr32_secondary_reload
459 +avr32_secondary_reload (bool in_p, rtx x, enum reg_class class,
460 + enum machine_mode mode, secondary_reload_info *sri)
463 + if ( avr32_rmw_memory_operand (x, mode) )
466 + sri->icode = CODE_FOR_reload_out_rmw_memory_operand;
468 + sri->icode = CODE_FOR_reload_in_rmw_memory_operand;
474 + * Switches to the appropriate section for output of constant pool
475 + * entry x in mode. You can assume that x is some kind of constant in
476 + * RTL. The argument mode is redundant except in the case of a
477 + * const_int rtx. Select the section by calling readonly_data_ section
478 + * or one of the alternatives for other sections. align is the
479 + * constant alignment in bits.
481 + * The default version of this function takes care of putting symbolic
482 + * constants in flag_ pic mode in data_section and everything else in
483 + * readonly_data_section.
485 +//#undef TARGET_ASM_SELECT_RTX_SECTION
486 +//#define TARGET_ASM_SELECT_RTX_SECTION avr32_select_rtx_section
490 + * If non-null, this hook performs a target-specific pass over the
491 + * instruction stream. The compiler will run it at all optimization
492 + * levels, just before the point at which it normally does
493 + * delayed-branch scheduling.
495 + * The exact purpose of the hook varies from target to target. Some
496 + * use it to do transformations that are necessary for correctness,
497 + * such as laying out in-function constant pools or avoiding hardware
498 + * hazards. Others use it as an opportunity to do some
499 + * machine-dependent optimizations.
501 + * You need not implement the hook if it has nothing to do. The
502 + * default definition is null.
504 +#undef TARGET_MACHINE_DEPENDENT_REORG
505 +#define TARGET_MACHINE_DEPENDENT_REORG avr32_reorg
507 +/* Target hook for assembling integer objects.
508 + Need to handle integer vectors */
510 +avr32_assemble_integer (rtx x, unsigned int size, int aligned_p)
512 + if (avr32_vector_mode_supported (GET_MODE (x)))
516 + if (GET_CODE (x) != CONST_VECTOR)
519 + units = CONST_VECTOR_NUNITS (x);
521 + switch (GET_MODE (x))
533 + for (i = 0; i < units; i++)
537 + elt = CONST_VECTOR_ELT (x, i);
538 + assemble_integer (elt, size, i == 0 ? 32 : size * BITS_PER_UNIT, 1);
544 + return default_assemble_integer (x, size, aligned_p);
549 + * This target hook describes the relative costs of RTL expressions.
551 + * The cost may depend on the precise form of the expression, which is
552 + * available for examination in x, and the rtx code of the expression
553 + * in which it is contained, found in outer_code. code is the
554 + * expression code--redundant, since it can be obtained with GET_CODE
557 + * In implementing this hook, you can use the construct COSTS_N_INSNS
558 + * (n) to specify a cost equal to n fast instructions.
560 + * On entry to the hook, *total contains a default estimate for the
561 + * cost of the expression. The hook should modify this value as
562 + * necessary. Traditionally, the default costs are COSTS_N_INSNS (5)
563 + * for multiplications, COSTS_N_INSNS (7) for division and modulus
564 + * operations, and COSTS_N_INSNS (1) for all other operations.
566 + * When optimizing for code size, i.e. when optimize_size is non-zero,
567 + * this target hook should be used to estimate the relative size cost
568 + * of an expression, again relative to COSTS_N_INSNS.
570 + * The hook returns true when all subexpressions of x have been
571 + * processed, and false when rtx_cost should recurse.
574 +/* Worker routine for avr32_rtx_costs. */
576 +avr32_rtx_costs_1 (rtx x, enum rtx_code code ATTRIBUTE_UNUSED,
577 + enum rtx_code outer ATTRIBUTE_UNUSED)
579 + enum machine_mode mode = GET_MODE (x);
581 + switch (GET_CODE (x))
584 + /* Using pre decrement / post increment memory operations on the
585 + avr32_uc architecture means that two writebacks must be performed
586 + and hence two cycles are needed. */
588 + && GET_MODE_SIZE (mode) <= 2 * UNITS_PER_WORD
590 + && (GET_CODE (XEXP (x, 0)) == PRE_DEC
591 + || GET_CODE (XEXP (x, 0)) == POST_INC))
592 + return COSTS_N_INSNS (5);
594 + /* Memory costs quite a lot for the first word, but subsequent words
595 + load at the equivalent of a single insn each. */
596 + if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
597 + return COSTS_N_INSNS (3 + (GET_MODE_SIZE (mode) / UNITS_PER_WORD));
599 + return COSTS_N_INSNS (4);
602 + /* These are valid for the pseudo insns: lda.w and call which operates
603 + on direct addresses. We assume that the cost of a lda.w is the same
604 + as the cost of a ld.w insn. */
605 + return (outer == SET) ? COSTS_N_INSNS (4) : COSTS_N_INSNS (1);
610 + return optimize_size ? COSTS_N_INSNS (1) : COSTS_N_INSNS (16);
614 + if (mode == TImode)
615 + return COSTS_N_INSNS (100);
617 + if (mode == DImode)
618 + return COSTS_N_INSNS (10);
619 + return COSTS_N_INSNS (4);
624 + if (mode == TImode)
625 + return COSTS_N_INSNS (10);
627 + if (mode == DImode)
628 + return COSTS_N_INSNS (4);
629 + return COSTS_N_INSNS (1);
635 + if (GET_MODE_CLASS (mode) == MODE_FLOAT)
636 + return COSTS_N_INSNS (100);
638 + if (mode == TImode)
639 + return COSTS_N_INSNS (50);
641 + if (mode == DImode)
642 + return COSTS_N_INSNS (2);
643 + return COSTS_N_INSNS (1);
647 + if (GET_MODE_CLASS (mode) == MODE_FLOAT)
648 + return COSTS_N_INSNS (300);
650 + if (mode == TImode)
651 + return COSTS_N_INSNS (16);
653 + if (mode == DImode)
654 + return COSTS_N_INSNS (4);
656 + if (mode == HImode)
657 + return COSTS_N_INSNS (2);
659 + return COSTS_N_INSNS (3);
662 + if (GET_CODE (XEXP (x, 1)) == PC || GET_CODE (XEXP (x, 2)) == PC)
663 + return COSTS_N_INSNS (4);
664 + return COSTS_N_INSNS (1);
667 + /* Sign/Zero extensions of registers cost quite much since these
668 + instrcutions only take one register operand which means that gcc
669 + often must insert some move instrcutions */
670 + if (mode == QImode || mode == HImode)
671 + return (COSTS_N_INSNS (GET_CODE (XEXP (x, 0)) == MEM ? 0 : 1));
672 + return COSTS_N_INSNS (4);
674 + /* divmod operations */
675 + if (XINT (x, 1) == UNSPEC_UDIVMODSI4_INTERNAL
676 + || XINT (x, 1) == UNSPEC_DIVMODSI4_INTERNAL)
678 + return optimize_size ? COSTS_N_INSNS (1) : COSTS_N_INSNS (16);
682 + return COSTS_N_INSNS (1);
688 +avr32_rtx_costs (rtx x, int code, int outer_code, int *total)
690 + *total = avr32_rtx_costs_1 (x, code, outer_code);
696 +avr32_cannot_force_const_mem (rtx x ATTRIBUTE_UNUSED)
698 + /* Do not want symbols in the constant pool when compiling pic or if using
699 + address pseudo instructions. */
700 + return ((flag_pic || TARGET_HAS_ASM_ADDR_PSEUDOS)
701 + && avr32_find_symbol (x) != NULL_RTX);
705 +/* Table of machine attributes. */
706 +const struct attribute_spec avr32_attribute_table[] = {
707 + /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
708 + /* Interrupt Service Routines have special prologue and epilogue
710 + {"isr", 0, 1, false, false, false, avr32_handle_isr_attribute},
711 + {"interrupt", 0, 1, false, false, false, avr32_handle_isr_attribute},
712 + {"acall", 0, 1, false, true, true, avr32_handle_acall_attribute},
713 + {"naked", 0, 0, true, false, false, avr32_handle_fndecl_attribute},
714 + {"rmw_addressable", 0, 0, true, false, false, NULL},
715 + {"flashvault", 0, 1, true, false, false, avr32_handle_fndecl_attribute},
716 + {"flashvault_impl", 0, 1, true, false, false, avr32_handle_fndecl_attribute},
717 + {NULL, 0, 0, false, false, false, NULL}
723 + const char *const arg;
724 + const unsigned long return_value;
729 +static const isr_attribute_arg isr_attribute_args[] = {
730 + {"FULL", AVR32_FT_ISR_FULL},
731 + {"full", AVR32_FT_ISR_FULL},
732 + {"HALF", AVR32_FT_ISR_HALF},
733 + {"half", AVR32_FT_ISR_HALF},
734 + {"NONE", AVR32_FT_ISR_NONE},
735 + {"none", AVR32_FT_ISR_NONE},
736 + {"UNDEF", AVR32_FT_ISR_NONE},
737 + {"undef", AVR32_FT_ISR_NONE},
738 + {"SWI", AVR32_FT_ISR_NONE},
739 + {"swi", AVR32_FT_ISR_NONE},
740 + {NULL, AVR32_FT_ISR_NONE}
744 +/* Returns the (interrupt) function type of the current
745 + function, or AVR32_FT_UNKNOWN if the type cannot be determined. */
746 +static unsigned long
747 +avr32_isr_value (tree argument)
749 + const isr_attribute_arg *ptr;
752 + /* No argument - default to ISR_NONE. */
753 + if (argument == NULL_TREE)
754 + return AVR32_FT_ISR_NONE;
756 + /* Get the value of the argument. */
757 + if (TREE_VALUE (argument) == NULL_TREE
758 + || TREE_CODE (TREE_VALUE (argument)) != STRING_CST)
759 + return AVR32_FT_UNKNOWN;
761 + arg = TREE_STRING_POINTER (TREE_VALUE (argument));
763 + /* Check it against the list of known arguments. */
764 + for (ptr = isr_attribute_args; ptr->arg != NULL; ptr++)
765 + if (streq (arg, ptr->arg))
766 + return ptr->return_value;
768 + /* An unrecognized interrupt type. */
769 + return AVR32_FT_UNKNOWN;
774 +These hooks specify assembly directives for creating certain kinds
775 +of integer object. The TARGET_ASM_BYTE_OP directive creates a
776 +byte-sized object, the TARGET_ASM_ALIGNED_HI_OP one creates an
777 +aligned two-byte object, and so on. Any of the hooks may be
778 +NULL, indicating that no suitable directive is available.
780 +The compiler will print these strings at the start of a new line,
781 +followed immediately by the object's initial value. In most cases,
782 +the string should contain a tab, a pseudo-op, and then another tab.
784 +#undef TARGET_ASM_BYTE_OP
785 +#define TARGET_ASM_BYTE_OP "\t.byte\t"
786 +#undef TARGET_ASM_ALIGNED_HI_OP
787 +#define TARGET_ASM_ALIGNED_HI_OP "\t.align 1\n\t.short\t"
788 +#undef TARGET_ASM_ALIGNED_SI_OP
789 +#define TARGET_ASM_ALIGNED_SI_OP "\t.align 2\n\t.int\t"
790 +#undef TARGET_ASM_ALIGNED_DI_OP
791 +#define TARGET_ASM_ALIGNED_DI_OP NULL
792 +#undef TARGET_ASM_ALIGNED_TI_OP
793 +#define TARGET_ASM_ALIGNED_TI_OP NULL
794 +#undef TARGET_ASM_UNALIGNED_HI_OP
795 +#define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
796 +#undef TARGET_ASM_UNALIGNED_SI_OP
797 +#define TARGET_ASM_UNALIGNED_SI_OP "\t.int\t"
798 +#undef TARGET_ASM_UNALIGNED_DI_OP
799 +#define TARGET_ASM_UNALIGNED_DI_OP NULL
800 +#undef TARGET_ASM_UNALIGNED_TI_OP
801 +#define TARGET_ASM_UNALIGNED_TI_OP NULL
803 +#undef TARGET_ASM_OUTPUT_MI_THUNK
804 +#define TARGET_ASM_OUTPUT_MI_THUNK avr32_output_mi_thunk
806 +#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
807 +#define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true
811 +avr32_output_mi_thunk (FILE * file,
812 + tree thunk ATTRIBUTE_UNUSED,
813 + HOST_WIDE_INT delta,
814 + HOST_WIDE_INT vcall_offset, tree function)
816 + int mi_delta = delta;
818 + (aggregate_value_p (TREE_TYPE (TREE_TYPE (function)), function) ?
819 + INTERNAL_REGNUM (11) : INTERNAL_REGNUM (12));
822 + if (!avr32_const_ok_for_constraint_p (mi_delta, 'I', "Is21")
825 + fputs ("\tpushm\tlr\n", file);
831 + if (avr32_const_ok_for_constraint_p (mi_delta, 'I', "Is21"))
833 + fprintf (file, "\tsub\t%s, %d\n", reg_names[this_regno], -mi_delta);
837 + /* Immediate is larger than k21 we must make us a temp register by
838 + pushing a register to the stack. */
839 + fprintf (file, "\tmov\tlr, lo(%d)\n", mi_delta);
840 + fprintf (file, "\torh\tlr, hi(%d)\n", mi_delta);
841 + fprintf (file, "\tadd\t%s, lr\n", reg_names[this_regno]);
846 + if (vcall_offset != 0)
848 + fprintf (file, "\tld.w\tlr, %s[0]\n", reg_names[this_regno]);
849 + fprintf (file, "\tld.w\tlr, lr[%i]\n", (int) vcall_offset);
850 + fprintf (file, "\tadd\t%s, lr\n", reg_names[this_regno]);
854 + if (!avr32_const_ok_for_constraint_p (mi_delta, 'I', "Is21")
857 + fputs ("\tpopm\tlr\n", file);
860 + /* Jump to the function. We assume that we can use an rjmp since the
861 + function to jump to is local and probably not too far away from
862 + the thunk. If this assumption proves to be wrong we could implement
863 + this jump by calculating the offset between the jump source and destination
864 + and put this in the constant pool and then perform an add to pc.
865 + This would also be legitimate PIC code. But for now we hope that an rjmp
866 + will be sufficient...
868 + fputs ("\trjmp\t", file);
869 + assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
870 + fputc ('\n', file);
874 +/* Implements target hook vector_mode_supported. */
876 +avr32_vector_mode_supported (enum machine_mode mode)
878 + if ((mode == V2HImode) || (mode == V4QImode))
885 +#undef TARGET_INIT_LIBFUNCS
886 +#define TARGET_INIT_LIBFUNCS avr32_init_libfuncs
888 +#undef TARGET_INIT_BUILTINS
889 +#define TARGET_INIT_BUILTINS avr32_init_builtins
891 +#undef TARGET_EXPAND_BUILTIN
892 +#define TARGET_EXPAND_BUILTIN avr32_expand_builtin
894 +tree int_ftype_int, int_ftype_void, short_ftype_short, void_ftype_int_int,
895 + void_ftype_ptr_int;
896 +tree void_ftype_int, void_ftype_ulong, void_ftype_void, int_ftype_ptr_int;
897 +tree short_ftype_short, int_ftype_int_short, int_ftype_short_short,
898 + short_ftype_short_short;
899 +tree int_ftype_int_int, longlong_ftype_int_short, longlong_ftype_short_short;
900 +tree void_ftype_int_int_int_int_int, void_ftype_int_int_int;
901 +tree longlong_ftype_int_int, void_ftype_int_int_longlong;
902 +tree int_ftype_int_int_int, longlong_ftype_longlong_int_short;
903 +tree longlong_ftype_longlong_short_short, int_ftype_int_short_short;
905 +#define def_builtin(NAME, TYPE, CODE) \
906 + add_builtin_function ((NAME), (TYPE), (CODE), \
907 + BUILT_IN_MD, NULL, NULL_TREE)
909 +#define def_mbuiltin(MASK, NAME, TYPE, CODE) \
913 + add_builtin_function ((NAME), (TYPE), (CODE), \
914 + BUILT_IN_MD, NULL, NULL_TREE); \
918 +struct builtin_description
920 + const unsigned int mask;
921 + const enum insn_code icode;
922 + const char *const name;
924 + const enum rtx_code comparison;
925 + const unsigned int flag;
929 +static const struct builtin_description bdesc_2arg[] = {
931 +#define DSP_BUILTIN(code, builtin, ftype) \
932 + { 1, CODE_FOR_##code, "__builtin_" #code , \
933 + AVR32_BUILTIN_##builtin, 0, 0, ftype }
935 + DSP_BUILTIN (mulsathh_h, MULSATHH_H, &short_ftype_short_short),
936 + DSP_BUILTIN (mulsathh_w, MULSATHH_W, &int_ftype_short_short),
937 + DSP_BUILTIN (mulsatrndhh_h, MULSATRNDHH_H, &short_ftype_short_short),
938 + DSP_BUILTIN (mulsatrndwh_w, MULSATRNDWH_W, &int_ftype_int_short),
939 + DSP_BUILTIN (mulsatwh_w, MULSATWH_W, &int_ftype_int_short),
940 + DSP_BUILTIN (satadd_h, SATADD_H, &short_ftype_short_short),
941 + DSP_BUILTIN (satsub_h, SATSUB_H, &short_ftype_short_short),
942 + DSP_BUILTIN (satadd_w, SATADD_W, &int_ftype_int_int),
943 + DSP_BUILTIN (satsub_w, SATSUB_W, &int_ftype_int_int),
944 + DSP_BUILTIN (mulwh_d, MULWH_D, &longlong_ftype_int_short),
945 + DSP_BUILTIN (mulnwh_d, MULNWH_D, &longlong_ftype_int_short)
950 +avr32_init_builtins (void)
953 + const struct builtin_description *d;
954 + tree endlink = void_list_node;
955 + tree int_endlink = tree_cons (NULL_TREE, integer_type_node, endlink);
956 + tree longlong_endlink =
957 + tree_cons (NULL_TREE, long_long_integer_type_node, endlink);
958 + tree short_endlink =
959 + tree_cons (NULL_TREE, short_integer_type_node, endlink);
960 + tree void_endlink = tree_cons (NULL_TREE, void_type_node, endlink);
962 + /* int func (int) */
963 + int_ftype_int = build_function_type (integer_type_node, int_endlink);
965 + /* short func (short) */
967 + = build_function_type (short_integer_type_node, short_endlink);
969 + /* short func (short, short) */
970 + short_ftype_short_short
971 + = build_function_type (short_integer_type_node,
972 + tree_cons (NULL_TREE, short_integer_type_node,
975 + /* long long func (long long, short, short) */
976 + longlong_ftype_longlong_short_short
977 + = build_function_type (long_long_integer_type_node,
978 + tree_cons (NULL_TREE, long_long_integer_type_node,
979 + tree_cons (NULL_TREE,
980 + short_integer_type_node,
983 + /* long long func (short, short) */
984 + longlong_ftype_short_short
985 + = build_function_type (long_long_integer_type_node,
986 + tree_cons (NULL_TREE, short_integer_type_node,
989 + /* int func (int, int) */
991 + = build_function_type (integer_type_node,
992 + tree_cons (NULL_TREE, integer_type_node,
995 + /* long long func (int, int) */
996 + longlong_ftype_int_int
997 + = build_function_type (long_long_integer_type_node,
998 + tree_cons (NULL_TREE, integer_type_node,
1001 + /* long long int func (long long, int, short) */
1002 + longlong_ftype_longlong_int_short
1003 + = build_function_type (long_long_integer_type_node,
1004 + tree_cons (NULL_TREE, long_long_integer_type_node,
1005 + tree_cons (NULL_TREE, integer_type_node,
1008 + /* long long int func (int, short) */
1009 + longlong_ftype_int_short
1010 + = build_function_type (long_long_integer_type_node,
1011 + tree_cons (NULL_TREE, integer_type_node,
1014 + /* int func (int, short, short) */
1015 + int_ftype_int_short_short
1016 + = build_function_type (integer_type_node,
1017 + tree_cons (NULL_TREE, integer_type_node,
1018 + tree_cons (NULL_TREE,
1019 + short_integer_type_node,
1022 + /* int func (short, short) */
1023 + int_ftype_short_short
1024 + = build_function_type (integer_type_node,
1025 + tree_cons (NULL_TREE, short_integer_type_node,
1028 + /* int func (int, short) */
1029 + int_ftype_int_short
1030 + = build_function_type (integer_type_node,
1031 + tree_cons (NULL_TREE, integer_type_node,
1034 + /* void func (int, int) */
1035 + void_ftype_int_int
1036 + = build_function_type (void_type_node,
1037 + tree_cons (NULL_TREE, integer_type_node,
1040 + /* void func (int, int, int) */
1041 + void_ftype_int_int_int
1042 + = build_function_type (void_type_node,
1043 + tree_cons (NULL_TREE, integer_type_node,
1044 + tree_cons (NULL_TREE, integer_type_node,
1047 + /* void func (int, int, long long) */
1048 + void_ftype_int_int_longlong
1049 + = build_function_type (void_type_node,
1050 + tree_cons (NULL_TREE, integer_type_node,
1051 + tree_cons (NULL_TREE, integer_type_node,
1052 + longlong_endlink)));
1054 + /* void func (int, int, int, int, int) */
1055 + void_ftype_int_int_int_int_int
1056 + = build_function_type (void_type_node,
1057 + tree_cons (NULL_TREE, integer_type_node,
1058 + tree_cons (NULL_TREE, integer_type_node,
1059 + tree_cons (NULL_TREE,
1060 + integer_type_node,
1063 + integer_type_node,
1066 + /* void func (void *, int) */
1067 + void_ftype_ptr_int
1068 + = build_function_type (void_type_node,
1069 + tree_cons (NULL_TREE, ptr_type_node, int_endlink));
1071 + /* void func (int) */
1072 + void_ftype_int = build_function_type (void_type_node, int_endlink);
1074 + /* void func (ulong) */
1075 + void_ftype_ulong = build_function_type_list (void_type_node,
1076 + long_unsigned_type_node, NULL_TREE);
1078 + /* void func (void) */
1079 + void_ftype_void = build_function_type (void_type_node, void_endlink);
1081 + /* int func (void) */
1082 + int_ftype_void = build_function_type (integer_type_node, void_endlink);
1084 + /* int func (void *, int) */
1086 + = build_function_type (integer_type_node,
1087 + tree_cons (NULL_TREE, ptr_type_node, int_endlink));
1089 + /* int func (int, int, int) */
1090 + int_ftype_int_int_int
1091 + = build_function_type (integer_type_node,
1092 + tree_cons (NULL_TREE, integer_type_node,
1093 + tree_cons (NULL_TREE, integer_type_node,
1096 + /* Initialize avr32 builtins. */
1097 + def_builtin ("__builtin_mfsr", int_ftype_int, AVR32_BUILTIN_MFSR);
1098 + def_builtin ("__builtin_mtsr", void_ftype_int_int, AVR32_BUILTIN_MTSR);
1099 + def_builtin ("__builtin_mfdr", int_ftype_int, AVR32_BUILTIN_MFDR);
1100 + def_builtin ("__builtin_mtdr", void_ftype_int_int, AVR32_BUILTIN_MTDR);
1101 + def_builtin ("__builtin_cache", void_ftype_ptr_int, AVR32_BUILTIN_CACHE);
1102 + def_builtin ("__builtin_sync", void_ftype_int, AVR32_BUILTIN_SYNC);
1103 + def_builtin ("__builtin_ssrf", void_ftype_int, AVR32_BUILTIN_SSRF);
1104 + def_builtin ("__builtin_csrf", void_ftype_int, AVR32_BUILTIN_CSRF);
1105 + def_builtin ("__builtin_tlbr", void_ftype_void, AVR32_BUILTIN_TLBR);
1106 + def_builtin ("__builtin_tlbs", void_ftype_void, AVR32_BUILTIN_TLBS);
1107 + def_builtin ("__builtin_tlbw", void_ftype_void, AVR32_BUILTIN_TLBW);
1108 + def_builtin ("__builtin_breakpoint", void_ftype_void,
1109 + AVR32_BUILTIN_BREAKPOINT);
1110 + def_builtin ("__builtin_xchg", int_ftype_ptr_int, AVR32_BUILTIN_XCHG);
1111 + def_builtin ("__builtin_ldxi", int_ftype_ptr_int, AVR32_BUILTIN_LDXI);
1112 + def_builtin ("__builtin_bswap_16", short_ftype_short,
1113 + AVR32_BUILTIN_BSWAP16);
1114 + def_builtin ("__builtin_bswap_32", int_ftype_int, AVR32_BUILTIN_BSWAP32);
1115 + def_builtin ("__builtin_cop", void_ftype_int_int_int_int_int,
1116 + AVR32_BUILTIN_COP);
1117 + def_builtin ("__builtin_mvcr_w", int_ftype_int_int, AVR32_BUILTIN_MVCR_W);
1118 + def_builtin ("__builtin_mvrc_w", void_ftype_int_int_int,
1119 + AVR32_BUILTIN_MVRC_W);
1120 + def_builtin ("__builtin_mvcr_d", longlong_ftype_int_int,
1121 + AVR32_BUILTIN_MVCR_D);
1122 + def_builtin ("__builtin_mvrc_d", void_ftype_int_int_longlong,
1123 + AVR32_BUILTIN_MVRC_D);
1124 + def_builtin ("__builtin_sats", int_ftype_int_int_int, AVR32_BUILTIN_SATS);
1125 + def_builtin ("__builtin_satu", int_ftype_int_int_int, AVR32_BUILTIN_SATU);
1126 + def_builtin ("__builtin_satrnds", int_ftype_int_int_int,
1127 + AVR32_BUILTIN_SATRNDS);
1128 + def_builtin ("__builtin_satrndu", int_ftype_int_int_int,
1129 + AVR32_BUILTIN_SATRNDU);
1130 + def_builtin ("__builtin_musfr", void_ftype_int, AVR32_BUILTIN_MUSFR);
1131 + def_builtin ("__builtin_mustr", int_ftype_void, AVR32_BUILTIN_MUSTR);
1132 + def_builtin ("__builtin_macsathh_w", int_ftype_int_short_short,
1133 + AVR32_BUILTIN_MACSATHH_W);
1134 + def_builtin ("__builtin_macwh_d", longlong_ftype_longlong_int_short,
1135 + AVR32_BUILTIN_MACWH_D);
1136 + def_builtin ("__builtin_machh_d", longlong_ftype_longlong_short_short,
1137 + AVR32_BUILTIN_MACHH_D);
1138 + def_builtin ("__builtin_mems", void_ftype_ptr_int, AVR32_BUILTIN_MEMS);
1139 + def_builtin ("__builtin_memt", void_ftype_ptr_int, AVR32_BUILTIN_MEMT);
1140 + def_builtin ("__builtin_memc", void_ftype_ptr_int, AVR32_BUILTIN_MEMC);
1141 + def_builtin ("__builtin_sleep", void_ftype_int, AVR32_BUILTIN_SLEEP);
1142 + def_builtin ("__builtin_avr32_delay_cycles", void_ftype_int, AVR32_BUILTIN_DELAY_CYCLES);
1144 + /* Add all builtins that are more or less simple operations on two
1146 + for (i = 0, d = bdesc_2arg; i < ARRAY_SIZE (bdesc_2arg); i++, d++)
1148 + /* Use one of the operands; the target can have a different mode for
1149 + mask-generating compares. */
1154 + def_mbuiltin (d->mask, d->name, *(d->ftype), d->code);
1159 +/* Subroutine of avr32_expand_builtin to take care of binop insns. */
1161 +avr32_expand_binop_builtin (enum insn_code icode, tree exp, rtx target)
1164 + tree arg0 = CALL_EXPR_ARG (exp,0);
1165 + tree arg1 = CALL_EXPR_ARG (exp,1);
1166 + rtx op0 = expand_normal (arg0);
1167 + rtx op1 = expand_normal (arg1);
1168 + enum machine_mode tmode = insn_data[icode].operand[0].mode;
1169 + enum machine_mode mode0 = insn_data[icode].operand[1].mode;
1170 + enum machine_mode mode1 = insn_data[icode].operand[2].mode;
1173 + || GET_MODE (target) != tmode
1174 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1175 + target = gen_reg_rtx (tmode);
1177 + /* In case the insn wants input operands in modes different from the
1179 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1181 + /* If op0 is already a reg we must cast it to the correct mode. */
1183 + op0 = convert_to_mode (mode0, op0, 1);
1185 + op0 = copy_to_mode_reg (mode0, op0);
1187 + if (!(*insn_data[icode].operand[2].predicate) (op1, mode1))
1189 + /* If op1 is already a reg we must cast it to the correct mode. */
1191 + op1 = convert_to_mode (mode1, op1, 1);
1193 + op1 = copy_to_mode_reg (mode1, op1);
1195 + pat = GEN_FCN (icode) (target, op0, op1);
1203 +/* Expand an expression EXP that calls a built-in function,
1204 + with result going to TARGET if that's convenient
1205 + (and in mode MODE if that's convenient).
1206 + SUBTARGET may be used as the target for computing one of EXP's operands.
1207 + IGNORE is nonzero if the value is to be ignored. */
1209 +avr32_expand_builtin (tree exp,
1211 + rtx subtarget ATTRIBUTE_UNUSED,
1212 + enum machine_mode mode ATTRIBUTE_UNUSED,
1213 + int ignore ATTRIBUTE_UNUSED)
1215 + const struct builtin_description *d;
1217 + enum insn_code icode = 0;
1218 + tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
1219 + tree arg0, arg1, arg2;
1220 + rtx op0, op1, op2, pat;
1221 + enum machine_mode tmode, mode0, mode1;
1222 + enum machine_mode arg0_mode;
1223 + int fcode = DECL_FUNCTION_CODE (fndecl);
1230 + case AVR32_BUILTIN_SATS:
1231 + case AVR32_BUILTIN_SATU:
1232 + case AVR32_BUILTIN_SATRNDS:
1233 + case AVR32_BUILTIN_SATRNDU:
1235 + const char *fname;
1239 + case AVR32_BUILTIN_SATS:
1240 + icode = CODE_FOR_sats;
1243 + case AVR32_BUILTIN_SATU:
1244 + icode = CODE_FOR_satu;
1247 + case AVR32_BUILTIN_SATRNDS:
1248 + icode = CODE_FOR_satrnds;
1249 + fname = "satrnds";
1251 + case AVR32_BUILTIN_SATRNDU:
1252 + icode = CODE_FOR_satrndu;
1253 + fname = "satrndu";
1257 + arg0 = CALL_EXPR_ARG (exp,0);
1258 + arg1 = CALL_EXPR_ARG (exp,1);
1259 + arg2 = CALL_EXPR_ARG (exp,2);
1260 + op0 = expand_normal (arg0);
1261 + op1 = expand_normal (arg1);
1262 + op2 = expand_normal (arg2);
1264 + tmode = insn_data[icode].operand[0].mode;
1268 + || GET_MODE (target) != tmode
1269 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1270 + target = gen_reg_rtx (tmode);
1273 + if (!(*insn_data[icode].operand[0].predicate) (op0, GET_MODE (op0)))
1275 + op0 = copy_to_mode_reg (insn_data[icode].operand[0].mode, op0);
1278 + if (!(*insn_data[icode].operand[1].predicate) (op1, SImode))
1280 + error ("Parameter 2 to __builtin_%s should be a constant number.",
1285 + if (!(*insn_data[icode].operand[1].predicate) (op2, SImode))
1287 + error ("Parameter 3 to __builtin_%s should be a constant number.",
1292 + emit_move_insn (target, op0);
1293 + pat = GEN_FCN (icode) (target, op1, op2);
1300 + case AVR32_BUILTIN_MUSTR:
1301 + icode = CODE_FOR_mustr;
1302 + tmode = insn_data[icode].operand[0].mode;
1305 + || GET_MODE (target) != tmode
1306 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1307 + target = gen_reg_rtx (tmode);
1308 + pat = GEN_FCN (icode) (target);
1314 + case AVR32_BUILTIN_MFSR:
1315 + icode = CODE_FOR_mfsr;
1316 + arg0 = CALL_EXPR_ARG (exp,0);
1317 + op0 = expand_normal (arg0);
1318 + tmode = insn_data[icode].operand[0].mode;
1319 + mode0 = insn_data[icode].operand[1].mode;
1321 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1323 + error ("Parameter 1 to __builtin_mfsr must be a constant number");
1327 + || GET_MODE (target) != tmode
1328 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1329 + target = gen_reg_rtx (tmode);
1330 + pat = GEN_FCN (icode) (target, op0);
1335 + case AVR32_BUILTIN_MTSR:
1336 + icode = CODE_FOR_mtsr;
1337 + arg0 = CALL_EXPR_ARG (exp,0);
1338 + arg1 = CALL_EXPR_ARG (exp,1);
1339 + op0 = expand_normal (arg0);
1340 + op1 = expand_normal (arg1);
1341 + mode0 = insn_data[icode].operand[0].mode;
1342 + mode1 = insn_data[icode].operand[1].mode;
1344 + if (!(*insn_data[icode].operand[0].predicate) (op0, mode0))
1346 + error ("Parameter 1 to __builtin_mtsr must be a constant number");
1347 + return gen_reg_rtx (mode0);
1349 + if (!(*insn_data[icode].operand[1].predicate) (op1, mode1))
1350 + op1 = copy_to_mode_reg (mode1, op1);
1351 + pat = GEN_FCN (icode) (op0, op1);
1356 + case AVR32_BUILTIN_MFDR:
1357 + icode = CODE_FOR_mfdr;
1358 + arg0 = CALL_EXPR_ARG (exp,0);
1359 + op0 = expand_normal (arg0);
1360 + tmode = insn_data[icode].operand[0].mode;
1361 + mode0 = insn_data[icode].operand[1].mode;
1363 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1365 + error ("Parameter 1 to __builtin_mfdr must be a constant number");
1369 + || GET_MODE (target) != tmode
1370 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1371 + target = gen_reg_rtx (tmode);
1372 + pat = GEN_FCN (icode) (target, op0);
1377 + case AVR32_BUILTIN_MTDR:
1378 + icode = CODE_FOR_mtdr;
1379 + arg0 = CALL_EXPR_ARG (exp,0);
1380 + arg1 = CALL_EXPR_ARG (exp,1);
1381 + op0 = expand_normal (arg0);
1382 + op1 = expand_normal (arg1);
1383 + mode0 = insn_data[icode].operand[0].mode;
1384 + mode1 = insn_data[icode].operand[1].mode;
1386 + if (!(*insn_data[icode].operand[0].predicate) (op0, mode0))
1388 + error ("Parameter 1 to __builtin_mtdr must be a constant number");
1389 + return gen_reg_rtx (mode0);
1391 + if (!(*insn_data[icode].operand[1].predicate) (op1, mode1))
1392 + op1 = copy_to_mode_reg (mode1, op1);
1393 + pat = GEN_FCN (icode) (op0, op1);
1398 + case AVR32_BUILTIN_CACHE:
1399 + icode = CODE_FOR_cache;
1400 + arg0 = CALL_EXPR_ARG (exp,0);
1401 + arg1 = CALL_EXPR_ARG (exp,1);
1402 + op0 = expand_normal (arg0);
1403 + op1 = expand_normal (arg1);
1404 + mode0 = insn_data[icode].operand[0].mode;
1405 + mode1 = insn_data[icode].operand[1].mode;
1407 + if (!(*insn_data[icode].operand[1].predicate) (op1, mode1))
1409 + error ("Parameter 2 to __builtin_cache must be a constant number");
1410 + return gen_reg_rtx (mode1);
1413 + if (!(*insn_data[icode].operand[0].predicate) (op0, mode0))
1414 + op0 = copy_to_mode_reg (mode0, op0);
1416 + pat = GEN_FCN (icode) (op0, op1);
1421 + case AVR32_BUILTIN_SYNC:
1422 + case AVR32_BUILTIN_MUSFR:
1423 + case AVR32_BUILTIN_SSRF:
1424 + case AVR32_BUILTIN_CSRF:
1426 + const char *fname;
1430 + case AVR32_BUILTIN_SYNC:
1431 + icode = CODE_FOR_sync;
1434 + case AVR32_BUILTIN_MUSFR:
1435 + icode = CODE_FOR_musfr;
1438 + case AVR32_BUILTIN_SSRF:
1439 + icode = CODE_FOR_ssrf;
1442 + case AVR32_BUILTIN_CSRF:
1443 + icode = CODE_FOR_csrf;
1448 + arg0 = CALL_EXPR_ARG (exp,0);
1449 + op0 = expand_normal (arg0);
1450 + mode0 = insn_data[icode].operand[0].mode;
1452 + if (!(*insn_data[icode].operand[0].predicate) (op0, mode0))
1454 + if (icode == CODE_FOR_musfr)
1455 + op0 = copy_to_mode_reg (mode0, op0);
1458 + error ("Parameter to __builtin_%s is illegal.", fname);
1459 + return gen_reg_rtx (mode0);
1462 + pat = GEN_FCN (icode) (op0);
1468 + case AVR32_BUILTIN_TLBR:
1469 + icode = CODE_FOR_tlbr;
1470 + pat = GEN_FCN (icode) (NULL_RTX);
1475 + case AVR32_BUILTIN_TLBS:
1476 + icode = CODE_FOR_tlbs;
1477 + pat = GEN_FCN (icode) (NULL_RTX);
1482 + case AVR32_BUILTIN_TLBW:
1483 + icode = CODE_FOR_tlbw;
1484 + pat = GEN_FCN (icode) (NULL_RTX);
1489 + case AVR32_BUILTIN_BREAKPOINT:
1490 + icode = CODE_FOR_breakpoint;
1491 + pat = GEN_FCN (icode) (NULL_RTX);
1496 + case AVR32_BUILTIN_XCHG:
1497 + icode = CODE_FOR_sync_lock_test_and_setsi;
1498 + arg0 = CALL_EXPR_ARG (exp,0);
1499 + arg1 = CALL_EXPR_ARG (exp,1);
1500 + op0 = expand_normal (arg0);
1501 + op1 = expand_normal (arg1);
1502 + tmode = insn_data[icode].operand[0].mode;
1503 + mode0 = insn_data[icode].operand[1].mode;
1504 + mode1 = insn_data[icode].operand[2].mode;
1506 + if (!(*insn_data[icode].operand[2].predicate) (op1, mode1))
1508 + op1 = copy_to_mode_reg (mode1, op1);
1511 + op0 = force_reg (GET_MODE (op0), op0);
1512 + op0 = gen_rtx_MEM (GET_MODE (op0), op0);
1513 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1516 + ("Parameter 1 to __builtin_xchg must be a pointer to an integer.");
1520 + || GET_MODE (target) != tmode
1521 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1522 + target = gen_reg_rtx (tmode);
1523 + pat = GEN_FCN (icode) (target, op0, op1);
1528 + case AVR32_BUILTIN_LDXI:
1529 + icode = CODE_FOR_ldxi;
1530 + arg0 = CALL_EXPR_ARG (exp,0);
1531 + arg1 = CALL_EXPR_ARG (exp,1);
1532 + arg2 = CALL_EXPR_ARG (exp,2);
1533 + op0 = expand_normal (arg0);
1534 + op1 = expand_normal (arg1);
1535 + op2 = expand_normal (arg2);
1536 + tmode = insn_data[icode].operand[0].mode;
1537 + mode0 = insn_data[icode].operand[1].mode;
1538 + mode1 = insn_data[icode].operand[2].mode;
1540 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1542 + op0 = copy_to_mode_reg (mode0, op0);
1545 + if (!(*insn_data[icode].operand[2].predicate) (op1, mode1))
1547 + op1 = copy_to_mode_reg (mode1, op1);
1550 + if (!(*insn_data[icode].operand[3].predicate) (op2, SImode))
1553 + ("Parameter 3 to __builtin_ldxi must be a valid extract shift operand: (0|8|16|24)");
1554 + return gen_reg_rtx (mode0);
1558 + || GET_MODE (target) != tmode
1559 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1560 + target = gen_reg_rtx (tmode);
1561 + pat = GEN_FCN (icode) (target, op0, op1, op2);
1566 + case AVR32_BUILTIN_BSWAP16:
1568 + icode = CODE_FOR_bswap_16;
1569 + arg0 = CALL_EXPR_ARG (exp,0);
1570 + arg0_mode = TYPE_MODE (TREE_TYPE (arg0));
1571 + mode0 = insn_data[icode].operand[1].mode;
1572 + if (arg0_mode != mode0)
1573 + arg0 = build1 (NOP_EXPR,
1574 + (*lang_hooks.types.type_for_mode) (mode0, 0), arg0);
1576 + op0 = expand_expr (arg0, NULL_RTX, HImode, 0);
1577 + tmode = insn_data[icode].operand[0].mode;
1580 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1582 + if ( CONST_INT_P (op0) )
1584 + HOST_WIDE_INT val = ( ((INTVAL (op0)&0x00ff) << 8) |
1585 + ((INTVAL (op0)&0xff00) >> 8) );
1586 + /* Sign extend 16-bit value to host wide int */
1587 + val <<= (HOST_BITS_PER_WIDE_INT - 16);
1588 + val >>= (HOST_BITS_PER_WIDE_INT - 16);
1589 + op0 = GEN_INT(val);
1591 + || GET_MODE (target) != tmode
1592 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1593 + target = gen_reg_rtx (tmode);
1594 + emit_move_insn(target, op0);
1598 + op0 = copy_to_mode_reg (mode0, op0);
1602 + || GET_MODE (target) != tmode
1603 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1605 + target = gen_reg_rtx (tmode);
1609 + pat = GEN_FCN (icode) (target, op0);
1616 + case AVR32_BUILTIN_BSWAP32:
1618 + icode = CODE_FOR_bswap_32;
1619 + arg0 = CALL_EXPR_ARG (exp,0);
1620 + op0 = expand_normal (arg0);
1621 + tmode = insn_data[icode].operand[0].mode;
1622 + mode0 = insn_data[icode].operand[1].mode;
1624 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1626 + if ( CONST_INT_P (op0) )
1628 + HOST_WIDE_INT val = ( ((INTVAL (op0)&0x000000ff) << 24) |
1629 + ((INTVAL (op0)&0x0000ff00) << 8) |
1630 + ((INTVAL (op0)&0x00ff0000) >> 8) |
1631 + ((INTVAL (op0)&0xff000000) >> 24) );
1632 + /* Sign extend 32-bit value to host wide int */
1633 + val <<= (HOST_BITS_PER_WIDE_INT - 32);
1634 + val >>= (HOST_BITS_PER_WIDE_INT - 32);
1635 + op0 = GEN_INT(val);
1637 + || GET_MODE (target) != tmode
1638 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1639 + target = gen_reg_rtx (tmode);
1640 + emit_move_insn(target, op0);
1644 + op0 = copy_to_mode_reg (mode0, op0);
1648 + || GET_MODE (target) != tmode
1649 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1650 + target = gen_reg_rtx (tmode);
1653 + pat = GEN_FCN (icode) (target, op0);
1660 + case AVR32_BUILTIN_MVCR_W:
1661 + case AVR32_BUILTIN_MVCR_D:
1663 + arg0 = CALL_EXPR_ARG (exp,0);
1664 + arg1 = CALL_EXPR_ARG (exp,1);
1665 + op0 = expand_normal (arg0);
1666 + op1 = expand_normal (arg1);
1668 + if (fcode == AVR32_BUILTIN_MVCR_W)
1669 + icode = CODE_FOR_mvcrsi;
1671 + icode = CODE_FOR_mvcrdi;
1673 + tmode = insn_data[icode].operand[0].mode;
1676 + || GET_MODE (target) != tmode
1677 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1678 + target = gen_reg_rtx (tmode);
1680 + if (!(*insn_data[icode].operand[1].predicate) (op0, SImode))
1683 + ("Parameter 1 to __builtin_cop is not a valid coprocessor number.");
1684 + error ("Number should be between 0 and 7.");
1688 + if (!(*insn_data[icode].operand[2].predicate) (op1, SImode))
1691 + ("Parameter 2 to __builtin_cop is not a valid coprocessor register number.");
1692 + error ("Number should be between 0 and 15.");
1696 + pat = GEN_FCN (icode) (target, op0, op1);
1703 + case AVR32_BUILTIN_MACSATHH_W:
1704 + case AVR32_BUILTIN_MACWH_D:
1705 + case AVR32_BUILTIN_MACHH_D:
1707 + arg0 = CALL_EXPR_ARG (exp,0);
1708 + arg1 = CALL_EXPR_ARG (exp,1);
1709 + arg2 = CALL_EXPR_ARG (exp,2);
1710 + op0 = expand_normal (arg0);
1711 + op1 = expand_normal (arg1);
1712 + op2 = expand_normal (arg2);
1714 + icode = ((fcode == AVR32_BUILTIN_MACSATHH_W) ? CODE_FOR_macsathh_w :
1715 + (fcode == AVR32_BUILTIN_MACWH_D) ? CODE_FOR_macwh_d :
1716 + CODE_FOR_machh_d);
1718 + tmode = insn_data[icode].operand[0].mode;
1719 + mode0 = insn_data[icode].operand[1].mode;
1720 + mode1 = insn_data[icode].operand[2].mode;
1724 + || GET_MODE (target) != tmode
1725 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1726 + target = gen_reg_rtx (tmode);
1728 + if (!(*insn_data[icode].operand[0].predicate) (op0, tmode))
1730 + /* If op0 is already a reg we must cast it to the correct mode. */
1732 + op0 = convert_to_mode (tmode, op0, 1);
1734 + op0 = copy_to_mode_reg (tmode, op0);
1737 + if (!(*insn_data[icode].operand[1].predicate) (op1, mode0))
1739 + /* If op1 is already a reg we must cast it to the correct mode. */
1741 + op1 = convert_to_mode (mode0, op1, 1);
1743 + op1 = copy_to_mode_reg (mode0, op1);
1746 + if (!(*insn_data[icode].operand[2].predicate) (op2, mode1))
1748 + /* If op1 is already a reg we must cast it to the correct mode. */
1750 + op2 = convert_to_mode (mode1, op2, 1);
1752 + op2 = copy_to_mode_reg (mode1, op2);
1755 + emit_move_insn (target, op0);
1757 + pat = GEN_FCN (icode) (target, op1, op2);
1763 + case AVR32_BUILTIN_MVRC_W:
1764 + case AVR32_BUILTIN_MVRC_D:
1766 + arg0 = CALL_EXPR_ARG (exp,0);
1767 + arg1 = CALL_EXPR_ARG (exp,1);
1768 + arg2 = CALL_EXPR_ARG (exp,2);
1769 + op0 = expand_normal (arg0);
1770 + op1 = expand_normal (arg1);
1771 + op2 = expand_normal (arg2);
1773 + if (fcode == AVR32_BUILTIN_MVRC_W)
1774 + icode = CODE_FOR_mvrcsi;
1776 + icode = CODE_FOR_mvrcdi;
1778 + if (!(*insn_data[icode].operand[0].predicate) (op0, SImode))
1780 + error ("Parameter 1 is not a valid coprocessor number.");
1781 + error ("Number should be between 0 and 7.");
1785 + if (!(*insn_data[icode].operand[1].predicate) (op1, SImode))
1787 + error ("Parameter 2 is not a valid coprocessor register number.");
1788 + error ("Number should be between 0 and 15.");
1792 + if (GET_CODE (op2) == CONST_INT
1793 + || GET_CODE (op2) == CONST
1794 + || GET_CODE (op2) == SYMBOL_REF || GET_CODE (op2) == LABEL_REF)
1796 + op2 = force_const_mem (insn_data[icode].operand[2].mode, op2);
1799 + if (!(*insn_data[icode].operand[2].predicate) (op2, GET_MODE (op2)))
1800 + op2 = copy_to_mode_reg (insn_data[icode].operand[2].mode, op2);
1803 + pat = GEN_FCN (icode) (op0, op1, op2);
1810 + case AVR32_BUILTIN_COP:
1814 + icode = CODE_FOR_cop;
1815 + arg0 = CALL_EXPR_ARG (exp,0);
1816 + arg1 = CALL_EXPR_ARG (exp,1);
1817 + arg2 = CALL_EXPR_ARG (exp,2);
1818 + arg3 = CALL_EXPR_ARG (exp,3);
1819 + arg4 = CALL_EXPR_ARG (exp,4);
1820 + op0 = expand_normal (arg0);
1821 + op1 = expand_normal (arg1);
1822 + op2 = expand_normal (arg2);
1823 + op3 = expand_normal (arg3);
1824 + op4 = expand_normal (arg4);
1826 + if (!(*insn_data[icode].operand[0].predicate) (op0, SImode))
1829 + ("Parameter 1 to __builtin_cop is not a valid coprocessor number.");
1830 + error ("Number should be between 0 and 7.");
1834 + if (!(*insn_data[icode].operand[1].predicate) (op1, SImode))
1837 + ("Parameter 2 to __builtin_cop is not a valid coprocessor register number.");
1838 + error ("Number should be between 0 and 15.");
1842 + if (!(*insn_data[icode].operand[2].predicate) (op2, SImode))
1845 + ("Parameter 3 to __builtin_cop is not a valid coprocessor register number.");
1846 + error ("Number should be between 0 and 15.");
1850 + if (!(*insn_data[icode].operand[3].predicate) (op3, SImode))
1853 + ("Parameter 4 to __builtin_cop is not a valid coprocessor register number.");
1854 + error ("Number should be between 0 and 15.");
1858 + if (!(*insn_data[icode].operand[4].predicate) (op4, SImode))
1861 + ("Parameter 5 to __builtin_cop is not a valid coprocessor operation.");
1862 + error ("Number should be between 0 and 127.");
1866 + pat = GEN_FCN (icode) (op0, op1, op2, op3, op4);
1874 + case AVR32_BUILTIN_MEMS:
1875 + case AVR32_BUILTIN_MEMC:
1876 + case AVR32_BUILTIN_MEMT:
1879 + error ("Trying to use __builtin_mem(s/c/t) when target does not support RMW insns.");
1882 + case AVR32_BUILTIN_MEMS:
1883 + icode = CODE_FOR_iorsi3;
1885 + case AVR32_BUILTIN_MEMC:
1886 + icode = CODE_FOR_andsi3;
1888 + case AVR32_BUILTIN_MEMT:
1889 + icode = CODE_FOR_xorsi3;
1892 + arg0 = CALL_EXPR_ARG (exp,0);
1893 + arg1 = CALL_EXPR_ARG (exp,1);
1894 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1895 + if ( GET_CODE (op0) == SYMBOL_REF )
1896 + // This symbol must be RMW addressable
1897 + SYMBOL_REF_FLAGS (op0) |= (1 << SYMBOL_FLAG_RMW_ADDR_SHIFT);
1898 + op0 = gen_rtx_MEM(SImode, op0);
1899 + op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
1900 + mode0 = insn_data[icode].operand[1].mode;
1903 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1905 + error ("Parameter 1 to __builtin_mem(s/c/t) must be a Ks15<<2 address or a rmw addressable symbol.");
1908 + if ( !CONST_INT_P (op1)
1909 + || INTVAL (op1) > 31
1910 + || INTVAL (op1) < 0 )
1911 + error ("Parameter 2 to __builtin_mem(s/c/t) must be a constant between 0 and 31.");
1913 + if ( fcode == AVR32_BUILTIN_MEMC )
1914 + op1 = GEN_INT((~(1 << INTVAL(op1)))&0xffffffff);
1916 + op1 = GEN_INT((1 << INTVAL(op1))&0xffffffff);
1917 + pat = GEN_FCN (icode) (op0, op0, op1);
1924 + case AVR32_BUILTIN_SLEEP:
1926 + arg0 = CALL_EXPR_ARG (exp, 0);
1927 + op0 = expand_normal (arg0);
1928 + int intval = INTVAL(op0);
1930 + /* Check if the argument if integer and if the value of integer
1931 + is greater than 0. */
1933 + if (!CONSTANT_P (op0))
1934 + error ("Parameter 1 to __builtin_sleep() is not a valid integer.");
1936 + error ("Parameter 1 to __builtin_sleep() should be an integer greater than 0.");
1938 + int strncmpval = strncmp (avr32_part_name,"uc3l", 4);
1940 + /* Check if op0 is less than 7 for uc3l* and less than 6 for other
1941 + devices. By this check we are avoiding if operand is less than
1942 + 256. For more devices, add more such checks. */
1944 + if ( strncmpval == 0 && intval >= 7)
1945 + error ("Parameter 1 to __builtin_sleep() should be less than or equal to 7.");
1946 + else if ( strncmp != 0 && intval >= 6)
1947 + error ("Parameter 1 to __builtin_sleep() should be less than or equal to 6.");
1949 + emit_insn (gen_sleep(op0));
1953 + case AVR32_BUILTIN_DELAY_CYCLES:
1955 + arg0 = CALL_EXPR_ARG (exp, 0);
1956 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1958 + if (TARGET_ARCH_AP)
1959 + error (" __builtin_avr32_delay_cycles() not supported for \'%s\' architecture.", avr32_arch_name);
1960 + if (!CONSTANT_P (op0))
1961 + error ("Parameter 1 to __builtin_avr32_delay_cycles() should be an integer.");
1962 + emit_insn (gen_delay_cycles (op0));
1969 + for (i = 0, d = bdesc_2arg; i < ARRAY_SIZE (bdesc_2arg); i++, d++)
1970 + if (d->code == fcode)
1971 + return avr32_expand_binop_builtin (d->icode, exp, target);
1974 + /* @@@ Should really do something sensible here. */
1979 +/* Handle an "interrupt" or "isr" attribute;
1980 + arguments as in struct attribute_spec.handler. */
1982 +avr32_handle_isr_attribute (tree * node, tree name, tree args,
1983 + int flags, bool * no_add_attrs)
1985 + if (DECL_P (*node))
1987 + if (TREE_CODE (*node) != FUNCTION_DECL)
1989 + warning (OPT_Wattributes,"`%s' attribute only applies to functions",
1990 + IDENTIFIER_POINTER (name));
1991 + *no_add_attrs = true;
1993 + /* FIXME: the argument if any is checked for type attributes; should it
1994 + be checked for decl ones? */
1998 + if (TREE_CODE (*node) == FUNCTION_TYPE
1999 + || TREE_CODE (*node) == METHOD_TYPE)
2001 + if (avr32_isr_value (args) == AVR32_FT_UNKNOWN)
2003 + warning (OPT_Wattributes,"`%s' attribute ignored", IDENTIFIER_POINTER (name));
2004 + *no_add_attrs = true;
2007 + else if (TREE_CODE (*node) == POINTER_TYPE
2008 + && (TREE_CODE (TREE_TYPE (*node)) == FUNCTION_TYPE
2009 + || TREE_CODE (TREE_TYPE (*node)) == METHOD_TYPE)
2010 + && avr32_isr_value (args) != AVR32_FT_UNKNOWN)
2012 + *node = build_variant_type_copy (*node);
2013 + TREE_TYPE (*node) = build_type_attribute_variant
2014 + (TREE_TYPE (*node),
2015 + tree_cons (name, args, TYPE_ATTRIBUTES (TREE_TYPE (*node))));
2016 + *no_add_attrs = true;
2020 + /* Possibly pass this attribute on from the type to a decl. */
2021 + if (flags & ((int) ATTR_FLAG_DECL_NEXT
2022 + | (int) ATTR_FLAG_FUNCTION_NEXT
2023 + | (int) ATTR_FLAG_ARRAY_NEXT))
2025 + *no_add_attrs = true;
2026 + return tree_cons (name, args, NULL_TREE);
2030 + warning (OPT_Wattributes,"`%s' attribute ignored", IDENTIFIER_POINTER (name));
2039 +/* Handle an attribute requiring a FUNCTION_DECL;
2040 + arguments as in struct attribute_spec.handler. */
2042 +avr32_handle_fndecl_attribute (tree * node, tree name,
2044 + int flags ATTRIBUTE_UNUSED,
2045 + bool * no_add_attrs)
2047 + if (TREE_CODE (*node) != FUNCTION_DECL)
2049 + warning (OPT_Wattributes,"%qs attribute only applies to functions",
2050 + IDENTIFIER_POINTER (name));
2051 + *no_add_attrs = true;
2055 + fndecl_attribute_args = args;
2056 + if (args == NULL_TREE)
2059 + tree value = TREE_VALUE (args);
2060 + if (TREE_CODE (value) != INTEGER_CST)
2062 + warning (OPT_Wattributes,
2063 + "argument of %qs attribute is not an integer constant",
2064 + IDENTIFIER_POINTER (name));
2065 + *no_add_attrs = true;
2072 +/* Handle an acall attribute;
2073 + arguments as in struct attribute_spec.handler. */
2076 +avr32_handle_acall_attribute (tree * node, tree name,
2077 + tree args ATTRIBUTE_UNUSED,
2078 + int flags ATTRIBUTE_UNUSED, bool * no_add_attrs)
2080 + if (TREE_CODE (*node) == FUNCTION_TYPE || TREE_CODE (*node) == METHOD_TYPE)
2082 + warning (OPT_Wattributes,"`%s' attribute not yet supported...",
2083 + IDENTIFIER_POINTER (name));
2084 + *no_add_attrs = true;
2088 + warning (OPT_Wattributes,"`%s' attribute only applies to functions",
2089 + IDENTIFIER_POINTER (name));
2090 + *no_add_attrs = true;
2096 +avr32_flashvault_call(tree decl)
2099 + tree fv_attribute;
2101 + unsigned int vector;
2103 + if (decl && TREE_CODE (decl) == FUNCTION_DECL)
2105 + attributes = DECL_ATTRIBUTES(decl);
2106 + fv_attribute = lookup_attribute ("flashvault", attributes);
2107 + if (fv_attribute != NULL_TREE)
2109 + /* Get attribute parameter, for the function vector number. */
2111 + There is probably an easier, standard way to retrieve the
2112 + attribute parameter which needs to be done here.
2114 + vector_tree = TREE_VALUE(fv_attribute);
2115 + if (vector_tree != NULL_TREE)
2117 + vector = (unsigned int)TREE_INT_CST_LOW(TREE_VALUE(vector_tree));
2118 + fprintf (asm_out_file,
2119 + "\tmov\tr8, lo(%i)\t# Load vector number for sscall.\n",
2123 + fprintf (asm_out_file,
2124 + "\tsscall\t# Secure system call.\n");
2134 +static bool has_attribute_p (tree decl, const char *name)
2136 + if (decl && TREE_CODE (decl) == FUNCTION_DECL)
2138 + return (lookup_attribute (name, DECL_ATTRIBUTES(decl)) != NULL_TREE);
2144 +/* Return 0 if the attributes for two types are incompatible, 1 if they
2145 + are compatible, and 2 if they are nearly compatible (which causes a
2146 + warning to be generated). */
2148 +avr32_comp_type_attributes (tree type1, tree type2)
2150 + bool acall1, acall2, isr1, isr2, naked1, naked2, fv1, fv2, fvimpl1, fvimpl2;
2152 + /* Check for mismatch of non-default calling convention. */
2153 + if (TREE_CODE (type1) != FUNCTION_TYPE)
2156 + /* Check for mismatched call attributes. */
2157 + acall1 = lookup_attribute ("acall", TYPE_ATTRIBUTES (type1)) != NULL;
2158 + acall2 = lookup_attribute ("acall", TYPE_ATTRIBUTES (type2)) != NULL;
2159 + naked1 = lookup_attribute ("naked", TYPE_ATTRIBUTES (type1)) != NULL;
2160 + naked2 = lookup_attribute ("naked", TYPE_ATTRIBUTES (type2)) != NULL;
2161 + fv1 = lookup_attribute ("flashvault", TYPE_ATTRIBUTES (type1)) != NULL;
2162 + fv2 = lookup_attribute ("flashvault", TYPE_ATTRIBUTES (type2)) != NULL;
2163 + fvimpl1 = lookup_attribute ("flashvault_impl", TYPE_ATTRIBUTES (type1)) != NULL;
2164 + fvimpl2 = lookup_attribute ("flashvault_impl", TYPE_ATTRIBUTES (type2)) != NULL;
2165 + isr1 = lookup_attribute ("isr", TYPE_ATTRIBUTES (type1)) != NULL;
2167 + isr1 = lookup_attribute ("interrupt", TYPE_ATTRIBUTES (type1)) != NULL;
2169 + isr2 = lookup_attribute ("isr", TYPE_ATTRIBUTES (type2)) != NULL;
2171 + isr2 = lookup_attribute ("interrupt", TYPE_ATTRIBUTES (type2)) != NULL;
2173 + if ((acall1 && isr2)
2174 + || (acall2 && isr1)
2175 + || (naked1 && isr2)
2176 + || (naked2 && isr1)
2179 + || (fvimpl1 && isr2)
2180 + || (fvimpl2 && isr1)
2181 + || (fv1 && fvimpl2)
2182 + || (fv2 && fvimpl1)
2190 +/* Computes the type of the current function. */
2191 +static unsigned long
2192 +avr32_compute_func_type (void)
2194 + unsigned long type = AVR32_FT_UNKNOWN;
2198 + if (TREE_CODE (current_function_decl) != FUNCTION_DECL)
2201 + /* Decide if the current function is volatile. Such functions never
2202 + return, and many memory cycles can be saved by not storing register
2203 + values that will never be needed again. This optimization was added to
2204 + speed up context switching in a kernel application. */
2206 + && TREE_NOTHROW (current_function_decl)
2207 + && TREE_THIS_VOLATILE (current_function_decl))
2208 + type |= AVR32_FT_VOLATILE;
2210 + if (cfun->static_chain_decl != NULL)
2211 + type |= AVR32_FT_NESTED;
2213 + attr = DECL_ATTRIBUTES (current_function_decl);
2215 + a = lookup_attribute ("isr", attr);
2216 + if (a == NULL_TREE)
2217 + a = lookup_attribute ("interrupt", attr);
2219 + if (a == NULL_TREE)
2220 + type |= AVR32_FT_NORMAL;
2222 + type |= avr32_isr_value (TREE_VALUE (a));
2225 + a = lookup_attribute ("acall", attr);
2226 + if (a != NULL_TREE)
2227 + type |= AVR32_FT_ACALL;
2229 + a = lookup_attribute ("naked", attr);
2230 + if (a != NULL_TREE)
2231 + type |= AVR32_FT_NAKED;
2233 + a = lookup_attribute ("flashvault", attr);
2234 + if (a != NULL_TREE)
2235 + type |= AVR32_FT_FLASHVAULT;
2237 + a = lookup_attribute ("flashvault_impl", attr);
2238 + if (a != NULL_TREE)
2239 + type |= AVR32_FT_FLASHVAULT_IMPL;
2245 +/* Returns the type of the current function. */
2246 +static unsigned long
2247 +avr32_current_func_type (void)
2249 + if (AVR32_FUNC_TYPE (cfun->machine->func_type) == AVR32_FT_UNKNOWN)
2250 + cfun->machine->func_type = avr32_compute_func_type ();
2252 + return cfun->machine->func_type;
2257 +This target hook should return true if we should not pass type solely
2258 +in registers. The file expr.h defines a definition that is usually appropriate,
2259 +refer to expr.h for additional documentation.
2262 +avr32_must_pass_in_stack (enum machine_mode mode ATTRIBUTE_UNUSED, tree type)
2264 + if (type && AGGREGATE_TYPE_P (type)
2265 + /* If the alignment is less than the size then pass in the struct on
2267 + && ((unsigned int) TYPE_ALIGN_UNIT (type) <
2268 + (unsigned int) int_size_in_bytes (type))
2269 + /* If we support unaligned word accesses then structs of size 4 and 8
2270 + can have any alignment and still be passed in registers. */
2271 + && !(TARGET_UNALIGNED_WORD
2272 + && (int_size_in_bytes (type) == 4
2273 + || int_size_in_bytes (type) == 8))
2274 + /* Double word structs need only a word alignment. */
2275 + && !(int_size_in_bytes (type) == 8 && TYPE_ALIGN_UNIT (type) >= 4))
2278 + if (type && AGGREGATE_TYPE_P (type)
2279 + /* Structs of size 3,5,6,7 are always passed in registers. */
2280 + && (int_size_in_bytes (type) == 3
2281 + || int_size_in_bytes (type) == 5
2282 + || int_size_in_bytes (type) == 6 || int_size_in_bytes (type) == 7))
2286 + return (type && TREE_ADDRESSABLE (type));
2291 +avr32_strict_argument_naming (CUMULATIVE_ARGS * ca ATTRIBUTE_UNUSED)
2298 + This target hook should return true if an argument at the position indicated
2299 + by cum should be passed by reference. This predicate is queried after target
2300 + independent reasons for being passed by reference, such as TREE_ADDRESSABLE (type).
2302 + If the hook returns true, a copy of that argument is made in memory and a
2303 + pointer to the argument is passed instead of the argument itself. The pointer
2304 + is passed in whatever way is appropriate for passing a pointer to that type.
2307 +avr32_pass_by_reference (CUMULATIVE_ARGS * cum ATTRIBUTE_UNUSED,
2308 + enum machine_mode mode ATTRIBUTE_UNUSED,
2309 + tree type, bool named ATTRIBUTE_UNUSED)
2311 + return (type && (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST));
2316 +avr32_arg_partial_bytes (CUMULATIVE_ARGS * pcum ATTRIBUTE_UNUSED,
2317 + enum machine_mode mode ATTRIBUTE_UNUSED,
2318 + tree type ATTRIBUTE_UNUSED,
2319 + bool named ATTRIBUTE_UNUSED)
2325 +struct gcc_target targetm = TARGET_INITIALIZER;
2328 + Table used to convert from register number in the assembler instructions and
2329 + the register numbers used in gcc.
2331 +const int avr32_function_arg_reglist[] = {
2332 + INTERNAL_REGNUM (12),
2333 + INTERNAL_REGNUM (11),
2334 + INTERNAL_REGNUM (10),
2335 + INTERNAL_REGNUM (9),
2336 + INTERNAL_REGNUM (8)
2340 +rtx avr32_compare_op0 = NULL_RTX;
2341 +rtx avr32_compare_op1 = NULL_RTX;
2342 +rtx avr32_compare_operator = NULL_RTX;
2343 +rtx avr32_acc_cache = NULL_RTX;
2347 + Returns nonzero if it is allowed to store a value of mode mode in hard
2348 + register number regno.
2351 +avr32_hard_regno_mode_ok (int regnr, enum machine_mode mode)
2355 + case DImode: /* long long */
2356 + case DFmode: /* double */
2357 + case SCmode: /* __complex__ float */
2358 + case CSImode: /* __complex__ int */
2360 + { /* long long int not supported in r12, sp, lr or pc. */
2365 + /* long long int has to be referred in even registers. */
2371 + case CDImode: /* __complex__ long long */
2372 + case DCmode: /* __complex__ double */
2373 + case TImode: /* 16 bytes */
2376 + else if (regnr % 2)
2387 +avr32_rnd_operands (rtx add, rtx shift)
2389 + if (GET_CODE (shift) == CONST_INT &&
2390 + GET_CODE (add) == CONST_INT && INTVAL (shift) > 0)
2392 + if ((1 << (INTVAL (shift) - 1)) == INTVAL (add))
2401 +avr32_const_ok_for_constraint_p (HOST_WIDE_INT value, char c, const char *str)
2408 + HOST_WIDE_INT min_value = 0, max_value = 0;
2412 + size_str[0] = str[2];
2413 + size_str[1] = str[3];
2414 + size_str[2] = '\0';
2415 + const_size = atoi (size_str);
2417 + if (toupper (str[1]) == 'U')
2420 + max_value = (1 << const_size) - 1;
2422 + else if (toupper (str[1]) == 'S')
2424 + min_value = -(1 << (const_size - 1));
2425 + max_value = (1 << (const_size - 1)) - 1;
2433 + if (value >= min_value && value <= max_value)
2440 + return avr32_mask_upper_bits_operand (GEN_INT (value), VOIDmode);
2442 + return avr32_hi16_immediate_operand (GEN_INT (value), VOIDmode);
2444 + return one_bit_set_operand (GEN_INT (value), VOIDmode);
2446 + return one_bit_cleared_operand (GEN_INT (value), VOIDmode);
2448 + /* The lower 16-bits are set. */
2449 + return ((value & 0xffff) == 0xffff) ;
2456 +/* Compute mask of registers which needs saving upon function entry. */
2457 +static unsigned long
2458 +avr32_compute_save_reg_mask (int push)
2460 + unsigned long func_type;
2461 + unsigned int save_reg_mask = 0;
2464 + func_type = avr32_current_func_type ();
2466 + if (IS_INTERRUPT (func_type))
2468 + unsigned int max_reg = 12;
2470 + /* Get the banking scheme for the interrupt */
2471 + switch (func_type)
2473 + case AVR32_FT_ISR_FULL:
2476 + case AVR32_FT_ISR_HALF:
2479 + case AVR32_FT_ISR_NONE:
2484 + /* Interrupt functions must not corrupt any registers, even call
2485 + clobbered ones. If this is a leaf function we can just examine the
2486 + registers used by the RTL, but otherwise we have to assume that
2487 + whatever function is called might clobber anything, and so we have
2488 + to save all the call-clobbered registers as well. */
2490 + /* Need not push the registers r8-r12 for AVR32A architectures, as this
2491 + is automatially done in hardware. We also do not have any shadow
2493 + if (TARGET_UARCH_AVR32A)
2496 + func_type = AVR32_FT_ISR_NONE;
2499 + /* All registers which are used and are not shadowed must be saved. */
2500 + for (reg = 0; reg <= max_reg; reg++)
2501 + if (df_regs_ever_live_p (INTERNAL_REGNUM (reg))
2502 + || (!current_function_is_leaf
2503 + && call_used_regs[INTERNAL_REGNUM (reg)]))
2504 + save_reg_mask |= (1 << reg);
2507 + if ((df_regs_ever_live_p (LR_REGNUM)
2508 + || !current_function_is_leaf || frame_pointer_needed)
2509 + /* Only non-shadowed register models */
2510 + && (func_type == AVR32_FT_ISR_NONE))
2511 + save_reg_mask |= (1 << ASM_REGNUM (LR_REGNUM));
2513 + /* Make sure that the GOT register is pushed. */
2514 + if (max_reg >= ASM_REGNUM (PIC_OFFSET_TABLE_REGNUM)
2515 + && current_function_uses_pic_offset_table)
2516 + save_reg_mask |= (1 << ASM_REGNUM (PIC_OFFSET_TABLE_REGNUM));
2521 + int use_pushm = optimize_size;
2523 + /* In the normal case we only need to save those registers which are
2524 + call saved and which are used by this function. */
2525 + for (reg = 0; reg <= 7; reg++)
2526 + if (df_regs_ever_live_p (INTERNAL_REGNUM (reg))
2527 + && !call_used_regs[INTERNAL_REGNUM (reg)])
2528 + save_reg_mask |= (1 << reg);
2530 + /* Make sure that the GOT register is pushed. */
2531 + if (current_function_uses_pic_offset_table)
2532 + save_reg_mask |= (1 << ASM_REGNUM (PIC_OFFSET_TABLE_REGNUM));
2535 + /* If we optimize for size and do not have anonymous arguments: use
2536 + pushm/popm always. */
2539 + if ((save_reg_mask & (1 << 0))
2540 + || (save_reg_mask & (1 << 1))
2541 + || (save_reg_mask & (1 << 2)) || (save_reg_mask & (1 << 3)))
2542 + save_reg_mask |= 0xf;
2544 + if ((save_reg_mask & (1 << 4))
2545 + || (save_reg_mask & (1 << 5))
2546 + || (save_reg_mask & (1 << 6)) || (save_reg_mask & (1 << 7)))
2547 + save_reg_mask |= 0xf0;
2549 + if ((save_reg_mask & (1 << 8)) || (save_reg_mask & (1 << 9)))
2550 + save_reg_mask |= 0x300;
2555 + if ((df_regs_ever_live_p (LR_REGNUM)
2556 + || !current_function_is_leaf
2559 + && !current_function_calls_eh_return)
2560 + || frame_pointer_needed)
2561 + && !IS_FLASHVAULT (func_type))
2564 + /* Never pop LR into PC for functions which
2565 + calls __builtin_eh_return, since we need to
2566 + fix the SP after the restoring of the registers
2567 + and before returning. */
2568 + || current_function_calls_eh_return)
2571 + save_reg_mask |= (1 << ASM_REGNUM (LR_REGNUM));
2576 + save_reg_mask |= (1 << ASM_REGNUM (PC_REGNUM));
2582 + /* Save registers so the exception handler can modify them. */
2583 + if (current_function_calls_eh_return)
2589 + reg = EH_RETURN_DATA_REGNO (i);
2590 + if (reg == INVALID_REGNUM)
2592 + save_reg_mask |= 1 << ASM_REGNUM (reg);
2596 + return save_reg_mask;
2600 +/* Compute total size in bytes of all saved registers. */
2602 +avr32_get_reg_mask_size (int reg_mask)
2607 + for (reg = 0; reg <= 15; reg++)
2608 + if (reg_mask & (1 << reg))
2615 +/* Get a register from one of the registers which are saved onto the stack
2616 + upon function entry. */
2618 +avr32_get_saved_reg (int save_reg_mask)
2622 + /* Find the first register which is saved in the saved_reg_mask */
2623 + for (reg = 0; reg <= 15; reg++)
2624 + if (save_reg_mask & (1 << reg))
2631 +/* Return 1 if it is possible to return using a single instruction. */
2633 +avr32_use_return_insn (int iscond)
2635 + unsigned int func_type = avr32_current_func_type ();
2636 + unsigned long saved_int_regs;
2638 + /* Never use a return instruction before reload has run. */
2639 + if (!reload_completed)
2642 + /* Must adjust the stack for vararg functions. */
2643 + if (current_function_args_info.uses_anonymous_args)
2646 + /* If there a stack adjstment. */
2647 + if (get_frame_size ())
2650 + saved_int_regs = avr32_compute_save_reg_mask (TRUE);
2652 + /* Conditional returns can not be performed in one instruction if we need
2653 + to restore registers from the stack */
2654 + if (iscond && saved_int_regs)
2657 + /* Conditional return can not be used for interrupt handlers. */
2658 + if (iscond && IS_INTERRUPT (func_type))
2661 + /* For interrupt handlers which needs to pop registers */
2662 + if (saved_int_regs && IS_INTERRUPT (func_type))
2666 + /* If there are saved registers but the LR isn't saved, then we need two
2667 + instructions for the return. */
2668 + if (saved_int_regs && !(saved_int_regs & (1 << ASM_REGNUM (LR_REGNUM))))
2676 +/* Generate some function prologue info in the assembly file. */
2678 +avr32_target_asm_function_prologue (FILE * f, HOST_WIDE_INT frame_size)
2680 + unsigned long func_type = avr32_current_func_type ();
2682 + if (IS_NAKED (func_type))
2684 + "\t# Function is naked: Prologue and epilogue provided by programmer\n");
2686 + if (IS_FLASHVAULT (func_type))
2689 + "\t.ident \"flashvault\"\n\t# Function is defined with flashvault attribute.\n");
2692 + if (IS_FLASHVAULT_IMPL (func_type))
2695 + "\t.ident \"flashvault\"\n\t# Function is defined with flashvault_impl attribute.\n");
2697 + /* Save information on flashvault function declaration. */
2698 + tree fv_attribute = lookup_attribute ("flashvault_impl", DECL_ATTRIBUTES(current_function_decl));
2699 + if (fv_attribute != NULL_TREE)
2701 + tree vector_tree = TREE_VALUE(fv_attribute);
2702 + if (vector_tree != NULL_TREE)
2704 + unsigned int vector_num;
2705 + const char * name;
2707 + vector_num = (unsigned int) TREE_INT_CST_LOW (TREE_VALUE (vector_tree));
2709 + name = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
2711 + flashvault_decl_list_add (vector_num, name);
2716 + if (IS_INTERRUPT (func_type))
2718 + switch (func_type)
2720 + case AVR32_FT_ISR_FULL:
2722 + "\t# Interrupt Function: Fully shadowed register file\n");
2724 + case AVR32_FT_ISR_HALF:
2726 + "\t# Interrupt Function: Half shadowed register file\n");
2729 + case AVR32_FT_ISR_NONE:
2730 + fprintf (f, "\t# Interrupt Function: No shadowed register file\n");
2736 + fprintf (f, "\t# args = %i, frame = %li, pretend = %i\n",
2737 + current_function_args_size, frame_size,
2738 + current_function_pretend_args_size);
2740 + fprintf (f, "\t# frame_needed = %i, leaf_function = %i\n",
2741 + frame_pointer_needed, current_function_is_leaf);
2743 + fprintf (f, "\t# uses_anonymous_args = %i\n",
2744 + current_function_args_info.uses_anonymous_args);
2746 + if (current_function_calls_eh_return)
2747 + fprintf (f, "\t# Calls __builtin_eh_return.\n");
2752 +/* Generate and emit an insn that we will recognize as a pushm or stm.
2753 + Unfortunately, since this insn does not reflect very well the actual
2754 + semantics of the operation, we need to annotate the insn for the benefit
2755 + of DWARF2 frame unwind information. */
2757 +int avr32_convert_to_reglist16 (int reglist8_vect);
2760 +emit_multi_reg_push (int reglist, int usePUSHM)
2772 + insn = emit_insn (gen_pushm (gen_rtx_CONST_INT (SImode, reglist)));
2773 + reglist = avr32_convert_to_reglist16 (reglist);
2777 + insn = emit_insn (gen_stm (stack_pointer_rtx,
2778 + gen_rtx_CONST_INT (SImode, reglist),
2779 + gen_rtx_CONST_INT (SImode, 1)));
2782 + nr_regs = avr32_get_reg_mask_size (reglist) / 4;
2783 + dwarf = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (nr_regs + 1));
2785 + for (i = 15; i >= 0; i--)
2787 + if (reglist & (1 << i))
2789 + reg = gen_rtx_REG (SImode, INTERNAL_REGNUM (i));
2790 + tmp = gen_rtx_SET (VOIDmode,
2791 + gen_rtx_MEM (SImode,
2792 + plus_constant (stack_pointer_rtx,
2793 + 4 * index)), reg);
2794 + RTX_FRAME_RELATED_P (tmp) = 1;
2795 + XVECEXP (dwarf, 0, 1 + index++) = tmp;
2799 + tmp = gen_rtx_SET (SImode,
2800 + stack_pointer_rtx,
2801 + gen_rtx_PLUS (SImode,
2802 + stack_pointer_rtx,
2803 + GEN_INT (-4 * nr_regs)));
2804 + RTX_FRAME_RELATED_P (tmp) = 1;
2805 + XVECEXP (dwarf, 0, 0) = tmp;
2806 + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR, dwarf,
2807 + REG_NOTES (insn));
2812 +avr32_gen_load_multiple (rtx * regs, int count, rtx from,
2813 + int write_back, int in_struct_p, int scalar_p)
2820 + gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + (write_back ? 1 : 0)));
2824 + XVECEXP (result, 0, 0)
2825 + = gen_rtx_SET (GET_MODE (from), from,
2826 + plus_constant (from, count * 4));
2832 + for (j = 0; i < count; i++, j++)
2835 + rtx mem = gen_rtx_MEM (SImode, plus_constant (from, j * 4));
2836 + MEM_IN_STRUCT_P (mem) = in_struct_p;
2837 + MEM_SCALAR_P (mem) = scalar_p;
2838 + unspec = gen_rtx_UNSPEC (VOIDmode, gen_rtvec (1, mem), UNSPEC_LDM);
2839 + XVECEXP (result, 0, i) = gen_rtx_SET (VOIDmode, regs[j], unspec);
2847 +avr32_gen_store_multiple (rtx * regs, int count, rtx to,
2848 + int in_struct_p, int scalar_p)
2853 + result = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2855 + for (j = 0; i < count; i++, j++)
2857 + rtx mem = gen_rtx_MEM (SImode, plus_constant (to, j * 4));
2858 + MEM_IN_STRUCT_P (mem) = in_struct_p;
2859 + MEM_SCALAR_P (mem) = scalar_p;
2860 + XVECEXP (result, 0, i)
2861 + = gen_rtx_SET (VOIDmode, mem,
2862 + gen_rtx_UNSPEC (VOIDmode,
2863 + gen_rtvec (1, regs[j]),
2864 + UNSPEC_STORE_MULTIPLE));
2871 +/* Move a block of memory if it is word aligned or we support unaligned
2872 + word memory accesses. The size must be maximum 64 bytes. */
2874 +avr32_gen_movmemsi (rtx * operands)
2876 + HOST_WIDE_INT bytes_to_go;
2878 + rtx st_src, st_dst;
2879 + int src_offset = 0, dst_offset = 0;
2881 + int dst_in_struct_p, src_in_struct_p;
2882 + int dst_scalar_p, src_scalar_p;
2885 + if (GET_CODE (operands[2]) != CONST_INT
2886 + || GET_CODE (operands[3]) != CONST_INT
2887 + || INTVAL (operands[2]) > 64
2888 + || ((INTVAL (operands[3]) & 3) && !TARGET_UNALIGNED_WORD))
2891 + unaligned = (INTVAL (operands[3]) & 3) != 0;
2895 + st_dst = XEXP (operands[0], 0);
2896 + st_src = XEXP (operands[1], 0);
2898 + dst_in_struct_p = MEM_IN_STRUCT_P (operands[0]);
2899 + dst_scalar_p = MEM_SCALAR_P (operands[0]);
2900 + src_in_struct_p = MEM_IN_STRUCT_P (operands[1]);
2901 + src_scalar_p = MEM_SCALAR_P (operands[1]);
2903 + dst = copy_to_mode_reg (SImode, st_dst);
2904 + src = copy_to_mode_reg (SImode, st_src);
2906 + bytes_to_go = INTVAL (operands[2]);
2908 + while (bytes_to_go)
2910 + enum machine_mode move_mode;
2911 + /* (Seems to be a problem with reloads for the movti pattern so this is
2912 + disabled until that problem is resolved)
2913 + UPDATE: Problem seems to be solved now.... */
2914 + if (bytes_to_go >= GET_MODE_SIZE (TImode) && !unaligned
2915 + /* Do not emit ldm/stm for UC3 as ld.d/st.d is more optimal. */
2916 + && !TARGET_ARCH_UC)
2917 + move_mode = TImode;
2918 + else if ((bytes_to_go >= GET_MODE_SIZE (DImode)) && !unaligned)
2919 + move_mode = DImode;
2920 + else if (bytes_to_go >= GET_MODE_SIZE (SImode))
2921 + move_mode = SImode;
2923 + move_mode = QImode;
2927 + rtx dst_mem = gen_rtx_MEM (move_mode,
2928 + gen_rtx_PLUS (SImode, dst,
2929 + GEN_INT (dst_offset)));
2930 + dst_offset += GET_MODE_SIZE (move_mode);
2931 + if ( 0 /* This causes an error in GCC. Think there is
2932 + something wrong in the gcse pass which causes REQ_EQUIV notes
2933 + to be wrong so disabling it for now. */
2934 + && move_mode == TImode
2935 + && INTVAL (operands[2]) > GET_MODE_SIZE (TImode) )
2937 + src_mem = gen_rtx_MEM (move_mode,
2938 + gen_rtx_POST_INC (SImode, src));
2942 + src_mem = gen_rtx_MEM (move_mode,
2943 + gen_rtx_PLUS (SImode, src,
2944 + GEN_INT (src_offset)));
2945 + src_offset += GET_MODE_SIZE (move_mode);
2948 + bytes_to_go -= GET_MODE_SIZE (move_mode);
2950 + MEM_IN_STRUCT_P (dst_mem) = dst_in_struct_p;
2951 + MEM_SCALAR_P (dst_mem) = dst_scalar_p;
2953 + MEM_IN_STRUCT_P (src_mem) = src_in_struct_p;
2954 + MEM_SCALAR_P (src_mem) = src_scalar_p;
2955 + emit_move_insn (dst_mem, src_mem);
2964 +/* Expand the prologue instruction. */
2966 +avr32_expand_prologue (void)
2969 + unsigned long saved_reg_mask;
2972 + /* Naked functions do not have a prologue. */
2973 + if (IS_NAKED (avr32_current_func_type ()))
2976 + saved_reg_mask = avr32_compute_save_reg_mask (TRUE);
2978 + if (saved_reg_mask)
2980 + /* Must push used registers. */
2982 + /* Should we use POPM or LDM? */
2983 + int usePUSHM = TRUE;
2985 + if (((saved_reg_mask & (1 << 0)) ||
2986 + (saved_reg_mask & (1 << 1)) ||
2987 + (saved_reg_mask & (1 << 2)) || (saved_reg_mask & (1 << 3))))
2989 + /* One of R0-R3 should at least be pushed. */
2990 + if (((saved_reg_mask & (1 << 0)) &&
2991 + (saved_reg_mask & (1 << 1)) &&
2992 + (saved_reg_mask & (1 << 2)) && (saved_reg_mask & (1 << 3))))
2994 + /* All should be pushed. */
3003 + if (((saved_reg_mask & (1 << 4)) ||
3004 + (saved_reg_mask & (1 << 5)) ||
3005 + (saved_reg_mask & (1 << 6)) || (saved_reg_mask & (1 << 7))))
3007 + /* One of R4-R7 should at least be pushed */
3008 + if (((saved_reg_mask & (1 << 4)) &&
3009 + (saved_reg_mask & (1 << 5)) &&
3010 + (saved_reg_mask & (1 << 6)) && (saved_reg_mask & (1 << 7))))
3013 + /* All should be pushed */
3022 + if (((saved_reg_mask & (1 << 8)) || (saved_reg_mask & (1 << 9))))
3024 + /* One of R8-R9 should at least be pushed. */
3025 + if (((saved_reg_mask & (1 << 8)) && (saved_reg_mask & (1 << 9))))
3028 + /* All should be pushed. */
3037 + if (saved_reg_mask & (1 << 10))
3040 + if (saved_reg_mask & (1 << 11))
3043 + if (saved_reg_mask & (1 << 12))
3046 + if ((saved_reg_mask & (1 << ASM_REGNUM (LR_REGNUM)))
3047 + && !IS_FLASHVAULT (avr32_current_func_type ()))
3055 + insn = emit_multi_reg_push (reglist8, TRUE);
3059 + insn = emit_multi_reg_push (saved_reg_mask, FALSE);
3061 + RTX_FRAME_RELATED_P (insn) = 1;
3063 + /* Prevent this instruction from being scheduled after any other
3065 + emit_insn (gen_blockage ());
3068 + /* Set frame pointer */
3069 + if (frame_pointer_needed)
3071 + insn = emit_move_insn (frame_pointer_rtx, stack_pointer_rtx);
3072 + RTX_FRAME_RELATED_P (insn) = 1;
3075 + if (get_frame_size () > 0)
3077 + if (avr32_const_ok_for_constraint_p (get_frame_size (), 'K', "Ks21"))
3079 + insn = emit_insn (gen_rtx_SET (SImode,
3080 + stack_pointer_rtx,
3081 + gen_rtx_PLUS (SImode,
3082 + stack_pointer_rtx,
3087 + RTX_FRAME_RELATED_P (insn) = 1;
3091 + /* Immediate is larger than k21 We must either check if we can use
3092 + one of the pushed reegisters as temporary storage or we must
3093 + make us a temp register by pushing a register to the stack. */
3094 + rtx temp_reg, const_pool_entry, insn;
3095 + if (saved_reg_mask)
3098 + gen_rtx_REG (SImode,
3099 + INTERNAL_REGNUM (avr32_get_saved_reg
3100 + (saved_reg_mask)));
3104 + temp_reg = gen_rtx_REG (SImode, INTERNAL_REGNUM (7));
3105 + emit_move_insn (gen_rtx_MEM
3107 + gen_rtx_PRE_DEC (SImode, stack_pointer_rtx)),
3111 + const_pool_entry =
3112 + force_const_mem (SImode,
3113 + gen_rtx_CONST_INT (SImode, get_frame_size ()));
3114 + emit_move_insn (temp_reg, const_pool_entry);
3116 + insn = emit_insn (gen_rtx_SET (SImode,
3117 + stack_pointer_rtx,
3118 + gen_rtx_MINUS (SImode,
3119 + stack_pointer_rtx,
3122 + dwarf = gen_rtx_SET (VOIDmode, stack_pointer_rtx,
3123 + gen_rtx_PLUS (SImode, stack_pointer_rtx,
3124 + GEN_INT (-get_frame_size ())));
3125 + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
3126 + dwarf, REG_NOTES (insn));
3127 + RTX_FRAME_RELATED_P (insn) = 1;
3129 + if (!saved_reg_mask)
3132 + emit_move_insn (temp_reg,
3133 + gen_rtx_MEM (SImode,
3134 + gen_rtx_POST_INC (SImode,
3140 + /* Mark the temp register as dead */
3141 + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_DEAD, temp_reg,
3142 + REG_NOTES (insn));
3147 + /* Prevent the the stack adjustment to be scheduled after any
3148 + instructions using the frame pointer. */
3149 + emit_insn (gen_blockage ());
3155 + avr32_load_pic_register ();
3157 + /* gcc does not know that load or call instructions might use the pic
3158 + register so it might schedule these instructions before the loading
3159 + of the pic register. To avoid this emit a barrier for now. TODO!
3160 + Find out a better way to let gcc know which instructions might use
3161 + the pic register. */
3162 + emit_insn (gen_blockage ());
3169 +avr32_set_return_address (rtx source, rtx scratch)
3172 + unsigned long saved_regs;
3174 + saved_regs = avr32_compute_save_reg_mask (TRUE);
3176 + if (!(saved_regs & (1 << ASM_REGNUM (LR_REGNUM))))
3177 + emit_move_insn (gen_rtx_REG (Pmode, LR_REGNUM), source);
3180 + if (frame_pointer_needed)
3181 + addr = gen_rtx_REG (Pmode, FRAME_POINTER_REGNUM);
3183 + if (avr32_const_ok_for_constraint_p (get_frame_size (), 'K', "Ks16"))
3185 + addr = plus_constant (stack_pointer_rtx, get_frame_size ());
3189 + emit_insn (gen_movsi (scratch, GEN_INT (get_frame_size ())));
3192 + emit_move_insn (gen_rtx_MEM (Pmode, addr), source);
3197 +/* Return the length of INSN. LENGTH is the initial length computed by
3198 + attributes in the machine-description file. */
3200 +avr32_adjust_insn_length (rtx insn ATTRIBUTE_UNUSED,
3201 + int length ATTRIBUTE_UNUSED)
3208 +avr32_output_return_instruction (int single_ret_inst ATTRIBUTE_UNUSED,
3209 + int iscond ATTRIBUTE_UNUSED,
3210 + rtx cond ATTRIBUTE_UNUSED, rtx r12_imm)
3213 + unsigned long saved_reg_mask;
3214 + int insert_ret = TRUE;
3216 + int stack_adjustment = get_frame_size ();
3217 + unsigned int func_type = avr32_current_func_type ();
3218 + FILE *f = asm_out_file;
3220 + /* Naked functions does not have an epilogue */
3221 + if (IS_NAKED (func_type))
3224 + saved_reg_mask = avr32_compute_save_reg_mask (FALSE);
3226 + /* Reset frame pointer */
3227 + if (stack_adjustment > 0)
3229 + if (avr32_const_ok_for_constraint_p (stack_adjustment, 'I', "Is21"))
3231 + fprintf (f, "\tsub\tsp, %i # Reset Frame Pointer\n",
3232 + -stack_adjustment);
3236 + /* TODO! Is it safe to use r8 as scratch?? */
3237 + fprintf (f, "\tmov\tr8, lo(%i) # Reset Frame Pointer\n",
3238 + -stack_adjustment);
3239 + fprintf (f, "\torh\tr8, hi(%i) # Reset Frame Pointer\n",
3240 + -stack_adjustment);
3241 + fprintf (f, "\tadd\tsp, r8 # Reset Frame Pointer\n");
3245 + if (saved_reg_mask)
3247 + /* Must pop used registers */
3249 + /* Should we use POPM or LDM? */
3250 + int usePOPM = TRUE;
3251 + if (((saved_reg_mask & (1 << 0)) ||
3252 + (saved_reg_mask & (1 << 1)) ||
3253 + (saved_reg_mask & (1 << 2)) || (saved_reg_mask & (1 << 3))))
3255 + /* One of R0-R3 should at least be popped */
3256 + if (((saved_reg_mask & (1 << 0)) &&
3257 + (saved_reg_mask & (1 << 1)) &&
3258 + (saved_reg_mask & (1 << 2)) && (saved_reg_mask & (1 << 3))))
3260 + /* All should be popped */
3269 + if (((saved_reg_mask & (1 << 4)) ||
3270 + (saved_reg_mask & (1 << 5)) ||
3271 + (saved_reg_mask & (1 << 6)) || (saved_reg_mask & (1 << 7))))
3273 + /* One of R0-R3 should at least be popped */
3274 + if (((saved_reg_mask & (1 << 4)) &&
3275 + (saved_reg_mask & (1 << 5)) &&
3276 + (saved_reg_mask & (1 << 6)) && (saved_reg_mask & (1 << 7))))
3279 + /* All should be popped */
3288 + if (((saved_reg_mask & (1 << 8)) || (saved_reg_mask & (1 << 9))))
3290 + /* One of R8-R9 should at least be pushed */
3291 + if (((saved_reg_mask & (1 << 8)) && (saved_reg_mask & (1 << 9))))
3294 + /* All should be pushed */
3303 + if (saved_reg_mask & (1 << 10))
3306 + if (saved_reg_mask & (1 << 11))
3309 + if (saved_reg_mask & (1 << 12))
3312 + if (saved_reg_mask & (1 << ASM_REGNUM (LR_REGNUM)))
3316 + if ((saved_reg_mask & (1 << ASM_REGNUM (PC_REGNUM)))
3317 + && !IS_FLASHVAULT_IMPL (func_type))
3318 + /* Pop LR into PC. */
3323 + char reglist[64]; /* 64 bytes should be enough... */
3324 + avr32_make_reglist8 (reglist8, (char *) reglist);
3326 + if (reglist8 & 0x80)
3327 + /* This instruction is also a return */
3328 + insert_ret = FALSE;
3330 + if (r12_imm && !insert_ret)
3331 + fprintf (f, "\tpopm\t%s, r12=%li\n", reglist, INTVAL (r12_imm));
3333 + fprintf (f, "\tpopm\t%s\n", reglist);
3338 + char reglist[64]; /* 64 bytes should be enough... */
3339 + avr32_make_reglist16 (saved_reg_mask, (char *) reglist);
3340 + if (saved_reg_mask & (1 << ASM_REGNUM (PC_REGNUM)))
3341 + /* This instruction is also a return */
3342 + insert_ret = FALSE;
3344 + if (r12_imm && !insert_ret)
3345 + fprintf (f, "\tldm\tsp++, %s, r12=%li\n", reglist,
3346 + INTVAL (r12_imm));
3348 + fprintf (f, "\tldm\tsp++, %s\n", reglist);
3354 + /* Stack adjustment for exception handler. */
3355 + if (current_function_calls_eh_return)
3356 + fprintf (f, "\tadd\tsp, r%d\n", ASM_REGNUM (EH_RETURN_STACKADJ_REGNO));
3359 + if (IS_INTERRUPT (func_type))
3361 + fprintf (f, "\trete\n");
3363 + else if (IS_FLASHVAULT (func_type))
3365 + /* Normal return from Secure System call, increment SS_RAR before
3366 + returning. Use R8 as scratch. */
3368 + "\t# Normal return from sscall.\n"
3369 + "\t# Increment SS_RAR before returning.\n"
3370 + "\t# Use R8 as scratch.\n"
3371 + "\tmfsr\tr8, 440\n"
3373 + "\tmtsr\t440, r8\n"
3376 + else if (insert_ret)
3379 + fprintf (f, "\tretal\t%li\n", INTVAL (r12_imm));
3381 + fprintf (f, "\tretal\tr12\n");
3386 +avr32_make_reglist16 (int reglist16_vect, char *reglist16_string)
3389 + bool first_reg = true;
3390 + /* Make sure reglist16_string is empty. */
3391 + reglist16_string[0] = '\0';
3393 + for (i = 0; i < 16; ++i)
3395 + if (reglist16_vect & (1 << i))
3397 + first_reg == true ? first_reg = false : strcat(reglist16_string,", ");
3398 + strcat (reglist16_string, reg_names[INTERNAL_REGNUM (i)]);
3404 +avr32_convert_to_reglist16 (int reglist8_vect)
3406 + int reglist16_vect = 0;
3407 + if (reglist8_vect & 0x1)
3408 + reglist16_vect |= 0xF;
3409 + if (reglist8_vect & 0x2)
3410 + reglist16_vect |= 0xF0;
3411 + if (reglist8_vect & 0x4)
3412 + reglist16_vect |= 0x300;
3413 + if (reglist8_vect & 0x8)
3414 + reglist16_vect |= 0x400;
3415 + if (reglist8_vect & 0x10)
3416 + reglist16_vect |= 0x800;
3417 + if (reglist8_vect & 0x20)
3418 + reglist16_vect |= 0x1000;
3419 + if (reglist8_vect & 0x40)
3420 + reglist16_vect |= 0x4000;
3421 + if (reglist8_vect & 0x80)
3422 + reglist16_vect |= 0x8000;
3424 + return reglist16_vect;
3428 +avr32_make_reglist8 (int reglist8_vect, char *reglist8_string)
3430 + /* Make sure reglist8_string is empty. */
3431 + reglist8_string[0] = '\0';
3433 + if (reglist8_vect & 0x1)
3434 + strcpy (reglist8_string, "r0-r3");
3435 + if (reglist8_vect & 0x2)
3436 + strlen (reglist8_string) ? strcat (reglist8_string, ", r4-r7") :
3437 + strcpy (reglist8_string, "r4-r7");
3438 + if (reglist8_vect & 0x4)
3439 + strlen (reglist8_string) ? strcat (reglist8_string, ", r8-r9") :
3440 + strcpy (reglist8_string, "r8-r9");
3441 + if (reglist8_vect & 0x8)
3442 + strlen (reglist8_string) ? strcat (reglist8_string, ", r10") :
3443 + strcpy (reglist8_string, "r10");
3444 + if (reglist8_vect & 0x10)
3445 + strlen (reglist8_string) ? strcat (reglist8_string, ", r11") :
3446 + strcpy (reglist8_string, "r11");
3447 + if (reglist8_vect & 0x20)
3448 + strlen (reglist8_string) ? strcat (reglist8_string, ", r12") :
3449 + strcpy (reglist8_string, "r12");
3450 + if (reglist8_vect & 0x40)
3451 + strlen (reglist8_string) ? strcat (reglist8_string, ", lr") :
3452 + strcpy (reglist8_string, "lr");
3453 + if (reglist8_vect & 0x80)
3454 + strlen (reglist8_string) ? strcat (reglist8_string, ", pc") :
3455 + strcpy (reglist8_string, "pc");
3460 +avr32_eh_return_data_regno (int n)
3462 + if (n >= 0 && n <= 3)
3465 + return INVALID_REGNUM;
3469 +/* Compute the distance from register FROM to register TO.
3470 + These can be the arg pointer, the frame pointer or
3471 + the stack pointer.
3472 + Typical stack layout looks like this:
3474 + old stack pointer -> | |
3477 + | | saved arguments for
3478 + | | vararg functions
3479 + arg_pointer -> | | /
3489 + stack ptr --> | | /
3497 + For a given funciton some or all of these stack compomnents
3498 + may not be needed, giving rise to the possibility of
3499 + eliminating some of the registers.
3501 + The values returned by this function must reflect the behaviour
3502 + of avr32_expand_prologue() and avr32_compute_save_reg_mask().
3504 + The sign of the number returned reflects the direction of stack
3505 + growth, so the values are positive for all eliminations except
3506 + from the soft frame pointer to the hard frame pointer. */
3508 +avr32_initial_elimination_offset (int from, int to)
3511 + int call_saved_regs = 0;
3512 + unsigned long saved_reg_mask;
3513 + unsigned int local_vars = get_frame_size ();
3515 + saved_reg_mask = avr32_compute_save_reg_mask (TRUE);
3517 + for (i = 0; i < 16; ++i)
3519 + if (saved_reg_mask & (1 << i))
3520 + call_saved_regs += 4;
3525 + case ARG_POINTER_REGNUM:
3528 + case STACK_POINTER_REGNUM:
3529 + return call_saved_regs + local_vars;
3530 + case FRAME_POINTER_REGNUM:
3531 + return call_saved_regs;
3535 + case FRAME_POINTER_REGNUM:
3538 + case STACK_POINTER_REGNUM:
3539 + return local_vars;
3550 + Returns a rtx used when passing the next argument to a function.
3551 + avr32_init_cumulative_args() and avr32_function_arg_advance() sets which
3555 +avr32_function_arg (CUMULATIVE_ARGS * cum, enum machine_mode mode,
3556 + tree type, int named)
3559 + //unsigned long func_type = avr32_current_func_type ();
3560 + //int last_reg_index = (IS_FLASHVAULT(func_type) || IS_FLASHVAULT_IMPL(func_type) || cum->flashvault_func ? LAST_CUM_REG_INDEX - 1 : LAST_CUM_REG_INDEX);
3561 + int last_reg_index = (cum->flashvault_func ? LAST_CUM_REG_INDEX - 1 : LAST_CUM_REG_INDEX);
3563 + HOST_WIDE_INT arg_size, arg_rsize;
3566 + arg_size = int_size_in_bytes (type);
3570 + arg_size = GET_MODE_SIZE (mode);
3572 + arg_rsize = PUSH_ROUNDING (arg_size);
3575 + The last time this macro is called, it is called with mode == VOIDmode,
3576 + and its result is passed to the call or call_value pattern as operands 2
3577 + and 3 respectively. */
3578 + if (mode == VOIDmode)
3580 + return gen_rtx_CONST_INT (SImode, 22); /* ToDo: fixme. */
3583 + if ((*targetm.calls.must_pass_in_stack) (mode, type) || !named)
3588 + if (arg_rsize == 8)
3590 + /* use r11:r10 or r9:r8. */
3591 + if (!(GET_USED_INDEX (cum, 1) || GET_USED_INDEX (cum, 2)))
3593 + else if ((last_reg_index == 4) &&
3594 + !(GET_USED_INDEX (cum, 3) || GET_USED_INDEX (cum, 4)))
3599 + else if (arg_rsize == 4)
3600 + { /* Use first available register */
3602 + while (index <= last_reg_index && GET_USED_INDEX (cum, index))
3604 + if (index > last_reg_index)
3608 + SET_REG_INDEX (cum, index);
3610 + if (GET_REG_INDEX (cum) >= 0)
3611 + return gen_rtx_REG (mode, avr32_function_arg_reglist[GET_REG_INDEX (cum)]);
3617 +/* Set the register used for passing the first argument to a function. */
3619 +avr32_init_cumulative_args (CUMULATIVE_ARGS * cum,
3620 + tree fntype ATTRIBUTE_UNUSED,
3621 + rtx libname ATTRIBUTE_UNUSED,
3624 + /* Set all registers as unused. */
3625 + SET_INDEXES_UNUSED (cum);
3627 + /* Reset uses_anonymous_args */
3628 + cum->uses_anonymous_args = 0;
3630 + /* Reset size of stack pushed arguments */
3631 + cum->stack_pushed_args_size = 0;
3633 + cum->flashvault_func = (fndecl && (has_attribute_p (fndecl,"flashvault") || has_attribute_p (fndecl,"flashvault_impl")));
3638 + Set register used for passing the next argument to a function. Only the
3639 + Scratch Registers are used.
3644 + 13 r13 _SP_________
3645 + FIRST_CUM_REG 12 r12 _||_
3647 + 11 r10 _||_ Scratch Registers
3649 + LAST_SCRATCH_REG 9 r8 _\/_________
3661 +avr32_function_arg_advance (CUMULATIVE_ARGS * cum, enum machine_mode mode,
3662 + tree type, int named ATTRIBUTE_UNUSED)
3664 + HOST_WIDE_INT arg_size, arg_rsize;
3668 + arg_size = int_size_in_bytes (type);
3672 + arg_size = GET_MODE_SIZE (mode);
3674 + arg_rsize = PUSH_ROUNDING (arg_size);
3676 + /* If the argument had to be passed in stack, no register is used. */
3677 + if ((*targetm.calls.must_pass_in_stack) (mode, type))
3679 + cum->stack_pushed_args_size += PUSH_ROUNDING (int_size_in_bytes (type));
3683 + /* Mark the used registers as "used". */
3684 + if (GET_REG_INDEX (cum) >= 0)
3686 + SET_USED_INDEX (cum, GET_REG_INDEX (cum));
3687 + if (arg_rsize == 8)
3689 + SET_USED_INDEX (cum, (GET_REG_INDEX (cum) + 1));
3694 + /* Had to use stack */
3695 + cum->stack_pushed_args_size += arg_rsize;
3701 + Defines witch direction to go to find the next register to use if the
3702 + argument is larger then one register or for arguments shorter than an
3703 + int which is not promoted, such as the last part of structures with
3704 + size not a multiple of 4. */
3706 +avr32_function_arg_padding (enum machine_mode mode ATTRIBUTE_UNUSED,
3709 + /* Pad upward for all aggregates except byte and halfword sized aggregates
3710 + which can be passed in registers. */
3712 + && AGGREGATE_TYPE_P (type)
3713 + && (int_size_in_bytes (type) != 1)
3714 + && !((int_size_in_bytes (type) == 2)
3715 + && TYPE_ALIGN_UNIT (type) >= 2)
3716 + && (int_size_in_bytes (type) & 0x3))
3725 +/* Return a rtx used for the return value from a function call. */
3727 +avr32_function_value (tree type, tree func, bool outgoing ATTRIBUTE_UNUSED)
3729 + if (avr32_return_in_memory (type, func))
3732 + if (int_size_in_bytes (type) <= 4)
3734 + enum machine_mode mode = TYPE_MODE (type);
3735 + int unsignedp = 0;
3736 + PROMOTE_FUNCTION_MODE (mode, unsignedp, type);
3737 + return gen_rtx_REG (mode, RET_REGISTER);
3739 + else if (int_size_in_bytes (type) <= 8)
3740 + return gen_rtx_REG (TYPE_MODE (type), INTERNAL_REGNUM (11));
3746 +/* Return a rtx used for the return value from a library function call. */
3748 +avr32_libcall_value (enum machine_mode mode)
3751 + if (GET_MODE_SIZE (mode) <= 4)
3752 + return gen_rtx_REG (mode, RET_REGISTER);
3753 + else if (GET_MODE_SIZE (mode) <= 8)
3754 + return gen_rtx_REG (mode, INTERNAL_REGNUM (11));
3760 +/* Return TRUE if X references a SYMBOL_REF. */
3762 +symbol_mentioned_p (rtx x)
3767 + if (GET_CODE (x) == SYMBOL_REF)
3770 + fmt = GET_RTX_FORMAT (GET_CODE (x));
3772 + for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
3774 + if (fmt[i] == 'E')
3778 + for (j = XVECLEN (x, i) - 1; j >= 0; j--)
3779 + if (symbol_mentioned_p (XVECEXP (x, i, j)))
3782 + else if (fmt[i] == 'e' && symbol_mentioned_p (XEXP (x, i)))
3790 +/* Return TRUE if X references a LABEL_REF. */
3792 +label_mentioned_p (rtx x)
3797 + if (GET_CODE (x) == LABEL_REF)
3800 + fmt = GET_RTX_FORMAT (GET_CODE (x));
3801 + for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
3803 + if (fmt[i] == 'E')
3807 + for (j = XVECLEN (x, i) - 1; j >= 0; j--)
3808 + if (label_mentioned_p (XVECEXP (x, i, j)))
3811 + else if (fmt[i] == 'e' && label_mentioned_p (XEXP (x, i)))
3819 +/* Return TRUE if X contains a MEM expression. */
3821 +mem_mentioned_p (rtx x)
3829 + fmt = GET_RTX_FORMAT (GET_CODE (x));
3830 + for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
3832 + if (fmt[i] == 'E')
3836 + for (j = XVECLEN (x, i) - 1; j >= 0; j--)
3837 + if (mem_mentioned_p (XVECEXP (x, i, j)))
3840 + else if (fmt[i] == 'e' && mem_mentioned_p (XEXP (x, i)))
3849 +avr32_legitimate_pic_operand_p (rtx x)
3852 + /* We can't have const, this must be broken down to a symbol. */
3853 + if (GET_CODE (x) == CONST)
3856 + /* Can't access symbols or labels via the constant pool either */
3857 + if ((GET_CODE (x) == SYMBOL_REF
3858 + && CONSTANT_POOL_ADDRESS_P (x)
3859 + && (symbol_mentioned_p (get_pool_constant (x))
3860 + || label_mentioned_p (get_pool_constant (x)))))
3868 +legitimize_pic_address (rtx orig, enum machine_mode mode ATTRIBUTE_UNUSED,
3872 + if (GET_CODE (orig) == SYMBOL_REF || GET_CODE (orig) == LABEL_REF)
3878 + if (!can_create_pseudo_p ())
3881 + reg = gen_reg_rtx (Pmode);
3886 + emit_move_insn (reg, orig);
3888 + /* Only set current function as using pic offset table if flag_pic is
3889 + set. This is because this function is also used if
3890 + TARGET_HAS_ASM_ADDR_PSEUDOS is set. */
3892 + current_function_uses_pic_offset_table = 1;
3894 + /* Put a REG_EQUAL note on this insn, so that it can be optimized by
3898 + else if (GET_CODE (orig) == CONST)
3903 + && GET_CODE (XEXP (orig, 0)) == PLUS
3904 + && XEXP (XEXP (orig, 0), 0) == pic_offset_table_rtx)
3909 + if (!can_create_pseudo_p ())
3912 + reg = gen_reg_rtx (Pmode);
3915 + if (GET_CODE (XEXP (orig, 0)) == PLUS)
3918 + legitimize_pic_address (XEXP (XEXP (orig, 0), 0), Pmode, reg);
3920 + legitimize_pic_address (XEXP (XEXP (orig, 0), 1), Pmode,
3921 + base == reg ? 0 : reg);
3926 + if (GET_CODE (offset) == CONST_INT)
3928 + /* The base register doesn't really matter, we only want to test
3929 + the index for the appropriate mode. */
3930 + if (!avr32_const_ok_for_constraint_p (INTVAL (offset), 'I', "Is21"))
3932 + if (can_create_pseudo_p ())
3933 + offset = force_reg (Pmode, offset);
3938 + if (GET_CODE (offset) == CONST_INT)
3939 + return plus_constant (base, INTVAL (offset));
3942 + return gen_rtx_PLUS (Pmode, base, offset);
3949 +/* Generate code to load the PIC register. */
3951 +avr32_load_pic_register (void)
3954 + rtx global_offset_table;
3956 + if ((current_function_uses_pic_offset_table == 0) || TARGET_NO_INIT_GOT)
3962 + l1 = gen_label_rtx ();
3964 + global_offset_table = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
3966 + gen_rtx_CONST (Pmode,
3967 + gen_rtx_MINUS (SImode, gen_rtx_LABEL_REF (Pmode, l1),
3968 + global_offset_table));
3969 + emit_insn (gen_pic_load_addr
3970 + (pic_offset_table_rtx, force_const_mem (SImode, pic_tmp)));
3971 + emit_insn (gen_pic_compute_got_from_pc (pic_offset_table_rtx, l1));
3973 + /* Need to emit this whether or not we obey regdecls, since setjmp/longjmp
3974 + can cause life info to screw up. */
3975 + emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
3979 +/* This hook should return true if values of type type are returned at the most
3980 + significant end of a register (in other words, if they are padded at the
3981 + least significant end). You can assume that type is returned in a register;
3982 + the caller is required to check this. Note that the register provided by
3983 + FUNCTION_VALUE must be able to hold the complete return value. For example,
3984 + if a 1-, 2- or 3-byte structure is returned at the most significant end of a
3985 + 4-byte register, FUNCTION_VALUE should provide an SImode rtx. */
3987 +avr32_return_in_msb (tree type ATTRIBUTE_UNUSED)
3989 + /* if ( AGGREGATE_TYPE_P (type) ) if ((int_size_in_bytes(type) == 1) ||
3990 + ((int_size_in_bytes(type) == 2) && TYPE_ALIGN_UNIT(type) >= 2)) return
3991 + false; else return true; */
3998 + Returns one if a certain function value is going to be returned in memory
3999 + and zero if it is going to be returned in a register.
4001 + BLKmode and all other modes that is larger than 64 bits are returned in
4005 +avr32_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
4007 + if (TYPE_MODE (type) == VOIDmode)
4010 + if (int_size_in_bytes (type) > (2 * UNITS_PER_WORD)
4011 + || int_size_in_bytes (type) == -1)
4016 + /* If we have an aggregate then use the same mechanism as when checking if
4017 + it should be passed on the stack. */
4019 + && AGGREGATE_TYPE_P (type)
4020 + && (*targetm.calls.must_pass_in_stack) (TYPE_MODE (type), type))
4027 +/* Output the constant part of the trampoline.
4028 + lddpc r0, pc[0x8:e] ; load static chain register
4029 + lddpc pc, pc[0x8:e] ; jump to subrutine
4030 + .long 0 ; Address to static chain,
4031 + ; filled in by avr32_initialize_trampoline()
4032 + .long 0 ; Address to subrutine,
4033 + ; filled in by avr32_initialize_trampoline()
4036 +avr32_trampoline_template (FILE * file)
4038 + fprintf (file, "\tlddpc r0, pc[8]\n");
4039 + fprintf (file, "\tlddpc pc, pc[8]\n");
4040 + /* make room for the address of the static chain. */
4041 + fprintf (file, "\t.long\t0\n");
4042 + /* make room for the address to the subrutine. */
4043 + fprintf (file, "\t.long\t0\n");
4047 +/* Initialize the variable parts of a trampoline. */
4049 +avr32_initialize_trampoline (rtx addr, rtx fnaddr, rtx static_chain)
4051 + /* Store the address to the static chain. */
4052 + emit_move_insn (gen_rtx_MEM
4053 + (SImode, plus_constant (addr, TRAMPOLINE_SIZE - 4)),
4056 + /* Store the address to the function. */
4057 + emit_move_insn (gen_rtx_MEM (SImode, plus_constant (addr, TRAMPOLINE_SIZE)),
4060 + emit_insn (gen_cache (gen_rtx_REG (SImode, 13),
4061 + gen_rtx_CONST_INT (SImode,
4062 + AVR32_CACHE_INVALIDATE_ICACHE)));
4066 +/* Return nonzero if X is valid as an addressing register. */
4068 +avr32_address_register_rtx_p (rtx x, int strict_p)
4072 + if (!register_operand(x, GET_MODE(x)))
4075 + /* If strict we require the register to be a hard register. */
4080 + regno = REGNO (x);
4083 + return REGNO_OK_FOR_BASE_P (regno);
4085 + return (regno <= LAST_REGNUM || regno >= FIRST_PSEUDO_REGISTER);
4089 +/* Return nonzero if INDEX is valid for an address index operand. */
4091 +avr32_legitimate_index_p (enum machine_mode mode, rtx index, int strict_p)
4093 + enum rtx_code code = GET_CODE (index);
4095 + if (GET_MODE_SIZE (mode) > 8)
4098 + /* Standard coprocessor addressing modes. */
4099 + if (code == CONST_INT)
4101 + return CONST_OK_FOR_CONSTRAINT_P (INTVAL (index), 'K', "Ks16");
4104 + if (avr32_address_register_rtx_p (index, strict_p))
4109 + rtx xiop0 = XEXP (index, 0);
4110 + rtx xiop1 = XEXP (index, 1);
4111 + return ((avr32_address_register_rtx_p (xiop0, strict_p)
4112 + && power_of_two_operand (xiop1, SImode)
4113 + && (INTVAL (xiop1) <= 8))
4114 + || (avr32_address_register_rtx_p (xiop1, strict_p)
4115 + && power_of_two_operand (xiop0, SImode)
4116 + && (INTVAL (xiop0) <= 8)));
4118 + else if (code == ASHIFT)
4120 + rtx op = XEXP (index, 1);
4122 + return (avr32_address_register_rtx_p (XEXP (index, 0), strict_p)
4123 + && GET_CODE (op) == CONST_INT
4124 + && INTVAL (op) > 0 && INTVAL (op) <= 3);
4132 + Used in the GO_IF_LEGITIMATE_ADDRESS macro. Returns a nonzero value if
4133 + the RTX x is a legitimate memory address.
4135 + Returns NO_REGS if the address is not legatime, GENERAL_REGS or ALL_REGS
4140 +/* Forward declaration */
4141 +int is_minipool_label (rtx label);
4144 +avr32_legitimate_address (enum machine_mode mode, rtx x, int strict)
4147 + switch (GET_CODE (x))
4150 + return avr32_address_register_rtx_p (x, strict);
4152 + return ((mode==SImode) && TARGET_RMW_ADDRESSABLE_DATA
4153 + && CONST_OK_FOR_CONSTRAINT_P(INTVAL(x), 'K', "Ks17"));
4156 + rtx label = avr32_find_symbol (x);
4160 + If we enable (const (plus (symbol_ref ...))) type constant
4161 + pool entries we must add support for it in the predicates and
4162 + in the minipool generation in avr32_reorg().
4163 + (CONSTANT_POOL_ADDRESS_P (label)
4165 + && (symbol_mentioned_p (get_pool_constant (label))
4166 + || label_mentioned_p (get_pool_constant (label)))))
4168 + ((GET_CODE (label) == LABEL_REF)
4169 + && GET_CODE (XEXP (label, 0)) == CODE_LABEL
4170 + && is_minipool_label (XEXP (label, 0)))
4171 + /*|| ((GET_CODE (label) == SYMBOL_REF)
4173 + && SYMBOL_REF_RMW_ADDR(label))*/))
4180 + if (GET_CODE (XEXP (x, 0)) == CODE_LABEL
4181 + && is_minipool_label (XEXP (x, 0)))
4188 + if (CONSTANT_POOL_ADDRESS_P (x)
4190 + && (symbol_mentioned_p (get_pool_constant (x))
4191 + || label_mentioned_p (get_pool_constant (x)))))
4193 + else if (SYMBOL_REF_RCALL_FUNCTION_P (x)
4194 + || (mode == SImode
4195 + && SYMBOL_REF_RMW_ADDR (x)))
4199 + case PRE_DEC: /* (pre_dec (...)) */
4200 + case POST_INC: /* (post_inc (...)) */
4201 + return avr32_address_register_rtx_p (XEXP (x, 0), strict);
4202 + case PLUS: /* (plus (...) (...)) */
4204 + rtx xop0 = XEXP (x, 0);
4205 + rtx xop1 = XEXP (x, 1);
4207 + return ((avr32_address_register_rtx_p (xop0, strict)
4208 + && avr32_legitimate_index_p (mode, xop1, strict))
4209 + || (avr32_address_register_rtx_p (xop1, strict)
4210 + && avr32_legitimate_index_p (mode, xop0, strict)));
4221 +avr32_const_ok_for_move (HOST_WIDE_INT c)
4223 + if ( TARGET_V2_INSNS )
4224 + return ( avr32_const_ok_for_constraint_p (c, 'K', "Ks21")
4225 + /* movh instruction */
4226 + || avr32_hi16_immediate_operand (GEN_INT(c), VOIDmode) );
4228 + return avr32_const_ok_for_constraint_p (c, 'K', "Ks21");
4233 +avr32_const_double_immediate (rtx value)
4235 + HOST_WIDE_INT hi, lo;
4237 + if (GET_CODE (value) != CONST_DOUBLE)
4240 + if (SCALAR_FLOAT_MODE_P (GET_MODE (value)))
4242 + HOST_WIDE_INT target_float[2];
4244 + real_to_target (target_float, CONST_DOUBLE_REAL_VALUE (value),
4245 + GET_MODE (value));
4246 + lo = target_float[0];
4247 + hi = target_float[1];
4251 + hi = CONST_DOUBLE_HIGH (value);
4252 + lo = CONST_DOUBLE_LOW (value);
4255 + if (avr32_const_ok_for_constraint_p (lo, 'K', "Ks21")
4256 + && (GET_MODE (value) == SFmode
4257 + || avr32_const_ok_for_constraint_p (hi, 'K', "Ks21")))
4267 +avr32_legitimate_constant_p (rtx x)
4269 + switch (GET_CODE (x))
4272 + /* Check if we should put large immediate into constant pool
4273 + or load them directly with mov/orh.*/
4274 + if (!avr32_imm_in_const_pool)
4277 + return avr32_const_ok_for_move (INTVAL (x));
4278 + case CONST_DOUBLE:
4279 + /* Check if we should put large immediate into constant pool
4280 + or load them directly with mov/orh.*/
4281 + if (!avr32_imm_in_const_pool)
4284 + if (GET_MODE (x) == SFmode
4285 + || GET_MODE (x) == DFmode || GET_MODE (x) == DImode)
4286 + return avr32_const_double_immediate (x);
4291 + return avr32_find_symbol (x) && (flag_pic || TARGET_HAS_ASM_ADDR_PSEUDOS);
4294 + case CONST_VECTOR:
4297 + printf ("%s():\n", __FUNCTION__);
4304 +/* Strip any special encoding from labels */
4306 +avr32_strip_name_encoding (const char *name)
4308 + const char *stripped = name;
4312 + switch (stripped[0])
4315 + stripped = strchr (name + 1, '#') + 1;
4318 + stripped = &stripped[1];
4328 +/* Do anything needed before RTL is emitted for each function. */
4329 +static struct machine_function *
4330 +avr32_init_machine_status (void)
4332 + struct machine_function *machine;
4334 + (machine_function *) ggc_alloc_cleared (sizeof (machine_function));
4336 +#if AVR32_FT_UNKNOWN != 0
4337 + machine->func_type = AVR32_FT_UNKNOWN;
4340 + machine->minipool_label_head = 0;
4341 + machine->minipool_label_tail = 0;
4342 + machine->ifcvt_after_reload = 0;
4348 +avr32_init_expanders (void)
4350 + /* Arrange to initialize and mark the machine per-function status. */
4351 + init_machine_status = avr32_init_machine_status;
4355 +/* Return an RTX indicating where the return address to the
4356 + calling function can be found. */
4358 +avr32_return_addr (int count, rtx frame ATTRIBUTE_UNUSED)
4363 + return get_hard_reg_initial_val (Pmode, LR_REGNUM);
4368 +avr32_encode_section_info (tree decl, rtx rtl, int first)
4370 + default_encode_section_info(decl, rtl, first);
4372 + if ( TREE_CODE (decl) == VAR_DECL
4373 + && (GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF)
4374 + && (lookup_attribute ("rmw_addressable", DECL_ATTRIBUTES (decl))
4375 + || TARGET_RMW_ADDRESSABLE_DATA) ){
4376 + if ( !TARGET_RMW || flag_pic )
4379 + // warning ("Using RMW addressable data with an arch that does not support RMW instructions.");
4385 + // warning ("Using RMW addressable data with together with -fpic switch. Can not use RMW instruction when compiling with -fpic.");
4388 + SYMBOL_REF_FLAGS (XEXP (rtl, 0)) |= (1 << SYMBOL_FLAG_RMW_ADDR_SHIFT);
4394 +avr32_asm_output_label (FILE * stream, const char *name)
4396 + name = avr32_strip_name_encoding (name);
4398 + /* Print the label. */
4399 + assemble_name (stream, name);
4400 + fprintf (stream, ":\n");
4405 +avr32_asm_weaken_label (FILE * stream, const char *name)
4407 + fprintf (stream, "\t.weak ");
4408 + assemble_name (stream, name);
4409 + fprintf (stream, "\n");
4414 + Checks if a labelref is equal to a reserved word in the assembler. If it is,
4415 + insert a '_' before the label name.
4418 +avr32_asm_output_labelref (FILE * stream, const char *name)
4420 + int verbatim = FALSE;
4421 + const char *stripped = name;
4422 + int strip_finished = FALSE;
4424 + while (!strip_finished)
4426 + switch (stripped[0])
4429 + stripped = strchr (name + 1, '#') + 1;
4432 + stripped = &stripped[1];
4436 + strip_finished = TRUE;
4442 + fputs (stripped, stream);
4444 + asm_fprintf (stream, "%U%s", stripped);
4449 + Check if the comparison in compare_exp is redundant
4450 + for the condition given in next_cond given that the
4451 + needed flags are already set by an earlier instruction.
4452 + Uses cc_prev_status to check this.
4454 + Returns NULL_RTX if the compare is not redundant
4455 + or the new condition to use in the conditional
4456 + instruction if the compare is redundant.
4459 +is_compare_redundant (rtx compare_exp, rtx next_cond)
4461 + int z_flag_valid = FALSE;
4462 + int n_flag_valid = FALSE;
4465 + if (GET_CODE (compare_exp) != COMPARE
4466 + && GET_CODE (compare_exp) != AND)
4470 + if (rtx_equal_p (cc_prev_status.mdep.value, compare_exp))
4472 + /* cc0 already contains the correct comparison -> delete cmp insn */
4476 + if (GET_MODE (compare_exp) != SImode)
4479 + switch (cc_prev_status.mdep.flags)
4483 + n_flag_valid = TRUE;
4486 + z_flag_valid = TRUE;
4489 + if (cc_prev_status.mdep.value
4490 + && GET_CODE (compare_exp) == COMPARE
4491 + && REG_P (XEXP (compare_exp, 0))
4492 + && REGNO (XEXP (compare_exp, 0)) == REGNO (cc_prev_status.mdep.value)
4493 + && GET_CODE (XEXP (compare_exp, 1)) == CONST_INT
4494 + && next_cond != NULL_RTX)
4496 + if (INTVAL (XEXP (compare_exp, 1)) == 0
4498 + && (GET_CODE (next_cond) == EQ || GET_CODE (next_cond) == NE))
4499 + /* We can skip comparison Z flag is already reflecting ops[0] */
4501 + else if (n_flag_valid
4502 + && ((INTVAL (XEXP (compare_exp, 1)) == 0
4503 + && (GET_CODE (next_cond) == GE
4504 + || GET_CODE (next_cond) == LT))
4505 + || (INTVAL (XEXP (compare_exp, 1)) == -1
4506 + && (GET_CODE (next_cond) == GT
4507 + || GET_CODE (next_cond) == LE))))
4509 + /* We can skip comparison N flag is already reflecting ops[0],
4510 + which means that we can use the mi/pl conditions to check if
4511 + ops[0] is GE or LT 0. */
4512 + if ((GET_CODE (next_cond) == GE) || (GET_CODE (next_cond) == GT))
4514 + gen_rtx_UNSPEC (GET_MODE (next_cond), gen_rtvec (2, cc0_rtx, const0_rtx),
4518 + gen_rtx_UNSPEC (GET_MODE (next_cond), gen_rtvec (2, cc0_rtx, const0_rtx),
4527 +/* Updates cc_status. */
4529 +avr32_notice_update_cc (rtx exp, rtx insn)
4531 + enum attr_cc attr_cc = get_attr_cc (insn);
4533 + if ( attr_cc == CC_SET_Z_IF_NOT_V2 )
4535 + if (TARGET_V2_INSNS)
4536 + attr_cc = CC_NONE;
4538 + attr_cc = CC_SET_Z;
4545 + /* Check if the function call returns a value in r12 */
4546 + if (REG_P (recog_data.operand[0])
4547 + && REGNO (recog_data.operand[0]) == RETVAL_REGNUM)
4549 + cc_status.flags = 0;
4550 + cc_status.mdep.value =
4551 + gen_rtx_COMPARE (SImode, recog_data.operand[0], const0_rtx);
4552 + cc_status.mdep.flags = CC_SET_VNCZ;
4553 + cc_status.mdep.cond_exec_cmp_clobbered = 0;
4559 + /* Check that compare will not be optimized away if so nothing should
4561 + rtx compare_exp = SET_SRC (exp);
4562 + /* Check if we have a tst expression. If so convert it to a
4563 + compare with 0. */
4564 + if ( REG_P (SET_SRC (exp)) )
4565 + compare_exp = gen_rtx_COMPARE (GET_MODE (SET_SRC (exp)),
4569 + if (!next_insn_emits_cmp (insn)
4570 + && (is_compare_redundant (compare_exp, get_next_insn_cond (insn)) == NULL_RTX))
4573 + /* Reset the nonstandard flag */
4575 + cc_status.flags = 0;
4576 + cc_status.mdep.value = compare_exp;
4577 + cc_status.mdep.flags = CC_SET_VNCZ;
4578 + cc_status.mdep.cond_exec_cmp_clobbered = 0;
4582 + case CC_CMP_COND_INSN:
4584 + /* Conditional insn that emit the compare itself. */
4586 + rtx cmp_op0, cmp_op1;
4589 + rtx next_insn = next_nonnote_insn (insn);
4591 + if ( GET_CODE (exp) == COND_EXEC )
4593 + cmp_op0 = XEXP (COND_EXEC_TEST (exp), 0);
4594 + cmp_op1 = XEXP (COND_EXEC_TEST (exp), 1);
4595 + cond = COND_EXEC_TEST (exp);
4596 + dest = SET_DEST (COND_EXEC_CODE (exp));
4600 + /* If then else conditional. compare operands are in operands
4602 + cmp_op0 = recog_data.operand[4];
4603 + cmp_op1 = recog_data.operand[5];
4604 + cond = recog_data.operand[1];
4605 + dest = SET_DEST (exp);
4608 + if ( GET_CODE (cmp_op0) == AND )
4611 + cmp = gen_rtx_COMPARE (GET_MODE (cmp_op0),
4615 + /* Check if the conditional insns updates a register present
4616 + in the comparison, if so then we must reset the cc_status. */
4618 + && (reg_mentioned_p (dest, cmp_op0)
4619 + || reg_mentioned_p (dest, cmp_op1))
4620 + && GET_CODE (exp) != COND_EXEC )
4624 + else if (is_compare_redundant (cmp, cond) == NULL_RTX)
4626 + /* Reset the nonstandard flag */
4628 + if ( GET_CODE (cmp_op0) == AND )
4630 + cc_status.flags = CC_INVERTED;
4631 + cc_status.mdep.flags = CC_SET_Z;
4635 + cc_status.flags = 0;
4636 + cc_status.mdep.flags = CC_SET_VNCZ;
4638 + cc_status.mdep.value = cmp;
4639 + cc_status.mdep.cond_exec_cmp_clobbered = 0;
4643 + /* Check if we have a COND_EXEC insn which updates one
4644 + of the registers in the compare status. */
4646 + && (reg_mentioned_p (dest, cmp_op0)
4647 + || reg_mentioned_p (dest, cmp_op1))
4648 + && GET_CODE (exp) == COND_EXEC )
4649 + cc_status.mdep.cond_exec_cmp_clobbered = 1;
4651 + if ( cc_status.mdep.cond_exec_cmp_clobbered
4652 + && GET_CODE (exp) == COND_EXEC
4653 + && next_insn != NULL
4654 + && INSN_P (next_insn)
4655 + && !(GET_CODE (PATTERN (next_insn)) == COND_EXEC
4656 + && rtx_equal_p (XEXP (COND_EXEC_TEST (PATTERN (next_insn)), 0), cmp_op0)
4657 + && rtx_equal_p (XEXP (COND_EXEC_TEST (PATTERN (next_insn)), 1), cmp_op1)
4658 + && (GET_CODE (COND_EXEC_TEST (PATTERN (next_insn))) == GET_CODE (cond)
4659 + || GET_CODE (COND_EXEC_TEST (PATTERN (next_insn))) == reverse_condition (GET_CODE (cond)))) )
4661 + /* We have a sequence of conditional insns where the compare status has been clobbered
4662 + since the compare no longer reflects the content of the values to compare. */
4664 + cc_status.mdep.cond_exec_cmp_clobbered = 1;
4670 + /* Bit load is kind of like an inverted testsi, because the Z flag is
4673 + cc_status.flags = CC_INVERTED;
4674 + cc_status.mdep.value = SET_SRC (exp);
4675 + cc_status.mdep.flags = CC_SET_Z;
4676 + cc_status.mdep.cond_exec_cmp_clobbered = 0;
4679 + /* Insn does not affect CC at all. Check if the instruction updates
4680 + some of the register currently reflected in cc0 */
4682 + if ((GET_CODE (exp) == SET)
4683 + && (cc_status.value1 || cc_status.value2 || cc_status.mdep.value)
4684 + && (reg_mentioned_p (SET_DEST (exp), cc_status.value1)
4685 + || reg_mentioned_p (SET_DEST (exp), cc_status.value2)
4686 + || reg_mentioned_p (SET_DEST (exp), cc_status.mdep.value)))
4691 + /* If this is a parallel we must step through each of the parallel
4693 + if (GET_CODE (exp) == PARALLEL)
4696 + for (i = 0; i < XVECLEN (exp, 0); ++i)
4698 + rtx vec_exp = XVECEXP (exp, 0, i);
4699 + if ((GET_CODE (vec_exp) == SET)
4700 + && (cc_status.value1 || cc_status.value2
4701 + || cc_status.mdep.value)
4702 + && (reg_mentioned_p (SET_DEST (vec_exp), cc_status.value1)
4703 + || reg_mentioned_p (SET_DEST (vec_exp),
4705 + || reg_mentioned_p (SET_DEST (vec_exp),
4706 + cc_status.mdep.value)))
4713 + /* Check if we have memory opartions with post_inc or pre_dec on the
4714 + register currently reflected in cc0 */
4715 + if (GET_CODE (exp) == SET
4716 + && GET_CODE (SET_SRC (exp)) == MEM
4717 + && (GET_CODE (XEXP (SET_SRC (exp), 0)) == POST_INC
4718 + || GET_CODE (XEXP (SET_SRC (exp), 0)) == PRE_DEC)
4721 + (XEXP (XEXP (SET_SRC (exp), 0), 0), cc_status.value1)
4722 + || reg_mentioned_p (XEXP (XEXP (SET_SRC (exp), 0), 0),
4724 + || reg_mentioned_p (XEXP (XEXP (SET_SRC (exp), 0), 0),
4725 + cc_status.mdep.value)))
4728 + if (GET_CODE (exp) == SET
4729 + && GET_CODE (SET_DEST (exp)) == MEM
4730 + && (GET_CODE (XEXP (SET_DEST (exp), 0)) == POST_INC
4731 + || GET_CODE (XEXP (SET_DEST (exp), 0)) == PRE_DEC)
4734 + (XEXP (XEXP (SET_DEST (exp), 0), 0), cc_status.value1)
4735 + || reg_mentioned_p (XEXP (XEXP (SET_DEST (exp), 0), 0),
4737 + || reg_mentioned_p (XEXP (XEXP (SET_DEST (exp), 0), 0),
4738 + cc_status.mdep.value)))
4744 + cc_status.mdep.value = recog_data.operand[0];
4745 + cc_status.mdep.flags = CC_SET_VNCZ;
4746 + cc_status.mdep.cond_exec_cmp_clobbered = 0;
4751 + cc_status.mdep.value = recog_data.operand[0];
4752 + cc_status.mdep.flags = CC_SET_NCZ;
4753 + cc_status.mdep.cond_exec_cmp_clobbered = 0;
4758 + cc_status.mdep.value = recog_data.operand[0];
4759 + cc_status.mdep.flags = CC_SET_CZ;
4760 + cc_status.mdep.cond_exec_cmp_clobbered = 0;
4765 + cc_status.mdep.value = recog_data.operand[0];
4766 + cc_status.mdep.flags = CC_SET_Z;
4767 + cc_status.mdep.cond_exec_cmp_clobbered = 0;
4781 + Outputs to stdio stream stream the assembler syntax for an instruction
4782 + operand x. x is an RTL expression.
4785 +avr32_print_operand (FILE * stream, rtx x, int code)
4789 + if ( code == '?' )
4791 + /* Predicable instruction, print condition code */
4793 + /* If the insn should not be conditional then do nothing. */
4794 + if ( current_insn_predicate == NULL_RTX )
4797 + /* Set x to the predicate to force printing
4798 + the condition later on. */
4799 + x = current_insn_predicate;
4801 + /* Reverse condition if useing bld insn. */
4802 + if ( GET_CODE (XEXP(current_insn_predicate,0)) == AND )
4803 + x = reversed_condition (current_insn_predicate);
4805 + else if ( code == '!' )
4807 + /* Output compare for conditional insn if needed. */
4809 + gcc_assert ( current_insn_predicate != NULL_RTX );
4810 + new_cond = avr32_output_cmp(current_insn_predicate,
4811 + GET_MODE(XEXP(current_insn_predicate,0)),
4812 + XEXP(current_insn_predicate,0),
4813 + XEXP(current_insn_predicate,1));
4815 + /* Check if the new condition is a special avr32 condition
4816 + specified using UNSPECs. If so we must handle it differently. */
4817 + if ( GET_CODE (new_cond) == UNSPEC )
4819 + current_insn_predicate =
4820 + gen_rtx_UNSPEC (CCmode,
4822 + XEXP(current_insn_predicate,0),
4823 + XEXP(current_insn_predicate,1)),
4824 + XINT (new_cond, 1));
4828 + PUT_CODE(current_insn_predicate, GET_CODE(new_cond));
4833 + switch (GET_CODE (x))
4836 + switch (XINT (x, 1))
4838 + case UNSPEC_COND_PL:
4840 + fputs ("mi", stream);
4842 + fputs ("pl", stream);
4844 + case UNSPEC_COND_MI:
4846 + fputs ("pl", stream);
4848 + fputs ("mi", stream);
4856 + fputs ("ne", stream);
4858 + fputs ("eq", stream);
4862 + fputs ("eq", stream);
4864 + fputs ("ne", stream);
4868 + fputs ("le", stream);
4870 + fputs ("gt", stream);
4874 + fputs ("ls", stream);
4876 + fputs ("hi", stream);
4880 + fputs ("ge", stream);
4882 + fputs ("lt", stream);
4886 + fputs ("hs", stream);
4888 + fputs ("lo", stream);
4892 + fputs ("lt", stream);
4894 + fputs ("ge", stream);
4898 + fputs ("lo", stream);
4900 + fputs ("hs", stream);
4904 + fputs ("gt", stream);
4906 + fputs ("le", stream);
4910 + fputs ("hi", stream);
4912 + fputs ("ls", stream);
4916 + HOST_WIDE_INT value = INTVAL (x);
4921 + if ( HOST_BITS_PER_WIDE_INT > BITS_PER_WORD )
4923 + /* A const_int can be used to represent DImode constants. */
4924 + value >>= BITS_PER_WORD;
4926 + /* We might get a const_int immediate for setting a DI register,
4927 + we then must then return the correct sign extended DI. The most
4928 + significant word is just a sign extension. */
4929 + else if (value < 0)
4939 + /* Set to bit position of first bit set in immediate */
4940 + int i, bitpos = 32;
4941 + for (i = 0; i < 32; i++)
4942 + if (value & (1 << i))
4952 + /* Set to bit position of first bit cleared in immediate */
4953 + int i, bitpos = 32;
4954 + for (i = 0; i < 32; i++)
4955 + if (!(value & (1 << i)))
4970 + strcpy (op, "r0-r3");
4972 + strlen (op) ? strcat (op, ", r4-r7") : strcpy (op,"r4-r7");
4974 + strlen (op) ? strcat (op, ", r8-r9") : strcpy (op,"r8-r9");
4976 + strlen (op) ? strcat (op, ", r10") : strcpy (op,"r10");
4978 + strlen (op) ? strcat (op, ", r11") : strcpy (op,"r11");
4980 + strlen (op) ? strcat (op, ", r12") : strcpy (op,"r12");
4982 + strlen (op) ? strcat (op, ", lr") : strcpy (op, "lr");
4984 + strlen (op) ? strcat (op, ", pc") : strcpy (op, "pc");
4986 + fputs (op, stream);
4992 + char reglist16_string[100];
4994 + bool first_reg = true;
4995 + reglist16_string[0] = '\0';
4997 + for (i = 0; i < 16; ++i)
4999 + if (value & (1 << i))
5001 + first_reg == true ? first_reg = false : strcat(reglist16_string,", ");
5002 + strcat(reglist16_string,reg_names[INTERNAL_REGNUM(i)]);
5005 + fputs (reglist16_string, stream);
5009 + /* Print halfword part of word */
5010 + fputs (value ? "b" : "t", stream);
5015 + fprintf (stream, "%d", value);
5018 + case CONST_DOUBLE:
5020 + HOST_WIDE_INT hi, lo;
5021 + if (SCALAR_FLOAT_MODE_P (GET_MODE (x)))
5023 + HOST_WIDE_INT target_float[2];
5025 + real_to_target (target_float, CONST_DOUBLE_REAL_VALUE (x),
5027 + /* For doubles the most significant part starts at index 0. */
5028 + if (GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
5030 + hi = target_float[0];
5031 + lo = target_float[1];
5035 + lo = target_float[0];
5040 + hi = CONST_DOUBLE_HIGH (x);
5041 + lo = CONST_DOUBLE_LOW (x);
5045 + fprintf (stream, "%ld", hi);
5047 + fprintf (stream, "%ld", lo);
5052 + output_addr_const (stream, XEXP (XEXP (x, 0), 0));
5053 + fprintf (stream, "+%ld", INTVAL (XEXP (XEXP (x, 0), 1)));
5056 + /* Swap register name if the register is DImode or DFmode. */
5057 + if (GET_MODE (x) == DImode || GET_MODE (x) == DFmode)
5059 + /* Double register must have an even numbered address */
5060 + gcc_assert (!(REGNO (x) % 2));
5062 + fputs (reg_names[true_regnum (x)], stream);
5064 + fputs (reg_names[true_regnum (x) + 1], stream);
5066 + else if (GET_MODE (x) == TImode)
5071 + fputs (reg_names[true_regnum (x)], stream);
5074 + fputs (reg_names[true_regnum (x) + 1], stream);
5077 + fputs (reg_names[true_regnum (x) + 2], stream);
5080 + fputs (reg_names[true_regnum (x) + 3], stream);
5083 + fprintf (stream, "%s, %s, %s, %s",
5084 + reg_names[true_regnum (x) + 3],
5085 + reg_names[true_regnum (x) + 2],
5086 + reg_names[true_regnum (x) + 1],
5087 + reg_names[true_regnum (x)]);
5093 + fputs (reg_names[true_regnum (x)], stream);
5099 + output_addr_const (stream, x);
5102 + switch (GET_CODE (XEXP (x, 0)))
5106 + output_addr_const (stream, XEXP (x, 0));
5109 + switch (GET_CODE (XEXP (XEXP (x, 0), 0)))
5112 + output_addr_const (stream, XEXP (XEXP (x, 0), 0));
5120 + avr32_print_operand (stream, XEXP (x, 0), 0);
5122 + fputs ("[0]", stream);
5125 + fputs ("--", stream);
5126 + avr32_print_operand (stream, XEXP (XEXP (x, 0), 0), 0);
5129 + avr32_print_operand (stream, XEXP (XEXP (x, 0), 0), 0);
5130 + fputs ("++", stream);
5134 + rtx op0 = XEXP (XEXP (x, 0), 0);
5135 + rtx op1 = XEXP (XEXP (x, 0), 1);
5136 + rtx base = NULL_RTX, offset = NULL_RTX;
5138 + if (avr32_address_register_rtx_p (op0, 1))
5143 + else if (avr32_address_register_rtx_p (op1, 1))
5145 + /* Operands are switched. */
5150 + gcc_assert (base && offset
5151 + && avr32_address_register_rtx_p (base, 1)
5152 + && avr32_legitimate_index_p (GET_MODE (x), offset,
5155 + avr32_print_operand (stream, base, 0);
5156 + fputs ("[", stream);
5157 + avr32_print_operand (stream, offset, 0);
5158 + fputs ("]", stream);
5162 + output_addr_const (stream, XEXP (XEXP (XEXP (x, 0), 0), 0));
5163 + fprintf (stream, " + %ld",
5164 + INTVAL (XEXP (XEXP (XEXP (x, 0), 0), 1)));
5167 + avr32_print_operand (stream, XEXP (x, 0), 0);
5175 + int value = INTVAL (XEXP (x, 1));
5177 + /* Convert immediate in multiplication into a shift immediate */
5192 + fprintf (stream, "%s << %i", reg_names[true_regnum (XEXP (x, 0))],
5197 + if (GET_CODE (XEXP (x, 1)) == CONST_INT)
5198 + fprintf (stream, "%s << %i", reg_names[true_regnum (XEXP (x, 0))],
5199 + (int) INTVAL (XEXP (x, 1)));
5200 + else if (REG_P (XEXP (x, 1)))
5201 + fprintf (stream, "%s << %s", reg_names[true_regnum (XEXP (x, 0))],
5202 + reg_names[true_regnum (XEXP (x, 1))]);
5209 + if (GET_CODE (XEXP (x, 1)) == CONST_INT)
5210 + fprintf (stream, "%s >> %i", reg_names[true_regnum (XEXP (x, 0))],
5211 + (int) INTVAL (XEXP (x, 1)));
5212 + else if (REG_P (XEXP (x, 1)))
5213 + fprintf (stream, "%s >> %s", reg_names[true_regnum (XEXP (x, 0))],
5214 + reg_names[true_regnum (XEXP (x, 1))]);
5219 + fprintf (stream, ">>");
5223 + /* Load store multiple */
5225 + int count = XVECLEN (x, 0);
5226 + int reglist16 = 0;
5227 + char reglist16_string[100];
5229 + for (i = 0; i < count; ++i)
5231 + rtx vec_elm = XVECEXP (x, 0, i);
5232 + if (GET_MODE (vec_elm) != SET)
5234 + debug_rtx (vec_elm);
5235 + internal_error ("Unknown element in parallel expression!");
5237 + if (GET_MODE (XEXP (vec_elm, 0)) == REG)
5239 + /* Load multiple */
5240 + reglist16 |= 1 << ASM_REGNUM (REGNO (XEXP (vec_elm, 0)));
5244 + /* Store multiple */
5245 + reglist16 |= 1 << ASM_REGNUM (REGNO (XEXP (vec_elm, 1)));
5249 + avr32_make_reglist16 (reglist16, reglist16_string);
5250 + fputs (reglist16_string, stream);
5257 + rtx op0 = XEXP (x, 0);
5258 + rtx op1 = XEXP (x, 1);
5259 + rtx base = NULL_RTX, offset = NULL_RTX;
5261 + if (avr32_address_register_rtx_p (op0, 1))
5266 + else if (avr32_address_register_rtx_p (op1, 1))
5268 + /* Operands are switched. */
5273 + gcc_assert (base && offset
5274 + && avr32_address_register_rtx_p (base, 1)
5275 + && avr32_legitimate_index_p (GET_MODE (x), offset, 1));
5277 + avr32_print_operand (stream, base, 0);
5278 + fputs ("[", stream);
5279 + avr32_print_operand (stream, offset, 0);
5280 + fputs ("]", stream);
5291 + internal_error ("Illegal expression for avr32_print_operand");
5296 +avr32_get_note_reg_equiv (rtx insn)
5300 + note = find_reg_note (insn, REG_EQUIV, NULL_RTX);
5302 + if (note != NULL_RTX)
5303 + return XEXP (note, 0);
5310 + Outputs to stdio stream stream the assembler syntax for an instruction
5311 + operand that is a memory reference whose address is x. x is an RTL
5317 +avr32_print_operand_address (FILE * stream, rtx x)
5319 + fprintf (stream, "(%d) /* address */", REGNO (x));
5323 +/* Return true if _GLOBAL_OFFSET_TABLE_ symbol is mentioned. */
5325 +avr32_got_mentioned_p (rtx addr)
5327 + if (GET_CODE (addr) == MEM)
5328 + addr = XEXP (addr, 0);
5329 + while (GET_CODE (addr) == CONST)
5330 + addr = XEXP (addr, 0);
5331 + if (GET_CODE (addr) == SYMBOL_REF)
5333 + return streq (XSTR (addr, 0), "_GLOBAL_OFFSET_TABLE_");
5335 + if (GET_CODE (addr) == PLUS || GET_CODE (addr) == MINUS)
5339 + l1 = avr32_got_mentioned_p (XEXP (addr, 0));
5340 + l2 = avr32_got_mentioned_p (XEXP (addr, 1));
5347 +/* Find the symbol in an address expression. */
5349 +avr32_find_symbol (rtx addr)
5351 + if (GET_CODE (addr) == MEM)
5352 + addr = XEXP (addr, 0);
5354 + while (GET_CODE (addr) == CONST)
5355 + addr = XEXP (addr, 0);
5357 + if (GET_CODE (addr) == SYMBOL_REF || GET_CODE (addr) == LABEL_REF)
5359 + if (GET_CODE (addr) == PLUS)
5363 + l1 = avr32_find_symbol (XEXP (addr, 0));
5364 + l2 = avr32_find_symbol (XEXP (addr, 1));
5365 + if (l1 != NULL_RTX && l2 == NULL_RTX)
5367 + else if (l1 == NULL_RTX && l2 != NULL_RTX)
5375 +/* Routines for manipulation of the constant pool. */
5377 +/* AVR32 instructions cannot load a large constant directly into a
5378 + register; they have to come from a pc relative load. The constant
5379 + must therefore be placed in the addressable range of the pc
5380 + relative load. Depending on the precise pc relative load
5381 + instruction the range is somewhere between 256 bytes and 4k. This
5382 + means that we often have to dump a constant inside a function, and
5383 + generate code to branch around it.
5385 + It is important to minimize this, since the branches will slow
5386 + things down and make the code larger.
5388 + Normally we can hide the table after an existing unconditional
5389 + branch so that there is no interruption of the flow, but in the
5390 + worst case the code looks like this:
5408 + We fix this by performing a scan after scheduling, which notices
5409 + which instructions need to have their operands fetched from the
5410 + constant table and builds the table.
5412 + The algorithm starts by building a table of all the constants that
5413 + need fixing up and all the natural barriers in the function (places
5414 + where a constant table can be dropped without breaking the flow).
5415 + For each fixup we note how far the pc-relative replacement will be
5416 + able to reach and the offset of the instruction into the function.
5418 + Having built the table we then group the fixes together to form
5419 + tables that are as large as possible (subject to addressing
5420 + constraints) and emit each table of constants after the last
5421 + barrier that is within range of all the instructions in the group.
5422 + If a group does not contain a barrier, then we forcibly create one
5423 + by inserting a jump instruction into the flow. Once the table has
5424 + been inserted, the insns are then modified to reference the
5425 + relevant entry in the pool.
5427 + Possible enhancements to the algorithm (not implemented) are:
5429 + 1) For some processors and object formats, there may be benefit in
5430 + aligning the pools to the start of cache lines; this alignment
5431 + would need to be taken into account when calculating addressability
5434 +/* These typedefs are located at the start of this file, so that
5435 + they can be used in the prototypes there. This comment is to
5436 + remind readers of that fact so that the following structures
5437 + can be understood more easily.
5439 + typedef struct minipool_node Mnode;
5440 + typedef struct minipool_fixup Mfix; */
5442 +struct minipool_node
5444 + /* Doubly linked chain of entries. */
5447 + /* The maximum offset into the code that this entry can be placed. While
5448 + pushing fixes for forward references, all entries are sorted in order of
5449 + increasing max_address. */
5450 + HOST_WIDE_INT max_address;
5451 + /* Similarly for an entry inserted for a backwards ref. */
5452 + HOST_WIDE_INT min_address;
5453 + /* The number of fixes referencing this entry. This can become zero if we
5454 + "unpush" an entry. In this case we ignore the entry when we come to
5457 + /* The offset from the start of the minipool. */
5458 + HOST_WIDE_INT offset;
5459 + /* The value in table. */
5461 + /* The mode of value. */
5462 + enum machine_mode mode;
5463 + /* The size of the value. */
5468 +struct minipool_fixup
5472 + HOST_WIDE_INT address;
5474 + enum machine_mode mode;
5478 + HOST_WIDE_INT forwards;
5479 + HOST_WIDE_INT backwards;
5483 +/* Fixes less than a word need padding out to a word boundary. */
5484 +#define MINIPOOL_FIX_SIZE(mode, value) \
5485 + (IS_FORCE_MINIPOOL(value) ? 0 : \
5486 + (GET_MODE_SIZE ((mode)) >= 4 ? GET_MODE_SIZE ((mode)) : 4))
5488 +#define IS_FORCE_MINIPOOL(x) \
5489 + (GET_CODE(x) == UNSPEC && \
5490 + XINT(x, 1) == UNSPEC_FORCE_MINIPOOL)
5492 +static Mnode *minipool_vector_head;
5493 +static Mnode *minipool_vector_tail;
5495 +/* The linked list of all minipool fixes required for this function. */
5496 +Mfix *minipool_fix_head;
5497 +Mfix *minipool_fix_tail;
5498 +/* The fix entry for the current minipool, once it has been placed. */
5499 +Mfix *minipool_barrier;
5502 +/* Determines if INSN is the start of a jump table. Returns the end
5503 + of the TABLE or NULL_RTX. */
5505 +is_jump_table (rtx insn)
5509 + if (GET_CODE (insn) == JUMP_INSN
5510 + && JUMP_LABEL (insn) != NULL
5511 + && ((table = next_real_insn (JUMP_LABEL (insn)))
5512 + == next_real_insn (insn))
5514 + && GET_CODE (table) == JUMP_INSN
5515 + && (GET_CODE (PATTERN (table)) == ADDR_VEC
5516 + || GET_CODE (PATTERN (table)) == ADDR_DIFF_VEC))
5523 +static HOST_WIDE_INT
5524 +get_jump_table_size (rtx insn)
5526 + /* ADDR_VECs only take room if read-only data does into the text section. */
5527 + if (JUMP_TABLES_IN_TEXT_SECTION
5528 +#if !defined(READONLY_DATA_SECTION_ASM_OP)
5533 + rtx body = PATTERN (insn);
5534 + int elt = GET_CODE (body) == ADDR_DIFF_VEC ? 1 : 0;
5536 + return GET_MODE_SIZE (GET_MODE (body)) * XVECLEN (body, elt);
5543 +/* Move a minipool fix MP from its current location to before MAX_MP.
5544 + If MAX_MP is NULL, then MP doesn't need moving, but the addressing
5545 + constraints may need updating. */
5547 +move_minipool_fix_forward_ref (Mnode * mp, Mnode * max_mp,
5548 + HOST_WIDE_INT max_address)
5550 + /* This should never be true and the code below assumes these are
5555 + if (max_mp == NULL)
5557 + if (max_address < mp->max_address)
5558 + mp->max_address = max_address;
5562 + if (max_address > max_mp->max_address - mp->fix_size)
5563 + mp->max_address = max_mp->max_address - mp->fix_size;
5565 + mp->max_address = max_address;
5567 + /* Unlink MP from its current position. Since max_mp is non-null,
5568 + mp->prev must be non-null. */
5569 + mp->prev->next = mp->next;
5570 + if (mp->next != NULL)
5571 + mp->next->prev = mp->prev;
5573 + minipool_vector_tail = mp->prev;
5575 + /* Re-insert it before MAX_MP. */
5576 + mp->next = max_mp;
5577 + mp->prev = max_mp->prev;
5578 + max_mp->prev = mp;
5580 + if (mp->prev != NULL)
5581 + mp->prev->next = mp;
5583 + minipool_vector_head = mp;
5586 + /* Save the new entry. */
5589 + /* Scan over the preceding entries and adjust their addresses as required.
5591 + while (mp->prev != NULL
5592 + && mp->prev->max_address > mp->max_address - mp->prev->fix_size)
5594 + mp->prev->max_address = mp->max_address - mp->prev->fix_size;
5602 +/* Add a constant to the minipool for a forward reference. Returns the
5603 + node added or NULL if the constant will not fit in this pool. */
5605 +add_minipool_forward_ref (Mfix * fix)
5607 + /* If set, max_mp is the first pool_entry that has a lower constraint than
5608 + the one we are trying to add. */
5609 + Mnode *max_mp = NULL;
5610 + HOST_WIDE_INT max_address = fix->address + fix->forwards;
5613 + /* If this fix's address is greater than the address of the first entry,
5614 + then we can't put the fix in this pool. We subtract the size of the
5615 + current fix to ensure that if the table is fully packed we still have
5616 + enough room to insert this value by suffling the other fixes forwards. */
5617 + if (minipool_vector_head &&
5618 + fix->address >= minipool_vector_head->max_address - fix->fix_size)
5621 + /* Scan the pool to see if a constant with the same value has already been
5622 + added. While we are doing this, also note the location where we must
5623 + insert the constant if it doesn't already exist. */
5624 + for (mp = minipool_vector_head; mp != NULL; mp = mp->next)
5626 + if (GET_CODE (fix->value) == GET_CODE (mp->value)
5627 + && fix->mode == mp->mode
5628 + && (GET_CODE (fix->value) != CODE_LABEL
5629 + || (CODE_LABEL_NUMBER (fix->value)
5630 + == CODE_LABEL_NUMBER (mp->value)))
5631 + && rtx_equal_p (fix->value, mp->value))
5633 + /* More than one fix references this entry. */
5635 + return move_minipool_fix_forward_ref (mp, max_mp, max_address);
5638 + /* Note the insertion point if necessary. */
5639 + if (max_mp == NULL && mp->max_address > max_address)
5644 + /* The value is not currently in the minipool, so we need to create a new
5645 + entry for it. If MAX_MP is NULL, the entry will be put on the end of
5646 + the list since the placement is less constrained than any existing
5647 + entry. Otherwise, we insert the new fix before MAX_MP and, if
5648 + necessary, adjust the constraints on the other entries. */
5649 + mp = xmalloc (sizeof (*mp));
5650 + mp->fix_size = fix->fix_size;
5651 + mp->mode = fix->mode;
5652 + mp->value = fix->value;
5654 + /* Not yet required for a backwards ref. */
5655 + mp->min_address = -65536;
5657 + if (max_mp == NULL)
5659 + mp->max_address = max_address;
5661 + mp->prev = minipool_vector_tail;
5663 + if (mp->prev == NULL)
5665 + minipool_vector_head = mp;
5666 + minipool_vector_label = gen_label_rtx ();
5669 + mp->prev->next = mp;
5671 + minipool_vector_tail = mp;
5675 + if (max_address > max_mp->max_address - mp->fix_size)
5676 + mp->max_address = max_mp->max_address - mp->fix_size;
5678 + mp->max_address = max_address;
5680 + mp->next = max_mp;
5681 + mp->prev = max_mp->prev;
5682 + max_mp->prev = mp;
5683 + if (mp->prev != NULL)
5684 + mp->prev->next = mp;
5686 + minipool_vector_head = mp;
5689 + /* Save the new entry. */
5692 + /* Scan over the preceding entries and adjust their addresses as required.
5694 + while (mp->prev != NULL
5695 + && mp->prev->max_address > mp->max_address - mp->prev->fix_size)
5697 + mp->prev->max_address = mp->max_address - mp->prev->fix_size;
5706 +move_minipool_fix_backward_ref (Mnode * mp, Mnode * min_mp,
5707 + HOST_WIDE_INT min_address)
5709 + HOST_WIDE_INT offset;
5711 + /* This should never be true, and the code below assumes these are
5716 + if (min_mp == NULL)
5718 + if (min_address > mp->min_address)
5719 + mp->min_address = min_address;
5723 + /* We will adjust this below if it is too loose. */
5724 + mp->min_address = min_address;
5726 + /* Unlink MP from its current position. Since min_mp is non-null,
5727 + mp->next must be non-null. */
5728 + mp->next->prev = mp->prev;
5729 + if (mp->prev != NULL)
5730 + mp->prev->next = mp->next;
5732 + minipool_vector_head = mp->next;
5734 + /* Reinsert it after MIN_MP. */
5735 + mp->prev = min_mp;
5736 + mp->next = min_mp->next;
5737 + min_mp->next = mp;
5738 + if (mp->next != NULL)
5739 + mp->next->prev = mp;
5741 + minipool_vector_tail = mp;
5747 + for (mp = minipool_vector_head; mp != NULL; mp = mp->next)
5749 + mp->offset = offset;
5750 + if (mp->refcount > 0)
5751 + offset += mp->fix_size;
5753 + if (mp->next && mp->next->min_address < mp->min_address + mp->fix_size)
5754 + mp->next->min_address = mp->min_address + mp->fix_size;
5761 +/* Add a constant to the minipool for a backward reference. Returns the
5762 + node added or NULL if the constant will not fit in this pool.
5764 + Note that the code for insertion for a backwards reference can be
5765 + somewhat confusing because the calculated offsets for each fix do
5766 + not take into account the size of the pool (which is still under
5769 +add_minipool_backward_ref (Mfix * fix)
5771 + /* If set, min_mp is the last pool_entry that has a lower constraint than
5772 + the one we are trying to add. */
5773 + Mnode *min_mp = NULL;
5774 + /* This can be negative, since it is only a constraint. */
5775 + HOST_WIDE_INT min_address = fix->address - fix->backwards;
5778 + /* If we can't reach the current pool from this insn, or if we can't insert
5779 + this entry at the end of the pool without pushing other fixes out of
5780 + range, then we don't try. This ensures that we can't fail later on. */
5781 + if (min_address >= minipool_barrier->address
5782 + || (minipool_vector_tail->min_address + fix->fix_size
5783 + >= minipool_barrier->address))
5786 + /* Scan the pool to see if a constant with the same value has already been
5787 + added. While we are doing this, also note the location where we must
5788 + insert the constant if it doesn't already exist. */
5789 + for (mp = minipool_vector_tail; mp != NULL; mp = mp->prev)
5791 + if (GET_CODE (fix->value) == GET_CODE (mp->value)
5792 + && fix->mode == mp->mode
5793 + && (GET_CODE (fix->value) != CODE_LABEL
5794 + || (CODE_LABEL_NUMBER (fix->value)
5795 + == CODE_LABEL_NUMBER (mp->value)))
5796 + && rtx_equal_p (fix->value, mp->value)
5797 + /* Check that there is enough slack to move this entry to the end
5798 + of the table (this is conservative). */
5799 + && (mp->max_address
5800 + > (minipool_barrier->address
5801 + + minipool_vector_tail->offset
5802 + + minipool_vector_tail->fix_size)))
5805 + return move_minipool_fix_backward_ref (mp, min_mp, min_address);
5808 + if (min_mp != NULL)
5809 + mp->min_address += fix->fix_size;
5812 + /* Note the insertion point if necessary. */
5813 + if (mp->min_address < min_address)
5817 + else if (mp->max_address
5818 + < minipool_barrier->address + mp->offset + fix->fix_size)
5820 + /* Inserting before this entry would push the fix beyond its
5821 + maximum address (which can happen if we have re-located a
5822 + forwards fix); force the new fix to come after it. */
5824 + min_address = mp->min_address + fix->fix_size;
5829 + /* We need to create a new entry. */
5830 + mp = xmalloc (sizeof (*mp));
5831 + mp->fix_size = fix->fix_size;
5832 + mp->mode = fix->mode;
5833 + mp->value = fix->value;
5835 + mp->max_address = minipool_barrier->address + 65536;
5837 + mp->min_address = min_address;
5839 + if (min_mp == NULL)
5842 + mp->next = minipool_vector_head;
5844 + if (mp->next == NULL)
5846 + minipool_vector_tail = mp;
5847 + minipool_vector_label = gen_label_rtx ();
5850 + mp->next->prev = mp;
5852 + minipool_vector_head = mp;
5856 + mp->next = min_mp->next;
5857 + mp->prev = min_mp;
5858 + min_mp->next = mp;
5860 + if (mp->next != NULL)
5861 + mp->next->prev = mp;
5863 + minipool_vector_tail = mp;
5866 + /* Save the new entry. */
5874 + /* Scan over the following entries and adjust their offsets. */
5875 + while (mp->next != NULL)
5877 + if (mp->next->min_address < mp->min_address + mp->fix_size)
5878 + mp->next->min_address = mp->min_address + mp->fix_size;
5881 + mp->next->offset = mp->offset + mp->fix_size;
5883 + mp->next->offset = mp->offset;
5893 +assign_minipool_offsets (Mfix * barrier)
5895 + HOST_WIDE_INT offset = 0;
5898 + minipool_barrier = barrier;
5900 + for (mp = minipool_vector_head; mp != NULL; mp = mp->next)
5902 + mp->offset = offset;
5904 + if (mp->refcount > 0)
5905 + offset += mp->fix_size;
5910 +/* Print a symbolic form of X to the debug file, F. */
5912 +avr32_print_value (FILE * f, rtx x)
5914 + switch (GET_CODE (x))
5917 + fprintf (f, "0x%x", (int) INTVAL (x));
5920 + case CONST_DOUBLE:
5921 + fprintf (f, "<0x%lx,0x%lx>", (long) XWINT (x, 2), (long) XWINT (x, 3));
5924 + case CONST_VECTOR:
5929 + for (i = 0; i < CONST_VECTOR_NUNITS (x); i++)
5931 + fprintf (f, "0x%x", (int) INTVAL (CONST_VECTOR_ELT (x, i)));
5932 + if (i < (CONST_VECTOR_NUNITS (x) - 1))
5939 + case CONST_STRING:
5940 + fprintf (f, "\"%s\"", XSTR (x, 0));
5944 + fprintf (f, "`%s'", XSTR (x, 0));
5948 + fprintf (f, "L%d", INSN_UID (XEXP (x, 0)));
5952 + avr32_print_value (f, XEXP (x, 0));
5956 + avr32_print_value (f, XEXP (x, 0));
5958 + avr32_print_value (f, XEXP (x, 1));
5962 + fprintf (f, "pc");
5966 + fprintf (f, "????");
5973 +is_minipool_label (rtx label)
5975 + minipool_labels *cur_mp_label = cfun->machine->minipool_label_head;
5977 + if (GET_CODE (label) != CODE_LABEL)
5980 + while (cur_mp_label)
5982 + if (CODE_LABEL_NUMBER (label)
5983 + == CODE_LABEL_NUMBER (cur_mp_label->label))
5985 + cur_mp_label = cur_mp_label->next;
5992 +new_minipool_label (rtx label)
5994 + if (!cfun->machine->minipool_label_head)
5996 + cfun->machine->minipool_label_head =
5997 + ggc_alloc (sizeof (minipool_labels));
5998 + cfun->machine->minipool_label_tail = cfun->machine->minipool_label_head;
5999 + cfun->machine->minipool_label_head->label = label;
6000 + cfun->machine->minipool_label_head->next = 0;
6001 + cfun->machine->minipool_label_head->prev = 0;
6005 + cfun->machine->minipool_label_tail->next =
6006 + ggc_alloc (sizeof (minipool_labels));
6007 + cfun->machine->minipool_label_tail->next->label = label;
6008 + cfun->machine->minipool_label_tail->next->next = 0;
6009 + cfun->machine->minipool_label_tail->next->prev =
6010 + cfun->machine->minipool_label_tail;
6011 + cfun->machine->minipool_label_tail =
6012 + cfun->machine->minipool_label_tail->next;
6017 +/* Output the literal table */
6019 +dump_minipool (rtx scan)
6025 + fprintf (dump_file,
6026 + ";; Emitting minipool after insn %u; address %ld; align %d (bytes)\n",
6027 + INSN_UID (scan), (unsigned long) minipool_barrier->address, 4);
6029 + scan = emit_insn_after (gen_consttable_start (), scan);
6030 + scan = emit_insn_after (gen_align_4 (), scan);
6031 + scan = emit_label_after (minipool_vector_label, scan);
6032 + new_minipool_label (minipool_vector_label);
6034 + for (mp = minipool_vector_head; mp != NULL; mp = nmp)
6036 + if (mp->refcount > 0)
6040 + fprintf (dump_file,
6041 + ";; Offset %u, min %ld, max %ld ",
6042 + (unsigned) mp->offset, (unsigned long) mp->min_address,
6043 + (unsigned long) mp->max_address);
6044 + avr32_print_value (dump_file, mp->value);
6045 + fputc ('\n', dump_file);
6048 + switch (mp->fix_size)
6050 +#ifdef HAVE_consttable_4
6052 + scan = emit_insn_after (gen_consttable_4 (mp->value), scan);
6056 +#ifdef HAVE_consttable_8
6058 + scan = emit_insn_after (gen_consttable_8 (mp->value), scan);
6062 +#ifdef HAVE_consttable_16
6064 + scan = emit_insn_after (gen_consttable_16 (mp->value), scan);
6069 + /* This can happen for force-minipool entries which just are
6070 + there to force the minipool to be generate. */
6082 + minipool_vector_head = minipool_vector_tail = NULL;
6083 + scan = emit_insn_after (gen_consttable_end (), scan);
6084 + scan = emit_barrier_after (scan);
6088 +/* Return the cost of forcibly inserting a barrier after INSN. */
6090 +avr32_barrier_cost (rtx insn)
6092 + /* Basing the location of the pool on the loop depth is preferable, but at
6093 + the moment, the basic block information seems to be corrupt by this
6094 + stage of the compilation. */
6095 + int base_cost = 50;
6096 + rtx next = next_nonnote_insn (insn);
6098 + if (next != NULL && GET_CODE (next) == CODE_LABEL)
6101 + switch (GET_CODE (insn))
6104 + /* It will always be better to place the table before the label, rather
6113 + return base_cost - 10;
6116 + return base_cost + 10;
6121 +/* Find the best place in the insn stream in the range
6122 + (FIX->address,MAX_ADDRESS) to forcibly insert a minipool barrier.
6123 + Create the barrier by inserting a jump and add a new fix entry for
6126 +create_fix_barrier (Mfix * fix, HOST_WIDE_INT max_address)
6128 + HOST_WIDE_INT count = 0;
6130 + rtx from = fix->insn;
6131 + rtx selected = from;
6132 + int selected_cost;
6133 + HOST_WIDE_INT selected_address;
6135 + HOST_WIDE_INT max_count = max_address - fix->address;
6136 + rtx label = gen_label_rtx ();
6138 + selected_cost = avr32_barrier_cost (from);
6139 + selected_address = fix->address;
6141 + while (from && count < max_count)
6146 + /* This code shouldn't have been called if there was a natural barrier
6148 + if (GET_CODE (from) == BARRIER)
6151 + /* Count the length of this insn. */
6152 + count += get_attr_length (from);
6154 + /* If there is a jump table, add its length. */
6155 + tmp = is_jump_table (from);
6158 + count += get_jump_table_size (tmp);
6160 + /* Jump tables aren't in a basic block, so base the cost on the
6161 + dispatch insn. If we select this location, we will still put
6162 + the pool after the table. */
6163 + new_cost = avr32_barrier_cost (from);
6165 + if (count < max_count && new_cost <= selected_cost)
6168 + selected_cost = new_cost;
6169 + selected_address = fix->address + count;
6172 + /* Continue after the dispatch table. */
6173 + from = NEXT_INSN (tmp);
6177 + new_cost = avr32_barrier_cost (from);
6179 + if (count < max_count && new_cost <= selected_cost)
6182 + selected_cost = new_cost;
6183 + selected_address = fix->address + count;
6186 + from = NEXT_INSN (from);
6189 + /* Create a new JUMP_INSN that branches around a barrier. */
6190 + from = emit_jump_insn_after (gen_jump (label), selected);
6191 + JUMP_LABEL (from) = label;
6192 + barrier = emit_barrier_after (from);
6193 + emit_label_after (label, barrier);
6195 + /* Create a minipool barrier entry for the new barrier. */
6196 + new_fix = (Mfix *) obstack_alloc (&minipool_obstack, sizeof (*new_fix));
6197 + new_fix->insn = barrier;
6198 + new_fix->address = selected_address;
6199 + new_fix->next = fix->next;
6200 + fix->next = new_fix;
6206 +/* Record that there is a natural barrier in the insn stream at
6209 +push_minipool_barrier (rtx insn, HOST_WIDE_INT address)
6211 + Mfix *fix = (Mfix *) obstack_alloc (&minipool_obstack, sizeof (*fix));
6214 + fix->address = address;
6217 + if (minipool_fix_head != NULL)
6218 + minipool_fix_tail->next = fix;
6220 + minipool_fix_head = fix;
6222 + minipool_fix_tail = fix;
6226 +/* Record INSN, which will need fixing up to load a value from the
6227 + minipool. ADDRESS is the offset of the insn since the start of the
6228 + function; LOC is a pointer to the part of the insn which requires
6229 + fixing; VALUE is the constant that must be loaded, which is of type
6232 +push_minipool_fix (rtx insn, HOST_WIDE_INT address, rtx * loc,
6233 + enum machine_mode mode, rtx value)
6235 + Mfix *fix = (Mfix *) obstack_alloc (&minipool_obstack, sizeof (*fix));
6236 + rtx body = PATTERN (insn);
6239 + fix->address = address;
6242 + fix->fix_size = MINIPOOL_FIX_SIZE (mode, value);
6243 + fix->value = value;
6245 + if (GET_CODE (body) == PARALLEL)
6247 + /* Mcall : Ks16 << 2 */
6248 + fix->forwards = ((1 << 15) - 1) << 2;
6249 + fix->backwards = (1 << 15) << 2;
6251 + else if (GET_CODE (body) == SET
6252 + && GET_MODE_SIZE (GET_MODE (SET_DEST (body))) == 4)
6254 + if (optimize_size)
6256 + /* Lddpc : Ku7 << 2 */
6257 + fix->forwards = ((1 << 7) - 1) << 2;
6258 + fix->backwards = 0;
6263 + fix->forwards = ((1 << 15) - 4);
6264 + fix->backwards = (1 << 15);
6267 + else if (GET_CODE (body) == SET
6268 + && GET_MODE_SIZE (GET_MODE (SET_DEST (body))) == 8)
6271 + fix->forwards = ((1 << 15) - 4);
6272 + fix->backwards = (1 << 15);
6274 + else if (GET_CODE (body) == UNSPEC_VOLATILE
6275 + && XINT (body, 1) == VUNSPEC_MVRC)
6277 + /* Coprocessor load */
6278 + /* Ldc : Ku8 << 2 */
6279 + fix->forwards = ((1 << 8) - 1) << 2;
6280 + fix->backwards = 0;
6284 + /* Assume worst case which is lddpc insn. */
6285 + fix->forwards = ((1 << 7) - 1) << 2;
6286 + fix->backwards = 0;
6289 + fix->minipool = NULL;
6291 + /* If an insn doesn't have a range defined for it, then it isn't expecting
6292 + to be reworked by this code. Better to abort now than to generate duff
6294 + if (fix->forwards == 0 && fix->backwards == 0)
6299 + fprintf (dump_file,
6300 + ";; %smode fixup for i%d; addr %lu, range (%ld,%ld): ",
6301 + GET_MODE_NAME (mode),
6302 + INSN_UID (insn), (unsigned long) address,
6303 + -1 * (long) fix->backwards, (long) fix->forwards);
6304 + avr32_print_value (dump_file, fix->value);
6305 + fprintf (dump_file, "\n");
6308 + /* Add it to the chain of fixes. */
6311 + if (minipool_fix_head != NULL)
6312 + minipool_fix_tail->next = fix;
6314 + minipool_fix_head = fix;
6316 + minipool_fix_tail = fix;
6320 +/* Scan INSN and note any of its operands that need fixing.
6321 + If DO_PUSHES is false we do not actually push any of the fixups
6322 + needed. The function returns TRUE is any fixups were needed/pushed.
6323 + This is used by avr32_memory_load_p() which needs to know about loads
6324 + of constants that will be converted into minipool loads. */
6326 +note_invalid_constants (rtx insn, HOST_WIDE_INT address, int do_pushes)
6328 + bool result = false;
6331 + extract_insn (insn);
6333 + if (!constrain_operands (1))
6334 + fatal_insn_not_found (insn);
6336 + if (recog_data.n_alternatives == 0)
6339 + /* Fill in recog_op_alt with information about the constraints of this
6341 + preprocess_constraints ();
6343 + for (opno = 0; opno < recog_data.n_operands; opno++)
6347 + /* Things we need to fix can only occur in inputs. */
6348 + if (recog_data.operand_type[opno] != OP_IN)
6351 + op = recog_data.operand[opno];
6353 + if (avr32_const_pool_ref_operand (op, GET_MODE (op)))
6357 + rtx cop = avoid_constant_pool_reference (op);
6359 + /* Casting the address of something to a mode narrower than a
6360 + word can cause avoid_constant_pool_reference() to return the
6361 + pool reference itself. That's no good to us here. Lets
6362 + just hope that we can use the constant pool value directly.
6365 + cop = get_pool_constant (XEXP (op, 0));
6367 + push_minipool_fix (insn, address,
6368 + recog_data.operand_loc[opno],
6369 + recog_data.operand_mode[opno], cop);
6374 + else if (TARGET_HAS_ASM_ADDR_PSEUDOS
6375 + && avr32_address_operand (op, GET_MODE (op)))
6377 + /* Handle pseudo instructions using a direct address. These pseudo
6378 + instructions might need entries in the constant pool and we must
6379 + therefor create a constant pool for them, in case the
6380 + assembler/linker needs to insert entries. */
6383 + /* Push a dummy constant pool entry so that the .cpool
6384 + directive should be inserted on the appropriate place in the
6385 + code even if there are no real constant pool entries. This
6386 + is used by the assembler and linker to know where to put
6387 + generated constant pool entries. */
6388 + push_minipool_fix (insn, address,
6389 + recog_data.operand_loc[opno],
6390 + recog_data.operand_mode[opno],
6391 + gen_rtx_UNSPEC (VOIDmode,
6392 + gen_rtvec (1, const0_rtx),
6393 + UNSPEC_FORCE_MINIPOOL));
6403 +avr32_insn_is_cast (rtx insn)
6406 + if (NONJUMP_INSN_P (insn)
6407 + && GET_CODE (PATTERN (insn)) == SET
6408 + && (GET_CODE (SET_SRC (PATTERN (insn))) == ZERO_EXTEND
6409 + || GET_CODE (SET_SRC (PATTERN (insn))) == SIGN_EXTEND)
6410 + && REG_P (XEXP (SET_SRC (PATTERN (insn)), 0))
6411 + && REG_P (SET_DEST (PATTERN (insn))))
6417 +/* Replace all occurances of reg FROM with reg TO in X. */
6419 +avr32_replace_reg (rtx x, rtx from, rtx to)
6424 + gcc_assert ( REG_P (from) && REG_P (to) );
6426 + /* Allow this function to make replacements in EXPR_LISTs. */
6430 + if (rtx_equal_p (x, from))
6433 + if (GET_CODE (x) == SUBREG)
6435 + rtx new = avr32_replace_reg (SUBREG_REG (x), from, to);
6437 + if (GET_CODE (new) == CONST_INT)
6439 + x = simplify_subreg (GET_MODE (x), new,
6440 + GET_MODE (SUBREG_REG (x)),
6445 + SUBREG_REG (x) = new;
6449 + else if (GET_CODE (x) == ZERO_EXTEND)
6451 + rtx new = avr32_replace_reg (XEXP (x, 0), from, to);
6453 + if (GET_CODE (new) == CONST_INT)
6455 + x = simplify_unary_operation (ZERO_EXTEND, GET_MODE (x),
6456 + new, GET_MODE (XEXP (x, 0)));
6460 + XEXP (x, 0) = new;
6465 + fmt = GET_RTX_FORMAT (GET_CODE (x));
6466 + for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
6468 + if (fmt[i] == 'e')
6469 + XEXP (x, i) = avr32_replace_reg (XEXP (x, i), from, to);
6470 + else if (fmt[i] == 'E')
6471 + for (j = XVECLEN (x, i) - 1; j >= 0; j--)
6472 + XVECEXP (x, i, j) = avr32_replace_reg (XVECEXP (x, i, j), from, to);
6479 +/* FIXME: The level of nesting in this function is way too deep. It needs to be
6482 +avr32_reorg_optimization (void)
6484 + rtx first = get_first_nonnote_insn ();
6487 + if (TARGET_MD_REORG_OPTIMIZATION && (optimize_size || (optimize > 0)))
6490 + /* Scan through all insns looking for cast operations. */
6493 + fprintf (dump_file, ";; Deleting redundant cast operations:\n");
6495 + for (insn = first; insn; insn = NEXT_INSN (insn))
6497 + rtx reg, src_reg, scan;
6498 + enum machine_mode mode;
6502 + if (avr32_insn_is_cast (insn)
6503 + && (GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 0)) == QImode
6504 + || GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 0)) == HImode))
6506 + mode = GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 0));
6507 + reg = SET_DEST (PATTERN (insn));
6508 + src_reg = XEXP (SET_SRC (PATTERN (insn)), 0);
6515 + unused_cast = false;
6516 + label_ref = NULL_RTX;
6517 + for (scan = NEXT_INSN (insn); scan; scan = NEXT_INSN (scan))
6519 + /* Check if we have reached the destination of a simple
6520 + conditional jump which we have already scanned past. If so,
6521 + we can safely continue scanning. */
6522 + if (LABEL_P (scan) && label_ref != NULL_RTX)
6524 + if (CODE_LABEL_NUMBER (scan) ==
6525 + CODE_LABEL_NUMBER (XEXP (label_ref, 0)))
6526 + label_ref = NULL_RTX;
6531 + if (!INSN_P (scan))
6534 + /* For conditional jumps we can manage to keep on scanning if
6535 + we meet the destination label later on before any new jump
6537 + if (GET_CODE (scan) == JUMP_INSN)
6539 + if (any_condjump_p (scan) && label_ref == NULL_RTX)
6540 + label_ref = condjump_label (scan);
6545 + /* Check if we have a call and the register is used as an argument. */
6547 + && find_reg_fusage (scan, USE, reg) )
6550 + if (!reg_mentioned_p (reg, PATTERN (scan)))
6553 + /* Check if casted register is used in this insn */
6554 + if ((regno_use_in (REGNO (reg), PATTERN (scan)) != NULL_RTX)
6555 + && (GET_MODE (regno_use_in (REGNO (reg), PATTERN (scan))) ==
6558 + /* If not used in the source to the set or in a memory
6559 + expression in the destiantion then the register is used
6560 + as a destination and is really dead. */
6561 + if (single_set (scan)
6562 + && GET_CODE (PATTERN (scan)) == SET
6563 + && REG_P (SET_DEST (PATTERN (scan)))
6564 + && !regno_use_in (REGNO (reg), SET_SRC (PATTERN (scan)))
6565 + && label_ref == NULL_RTX)
6567 + unused_cast = true;
6572 + /* Check if register is dead or set in this insn */
6573 + if (dead_or_set_p (scan, reg))
6575 + unused_cast = true;
6580 + /* Check if we have unresolved conditional jumps */
6581 + if (label_ref != NULL_RTX)
6586 + if (REGNO (reg) == REGNO (XEXP (SET_SRC (PATTERN (insn)), 0)))
6588 + /* One operand cast, safe to delete */
6591 + fprintf (dump_file,
6592 + ";; INSN %i removed, casted register %i value not used.\n",
6593 + INSN_UID (insn), REGNO (reg));
6595 + SET_INSN_DELETED (insn);
6596 + /* Force the instruction to be recognized again */
6597 + INSN_CODE (insn) = -1;
6601 + /* Two operand cast, which really could be substituted with
6602 + a move, if the source register is dead after the cast
6603 + insn and then the insn which sets the source register
6604 + could instead directly set the destination register for
6605 + the cast. As long as there are no insns in between which
6606 + uses the register. */
6607 + rtx link = NULL_RTX;
6609 + rtx src_reg = XEXP (SET_SRC (PATTERN (insn)), 0);
6610 + unused_cast = false;
6612 + if (!find_reg_note (insn, REG_DEAD, src_reg))
6615 + /* Search for the insn which sets the source register */
6616 + for (scan = PREV_INSN (insn);
6617 + scan && GET_CODE (scan) != CODE_LABEL;
6618 + scan = PREV_INSN (scan))
6620 + if (! INSN_P (scan))
6623 + set = single_set (scan);
6624 + // Fix for bug #11763 : the following if condition
6625 + // has been modified and else part is included to
6626 + // set the link to NULL_RTX.
6627 + // if (set && rtx_equal_p (src_reg, SET_DEST (set)))
6628 + if (set && (REGNO(src_reg) == REGNO(SET_DEST(set))))
6630 + if (rtx_equal_p (src_reg, SET_DEST (set)))
6644 + /* Found no link or link is a call insn where we can not
6645 + change the destination register */
6646 + if (link == NULL_RTX || CALL_P (link))
6649 + /* Scan through all insn between link and insn */
6650 + for (scan = NEXT_INSN (link); scan; scan = NEXT_INSN (scan))
6652 + /* Don't try to trace forward past a CODE_LABEL if we
6653 + haven't seen INSN yet. Ordinarily, we will only
6654 + find the setting insn in LOG_LINKS if it is in the
6655 + same basic block. However, cross-jumping can insert
6656 + code labels in between the load and the call, and
6657 + can result in situations where a single call insn
6658 + may have two targets depending on where we came
6661 + if (GET_CODE (scan) == CODE_LABEL)
6664 + if (!INSN_P (scan))
6667 + /* Don't try to trace forward past a JUMP. To optimize
6668 + safely, we would have to check that all the
6669 + instructions at the jump destination did not use REG.
6672 + if (GET_CODE (scan) == JUMP_INSN)
6677 + if (!reg_mentioned_p (src_reg, PATTERN (scan)))
6680 + /* We have reached the cast insn */
6683 + /* We can remove cast and replace the destination
6684 + register of the link insn with the destination
6688 + fprintf (dump_file,
6689 + ";; INSN %i removed, casted value unused. "
6690 + "Destination of removed cast operation: register %i, folded into INSN %i.\n",
6691 + INSN_UID (insn), REGNO (reg),
6694 + /* Update link insn */
6695 + SET_DEST (PATTERN (link)) =
6696 + gen_rtx_REG (mode, REGNO (reg));
6697 + /* Force the instruction to be recognized again */
6698 + INSN_CODE (link) = -1;
6701 + SET_INSN_DELETED (insn);
6702 + /* Force the instruction to be recognized again */
6703 + INSN_CODE (insn) = -1;
6712 + if (TARGET_MD_REORG_OPTIMIZATION && (optimize_size || (optimize > 0)))
6715 + /* Scan through all insns looking for shifted add operations */
6718 + fprintf (dump_file,
6719 + ";; Deleting redundant shifted add operations:\n");
6721 + for (insn = first; insn; insn = NEXT_INSN (insn))
6723 + rtx reg, mem_expr, scan, op0, op1;
6724 + int add_only_used_as_pointer;
6727 + && GET_CODE (PATTERN (insn)) == SET
6728 + && GET_CODE (SET_SRC (PATTERN (insn))) == PLUS
6729 + && (GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 0)) == MULT
6730 + || GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 0)) == ASHIFT)
6731 + && GET_CODE (XEXP (XEXP (SET_SRC (PATTERN (insn)), 0), 1)) ==
6732 + CONST_INT && REG_P (SET_DEST (PATTERN (insn)))
6733 + && REG_P (XEXP (SET_SRC (PATTERN (insn)), 1))
6734 + && REG_P (XEXP (XEXP (SET_SRC (PATTERN (insn)), 0), 0)))
6736 + reg = SET_DEST (PATTERN (insn));
6737 + mem_expr = SET_SRC (PATTERN (insn));
6738 + op0 = XEXP (XEXP (mem_expr, 0), 0);
6739 + op1 = XEXP (mem_expr, 1);
6746 + /* Scan forward the check if the result of the shifted add
6747 + operation is only used as an address in memory operations and
6748 + that the operands to the shifted add are not clobbered. */
6749 + add_only_used_as_pointer = false;
6750 + for (scan = NEXT_INSN (insn); scan; scan = NEXT_INSN (scan))
6752 + if (!INSN_P (scan))
6755 + /* Don't try to trace forward past a JUMP or CALL. To optimize
6756 + safely, we would have to check that all the instructions at
6757 + the jump destination did not use REG. */
6759 + if (GET_CODE (scan) == JUMP_INSN)
6764 + /* If used in a call insn then we cannot optimize it away */
6765 + if (CALL_P (scan) && find_regno_fusage (scan, USE, REGNO (reg)))
6768 + /* If any of the operands of the shifted add are clobbered we
6769 + cannot optimize the shifted adda away */
6770 + if ((reg_set_p (op0, scan) && (REGNO (op0) != REGNO (reg)))
6771 + || (reg_set_p (op1, scan) && (REGNO (op1) != REGNO (reg))))
6774 + if (!reg_mentioned_p (reg, PATTERN (scan)))
6777 + /* If used any other place than as a pointer or as the
6778 + destination register we failed */
6779 + if (!(single_set (scan)
6780 + && GET_CODE (PATTERN (scan)) == SET
6781 + && ((MEM_P (SET_DEST (PATTERN (scan)))
6782 + && REG_P (XEXP (SET_DEST (PATTERN (scan)), 0))
6783 + && REGNO (XEXP (SET_DEST (PATTERN (scan)), 0)) == REGNO (reg))
6784 + || (MEM_P (SET_SRC (PATTERN (scan)))
6785 + && REG_P (XEXP (SET_SRC (PATTERN (scan)), 0))
6787 + (SET_SRC (PATTERN (scan)), 0)) == REGNO (reg))))
6788 + && !(GET_CODE (PATTERN (scan)) == SET
6789 + && REG_P (SET_DEST (PATTERN (scan)))
6790 + && !regno_use_in (REGNO (reg),
6791 + SET_SRC (PATTERN (scan)))))
6794 + /* We cannot replace the pointer in TImode insns
6795 + as these has a differene addressing mode than the other
6797 + if ( GET_MODE (SET_DEST (PATTERN (scan))) == TImode )
6800 + /* Check if register is dead or set in this insn */
6801 + if (dead_or_set_p (scan, reg))
6803 + add_only_used_as_pointer = true;
6808 + if (add_only_used_as_pointer)
6810 + /* Lets delete the add insn and replace all memory references
6811 + which uses the pointer with the full expression. */
6814 + fprintf (dump_file,
6815 + ";; Deleting INSN %i since address expression can be folded into all "
6816 + "memory references using this expression\n",
6819 + SET_INSN_DELETED (insn);
6820 + /* Force the instruction to be recognized again */
6821 + INSN_CODE (insn) = -1;
6823 + for (scan = NEXT_INSN (insn); scan; scan = NEXT_INSN (scan))
6825 + if (!INSN_P (scan))
6828 + if (!reg_mentioned_p (reg, PATTERN (scan)))
6831 + /* If used any other place than as a pointer or as the
6832 + destination register we failed */
6833 + if ((single_set (scan)
6834 + && GET_CODE (PATTERN (scan)) == SET
6835 + && ((MEM_P (SET_DEST (PATTERN (scan)))
6836 + && REG_P (XEXP (SET_DEST (PATTERN (scan)), 0))
6837 + && REGNO (XEXP (SET_DEST (PATTERN (scan)), 0)) ==
6838 + REGNO (reg)) || (MEM_P (SET_SRC (PATTERN (scan)))
6841 + (SET_SRC (PATTERN (scan)),
6845 + (SET_SRC (PATTERN (scan)),
6846 + 0)) == REGNO (reg)))))
6850 + fprintf (dump_file,
6851 + ";; Register %i replaced by indexed address in INSN %i\n",
6852 + REGNO (reg), INSN_UID (scan));
6854 + if (MEM_P (SET_DEST (PATTERN (scan))))
6855 + XEXP (SET_DEST (PATTERN (scan)), 0) = mem_expr;
6857 + XEXP (SET_SRC (PATTERN (scan)), 0) = mem_expr;
6860 + /* Check if register is dead or set in this insn */
6861 + if (dead_or_set_p (scan, reg))
6872 + if (TARGET_MD_REORG_OPTIMIZATION && (optimize_size || (optimize > 0)))
6875 + /* Scan through all insns looking for conditional register to
6876 + register move operations */
6879 + fprintf (dump_file,
6880 + ";; Folding redundant conditional move operations:\n");
6882 + for (insn = first; insn; insn = next_nonnote_insn (insn))
6884 + rtx src_reg, dst_reg, scan, test;
6887 + && GET_CODE (PATTERN (insn)) == COND_EXEC
6888 + && GET_CODE (COND_EXEC_CODE (PATTERN (insn))) == SET
6889 + && REG_P (SET_SRC (COND_EXEC_CODE (PATTERN (insn))))
6890 + && REG_P (SET_DEST (COND_EXEC_CODE (PATTERN (insn))))
6891 + && find_reg_note (insn, REG_DEAD, SET_SRC (COND_EXEC_CODE (PATTERN (insn)))))
6893 + src_reg = SET_SRC (COND_EXEC_CODE (PATTERN (insn)));
6894 + dst_reg = SET_DEST (COND_EXEC_CODE (PATTERN (insn)));
6895 + test = COND_EXEC_TEST (PATTERN (insn));
6902 + /* Scan backward through the rest of insns in this if-then or if-else
6903 + block and check if we can fold the move into another of the conditional
6904 + insns in the same block. */
6905 + scan = prev_nonnote_insn (insn);
6906 + while (INSN_P (scan)
6907 + && GET_CODE (PATTERN (scan)) == COND_EXEC
6908 + && rtx_equal_p (COND_EXEC_TEST (PATTERN (scan)), test))
6910 + rtx pattern = COND_EXEC_CODE (PATTERN (scan));
6911 + if ( GET_CODE (pattern) == PARALLEL )
6912 + pattern = XVECEXP (pattern, 0, 0);
6914 + if ( reg_set_p (src_reg, pattern) )
6916 + /* Fold in the destination register for the cond. move
6917 + into this insn. */
6918 + SET_DEST (pattern) = dst_reg;
6921 + fprintf (dump_file,
6922 + ";; Deleting INSN %i since this operation can be folded into INSN %i\n",
6923 + INSN_UID (insn), INSN_UID (scan));
6926 + /* Scan and check if any of the insns in between uses the src_reg. We
6927 + must then replace it with the dst_reg. */
6928 + while ( (scan = next_nonnote_insn (scan)) != insn ){
6929 + avr32_replace_reg (scan, src_reg, dst_reg);
6931 + /* Delete the insn. */
6932 + SET_INSN_DELETED (insn);
6934 + /* Force the instruction to be recognized again */
6935 + INSN_CODE (insn) = -1;
6939 + /* If the destination register is used but not set in this insn
6940 + we cannot fold. */
6941 + if ( reg_mentioned_p (dst_reg, pattern) )
6944 + scan = prev_nonnote_insn (scan);
6952 +/* Exported to toplev.c.
6954 + Do a final pass over the function, just before delayed branch
6960 + HOST_WIDE_INT address = 0;
6963 + minipool_fix_head = minipool_fix_tail = NULL;
6965 + /* The first insn must always be a note, or the code below won't scan it
6967 + insn = get_insns ();
6968 + if (GET_CODE (insn) != NOTE)
6971 + /* Scan all the insns and record the operands that will need fixing. */
6972 + for (insn = next_nonnote_insn (insn); insn; insn = next_nonnote_insn (insn))
6974 + if (GET_CODE (insn) == BARRIER)
6975 + push_minipool_barrier (insn, address);
6976 + else if (INSN_P (insn))
6980 + note_invalid_constants (insn, address, true);
6981 + address += get_attr_length (insn);
6983 + /* If the insn is a vector jump, add the size of the table and skip
6985 + if ((table = is_jump_table (insn)) != NULL)
6987 + address += get_jump_table_size (table);
6993 + fix = minipool_fix_head;
6995 + /* Now scan the fixups and perform the required changes. */
7000 + Mfix *last_added_fix;
7001 + Mfix *last_barrier = NULL;
7004 + /* Skip any further barriers before the next fix. */
7005 + while (fix && GET_CODE (fix->insn) == BARRIER)
7008 + /* No more fixes. */
7012 + last_added_fix = NULL;
7014 + for (ftmp = fix; ftmp; ftmp = ftmp->next)
7016 + if (GET_CODE (ftmp->insn) == BARRIER)
7018 + if (ftmp->address >= minipool_vector_head->max_address)
7021 + last_barrier = ftmp;
7023 + else if ((ftmp->minipool = add_minipool_forward_ref (ftmp)) == NULL)
7026 + last_added_fix = ftmp; /* Keep track of the last fix added.
7030 + /* If we found a barrier, drop back to that; any fixes that we could
7031 + have reached but come after the barrier will now go in the next
7033 + if (last_barrier != NULL)
7035 + /* Reduce the refcount for those fixes that won't go into this pool
7037 + for (fdel = last_barrier->next;
7038 + fdel && fdel != ftmp; fdel = fdel->next)
7040 + fdel->minipool->refcount--;
7041 + fdel->minipool = NULL;
7044 + ftmp = last_barrier;
7048 + /* ftmp is first fix that we can't fit into this pool and there no
7049 + natural barriers that we could use. Insert a new barrier in the
7050 + code somewhere between the previous fix and this one, and
7051 + arrange to jump around it. */
7052 + HOST_WIDE_INT max_address;
7054 + /* The last item on the list of fixes must be a barrier, so we can
7055 + never run off the end of the list of fixes without last_barrier
7060 + max_address = minipool_vector_head->max_address;
7061 + /* Check that there isn't another fix that is in range that we
7062 + couldn't fit into this pool because the pool was already too
7063 + large: we need to put the pool before such an instruction. */
7064 + if (ftmp->address < max_address)
7065 + max_address = ftmp->address;
7067 + last_barrier = create_fix_barrier (last_added_fix, max_address);
7070 + assign_minipool_offsets (last_barrier);
7074 + if (GET_CODE (ftmp->insn) != BARRIER
7075 + && ((ftmp->minipool = add_minipool_backward_ref (ftmp))
7079 + ftmp = ftmp->next;
7082 + /* Scan over the fixes we have identified for this pool, fixing them up
7083 + and adding the constants to the pool itself. */
7084 + for (this_fix = fix; this_fix && ftmp != this_fix;
7085 + this_fix = this_fix->next)
7086 + if (GET_CODE (this_fix->insn) != BARRIER
7087 + /* Do nothing for entries present just to force the insertion of
7089 + && !IS_FORCE_MINIPOOL (this_fix->value))
7091 + rtx addr = plus_constant (gen_rtx_LABEL_REF (VOIDmode,
7092 + minipool_vector_label),
7093 + this_fix->minipool->offset);
7094 + *this_fix->loc = gen_rtx_MEM (this_fix->mode, addr);
7097 + dump_minipool (last_barrier->insn);
7101 + /* Free the minipool memory. */
7102 + obstack_free (&minipool_obstack, minipool_startobj);
7104 + avr32_reorg_optimization ();
7108 +/* Hook for doing some final scanning of instructions. Does nothing yet...*/
7110 +avr32_final_prescan_insn (rtx insn ATTRIBUTE_UNUSED,
7111 + rtx * opvec ATTRIBUTE_UNUSED,
7112 + int noperands ATTRIBUTE_UNUSED)
7118 +/* Function for changing the condition on the next instruction,
7119 + should be used when emmiting compare instructions and
7120 + the condition of the next instruction needs to change.
7123 +set_next_insn_cond (rtx cur_insn, rtx new_cond)
7125 + rtx next_insn = next_nonnote_insn (cur_insn);
7126 + if ((next_insn != NULL_RTX)
7127 + && (INSN_P (next_insn)))
7129 + if ((GET_CODE (PATTERN (next_insn)) == SET)
7130 + && (GET_CODE (SET_SRC (PATTERN (next_insn))) == IF_THEN_ELSE))
7132 + /* Branch instructions */
7133 + XEXP (SET_SRC (PATTERN (next_insn)), 0) = new_cond;
7134 + /* Force the instruction to be recognized again */
7135 + INSN_CODE (next_insn) = -1;
7138 + else if ((GET_CODE (PATTERN (next_insn)) == SET)
7139 + && avr32_comparison_operator (SET_SRC (PATTERN (next_insn)),
7140 + GET_MODE (SET_SRC (PATTERN (next_insn)))))
7142 + /* scc with no compare */
7143 + SET_SRC (PATTERN (next_insn)) = new_cond;
7144 + /* Force the instruction to be recognized again */
7145 + INSN_CODE (next_insn) = -1;
7148 + else if (GET_CODE (PATTERN (next_insn)) == COND_EXEC)
7150 + if ( GET_CODE (new_cond) == UNSPEC )
7152 + COND_EXEC_TEST (PATTERN (next_insn)) =
7153 + gen_rtx_UNSPEC (CCmode,
7155 + XEXP (COND_EXEC_TEST (PATTERN (next_insn)), 0),
7156 + XEXP (COND_EXEC_TEST (PATTERN (next_insn)), 1)),
7157 + XINT (new_cond, 1));
7161 + PUT_CODE(COND_EXEC_TEST (PATTERN (next_insn)), GET_CODE(new_cond));
7170 +/* Function for obtaining the condition for the next instruction after cur_insn.
7173 +get_next_insn_cond (rtx cur_insn)
7175 + rtx next_insn = next_nonnote_insn (cur_insn);
7176 + rtx cond = NULL_RTX;
7177 + if (next_insn != NULL_RTX
7178 + && INSN_P (next_insn))
7180 + if ((GET_CODE (PATTERN (next_insn)) == SET)
7181 + && (GET_CODE (SET_SRC (PATTERN (next_insn))) == IF_THEN_ELSE))
7183 + /* Branch and cond if then else instructions */
7184 + cond = XEXP (SET_SRC (PATTERN (next_insn)), 0);
7186 + else if ((GET_CODE (PATTERN (next_insn)) == SET)
7187 + && avr32_comparison_operator (SET_SRC (PATTERN (next_insn)),
7188 + GET_MODE (SET_SRC (PATTERN (next_insn)))))
7190 + /* scc with no compare */
7191 + cond = SET_SRC (PATTERN (next_insn));
7193 + else if (GET_CODE (PATTERN (next_insn)) == COND_EXEC)
7195 + cond = COND_EXEC_TEST (PATTERN (next_insn));
7202 +/* Check if the next insn is a conditional insn that will emit a compare
7206 +next_insn_emits_cmp (rtx cur_insn)
7208 + rtx next_insn = next_nonnote_insn (cur_insn);
7209 + rtx cond = NULL_RTX;
7210 + if (next_insn != NULL_RTX
7211 + && INSN_P (next_insn))
7213 + if ( ((GET_CODE (PATTERN (next_insn)) == SET)
7214 + && (GET_CODE (SET_SRC (PATTERN (next_insn))) == IF_THEN_ELSE)
7215 + && (XEXP (XEXP (SET_SRC (PATTERN (next_insn)), 0),0) != cc0_rtx))
7216 + || GET_CODE (PATTERN (next_insn)) == COND_EXEC )
7224 +avr32_output_cmp (rtx cond, enum machine_mode mode, rtx op0, rtx op1)
7227 + rtx new_cond = NULL_RTX;
7229 + rtx compare_pattern;
7233 + if ( GET_CODE (op0) == AND )
7234 + compare_pattern = op0;
7236 + compare_pattern = gen_rtx_COMPARE (mode, op0, op1);
7238 + new_cond = is_compare_redundant (compare_pattern, cond);
7240 + if (new_cond != NULL_RTX)
7243 + /* Check if we are inserting a bit-load instead of a compare. */
7244 + if ( GET_CODE (op0) == AND )
7246 + ops[0] = XEXP (op0, 0);
7247 + ops[1] = XEXP (op0, 1);
7248 + output_asm_insn ("bld\t%0, %p1", ops);
7252 + /* Insert compare */
7256 + output_asm_insn ("cp.b\t%0, %1", ops);
7259 + output_asm_insn ("cp.h\t%0, %1", ops);
7262 + output_asm_insn ("cp.w\t%0, %1", ops);
7265 + if (GET_CODE (op1) != REG)
7266 + output_asm_insn ("cp.w\t%0, %1\ncpc\t%m0", ops);
7268 + output_asm_insn ("cp.w\t%0, %1\ncpc\t%m0, %m1", ops);
7271 + internal_error ("Unknown comparison mode");
7280 +avr32_load_multiple_operation (rtx op,
7281 + enum machine_mode mode ATTRIBUTE_UNUSED)
7283 + int count = XVECLEN (op, 0);
7284 + unsigned int dest_regno;
7287 + int i = 1, base = 0;
7289 + if (count <= 1 || GET_CODE (XVECEXP (op, 0, 0)) != SET)
7292 + /* Check to see if this might be a write-back. */
7293 + if (GET_CODE (SET_SRC (elt = XVECEXP (op, 0, 0))) == PLUS)
7298 + /* Now check it more carefully. */
7299 + if (GET_CODE (SET_DEST (elt)) != REG
7300 + || GET_CODE (XEXP (SET_SRC (elt), 0)) != REG
7301 + || GET_CODE (XEXP (SET_SRC (elt), 1)) != CONST_INT
7302 + || INTVAL (XEXP (SET_SRC (elt), 1)) != (count - 1) * 4)
7306 + /* Perform a quick check so we don't blow up below. */
7308 + || GET_CODE (XVECEXP (op, 0, i - 1)) != SET
7309 + || GET_CODE (SET_DEST (XVECEXP (op, 0, i - 1))) != REG
7310 + || GET_CODE (SET_SRC (XVECEXP (op, 0, i - 1))) != UNSPEC)
7313 + dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, i - 1)));
7314 + src_addr = XEXP (SET_SRC (XVECEXP (op, 0, i - 1)), 0);
7316 + for (; i < count; i++)
7318 + elt = XVECEXP (op, 0, i);
7320 + if (GET_CODE (elt) != SET
7321 + || GET_CODE (SET_DEST (elt)) != REG
7322 + || GET_MODE (SET_DEST (elt)) != SImode
7323 + || GET_CODE (SET_SRC (elt)) != UNSPEC)
7332 +avr32_store_multiple_operation (rtx op,
7333 + enum machine_mode mode ATTRIBUTE_UNUSED)
7335 + int count = XVECLEN (op, 0);
7341 + if (count <= 1 || GET_CODE (XVECEXP (op, 0, 0)) != SET)
7344 + /* Perform a quick check so we don't blow up below. */
7346 + || GET_CODE (XVECEXP (op, 0, i - 1)) != SET
7347 + || GET_CODE (SET_DEST (XVECEXP (op, 0, i - 1))) != MEM
7348 + || GET_CODE (SET_SRC (XVECEXP (op, 0, i - 1))) != UNSPEC)
7351 + src_regno = REGNO (SET_SRC (XVECEXP (op, 0, i - 1)));
7352 + dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, i - 1)), 0);
7354 + for (; i < count; i++)
7356 + elt = XVECEXP (op, 0, i);
7358 + if (GET_CODE (elt) != SET
7359 + || GET_CODE (SET_DEST (elt)) != MEM
7360 + || GET_MODE (SET_DEST (elt)) != SImode
7361 + || GET_CODE (SET_SRC (elt)) != UNSPEC)
7370 +avr32_valid_macmac_bypass (rtx insn_out, rtx insn_in)
7372 + /* Check if they use the same accumulator */
7374 + (SET_DEST (PATTERN (insn_out)), SET_DEST (PATTERN (insn_in))))
7384 +avr32_valid_mulmac_bypass (rtx insn_out, rtx insn_in)
7387 + Check if the mul instruction produces the accumulator for the mac
7390 + (SET_DEST (PATTERN (insn_out)), SET_DEST (PATTERN (insn_in))))
7399 +avr32_store_bypass (rtx insn_out, rtx insn_in)
7401 + /* Only valid bypass if the output result is used as an src in the store
7402 + instruction, NOT if used as a pointer or base. */
7404 + (SET_DEST (PATTERN (insn_out)), SET_SRC (PATTERN (insn_in))))
7414 +avr32_mul_waw_bypass (rtx insn_out, rtx insn_in)
7416 + /* Check if the register holding the result from the mul instruction is
7417 + used as a result register in the input instruction. */
7419 + (SET_DEST (PATTERN (insn_out)), SET_DEST (PATTERN (insn_in))))
7429 +avr32_valid_load_double_bypass (rtx insn_out, rtx insn_in)
7431 + /* Check if the first loaded word in insn_out is used in insn_in. */
7433 + rtx second_loaded_reg;
7435 + /* If this is a double alu operation then the bypass is not valid */
7436 + if ((get_attr_type (insn_in) == TYPE_ALU
7437 + || get_attr_type (insn_in) == TYPE_ALU2)
7438 + && (GET_MODE_SIZE (GET_MODE (SET_DEST (PATTERN (insn_out)))) > 4))
7441 + /* Get the destination register in the load */
7442 + if (!REG_P (SET_DEST (PATTERN (insn_out))))
7445 + dst_reg = SET_DEST (PATTERN (insn_out));
7446 + second_loaded_reg = gen_rtx_REG (SImode, REGNO (dst_reg) + 1);
7448 + if (!reg_mentioned_p (second_loaded_reg, PATTERN (insn_in)))
7456 +avr32_valid_load_quad_bypass (rtx insn_out, rtx insn_in)
7459 + Check if the two first loaded word in insn_out are used in insn_in. */
7461 + rtx third_loaded_reg, fourth_loaded_reg;
7463 + /* Get the destination register in the load */
7464 + if (!REG_P (SET_DEST (PATTERN (insn_out))))
7467 + dst_reg = SET_DEST (PATTERN (insn_out));
7468 + third_loaded_reg = gen_rtx_REG (SImode, REGNO (dst_reg) + 2);
7469 + fourth_loaded_reg = gen_rtx_REG (SImode, REGNO (dst_reg) + 3);
7471 + if (!reg_mentioned_p (third_loaded_reg, PATTERN (insn_in))
7472 + && !reg_mentioned_p (fourth_loaded_reg, PATTERN (insn_in)))
7482 +avr32_ifcvt_modify_test (ce_if_block_t *ce_info, rtx test )
7491 + || test == NULL_RTX
7492 + || !reg_mentioned_p (cc0_rtx, test))
7495 + branch_insn = BB_END (ce_info->test_bb);
7496 + cmp_test = PATTERN(prev_nonnote_insn (branch_insn));
7498 + if (GET_CODE(cmp_test) != SET
7499 + || !CC0_P(XEXP(cmp_test, 0)) )
7502 + if ( GET_CODE(SET_SRC(cmp_test)) == COMPARE ){
7503 + compare_op0 = XEXP(SET_SRC(cmp_test), 0);
7504 + compare_op1 = XEXP(SET_SRC(cmp_test), 1);
7506 + compare_op0 = SET_SRC(cmp_test);
7507 + compare_op1 = const0_rtx;
7510 + return gen_rtx_fmt_ee (GET_CODE(test), GET_MODE (compare_op0),
7511 + compare_op0, compare_op1);
7516 +avr32_ifcvt_modify_insn (ce_if_block_t *ce_info, rtx pattern, rtx insn,
7517 + int *num_true_changes)
7519 + rtx test = COND_EXEC_TEST(pattern);
7520 + rtx op = COND_EXEC_CODE(pattern);
7522 + rtx cond_exec_insn;
7523 + int inputs_set_outside_ifblock = 1;
7524 + basic_block current_bb = BLOCK_FOR_INSN (insn);
7526 + enum machine_mode mode = GET_MODE (XEXP (op, 0));
7528 + if (CC0_P(XEXP(test, 0)))
7529 + test = avr32_ifcvt_modify_test (ce_info,
7532 + /* We do not support multiple tests. */
7534 + && ce_info->num_multiple_test_blocks > 0 )
7537 + pattern = gen_rtx_COND_EXEC (VOIDmode, test, op);
7539 + if ( !reload_completed )
7543 + int max_insns = MAX_CONDITIONAL_EXECUTE;
7548 + /* Check if the insn is not suitable for conditional
7550 + start_sequence ();
7551 + cond_exec_insn = emit_insn (pattern);
7552 + if ( recog_memoized (cond_exec_insn) < 0
7553 + && can_create_pseudo_p () )
7555 + /* Insn is not suitable for conditional execution, try
7556 + to fix it up by using an extra scratch register or
7557 + by pulling the operation outside the if-then-else
7558 + and then emiting a conditional move inside the if-then-else. */
7560 + if ( GET_CODE (op) != SET
7561 + || !REG_P (SET_DEST (op))
7562 + || GET_CODE (SET_SRC (op)) == IF_THEN_ELSE
7563 + || GET_MODE_SIZE (mode) > UNITS_PER_WORD )
7566 + /* Check if any of the input operands to the insn is set inside the
7568 + if ( current_bb->index == ce_info->then_bb->index )
7569 + start = PREV_INSN (BB_HEAD (ce_info->then_bb));
7571 + start = PREV_INSN (BB_HEAD (ce_info->else_bb));
7574 + for ( bb_insn = next_nonnote_insn (start); bb_insn != insn; bb_insn = next_nonnote_insn (bb_insn) )
7576 + rtx set = single_set (bb_insn);
7578 + if ( set && reg_mentioned_p (SET_DEST (set), SET_SRC (op)))
7580 + inputs_set_outside_ifblock = 0;
7585 + cmp_insn = prev_nonnote_insn (BB_END (ce_info->test_bb));
7588 + /* Check if we can insert more insns. */
7589 + num_insns = ( ce_info->num_then_insns +
7590 + ce_info->num_else_insns +
7591 + ce_info->num_cond_clobber_insns +
7592 + ce_info->num_extra_move_insns );
7594 + if ( ce_info->num_else_insns != 0 )
7597 + if ( num_insns >= max_insns )
7600 + /* Check if we have an instruction which might be converted to
7601 + conditional form if we give it a scratch register to clobber. */
7604 + rtx scratch_reg = gen_reg_rtx (mode);
7605 + rtx new_pattern = copy_rtx (pattern);
7606 + rtx set_src = SET_SRC (COND_EXEC_CODE (new_pattern));
7608 + rtx clobber = gen_rtx_CLOBBER (mode, scratch_reg);
7609 + rtx vec[2] = { COND_EXEC_CODE (new_pattern), clobber };
7610 + COND_EXEC_CODE (new_pattern) = gen_rtx_PARALLEL (mode, gen_rtvec_v (2, vec));
7612 + start_sequence ();
7613 + clobber_insn = emit_insn (new_pattern);
7615 + if ( recog_memoized (clobber_insn) >= 0
7616 + && ( ( GET_RTX_LENGTH (GET_CODE (set_src)) == 2
7617 + && CONST_INT_P (XEXP (set_src, 1))
7618 + && avr32_const_ok_for_constraint_p (INTVAL (XEXP (set_src, 1)), 'K', "Ks08") )
7619 + || !ce_info->else_bb
7620 + || current_bb->index == ce_info->else_bb->index ))
7623 + /* Force the insn to be recognized again. */
7624 + INSN_CODE (insn) = -1;
7626 + /* If this is the first change in this IF-block then
7627 + signal that we have made a change. */
7628 + if ( ce_info->num_cond_clobber_insns == 0
7629 + && ce_info->num_extra_move_insns == 0 )
7630 + *num_true_changes += 1;
7632 + ce_info->num_cond_clobber_insns++;
7635 + fprintf (dump_file,
7636 + "\nReplacing INSN %d with an insn using a scratch register for later ifcvt passes...\n",
7639 + return COND_EXEC_CODE (new_pattern);
7644 + if ( inputs_set_outside_ifblock )
7646 + /* Check if the insn before the cmp is an and which used
7647 + together with the cmp can be optimized into a bld. If
7648 + so then we should try to put the insn before the and
7649 + so that we can catch the bld peephole. */
7651 + rtx insn_before_cmp_insn = prev_nonnote_insn (cmp_insn);
7652 + if (insn_before_cmp_insn
7653 + && (set = single_set (insn_before_cmp_insn))
7654 + && GET_CODE (SET_SRC (set)) == AND
7655 + && one_bit_set_operand (XEXP (SET_SRC (set), 1), SImode)
7656 + /* Also make sure that the insn does not set any
7657 + of the input operands to the insn we are pulling out. */
7658 + && !reg_mentioned_p (SET_DEST (set), SET_SRC (op)) )
7659 + cmp_insn = prev_nonnote_insn (cmp_insn);
7661 + /* We can try to put the operation outside the if-then-else
7662 + blocks and insert a move. */
7663 + if ( !insn_invalid_p (insn)
7664 + /* Do not allow conditional insns to be moved outside the
7666 + && !reg_mentioned_p (cc0_rtx, insn)
7667 + /* We cannot move memory loads outside of the if-then-else
7668 + since the memory access should not be perfomed if the
7669 + condition is not met. */
7670 + && !mem_mentioned_p (SET_SRC (op)) )
7672 + rtx scratch_reg = gen_reg_rtx (mode);
7673 + rtx op_pattern = copy_rtx (op);
7674 + rtx new_insn, seq;
7675 + rtx link, prev_link;
7676 + op = copy_rtx (op);
7677 + /* Emit the operation to a temp reg before the compare,
7678 + and emit a move inside the if-then-else, hoping that the
7679 + whole if-then-else can be converted to conditional
7681 + SET_DEST (op_pattern) = scratch_reg;
7682 + start_sequence ();
7683 + new_insn = emit_insn (op_pattern);
7684 + seq = get_insns();
7687 + /* Check again that the insn is valid. For some insns the insn might
7688 + become invalid if the destination register is changed. Ie. for mulacc
7690 + if ( insn_invalid_p (new_insn) )
7693 + emit_insn_before_setloc (seq, cmp_insn, INSN_LOCATOR (insn));
7696 + fprintf (dump_file,
7697 + "\nMoving INSN %d out of IF-block by adding INSN %d...\n",
7698 + INSN_UID (insn), INSN_UID (new_insn));
7700 + ce_info->extra_move_insns[ce_info->num_extra_move_insns] = insn;
7701 + ce_info->moved_insns[ce_info->num_extra_move_insns] = new_insn;
7702 + XEXP (op, 1) = scratch_reg;
7703 + /* Force the insn to be recognized again. */
7704 + INSN_CODE (insn) = -1;
7706 + /* Move REG_DEAD notes to the moved insn. */
7707 + prev_link = NULL_RTX;
7708 + for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
7710 + if (REG_NOTE_KIND (link) == REG_DEAD)
7712 + /* Add the REG_DEAD note to the new insn. */
7713 + rtx dead_reg = XEXP (link, 0);
7714 + REG_NOTES (new_insn) = gen_rtx_EXPR_LIST (REG_DEAD, dead_reg, REG_NOTES (new_insn));
7715 + /* Remove the REG_DEAD note from the insn we convert to a move. */
7717 + XEXP (prev_link, 1) = XEXP (link, 1);
7719 + REG_NOTES (insn) = XEXP (link, 1);
7726 + /* Add a REG_DEAD note to signal that the scratch register is dead. */
7727 + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_DEAD, scratch_reg, REG_NOTES (insn));
7729 + /* If this is the first change in this IF-block then
7730 + signal that we have made a change. */
7731 + if ( ce_info->num_cond_clobber_insns == 0
7732 + && ce_info->num_extra_move_insns == 0 )
7733 + *num_true_changes += 1;
7735 + ce_info->num_extra_move_insns++;
7740 + /* We failed to fixup the insns, so this if-then-else can not be made
7741 + conditional. Just return NULL_RTX so that the if-then-else conversion
7742 + for this if-then-else will be cancelled. */
7749 + /* Signal that we have started if conversion after reload, which means
7750 + that it should be safe to split all the predicable clobber insns which
7751 + did not become cond_exec back into a simpler form if possible. */
7752 + cfun->machine->ifcvt_after_reload = 1;
7759 +avr32_ifcvt_modify_cancel ( ce_if_block_t *ce_info, int *num_true_changes)
7763 + if ( ce_info->num_extra_move_insns > 0
7764 + && ce_info->num_cond_clobber_insns == 0)
7765 + /* Signal that we did not do any changes after all. */
7766 + *num_true_changes -= 1;
7768 + /* Remove any inserted move insns. */
7769 + for ( n = 0; n < ce_info->num_extra_move_insns; n++ )
7771 + rtx link, prev_link;
7773 + /* Remove REG_DEAD note since we are not needing the scratch register anyway. */
7774 + prev_link = NULL_RTX;
7775 + for (link = REG_NOTES (ce_info->extra_move_insns[n]); link; link = XEXP (link, 1))
7777 + if (REG_NOTE_KIND (link) == REG_DEAD)
7780 + XEXP (prev_link, 1) = XEXP (link, 1);
7782 + REG_NOTES (ce_info->extra_move_insns[n]) = XEXP (link, 1);
7790 + /* Revert all reg_notes for the moved insn. */
7791 + for (link = REG_NOTES (ce_info->moved_insns[n]); link; link = XEXP (link, 1))
7793 + REG_NOTES (ce_info->extra_move_insns[n]) = gen_rtx_EXPR_LIST (REG_NOTE_KIND (link),
7795 + REG_NOTES (ce_info->extra_move_insns[n]));
7798 + /* Remove the moved insn. */
7799 + remove_insn ( ce_info->moved_insns[n] );
7804 +/* Function returning TRUE if INSN with OPERANDS is a splittable
7805 + conditional immediate clobber insn. We assume that the insn is
7806 + already a conditional immediate clobber insns and do not check
7809 +avr32_cond_imm_clobber_splittable (rtx insn, rtx operands[])
7811 + if ( REGNO (operands[0]) == REGNO (operands[1]) )
7813 + if ( (GET_CODE (SET_SRC (XVECEXP (PATTERN (insn),0,0))) == PLUS
7814 + && !avr32_const_ok_for_constraint_p (INTVAL (operands[2]), 'I', "Is21"))
7815 + || (GET_CODE (SET_SRC (XVECEXP (PATTERN (insn),0,0))) == MINUS
7816 + && !avr32_const_ok_for_constraint_p (INTVAL (operands[2]), 'K', "Ks21")))
7819 + else if ( (logical_binary_operator (SET_SRC (XVECEXP (PATTERN (insn),0,0)), VOIDmode)
7820 + || (GET_CODE (SET_SRC (XVECEXP (PATTERN (insn),0,0))) == PLUS
7821 + && !avr32_const_ok_for_constraint_p (INTVAL (operands[2]), 'I', "Is16"))
7822 + || (GET_CODE (SET_SRC (XVECEXP (PATTERN (insn),0,0))) == MINUS
7823 + && !avr32_const_ok_for_constraint_p (INTVAL (operands[2]), 'K', "Ks16"))) )
7830 +/* Function for getting an integer value from a const_int or const_double
7831 + expression regardless of the HOST_WIDE_INT size. Each target cpu word
7832 + will be put into the val array where the LSW will be stored at the lowest
7833 + address and so forth. Assumes that const_expr is either a const_int or
7834 + const_double. Only valid for modes which have sizes that are a multiple
7838 +avr32_get_intval (enum machine_mode mode, rtx const_expr, HOST_WIDE_INT *val)
7840 + int words_in_mode = GET_MODE_SIZE (mode)/UNITS_PER_WORD;
7841 + const int words_in_const_int = HOST_BITS_PER_WIDE_INT / BITS_PER_WORD;
7843 + if ( GET_CODE(const_expr) == CONST_DOUBLE ){
7844 + HOST_WIDE_INT hi = CONST_DOUBLE_HIGH(const_expr);
7845 + HOST_WIDE_INT lo = CONST_DOUBLE_LOW(const_expr);
7846 + /* Evaluate hi and lo values of const_double. */
7847 + avr32_get_intval (mode_for_size (HOST_BITS_PER_WIDE_INT, MODE_INT, 0),
7850 + avr32_get_intval (mode_for_size (HOST_BITS_PER_WIDE_INT, MODE_INT, 0),
7852 + &val[words_in_const_int]);
7853 + } else if ( GET_CODE(const_expr) == CONST_INT ){
7854 + HOST_WIDE_INT value = INTVAL(const_expr);
7856 + for ( word = 0; (word < words_in_mode) && (word < words_in_const_int); word++ ){
7857 + /* Shift word up to the MSW and shift down again to extract the
7858 + word and sign-extend. */
7859 + int lshift = (words_in_const_int - word - 1) * BITS_PER_WORD;
7860 + int rshift = (words_in_const_int-1) * BITS_PER_WORD;
7861 + val[word] = (value << lshift) >> rshift;
7864 + for ( ; word < words_in_mode; word++ ){
7865 + /* Just put the sign bits in the remaining words. */
7866 + val[word] = value < 0 ? -1 : 0;
7873 +avr32_split_const_expr (enum machine_mode mode, enum machine_mode new_mode,
7874 + rtx expr, rtx *split_expr)
7877 + int words_in_intval = GET_MODE_SIZE (mode)/UNITS_PER_WORD;
7878 + int words_in_split_values = GET_MODE_SIZE (new_mode)/UNITS_PER_WORD;
7879 + const int words_in_const_int = HOST_BITS_PER_WIDE_INT / BITS_PER_WORD;
7880 + HOST_WIDE_INT *val = alloca (words_in_intval * UNITS_PER_WORD);
7882 + avr32_get_intval (mode, expr, val);
7884 + for ( i=0; i < (words_in_intval/words_in_split_values); i++ )
7886 + HOST_WIDE_INT value_lo = 0, value_hi = 0;
7887 + for ( word = 0; word < words_in_split_values; word++ )
7889 + if ( word >= words_in_const_int )
7890 + value_hi |= ((val[i * words_in_split_values + word] &
7891 + (((HOST_WIDE_INT)1 << BITS_PER_WORD)-1))
7892 + << (BITS_PER_WORD * (word - words_in_const_int)));
7894 + value_lo |= ((val[i * words_in_split_values + word] &
7895 + (((HOST_WIDE_INT)1 << BITS_PER_WORD)-1))
7896 + << (BITS_PER_WORD * word));
7898 + split_expr[i] = immed_double_const(value_lo, value_hi, new_mode);
7903 +/* Set up library functions to comply to AVR32 ABI */
7905 +avr32_init_libfuncs (void)
7907 + /* Convert gcc run-time function names to AVR32 ABI names */
7909 + /* Double-precision floating-point arithmetic. */
7910 + set_optab_libfunc (neg_optab, DFmode, NULL);
7912 + /* Double-precision comparisons. */
7913 + set_optab_libfunc (eq_optab, DFmode, "__avr32_f64_cmp_eq");
7914 + set_optab_libfunc (ne_optab, DFmode, NULL);
7915 + set_optab_libfunc (lt_optab, DFmode, "__avr32_f64_cmp_lt");
7916 + set_optab_libfunc (le_optab, DFmode, NULL);
7917 + set_optab_libfunc (ge_optab, DFmode, "__avr32_f64_cmp_ge");
7918 + set_optab_libfunc (gt_optab, DFmode, NULL);
7920 + /* Single-precision floating-point arithmetic. */
7921 + set_optab_libfunc (smul_optab, SFmode, "__avr32_f32_mul");
7922 + set_optab_libfunc (neg_optab, SFmode, NULL);
7924 + /* Single-precision comparisons. */
7925 + set_optab_libfunc (eq_optab, SFmode, "__avr32_f32_cmp_eq");
7926 + set_optab_libfunc (ne_optab, SFmode, NULL);
7927 + set_optab_libfunc (lt_optab, SFmode, "__avr32_f32_cmp_lt");
7928 + set_optab_libfunc (le_optab, SFmode, NULL);
7929 + set_optab_libfunc (ge_optab, SFmode, "__avr32_f32_cmp_ge");
7930 + set_optab_libfunc (gt_optab, SFmode, NULL);
7932 + /* Floating-point to integer conversions. */
7933 + set_conv_libfunc (sfix_optab, SImode, DFmode, "__avr32_f64_to_s32");
7934 + set_conv_libfunc (ufix_optab, SImode, DFmode, "__avr32_f64_to_u32");
7935 + set_conv_libfunc (sfix_optab, DImode, DFmode, "__avr32_f64_to_s64");
7936 + set_conv_libfunc (ufix_optab, DImode, DFmode, "__avr32_f64_to_u64");
7937 + set_conv_libfunc (sfix_optab, SImode, SFmode, "__avr32_f32_to_s32");
7938 + set_conv_libfunc (ufix_optab, SImode, SFmode, "__avr32_f32_to_u32");
7939 + set_conv_libfunc (sfix_optab, DImode, SFmode, "__avr32_f32_to_s64");
7940 + set_conv_libfunc (ufix_optab, DImode, SFmode, "__avr32_f32_to_u64");
7942 + /* Conversions between floating types. */
7943 + set_conv_libfunc (trunc_optab, SFmode, DFmode, "__avr32_f64_to_f32");
7944 + set_conv_libfunc (sext_optab, DFmode, SFmode, "__avr32_f32_to_f64");
7946 + /* Integer to floating-point conversions. Table 8. */
7947 + set_conv_libfunc (sfloat_optab, DFmode, SImode, "__avr32_s32_to_f64");
7948 + set_conv_libfunc (sfloat_optab, DFmode, DImode, "__avr32_s64_to_f64");
7949 + set_conv_libfunc (sfloat_optab, SFmode, SImode, "__avr32_s32_to_f32");
7950 + set_conv_libfunc (sfloat_optab, SFmode, DImode, "__avr32_s64_to_f32");
7951 + set_conv_libfunc (ufloat_optab, DFmode, SImode, "__avr32_u32_to_f64");
7952 + set_conv_libfunc (ufloat_optab, SFmode, SImode, "__avr32_u32_to_f32");
7953 + /* TODO: Add these to gcc library functions */
7954 + //set_conv_libfunc (ufloat_optab, DFmode, DImode, NULL);
7955 + //set_conv_libfunc (ufloat_optab, SFmode, DImode, NULL);
7957 + /* Long long. Table 9. */
7958 + set_optab_libfunc (smul_optab, DImode, "__avr32_mul64");
7959 + set_optab_libfunc (sdiv_optab, DImode, "__avr32_sdiv64");
7960 + set_optab_libfunc (udiv_optab, DImode, "__avr32_udiv64");
7961 + set_optab_libfunc (smod_optab, DImode, "__avr32_smod64");
7962 + set_optab_libfunc (umod_optab, DImode, "__avr32_umod64");
7963 + set_optab_libfunc (ashl_optab, DImode, "__avr32_lsl64");
7964 + set_optab_libfunc (lshr_optab, DImode, "__avr32_lsr64");
7965 + set_optab_libfunc (ashr_optab, DImode, "__avr32_asr64");
7967 + /* Floating point library functions which have fast versions. */
7968 + if ( TARGET_FAST_FLOAT )
7970 + set_optab_libfunc (sdiv_optab, DFmode, "__avr32_f64_div_fast");
7971 + set_optab_libfunc (smul_optab, DFmode, "__avr32_f64_mul_fast");
7972 + set_optab_libfunc (add_optab, DFmode, "__avr32_f64_add_fast");
7973 + set_optab_libfunc (sub_optab, DFmode, "__avr32_f64_sub_fast");
7974 + set_optab_libfunc (add_optab, SFmode, "__avr32_f32_add_fast");
7975 + set_optab_libfunc (sub_optab, SFmode, "__avr32_f32_sub_fast");
7976 + set_optab_libfunc (sdiv_optab, SFmode, "__avr32_f32_div_fast");
7980 + set_optab_libfunc (sdiv_optab, DFmode, "__avr32_f64_div");
7981 + set_optab_libfunc (smul_optab, DFmode, "__avr32_f64_mul");
7982 + set_optab_libfunc (add_optab, DFmode, "__avr32_f64_add");
7983 + set_optab_libfunc (sub_optab, DFmode, "__avr32_f64_sub");
7984 + set_optab_libfunc (add_optab, SFmode, "__avr32_f32_add");
7985 + set_optab_libfunc (sub_optab, SFmode, "__avr32_f32_sub");
7986 + set_optab_libfunc (sdiv_optab, SFmode, "__avr32_f32_div");
7991 +/* Record a flashvault declaration. */
7993 +flashvault_decl_list_add (unsigned int vector_num, const char *name)
7995 + struct flashvault_decl_list *p;
7997 + p = (struct flashvault_decl_list *)
7998 + xmalloc (sizeof (struct flashvault_decl_list));
7999 + p->next = flashvault_decl_list_head;
8001 + p->vector_num = vector_num;
8002 + flashvault_decl_list_head = p;
8007 +avr32_file_end (void)
8009 + struct flashvault_decl_list *p;
8010 + unsigned int num_entries = 0;
8012 + /* Check if a list of flashvault declarations exists. */
8013 + if (flashvault_decl_list_head != NULL)
8015 + /* Calculate the number of entries in the table. */
8016 + for (p = flashvault_decl_list_head; p != NULL; p = p->next)
8021 + /* Generate the beginning of the flashvault data table. */
8022 + fputs ("\t.global __fv_table\n"
8025 + "\t.set .LFVTABLE, . + 0\n"
8026 + "\t.type __fv_table, @object\n", asm_out_file);
8027 + /* Each table entry is 8 bytes. */
8028 + fprintf (asm_out_file, "\t.size __fv_table, %u\n", (num_entries * 8));
8030 + fputs("__fv_table:\n", asm_out_file);
8032 + for (p = flashvault_decl_list_head; p != NULL; p = p->next)
8034 + /* Output table entry. */
8035 + fprintf (asm_out_file,
8037 + "\t.int %u\n", p->vector_num);
8038 + fprintf (asm_out_file,
8040 + "\t.int %s\n", p->name);
8045 +++ b/gcc/config/avr32/avr32-elf.h
8048 + Elf specific definitions.
8049 + Copyright 2003,2004,2005,2006,2007,2008,2009 Atmel Corporation.
8051 + This file is part of GCC.
8053 + This program is free software; you can redistribute it and/or modify
8054 + it under the terms of the GNU General Public License as published by
8055 + the Free Software Foundation; either version 2 of the License, or
8056 + (at your option) any later version.
8058 + This program is distributed in the hope that it will be useful,
8059 + but WITHOUT ANY WARRANTY; without even the implied warranty of
8060 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8061 + GNU General Public License for more details.
8063 + You should have received a copy of the GNU General Public License
8064 + along with this program; if not, write to the Free Software
8065 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
8068 +/*****************************************************************************
8069 + * Controlling the Compiler Driver, 'gcc'
8070 + *****************************************************************************/
8072 +/* Run-time Target Specification. */
8073 +#undef TARGET_VERSION
8074 +#define TARGET_VERSION fputs (" (AVR32 GNU with ELF)", stderr);
8077 +Another C string constant used much like LINK_SPEC. The
8078 +difference between the two is that STARTFILE_SPEC is used at
8079 +the very beginning of the command given to the linker.
8081 +If this macro is not defined, a default is provided that loads the
8082 +standard C startup file from the usual place. See gcc.c.
8085 +#undef STARTFILE_SPEC
8086 +#define STARTFILE_SPEC "crt0%O%s crti%O%s crtbegin%O%s"
8088 +#undef STARTFILE_SPEC
8089 +#define STARTFILE_SPEC "%{mflashvault: crtfv.o%s} %{!mflashvault: crt0.o%s} \
8090 + crti.o%s crtbegin.o%s"
8093 +#define LINK_SPEC "%{muse-oscall:--defsym __do_not_use_oscall_coproc__=0} %{mrelax|O*:%{mno-relax|O0|O1: ;:--relax}} %{mpart=uc3a3revd:-mavr32elf_uc3a3256s;:%{mpart=*:-mavr32elf_%*}} %{mcpu=*:-mavr32elf_%*}"
8097 +Another C string constant used much like LINK_SPEC. The
8098 +difference between the two is that ENDFILE_SPEC is used at
8099 +the very end of the command given to the linker.
8101 +Do not define this macro if it does not need to do anything.
8103 +#undef ENDFILE_SPEC
8104 +#define ENDFILE_SPEC "crtend%O%s crtn%O%s"
8107 +/* Target CPU builtins. */
8108 +#define TARGET_CPU_CPP_BUILTINS() \
8111 + builtin_define ("__avr32__"); \
8112 + builtin_define ("__AVR32__"); \
8113 + builtin_define ("__AVR32_ELF__"); \
8114 + builtin_define (avr32_part->macro); \
8115 + builtin_define (avr32_arch->macro); \
8116 + if (avr32_arch->uarch_type == UARCH_TYPE_AVR32A) \
8117 + builtin_define ("__AVR32_AVR32A__"); \
8119 + builtin_define ("__AVR32_AVR32B__"); \
8120 + if (TARGET_UNALIGNED_WORD) \
8121 + builtin_define ("__AVR32_HAS_UNALIGNED_WORD__"); \
8122 + if (TARGET_SIMD) \
8123 + builtin_define ("__AVR32_HAS_SIMD__"); \
8125 + builtin_define ("__AVR32_HAS_DSP__"); \
8127 + builtin_define ("__AVR32_HAS_RMW__"); \
8128 + if (TARGET_BRANCH_PRED) \
8129 + builtin_define ("__AVR32_HAS_BRANCH_PRED__"); \
8130 + if (TARGET_FAST_FLOAT) \
8131 + builtin_define ("__AVR32_FAST_FLOAT__"); \
8132 + if (TARGET_FLASHVAULT) \
8133 + builtin_define ("__AVR32_FLASHVAULT__"); \
8134 + if (TARGET_NO_MUL_INSNS) \
8135 + builtin_define ("__AVR32_NO_MUL__"); \
8139 +++ b/gcc/config/avr32/avr32.h
8142 + Definitions of target machine for AVR32.
8143 + Copyright 2003,2004,2005,2006,2007,2008,2009,2010 Atmel Corporation.
8145 + This file is part of GCC.
8147 + This program is free software; you can redistribute it and/or modify
8148 + it under the terms of the GNU General Public License as published by
8149 + the Free Software Foundation; either version 2 of the License, or
8150 + (at your option) any later version.
8152 + This program is distributed in the hope that it will be useful,
8153 + but WITHOUT ANY WARRANTY; without even the implied warranty of
8154 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8155 + GNU General Public License for more details.
8157 + You should have received a copy of the GNU General Public License
8158 + along with this program; if not, write to the Free Software
8159 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
8161 +#ifndef GCC_AVR32_H
8162 +#define GCC_AVR32_H
8165 +#ifndef OBJECT_FORMAT_ELF
8166 +#error avr32.h included before elfos.h
8169 +#ifndef LOCAL_LABEL_PREFIX
8170 +#define LOCAL_LABEL_PREFIX "."
8173 +#ifndef SUBTARGET_CPP_SPEC
8174 +#define SUBTARGET_CPP_SPEC "-D__ELF__"
8178 +extern struct rtx_def *avr32_compare_op0;
8179 +extern struct rtx_def *avr32_compare_op1;
8182 +extern struct rtx_def *avr32_acc_cache;
8184 +/* cache instruction op5 codes */
8185 +#define AVR32_CACHE_INVALIDATE_ICACHE 1
8188 +These bits describe the different types of function supported by the AVR32
8189 +backend. They are exclusive, e.g. a function cannot be both a normal function
8190 +and an interworked function. Knowing the type of a function is important for
8191 +determining its prologue and epilogue sequences. Note value 7 is currently
8192 +unassigned. Also note that the interrupt function types all have bit 2 set,
8193 +so that they can be tested for easily. Note that 0 is deliberately chosen for
8194 +AVR32_FT_UNKNOWN so that when the machine_function structure is initialized
8195 +(to zero) func_type will default to unknown. This will force the first use of
8196 +avr32_current_func_type to call avr32_compute_func_type.
8198 +#define AVR32_FT_UNKNOWN 0 /* Type has not yet been determined. */
8199 +#define AVR32_FT_NORMAL 1 /* Normal function. */
8200 +#define AVR32_FT_ACALL 2 /* An acall function. */
8201 +#define AVR32_FT_EXCEPTION_HANDLER 3 /* A C++ exception handler. */
8202 +#define AVR32_FT_ISR_FULL 4 /* A fully shadowed interrupt mode. */
8203 +#define AVR32_FT_ISR_HALF 5 /* A half shadowed interrupt mode. */
8204 +#define AVR32_FT_ISR_NONE 6 /* No shadow registers. */
8206 +#define AVR32_FT_TYPE_MASK ((1 << 3) - 1)
8208 +/* In addition functions can have several type modifiers, outlined by these bit masks: */
8209 +#define AVR32_FT_INTERRUPT (1 << 2) /* Note overlap with FT_ISR and above. */
8210 +#define AVR32_FT_NAKED (1 << 3) /* No prologue or epilogue. */
8211 +#define AVR32_FT_VOLATILE (1 << 4) /* Does not return. */
8212 +#define AVR32_FT_NESTED (1 << 5) /* Embedded inside another func. */
8213 +#define AVR32_FT_FLASHVAULT (1 << 6) /* Flashvault function call. */
8214 +#define AVR32_FT_FLASHVAULT_IMPL (1 << 7) /* Function definition in FlashVault. */
8217 +/* Some macros to test these flags. */
8218 +#define AVR32_FUNC_TYPE(t) (t & AVR32_FT_TYPE_MASK)
8219 +#define IS_INTERRUPT(t) (t & AVR32_FT_INTERRUPT)
8220 +#define IS_NAKED(t) (t & AVR32_FT_NAKED)
8221 +#define IS_VOLATILE(t) (t & AVR32_FT_VOLATILE)
8222 +#define IS_NESTED(t) (t & AVR32_FT_NESTED)
8223 +#define IS_FLASHVAULT(t) (t & AVR32_FT_FLASHVAULT)
8224 +#define IS_FLASHVAULT_IMPL(t) (t & AVR32_FT_FLASHVAULT_IMPL)
8226 +#define SYMBOL_FLAG_RMW_ADDR_SHIFT SYMBOL_FLAG_MACH_DEP_SHIFT
8227 +#define SYMBOL_REF_RMW_ADDR(RTX) \
8228 + ((SYMBOL_REF_FLAGS (RTX) & (1 << SYMBOL_FLAG_RMW_ADDR_SHIFT)) != 0)
8231 +typedef struct minipool_labels
8232 +GTY ((chain_next ("%h.next"), chain_prev ("%h.prev")))
8235 + struct minipool_labels *prev;
8236 + struct minipool_labels *next;
8239 +/* A C structure for machine-specific, per-function data.
8240 + This is added to the cfun structure. */
8242 +typedef struct machine_function
8245 + /* Records the type of the current function. */
8246 + unsigned long func_type;
8247 + /* List of minipool labels, use for checking if code label is valid in a
8248 + memory expression */
8249 + minipool_labels *minipool_label_head;
8250 + minipool_labels *minipool_label_tail;
8251 + int ifcvt_after_reload;
8252 +} machine_function;
8254 +/* Initialize data used by insn expanders. This is called from insn_emit,
8255 + once for every function before code is generated. */
8256 +#define INIT_EXPANDERS avr32_init_expanders ()
8258 +/******************************************************************************
8260 + *****************************************************************************/
8263 +#define ASM_SPEC "%{fpic:--pic} %{mrelax|O*:%{mno-relax|O0|O1: ;:--linkrelax}} %{march=ucr2nomul:-march=ucr2;:%{march=*:-march=%*}} %{mpart=uc3a3revd:-mpart=uc3a3256s;:%{mpart=*:-mpart=%*}}"
8266 +#ifndef MULTILIB_DEFAULTS
8267 +#define MULTILIB_DEFAULTS { "march=ap", "" }
8270 +/******************************************************************************
8271 + * Run-time Target Specification
8272 + *****************************************************************************/
8273 +#ifndef TARGET_VERSION
8274 +#define TARGET_VERSION fprintf(stderr, " (AVR32, GNU assembler syntax)");
8278 +/* Part types. Keep this in sync with the order of avr32_part_types in avr32.c*/
8281 + PART_TYPE_AVR32_NONE,
8282 + PART_TYPE_AVR32_AP7000,
8283 + PART_TYPE_AVR32_AP7001,
8284 + PART_TYPE_AVR32_AP7002,
8285 + PART_TYPE_AVR32_AP7200,
8286 + PART_TYPE_AVR32_UC3A0128,
8287 + PART_TYPE_AVR32_UC3A0256,
8288 + PART_TYPE_AVR32_UC3A0512,
8289 + PART_TYPE_AVR32_UC3A0512ES,
8290 + PART_TYPE_AVR32_UC3A1128,
8291 + PART_TYPE_AVR32_UC3A1256,
8292 + PART_TYPE_AVR32_UC3A1512,
8293 + PART_TYPE_AVR32_UC3A1512ES,
8294 + PART_TYPE_AVR32_UC3A3REVD,
8295 + PART_TYPE_AVR32_UC3A364,
8296 + PART_TYPE_AVR32_UC3A364S,
8297 + PART_TYPE_AVR32_UC3A3128,
8298 + PART_TYPE_AVR32_UC3A3128S,
8299 + PART_TYPE_AVR32_UC3A3256,
8300 + PART_TYPE_AVR32_UC3A3256S,
8301 + PART_TYPE_AVR32_UC3B064,
8302 + PART_TYPE_AVR32_UC3B0128,
8303 + PART_TYPE_AVR32_UC3B0256,
8304 + PART_TYPE_AVR32_UC3B0256ES,
8305 + PART_TYPE_AVR32_UC3B0512,
8306 + PART_TYPE_AVR32_UC3B0512REVC,
8307 + PART_TYPE_AVR32_UC3B164,
8308 + PART_TYPE_AVR32_UC3B1128,
8309 + PART_TYPE_AVR32_UC3B1256,
8310 + PART_TYPE_AVR32_UC3B1256ES,
8311 + PART_TYPE_AVR32_UC3B1512,
8312 + PART_TYPE_AVR32_UC3B1512REVC,
8313 + PART_TYPE_AVR32_UC3C0512CREVC,
8314 + PART_TYPE_AVR32_UC3C1512CREVC,
8315 + PART_TYPE_AVR32_UC3C2512CREVC,
8316 + PART_TYPE_AVR32_UC3L0256,
8317 + PART_TYPE_AVR32_UC3L0128,
8318 + PART_TYPE_AVR32_UC3L064,
8319 + PART_TYPE_AVR32_UC3L032,
8320 + PART_TYPE_AVR32_UC3L016,
8321 + PART_TYPE_AVR32_UC3C064C,
8322 + PART_TYPE_AVR32_UC3C0128C,
8323 + PART_TYPE_AVR32_UC3C0256C,
8324 + PART_TYPE_AVR32_UC3C0512C,
8325 + PART_TYPE_AVR32_UC3C164C,
8326 + PART_TYPE_AVR32_UC3C1128C,
8327 + PART_TYPE_AVR32_UC3C1256C,
8328 + PART_TYPE_AVR32_UC3C1512C,
8329 + PART_TYPE_AVR32_UC3C264C,
8330 + PART_TYPE_AVR32_UC3C2128C,
8331 + PART_TYPE_AVR32_UC3C2256C,
8332 + PART_TYPE_AVR32_UC3C2512C,
8333 + PART_TYPE_AVR32_MXT768E
8336 +/* Microarchitectures. */
8337 +enum microarchitecture_type
8339 + UARCH_TYPE_AVR32A,
8340 + UARCH_TYPE_AVR32B,
8344 +/* Architectures types which specifies the pipeline.
8345 + Keep this in sync with avr32_arch_types in avr32.c
8346 + and the pipeline attribute in avr32.md */
8347 +enum architecture_type
8349 + ARCH_TYPE_AVR32_AP,
8350 + ARCH_TYPE_AVR32_UCR1,
8351 + ARCH_TYPE_AVR32_UCR2,
8352 + ARCH_TYPE_AVR32_UCR2NOMUL,
8353 + ARCH_TYPE_AVR32_UCR3,
8354 + ARCH_TYPE_AVR32_UCR3FP,
8355 + ARCH_TYPE_AVR32_NONE
8358 +/* Flag specifying if the cpu has support for DSP instructions.*/
8359 +#define FLAG_AVR32_HAS_DSP (1 << 0)
8360 +/* Flag specifying if the cpu has support for Read-Modify-Write
8362 +#define FLAG_AVR32_HAS_RMW (1 << 1)
8363 +/* Flag specifying if the cpu has support for SIMD instructions. */
8364 +#define FLAG_AVR32_HAS_SIMD (1 << 2)
8365 +/* Flag specifying if the cpu has support for unaligned memory word access. */
8366 +#define FLAG_AVR32_HAS_UNALIGNED_WORD (1 << 3)
8367 +/* Flag specifying if the cpu has support for branch prediction. */
8368 +#define FLAG_AVR32_HAS_BRANCH_PRED (1 << 4)
8369 +/* Flag specifying if the cpu has support for a return stack. */
8370 +#define FLAG_AVR32_HAS_RETURN_STACK (1 << 5)
8371 +/* Flag specifying if the cpu has caches. */
8372 +#define FLAG_AVR32_HAS_CACHES (1 << 6)
8373 +/* Flag specifying if the cpu has support for v2 insns. */
8374 +#define FLAG_AVR32_HAS_V2_INSNS (1 << 7)
8375 +/* Flag specifying that the cpu has buggy mul insns. */
8376 +#define FLAG_AVR32_HAS_NO_MUL_INSNS (1 << 8)
8377 +/* Flag specifying that the device has FPU instructions according
8378 + to AVR32002 specifications*/
8379 +#define FLAG_AVR32_HAS_FPU (1 << 9)
8381 +/* Structure for holding information about different avr32 CPUs/parts */
8384 + const char *const name;
8385 + enum part_type part_type;
8386 + enum architecture_type arch_type;
8387 + /* Must lie outside user's namespace. NULL == no macro. */
8388 + const char *const macro;
8391 +/* Structure for holding information about different avr32 pipeline
8395 + const char *const name;
8396 + enum architecture_type arch_type;
8397 + enum microarchitecture_type uarch_type;
8398 + const unsigned long feature_flags;
8399 + /* Must lie outside user's namespace. NULL == no macro. */
8400 + const char *const macro;
8403 +extern const struct part_type_s *avr32_part;
8404 +extern const struct arch_type_s *avr32_arch;
8406 +#define TARGET_SIMD (avr32_arch->feature_flags & FLAG_AVR32_HAS_SIMD)
8407 +#define TARGET_DSP (avr32_arch->feature_flags & FLAG_AVR32_HAS_DSP)
8408 +#define TARGET_RMW (avr32_arch->feature_flags & FLAG_AVR32_HAS_RMW)
8409 +#define TARGET_UNALIGNED_WORD (avr32_arch->feature_flags & FLAG_AVR32_HAS_UNALIGNED_WORD)
8410 +#define TARGET_BRANCH_PRED (avr32_arch->feature_flags & FLAG_AVR32_HAS_BRANCH_PRED)
8411 +#define TARGET_RETURN_STACK (avr32_arch->feature_flags & FLAG_AVR32_HAS_RETURN_STACK)
8412 +#define TARGET_V2_INSNS (avr32_arch->feature_flags & FLAG_AVR32_HAS_V2_INSNS)
8413 +#define TARGET_CACHES (avr32_arch->feature_flags & FLAG_AVR32_HAS_CACHES)
8414 +#define TARGET_NO_MUL_INSNS (avr32_arch->feature_flags & FLAG_AVR32_HAS_NO_MUL_INSNS)
8415 +#define TARGET_ARCH_AP (avr32_arch->arch_type == ARCH_TYPE_AVR32_AP)
8416 +#define TARGET_ARCH_UCR1 (avr32_arch->arch_type == ARCH_TYPE_AVR32_UCR1)
8417 +#define TARGET_ARCH_UCR2 (avr32_arch->arch_type == ARCH_TYPE_AVR32_UCR2)
8418 +#define TARGET_ARCH_UC (TARGET_ARCH_UCR1 || TARGET_ARCH_UCR2)
8419 +#define TARGET_UARCH_AVR32A (avr32_arch->uarch_type == UARCH_TYPE_AVR32A)
8420 +#define TARGET_UARCH_AVR32B (avr32_arch->uarch_type == UARCH_TYPE_AVR32B)
8421 +#define TARGET_ARCH_FPU (avr32_arch->feature_flags & FLAG_AVR32_HAS_FPU)
8423 +#define CAN_DEBUG_WITHOUT_FP
8428 +/******************************************************************************
8430 + *****************************************************************************/
8433 +Define this macro to have the value 1 if the most significant bit in a
8434 +byte has the lowest number; otherwise define it to have the value zero.
8435 +This means that bit-field instructions count from the most significant
8436 +bit. If the machine has no bit-field instructions, then this must still
8437 +be defined, but it doesn't matter which value it is defined to. This
8438 +macro need not be a constant.
8440 +This macro does not affect the way structure fields are packed into
8441 +bytes or words; that is controlled by BYTES_BIG_ENDIAN.
8443 +#define BITS_BIG_ENDIAN 0
8446 +Define this macro to have the value 1 if the most significant byte in a
8447 +word has the lowest number. This macro need not be a constant.
8450 + Data is stored in an big-endian way.
8452 +#define BYTES_BIG_ENDIAN 1
8455 +Define this macro to have the value 1 if, in a multiword object, the
8456 +most significant word has the lowest number. This applies to both
8457 +memory locations and registers; GCC fundamentally assumes that the
8458 +order of words in memory is the same as the order in registers. This
8459 +macro need not be a constant.
8462 + Data is stored in an bin-endian way.
8464 +#define WORDS_BIG_ENDIAN 1
8467 +Define this macro if WORDS_BIG_ENDIAN is not constant. This must be a
8468 +constant value with the same meaning as WORDS_BIG_ENDIAN, which will be
8469 +used only when compiling libgcc2.c. Typically the value will be set
8470 +based on preprocessor defines.
8472 +#define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
8475 +Define this macro to have the value 1 if DFmode, XFmode or
8476 +TFmode floating point numbers are stored in memory with the word
8477 +containing the sign bit at the lowest address; otherwise define it to
8478 +have the value 0. This macro need not be a constant.
8480 +You need not define this macro if the ordering is the same as for
8481 +multi-word integers.
8483 +/* #define FLOAT_WORDS_BIG_ENDIAN 1 */
8486 +Define this macro to be the number of bits in an addressable storage
8487 +unit (byte); normally 8.
8489 +#define BITS_PER_UNIT 8
8492 +Number of bits in a word; normally 32.
8494 +#define BITS_PER_WORD 32
8497 +Maximum number of bits in a word. If this is undefined, the default is
8498 +BITS_PER_WORD. Otherwise, it is the constant value that is the
8499 +largest value that BITS_PER_WORD can have at run-time.
8501 +/* MAX_BITS_PER_WORD not defined*/
8504 +Number of storage units in a word; normally 4.
8506 +#define UNITS_PER_WORD 4
8509 +Minimum number of units in a word. If this is undefined, the default is
8510 +UNITS_PER_WORD. Otherwise, it is the constant value that is the
8511 +smallest value that UNITS_PER_WORD can have at run-time.
8513 +/* MIN_UNITS_PER_WORD not defined */
8516 +Width of a pointer, in bits. You must specify a value no wider than the
8517 +width of Pmode. If it is not equal to the width of Pmode,
8518 +you must define POINTERS_EXTEND_UNSIGNED.
8520 +#define POINTER_SIZE 32
8523 +A C expression whose value is greater than zero if pointers that need to be
8524 +extended from being POINTER_SIZE bits wide to Pmode are to
8525 +be zero-extended and zero if they are to be sign-extended. If the value
8526 +is less then zero then there must be an "ptr_extend" instruction that
8527 +extends a pointer from POINTER_SIZE to Pmode.
8529 +You need not define this macro if the POINTER_SIZE is equal
8530 +to the width of Pmode.
8532 +/* #define POINTERS_EXTEND_UNSIGNED */
8535 +A Macro to update M and UNSIGNEDP when an object whose type
8536 +is TYPE and which has the specified mode and signedness is to be
8537 +stored in a register. This macro is only called when TYPE is a
8540 +On most RISC machines, which only have operations that operate on a full
8541 +register, define this macro to set M to word_mode if
8542 +M is an integer mode narrower than BITS_PER_WORD. In most
8543 +cases, only integer modes should be widened because wider-precision
8544 +floating-point operations are usually more expensive than their narrower
8547 +For most machines, the macro definition does not change UNSIGNEDP.
8548 +However, some machines, have instructions that preferentially handle
8549 +either signed or unsigned quantities of certain modes. For example, on
8550 +the DEC Alpha, 32-bit loads from memory and 32-bit add instructions
8551 +sign-extend the result to 64 bits. On such machines, set
8552 +UNSIGNEDP according to which kind of extension is more efficient.
8554 +Do not define this macro if it would never modify M.
8556 +#define PROMOTE_MODE(M, UNSIGNEDP, TYPE) \
8558 + if (!AGGREGATE_TYPE_P (TYPE) \
8559 + && GET_MODE_CLASS (mode) == MODE_INT \
8560 + && GET_MODE_SIZE (mode) < 4) \
8562 + if (M == QImode) \
8563 + (UNSIGNEDP) = 1; \
8564 + else if (M == HImode) \
8565 + (UNSIGNEDP) = 0; \
8570 +#define PROMOTE_FUNCTION_MODE(M, UNSIGNEDP, TYPE) \
8571 + PROMOTE_MODE(M, UNSIGNEDP, TYPE)
8573 +/* Define if operations between registers always perform the operation
8574 + on the full register even if a narrower mode is specified. */
8575 +#define WORD_REGISTER_OPERATIONS
8577 +/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
8578 + will either zero-extend or sign-extend. The value of this macro should
8579 + be the code that says which one of the two operations is implicitly
8580 + done, UNKNOWN if not known. */
8581 +#define LOAD_EXTEND_OP(MODE) \
8582 + (((MODE) == QImode) ? ZERO_EXTEND \
8583 + : ((MODE) == HImode) ? SIGN_EXTEND : UNKNOWN)
8587 +Normal alignment required for function parameters on the stack, in
8588 +bits. All stack parameters receive at least this much alignment
8589 +regardless of data type. On most machines, this is the same as the
8590 +size of an integer.
8592 +#define PARM_BOUNDARY 32
8595 +Define this macro to the minimum alignment enforced by hardware for the
8596 +stack pointer on this machine. The definition is a C expression for the
8597 +desired alignment (measured in bits). This value is used as a default
8598 +if PREFERRED_STACK_BOUNDARY is not defined. On most machines,
8599 +this should be the same as PARM_BOUNDARY.
8601 +#define STACK_BOUNDARY 32
8604 +Define this macro if you wish to preserve a certain alignment for the
8605 +stack pointer, greater than what the hardware enforces. The definition
8606 +is a C expression for the desired alignment (measured in bits). This
8607 +macro must evaluate to a value equal to or larger than
8610 +#define PREFERRED_STACK_BOUNDARY (TARGET_FORCE_DOUBLE_ALIGN ? 64 : 32 )
8613 +Alignment required for a function entry point, in bits.
8615 +#define FUNCTION_BOUNDARY 16
8618 +Biggest alignment that any data type can require on this machine, in bits.
8620 +#define BIGGEST_ALIGNMENT (TARGET_FORCE_DOUBLE_ALIGN ? 64 : 32 )
8623 +If defined, the smallest alignment, in bits, that can be given to an
8624 +object that can be referenced in one operation, without disturbing any
8625 +nearby object. Normally, this is BITS_PER_UNIT, but may be larger
8626 +on machines that don't have byte or half-word store operations.
8628 +#define MINIMUM_ATOMIC_ALIGNMENT BITS_PER_UNIT
8632 +An integer expression for the size in bits of the largest integer machine mode that
8633 +should actually be used. All integer machine modes of this size or smaller can be
8634 +used for structures and unions with the appropriate sizes. If this macro is undefined,
8635 +GET_MODE_BITSIZE (DImode) is assumed.*/
8636 +#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (DImode)
8640 +If defined, a C expression to compute the alignment given to a constant
8641 +that is being placed in memory. CONSTANT is the constant and
8642 +BASIC_ALIGN is the alignment that the object would ordinarily
8643 +have. The value of this macro is used instead of that alignment to
8646 +If this macro is not defined, then BASIC_ALIGN is used.
8648 +The typical use of this macro is to increase alignment for string
8649 +constants to be word aligned so that strcpy calls that copy
8650 +constants can be done inline.
8652 +#define CONSTANT_ALIGNMENT(CONSTANT, BASIC_ALIGN) \
8653 + ((TREE_CODE(CONSTANT) == STRING_CST) ? BITS_PER_WORD : BASIC_ALIGN)
8655 +/* Try to align string to a word. */
8656 +#define DATA_ALIGNMENT(TYPE, ALIGN) \
8657 + ({(TREE_CODE (TYPE) == ARRAY_TYPE \
8658 + && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
8659 + && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN));})
8661 +/* Try to align local store strings to a word. */
8662 +#define LOCAL_ALIGNMENT(TYPE, ALIGN) \
8663 + ({(TREE_CODE (TYPE) == ARRAY_TYPE \
8664 + && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
8665 + && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN));})
8668 +Define this macro to be the value 1 if instructions will fail to work
8669 +if given data not on the nominal alignment. If instructions will merely
8670 +go slower in that case, define this macro as 0.
8672 +#define STRICT_ALIGNMENT 1
8675 +Define this if you wish to imitate the way many other C compilers handle
8676 +alignment of bit-fields and the structures that contain them.
8678 +The behavior is that the type written for a bit-field (int,
8679 +short, or other integer type) imposes an alignment for the
8680 +entire structure, as if the structure really did contain an ordinary
8681 +field of that type. In addition, the bit-field is placed within the
8682 +structure so that it would fit within such a field, not crossing a
8685 +Thus, on most machines, a bit-field whose type is written as int
8686 +would not cross a four-byte boundary, and would force four-byte
8687 +alignment for the whole structure. (The alignment used may not be four
8688 +bytes; it is controlled by the other alignment parameters.)
8690 +If the macro is defined, its definition should be a C expression;
8691 +a nonzero value for the expression enables this behavior.
8693 +Note that if this macro is not defined, or its value is zero, some
8694 +bit-fields may cross more than one alignment boundary. The compiler can
8695 +support such references if there are insv, extv, and
8696 +extzv insns that can directly reference memory.
8698 +The other known way of making bit-fields work is to define
8699 +STRUCTURE_SIZE_BOUNDARY as large as BIGGEST_ALIGNMENT.
8700 +Then every structure can be accessed with fullwords.
8702 +Unless the machine has bit-field instructions or you define
8703 +STRUCTURE_SIZE_BOUNDARY that way, you must define
8704 +PCC_BITFIELD_TYPE_MATTERS to have a nonzero value.
8706 +If your aim is to make GCC use the same conventions for laying out
8707 +bit-fields as are used by another compiler, here is how to investigate
8708 +what the other compiler does. Compile and run this program:
8726 + printf ("Size of foo1 is %d\n",
8727 + sizeof (struct foo1));
8728 + printf ("Size of foo2 is %d\n",
8729 + sizeof (struct foo2));
8733 +If this prints 2 and 5, then the compiler's behavior is what you would
8734 +get from PCC_BITFIELD_TYPE_MATTERS.
8736 +#define PCC_BITFIELD_TYPE_MATTERS 1
8739 +/******************************************************************************
8740 + * Layout of Source Language Data Types
8741 + *****************************************************************************/
8744 +A C expression for the size in bits of the type int on the
8745 +target machine. If you don't define this, the default is one word.
8747 +#define INT_TYPE_SIZE 32
8750 +A C expression for the size in bits of the type short on the
8751 +target machine. If you don't define this, the default is half a word. (If
8752 +this would be less than one storage unit, it is rounded up to one unit.)
8754 +#define SHORT_TYPE_SIZE 16
8757 +A C expression for the size in bits of the type long on the
8758 +target machine. If you don't define this, the default is one word.
8760 +#define LONG_TYPE_SIZE 32
8764 +A C expression for the size in bits of the type long long on the
8765 +target machine. If you don't define this, the default is two
8766 +words. If you want to support GNU Ada on your machine, the value of this
8767 +macro must be at least 64.
8769 +#define LONG_LONG_TYPE_SIZE 64
8772 +A C expression for the size in bits of the type char on the
8773 +target machine. If you don't define this, the default is
8776 +#define CHAR_TYPE_SIZE 8
8780 +A C expression for the size in bits of the C++ type bool and
8781 +C99 type _Bool on the target machine. If you don't define
8782 +this, and you probably shouldn't, the default is CHAR_TYPE_SIZE.
8784 +#define BOOL_TYPE_SIZE 8
8788 +An expression whose value is 1 or 0, according to whether the type
8789 +char should be signed or unsigned by default. The user can
8790 +always override this default with the options -fsigned-char
8791 +and -funsigned-char.
8793 +/* We are using unsigned char */
8794 +#define DEFAULT_SIGNED_CHAR 0
8798 +A C expression for a string describing the name of the data type to use
8799 +for size values. The typedef name size_t is defined using the
8800 +contents of the string.
8802 +The string can contain more than one keyword. If so, separate them with
8803 +spaces, and write first any length keyword, then unsigned if
8804 +appropriate, and finally int. The string must exactly match one
8805 +of the data type names defined in the function
8806 +init_decl_processing in the file c-decl.c. You may not
8807 +omit int or change the order - that would cause the compiler to
8810 +If you don't define this macro, the default is "long unsigned int".
8812 +#define SIZE_TYPE "long unsigned int"
8815 +A C expression for a string describing the name of the data type to use
8816 +for the result of subtracting two pointers. The typedef name
8817 +ptrdiff_t is defined using the contents of the string. See
8818 +SIZE_TYPE above for more information.
8820 +If you don't define this macro, the default is "long int".
8822 +#define PTRDIFF_TYPE "long int"
8826 +A C expression for the size in bits of the data type for wide
8827 +characters. This is used in cpp, which cannot make use of
8830 +#define WCHAR_TYPE_SIZE 32
8834 +A C expression for a string describing the name of the data type to
8835 +use for wide characters passed to printf and returned from
8836 +getwc. The typedef name wint_t is defined using the
8837 +contents of the string. See SIZE_TYPE above for more
8840 +If you don't define this macro, the default is "unsigned int".
8842 +#define WINT_TYPE "unsigned int"
8845 +A C expression for a string describing the name of the data type that
8846 +can represent any value of any standard or extended signed integer type.
8847 +The typedef name intmax_t is defined using the contents of the
8848 +string. See SIZE_TYPE above for more information.
8850 +If you don't define this macro, the default is the first of
8851 +"int", "long int", or "long long int" that has as
8852 +much precision as long long int.
8854 +#define INTMAX_TYPE "long long int"
8857 +A C expression for a string describing the name of the data type that
8858 +can represent any value of any standard or extended unsigned integer
8859 +type. The typedef name uintmax_t is defined using the contents
8860 +of the string. See SIZE_TYPE above for more information.
8862 +If you don't define this macro, the default is the first of
8863 +"unsigned int", "long unsigned int", or "long long unsigned int"
8864 +that has as much precision as long long unsigned int.
8866 +#define UINTMAX_TYPE "long long unsigned int"
8869 +/******************************************************************************
8871 + *****************************************************************************/
8873 +/* Convert from gcc internal register number to register number
8874 + used in assembly code */
8875 +#define ASM_REGNUM(reg) (LAST_REGNUM - (reg))
8877 +/* Convert between register number used in assembly to gcc
8878 + internal register number */
8879 +#define INTERNAL_REGNUM(reg) (LAST_REGNUM - (reg))
8881 +/** Basic Characteristics of Registers **/
8884 +Number of hardware registers known to the compiler. They receive
8885 +numbers 0 through FIRST_PSEUDO_REGISTER-1; thus, the first
8886 +pseudo register's number really is assigned the number
8887 +FIRST_PSEUDO_REGISTER.
8889 +#define FIRST_PSEUDO_REGISTER (LAST_REGNUM + 1)
8891 +#define FIRST_REGNUM 0
8892 +#define LAST_REGNUM 15
8895 +An initializer that says which registers are used for fixed purposes
8896 +all throughout the compiled code and are therefore not available for
8897 +general allocation. These would include the stack pointer, the frame
8898 +pointer (except on machines where that can be used as a general
8899 +register when no frame pointer is needed), the program counter on
8900 +machines where that is considered one of the addressable registers,
8901 +and any other numbered register with a standard use.
8903 +This information is expressed as a sequence of numbers, separated by
8904 +commas and surrounded by braces. The nth number is 1 if
8905 +register n is fixed, 0 otherwise.
8907 +The table initialized from this macro, and the table initialized by
8908 +the following one, may be overridden at run time either automatically,
8909 +by the actions of the macro CONDITIONAL_REGISTER_USAGE, or by
8910 +the user with the command options -ffixed-[reg],
8911 +-fcall-used-[reg] and -fcall-saved-[reg].
8914 +/* The internal gcc register numbers are reversed
8915 + compared to the real register numbers since
8916 + gcc expects data types stored over multiple
8917 + registers in the register file to be big endian
8918 + if the memory layout is big endian. But this
8919 + is not the case for avr32 so we fake a big
8920 + endian register file. */
8922 +#define FIXED_REGISTERS { \
8923 + 1, /* Program Counter */ \
8924 + 0, /* Link Register */ \
8925 + 1, /* Stack Pointer */ \
8942 +Like FIXED_REGISTERS but has 1 for each register that is
8943 +clobbered (in general) by function calls as well as for fixed
8944 +registers. This macro therefore identifies the registers that are not
8945 +available for general allocation of values that must live across
8948 +If a register has 0 in CALL_USED_REGISTERS, the compiler
8949 +automatically saves it on function entry and restores it on function
8950 +exit, if the register is used within the function.
8952 +#define CALL_USED_REGISTERS { \
8953 + 1, /* Program Counter */ \
8954 + 0, /* Link Register */ \
8955 + 1, /* Stack Pointer */ \
8971 +/* Interrupt functions can only use registers that have already been
8972 + saved by the prologue, even if they would normally be
8973 + call-clobbered. */
8974 +#define HARD_REGNO_RENAME_OK(SRC, DST) \
8975 + (! IS_INTERRUPT (cfun->machine->func_type) || \
8976 + df_regs_ever_live_p (DST))
8980 +Zero or more C statements that may conditionally modify five variables
8981 +fixed_regs, call_used_regs, global_regs,
8982 +reg_names, and reg_class_contents, to take into account
8983 +any dependence of these register sets on target flags. The first three
8984 +of these are of type char [] (interpreted as Boolean vectors).
8985 +global_regs is a const char *[], and
8986 +reg_class_contents is a HARD_REG_SET. Before the macro is
8987 +called, fixed_regs, call_used_regs,
8988 +reg_class_contents, and reg_names have been initialized
8989 +from FIXED_REGISTERS, CALL_USED_REGISTERS,
8990 +REG_CLASS_CONTENTS, and REGISTER_NAMES, respectively.
8991 +global_regs has been cleared, and any -ffixed-[reg],
8992 +-fcall-used-[reg] and -fcall-saved-[reg]
8993 +command options have been applied.
8995 +You need not define this macro if it has no work to do.
8997 +If the usage of an entire class of registers depends on the target
8998 +flags, you may indicate this to GCC by using this macro to modify
8999 +fixed_regs and call_used_regs to 1 for each of the
9000 +registers in the classes which should not be used by GCC. Also define
9001 +the macro REG_CLASS_FROM_LETTER to return NO_REGS if it
9002 +is called with a letter for a class that shouldn't be used.
9004 + (However, if this class is not included in GENERAL_REGS and all
9005 +of the insn patterns whose constraints permit this class are
9006 +controlled by target switches, then GCC will automatically avoid using
9007 +these registers when the target switches are opposed to them.)
9009 +#define CONDITIONAL_REGISTER_USAGE \
9014 + fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
9015 + call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
9022 +If the program counter has a register number, define this as that
9023 +register number. Otherwise, do not define it.
9026 +#define LAST_AVR32_REGNUM 16
9029 +/** Order of Allocation of Registers **/
9032 +If defined, an initializer for a vector of integers, containing the
9033 +numbers of hard registers in the order in which GCC should prefer
9034 +to use them (from most preferred to least).
9036 +If this macro is not defined, registers are used lowest numbered first
9037 +(all else being equal).
9039 +One use of this macro is on machines where the highest numbered
9040 +registers must always be saved and the save-multiple-registers
9041 +instruction supports only sequences of consecutive registers. On such
9042 +machines, define REG_ALLOC_ORDER to be an initializer that lists
9043 +the highest numbered allocable register first.
9045 +#define REG_ALLOC_ORDER \
9047 + INTERNAL_REGNUM(8), \
9048 + INTERNAL_REGNUM(9), \
9049 + INTERNAL_REGNUM(10), \
9050 + INTERNAL_REGNUM(11), \
9051 + INTERNAL_REGNUM(12), \
9053 + INTERNAL_REGNUM(7), \
9054 + INTERNAL_REGNUM(6), \
9055 + INTERNAL_REGNUM(5), \
9056 + INTERNAL_REGNUM(4), \
9057 + INTERNAL_REGNUM(3), \
9058 + INTERNAL_REGNUM(2), \
9059 + INTERNAL_REGNUM(1), \
9060 + INTERNAL_REGNUM(0), \
9066 +/** How Values Fit in Registers **/
9069 +A C expression for the number of consecutive hard registers, starting
9070 +at register number REGNO, required to hold a value of mode
9073 +On a machine where all registers are exactly one word, a suitable
9074 +definition of this macro is
9076 +#define HARD_REGNO_NREGS(REGNO, MODE) \
9077 + ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
9080 +#define HARD_REGNO_NREGS(REGNO, MODE) \
9081 + ((unsigned int)((GET_MODE_SIZE(MODE) + UNITS_PER_WORD -1 ) / UNITS_PER_WORD))
9084 +A C expression that is nonzero if it is permissible to store a value
9085 +of mode MODE in hard register number REGNO (or in several
9086 +registers starting with that one). For a machine where all registers
9087 +are equivalent, a suitable definition is
9089 + #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
9091 +You need not include code to check for the numbers of fixed registers,
9092 +because the allocation mechanism considers them to be always occupied.
9094 +On some machines, double-precision values must be kept in even/odd
9095 +register pairs. You can implement that by defining this macro to reject
9096 +odd register numbers for such modes.
9098 +The minimum requirement for a mode to be OK in a register is that the
9099 +mov[mode] instruction pattern support moves between the
9100 +register and other hard register in the same class and that moving a
9101 +value into the register and back out not alter it.
9103 +Since the same instruction used to move word_mode will work for
9104 +all narrower integer modes, it is not necessary on any machine for
9105 +HARD_REGNO_MODE_OK to distinguish between these modes, provided
9106 +you define patterns movhi, etc., to take advantage of this. This
9107 +is useful because of the interaction between HARD_REGNO_MODE_OK
9108 +and MODES_TIEABLE_P; it is very desirable for all integer modes
9111 +Many machines have special registers for floating point arithmetic.
9112 +Often people assume that floating point machine modes are allowed only
9113 +in floating point registers. This is not true. Any registers that
9114 +can hold integers can safely hold a floating point machine
9115 +mode, whether or not floating arithmetic can be done on it in those
9116 +registers. Integer move instructions can be used to move the values.
9118 +On some machines, though, the converse is true: fixed-point machine
9119 +modes may not go in floating registers. This is true if the floating
9120 +registers normalize any value stored in them, because storing a
9121 +non-floating value there would garble it. In this case,
9122 +HARD_REGNO_MODE_OK should reject fixed-point machine modes in
9123 +floating registers. But if the floating registers do not automatically
9124 +normalize, if you can store any bit pattern in one and retrieve it
9125 +unchanged without a trap, then any machine mode may go in a floating
9126 +register, so you can define this macro to say so.
9128 +The primary significance of special floating registers is rather that
9129 +they are the registers acceptable in floating point arithmetic
9130 +instructions. However, this is of no concern to
9131 +HARD_REGNO_MODE_OK. You handle it by writing the proper
9132 +constraints for those instructions.
9134 +On some machines, the floating registers are especially slow to access,
9135 +so that it is better to store a value in a stack frame than in such a
9136 +register if floating point arithmetic is not being done. As long as the
9137 +floating registers are not in class GENERAL_REGS, they will not
9138 +be used unless some pattern's constraint asks for one.
9140 +#define HARD_REGNO_MODE_OK(REGNO, MODE) avr32_hard_regno_mode_ok(REGNO, MODE)
9143 +A C expression that is nonzero if a value of mode
9144 +MODE1 is accessible in mode MODE2 without copying.
9146 +If HARD_REGNO_MODE_OK(R, MODE1) and
9147 +HARD_REGNO_MODE_OK(R, MODE2) are always the same for
9148 +any R, then MODES_TIEABLE_P(MODE1, MODE2)
9149 +should be nonzero. If they differ for any R, you should define
9150 +this macro to return zero unless some other mechanism ensures the
9151 +accessibility of the value in a narrower mode.
9153 +You should define this macro to return nonzero in as many cases as
9154 +possible since doing so will allow GCC to perform better register
9157 +#define MODES_TIEABLE_P(MODE1, MODE2) \
9158 + (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
9162 +/******************************************************************************
9163 + * Register Classes
9164 + *****************************************************************************/
9167 +An enumeral type that must be defined with all the register class names
9168 +as enumeral values. NO_REGS must be first. ALL_REGS
9169 +must be the last register class, followed by one more enumeral value,
9170 +LIM_REG_CLASSES, which is not a register class but rather
9171 +tells how many classes there are.
9173 +Each register class has a number, which is the value of casting
9174 +the class name to type int. The number serves as an index
9175 +in many of the tables described below.
9186 +The number of distinct register classes, defined as follows:
9187 + #define N_REG_CLASSES (int) LIM_REG_CLASSES
9189 +#define N_REG_CLASSES (int)LIM_REG_CLASSES
9192 +An initializer containing the names of the register classes as C string
9193 +constants. These names are used in writing some of the debugging dumps.
9195 +#define REG_CLASS_NAMES \
9203 +An initializer containing the contents of the register classes, as integers
9204 +which are bit masks. The nth integer specifies the contents of class
9205 +n. The way the integer mask is interpreted is that
9206 +register r is in the class if mask & (1 << r) is 1.
9208 +When the machine has more than 32 registers, an integer does not suffice.
9209 +Then the integers are replaced by sub-initializers, braced groupings containing
9210 +several integers. Each sub-initializer must be suitable as an initializer
9211 +for the type HARD_REG_SET which is defined in hard-reg-set.h.
9212 +In this situation, the first integer in each sub-initializer corresponds to
9213 +registers 0 through 31, the second integer to registers 32 through 63, and
9216 +#define REG_CLASS_CONTENTS { \
9217 + {0x00000000}, /* NO_REGS */ \
9218 + {0x0000FFFF}, /* GENERAL_REGS */ \
9219 + {0x7FFFFFFF}, /* ALL_REGS */ \
9224 +A C expression whose value is a register class containing hard register
9225 +REGNO. In general there is more than one such class; choose a class
9226 +which is minimal, meaning that no smaller class also contains the
9229 +#define REGNO_REG_CLASS(REGNO) (GENERAL_REGS)
9232 +A macro whose definition is the name of the class to which a valid
9233 +base register must belong. A base register is one used in an address
9234 +which is the register value plus a displacement.
9236 +#define BASE_REG_CLASS GENERAL_REGS
9239 +This is a variation of the BASE_REG_CLASS macro which allows
9240 +the selection of a base register in a mode depenedent manner. If
9241 +mode is VOIDmode then it should return the same value as
9244 +#define MODE_BASE_REG_CLASS(MODE) BASE_REG_CLASS
9247 +A macro whose definition is the name of the class to which a valid
9248 +index register must belong. An index register is one used in an
9249 +address where its value is either multiplied by a scale factor or
9250 +added to another register (as well as added to a displacement).
9252 +#define INDEX_REG_CLASS BASE_REG_CLASS
9255 +A C expression which defines the machine-dependent operand constraint
9256 +letters for register classes. If CHAR is such a letter, the
9257 +value should be the register class corresponding to it. Otherwise,
9258 +the value should be NO_REGS. The register letter r,
9259 +corresponding to class GENERAL_REGS, will not be passed
9260 +to this macro; you do not need to handle it.
9262 +#define REG_CLASS_FROM_LETTER(CHAR) NO_REGS
9264 +/* These assume that REGNO is a hard or pseudo reg number.
9265 + They give nonzero only if REGNO is a hard reg of the suitable class
9266 + or a pseudo reg currently allocated to a suitable hard reg.
9267 + Since they use reg_renumber, they are safe only once reg_renumber
9268 + has been allocated, which happens in local-alloc.c. */
9269 +#define TEST_REGNO(R, TEST, VALUE) \
9270 + ((R TEST VALUE) || ((unsigned) reg_renumber[R] TEST VALUE))
9273 +A C expression which is nonzero if register number num is suitable for use as a base
9274 +register in operand addresses. It may be either a suitable hard register or a pseudo
9275 +register that has been allocated such a hard register.
9277 +#define REGNO_OK_FOR_BASE_P(NUM) TEST_REGNO(NUM, <=, LAST_REGNUM)
9280 +A C expression which is nonzero if register number NUM is
9281 +suitable for use as an index register in operand addresses. It may be
9282 +either a suitable hard register or a pseudo register that has been
9283 +allocated such a hard register.
9285 +The difference between an index register and a base register is that
9286 +the index register may be scaled. If an address involves the sum of
9287 +two registers, neither one of them scaled, then either one may be
9288 +labeled the ``base'' and the other the ``index''; but whichever
9289 +labeling is used must fit the machine's constraints of which registers
9290 +may serve in each capacity. The compiler will try both labelings,
9291 +looking for one that is valid, and will reload one or both registers
9292 +only if neither labeling works.
9294 +#define REGNO_OK_FOR_INDEX_P(NUM) TEST_REGNO(NUM, <=, LAST_REGNUM)
9297 +A C expression that places additional restrictions on the register class
9298 +to use when it is necessary to copy value X into a register in class
9299 +CLASS. The value is a register class; perhaps CLASS, or perhaps
9300 +another, smaller class. On many machines, the following definition is
9301 +safe: #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
9303 +Sometimes returning a more restrictive class makes better code. For
9304 +example, on the 68000, when X is an integer constant that is in range
9305 +for a 'moveq' instruction, the value of this macro is always
9306 +DATA_REGS as long as CLASS includes the data registers.
9307 +Requiring a data register guarantees that a 'moveq' will be used.
9309 +If X is a const_double, by returning NO_REGS
9310 +you can force X into a memory constant. This is useful on
9311 +certain machines where immediate floating values cannot be loaded into
9312 +certain kinds of registers.
9314 +#define PREFERRED_RELOAD_CLASS(X, CLASS) CLASS
9319 +A C expression for the maximum number of consecutive registers
9320 +of class CLASS needed to hold a value of mode MODE.
9322 +This is closely related to the macro HARD_REGNO_NREGS. In fact,
9323 +the value of the macro CLASS_MAX_NREGS(CLASS, MODE)
9324 +should be the maximum value of HARD_REGNO_NREGS(REGNO, MODE)
9325 +for all REGNO values in the class CLASS.
9327 +This macro helps control the handling of multiple-word values
9328 +in the reload pass.
9330 +#define CLASS_MAX_NREGS(CLASS, MODE) /* ToDo:fixme */ \
9331 + (unsigned int)((GET_MODE_SIZE(MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
9335 + Using CONST_OK_FOR_CONSTRAINT_P instead of CONS_OK_FOR_LETTER_P
9336 + in order to support constraints with more than one letter.
9337 + Only two letters are then used for constant constraints,
9338 + the letter 'K' and the letter 'I'. The constraint starting with
9339 + these letters must consist of four characters. The character following
9340 + 'K' or 'I' must be either 'u' (unsigned) or 's' (signed) to specify
9341 + if the constant is zero or sign extended. The last two characters specify
9342 + the length in bits of the constant. The base constraint letter 'I' means
9343 + that this is an negated constant, meaning that actually -VAL should be
9344 + checked to lie withing the valid range instead of VAL which is used when
9345 + 'K' is the base constraint letter.
9349 +#define CONSTRAINT_LEN(C, STR) \
9350 + ( ((C) == 'K' || (C) == 'I') ? 4 : \
9351 + ((C) == 'R') ? 5 : \
9352 + ((C) == 'P') ? -1 : \
9353 + DEFAULT_CONSTRAINT_LEN((C), (STR)) )
9355 +#define CONST_OK_FOR_CONSTRAINT_P(VALUE, C, STR) \
9356 + avr32_const_ok_for_constraint_p(VALUE, C, STR)
9359 +A C expression that defines the machine-dependent operand constraint
9360 +letters that specify particular ranges of const_double values ('G' or 'H').
9362 +If C is one of those letters, the expression should check that
9363 +VALUE, an RTX of code const_double, is in the appropriate
9364 +range and return 1 if so, 0 otherwise. If C is not one of those
9365 +letters, the value should be 0 regardless of VALUE.
9367 +const_double is used for all floating-point constants and for
9368 +DImode fixed-point constants. A given letter can accept either
9369 +or both kinds of values. It can use GET_MODE to distinguish
9370 +between these kinds.
9372 +#define CONST_DOUBLE_OK_FOR_LETTER_P(OP, C) \
9373 + ((C) == 'G' ? avr32_const_double_immediate(OP) : 0)
9376 +A C expression that defines the optional machine-dependent constraint
9377 +letters that can be used to segregate specific types of operands, usually
9378 +memory references, for the target machine. Any letter that is not
9379 +elsewhere defined and not matched by REG_CLASS_FROM_LETTER
9380 +may be used. Normally this macro will not be defined.
9382 +If it is required for a particular target machine, it should return 1
9383 +if VALUE corresponds to the operand type represented by the
9384 +constraint letter C. If C is not defined as an extra
9385 +constraint, the value returned should be 0 regardless of VALUE.
9387 +For example, on the ROMP, load instructions cannot have their output
9388 +in r0 if the memory reference contains a symbolic address. Constraint
9389 +letter 'Q' is defined as representing a memory address that does
9390 +not contain a symbolic address. An alternative is specified with
9391 +a 'Q' constraint on the input and 'r' on the output. The next
9392 +alternative specifies 'm' on the input and a register class that
9393 +does not include r0 on the output.
9395 +#define EXTRA_CONSTRAINT_STR(OP, C, STR) \
9396 + ((C) == 'W' ? avr32_address_operand(OP, GET_MODE(OP)) : \
9397 + (C) == 'R' ? (avr32_indirect_register_operand(OP, GET_MODE(OP)) || \
9398 + (avr32_imm_disp_memory_operand(OP, GET_MODE(OP)) \
9399 + && avr32_const_ok_for_constraint_p( \
9400 + INTVAL(XEXP(XEXP(OP, 0), 1)), \
9401 + (STR)[1], &(STR)[1]))) : \
9402 + (C) == 'S' ? avr32_indexed_memory_operand(OP, GET_MODE(OP)) : \
9403 + (C) == 'T' ? avr32_const_pool_ref_operand(OP, GET_MODE(OP)) : \
9404 + (C) == 'U' ? SYMBOL_REF_RCALL_FUNCTION_P(OP) : \
9405 + (C) == 'Z' ? avr32_cop_memory_operand(OP, GET_MODE(OP)) : \
9406 + (C) == 'Q' ? avr32_non_rmw_memory_operand(OP, GET_MODE(OP)) : \
9407 + (C) == 'Y' ? avr32_rmw_memory_operand(OP, GET_MODE(OP)) : \
9411 +#define EXTRA_MEMORY_CONSTRAINT(C, STR) ( ((C) == 'R') || \
9418 +/* Returns nonzero if op is a function SYMBOL_REF which
9419 + can be called using an rcall instruction */
9420 +#define SYMBOL_REF_RCALL_FUNCTION_P(op) \
9421 + ( GET_CODE(op) == SYMBOL_REF \
9422 + && SYMBOL_REF_FUNCTION_P(op) \
9423 + && SYMBOL_REF_LOCAL_P(op) \
9424 + && !SYMBOL_REF_EXTERNAL_P(op) \
9425 + && !TARGET_HAS_ASM_ADDR_PSEUDOS )
9427 +/******************************************************************************
9428 + * Stack Layout and Calling Conventions
9429 + *****************************************************************************/
9431 +/** Basic Stack Layout **/
9434 +Define this macro if pushing a word onto the stack moves the stack
9435 +pointer to a smaller address.
9437 +When we say, ``define this macro if ...,'' it means that the
9438 +compiler checks this macro only with #ifdef so the precise
9439 +definition used does not matter.
9441 +/* pushm decrece SP: *(--SP) <-- Rx */
9442 +#define STACK_GROWS_DOWNWARD
9445 +This macro defines the operation used when something is pushed
9446 +on the stack. In RTL, a push operation will be
9447 +(set (mem (STACK_PUSH_CODE (reg sp))) ...)
9449 +The choices are PRE_DEC, POST_DEC, PRE_INC,
9450 +and POST_INC. Which of these is correct depends on
9451 +the stack direction and on whether the stack pointer points
9452 +to the last item on the stack or whether it points to the
9453 +space for the next item on the stack.
9455 +The default is PRE_DEC when STACK_GROWS_DOWNWARD is
9456 +defined, which is almost always right, and PRE_INC otherwise,
9457 +which is often wrong.
9459 +/* pushm: *(--SP) <-- Rx */
9460 +#define STACK_PUSH_CODE PRE_DEC
9462 +/* Define this to nonzero if the nominal address of the stack frame
9463 + is at the high-address end of the local variables;
9464 + that is, each additional local variable allocated
9465 + goes at a more negative offset in the frame. */
9466 +#define FRAME_GROWS_DOWNWARD 1
9470 +Offset from the frame pointer to the first local variable slot to be allocated.
9472 +If FRAME_GROWS_DOWNWARD, find the next slot's offset by
9473 +subtracting the first slot's length from STARTING_FRAME_OFFSET.
9474 +Otherwise, it is found by adding the length of the first slot to the
9475 +value STARTING_FRAME_OFFSET.
9476 + (i'm not sure if the above is still correct.. had to change it to get
9477 + rid of an overfull. --mew 2feb93 )
9479 +#define STARTING_FRAME_OFFSET 0
9482 +Offset from the stack pointer register to the first location at which
9483 +outgoing arguments are placed. If not specified, the default value of
9484 +zero is used. This is the proper value for most machines.
9486 +If ARGS_GROW_DOWNWARD, this is the offset to the location above
9487 +the first location at which outgoing arguments are placed.
9489 +#define STACK_POINTER_OFFSET 0
9492 +Offset from the argument pointer register to the first argument's
9493 +address. On some machines it may depend on the data type of the
9496 +If ARGS_GROW_DOWNWARD, this is the offset to the location above
9497 +the first argument's address.
9499 +#define FIRST_PARM_OFFSET(FUNDECL) 0
9503 +A C expression whose value is RTL representing the address in a stack
9504 +frame where the pointer to the caller's frame is stored. Assume that
9505 +FRAMEADDR is an RTL expression for the address of the stack frame
9508 +If you don't define this macro, the default is to return the value
9509 +of FRAMEADDR - that is, the stack frame address is also the
9510 +address of the stack word that points to the previous frame.
9512 +#define DYNAMIC_CHAIN_ADDRESS(FRAMEADDR) plus_constant ((FRAMEADDR), 4)
9516 +A C expression whose value is RTL representing the value of the return
9517 +address for the frame COUNT steps up from the current frame, after
9518 +the prologue. FRAMEADDR is the frame pointer of the COUNT
9519 +frame, or the frame pointer of the COUNT - 1 frame if
9520 +RETURN_ADDR_IN_PREVIOUS_FRAME is defined.
9522 +The value of the expression must always be the correct address when
9523 +COUNT is zero, but may be NULL_RTX if there is not way to
9524 +determine the return address of other frames.
9526 +#define RETURN_ADDR_RTX(COUNT, FRAMEADDR) avr32_return_addr(COUNT, FRAMEADDR)
9530 +A C expression whose value is RTL representing the location of the
9531 +incoming return address at the beginning of any function, before the
9532 +prologue. This RTL is either a REG, indicating that the return
9533 +value is saved in 'REG', or a MEM representing a location in
9536 +You only need to define this macro if you want to support call frame
9537 +debugging information like that provided by DWARF 2.
9539 +If this RTL is a REG, you should also define
9540 +DWARF_FRAME_RETURN_COLUMN to DWARF_FRAME_REGNUM (REGNO).
9542 +#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LR_REGNUM)
9545 +A C expression whose value is an integer giving the offset, in bytes,
9546 +from the value of the stack pointer register to the top of the stack
9547 +frame at the beginning of any function, before the prologue. The top of
9548 +the frame is defined to be the value of the stack pointer in the
9549 +previous frame, just before the call instruction.
9551 +You only need to define this macro if you want to support call frame
9552 +debugging information like that provided by DWARF 2.
9554 +#define INCOMING_FRAME_SP_OFFSET 0
9557 +/** Exception Handling Support **/
9559 +/* Use setjump/longjump for exception handling. */
9560 +#define DWARF2_UNWIND_INFO 0
9561 +#define MUST_USE_SJLJ_EXCEPTIONS 1
9564 +A C expression whose value is the Nth register number used for
9565 +data by exception handlers, or INVALID_REGNUM if fewer than
9566 +N registers are usable.
9568 +The exception handling library routines communicate with the exception
9569 +handlers via a set of agreed upon registers. Ideally these registers
9570 +should be call-clobbered; it is possible to use call-saved registers,
9571 +but may negatively impact code size. The target must support at least
9572 +2 data registers, but should define 4 if there are enough free registers.
9574 +You must define this macro if you want to support call frame exception
9575 +handling like that provided by DWARF 2.
9580 +#define EH_RETURN_DATA_REGNO(N) \
9581 + ((N<3) ? INTERNAL_REGNUM(N+9) : INVALID_REGNUM)
9584 +A C expression whose value is RTL representing a location in which
9585 +to store a stack adjustment to be applied before function return.
9586 +This is used to unwind the stack to an exception handler's call frame.
9587 +It will be assigned zero on code paths that return normally.
9589 +Typically this is a call-clobbered hard register that is otherwise
9590 +untouched by the epilogue, but could also be a stack slot.
9592 +You must define this macro if you want to support call frame exception
9593 +handling like that provided by DWARF 2.
9598 +#define EH_RETURN_STACKADJ_REGNO INTERNAL_REGNUM(8)
9599 +#define EH_RETURN_STACKADJ_RTX gen_rtx_REG(SImode, EH_RETURN_STACKADJ_REGNO)
9602 +A C expression whose value is RTL representing a location in which
9603 +to store the address of an exception handler to which we should
9604 +return. It will not be assigned on code paths that return normally.
9606 +Typically this is the location in the call frame at which the normal
9607 +return address is stored. For targets that return by popping an
9608 +address off the stack, this might be a memory address just below
9609 +the target call frame rather than inside the current call
9610 +frame. EH_RETURN_STACKADJ_RTX will have already been assigned,
9611 +so it may be used to calculate the location of the target call frame.
9613 +Some targets have more complex requirements than storing to an
9614 +address calculable during initial code generation. In that case
9615 +the eh_return instruction pattern should be used instead.
9617 +If you want to support call frame exception handling, you must
9618 +define either this macro or the eh_return instruction pattern.
9621 + We define the eh_return instruction pattern, so this isn't needed.
9623 +/* #define EH_RETURN_HANDLER_RTX gen_rtx_REG(Pmode, RET_REGISTER) */
9626 + This macro chooses the encoding of pointers embedded in the
9627 + exception handling sections. If at all possible, this should be
9628 + defined such that the exception handling section will not require
9629 + dynamic relocations, and so may be read-only.
9631 + code is 0 for data, 1 for code labels, 2 for function
9632 + pointers. global is true if the symbol may be affected by dynamic
9633 + relocations. The macro should return a combination of the DW_EH_PE_*
9634 + defines as found in dwarf2.h.
9636 + If this macro is not defined, pointers will not be encoded but
9637 + represented directly.
9639 +#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
9640 + ((flag_pic && (GLOBAL) ? DW_EH_PE_indirect : 0) \
9641 + | (flag_pic ? DW_EH_PE_pcrel : DW_EH_PE_absptr) \
9642 + | DW_EH_PE_sdata4)
9644 +/* ToDo: The rest of this subsection */
9646 +/** Specifying How Stack Checking is Done **/
9647 +/* ToDo: All in this subsection */
9649 +/** Registers That Address the Stack Frame **/
9652 +The register number of the stack pointer register, which must also be a
9653 +fixed register according to FIXED_REGISTERS. On most machines,
9654 +the hardware determines which register this is.
9656 +/* Using r13 as stack pointer. */
9657 +#define STACK_POINTER_REGNUM INTERNAL_REGNUM(13)
9660 +The register number of the frame pointer register, which is used to
9661 +access automatic variables in the stack frame. On some machines, the
9662 +hardware determines which register this is. On other machines, you can
9663 +choose any register you wish for this purpose.
9666 +#define FRAME_POINTER_REGNUM INTERNAL_REGNUM(7)
9669 +The register number of the arg pointer register, which is used to access
9670 +the function's argument list. On some machines, this is the same as the
9671 +frame pointer register. On some machines, the hardware determines which
9672 +register this is. On other machines, you can choose any register you
9673 +wish for this purpose. If this is not the same register as the frame
9674 +pointer register, then you must mark it as a fixed register according to
9675 +FIXED_REGISTERS, or arrange to be able to eliminate it (see Section
9676 +10.10.5 [Elimination], page 224).
9679 +#define ARG_POINTER_REGNUM INTERNAL_REGNUM(4)
9683 +Register numbers used for passing a function's static chain pointer. If
9684 +register windows are used, the register number as seen by the called
9685 +function is STATIC_CHAIN_INCOMING_REGNUM, while the register
9686 +number as seen by the calling function is STATIC_CHAIN_REGNUM. If
9687 +these registers are the same, STATIC_CHAIN_INCOMING_REGNUM need
9690 +The static chain register need not be a fixed register.
9692 +If the static chain is passed in memory, these macros should not be
9693 +defined; instead, the next two macros should be defined.
9696 +#define STATIC_CHAIN_REGNUM INTERNAL_REGNUM(0)
9698 +/** Eliminating Frame Pointer and Arg Pointer **/
9701 +A C expression which is nonzero if a function must have and use a frame
9702 +pointer. This expression is evaluated in the reload pass. If its value is
9703 +nonzero the function will have a frame pointer.
9705 +The expression can in principle examine the current function and decide
9706 +according to the facts, but on most machines the constant 0 or the
9707 +constant 1 suffices. Use 0 when the machine allows code to be generated
9708 +with no frame pointer, and doing so saves some time or space. Use 1
9709 +when there is no possible advantage to avoiding a frame pointer.
9711 +In certain cases, the compiler does not know how to produce valid code
9712 +without a frame pointer. The compiler recognizes those cases and
9713 +automatically gives the function a frame pointer regardless of what
9714 +FRAME_POINTER_REQUIRED says. You don't need to worry about
9717 +In a function that does not require a frame pointer, the frame pointer
9718 +register can be allocated for ordinary usage, unless you mark it as a
9719 +fixed register. See FIXED_REGISTERS for more information.
9721 +/* We need the frame pointer when compiling for profiling */
9722 +#define FRAME_POINTER_REQUIRED (current_function_profile)
9725 +A C statement to store in the variable DEPTH_VAR the difference
9726 +between the frame pointer and the stack pointer values immediately after
9727 +the function prologue. The value would be computed from information
9728 +such as the result of get_frame_size () and the tables of
9729 +registers regs_ever_live and call_used_regs.
9731 +If ELIMINABLE_REGS is defined, this macro will be not be used and
9732 +need not be defined. Otherwise, it must be defined even if
9733 +FRAME_POINTER_REQUIRED is defined to always be true; in that
9734 +case, you may set DEPTH_VAR to anything.
9736 +#define INITIAL_FRAME_POINTER_OFFSET(DEPTH_VAR) ((DEPTH_VAR) = get_frame_size())
9739 +If defined, this macro specifies a table of register pairs used to
9740 +eliminate unneeded registers that point into the stack frame. If it is not
9741 +defined, the only elimination attempted by the compiler is to replace
9742 +references to the frame pointer with references to the stack pointer.
9744 +The definition of this macro is a list of structure initializations, each
9745 +of which specifies an original and replacement register.
9747 +On some machines, the position of the argument pointer is not known until
9748 +the compilation is completed. In such a case, a separate hard register
9749 +must be used for the argument pointer. This register can be eliminated by
9750 +replacing it with either the frame pointer or the argument pointer,
9751 +depending on whether or not the frame pointer has been eliminated.
9753 +In this case, you might specify:
9754 + #define ELIMINABLE_REGS \
9755 + {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
9756 + {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
9757 + {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
9759 +Note that the elimination of the argument pointer with the stack pointer is
9760 +specified first since that is the preferred elimination.
9762 +#define ELIMINABLE_REGS \
9764 + { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
9765 + { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
9766 + { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM } \
9770 +A C expression that returns nonzero if the compiler is allowed to try
9771 +to replace register number FROM with register number
9772 +TO. This macro need only be defined if ELIMINABLE_REGS
9773 +is defined, and will usually be the constant 1, since most of the cases
9774 +preventing register elimination are things that the compiler already
9777 +#define CAN_ELIMINATE(FROM, TO) 1
9780 +This macro is similar to INITIAL_FRAME_POINTER_OFFSET. It
9781 +specifies the initial difference between the specified pair of
9782 +registers. This macro must be defined if ELIMINABLE_REGS is
9785 +#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
9786 + ((OFFSET) = avr32_initial_elimination_offset(FROM, TO))
9788 +/** Passing Function Arguments on the Stack **/
9792 +A C expression. If nonzero, push insns will be used to pass
9793 +outgoing arguments.
9794 +If the target machine does not have a push instruction, set it to zero.
9795 +That directs GCC to use an alternate strategy: to
9796 +allocate the entire argument block and then store the arguments into
9797 +it. When PUSH_ARGS is nonzero, PUSH_ROUNDING must be defined too.
9799 +#define PUSH_ARGS 1
9802 +A C expression that is the number of bytes actually pushed onto the
9803 +stack when an instruction attempts to push NPUSHED bytes.
9805 +On some machines, the definition
9807 + #define PUSH_ROUNDING(BYTES) (BYTES)
9809 +will suffice. But on other machines, instructions that appear
9810 +to push one byte actually push two bytes in an attempt to maintain
9811 +alignment. Then the definition should be
9813 + #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
9815 +/* Push 4 bytes at the time. */
9816 +#define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3)
9819 +A C expression. If nonzero, the maximum amount of space required for
9820 +outgoing arguments will be computed and placed into the variable
9821 +current_function_outgoing_args_size. No space will be pushed
9822 +onto the stack for each call; instead, the function prologue should
9823 +increase the stack frame size by this amount.
9825 +Setting both PUSH_ARGS and ACCUMULATE_OUTGOING_ARGS is not proper.
9827 +#define ACCUMULATE_OUTGOING_ARGS 0
9830 +A C expression that should indicate the number of bytes of its own
9831 +arguments that a function pops on returning, or 0 if the
9832 +function pops no arguments and the caller must therefore pop them all
9833 +after the function returns.
9835 +FUNDECL is a C variable whose value is a tree node that describes
9836 +the function in question. Normally it is a node of type
9837 +FUNCTION_DECL that describes the declaration of the function.
9838 +From this you can obtain the DECL_ATTRIBUTES of the function.
9840 +FUNTYPE is a C variable whose value is a tree node that
9841 +describes the function in question. Normally it is a node of type
9842 +FUNCTION_TYPE that describes the data type of the function.
9843 +From this it is possible to obtain the data types of the value and
9844 +arguments (if known).
9846 +When a call to a library function is being considered, FUNDECL
9847 +will contain an identifier node for the library function. Thus, if
9848 +you need to distinguish among various library functions, you can do so
9849 +by their names. Note that ``library function'' in this context means
9850 +a function used to perform arithmetic, whose name is known specially
9851 +in the compiler and was not mentioned in the C code being compiled.
9853 +STACK_SIZE is the number of bytes of arguments passed on the
9854 +stack. If a variable number of bytes is passed, it is zero, and
9855 +argument popping will always be the responsibility of the calling function.
9857 +On the VAX, all functions always pop their arguments, so the definition
9858 +of this macro is STACK_SIZE. On the 68000, using the standard
9859 +calling convention, no functions pop their arguments, so the value of
9860 +the macro is always 0 in this case. But an alternative calling
9861 +convention is available in which functions that take a fixed number of
9862 +arguments pop them but other functions (such as printf) pop
9863 +nothing (the caller pops all). When this convention is in use,
9864 +FUNTYPE is examined to determine whether a function takes a fixed
9865 +number of arguments.
9867 +#define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACK_SIZE) 0
9870 +/*Return true if this function can we use a single return instruction*/
9871 +#define USE_RETURN_INSN(ISCOND) avr32_use_return_insn(ISCOND)
9874 +A C expression that should indicate the number of bytes a call sequence
9875 +pops off the stack. It is added to the value of RETURN_POPS_ARGS
9876 +when compiling a function call.
9878 +CUM is the variable in which all arguments to the called function
9879 +have been accumulated.
9881 +On certain architectures, such as the SH5, a call trampoline is used
9882 +that pops certain registers off the stack, depending on the arguments
9883 +that have been passed to the function. Since this is a property of the
9884 +call site, not of the called function, RETURN_POPS_ARGS is not
9887 +#define CALL_POPS_ARGS(CUM) 0
9889 +/* Passing Arguments in Registers */
9892 +A C expression that controls whether a function argument is passed
9893 +in a register, and which register.
9895 +The arguments are CUM, which summarizes all the previous
9896 +arguments; MODE, the machine mode of the argument; TYPE,
9897 +the data type of the argument as a tree node or 0 if that is not known
9898 +(which happens for C support library functions); and NAMED,
9899 +which is 1 for an ordinary argument and 0 for nameless arguments that
9900 +correspond to '...' in the called function's prototype.
9901 +TYPE can be an incomplete type if a syntax error has previously
9904 +The value of the expression is usually either a reg RTX for the
9905 +hard register in which to pass the argument, or zero to pass the
9906 +argument on the stack.
9908 +For machines like the VAX and 68000, where normally all arguments are
9909 +pushed, zero suffices as a definition.
9911 +The value of the expression can also be a parallel RTX. This is
9912 +used when an argument is passed in multiple locations. The mode of the
9913 +of the parallel should be the mode of the entire argument. The
9914 +parallel holds any number of expr_list pairs; each one
9915 +describes where part of the argument is passed. In each
9916 +expr_list the first operand must be a reg RTX for the hard
9917 +register in which to pass this part of the argument, and the mode of the
9918 +register RTX indicates how large this part of the argument is. The
9919 +second operand of the expr_list is a const_int which gives
9920 +the offset in bytes into the entire argument of where this part starts.
9921 +As a special exception the first expr_list in the parallel
9922 +RTX may have a first operand of zero. This indicates that the entire
9923 +argument is also stored on the stack.
9925 +The last time this macro is called, it is called with MODE == VOIDmode,
9926 +and its result is passed to the call or call_value
9927 +pattern as operands 2 and 3 respectively.
9929 +The usual way to make the ISO library 'stdarg.h' work on a machine
9930 +where some arguments are usually passed in registers, is to cause
9931 +nameless arguments to be passed on the stack instead. This is done
9932 +by making FUNCTION_ARG return 0 whenever NAMED is 0.
9934 +You may use the macro MUST_PASS_IN_STACK (MODE, TYPE)
9935 +in the definition of this macro to determine if this argument is of a
9936 +type that must be passed in the stack. If REG_PARM_STACK_SPACE
9937 +is not defined and FUNCTION_ARG returns nonzero for such an
9938 +argument, the compiler will abort. If REG_PARM_STACK_SPACE is
9939 +defined, the argument will be computed in the stack and then loaded into
9942 +#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
9943 + avr32_function_arg(&(CUM), MODE, TYPE, NAMED)
9946 +A C type for declaring a variable that is used as the first argument of
9947 +FUNCTION_ARG and other related values. For some target machines,
9948 +the type int suffices and can hold the number of bytes of
9951 +There is no need to record in CUMULATIVE_ARGS anything about the
9952 +arguments that have been passed on the stack. The compiler has other
9953 +variables to keep track of that. For target machines on which all
9954 +arguments are passed on the stack, there is no need to store anything in
9955 +CUMULATIVE_ARGS; however, the data structure must exist and
9956 +should not be empty, so use int.
9958 +typedef struct avr32_args
9960 + /* Index representing the argument register the current function argument
9963 + /* A mask with bits representing the argument registers: if a bit is set
9964 + then this register is used for an argument */
9966 + /* TRUE if this function has anonymous arguments */
9967 + int uses_anonymous_args;
9968 + /* The size in bytes of the named arguments pushed on the stack */
9969 + int stack_pushed_args_size;
9970 + /* Set to true if this function needs a Return Value Pointer */
9972 + /* Set to true if function is a flashvault function. */
9973 + int flashvault_func;
9978 +#define FIRST_CUM_REG_INDEX 0
9979 +#define LAST_CUM_REG_INDEX 4
9980 +#define GET_REG_INDEX(CUM) ((CUM)->index)
9981 +#define SET_REG_INDEX(CUM, INDEX) ((CUM)->index = (INDEX));
9982 +#define GET_USED_INDEX(CUM, INDEX) ((CUM)->used_index & (1 << (INDEX)))
9983 +#define SET_USED_INDEX(CUM, INDEX) \
9987 + (CUM)->used_index |= (1 << (INDEX)); \
9990 +#define SET_INDEXES_UNUSED(CUM) ((CUM)->used_index = 0)
9993 + A C statement (sans semicolon) for initializing the variable cum for the
9994 + state at the beginning of the argument list. The variable has type
9995 + CUMULATIVE_ARGS. The value of FNTYPE is the tree node for the data type of
9996 + the function which will receive the args, or 0 if the args are to a compiler
9997 + support library function. For direct calls that are not libcalls, FNDECL
9998 + contain the declaration node of the function. FNDECL is also set when
9999 + INIT_CUMULATIVE_ARGS is used to find arguments for the function being
10000 + compiled. N_NAMED_ARGS is set to the number of named arguments, including a
10001 + structure return address if it is passed as a parameter, when making a call.
10002 + When processing incoming arguments, N_NAMED_ARGS is set to -1.
10004 + When processing a call to a compiler support library function, LIBNAME
10005 + identifies which one. It is a symbol_ref rtx which contains the name of the
10006 + function, as a string. LIBNAME is 0 when an ordinary C function call is
10007 + being processed. Thus, each time this macro is called, either LIBNAME or
10008 + FNTYPE is nonzero, but never both of them at once.
10010 +#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
10011 + avr32_init_cumulative_args(&(CUM), FNTYPE, LIBNAME, FNDECL)
10014 +A C statement (sans semicolon) to update the summarizer variable
10015 +CUM to advance past an argument in the argument list. The
10016 +values MODE, TYPE and NAMED describe that argument.
10017 +Once this is done, the variable CUM is suitable for analyzing
10018 +the following argument with FUNCTION_ARG, etc.
10020 +This macro need not do anything if the argument in question was passed
10021 +on the stack. The compiler knows how to track the amount of stack space
10022 +used for arguments without any special help.
10024 +#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
10025 + avr32_function_arg_advance(&(CUM), MODE, TYPE, NAMED)
10028 +If defined, a C expression which determines whether, and in which direction,
10029 +to pad out an argument with extra space. The value should be of type
10030 +enum direction: either 'upward' to pad above the argument,
10031 +'downward' to pad below, or 'none' to inhibit padding.
10033 +The amount of padding is always just enough to reach the next
10034 +multiple of FUNCTION_ARG_BOUNDARY; this macro does not control
10037 +This macro has a default definition which is right for most systems.
10038 +For little-endian machines, the default is to pad upward. For
10039 +big-endian machines, the default is to pad downward for an argument of
10040 +constant size shorter than an int, and upward otherwise.
10042 +#define FUNCTION_ARG_PADDING(MODE, TYPE) \
10043 + avr32_function_arg_padding(MODE, TYPE)
10046 + Specify padding for the last element of a block move between registers
10047 + and memory. First is nonzero if this is the only element. Defining
10048 + this macro allows better control of register function parameters on
10049 + big-endian machines, without using PARALLEL rtl. In particular,
10050 + MUST_PASS_IN_STACK need not test padding and mode of types in registers,
10051 + as there is no longer a "wrong" part of a register; For example, a three
10052 + byte aggregate may be passed in the high part of a register if so required.
10054 +#define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
10055 + avr32_function_arg_padding(MODE, TYPE)
10058 +If defined, a C expression which determines whether the default
10059 +implementation of va_arg will attempt to pad down before reading the
10060 +next argument, if that argument is smaller than its aligned space as
10061 +controlled by PARM_BOUNDARY. If this macro is not defined, all such
10062 +arguments are padded down if BYTES_BIG_ENDIAN is true.
10064 +#define PAD_VARARGS_DOWN \
10065 + (FUNCTION_ARG_PADDING (TYPE_MODE (type), type) == downward)
10068 +A C expression that is nonzero if REGNO is the number of a hard
10069 +register in which function arguments are sometimes passed. This does
10070 +not include implicit arguments such as the static chain and
10071 +the structure-value address. On many machines, no registers can be
10072 +used for this purpose since all function arguments are pushed on the
10076 + Use r8 - r12 for function arguments.
10078 +#define FUNCTION_ARG_REGNO_P(REGNO) \
10079 + (REGNO >= 3 && REGNO <= 7)
10081 +/* Number of registers used for passing function arguments */
10082 +#define NUM_ARG_REGS 5
10085 +If defined, the order in which arguments are loaded into their
10086 +respective argument registers is reversed so that the last
10087 +argument is loaded first. This macro only affects arguments
10088 +passed in registers.
10090 +/* #define LOAD_ARGS_REVERSED */
10092 +/** How Scalar Function Values Are Returned **/
10094 +/* AVR32 is using r12 as return register. */
10095 +#define RET_REGISTER (15 - 12)
10098 +A C expression to create an RTX representing the place where a library
10099 +function returns a value of mode MODE. If the precise function
10100 +being called is known, FUNC is a tree node
10101 +(FUNCTION_DECL) for it; otherwise, func is a null
10102 +pointer. This makes it possible to use a different value-returning
10103 +convention for specific functions when all their calls are
10106 +Note that "library function" in this context means a compiler
10107 +support routine, used to perform arithmetic, whose name is known
10108 +specially by the compiler and was not mentioned in the C code being
10111 +The definition of LIBRARY_VALUE need not be concerned aggregate
10112 +data types, because none of the library functions returns such types.
10114 +#define LIBCALL_VALUE(MODE) avr32_libcall_value(MODE)
10117 +A C expression that is nonzero if REGNO is the number of a hard
10118 +register in which the values of called function may come back.
10120 +A register whose use for returning values is limited to serving as the
10121 +second of a pair (for a value of type double, say) need not be
10122 +recognized by this macro. So for most machines, this definition
10124 + #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
10126 +If the machine has register windows, so that the caller and the called
10127 +function use different registers for the return value, this macro
10128 +should recognize only the caller's register numbers.
10131 + When returning a value of mode DImode, r11:r10 is used, else r12 is used.
10133 +#define FUNCTION_VALUE_REGNO_P(REGNO) ((REGNO) == RET_REGISTER \
10134 + || (REGNO) == INTERNAL_REGNUM(11))
10137 +/** How Large Values Are Returned **/
10141 +Define this macro to be 1 if all structure and union return values must be
10142 +in memory. Since this results in slower code, this should be defined
10143 +only if needed for compatibility with other compilers or with an ABI.
10144 +If you define this macro to be 0, then the conventions used for structure
10145 +and union return values are decided by the RETURN_IN_MEMORY macro.
10147 +If not defined, this defaults to the value 1.
10149 +#define DEFAULT_PCC_STRUCT_RETURN 0
10154 +/** Generating Code for Profiling **/
10157 +A C statement or compound statement to output to FILE some
10158 +assembler code to call the profiling subroutine mcount.
10160 +The details of how mcount expects to be called are determined by
10161 +your operating system environment, not by GCC. To figure them out,
10162 +compile a small program for profiling using the system's installed C
10163 +compiler and look at the assembler code that results.
10165 +Older implementations of mcount expect the address of a counter
10166 +variable to be loaded into some register. The name of this variable is
10167 +'LP' followed by the number LABELNO, so you would generate
10168 +the name using 'LP%d' in a fprintf.
10171 +#ifndef FUNCTION_PROFILER
10172 +#define FUNCTION_PROFILER(FILE, LABELNO) \
10173 + fprintf((FILE), "/* profiler %d */", (LABELNO))
10177 +/*****************************************************************************
10178 + * Trampolines for Nested Functions *
10179 + *****************************************************************************/
10182 +A C statement to output, on the stream FILE, assembler code for a
10183 +block of data that contains the constant parts of a trampoline. This
10184 +code should not include a label - the label is taken care of
10187 +If you do not define this macro, it means no template is needed
10188 +for the target. Do not define this macro on systems where the block move
10189 +code to copy the trampoline into place would be larger than the code
10190 +to generate it on the spot.
10192 +/* ToDo: correct? */
10193 +#define TRAMPOLINE_TEMPLATE(FILE) avr32_trampoline_template(FILE);
10197 +A C expression for the size in bytes of the trampoline, as an integer.
10200 +#define TRAMPOLINE_SIZE 0x0C
10203 +Alignment required for trampolines, in bits.
10205 +If you don't define this macro, the value of BIGGEST_ALIGNMENT
10206 +is used for aligning trampolines.
10208 +#define TRAMPOLINE_ALIGNMENT 16
10211 +A C statement to initialize the variable parts of a trampoline.
10212 +ADDR is an RTX for the address of the trampoline; FNADDR is
10213 +an RTX for the address of the nested function; STATIC_CHAIN is an
10214 +RTX for the static chain value that should be passed to the function
10215 +when it is called.
10217 +#define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, STATIC_CHAIN) \
10218 + avr32_initialize_trampoline(ADDR, FNADDR, STATIC_CHAIN)
10221 +/******************************************************************************
10222 + * Implicit Calls to Library Routines
10223 + *****************************************************************************/
10225 +/* Tail calling. */
10227 +/* A C expression that evaluates to true if it is ok to perform a sibling
10229 +#define FUNCTION_OK_FOR_SIBCALL(DECL) 0
10231 +#define OVERRIDE_OPTIONS avr32_override_options ()
10233 +#define OPTIMIZATION_OPTIONS(LEVEL, SIZE) avr32_optimization_options (LEVEL, SIZE)
10235 +/******************************************************************************
10236 + * Addressing Modes
10237 + *****************************************************************************/
10240 +A C expression that is nonzero if the machine supports pre-increment,
10241 +pre-decrement, post-increment, or post-decrement addressing respectively.
10244 + AVR32 supports Rp++ and --Rp
10246 +#define HAVE_PRE_INCREMENT 0
10247 +#define HAVE_PRE_DECREMENT 1
10248 +#define HAVE_POST_INCREMENT 1
10249 +#define HAVE_POST_DECREMENT 0
10252 +A C expression that is nonzero if the machine supports pre- or
10253 +post-address side-effect generation involving constants other than
10254 +the size of the memory operand.
10256 +#define HAVE_PRE_MODIFY_DISP 0
10257 +#define HAVE_POST_MODIFY_DISP 0
10260 +A C expression that is nonzero if the machine supports pre- or
10261 +post-address side-effect generation involving a register displacement.
10263 +#define HAVE_PRE_MODIFY_REG 0
10264 +#define HAVE_POST_MODIFY_REG 0
10267 +A C expression that is 1 if the RTX X is a constant which
10268 +is a valid address. On most machines, this can be defined as
10269 +CONSTANT_P (X), but a few machines are more restrictive
10270 +in which constant addresses are supported.
10272 +CONSTANT_P accepts integer-values expressions whose values are
10273 +not explicitly known, such as symbol_ref, label_ref, and
10274 +high expressions and const arithmetic expressions, in
10275 +addition to const_int and const_double expressions.
10277 +#define CONSTANT_ADDRESS_P(X) CONSTANT_P(X)
10280 +A number, the maximum number of registers that can appear in a valid
10281 +memory address. Note that it is up to you to specify a value equal to
10282 +the maximum number that GO_IF_LEGITIMATE_ADDRESS would ever
10285 +#define MAX_REGS_PER_ADDRESS 2
10288 +A C compound statement with a conditional goto LABEL;
10289 +executed if X (an RTX) is a legitimate memory address on the
10290 +target machine for a memory operand of mode MODE.
10292 +It usually pays to define several simpler macros to serve as
10293 +subroutines for this one. Otherwise it may be too complicated to
10296 +This macro must exist in two variants: a strict variant and a
10297 +non-strict one. The strict variant is used in the reload pass. It
10298 +must be defined so that any pseudo-register that has not been
10299 +allocated a hard register is considered a memory reference. In
10300 +contexts where some kind of register is required, a pseudo-register
10301 +with no hard register must be rejected.
10303 +The non-strict variant is used in other passes. It must be defined to
10304 +accept all pseudo-registers in every context where some kind of
10305 +register is required.
10307 +Compiler source files that want to use the strict variant of this
10308 +macro define the macro REG_OK_STRICT. You should use an
10309 +#ifdef REG_OK_STRICT conditional to define the strict variant
10310 +in that case and the non-strict variant otherwise.
10312 +Subroutines to check for acceptable registers for various purposes (one
10313 +for base registers, one for index registers, and so on) are typically
10314 +among the subroutines used to define GO_IF_LEGITIMATE_ADDRESS.
10315 +Then only these subroutine macros need have two variants; the higher
10316 +levels of macros may be the same whether strict or not.
10318 +Normally, constant addresses which are the sum of a symbol_ref
10319 +and an integer are stored inside a const RTX to mark them as
10320 +constant. Therefore, there is no need to recognize such sums
10321 +specifically as legitimate addresses. Normally you would simply
10322 +recognize any const as legitimate.
10324 +Usually PRINT_OPERAND_ADDRESS is not prepared to handle constant
10325 +sums that are not marked with const. It assumes that a naked
10326 +plus indicates indexing. If so, then you must reject such
10327 +naked constant sums as illegitimate addresses, so that none of them will
10328 +be given to PRINT_OPERAND_ADDRESS.
10330 +On some machines, whether a symbolic address is legitimate depends on
10331 +the section that the address refers to. On these machines, define the
10332 +macro ENCODE_SECTION_INFO to store the information into the
10333 +symbol_ref, and then check for it here. When you see a
10334 +const, you will have to look inside it to find the
10335 +symbol_ref in order to determine the section.
10337 +The best way to modify the name string is by adding text to the
10338 +beginning, with suitable punctuation to prevent any ambiguity. Allocate
10339 +the new name in saveable_obstack. You will have to modify
10340 +ASM_OUTPUT_LABELREF to remove and decode the added text and
10341 +output the name accordingly, and define STRIP_NAME_ENCODING to
10342 +access the original name string.
10344 +You can check the information stored here into the symbol_ref in
10345 +the definitions of the macros GO_IF_LEGITIMATE_ADDRESS and
10346 +PRINT_OPERAND_ADDRESS.
10348 +#ifdef REG_OK_STRICT
10349 +# define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
10352 + if (avr32_legitimate_address(MODE, X, 1)) \
10357 +# define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
10360 + if (avr32_legitimate_address(MODE, X, 0)) \
10369 +A C compound statement that attempts to replace X with a valid
10370 +memory address for an operand of mode MODE. win will be a
10371 +C statement label elsewhere in the code; the macro definition may use
10373 + GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN);
10375 +to avoid further processing if the address has become legitimate.
10377 +X will always be the result of a call to break_out_memory_refs,
10378 +and OLDX will be the operand that was given to that function to produce
10381 +The code generated by this macro should not alter the substructure of
10382 +X. If it transforms X into a more legitimate form, it
10383 +should assign X (which will always be a C variable) a new value.
10385 +It is not necessary for this macro to come up with a legitimate
10386 +address. The compiler has standard ways of doing so in all cases. In
10387 +fact, it is safe for this macro to do nothing. But often a
10388 +machine-dependent strategy can generate better code.
10390 +#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
10393 + if (GET_CODE(X) == PLUS \
10394 + && GET_CODE(XEXP(X, 0)) == REG \
10395 + && GET_CODE(XEXP(X, 1)) == CONST_INT \
10396 + && !CONST_OK_FOR_CONSTRAINT_P(INTVAL(XEXP(X, 1)), \
10399 + rtx index = force_reg(SImode, XEXP(X, 1)); \
10400 + X = gen_rtx_PLUS( SImode, XEXP(X, 0), index); \
10402 + GO_IF_LEGITIMATE_ADDRESS(MODE, X, WIN); \
10408 +A C statement or compound statement with a conditional
10409 +goto LABEL; executed if memory address X (an RTX) can have
10410 +different meanings depending on the machine mode of the memory
10411 +reference it is used for or if the address is valid for some modes
10414 +Autoincrement and autodecrement addresses typically have mode-dependent
10415 +effects because the amount of the increment or decrement is the size
10416 +of the operand being addressed. Some machines have other mode-dependent
10417 +addresses. Many RISC machines have no mode-dependent addresses.
10419 +You may assume that ADDR is a valid address for the machine.
10421 +#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \
10424 + if (GET_CODE (ADDR) == POST_INC \
10425 + || GET_CODE (ADDR) == PRE_DEC) \
10431 +A C expression that is nonzero if X is a legitimate constant for
10432 +an immediate operand on the target machine. You can assume that
10433 +X satisfies CONSTANT_P, so you need not check this. In fact,
10434 +'1' is a suitable definition for this macro on machines where
10435 +anything CONSTANT_P is valid.
10437 +#define LEGITIMATE_CONSTANT_P(X) avr32_legitimate_constant_p(X)
10440 +/******************************************************************************
10441 + * Condition Code Status
10442 + *****************************************************************************/
10445 +C code for a data type which is used for declaring the mdep
10446 +component of cc_status. It defaults to int.
10448 +This macro is not used on machines that do not use cc0.
10455 + int cond_exec_cmp_clobbered;
10456 +} avr32_status_reg;
10459 +#define CC_STATUS_MDEP avr32_status_reg
10462 +A C expression to initialize the mdep field to "empty".
10463 +The default definition does nothing, since most machines don't use
10464 +the field anyway. If you want to use the field, you should probably
10465 +define this macro to initialize it.
10467 +This macro is not used on machines that do not use cc0.
10470 +#define CC_STATUS_MDEP_INIT \
10471 + (cc_status.mdep.flags = CC_NONE , cc_status.mdep.cond_exec_cmp_clobbered = 0, cc_status.mdep.value = 0)
10474 +A C compound statement to set the components of cc_status
10475 +appropriately for an insn INSN whose body is EXP. It is
10476 +this macro's responsibility to recognize insns that set the condition
10477 +code as a byproduct of other activity as well as those that explicitly
10480 +This macro is not used on machines that do not use cc0.
10482 +If there are insns that do not set the condition code but do alter
10483 +other machine registers, this macro must check to see whether they
10484 +invalidate the expressions that the condition code is recorded as
10485 +reflecting. For example, on the 68000, insns that store in address
10486 +registers do not set the condition code, which means that usually
10487 +NOTICE_UPDATE_CC can leave cc_status unaltered for such
10488 +insns. But suppose that the previous insn set the condition code
10489 +based on location 'a4@@(102)' and the current insn stores a new
10490 +value in 'a4'. Although the condition code is not changed by
10491 +this, it will no longer be true that it reflects the contents of
10492 +'a4@@(102)'. Therefore, NOTICE_UPDATE_CC must alter
10493 +cc_status in this case to say that nothing is known about the
10494 +condition code value.
10496 +The definition of NOTICE_UPDATE_CC must be prepared to deal
10497 +with the results of peephole optimization: insns whose patterns are
10498 +parallel RTXs containing various reg, mem or
10499 +constants which are just the operands. The RTL structure of these
10500 +insns is not sufficient to indicate what the insns actually do. What
10501 +NOTICE_UPDATE_CC should do when it sees one is just to run
10504 +A possible definition of NOTICE_UPDATE_CC is to call a function
10505 +that looks at an attribute (see Insn Attributes) named, for example,
10506 +'cc'. This avoids having detailed information about patterns in
10507 +two places, the 'md' file and in NOTICE_UPDATE_CC.
10510 +#define NOTICE_UPDATE_CC(EXP, INSN) avr32_notice_update_cc(EXP, INSN)
10515 +/******************************************************************************
10516 + * Describing Relative Costs of Operations
10517 + *****************************************************************************/
10522 +A C expression for the cost of moving data of mode MODE from a
10523 +register in class FROM to one in class TO. The classes are
10524 +expressed using the enumeration values such as GENERAL_REGS. A
10525 +value of 2 is the default; other values are interpreted relative to
10528 +It is not required that the cost always equal 2 when FROM is the
10529 +same as TO; on some machines it is expensive to move between
10530 +registers if they are not general registers.
10532 +If reload sees an insn consisting of a single set between two
10533 +hard registers, and if REGISTER_MOVE_COST applied to their
10534 +classes returns a value of 2, reload does not check to ensure that the
10535 +constraints of the insn are met. Setting a cost of other than 2 will
10536 +allow reload to verify that the constraints are met. You should do this
10537 +if the movm pattern's constraints do not allow such copying.
10539 +#define REGISTER_MOVE_COST(MODE, FROM, TO) \
10540 + ((GET_MODE_SIZE(MODE) <= 4) ? 2: \
10541 + (GET_MODE_SIZE(MODE) <= 8) ? 3: \
10545 +A C expression for the cost of moving data of mode MODE between a
10546 +register of class CLASS and memory; IN is zero if the value
10547 +is to be written to memory, nonzero if it is to be read in. This cost
10548 +is relative to those in REGISTER_MOVE_COST. If moving between
10549 +registers and memory is more expensive than between two registers, you
10550 +should define this macro to express the relative cost.
10552 +If you do not define this macro, GCC uses a default cost of 4 plus
10553 +the cost of copying via a secondary reload register, if one is
10554 +needed. If your machine requires a secondary reload register to copy
10555 +between memory and a register of CLASS but the reload mechanism is
10556 +more complex than copying via an intermediate, define this macro to
10557 +reflect the actual cost of the move.
10559 +GCC defines the function memory_move_secondary_cost if
10560 +secondary reloads are needed. It computes the costs due to copying via
10561 +a secondary register. If your machine copies from memory using a
10562 +secondary register in the conventional way but the default base value of
10563 +4 is not correct for your machine, define this macro to add some other
10564 +value to the result of that function. The arguments to that function
10565 +are the same as to this macro.
10568 + Memory moves are costly
10570 +#define MEMORY_MOVE_COST(MODE, CLASS, IN) \
10571 + (((IN) ? ((GET_MODE_SIZE(MODE) < 4) ? 4 : \
10572 + (GET_MODE_SIZE(MODE) > 8) ? 6 : \
10574 + : ((GET_MODE_SIZE(MODE) > 8) ? 6 : 3)))
10577 +A C expression for the cost of a branch instruction. A value of 1 is
10578 +the default; other values are interpreted relative to that.
10580 + /* Try to use conditionals as much as possible */
10581 +#define BRANCH_COST (TARGET_BRANCH_PRED ? 3 : 4)
10583 +/*A C expression for the maximum number of instructions to execute via conditional
10584 + execution instructions instead of a branch. A value of BRANCH_COST+1 is the default
10585 + if the machine does not use cc0, and 1 if it does use cc0.*/
10586 +#define MAX_CONDITIONAL_EXECUTE 4
10589 +Define this macro as a C expression which is nonzero if accessing less
10590 +than a word of memory (i.e.: a char or a short) is no
10591 +faster than accessing a word of memory, i.e., if such access
10592 +require more than one instruction or if there is no difference in cost
10593 +between byte and (aligned) word loads.
10595 +When this macro is not defined, the compiler will access a field by
10596 +finding the smallest containing object; when it is defined, a fullword
10597 +load will be used if alignment permits. Unless bytes accesses are
10598 +faster than word accesses, using word accesses is preferable since it
10599 +may eliminate subsequent memory access if subsequent accesses occur to
10600 +other fields in the same word of the structure, but to different bytes.
10602 +#define SLOW_BYTE_ACCESS 1
10606 +Define this macro if it is as good or better to call a constant
10607 +function address than to call an address kept in a register.
10609 +#define NO_FUNCTION_CSE
10612 +/******************************************************************************
10613 + * Adjusting the Instruction Scheduler
10614 + *****************************************************************************/
10616 +/*****************************************************************************
10617 + * Dividing the Output into Sections (Texts, Data, ...) *
10618 + *****************************************************************************/
10621 +A C expression whose value is a string, including spacing, containing the
10622 +assembler operation that should precede instructions and read-only data.
10623 +Normally "\t.text" is right.
10625 +#define TEXT_SECTION_ASM_OP "\t.text"
10627 +A C statement that switches to the default section containing instructions.
10628 +Normally this is not needed, as simply defining TEXT_SECTION_ASM_OP
10629 +is enough. The MIPS port uses this to sort all functions after all data
10632 +/* #define TEXT_SECTION */
10635 +A C expression whose value is a string, including spacing, containing the
10636 +assembler operation to identify the following data as writable initialized
10637 +data. Normally "\t.data" is right.
10639 +#define DATA_SECTION_ASM_OP "\t.data"
10642 +If defined, a C expression whose value is a string, including spacing,
10643 +containing the assembler operation to identify the following data as
10644 +shared data. If not defined, DATA_SECTION_ASM_OP will be used.
10648 +A C expression whose value is a string, including spacing, containing
10649 +the assembler operation to identify the following data as read-only
10652 +#undef READONLY_DATA_SECTION_ASM_OP
10653 +#define READONLY_DATA_SECTION_ASM_OP \
10654 + ((TARGET_USE_RODATA_SECTION) ? \
10655 + "\t.section\t.rodata" : \
10656 + TEXT_SECTION_ASM_OP )
10660 +If defined, a C expression whose value is a string, including spacing,
10661 +containing the assembler operation to identify the following data as
10662 +uninitialized global data. If not defined, and neither
10663 +ASM_OUTPUT_BSS nor ASM_OUTPUT_ALIGNED_BSS are defined,
10664 +uninitialized global data will be output in the data section if
10665 +-fno-common is passed, otherwise ASM_OUTPUT_COMMON will be
10668 +#define BSS_SECTION_ASM_OP "\t.section\t.bss"
10671 +If defined, a C expression whose value is a string, including spacing,
10672 +containing the assembler operation to identify the following data as
10673 +uninitialized global shared data. If not defined, and
10674 +BSS_SECTION_ASM_OP is, the latter will be used.
10676 +/*#define SHARED_BSS_SECTION_ASM_OP "\trseg\tshared_bbs_section:data:noroot(0)\n"*/
10678 +If defined, a C expression whose value is a string, including spacing,
10679 +containing the assembler operation to identify the following data as
10680 +initialization code. If not defined, GCC will assume such a section does
10683 +#undef INIT_SECTION_ASM_OP
10684 +#define INIT_SECTION_ASM_OP "\t.section\t.init"
10687 +If defined, a C expression whose value is a string, including spacing,
10688 +containing the assembler operation to identify the following data as
10689 +finalization code. If not defined, GCC will assume such a section does
10692 +#undef FINI_SECTION_ASM_OP
10693 +#define FINI_SECTION_ASM_OP "\t.section\t.fini"
10696 +If defined, an ASM statement that switches to a different section
10697 +via SECTION_OP, calls FUNCTION, and switches back to
10698 +the text section. This is used in crtstuff.c if
10699 +INIT_SECTION_ASM_OP or FINI_SECTION_ASM_OP to calls
10700 +to initialization and finalization functions from the init and fini
10701 +sections. By default, this macro uses a simple function call. Some
10702 +ports need hand-crafted assembly code to avoid dependencies on
10703 +registers initialized in the function prologue or to ensure that
10704 +constant pools don't end up too far way in the text section.
10706 +#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
10707 + asm ( SECTION_OP "\n" \
10708 + "mcall r6[" USER_LABEL_PREFIX #FUNC "@got]\n" \
10709 + TEXT_SECTION_ASM_OP);
10713 +Define this macro to be an expression with a nonzero value if jump
10714 +tables (for tablejump insns) should be output in the text
10715 +section, along with the assembler instructions. Otherwise, the
10716 +readonly data section is used.
10718 +This macro is irrelevant if there is no separate readonly data section.
10720 +/* Put jump tables in text section if we have caches. Otherwise assume that
10721 + loading data from code memory is slow. */
10722 +#define JUMP_TABLES_IN_TEXT_SECTION \
10723 + (TARGET_CACHES ? 1 : 0)
10726 +/******************************************************************************
10727 + * Position Independent Code (PIC)
10728 + *****************************************************************************/
10730 +#ifndef AVR32_ALWAYS_PIC
10731 +#define AVR32_ALWAYS_PIC 0
10734 +/* GOT is set to r6 */
10735 +#define PIC_OFFSET_TABLE_REGNUM INTERNAL_REGNUM(6)
10738 +A C expression that is nonzero if X is a legitimate immediate
10739 +operand on the target machine when generating position independent code.
10740 +You can assume that X satisfies CONSTANT_P, so you need not
10741 +check this. You can also assume flag_pic is true, so you need not
10742 +check it either. You need not define this macro if all constants
10743 +(including SYMBOL_REF) can be immediate operands when generating
10744 +position independent code.
10746 +/* We can't directly access anything that contains a symbol,
10747 + nor can we indirect via the constant pool. */
10748 +#define LEGITIMATE_PIC_OPERAND_P(X) avr32_legitimate_pic_operand_p(X)
10751 +/* We need to know when we are making a constant pool; this determines
10752 + whether data needs to be in the GOT or can be referenced via a GOT
10754 +extern int making_const_table;
10756 +/******************************************************************************
10757 + * Defining the Output Assembler Language
10758 + *****************************************************************************/
10762 +A C string constant describing how to begin a comment in the target
10763 +assembler language. The compiler assumes that the comment will end at
10764 +the end of the line.
10766 +#define ASM_COMMENT_START "# "
10769 +A C string constant for text to be output before each asm
10770 +statement or group of consecutive ones. Normally this is
10771 +"#APP", which is a comment that has no effect on most
10772 +assemblers but tells the GNU assembler that it must check the lines
10773 +that follow for all valid assembler constructs.
10776 +#define ASM_APP_ON "#APP\n"
10779 +A C string constant for text to be output after each asm
10780 +statement or group of consecutive ones. Normally this is
10781 +"#NO_APP", which tells the GNU assembler to resume making the
10782 +time-saving assumptions that are valid for ordinary compiler output.
10784 +#undef ASM_APP_OFF
10785 +#define ASM_APP_OFF "#NO_APP\n"
10789 +#define FILE_ASM_OP "\t.file\n"
10790 +#define IDENT_ASM_OP "\t.ident\t"
10791 +#define SET_ASM_OP "\t.set\t"
10795 + * Output assembly directives to switch to section name. The section
10796 + * should have attributes as specified by flags, which is a bit mask
10797 + * of the SECTION_* flags defined in 'output.h'. If align is nonzero,
10798 + * it contains an alignment in bytes to be used for the section,
10799 + * otherwise some target default should be used. Only targets that
10800 + * must specify an alignment within the section directive need pay
10801 + * attention to align -- we will still use ASM_OUTPUT_ALIGN.
10803 + * NOTE: This one must not be moved to avr32.c
10805 +#undef TARGET_ASM_NAMED_SECTION
10806 +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
10810 +You may define this macro as a C expression. You should define the
10811 +expression to have a nonzero value if GCC should output the constant
10812 +pool for a function before the code for the function, or a zero value if
10813 +GCC should output the constant pool after the function. If you do
10814 +not define this macro, the usual case, GCC will output the constant
10815 +pool before the function.
10817 +#define CONSTANT_POOL_BEFORE_FUNCTION 0
10821 +Define this macro as a C expression which is nonzero if the constant
10822 +EXP, of type tree, should be output after the code for a
10823 +function. The compiler will normally output all constants before the
10824 +function; you need not define this macro if this is OK.
10826 +#define CONSTANT_AFTER_FUNCTION_P(EXP) 1
10830 +Define this macro as a C expression which is nonzero if C is
10831 +as a logical line separator by the assembler. STR points to the
10832 +position in the string where C was found; this can be used if a
10833 +line separator uses multiple characters.
10835 +If you do not define this macro, the default is that only
10836 +the character ';' is treated as a logical line separator.
10838 +#define IS_ASM_LOGICAL_LINE_SEPARATOR(C,STR) (((C) == '\n') || ((C) == ';'))
10841 +/** Output of Uninitialized Variables **/
10844 +A C statement (sans semicolon) to output to the stdio stream
10845 +STREAM the assembler definition of a common-label named
10846 +NAME whose size is SIZE bytes. The variable ROUNDED
10847 +is the size rounded up to whatever alignment the caller wants.
10849 +Use the expression assemble_name(STREAM, NAME) to
10850 +output the name itself; before and after that, output the additional
10851 +assembler syntax for defining the name, and a newline.
10853 +This macro controls how the assembler definitions of uninitialized
10854 +common global variables are output.
10857 +#define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \
10858 + avr32_asm_output_common(STREAM, NAME, SIZE, ROUNDED)
10861 +#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
10864 + fputs ("\t.comm ", (FILE)); \
10865 + assemble_name ((FILE), (NAME)); \
10866 + fprintf ((FILE), ",%d\n", (SIZE)); \
10871 + * Like ASM_OUTPUT_BSS except takes the required alignment as a
10872 + * separate, explicit argument. If you define this macro, it is used
10873 + * in place of ASM_OUTPUT_BSS, and gives you more flexibility in
10874 + * handling the required alignment of the variable. The alignment is
10875 + * specified as the number of bits.
10877 + * Try to use function asm_output_aligned_bss defined in file varasm.c
10878 + * when defining this macro.
10880 +#define ASM_OUTPUT_ALIGNED_BSS(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
10881 + asm_output_aligned_bss (STREAM, DECL, NAME, SIZE, ALIGNMENT)
10884 +A C statement (sans semicolon) to output to the stdio stream
10885 +STREAM the assembler definition of a local-common-label named
10886 +NAME whose size is SIZE bytes. The variable ROUNDED
10887 +is the size rounded up to whatever alignment the caller wants.
10889 +Use the expression assemble_name(STREAM, NAME) to
10890 +output the name itself; before and after that, output the additional
10891 +assembler syntax for defining the name, and a newline.
10893 +This macro controls how the assembler definitions of uninitialized
10894 +static variables are output.
10896 +#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
10899 + fputs ("\t.lcomm ", (FILE)); \
10900 + assemble_name ((FILE), (NAME)); \
10901 + fprintf ((FILE), ",%d, %d\n", (SIZE), 2); \
10907 +A C statement (sans semicolon) to output to the stdio stream
10908 +STREAM the assembler definition of a label named NAME.
10909 +Use the expression assemble_name(STREAM, NAME) to
10910 +output the name itself; before and after that, output the additional
10911 +assembler syntax for defining the name, and a newline.
10913 +#define ASM_OUTPUT_LABEL(STREAM, NAME) avr32_asm_output_label(STREAM, NAME)
10915 +/* A C string containing the appropriate assembler directive to
10916 + * specify the size of a symbol, without any arguments. On systems
10917 + * that use ELF, the default (in 'config/elfos.h') is '"\t.size\t"';
10918 + * on other systems, the default is not to define this macro.
10920 + * Define this macro only if it is correct to use the default
10921 + * definitions of ASM_ OUTPUT_SIZE_DIRECTIVE and
10922 + * ASM_OUTPUT_MEASURED_SIZE for your system. If you need your own
10923 + * custom definitions of those macros, or if you do not need explicit
10924 + * symbol sizes at all, do not define this macro.
10926 +#define SIZE_ASM_OP "\t.size\t"
10930 +A C statement (sans semicolon) to output to the stdio stream
10931 +STREAM some commands that will make the label NAME global;
10932 +that is, available for reference from other files. Use the expression
10933 +assemble_name(STREAM, NAME) to output the name
10934 +itself; before and after that, output the additional assembler syntax
10935 +for making that name global, and a newline.
10937 +#define GLOBAL_ASM_OP "\t.global\t"
10942 +A C expression which evaluates to true if the target supports weak symbols.
10944 +If you don't define this macro, defaults.h provides a default
10945 +definition. If either ASM_WEAKEN_LABEL or ASM_WEAKEN_DECL
10946 +is defined, the default definition is '1'; otherwise, it is
10947 +'0'. Define this macro if you want to control weak symbol support
10948 +with a compiler flag such as -melf.
10950 +#define SUPPORTS_WEAK 1
10953 +A C statement (sans semicolon) to output to the stdio stream
10954 +STREAM a reference in assembler syntax to a label named
10955 +NAME. This should add '_' to the front of the name, if that
10956 +is customary on your operating system, as it is in most Berkeley Unix
10957 +systems. This macro is used in assemble_name.
10959 +#define ASM_OUTPUT_LABELREF(STREAM, NAME) \
10960 + avr32_asm_output_labelref(STREAM, NAME)
10965 +A C expression to assign to OUTVAR (which is a variable of type
10966 +char *) a newly allocated string made from the string
10967 +NAME and the number NUMBER, with some suitable punctuation
10968 +added. Use alloca to get space for the string.
10970 +The string will be used as an argument to ASM_OUTPUT_LABELREF to
10971 +produce an assembler label for an internal static variable whose name is
10972 +NAME. Therefore, the string must be such as to result in valid
10973 +assembler code. The argument NUMBER is different each time this
10974 +macro is executed; it prevents conflicts between similarly-named
10975 +internal static variables in different scopes.
10977 +Ideally this string should not be a valid C identifier, to prevent any
10978 +conflict with the user's own symbols. Most assemblers allow periods
10979 +or percent signs in assembler symbols; putting at least one of these
10980 +between the name and the number will suffice.
10982 +#define ASM_FORMAT_PRIVATE_NAME(OUTVAR, NAME, NUMBER) \
10985 + (OUTVAR) = (char *) alloca (strlen ((NAME)) + 10); \
10986 + sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)); \
10991 +/** Macros Controlling Initialization Routines **/
10995 +If defined, main will not call __main as described above.
10996 +This macro should be defined for systems that control start-up code
10997 +on a symbol-by-symbol basis, such as OSF/1, and should not
10998 +be defined explicitly for systems that support INIT_SECTION_ASM_OP.
11001 + __main is not defined when debugging.
11003 +#define HAS_INIT_SECTION
11006 +/** Output of Assembler Instructions **/
11009 +A C initializer containing the assembler's names for the machine
11010 +registers, each one as a C string constant. This is what translates
11011 +register numbers in the compiler into assembler language.
11014 +#define REGISTER_NAMES \
11027 +A C compound statement to output to stdio stream STREAM the
11028 +assembler syntax for an instruction operand X. X is an
11031 +CODE is a value that can be used to specify one of several ways
11032 +of printing the operand. It is used when identical operands must be
11033 +printed differently depending on the context. CODE comes from
11034 +the '%' specification that was used to request printing of the
11035 +operand. If the specification was just '%digit' then
11036 +CODE is 0; if the specification was '%ltr digit'
11037 +then CODE is the ASCII code for ltr.
11039 +If X is a register, this macro should print the register's name.
11040 +The names can be found in an array reg_names whose type is
11041 +char *[]. reg_names is initialized from REGISTER_NAMES.
11043 +When the machine description has a specification '%punct'
11044 +(a '%' followed by a punctuation character), this macro is called
11045 +with a null pointer for X and the punctuation character for
11048 +#define PRINT_OPERAND(STREAM, X, CODE) avr32_print_operand(STREAM, X, CODE)
11050 +/* A C statement to be executed just prior to the output of
11051 + assembler code for INSN, to modify the extracted operands so
11052 + they will be output differently.
11054 + Here the argument OPVEC is the vector containing the operands
11055 + extracted from INSN, and NOPERANDS is the number of elements of
11056 + the vector which contain meaningful data for this insn.
11057 + The contents of this vector are what will be used to convert the insn
11058 + template into assembler code, so you can change the assembler output
11059 + by changing the contents of the vector. */
11060 +#define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
11061 + avr32_final_prescan_insn ((INSN), (OPVEC), (NOPERANDS))
11064 +A C expression which evaluates to true if CODE is a valid
11065 +punctuation character for use in the PRINT_OPERAND macro. If
11066 +PRINT_OPERAND_PUNCT_VALID_P is not defined, it means that no
11067 +punctuation characters (except for the standard one, '%') are used
11070 +#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
11071 + (((CODE) == '?') \
11072 + || ((CODE) == '!'))
11075 +A C compound statement to output to stdio stream STREAM the
11076 +assembler syntax for an instruction operand that is a memory reference
11077 +whose address is X. X is an RTL expression.
11079 +On some machines, the syntax for a symbolic address depends on the
11080 +section that the address refers to. On these machines, define the macro
11081 +ENCODE_SECTION_INFO to store the information into the
11082 +symbol_ref, and then check for it here. (see Assembler Format.)
11084 +#define PRINT_OPERAND_ADDRESS(STREAM, X) avr32_print_operand_address(STREAM, X)
11087 +/** Output of Dispatch Tables **/
11090 + * A C statement to output to the stdio stream stream an assembler
11091 + * pseudo-instruction to generate a difference between two
11092 + * labels. value and rel are the numbers of two internal labels. The
11093 + * definitions of these labels are output using
11094 + * (*targetm.asm_out.internal_label), and they must be printed in the
11095 + * same way here. For example,
11097 + * fprintf (stream, "\t.word L%d-L%d\n",
11100 + * You must provide this macro on machines where the addresses in a
11101 + * dispatch table are relative to the table's own address. If defined,
11102 + * GCC will also use this macro on all machines when producing
11103 + * PIC. body is the body of the ADDR_DIFF_VEC; it is provided so that
11104 + * the mode and flags can be read.
11106 +#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL) \
11107 + fprintf(STREAM, "\tbral\t%sL%d\n", LOCAL_LABEL_PREFIX, VALUE)
11110 +This macro should be provided on machines where the addresses
11111 +in a dispatch table are absolute.
11113 +The definition should be a C statement to output to the stdio stream
11114 +STREAM an assembler pseudo-instruction to generate a reference to
11115 +a label. VALUE is the number of an internal label whose
11116 +definition is output using ASM_OUTPUT_INTERNAL_LABEL.
11119 +fprintf(STREAM, "\t.word L%d\n", VALUE)
11122 +#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \
11123 + fprintf(STREAM, "\t.long %sL%d\n", LOCAL_LABEL_PREFIX, VALUE)
11125 +/** Assembler Commands for Exception Regions */
11127 +/* ToDo: All of this subsection */
11129 +/** Assembler Commands for Alignment */
11133 +A C statement to output to the stdio stream STREAM an assembler
11134 +command to advance the location counter to a multiple of 2 to the
11135 +POWER bytes. POWER will be a C expression of type int.
11137 +#define ASM_OUTPUT_ALIGN(STREAM, POWER) \
11140 + if ((POWER) != 0) \
11141 + fprintf(STREAM, "\t.align\t%d\n", POWER); \
11146 +Like ASM_OUTPUT_ALIGN, except that the \nop" instruction is used for padding, if
11149 +#define ASM_OUTPUT_ALIGN_WITH_NOP(STREAM, POWER) \
11150 + fprintf(STREAM, "\t.balignw\t%d, 0xd703\n", (1 << POWER))
11154 +/******************************************************************************
11155 + * Controlling Debugging Information Format
11156 + *****************************************************************************/
11158 +/* How to renumber registers for dbx and gdb. */
11159 +#define DBX_REGISTER_NUMBER(REGNO) ASM_REGNUM (REGNO)
11161 +/* The DWARF 2 CFA column which tracks the return address. */
11162 +#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM(LR_REGNUM)
11165 +Define this macro if GCC should produce dwarf version 2 format
11166 +debugging output in response to the -g option.
11168 +To support optional call frame debugging information, you must also
11169 +define INCOMING_RETURN_ADDR_RTX and either set
11170 +RTX_FRAME_RELATED_P on the prologue insns if you use RTL for the
11171 +prologue, or call dwarf2out_def_cfa and dwarf2out_reg_save
11172 +as appropriate from TARGET_ASM_FUNCTION_PROLOGUE if you don't.
11174 +#define DWARF2_DEBUGGING_INFO 1
11177 +#define DWARF2_ASM_LINE_DEBUG_INFO 1
11178 +#define DWARF2_FRAME_INFO 1
11181 +/******************************************************************************
11182 + * Miscellaneous Parameters
11183 + *****************************************************************************/
11188 +An alias for a machine mode name. This is the machine mode that
11189 +elements of a jump-table should have.
11191 +#define CASE_VECTOR_MODE SImode
11194 +Define this macro to be a C expression to indicate when jump-tables
11195 +should contain relative addresses. If jump-tables never contain
11196 +relative addresses, then you need not define this macro.
11198 +#define CASE_VECTOR_PC_RELATIVE 0
11200 +/* Increase the threshold for using table jumps on the UC arch. */
11201 +#define CASE_VALUES_THRESHOLD (TARGET_BRANCH_PRED ? 4 : 7)
11204 +The maximum number of bytes that a single instruction can move quickly
11205 +between memory and registers or between two memory locations.
11207 +#define MOVE_MAX (2*UNITS_PER_WORD)
11210 +/* A C expression that is nonzero if on this machine the number of bits actually used
11211 + for the count of a shift operation is equal to the number of bits needed to represent
11212 + the size of the object being shifted. When this macro is nonzero, the compiler will
11213 + assume that it is safe to omit a sign-extend, zero-extend, and certain bitwise 'and'
11214 + instructions that truncates the count of a shift operation. On machines that have
11215 + instructions that act on bit-fields at variable positions, which may include 'bit test'
11216 + 378 GNU Compiler Collection (GCC) Internals
11217 + instructions, a nonzero SHIFT_COUNT_TRUNCATED also enables deletion of truncations
11218 + of the values that serve as arguments to bit-field instructions.
11219 + If both types of instructions truncate the count (for shifts) and position (for bit-field
11220 + operations), or if no variable-position bit-field instructions exist, you should define
11222 + However, on some machines, such as the 80386 and the 680x0, truncation only applies
11223 + to shift operations and not the (real or pretended) bit-field operations. Define SHIFT_
11224 + COUNT_TRUNCATED to be zero on such machines. Instead, add patterns to the 'md' file
11225 + that include the implied truncation of the shift instructions.
11226 + You need not de
\fne this macro if it would always have the value of zero. */
11227 +#define SHIFT_COUNT_TRUNCATED 1
11230 +A C expression which is nonzero if on this machine it is safe to
11231 +convert an integer of INPREC bits to one of OUTPREC
11232 +bits (where OUTPREC is smaller than INPREC) by merely
11233 +operating on it as if it had only OUTPREC bits.
11235 +On many machines, this expression can be 1.
11237 +When TRULY_NOOP_TRUNCATION returns 1 for a pair of sizes for
11238 +modes for which MODES_TIEABLE_P is 0, suboptimal code can result.
11239 +If this is the case, making TRULY_NOOP_TRUNCATION return 0 in
11240 +such cases may improve things.
11242 +#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
11245 +An alias for the machine mode for pointers. On most machines, define
11246 +this to be the integer mode corresponding to the width of a hardware
11247 +pointer; SImode on 32-bit machine or DImode on 64-bit machines.
11248 +On some machines you must define this to be one of the partial integer
11249 +modes, such as PSImode.
11251 +The width of Pmode must be at least as large as the value of
11252 +POINTER_SIZE. If it is not equal, you must define the macro
11253 +POINTERS_EXTEND_UNSIGNED to specify how pointers are extended
11256 +#define Pmode SImode
11259 +An alias for the machine mode used for memory references to functions
11260 +being called, in call RTL expressions. On most machines this
11263 +#define FUNCTION_MODE SImode
11266 +#define REG_S_P(x) \
11267 + (REG_P (x) || (GET_CODE (x) == SUBREG && REG_P (XEXP (x, 0))))
11270 +/* If defined, modifies the length assigned to instruction INSN as a
11271 + function of the context in which it is used. LENGTH is an lvalue
11272 + that contains the initially computed length of the insn and should
11273 + be updated with the correct length of the insn. */
11274 +#define ADJUST_INSN_LENGTH(INSN, LENGTH) \
11275 + ((LENGTH) = avr32_adjust_insn_length ((INSN), (LENGTH)))
11278 +#define CLZ_DEFINED_VALUE_AT_ZERO(mode, value) \
11279 + (value = 32, (mode == SImode))
11281 +#define CTZ_DEFINED_VALUE_AT_ZERO(mode, value) \
11282 + (value = 32, (mode == SImode))
11284 +#define UNITS_PER_SIMD_WORD UNITS_PER_WORD
11286 +#define STORE_FLAG_VALUE 1
11289 +/* IF-conversion macros. */
11290 +#define IFCVT_MODIFY_INSN( CE_INFO, PATTERN, INSN ) \
11292 + (PATTERN) = avr32_ifcvt_modify_insn (CE_INFO, PATTERN, INSN, &num_true_changes); \
11295 +#define IFCVT_EXTRA_FIELDS \
11296 + int num_cond_clobber_insns; \
11297 + int num_extra_move_insns; \
11298 + rtx extra_move_insns[MAX_CONDITIONAL_EXECUTE]; \
11299 + rtx moved_insns[MAX_CONDITIONAL_EXECUTE];
11301 +#define IFCVT_INIT_EXTRA_FIELDS( CE_INFO ) \
11303 + (CE_INFO)->num_cond_clobber_insns = 0; \
11304 + (CE_INFO)->num_extra_move_insns = 0; \
11308 +#define IFCVT_MODIFY_CANCEL( CE_INFO ) avr32_ifcvt_modify_cancel (CE_INFO, &num_true_changes)
11310 +#define IFCVT_ALLOW_MODIFY_TEST_IN_INSN 1
11311 +#define IFCVT_COND_EXEC_BEFORE_RELOAD (TARGET_COND_EXEC_BEFORE_RELOAD)
11313 +enum avr32_builtins
11315 + AVR32_BUILTIN_MTSR,
11316 + AVR32_BUILTIN_MFSR,
11317 + AVR32_BUILTIN_MTDR,
11318 + AVR32_BUILTIN_MFDR,
11319 + AVR32_BUILTIN_CACHE,
11320 + AVR32_BUILTIN_SYNC,
11321 + AVR32_BUILTIN_SSRF,
11322 + AVR32_BUILTIN_CSRF,
11323 + AVR32_BUILTIN_TLBR,
11324 + AVR32_BUILTIN_TLBS,
11325 + AVR32_BUILTIN_TLBW,
11326 + AVR32_BUILTIN_BREAKPOINT,
11327 + AVR32_BUILTIN_XCHG,
11328 + AVR32_BUILTIN_LDXI,
11329 + AVR32_BUILTIN_BSWAP16,
11330 + AVR32_BUILTIN_BSWAP32,
11331 + AVR32_BUILTIN_COP,
11332 + AVR32_BUILTIN_MVCR_W,
11333 + AVR32_BUILTIN_MVRC_W,
11334 + AVR32_BUILTIN_MVCR_D,
11335 + AVR32_BUILTIN_MVRC_D,
11336 + AVR32_BUILTIN_MULSATHH_H,
11337 + AVR32_BUILTIN_MULSATHH_W,
11338 + AVR32_BUILTIN_MULSATRNDHH_H,
11339 + AVR32_BUILTIN_MULSATRNDWH_W,
11340 + AVR32_BUILTIN_MULSATWH_W,
11341 + AVR32_BUILTIN_MACSATHH_W,
11342 + AVR32_BUILTIN_SATADD_H,
11343 + AVR32_BUILTIN_SATSUB_H,
11344 + AVR32_BUILTIN_SATADD_W,
11345 + AVR32_BUILTIN_SATSUB_W,
11346 + AVR32_BUILTIN_MULWH_D,
11347 + AVR32_BUILTIN_MULNWH_D,
11348 + AVR32_BUILTIN_MACWH_D,
11349 + AVR32_BUILTIN_MACHH_D,
11350 + AVR32_BUILTIN_MUSFR,
11351 + AVR32_BUILTIN_MUSTR,
11352 + AVR32_BUILTIN_SATS,
11353 + AVR32_BUILTIN_SATU,
11354 + AVR32_BUILTIN_SATRNDS,
11355 + AVR32_BUILTIN_SATRNDU,
11356 + AVR32_BUILTIN_MEMS,
11357 + AVR32_BUILTIN_MEMC,
11358 + AVR32_BUILTIN_MEMT,
11359 + AVR32_BUILTIN_SLEEP,
11360 + AVR32_BUILTIN_DELAY_CYCLES
11364 +#define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) \
11365 + ((MODE == SFmode) || (MODE == DFmode))
11367 +#define RENAME_LIBRARY_SET ".set"
11369 +/* Make ABI_NAME an alias for __GCC_NAME. */
11370 +#define RENAME_LIBRARY(GCC_NAME, ABI_NAME) \
11371 + __asm__ (".globl\t__avr32_" #ABI_NAME "\n" \
11372 + ".set\t__avr32_" #ABI_NAME \
11373 + ", __" #GCC_NAME "\n");
11375 +/* Give libgcc functions avr32 ABI name. */
11377 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (muldi3, mul64)
11380 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (divdi3, sdiv64)
11383 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (udivdi3, udiv64)
11386 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (moddi3, smod64)
11389 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (umoddi3, umod64)
11392 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (ashldi3, lsl64)
11395 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (lshrdi3, lsr64)
11398 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (ashrdi3, asr64)
11402 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (fixsfdi, f32_to_s64)
11404 +#ifdef L_fixunssfdi
11405 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (fixunssfdi, f32_to_u64)
11407 +#ifdef L_floatdidf
11408 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (floatdidf, s64_to_f64)
11410 +#ifdef L_floatdisf
11411 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (floatdisf, s64_to_f32)
11416 +++ b/gcc/config/avr32/avr32.md
11418 +;; AVR32 machine description file.
11419 +;; Copyright 2003,2004,2005,2006,2007,2008,2009 Atmel Corporation.
11421 +;; This file is part of GCC.
11423 +;; This program is free software; you can redistribute it and/or modify
11424 +;; it under the terms of the GNU General Public License as published by
11425 +;; the Free Software Foundation; either version 2 of the License, or
11426 +;; (at your option) any later version.
11428 +;; This program is distributed in the hope that it will be useful,
11429 +;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11430 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11431 +;; GNU General Public License for more details.
11433 +;; You should have received a copy of the GNU General Public License
11434 +;; along with this program; if not, write to the Free Software
11435 +;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
11437 +;; -*- Mode: Scheme -*-
11439 +(define_attr "type" "alu,alu2,alu_sat,mulhh,mulwh,mulww_w,mulww_d,div,machh_w,macww_w,macww_d,branch,call,load,load_rm,store,load2,load4,store2,store4,fmul,fcmps,fcmpd,fcast,fmv,fmvcpu,fldd,fstd,flds,fsts,fstm"
11440 + (const_string "alu"))
11443 +(define_attr "cc" "none,set_vncz,set_ncz,set_cz,set_z,set_z_if_not_v2,bld,compare,cmp_cond_insn,clobber,call_set,fpcompare,from_fpcc"
11444 + (const_string "none"))
11447 +; NB! Keep this in sync with enum architecture_type in avr32.h
11448 +(define_attr "pipeline" "ap,ucr1,ucr2,ucr2nomul,ucr3,ucr3fp"
11449 + (const (symbol_ref "avr32_arch->arch_type")))
11451 +; Insn length in bytes
11452 +(define_attr "length" ""
11455 +; Signal if an insn is predicable and hence can be conditionally executed.
11456 +(define_attr "predicable" "no,yes" (const_string "no"))
11458 +;; Uses of UNSPEC in this file:
11460 + [(UNSPEC_PUSHM 0)
11462 + (UNSPEC_UDIVMODSI4_INTERNAL 2)
11463 + (UNSPEC_DIVMODSI4_INTERNAL 3)
11466 + (UNSPEC_MOVSICC 6)
11467 + (UNSPEC_ADDSICC 7)
11468 + (UNSPEC_COND_MI 8)
11469 + (UNSPEC_COND_PL 9)
11470 + (UNSPEC_PIC_SYM 10)
11471 + (UNSPEC_PIC_BASE 11)
11472 + (UNSPEC_STORE_MULTIPLE 12)
11473 + (UNSPEC_STMFP 13)
11474 + (UNSPEC_FRCPA 14)
11475 + (UNSPEC_REG_TO_CC 15)
11476 + (UNSPEC_FORCE_MINIPOOL 16)
11479 + (UNSPEC_SATRNDS 19)
11480 + (UNSPEC_SATRNDU 20)
11484 + [(VUNSPEC_EPILOGUE 0)
11485 + (VUNSPEC_CACHE 1)
11488 + (VUNSPEC_BLOCKAGE 4)
11493 + (VUNSPEC_BREAKPOINT 9)
11494 + (VUNSPEC_MTDR 10)
11495 + (VUNSPEC_MFDR 11)
11496 + (VUNSPEC_MVCR 12)
11497 + (VUNSPEC_MVRC 13)
11499 + (VUNSPEC_ALIGN 15)
11500 + (VUNSPEC_POOL_START 16)
11501 + (VUNSPEC_POOL_END 17)
11502 + (VUNSPEC_POOL_4 18)
11503 + (VUNSPEC_POOL_8 19)
11504 + (VUNSPEC_POOL_16 20)
11505 + (VUNSPEC_MUSFR 21)
11506 + (VUNSPEC_MUSTR 22)
11507 + (VUNSPEC_SYNC_CMPXCHG 23)
11508 + (VUNSPEC_SYNC_SET_LOCK_AND_LOAD 24)
11509 + (VUNSPEC_SYNC_STORE_IF_LOCK 25)
11510 + (VUNSPEC_EH_RETURN 26)
11512 + (VUNSPEC_CSRF 28)
11513 + (VUNSPEC_SSRF 29)
11514 + (VUNSPEC_SLEEP 30)
11515 + (VUNSPEC_DELAY_CYCLES 31)
11516 + (VUNSPEC_DELAY_CYCLES_1 32)
11517 + (VUNSPEC_DELAY_CYCLES_2 33)
11519 + (VUNSPEC_NOP3 35)
11526 + ;; Return Register = R12 = 15 - 12 = 3
11527 + (RETVAL_REGNUM 3)
11528 + ;; SP = R13 = 15 - 13 = 2
11530 + ;; LR = R14 = 15 - 14 = 1
11532 + ;; PC = R15 = 15 - 15 = 0
11534 + ;; FPSR = GENERAL_REGS + 1 = 17
11541 +;;******************************************************************************
11543 +;;******************************************************************************
11545 +;; Integer Modes for basic alu insns
11546 +(define_mode_iterator INTM [SI HI QI])
11547 +(define_mode_attr alu_cc_attr [(SI "set_vncz") (HI "clobber") (QI "clobber")])
11549 +;; Move word modes
11550 +(define_mode_iterator MOVM [SI V2HI V4QI])
11552 +;; For mov/addcc insns
11553 +(define_mode_iterator ADDCC [SI HI QI])
11554 +(define_mode_iterator MOVCC [SF SI HI QI])
11555 +(define_mode_iterator CMP [DI SI HI QI])
11556 +(define_mode_attr store_postfix [(SF ".w") (SI ".w") (HI ".h") (QI ".b")])
11557 +(define_mode_attr load_postfix [(SF ".w") (SI ".w") (HI ".sh") (QI ".ub")])
11558 +(define_mode_attr load_postfix_s [(SI ".w") (HI ".sh") (QI ".sb")])
11559 +(define_mode_attr load_postfix_u [(SI ".w") (HI ".uh") (QI ".ub")])
11560 +(define_mode_attr pred_mem_constraint [(SF "RKu11") (SI "RKu11") (HI "RKu10") (QI "RKu09")])
11561 +(define_mode_attr cmp_constraint [(DI "rKu20") (SI "rKs21") (HI "r") (QI "r")])
11562 +(define_mode_attr cmp_predicate [(DI "register_immediate_operand")
11563 + (SI "register_const_int_operand")
11564 + (HI "register_operand")
11565 + (QI "register_operand")])
11566 +(define_mode_attr cmp_length [(DI "6")
11571 +;; For all conditional insns
11572 +(define_code_iterator any_cond [eq ne gt ge lt le gtu geu ltu leu])
11573 +(define_code_attr cond [(eq "eq") (ne "ne") (gt "gt") (ge "ge") (lt "lt") (le "le")
11574 + (gtu "hi") (geu "hs") (ltu "lo") (leu "ls")])
11575 +(define_code_attr invcond [(eq "ne") (ne "eq") (gt "le") (ge "lt") (lt "ge") (le "gt")
11576 + (gtu "ls") (geu "lo") (ltu "hs") (leu "hi")])
11578 +;; For logical operations
11579 +(define_code_iterator logical [and ior xor])
11580 +(define_code_attr logical_insn [(and "and") (ior "or") (xor "eor")])
11582 +;; Predicable operations with three register operands
11583 +(define_code_iterator predicable_op3 [and ior xor plus minus])
11584 +(define_code_attr predicable_insn3 [(and "and") (ior "or") (xor "eor") (plus "add") (minus "sub")])
11585 +(define_code_attr predicable_commutative3 [(and "%") (ior "%") (xor "%") (plus "%") (minus "")])
11587 +;; Load the predicates
11588 +(include "predicates.md")
11591 +;;******************************************************************************
11592 +;; Automaton pipeline description for avr32
11593 +;;******************************************************************************
11595 +(define_automaton "avr32_ap")
11598 +(define_cpu_unit "is" "avr32_ap")
11599 +(define_cpu_unit "a1,m1,da" "avr32_ap")
11600 +(define_cpu_unit "a2,m2,d" "avr32_ap")
11602 +;;Alu instructions
11603 +(define_insn_reservation "alu_op" 1
11604 + (and (eq_attr "pipeline" "ap")
11605 + (eq_attr "type" "alu"))
11608 +(define_insn_reservation "alu2_op" 2
11609 + (and (eq_attr "pipeline" "ap")
11610 + (eq_attr "type" "alu2"))
11611 + "is,is+a1,a1+a2,a2")
11613 +(define_insn_reservation "alu_sat_op" 2
11614 + (and (eq_attr "pipeline" "ap")
11615 + (eq_attr "type" "alu_sat"))
11619 +;;Mul instructions
11620 +(define_insn_reservation "mulhh_op" 2
11621 + (and (eq_attr "pipeline" "ap")
11622 + (eq_attr "type" "mulhh,mulwh"))
11625 +(define_insn_reservation "mulww_w_op" 3
11626 + (and (eq_attr "pipeline" "ap")
11627 + (eq_attr "type" "mulww_w"))
11628 + "is,m1,m1+m2,m2")
11630 +(define_insn_reservation "mulww_d_op" 5
11631 + (and (eq_attr "pipeline" "ap")
11632 + (eq_attr "type" "mulww_d"))
11633 + "is,m1,m1+m2,m1+m2,m2,m2")
11635 +(define_insn_reservation "div_op" 33
11636 + (and (eq_attr "pipeline" "ap")
11637 + (eq_attr "type" "div"))
11638 + "is,m1,m1*31 + m2*31,m2")
11640 +(define_insn_reservation "machh_w_op" 3
11641 + (and (eq_attr "pipeline" "ap")
11642 + (eq_attr "type" "machh_w"))
11646 +(define_insn_reservation "macww_w_op" 4
11647 + (and (eq_attr "pipeline" "ap")
11648 + (eq_attr "type" "macww_w"))
11652 +(define_insn_reservation "macww_d_op" 6
11653 + (and (eq_attr "pipeline" "ap")
11654 + (eq_attr "type" "macww_d"))
11655 + "is*2,m1,m1+m2,m1+m2,m2")
11657 +;;Bypasses for Mac instructions, because of accumulator cache.
11658 +;;Set latency as low as possible in order to let the compiler let
11659 +;;mul -> mac and mac -> mac combinations which use the same
11660 +;;accumulator cache be placed close together to avoid any
11661 +;;instructions which can ruin the accumulator cache come inbetween.
11662 +(define_bypass 4 "machh_w_op" "alu_op,alu2_op,alu_sat_op,load_op" "avr32_mul_waw_bypass")
11663 +(define_bypass 5 "macww_w_op" "alu_op,alu2_op,alu_sat_op,load_op" "avr32_mul_waw_bypass")
11664 +(define_bypass 7 "macww_d_op" "alu_op,alu2_op,alu_sat_op,load_op" "avr32_mul_waw_bypass")
11666 +(define_bypass 3 "mulhh_op" "alu_op,alu2_op,alu_sat_op,load_op" "avr32_mul_waw_bypass")
11667 +(define_bypass 4 "mulww_w_op" "alu_op,alu2_op,alu_sat_op,load_op" "avr32_mul_waw_bypass")
11668 +(define_bypass 6 "mulww_d_op" "alu_op,alu2_op,alu_sat_op,load_op" "avr32_mul_waw_bypass")
11671 +;;Bypasses for all mul/mac instructions followed by an instruction
11672 +;;which reads the output AND writes the result to the same register.
11673 +;;This will generate an Write After Write hazard which gives an
11674 +;;extra cycle before the result is ready.
11675 +(define_bypass 0 "machh_w_op" "machh_w_op" "avr32_valid_macmac_bypass")
11676 +(define_bypass 0 "macww_w_op" "macww_w_op" "avr32_valid_macmac_bypass")
11677 +(define_bypass 0 "macww_d_op" "macww_d_op" "avr32_valid_macmac_bypass")
11679 +(define_bypass 0 "mulhh_op" "machh_w_op" "avr32_valid_mulmac_bypass")
11680 +(define_bypass 0 "mulww_w_op" "macww_w_op" "avr32_valid_mulmac_bypass")
11681 +(define_bypass 0 "mulww_d_op" "macww_d_op" "avr32_valid_mulmac_bypass")
11683 +;;Branch and call instructions
11684 +;;We assume that all branches and rcalls are predicted correctly :-)
11685 +;;while calls use a lot of cycles.
11686 +(define_insn_reservation "branch_op" 0
11687 + (and (eq_attr "pipeline" "ap")
11688 + (eq_attr "type" "branch"))
11691 +(define_insn_reservation "call_op" 10
11692 + (and (eq_attr "pipeline" "ap")
11693 + (eq_attr "type" "call"))
11697 +;;Load store instructions
11698 +(define_insn_reservation "load_op" 2
11699 + (and (eq_attr "pipeline" "ap")
11700 + (eq_attr "type" "load"))
11703 +(define_insn_reservation "load_rm_op" 3
11704 + (and (eq_attr "pipeline" "ap")
11705 + (eq_attr "type" "load_rm"))
11709 +(define_insn_reservation "store_op" 0
11710 + (and (eq_attr "pipeline" "ap")
11711 + (eq_attr "type" "store"))
11715 +(define_insn_reservation "load_double_op" 3
11716 + (and (eq_attr "pipeline" "ap")
11717 + (eq_attr "type" "load2"))
11720 +(define_insn_reservation "load_quad_op" 4
11721 + (and (eq_attr "pipeline" "ap")
11722 + (eq_attr "type" "load4"))
11723 + "is,da,da+d,da+d,d")
11725 +(define_insn_reservation "store_double_op" 0
11726 + (and (eq_attr "pipeline" "ap")
11727 + (eq_attr "type" "store2"))
11731 +(define_insn_reservation "store_quad_op" 0
11732 + (and (eq_attr "pipeline" "ap")
11733 + (eq_attr "type" "store4"))
11734 + "is,da,da+d,da+d,d")
11736 +;;For store the operand to write to memory is read in d and
11737 +;;the real latency between any instruction and a store is therefore
11738 +;;one less than for the instructions which reads the operands in the first
11739 +;;excecution stage
11740 +(define_bypass 2 "load_double_op" "store_double_op" "avr32_store_bypass")
11741 +(define_bypass 3 "load_quad_op" "store_quad_op" "avr32_store_bypass")
11742 +(define_bypass 1 "load_op" "store_op" "avr32_store_bypass")
11743 +(define_bypass 2 "load_rm_op" "store_op" "avr32_store_bypass")
11744 +(define_bypass 1 "alu_sat_op" "store_op" "avr32_store_bypass")
11745 +(define_bypass 1 "alu2_op" "store_op" "avr32_store_bypass")
11746 +(define_bypass 1 "mulhh_op" "store_op" "avr32_store_bypass")
11747 +(define_bypass 2 "mulww_w_op" "store_op" "avr32_store_bypass")
11748 +(define_bypass 4 "mulww_d_op" "store_op" "avr32_store_bypass" )
11749 +(define_bypass 2 "machh_w_op" "store_op" "avr32_store_bypass")
11750 +(define_bypass 3 "macww_w_op" "store_op" "avr32_store_bypass")
11751 +(define_bypass 5 "macww_d_op" "store_op" "avr32_store_bypass")
11754 +; Bypass for load double operation. If only the first loaded word is needed
11755 +; then the latency is 2
11756 +(define_bypass 2 "load_double_op"
11757 + "load_op,load_rm_op,alu_sat_op, alu2_op, alu_op, mulhh_op, mulww_w_op,
11758 + mulww_d_op, machh_w_op, macww_w_op, macww_d_op"
11759 + "avr32_valid_load_double_bypass")
11761 +; Bypass for load quad operation. If only the first or second loaded word is needed
11762 +; we set the latency to 2
11763 +(define_bypass 2 "load_quad_op"
11764 + "load_op,load_rm_op,alu_sat_op, alu2_op, alu_op, mulhh_op, mulww_w_op,
11765 + mulww_d_op, machh_w_op, macww_w_op, macww_d_op"
11766 + "avr32_valid_load_quad_bypass")
11769 +;;******************************************************************************
11770 +;; End of Automaton pipeline description for avr32
11771 +;;******************************************************************************
11774 + [(match_operator 0 "avr32_comparison_operator"
11775 + [(match_operand:CMP 1 "register_operand" "r")
11776 + (match_operand:CMP 2 "<CMP:cmp_predicate>" "<CMP:cmp_constraint>")])]
11777 + "TARGET_V2_INSNS"
11782 + [(match_operator 0 "avr32_comparison_operator"
11783 + [(and:SI (match_operand:SI 1 "register_operand" "r")
11784 + (match_operand:SI 2 "one_bit_set_operand" "i"))
11786 + "TARGET_V2_INSNS"
11790 +;;=============================================================================
11792 +;;-----------------------------------------------------------------------------
11795 +;;== char - 8 bits ============================================================
11796 +(define_expand "movqi"
11797 + [(set (match_operand:QI 0 "nonimmediate_operand" "")
11798 + (match_operand:QI 1 "general_operand" ""))]
11801 + if ( can_create_pseudo_p () ){
11802 + if (GET_CODE (operands[1]) == MEM && optimize){
11803 + rtx reg = gen_reg_rtx (SImode);
11805 + emit_insn (gen_zero_extendqisi2 (reg, operands[1]));
11806 + operands[1] = gen_lowpart (QImode, reg);
11809 + /* One of the ops has to be in a register. */
11810 + if (GET_CODE (operands[0]) == MEM)
11811 + operands[1] = force_reg (QImode, operands[1]);
11816 +(define_insn "*movqi_internal"
11817 + [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r")
11818 + (match_operand:QI 1 "general_operand" "rKs08,m,r,i"))]
11819 + "register_operand (operands[0], QImode)
11820 + || register_operand (operands[1], QImode)"
11826 + [(set_attr "length" "2,4,4,4")
11827 + (set_attr "type" "alu,load_rm,store,alu")])
11831 +;;== short - 16 bits ==========================================================
11832 +(define_expand "movhi"
11833 + [(set (match_operand:HI 0 "nonimmediate_operand" "")
11834 + (match_operand:HI 1 "general_operand" ""))]
11837 + if ( can_create_pseudo_p () ){
11838 + if (GET_CODE (operands[1]) == MEM && optimize){
11839 + rtx reg = gen_reg_rtx (SImode);
11841 + emit_insn (gen_extendhisi2 (reg, operands[1]));
11842 + operands[1] = gen_lowpart (HImode, reg);
11845 + /* One of the ops has to be in a register. */
11846 + if (GET_CODE (operands[0]) == MEM)
11847 + operands[1] = force_reg (HImode, operands[1]);
11853 +(define_insn "*movhi_internal"
11854 + [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r")
11855 + (match_operand:HI 1 "general_operand" "rKs08,m,r,i"))]
11856 + "register_operand (operands[0], HImode)
11857 + || register_operand (operands[1], HImode)"
11863 + [(set_attr "length" "2,4,4,4")
11864 + (set_attr "type" "alu,load_rm,store,alu")])
11867 +;;== int - 32 bits ============================================================
11869 +(define_expand "movmisalignsi"
11870 + [(set (match_operand:SI 0 "nonimmediate_operand" "")
11871 + (match_operand:SI 1 "nonimmediate_operand" ""))]
11872 + "TARGET_UNALIGNED_WORD"
11877 +(define_expand "mov<mode>"
11878 + [(set (match_operand:MOVM 0 "avr32_non_rmw_nonimmediate_operand" "")
11879 + (match_operand:MOVM 1 "avr32_non_rmw_general_operand" ""))]
11883 + /* One of the ops has to be in a register. */
11884 + if (GET_CODE (operands[0]) == MEM)
11885 + operands[1] = force_reg (<MODE>mode, operands[1]);
11887 + /* Check for out of range immediate constants as these may
11888 + occur during reloading, since it seems like reload does
11889 + not check if the immediate is legitimate. Don't know if
11890 + this is a bug? */
11891 + if ( reload_in_progress
11892 + && avr32_imm_in_const_pool
11893 + && GET_CODE(operands[1]) == CONST_INT
11894 + && !avr32_const_ok_for_constraint_p(INTVAL(operands[1]), 'K', "Ks21") ){
11895 + operands[1] = force_const_mem(SImode, operands[1]);
11897 + /* Check for RMW memory operands. They are not allowed for mov operations
11898 + only the atomic memc/s/t operations */
11899 + if ( !reload_in_progress
11900 + && avr32_rmw_memory_operand (operands[0], <MODE>mode) ){
11901 + operands[0] = copy_rtx (operands[0]);
11902 + XEXP(operands[0], 0) = force_reg (<MODE>mode, XEXP(operands[0], 0));
11905 + if ( !reload_in_progress
11906 + && avr32_rmw_memory_operand (operands[1], <MODE>mode) ){
11907 + operands[1] = copy_rtx (operands[1]);
11908 + XEXP(operands[1], 0) = force_reg (<MODE>mode, XEXP(operands[1], 0));
11910 + if ( (flag_pic || TARGET_HAS_ASM_ADDR_PSEUDOS)
11911 + && !avr32_legitimate_pic_operand_p(operands[1]) )
11912 + operands[1] = legitimize_pic_address (operands[1], <MODE>mode,
11913 + (can_create_pseudo_p () ? 0: operands[0]));
11914 + else if ( flag_pic && avr32_address_operand(operands[1], GET_MODE(operands[1])) )
11915 + /* If we have an address operand then this function uses the pic register. */
11916 + current_function_uses_pic_offset_table = 1;
11920 +(define_insn "mov<mode>_internal"
11921 + [(set (match_operand:MOVM 0 "avr32_non_rmw_nonimmediate_operand" "=r, r, r,r,r,Q,r")
11922 + (match_operand:MOVM 1 "avr32_non_rmw_general_operand" "rKs08,Ks21,J,n,Q,r,W"))]
11923 + "(register_operand (operands[0], <MODE>mode)
11924 + || register_operand (operands[1], <MODE>mode))
11925 + && !avr32_rmw_memory_operand (operands[0], <MODE>mode)
11926 + && !avr32_rmw_memory_operand (operands[1], <MODE>mode)"
11928 + switch (which_alternative) {
11930 + case 1: return "mov\t%0, %1";
11932 + if ( TARGET_V2_INSNS )
11933 + return "movh\t%0, hi(%1)";
11934 + /* Fallthrough */
11935 + case 3: return "mov\t%0, lo(%1)\;orh\t%0,hi(%1)";
11937 + if ( (REG_P(XEXP(operands[1], 0))
11938 + && REGNO(XEXP(operands[1], 0)) == SP_REGNUM)
11939 + || (GET_CODE(XEXP(operands[1], 0)) == PLUS
11940 + && REGNO(XEXP(XEXP(operands[1], 0), 0)) == SP_REGNUM
11941 + && GET_CODE(XEXP(XEXP(operands[1], 0), 1)) == CONST_INT
11942 + && INTVAL(XEXP(XEXP(operands[1], 0), 1)) % 4 == 0
11943 + && INTVAL(XEXP(XEXP(operands[1], 0), 1)) <= 0x1FC) )
11944 + return "lddsp\t%0, %1";
11945 + else if ( avr32_const_pool_ref_operand(operands[1], GET_MODE(operands[1])) )
11946 + return "lddpc\t%0, %1";
11948 + return "ld.w\t%0, %1";
11950 + if ( (REG_P(XEXP(operands[0], 0))
11951 + && REGNO(XEXP(operands[0], 0)) == SP_REGNUM)
11952 + || (GET_CODE(XEXP(operands[0], 0)) == PLUS
11953 + && REGNO(XEXP(XEXP(operands[0], 0), 0)) == SP_REGNUM
11954 + && GET_CODE(XEXP(XEXP(operands[0], 0), 1)) == CONST_INT
11955 + && INTVAL(XEXP(XEXP(operands[0], 0), 1)) % 4 == 0
11956 + && INTVAL(XEXP(XEXP(operands[0], 0), 1)) <= 0x1FC) )
11957 + return "stdsp\t%0, %1";
11959 + return "st.w\t%0, %1";
11961 + if ( TARGET_HAS_ASM_ADDR_PSEUDOS )
11962 + return "lda.w\t%0, %1";
11964 + return "ld.w\t%0, r6[%1@got]";
11970 + [(set_attr "length" "2,4,4,8,4,4,8")
11971 + (set_attr "type" "alu,alu,alu,alu2,load,store,load")
11972 + (set_attr "cc" "none,none,set_z_if_not_v2,set_z,none,none,clobber")])
11975 +(define_expand "reload_out_rmw_memory_operand"
11976 + [(set (match_operand:SI 2 "register_operand" "=r")
11977 + (match_operand:SI 0 "address_operand" ""))
11978 + (set (mem:SI (match_dup 2))
11979 + (match_operand:SI 1 "register_operand" ""))]
11982 + operands[0] = XEXP(operands[0], 0);
11986 +(define_expand "reload_in_rmw_memory_operand"
11987 + [(set (match_operand:SI 2 "register_operand" "=r")
11988 + (match_operand:SI 1 "address_operand" ""))
11989 + (set (match_operand:SI 0 "register_operand" "")
11990 + (mem:SI (match_dup 2)))]
11993 + operands[1] = XEXP(operands[1], 0);
11998 +;; These instructions are for loading constants which cannot be loaded
11999 +;; directly from the constant pool because the offset is too large
12000 +;; high and lo_sum are used even tough for our case it should be
12001 +;; low and high sum :-)
12002 +(define_insn "mov_symbol_lo"
12003 + [(set (match_operand:SI 0 "register_operand" "=r")
12004 + (high:SI (match_operand:SI 1 "immediate_operand" "i" )))]
12006 + "mov\t%0, lo(%1)"
12007 + [(set_attr "type" "alu")
12008 + (set_attr "length" "4")]
12011 +(define_insn "add_symbol_hi"
12012 + [(set (match_operand:SI 0 "register_operand" "=r")
12013 + (lo_sum:SI (match_dup 0)
12014 + (match_operand:SI 1 "immediate_operand" "i" )))]
12016 + "orh\t%0, hi(%1)"
12017 + [(set_attr "type" "alu")
12018 + (set_attr "length" "4")]
12023 +;; When generating pic, we need to load the symbol offset into a register.
12024 +;; So that the optimizer does not confuse this with a normal symbol load
12025 +;; we use an unspec. The offset will be loaded from a constant pool entry,
12026 +;; since that is the only type of relocation we can use.
12027 +(define_insn "pic_load_addr"
12028 + [(set (match_operand:SI 0 "register_operand" "=r")
12029 + (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PIC_SYM))]
12030 + "flag_pic && CONSTANT_POOL_ADDRESS_P(XEXP(operands[1], 0))"
12032 + [(set_attr "type" "load")
12033 + (set_attr "length" "4")]
12036 +(define_insn "pic_compute_got_from_pc"
12037 + [(set (match_operand:SI 0 "register_operand" "+r")
12038 + (unspec:SI [(minus:SI (pc)
12039 + (match_dup 0))] UNSPEC_PIC_BASE))
12040 + (use (label_ref (match_operand 1 "" "")))]
12043 + (*targetm.asm_out.internal_label) (asm_out_file, "L",
12044 + CODE_LABEL_NUMBER (operands[1]));
12045 + return \"rsub\t%0, pc\";
12047 + [(set_attr "cc" "clobber")
12048 + (set_attr "length" "2")]
12051 +;;== long long int - 64 bits ==================================================
12053 +(define_expand "movdi"
12054 + [(set (match_operand:DI 0 "nonimmediate_operand" "")
12055 + (match_operand:DI 1 "general_operand" ""))]
12059 + /* One of the ops has to be in a register. */
12060 + if (GET_CODE (operands[0]) != REG)
12061 + operands[1] = force_reg (DImode, operands[1]);
12066 +(define_insn_and_split "*movdi_internal"
12067 + [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r, r, r,r,r,m")
12068 + (match_operand:DI 1 "general_operand" "r, Ks08,Ks21,G,n,m,r"))]
12069 + "register_operand (operands[0], DImode)
12070 + || register_operand (operands[1], DImode)"
12072 + switch (which_alternative ){
12080 + if ( avr32_const_pool_ref_operand(operands[1], GET_MODE(operands[1])))
12081 + return "ld.d\t%0, pc[%1 - .]";
12083 + return "ld.d\t%0, %1";
12085 + return "st.d\t%0, %1";
12090 +;; Lets split all reg->reg or imm->reg transfers into two SImode transfers
12091 + "reload_completed &&
12092 + (REG_P (operands[0]) &&
12093 + (REG_P (operands[1])
12094 + || GET_CODE (operands[1]) == CONST_INT
12095 + || GET_CODE (operands[1]) == CONST_DOUBLE))"
12096 + [(set (match_dup 0) (match_dup 1))
12097 + (set (match_dup 2) (match_dup 3))]
12099 + operands[2] = gen_highpart (SImode, operands[0]);
12100 + operands[0] = gen_lowpart (SImode, operands[0]);
12101 + if ( REG_P(operands[1]) ){
12102 + operands[3] = gen_highpart(SImode, operands[1]);
12103 + operands[1] = gen_lowpart(SImode, operands[1]);
12104 + } else if ( GET_CODE(operands[1]) == CONST_DOUBLE
12105 + || GET_CODE(operands[1]) == CONST_INT ){
12106 + rtx split_const[2];
12107 + avr32_split_const_expr (DImode, SImode, operands[1], split_const);
12108 + operands[3] = split_const[1];
12109 + operands[1] = split_const[0];
12111 + internal_error("Illegal operand[1] for movdi split!");
12115 + [(set_attr "length" "*,*,*,*,*,4,4")
12116 + (set_attr "type" "*,*,*,*,*,load2,store2")
12117 + (set_attr "cc" "*,*,*,*,*,none,none")])
12120 +;;== 128 bits ==================================================
12121 +(define_expand "movti"
12122 + [(set (match_operand:TI 0 "nonimmediate_operand" "")
12123 + (match_operand:TI 1 "nonimmediate_operand" ""))]
12127 + /* One of the ops has to be in a register. */
12128 + if (GET_CODE (operands[0]) != REG)
12129 + operands[1] = force_reg (TImode, operands[1]);
12131 + /* We must fix any pre_dec for loads and post_inc stores */
12132 + if ( GET_CODE (operands[0]) == MEM
12133 + && GET_CODE (XEXP(operands[0],0)) == POST_INC ){
12134 + emit_move_insn(gen_rtx_MEM(TImode, XEXP(XEXP(operands[0],0),0)), operands[1]);
12135 + emit_insn(gen_addsi3(XEXP(XEXP(operands[0],0),0), XEXP(XEXP(operands[0],0),0), GEN_INT(GET_MODE_SIZE(TImode))));
12139 + if ( GET_CODE (operands[1]) == MEM
12140 + && GET_CODE (XEXP(operands[1],0)) == PRE_DEC ){
12141 + emit_insn(gen_addsi3(XEXP(XEXP(operands[1],0),0), XEXP(XEXP(operands[1],0),0), GEN_INT(-GET_MODE_SIZE(TImode))));
12142 + emit_move_insn(operands[0], gen_rtx_MEM(TImode, XEXP(XEXP(operands[1],0),0)));
12148 +(define_insn_and_split "*movti_internal"
12149 + [(set (match_operand:TI 0 "avr32_movti_dst_operand" "=r,&r, r, <RKu00,r,r")
12150 + (match_operand:TI 1 "avr32_movti_src_operand" " r,RKu00>,RKu00,r, n,T"))]
12151 + "(register_operand (operands[0], TImode)
12152 + || register_operand (operands[1], TImode))"
12154 + switch (which_alternative ){
12160 + return "ldm\t%p1, %0";
12162 + return "stm\t%p0, %1";
12164 + return "ld.d\t%U0, pc[%1 - .]\;ld.d\t%B0, pc[%1 - . + 8]";
12168 + "reload_completed &&
12169 + (REG_P (operands[0]) &&
12170 + (REG_P (operands[1])
12171 + /* If this is a load from the constant pool we split it into
12172 + two double loads. */
12173 + || (GET_CODE (operands[1]) == MEM
12174 + && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
12175 + && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0)))
12176 + /* If this is a load where the pointer register is a part
12177 + of the register list, we must split it into two double
12178 + loads in order for it to be exception safe. */
12179 + || (GET_CODE (operands[1]) == MEM
12180 + && register_operand (XEXP (operands[1], 0), SImode)
12181 + && reg_overlap_mentioned_p (operands[0], XEXP (operands[1], 0)))
12182 + || GET_CODE (operands[1]) == CONST_INT
12183 + || GET_CODE (operands[1]) == CONST_DOUBLE))"
12184 + [(set (match_dup 0) (match_dup 1))
12185 + (set (match_dup 2) (match_dup 3))]
12187 + operands[2] = simplify_gen_subreg ( DImode, operands[0],
12189 + operands[0] = simplify_gen_subreg ( DImode, operands[0],
12191 + if ( REG_P(operands[1]) ){
12192 + operands[3] = simplify_gen_subreg ( DImode, operands[1],
12194 + operands[1] = simplify_gen_subreg ( DImode, operands[1],
12196 + } else if ( GET_CODE(operands[1]) == CONST_DOUBLE
12197 + || GET_CODE(operands[1]) == CONST_INT ){
12198 + rtx split_const[2];
12199 + avr32_split_const_expr (TImode, DImode, operands[1], split_const);
12200 + operands[3] = split_const[1];
12201 + operands[1] = split_const[0];
12202 + } else if (avr32_const_pool_ref_operand (operands[1], GET_MODE(operands[1]))){
12203 + rtx split_const[2];
12204 + rtx cop = avoid_constant_pool_reference (operands[1]);
12205 + if (operands[1] == cop)
12206 + cop = get_pool_constant (XEXP (operands[1], 0));
12207 + avr32_split_const_expr (TImode, DImode, cop, split_const);
12208 + operands[3] = force_const_mem (DImode, split_const[1]);
12209 + operands[1] = force_const_mem (DImode, split_const[0]);
12211 + rtx ptr_reg = XEXP (operands[1], 0);
12212 + operands[1] = gen_rtx_MEM (DImode,
12213 + gen_rtx_PLUS ( SImode,
12216 + operands[3] = gen_rtx_MEM (DImode,
12219 + /* Check if the first load will clobber the pointer.
12220 + If so, we must switch the order of the operations. */
12221 + if ( reg_overlap_mentioned_p (operands[0], ptr_reg) )
12223 + /* We need to switch the order of the operations
12224 + so that the pointer register does not get clobbered
12225 + after the first double word load. */
12227 + tmp = operands[0];
12228 + operands[0] = operands[2];
12229 + operands[2] = tmp;
12230 + tmp = operands[1];
12231 + operands[1] = operands[3];
12232 + operands[3] = tmp;
12238 + [(set_attr "length" "*,*,4,4,*,8")
12239 + (set_attr "type" "*,*,load4,store4,*,load4")])
12242 +;;== float - 32 bits ==========================================================
12243 +(define_expand "movsf"
12244 + [(set (match_operand:SF 0 "nonimmediate_operand" "")
12245 + (match_operand:SF 1 "general_operand" ""))]
12250 + /* One of the ops has to be in a register. */
12251 + if (GET_CODE (operands[0]) != REG)
12252 + operands[1] = force_reg (SFmode, operands[1]);
12256 +(define_insn "*movsf_internal"
12257 + [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,r,r,m")
12258 + (match_operand:SF 1 "general_operand" "r, G,F,m,r"))]
12259 + "(register_operand (operands[0], SFmode)
12260 + || register_operand (operands[1], SFmode))"
12262 + switch (which_alternative) {
12264 + case 1: return "mov\t%0, %1";
12267 + HOST_WIDE_INT target_float[2];
12268 + real_to_target (target_float, CONST_DOUBLE_REAL_VALUE (operands[1]), SFmode);
12269 + if ( TARGET_V2_INSNS
12270 + && avr32_hi16_immediate_operand (GEN_INT (target_float[0]), VOIDmode) )
12271 + return "movh\t%0, hi(%1)";
12273 + return "mov\t%0, lo(%1)\;orh\t%0, hi(%1)";
12276 + if ( (REG_P(XEXP(operands[1], 0))
12277 + && REGNO(XEXP(operands[1], 0)) == SP_REGNUM)
12278 + || (GET_CODE(XEXP(operands[1], 0)) == PLUS
12279 + && REGNO(XEXP(XEXP(operands[1], 0), 0)) == SP_REGNUM
12280 + && GET_CODE(XEXP(XEXP(operands[1], 0), 1)) == CONST_INT
12281 + && INTVAL(XEXP(XEXP(operands[1], 0), 1)) % 4 == 0
12282 + && INTVAL(XEXP(XEXP(operands[1], 0), 1)) <= 0x1FC) )
12283 + return "lddsp\t%0, %1";
12284 + else if ( avr32_const_pool_ref_operand(operands[1], GET_MODE(operands[1])) )
12285 + return "lddpc\t%0, %1";
12287 + return "ld.w\t%0, %1";
12289 + if ( (REG_P(XEXP(operands[0], 0))
12290 + && REGNO(XEXP(operands[0], 0)) == SP_REGNUM)
12291 + || (GET_CODE(XEXP(operands[0], 0)) == PLUS
12292 + && REGNO(XEXP(XEXP(operands[0], 0), 0)) == SP_REGNUM
12293 + && GET_CODE(XEXP(XEXP(operands[0], 0), 1)) == CONST_INT
12294 + && INTVAL(XEXP(XEXP(operands[0], 0), 1)) % 4 == 0
12295 + && INTVAL(XEXP(XEXP(operands[0], 0), 1)) <= 0x1FC) )
12296 + return "stdsp\t%0, %1";
12298 + return "st.w\t%0, %1";
12304 + [(set_attr "length" "2,4,8,4,4")
12305 + (set_attr "type" "alu,alu,alu2,load,store")
12306 + (set_attr "cc" "none,none,clobber,none,none")])
12310 +;;== double - 64 bits =========================================================
12311 +(define_expand "movdf"
12312 + [(set (match_operand:DF 0 "nonimmediate_operand" "")
12313 + (match_operand:DF 1 "general_operand" ""))]
12316 + /* One of the ops has to be in a register. */
12317 + if (GET_CODE (operands[0]) != REG){
12318 + operands[1] = force_reg (DFmode, operands[1]);
12323 +(define_insn_and_split "*movdf_internal"
12324 + [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,r,r,m")
12325 + (match_operand:DF 1 "general_operand" " r,G,F,m,r"))]
12326 + "(register_operand (operands[0], DFmode)
12327 + || register_operand (operands[1], DFmode))"
12329 + switch (which_alternative ){
12335 + if ( avr32_const_pool_ref_operand(operands[1], GET_MODE(operands[1])))
12336 + return "ld.d\t%0, pc[%1 - .]";
12338 + return "ld.d\t%0, %1";
12340 + return "st.d\t%0, %1";
12345 + "reload_completed
12346 + && (REG_P (operands[0])
12347 + && (REG_P (operands[1])
12348 + || GET_CODE (operands[1]) == CONST_DOUBLE))"
12349 + [(set (match_dup 0) (match_dup 1))
12350 + (set (match_dup 2) (match_dup 3))]
12353 + operands[2] = gen_highpart (SImode, operands[0]);
12354 + operands[0] = gen_lowpart (SImode, operands[0]);
12355 + operands[3] = gen_highpart(SImode, operands[1]);
12356 + operands[1] = gen_lowpart(SImode, operands[1]);
12360 + [(set_attr "length" "*,*,*,4,4")
12361 + (set_attr "type" "*,*,*,load2,store2")
12362 + (set_attr "cc" "*,*,*,none,none")])
12365 +;;=============================================================================
12366 +;; Conditional Moves
12367 +;;=============================================================================
12368 +(define_insn "ld<mode>_predicable"
12369 + [(set (match_operand:MOVCC 0 "register_operand" "=r")
12370 + (match_operand:MOVCC 1 "avr32_non_rmw_memory_operand" "<MOVCC:pred_mem_constraint>"))]
12371 + "TARGET_V2_INSNS"
12372 + "ld<MOVCC:load_postfix>%?\t%0, %1"
12373 + [(set_attr "length" "4")
12374 + (set_attr "cc" "cmp_cond_insn")
12375 + (set_attr "type" "load")
12376 + (set_attr "predicable" "yes")]
12380 +(define_insn "st<mode>_predicable"
12381 + [(set (match_operand:MOVCC 0 "avr32_non_rmw_memory_operand" "=<MOVCC:pred_mem_constraint>")
12382 + (match_operand:MOVCC 1 "register_operand" "r"))]
12383 + "TARGET_V2_INSNS"
12384 + "st<MOVCC:store_postfix>%?\t%0, %1"
12385 + [(set_attr "length" "4")
12386 + (set_attr "cc" "cmp_cond_insn")
12387 + (set_attr "type" "store")
12388 + (set_attr "predicable" "yes")]
12391 +(define_insn "mov<mode>_predicable"
12392 + [(set (match_operand:MOVCC 0 "register_operand" "=r")
12393 + (match_operand:MOVCC 1 "avr32_cond_register_immediate_operand" "rKs08"))]
12396 + [(set_attr "length" "4")
12397 + (set_attr "cc" "cmp_cond_insn")
12398 + (set_attr "type" "alu")
12399 + (set_attr "predicable" "yes")]
12403 +;;=============================================================================
12404 +;; Move chunks of memory
12405 +;;=============================================================================
12407 +(define_expand "movmemsi"
12408 + [(match_operand:BLK 0 "general_operand" "")
12409 + (match_operand:BLK 1 "general_operand" "")
12410 + (match_operand:SI 2 "const_int_operand" "")
12411 + (match_operand:SI 3 "const_int_operand" "")]
12414 + if (avr32_gen_movmemsi (operands))
12423 +;;=============================================================================
12424 +;; Bit field instructions
12425 +;;-----------------------------------------------------------------------------
12426 +;; Instructions to insert or extract bit-fields
12427 +;;=============================================================================
12429 +(define_insn "insv"
12430 + [ (set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
12431 + (match_operand:SI 1 "immediate_operand" "Ku05")
12432 + (match_operand:SI 2 "immediate_operand" "Ku05"))
12433 + (match_operand 3 "register_operand" "r"))]
12435 + "bfins\t%0, %3, %2, %1"
12436 + [(set_attr "type" "alu")
12437 + (set_attr "length" "4")
12438 + (set_attr "cc" "set_ncz")])
12442 +(define_expand "extv"
12443 + [ (set (match_operand:SI 0 "register_operand" "")
12444 + (sign_extract:SI (match_operand:SI 1 "register_operand" "")
12445 + (match_operand:SI 2 "immediate_operand" "")
12446 + (match_operand:SI 3 "immediate_operand" "")))]
12449 + if ( INTVAL(operands[2]) >= 32 )
12454 +(define_expand "extzv"
12455 + [ (set (match_operand:SI 0 "register_operand" "")
12456 + (zero_extract:SI (match_operand:SI 1 "register_operand" "")
12457 + (match_operand:SI 2 "immediate_operand" "")
12458 + (match_operand:SI 3 "immediate_operand" "")))]
12461 + if ( INTVAL(operands[2]) >= 32 )
12466 +(define_insn "extv_internal"
12467 + [ (set (match_operand:SI 0 "register_operand" "=r")
12468 + (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
12469 + (match_operand:SI 2 "immediate_operand" "Ku05")
12470 + (match_operand:SI 3 "immediate_operand" "Ku05")))]
12471 + "INTVAL(operands[2]) < 32"
12472 + "bfexts\t%0, %1, %3, %2"
12473 + [(set_attr "type" "alu")
12474 + (set_attr "length" "4")
12475 + (set_attr "cc" "set_ncz")])
12478 +(define_insn "extzv_internal"
12479 + [ (set (match_operand:SI 0 "register_operand" "=r")
12480 + (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
12481 + (match_operand:SI 2 "immediate_operand" "Ku05")
12482 + (match_operand:SI 3 "immediate_operand" "Ku05")))]
12483 + "INTVAL(operands[2]) < 32"
12484 + "bfextu\t%0, %1, %3, %2"
12485 + [(set_attr "type" "alu")
12486 + (set_attr "length" "4")
12487 + (set_attr "cc" "set_ncz")])
12491 +;;=============================================================================
12492 +;; Some peepholes for avoiding unnecessary cast instructions
12493 +;; followed by bfins.
12494 +;;-----------------------------------------------------------------------------
12497 + [(set (match_operand:SI 0 "register_operand" "")
12498 + (zero_extend:SI (match_operand:QI 1 "register_operand" "")))
12499 + (set (zero_extract:SI (match_operand 2 "register_operand" "")
12500 + (match_operand:SI 3 "immediate_operand" "")
12501 + (match_operand:SI 4 "immediate_operand" ""))
12503 + "((peep2_reg_dead_p(2, operands[0]) &&
12504 + (INTVAL(operands[3]) <= 8)))"
12505 + [(set (zero_extract:SI (match_dup 2)
12512 + [(set (match_operand:SI 0 "register_operand" "")
12513 + (zero_extend:SI (match_operand:HI 1 "register_operand" "")))
12514 + (set (zero_extract:SI (match_operand 2 "register_operand" "")
12515 + (match_operand:SI 3 "immediate_operand" "")
12516 + (match_operand:SI 4 "immediate_operand" ""))
12518 + "((peep2_reg_dead_p(2, operands[0]) &&
12519 + (INTVAL(operands[3]) <= 16)))"
12520 + [(set (zero_extract:SI (match_dup 2)
12526 +;;=============================================================================
12528 +;;-----------------------------------------------------------------------------
12529 +;; Implements the push instruction
12530 +;;=============================================================================
12531 +(define_insn "pushm"
12532 + [(set (mem:BLK (pre_dec:BLK (reg:SI SP_REGNUM)))
12533 + (unspec:BLK [(match_operand 0 "const_int_operand" "")]
12537 + if (INTVAL(operands[0])) {
12538 + return "pushm\t%r0";
12543 + [(set_attr "type" "store")
12544 + (set_attr "length" "2")
12545 + (set_attr "cc" "none")])
12547 +(define_insn "stm"
12548 + [(unspec [(match_operand 0 "register_operand" "r")
12549 + (match_operand 1 "const_int_operand" "")
12550 + (match_operand 2 "const_int_operand" "")]
12554 + if (INTVAL(operands[1])) {
12555 + if (INTVAL(operands[2]) != 0)
12556 + return "stm\t--%0, %s1";
12558 + return "stm\t%0, %s1";
12563 + [(set_attr "type" "store")
12564 + (set_attr "length" "4")
12565 + (set_attr "cc" "none")])
12569 +(define_insn "popm"
12570 + [(unspec [(match_operand 0 "const_int_operand" "")]
12574 + if (INTVAL(operands[0])) {
12575 + return "popm %r0";
12580 + [(set_attr "type" "load")
12581 + (set_attr "length" "2")])
12585 +;;=============================================================================
12587 +;;-----------------------------------------------------------------------------
12588 +;; Adds reg1 with reg2 and puts the result in reg0.
12589 +;;=============================================================================
12590 +(define_insn "add<mode>3"
12591 + [(set (match_operand:INTM 0 "register_operand" "=r,r,r,r,r")
12592 + (plus:INTM (match_operand:INTM 1 "register_operand" "%0,r,0,r,0")
12593 + (match_operand:INTM 2 "avr32_add_operand" "r,r,Is08,Is16,Is21")))]
12602 + [(set_attr "length" "2,4,2,4,4")
12603 + (set_attr "cc" "<INTM:alu_cc_attr>")])
12605 +(define_insn "add<mode>3_lsl"
12606 + [(set (match_operand:INTM 0 "register_operand" "=r")
12607 + (plus:INTM (ashift:INTM (match_operand:INTM 1 "register_operand" "r")
12608 + (match_operand:INTM 3 "avr32_add_shift_immediate_operand" "Ku02"))
12609 + (match_operand:INTM 2 "register_operand" "r")))]
12611 + "add %0, %2, %1 << %3"
12612 + [(set_attr "length" "4")
12613 + (set_attr "cc" "<INTM:alu_cc_attr>")])
12615 +(define_insn "add<mode>3_lsl2"
12616 + [(set (match_operand:INTM 0 "register_operand" "=r")
12617 + (plus:INTM (match_operand:INTM 1 "register_operand" "r")
12618 + (ashift:INTM (match_operand:INTM 2 "register_operand" "r")
12619 + (match_operand:INTM 3 "avr32_add_shift_immediate_operand" "Ku02"))))]
12621 + "add %0, %1, %2 << %3"
12622 + [(set_attr "length" "4")
12623 + (set_attr "cc" "<INTM:alu_cc_attr>")])
12626 +(define_insn "add<mode>3_mul"
12627 + [(set (match_operand:INTM 0 "register_operand" "=r")
12628 + (plus:INTM (mult:INTM (match_operand:INTM 1 "register_operand" "r")
12629 + (match_operand:INTM 3 "immediate_operand" "Ku04" ))
12630 + (match_operand:INTM 2 "register_operand" "r")))]
12631 + "(INTVAL(operands[3]) == 0) || (INTVAL(operands[3]) == 2) ||
12632 + (INTVAL(operands[3]) == 4) || (INTVAL(operands[3]) == 8)"
12633 + "add %0, %2, %1 << %p3"
12634 + [(set_attr "length" "4")
12635 + (set_attr "cc" "<INTM:alu_cc_attr>")])
12637 +(define_insn "add<mode>3_mul2"
12638 + [(set (match_operand:INTM 0 "register_operand" "=r")
12639 + (plus:INTM (match_operand:INTM 1 "register_operand" "r")
12640 + (mult:INTM (match_operand:INTM 2 "register_operand" "r")
12641 + (match_operand:INTM 3 "immediate_operand" "Ku04" ))))]
12642 + "(INTVAL(operands[3]) == 0) || (INTVAL(operands[3]) == 2) ||
12643 + (INTVAL(operands[3]) == 4) || (INTVAL(operands[3]) == 8)"
12644 + "add %0, %1, %2 << %p3"
12645 + [(set_attr "length" "4")
12646 + (set_attr "cc" "<INTM:alu_cc_attr>")])
12650 + [(set (match_operand:SI 0 "register_operand" "")
12651 + (ashift:SI (match_operand:SI 1 "register_operand" "")
12652 + (match_operand:SI 2 "immediate_operand" "")))
12653 + (set (match_operand:SI 3 "register_operand" "")
12654 + (plus:SI (match_dup 0)
12655 + (match_operand:SI 4 "register_operand" "")))]
12656 + "(peep2_reg_dead_p(2, operands[0]) &&
12657 + (INTVAL(operands[2]) < 4 && INTVAL(operands[2]) > 0))"
12658 + [(set (match_dup 3)
12659 + (plus:SI (ashift:SI (match_dup 1)
12665 + [(set (match_operand:SI 0 "register_operand" "")
12666 + (ashift:SI (match_operand:SI 1 "register_operand" "")
12667 + (match_operand:SI 2 "immediate_operand" "")))
12668 + (set (match_operand:SI 3 "register_operand" "")
12669 + (plus:SI (match_operand:SI 4 "register_operand" "")
12671 + "(peep2_reg_dead_p(2, operands[0]) &&
12672 + (INTVAL(operands[2]) < 4 && INTVAL(operands[2]) > 0))"
12673 + [(set (match_dup 3)
12674 + (plus:SI (ashift:SI (match_dup 1)
12679 +(define_insn "adddi3"
12680 + [(set (match_operand:DI 0 "register_operand" "=r,r")
12681 + (plus:DI (match_operand:DI 1 "register_operand" "%0,r")
12682 + (match_operand:DI 2 "register_operand" "r,r")))]
12685 + add %0, %2\;adc %m0, %m0, %m2
12686 + add %0, %1, %2\;adc %m0, %m1, %m2"
12687 + [(set_attr "length" "6,8")
12688 + (set_attr "type" "alu2")
12689 + (set_attr "cc" "set_vncz")])
12692 +(define_insn "add<mode>_imm_predicable"
12693 + [(set (match_operand:INTM 0 "register_operand" "+r")
12694 + (plus:INTM (match_dup 0)
12695 + (match_operand:INTM 1 "avr32_cond_immediate_operand" "%Is08")))]
12698 + [(set_attr "length" "4")
12699 + (set_attr "cc" "cmp_cond_insn")
12700 + (set_attr "predicable" "yes")]
12703 +;;=============================================================================
12705 +;;-----------------------------------------------------------------------------
12706 +;; Subtract reg2 or immediate value from reg0 and puts the result in reg0.
12707 +;;=============================================================================
12709 +(define_insn "sub<mode>3"
12710 + [(set (match_operand:INTM 0 "general_operand" "=r,r,r,r,r,r,r")
12711 + (minus:INTM (match_operand:INTM 1 "register_const_int_operand" "0,r,0,r,0,r,Ks08")
12712 + (match_operand:INTM 2 "register_const_int_operand" "r,r,Ks08,Ks16,Ks21,0,r")))]
12722 + [(set_attr "length" "2,4,2,4,4,2,4")
12723 + (set_attr "cc" "<INTM:alu_cc_attr>")])
12725 +(define_insn "*sub<mode>3_mul"
12726 + [(set (match_operand:INTM 0 "register_operand" "=r")
12727 + (minus:INTM (match_operand:INTM 1 "register_operand" "r")
12728 + (mult:INTM (match_operand:INTM 2 "register_operand" "r")
12729 + (match_operand:SI 3 "immediate_operand" "Ku04" ))))]
12730 + "(INTVAL(operands[3]) == 0) || (INTVAL(operands[3]) == 2) ||
12731 + (INTVAL(operands[3]) == 4) || (INTVAL(operands[3]) == 8)"
12732 + "sub %0, %1, %2 << %p3"
12733 + [(set_attr "length" "4")
12734 + (set_attr "cc" "<INTM:alu_cc_attr>")])
12736 +(define_insn "*sub<mode>3_lsl"
12737 + [(set (match_operand:INTM 0 "register_operand" "=r")
12738 + (minus:INTM (match_operand:INTM 1 "register_operand" "r")
12739 + (ashift:INTM (match_operand:INTM 2 "register_operand" "r")
12740 + (match_operand:SI 3 "avr32_add_shift_immediate_operand" "Ku02"))))]
12742 + "sub %0, %1, %2 << %3"
12743 + [(set_attr "length" "4")
12744 + (set_attr "cc" "<INTM:alu_cc_attr>")])
12747 +(define_insn "subdi3"
12748 + [(set (match_operand:DI 0 "register_operand" "=r,r")
12749 + (minus:DI (match_operand:DI 1 "register_operand" "%0,r")
12750 + (match_operand:DI 2 "register_operand" "r,r")))]
12753 + sub %0, %2\;sbc %m0, %m0, %m2
12754 + sub %0, %1, %2\;sbc %m0, %m1, %m2"
12755 + [(set_attr "length" "6,8")
12756 + (set_attr "type" "alu2")
12757 + (set_attr "cc" "set_vncz")])
12760 +(define_insn "sub<mode>_imm_predicable"
12761 + [(set (match_operand:INTM 0 "register_operand" "+r")
12762 + (minus:INTM (match_dup 0)
12763 + (match_operand:INTM 1 "avr32_cond_immediate_operand" "Ks08")))]
12766 + [(set_attr "length" "4")
12767 + (set_attr "cc" "cmp_cond_insn")
12768 + (set_attr "predicable" "yes")])
12770 +(define_insn "rsub<mode>_imm_predicable"
12771 + [(set (match_operand:INTM 0 "register_operand" "+r")
12772 + (minus:INTM (match_operand:INTM 1 "avr32_cond_immediate_operand" "Ks08")
12776 + [(set_attr "length" "4")
12777 + (set_attr "cc" "cmp_cond_insn")
12778 + (set_attr "predicable" "yes")])
12780 +;;=============================================================================
12782 +;;-----------------------------------------------------------------------------
12783 +;; Multiply op1 and op2 and put the value in op0.
12784 +;;=============================================================================
12787 +(define_insn "mulqi3"
12788 + [(set (match_operand:QI 0 "register_operand" "=r,r,r")
12789 + (mult:QI (match_operand:QI 1 "register_operand" "%0,r,r")
12790 + (match_operand:QI 2 "avr32_mul_operand" "r,r,Ks08")))]
12791 + "!TARGET_NO_MUL_INSNS"
12793 + switch (which_alternative){
12795 + return "mul %0, %2";
12797 + return "mul %0, %1, %2";
12799 + return "mul %0, %1, %2";
12801 + gcc_unreachable();
12804 + [(set_attr "type" "mulww_w,mulww_w,mulwh")
12805 + (set_attr "length" "2,4,4")
12806 + (set_attr "cc" "none")])
12808 +(define_insn "mulsi3"
12809 + [(set (match_operand:SI 0 "register_operand" "=r,r,r")
12810 + (mult:SI (match_operand:SI 1 "register_operand" "%0,r,r")
12811 + (match_operand:SI 2 "avr32_mul_operand" "r,r,Ks08")))]
12812 + "!TARGET_NO_MUL_INSNS"
12814 + switch (which_alternative){
12816 + return "mul %0, %2";
12818 + return "mul %0, %1, %2";
12820 + return "mul %0, %1, %2";
12822 + gcc_unreachable();
12825 + [(set_attr "type" "mulww_w,mulww_w,mulwh")
12826 + (set_attr "length" "2,4,4")
12827 + (set_attr "cc" "none")])
12830 +(define_insn "mulhisi3"
12831 + [(set (match_operand:SI 0 "register_operand" "=r")
12833 + (sign_extend:SI (match_operand:HI 1 "register_operand" "%r"))
12834 + (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
12835 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
12836 + "mulhh.w %0, %1:b, %2:b"
12837 + [(set_attr "type" "mulhh")
12838 + (set_attr "length" "4")
12839 + (set_attr "cc" "none")])
12842 + [(match_scratch:DI 6 "r")
12843 + (set (match_operand:SI 0 "register_operand" "")
12845 + (sign_extend:SI (match_operand:HI 1 "register_operand" ""))
12846 + (sign_extend:SI (match_operand:HI 2 "register_operand" ""))))
12847 + (set (match_operand:SI 3 "register_operand" "")
12848 + (ashiftrt:SI (match_dup 0)
12849 + (const_int 16)))]
12850 + "!TARGET_NO_MUL_INSNS && TARGET_DSP
12851 + && (peep2_reg_dead_p(1, operands[0]) || (REGNO(operands[0]) == REGNO(operands[3])))"
12852 + [(set (match_dup 4) (sign_extend:SI (match_dup 1)))
12853 + (set (match_dup 6)
12854 + (ashift:DI (mult:DI (sign_extend:DI (match_dup 4))
12855 + (sign_extend:DI (match_dup 2)))
12857 + (set (match_dup 3) (match_dup 5))]
12860 + operands[4] = gen_rtx_REG(SImode, REGNO(operands[1]));
12861 + operands[5] = gen_highpart (SImode, operands[4]);
12865 +(define_insn "mulnhisi3"
12866 + [(set (match_operand:SI 0 "register_operand" "=r")
12868 + (sign_extend:SI (neg:HI (match_operand:HI 1 "register_operand" "r")))
12869 + (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
12870 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
12871 + "mulnhh.w %0, %1:b, %2:b"
12872 + [(set_attr "type" "mulhh")
12873 + (set_attr "length" "4")
12874 + (set_attr "cc" "none")])
12876 +(define_insn "machisi3"
12877 + [(set (match_operand:SI 0 "register_operand" "+r")
12878 + (plus:SI (mult:SI
12879 + (sign_extend:SI (match_operand:HI 1 "register_operand" "%r"))
12880 + (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))
12882 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
12883 + "machh.w %0, %1:b, %2:b"
12884 + [(set_attr "type" "machh_w")
12885 + (set_attr "length" "4")
12886 + (set_attr "cc" "none")])
12890 +(define_insn "mulsidi3"
12891 + [(set (match_operand:DI 0 "register_operand" "=r")
12893 + (sign_extend:DI (match_operand:SI 1 "register_operand" "%r"))
12894 + (sign_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
12895 + "!TARGET_NO_MUL_INSNS"
12896 + "muls.d %0, %1, %2"
12897 + [(set_attr "type" "mulww_d")
12898 + (set_attr "length" "4")
12899 + (set_attr "cc" "none")])
12901 +(define_insn "umulsidi3"
12902 + [(set (match_operand:DI 0 "register_operand" "=r")
12904 + (zero_extend:DI (match_operand:SI 1 "register_operand" "%r"))
12905 + (zero_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
12906 + "!TARGET_NO_MUL_INSNS"
12907 + "mulu.d %0, %1, %2"
12908 + [(set_attr "type" "mulww_d")
12909 + (set_attr "length" "4")
12910 + (set_attr "cc" "none")])
12912 +(define_insn "*mulaccsi3"
12913 + [(set (match_operand:SI 0 "register_operand" "+r")
12914 + (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "%r")
12915 + (match_operand:SI 2 "register_operand" "r"))
12917 + "!TARGET_NO_MUL_INSNS"
12919 + [(set_attr "type" "macww_w")
12920 + (set_attr "length" "4")
12921 + (set_attr "cc" "none")])
12923 +(define_insn "*mulaccsidi3"
12924 + [(set (match_operand:DI 0 "register_operand" "+r")
12925 + (plus:DI (mult:DI
12926 + (sign_extend:DI (match_operand:SI 1 "register_operand" "%r"))
12927 + (sign_extend:DI (match_operand:SI 2 "register_operand" "r")))
12929 + "!TARGET_NO_MUL_INSNS"
12930 + "macs.d %0, %1, %2"
12931 + [(set_attr "type" "macww_d")
12932 + (set_attr "length" "4")
12933 + (set_attr "cc" "none")])
12935 +(define_insn "*umulaccsidi3"
12936 + [(set (match_operand:DI 0 "register_operand" "+r")
12937 + (plus:DI (mult:DI
12938 + (zero_extend:DI (match_operand:SI 1 "register_operand" "%r"))
12939 + (zero_extend:DI (match_operand:SI 2 "register_operand" "r")))
12941 + "!TARGET_NO_MUL_INSNS"
12942 + "macu.d %0, %1, %2"
12943 + [(set_attr "type" "macww_d")
12944 + (set_attr "length" "4")
12945 + (set_attr "cc" "none")])
12949 +;; Try to avoid Write-After-Write hazards for mul operations
12950 +;; if it can be done
12952 + [(set (match_operand:SI 0 "register_operand" "")
12954 + (sign_extend:SI (match_operand 1 "general_operand" ""))
12955 + (sign_extend:SI (match_operand 2 "general_operand" ""))))
12956 + (set (match_dup 0)
12957 + (match_operator:SI 3 "alu_operator" [(match_dup 0)
12958 + (match_operand 4 "general_operand" "")]))]
12959 + "peep2_reg_dead_p(1, operands[2])"
12960 + [(set (match_dup 5)
12962 + (sign_extend:SI (match_dup 1))
12963 + (sign_extend:SI (match_dup 2))))
12964 + (set (match_dup 0)
12965 + (match_op_dup 3 [(match_dup 5)
12966 + (match_dup 4)]))]
12967 + "{operands[5] = gen_rtx_REG(SImode, REGNO(operands[2]));}"
12972 +;;=============================================================================
12973 +;; DSP instructions
12974 +;;=============================================================================
12975 +(define_insn "mulsathh_h"
12976 + [(set (match_operand:HI 0 "register_operand" "=r")
12977 + (ss_truncate:HI (ashiftrt:SI (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%r"))
12978 + (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))
12979 + (const_int 15))))]
12980 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
12981 + "mulsathh.h\t%0, %1:b, %2:b"
12982 + [(set_attr "length" "4")
12983 + (set_attr "cc" "none")
12984 + (set_attr "type" "mulhh")])
12986 +(define_insn "mulsatrndhh_h"
12987 + [(set (match_operand:HI 0 "register_operand" "=r")
12988 + (ss_truncate:HI (ashiftrt:SI
12989 + (plus:SI (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%r"))
12990 + (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))
12991 + (const_int 1073741824))
12992 + (const_int 15))))]
12993 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
12994 + "mulsatrndhh.h\t%0, %1:b, %2:b"
12995 + [(set_attr "length" "4")
12996 + (set_attr "cc" "none")
12997 + (set_attr "type" "mulhh")])
12999 +(define_insn "mulsathh_w"
13000 + [(set (match_operand:SI 0 "register_operand" "=r")
13001 + (ss_truncate:SI (ashift:DI (mult:DI (sign_extend:DI (match_operand:HI 1 "register_operand" "%r"))
13002 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
13003 + (const_int 1))))]
13004 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
13005 + "mulsathh.w\t%0, %1:b, %2:b"
13006 + [(set_attr "length" "4")
13007 + (set_attr "cc" "none")
13008 + (set_attr "type" "mulhh")])
13010 +(define_insn "mulsatwh_w"
13011 + [(set (match_operand:SI 0 "register_operand" "=r")
13012 + (ss_truncate:SI (ashiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
13013 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
13014 + (const_int 15))))]
13015 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
13016 + "mulsatwh.w\t%0, %1, %2:b"
13017 + [(set_attr "length" "4")
13018 + (set_attr "cc" "none")
13019 + (set_attr "type" "mulwh")])
13021 +(define_insn "mulsatrndwh_w"
13022 + [(set (match_operand:SI 0 "register_operand" "=r")
13023 + (ss_truncate:SI (ashiftrt:DI (plus:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
13024 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
13025 + (const_int 1073741824))
13026 + (const_int 15))))]
13027 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
13028 + "mulsatrndwh.w\t%0, %1, %2:b"
13029 + [(set_attr "length" "4")
13030 + (set_attr "cc" "none")
13031 + (set_attr "type" "mulwh")])
13033 +(define_insn "macsathh_w"
13034 + [(set (match_operand:SI 0 "register_operand" "+r")
13035 + (plus:SI (match_dup 0)
13036 + (ss_truncate:SI (ashift:DI (mult:DI (sign_extend:DI (match_operand:HI 1 "register_operand" "%r"))
13037 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
13038 + (const_int 1)))))]
13039 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
13040 + "macsathh.w\t%0, %1:b, %2:b"
13041 + [(set_attr "length" "4")
13042 + (set_attr "cc" "none")
13043 + (set_attr "type" "mulhh")])
13046 +(define_insn "mulwh_d"
13047 + [(set (match_operand:DI 0 "register_operand" "=r")
13048 + (ashift:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
13049 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
13050 + (const_int 16)))]
13051 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
13052 + "mulwh.d\t%0, %1, %2:b"
13053 + [(set_attr "length" "4")
13054 + (set_attr "cc" "none")
13055 + (set_attr "type" "mulwh")])
13058 +(define_insn "mulnwh_d"
13059 + [(set (match_operand:DI 0 "register_operand" "=r")
13060 + (ashift:DI (mult:DI (not:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))
13061 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
13062 + (const_int 16)))]
13063 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
13064 + "mulnwh.d\t%0, %1, %2:b"
13065 + [(set_attr "length" "4")
13066 + (set_attr "cc" "none")
13067 + (set_attr "type" "mulwh")])
13069 +(define_insn "macwh_d"
13070 + [(set (match_operand:DI 0 "register_operand" "+r")
13071 + (plus:DI (match_dup 0)
13072 + (ashift:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "%r"))
13073 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
13074 + (const_int 16))))]
13075 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
13076 + "macwh.d\t%0, %1, %2:b"
13077 + [(set_attr "length" "4")
13078 + (set_attr "cc" "none")
13079 + (set_attr "type" "mulwh")])
13081 +(define_insn "machh_d"
13082 + [(set (match_operand:DI 0 "register_operand" "+r")
13083 + (plus:DI (match_dup 0)
13084 + (mult:DI (sign_extend:DI (match_operand:HI 1 "register_operand" "%r"))
13085 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))))]
13086 + "!TARGET_NO_MUL_INSNS && TARGET_DSP"
13087 + "machh.d\t%0, %1:b, %2:b"
13088 + [(set_attr "length" "4")
13089 + (set_attr "cc" "none")
13090 + (set_attr "type" "mulwh")])
13092 +(define_insn "satadd_w"
13093 + [(set (match_operand:SI 0 "register_operand" "=r")
13094 + (ss_plus:SI (match_operand:SI 1 "register_operand" "r")
13095 + (match_operand:SI 2 "register_operand" "r")))]
13097 + "satadd.w\t%0, %1, %2"
13098 + [(set_attr "length" "4")
13099 + (set_attr "cc" "none")
13100 + (set_attr "type" "alu_sat")])
13102 +(define_insn "satsub_w"
13103 + [(set (match_operand:SI 0 "register_operand" "=r")
13104 + (ss_minus:SI (match_operand:SI 1 "register_operand" "r")
13105 + (match_operand:SI 2 "register_operand" "r")))]
13107 + "satsub.w\t%0, %1, %2"
13108 + [(set_attr "length" "4")
13109 + (set_attr "cc" "none")
13110 + (set_attr "type" "alu_sat")])
13112 +(define_insn "satadd_h"
13113 + [(set (match_operand:HI 0 "register_operand" "=r")
13114 + (ss_plus:HI (match_operand:HI 1 "register_operand" "r")
13115 + (match_operand:HI 2 "register_operand" "r")))]
13117 + "satadd.h\t%0, %1, %2"
13118 + [(set_attr "length" "4")
13119 + (set_attr "cc" "none")
13120 + (set_attr "type" "alu_sat")])
13122 +(define_insn "satsub_h"
13123 + [(set (match_operand:HI 0 "register_operand" "=r")
13124 + (ss_minus:HI (match_operand:HI 1 "register_operand" "r")
13125 + (match_operand:HI 2 "register_operand" "r")))]
13127 + "satsub.h\t%0, %1, %2"
13128 + [(set_attr "length" "4")
13129 + (set_attr "cc" "none")
13130 + (set_attr "type" "alu_sat")])
13133 +;;=============================================================================
13135 +;;-----------------------------------------------------------------------------
13136 +;; Set reg0 to the smallest value of reg1 and reg2. It is used for signed
13137 +;; values in the registers.
13138 +;;=============================================================================
13139 +(define_insn "sminsi3"
13140 + [(set (match_operand:SI 0 "register_operand" "=r")
13141 + (smin:SI (match_operand:SI 1 "register_operand" "r")
13142 + (match_operand:SI 2 "register_operand" "r")))]
13145 + [(set_attr "length" "4")
13146 + (set_attr "cc" "none")])
13148 +;;=============================================================================
13150 +;;-----------------------------------------------------------------------------
13151 +;; Set reg0 to the largest value of reg1 and reg2. It is used for signed
13152 +;; values in the registers.
13153 +;;=============================================================================
13154 +(define_insn "smaxsi3"
13155 + [(set (match_operand:SI 0 "register_operand" "=r")
13156 + (smax:SI (match_operand:SI 1 "register_operand" "r")
13157 + (match_operand:SI 2 "register_operand" "r")))]
13160 + [(set_attr "length" "4")
13161 + (set_attr "cc" "none")])
13165 +;;=============================================================================
13166 +;; Logical operations
13167 +;;-----------------------------------------------------------------------------
13170 +;; Split up simple DImode logical operations. Simply perform the logical
13171 +;; operation on the upper and lower halves of the registers.
13173 + [(set (match_operand:DI 0 "register_operand" "")
13174 + (match_operator:DI 6 "logical_binary_operator"
13175 + [(match_operand:DI 1 "register_operand" "")
13176 + (match_operand:DI 2 "register_operand" "")]))]
13177 + "reload_completed"
13178 + [(set (match_dup 0) (match_op_dup:SI 6 [(match_dup 1) (match_dup 2)]))
13179 + (set (match_dup 3) (match_op_dup:SI 6 [(match_dup 4) (match_dup 5)]))]
13182 + operands[3] = gen_highpart (SImode, operands[0]);
13183 + operands[0] = gen_lowpart (SImode, operands[0]);
13184 + operands[4] = gen_highpart (SImode, operands[1]);
13185 + operands[1] = gen_lowpart (SImode, operands[1]);
13186 + operands[5] = gen_highpart (SImode, operands[2]);
13187 + operands[2] = gen_lowpart (SImode, operands[2]);
13191 +;;=============================================================================
13192 +;; Logical operations with shifted operand
13193 +;;=============================================================================
13194 +(define_insn "<code>si_lshift"
13195 + [(set (match_operand:SI 0 "register_operand" "=r")
13196 + (logical:SI (match_operator:SI 4 "logical_shift_operator"
13197 + [(match_operand:SI 2 "register_operand" "r")
13198 + (match_operand:SI 3 "immediate_operand" "Ku05")])
13199 + (match_operand:SI 1 "register_operand" "r")))]
13202 + if ( GET_CODE(operands[4]) == ASHIFT )
13203 + return "<logical_insn>\t%0, %1, %2 << %3";
13205 + return "<logical_insn>\t%0, %1, %2 >> %3";
13208 + [(set_attr "cc" "set_z")]
13212 +;;************************************************
13213 +;; Peepholes for detecting logical operantions
13214 +;; with shifted operands
13215 +;;************************************************
13218 + [(set (match_operand:SI 3 "register_operand" "")
13219 + (match_operator:SI 5 "logical_shift_operator"
13220 + [(match_operand:SI 1 "register_operand" "")
13221 + (match_operand:SI 2 "immediate_operand" "")]))
13222 + (set (match_operand:SI 0 "register_operand" "")
13223 + (logical:SI (match_operand:SI 4 "register_operand" "")
13225 + "(dead_or_set_p(insn, operands[3])) || (REGNO(operands[3]) == REGNO(operands[0]))"
13227 + if ( GET_CODE(operands[5]) == ASHIFT )
13228 + return "<logical_insn>\t%0, %4, %1 << %2";
13230 + return "<logical_insn>\t%0, %4, %1 >> %2";
13232 + [(set_attr "cc" "set_z")]
13236 + [(set (match_operand:SI 3 "register_operand" "")
13237 + (match_operator:SI 5 "logical_shift_operator"
13238 + [(match_operand:SI 1 "register_operand" "")
13239 + (match_operand:SI 2 "immediate_operand" "")]))
13240 + (set (match_operand:SI 0 "register_operand" "")
13241 + (logical:SI (match_dup 3)
13242 + (match_operand:SI 4 "register_operand" "")))]
13243 + "(dead_or_set_p(insn, operands[3])) || (REGNO(operands[3]) == REGNO(operands[0]))"
13245 + if ( GET_CODE(operands[5]) == ASHIFT )
13246 + return "<logical_insn>\t%0, %4, %1 << %2";
13248 + return "<logical_insn>\t%0, %4, %1 >> %2";
13250 + [(set_attr "cc" "set_z")]
13255 + [(set (match_operand:SI 0 "register_operand" "")
13256 + (match_operator:SI 5 "logical_shift_operator"
13257 + [(match_operand:SI 1 "register_operand" "")
13258 + (match_operand:SI 2 "immediate_operand" "")]))
13259 + (set (match_operand:SI 3 "register_operand" "")
13260 + (logical:SI (match_operand:SI 4 "register_operand" "")
13262 + "(peep2_reg_dead_p(2, operands[0])) || (REGNO(operands[3]) == REGNO(operands[0]))"
13264 + [(set (match_dup 3)
13265 + (logical:SI (match_op_dup:SI 5 [(match_dup 1) (match_dup 2)])
13272 + [(set (match_operand:SI 0 "register_operand" "")
13273 + (match_operator:SI 5 "logical_shift_operator"
13274 + [(match_operand:SI 1 "register_operand" "")
13275 + (match_operand:SI 2 "immediate_operand" "")]))
13276 + (set (match_operand:SI 3 "register_operand" "")
13277 + (logical:SI (match_dup 0)
13278 + (match_operand:SI 4 "register_operand" "")))]
13279 + "(peep2_reg_dead_p(2, operands[0])) || (REGNO(operands[3]) == REGNO(operands[0]))"
13281 + [(set (match_dup 3)
13282 + (logical:SI (match_op_dup:SI 5 [(match_dup 1) (match_dup 2)])
13289 +;;=============================================================================
13291 +;;-----------------------------------------------------------------------------
13292 +;; Store the result after a bitwise logical-and between reg0 and reg2 in reg0.
13293 +;;=============================================================================
13295 +(define_insn "andnsi"
13296 + [(set (match_operand:SI 0 "register_operand" "+r")
13297 + (and:SI (match_dup 0)
13298 + (not:SI (match_operand:SI 1 "register_operand" "r"))))]
13301 + [(set_attr "cc" "set_z")
13302 + (set_attr "length" "2")]
13306 +(define_insn "andsi3"
13307 + [(set (match_operand:SI 0 "avr32_rmw_memory_or_register_operand" "=Y,r,r,r, r, r,r,r,r,r")
13308 + (and:SI (match_operand:SI 1 "avr32_rmw_memory_or_register_operand" "%0,r,0,0, 0, 0,0,0,0,r" )
13309 + (match_operand:SI 2 "nonmemory_operand" " N,M,N,Ku16,Ks17,J,L,r,i,r")))]
13313 + bfextu\t%0, %1, 0, %z2
13315 + andl\t%0, %2, COH
13317 + andh\t%0, hi(%2), COH
13320 + andh\t%0, hi(%2)\;andl\t%0, lo(%2)
13323 + [(set_attr "length" "4,4,2,4,4,4,4,2,8,4")
13324 + (set_attr "cc" "none,set_z,set_z,set_z,set_z,set_z,set_z,set_z,set_z,set_z")])
13328 +(define_insn "anddi3"
13329 + [(set (match_operand:DI 0 "register_operand" "=&r,&r")
13330 + (and:DI (match_operand:DI 1 "register_operand" "%0,r")
13331 + (match_operand:DI 2 "register_operand" "r,r")))]
13334 + [(set_attr "length" "8")
13335 + (set_attr "cc" "clobber")]
13338 +;;=============================================================================
13340 +;;-----------------------------------------------------------------------------
13341 +;; Store the result after a bitwise inclusive-or between reg0 and reg2 in reg0.
13342 +;;=============================================================================
13344 +(define_insn "iorsi3"
13345 + [(set (match_operand:SI 0 "avr32_rmw_memory_or_register_operand" "=Y,r,r, r,r,r,r")
13346 + (ior:SI (match_operand:SI 1 "avr32_rmw_memory_or_register_operand" "%0,0,0, 0,0,0,r" )
13347 + (match_operand:SI 2 "nonmemory_operand" " O,O,Ku16,J,r,i,r")))]
13355 + orh\t%0, hi(%2)\;orl\t%0, lo(%2)
13358 + [(set_attr "length" "4,2,4,4,2,8,4")
13359 + (set_attr "cc" "none,set_z,set_z,set_z,set_z,set_z,set_z")])
13362 +(define_insn "iordi3"
13363 + [(set (match_operand:DI 0 "register_operand" "=&r,&r")
13364 + (ior:DI (match_operand:DI 1 "register_operand" "%0,r")
13365 + (match_operand:DI 2 "register_operand" "r,r")))]
13368 + [(set_attr "length" "8")
13369 + (set_attr "cc" "clobber")]
13372 +;;=============================================================================
13374 +;;-----------------------------------------------------------------------------
13375 +;; Store the result after a bitwise exclusive-or between reg0 and reg2 in reg0.
13376 +;;=============================================================================
13378 +(define_insn "xorsi3"
13379 + [(set (match_operand:SI 0 "avr32_rmw_memory_or_register_operand" "=Y,r, r,r,r,r")
13380 + (xor:SI (match_operand:SI 1 "avr32_rmw_memory_or_register_operand" "%0,0, 0,0,0,r" )
13381 + (match_operand:SI 2 "nonmemory_operand" " O,Ku16,J,r,i,r")))]
13388 + eorh\t%0, hi(%2)\;eorl\t%0, lo(%2)
13391 + [(set_attr "length" "4,4,4,2,8,4")
13392 + (set_attr "cc" "none,set_z,set_z,set_z,set_z,set_z")])
13394 +(define_insn "xordi3"
13395 + [(set (match_operand:DI 0 "register_operand" "=&r,&r")
13396 + (xor:DI (match_operand:DI 1 "register_operand" "%0,r")
13397 + (match_operand:DI 2 "register_operand" "r,r")))]
13400 + [(set_attr "length" "8")
13401 + (set_attr "cc" "clobber")]
13404 +;;=============================================================================
13405 +;; Three operand predicable insns
13406 +;;=============================================================================
13408 +(define_insn "<predicable_insn3><mode>_predicable"
13409 + [(set (match_operand:INTM 0 "register_operand" "=r")
13410 + (predicable_op3:INTM (match_operand:INTM 1 "register_operand" "<predicable_commutative3>r")
13411 + (match_operand:INTM 2 "register_operand" "r")))]
13412 + "TARGET_V2_INSNS"
13413 + "<predicable_insn3>%?\t%0, %1, %2"
13414 + [(set_attr "length" "4")
13415 + (set_attr "cc" "cmp_cond_insn")
13416 + (set_attr "predicable" "yes")]
13419 +(define_insn_and_split "<predicable_insn3><mode>_imm_clobber_predicable"
13421 + [(set (match_operand:INTM 0 "register_operand" "=r")
13422 + (predicable_op3:INTM (match_operand:INTM 1 "register_operand" "<predicable_commutative3>r")
13423 + (match_operand:INTM 2 "avr32_mov_immediate_operand" "JKs21")))
13424 + (clobber (match_operand:INTM 3 "register_operand" "=&r"))])]
13425 + "TARGET_V2_INSNS"
13427 + if ( current_insn_predicate != NULL_RTX )
13429 + if ( avr32_const_ok_for_constraint_p (INTVAL (operands[2]), 'K', "Ks08") )
13430 + return "%! mov%?\t%3, %2\;<predicable_insn3>%?\t%0, %1, %3";
13431 + else if ( avr32_const_ok_for_constraint_p (INTVAL (operands[2]), 'K', "Ks21") )
13432 + return "%! mov\t%3, %2\;<predicable_insn3>%?\t%0, %1, %3";
13434 + return "%! movh\t%3, hi(%2)\;<predicable_insn3>%?\t%0, %1, %3";
13438 + if ( !avr32_cond_imm_clobber_splittable (insn, operands) )
13440 + if ( avr32_const_ok_for_constraint_p (INTVAL (operands[2]), 'K', "Ks08") )
13441 + return "mov%?\t%3, %2\;<predicable_insn3>%?\t%0, %1, %3";
13442 + else if ( avr32_const_ok_for_constraint_p (INTVAL (operands[2]), 'K', "Ks21") )
13443 + return "mov\t%3, %2\;<predicable_insn3>%?\t%0, %1, %3";
13445 + return "movh\t%3, hi(%2)\;<predicable_insn3>%?\t%0, %1, %3";
13451 + ;; If we find out that we could not actually do if-conversion on the block
13452 + ;; containing this insn we convert it back to normal immediate format
13453 + ;; to avoid outputing a redundant move insn
13454 + ;; Do not split until after we have checked if we can make the insn
13456 + "(GET_CODE (PATTERN (insn)) != COND_EXEC
13457 + && cfun->machine->ifcvt_after_reload
13458 + && avr32_cond_imm_clobber_splittable (insn, operands))"
13459 + [(set (match_dup 0)
13460 + (predicable_op3:INTM (match_dup 1)
13463 + [(set_attr "length" "8")
13464 + (set_attr "cc" "cmp_cond_insn")
13465 + (set_attr "predicable" "yes")]
13469 +;;=============================================================================
13470 +;; Zero extend predicable insns
13471 +;;=============================================================================
13472 +(define_insn_and_split "zero_extendhisi_clobber_predicable"
13474 + [(set (match_operand:SI 0 "register_operand" "=r")
13475 + (zero_extend:SI (match_operand:HI 1 "register_operand" "r")))
13476 + (clobber (match_operand:SI 2 "register_operand" "=&r"))])]
13477 + "TARGET_V2_INSNS"
13479 + if ( current_insn_predicate != NULL_RTX )
13481 + return "%! mov\t%2, 0xffff\;and%?\t%0, %1, %2";
13489 + ;; If we find out that we could not actually do if-conversion on the block
13490 + ;; containing this insn we convert it back to normal immediate format
13491 + ;; to avoid outputing a redundant move insn
13492 + ;; Do not split until after we have checked if we can make the insn
13494 + "(GET_CODE (PATTERN (insn)) != COND_EXEC
13495 + && cfun->machine->ifcvt_after_reload)"
13496 + [(set (match_dup 0)
13497 + (zero_extend:SI (match_dup 1)))]
13499 + [(set_attr "length" "8")
13500 + (set_attr "cc" "cmp_cond_insn")
13501 + (set_attr "predicable" "yes")]
13504 +(define_insn_and_split "zero_extendqisi_clobber_predicable"
13506 + [(set (match_operand:SI 0 "register_operand" "=r")
13507 + (zero_extend:SI (match_operand:QI 1 "register_operand" "r")))
13508 + (clobber (match_operand:SI 2 "register_operand" "=&r"))])]
13509 + "TARGET_V2_INSNS"
13511 + if ( current_insn_predicate != NULL_RTX )
13513 + return "%! mov\t%2, 0xff\;and%?\t%0, %1, %2";
13521 + ;; If we find out that we could not actually do if-conversion on the block
13522 + ;; containing this insn we convert it back to normal immediate format
13523 + ;; to avoid outputing a redundant move insn
13524 + ;; Do not split until after we have checked if we can make the insn
13526 + "(GET_CODE (PATTERN (insn)) != COND_EXEC
13527 + && cfun->machine->ifcvt_after_reload)"
13528 + [(set (match_dup 0)
13529 + (zero_extend:SI (match_dup 1)))]
13531 + [(set_attr "length" "8")
13532 + (set_attr "cc" "cmp_cond_insn")
13533 + (set_attr "predicable" "yes")]
13536 +(define_insn_and_split "zero_extendqihi_clobber_predicable"
13538 + [(set (match_operand:HI 0 "register_operand" "=r")
13539 + (zero_extend:HI (match_operand:QI 1 "register_operand" "r")))
13540 + (clobber (match_operand:SI 2 "register_operand" "=&r"))])]
13541 + "TARGET_V2_INSNS"
13543 + if ( current_insn_predicate != NULL_RTX )
13545 + return "%! mov\t%2, 0xff\;and%?\t%0, %1, %2";
13553 + ;; If we find out that we could not actually do if-conversion on the block
13554 + ;; containing this insn we convert it back to normal immediate format
13555 + ;; to avoid outputing a redundant move insn
13556 + ;; Do not split until after we have checked if we can make the insn
13558 + "(GET_CODE (PATTERN (insn)) != COND_EXEC
13559 + && cfun->machine->ifcvt_after_reload)"
13560 + [(set (match_dup 0)
13561 + (zero_extend:HI (match_dup 1)))]
13563 + [(set_attr "length" "8")
13564 + (set_attr "cc" "cmp_cond_insn")
13565 + (set_attr "predicable" "yes")]
13567 +;;=============================================================================
13569 +;;-----------------------------------------------------------------------------
13570 +;; Signed division that produces both a quotient and a remainder.
13571 +;;=============================================================================
13573 +(define_expand "divmodsi4"
13576 + (set (match_operand:SI 0 "register_operand" "=r")
13577 + (div:SI (match_operand:SI 1 "register_operand" "r")
13578 + (match_operand:SI 2 "register_operand" "r")))
13579 + (set (match_operand:SI 3 "register_operand" "=r")
13580 + (mod:SI (match_dup 1)
13581 + (match_dup 2)))])
13582 + (use (match_dup 4))])]
13585 + if (can_create_pseudo_p ()) {
13586 + operands[4] = gen_reg_rtx (DImode);
13587 + emit_insn(gen_divmodsi4_internal(operands[4],operands[1],operands[2]));
13588 + emit_move_insn(operands[0], gen_rtx_SUBREG( SImode, operands[4], 4));
13589 + emit_move_insn(operands[3], gen_rtx_SUBREG( SImode, operands[4], 0));
13597 +(define_insn "divmodsi4_internal"
13598 + [(set (match_operand:DI 0 "register_operand" "=r")
13599 + (unspec:DI [(match_operand:SI 1 "register_operand" "r")
13600 + (match_operand:SI 2 "register_operand" "r")]
13601 + UNSPEC_DIVMODSI4_INTERNAL))]
13603 + "divs %0, %1, %2"
13604 + [(set_attr "type" "div")
13605 + (set_attr "cc" "none")])
13608 +;;=============================================================================
13610 +;;-----------------------------------------------------------------------------
13611 +;; Unsigned division that produces both a quotient and a remainder.
13612 +;;=============================================================================
13613 +(define_expand "udivmodsi4"
13616 + (set (match_operand:SI 0 "register_operand" "=r")
13617 + (udiv:SI (match_operand:SI 1 "register_operand" "r")
13618 + (match_operand:SI 2 "register_operand" "r")))
13619 + (set (match_operand:SI 3 "register_operand" "=r")
13620 + (umod:SI (match_dup 1)
13621 + (match_dup 2)))])
13622 + (use (match_dup 4))])]
13625 + if (can_create_pseudo_p ()) {
13626 + operands[4] = gen_reg_rtx (DImode);
13628 + emit_insn(gen_udivmodsi4_internal(operands[4],operands[1],operands[2]));
13629 + emit_move_insn(operands[0], gen_rtx_SUBREG( SImode, operands[4], 4));
13630 + emit_move_insn(operands[3], gen_rtx_SUBREG( SImode, operands[4], 0));
13638 +(define_insn "udivmodsi4_internal"
13639 + [(set (match_operand:DI 0 "register_operand" "=r")
13640 + (unspec:DI [(match_operand:SI 1 "register_operand" "r")
13641 + (match_operand:SI 2 "register_operand" "r")]
13642 + UNSPEC_UDIVMODSI4_INTERNAL))]
13644 + "divu %0, %1, %2"
13645 + [(set_attr "type" "div")
13646 + (set_attr "cc" "none")])
13649 +;;=============================================================================
13650 +;; Arithmetic-shift left
13651 +;;-----------------------------------------------------------------------------
13652 +;; Arithmetic-shift reg0 left by reg2 or immediate value.
13653 +;;=============================================================================
13655 +(define_insn "ashlsi3"
13656 + [(set (match_operand:SI 0 "register_operand" "=r,r,r")
13657 + (ashift:SI (match_operand:SI 1 "register_operand" "r,0,r")
13658 + (match_operand:SI 2 "register_const_int_operand" "r,Ku05,Ku05")))]
13664 + [(set_attr "length" "4,2,4")
13665 + (set_attr "cc" "set_ncz")])
13667 +;;=============================================================================
13668 +;; Arithmetic-shift right
13669 +;;-----------------------------------------------------------------------------
13670 +;; Arithmetic-shift reg0 right by an immediate value.
13671 +;;=============================================================================
13673 +(define_insn "ashrsi3"
13674 + [(set (match_operand:SI 0 "register_operand" "=r,r,r")
13675 + (ashiftrt:SI (match_operand:SI 1 "register_operand" "r,0,r")
13676 + (match_operand:SI 2 "register_const_int_operand" "r,Ku05,Ku05")))]
13682 + [(set_attr "length" "4,2,4")
13683 + (set_attr "cc" "set_ncz")])
13685 +;;=============================================================================
13686 +;; Logical shift right
13687 +;;-----------------------------------------------------------------------------
13688 +;; Logical shift reg0 right by an immediate value.
13689 +;;=============================================================================
13691 +(define_insn "lshrsi3"
13692 + [(set (match_operand:SI 0 "register_operand" "=r,r,r")
13693 + (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,0,r")
13694 + (match_operand:SI 2 "register_const_int_operand" "r,Ku05,Ku05")))]
13700 + [(set_attr "length" "4,2,4")
13701 + (set_attr "cc" "set_ncz")])
13704 +;;=============================================================================
13706 +;;-----------------------------------------------------------------------------
13707 +;; Negate operand 1 and store the result in operand 0.
13708 +;;=============================================================================
13709 +(define_insn "negsi2"
13710 + [(set (match_operand:SI 0 "register_operand" "=r,r")
13711 + (neg:SI (match_operand:SI 1 "register_operand" "0,r")))]
13716 + [(set_attr "length" "2,4")
13717 + (set_attr "cc" "set_vncz")])
13719 +(define_insn "negsi2_predicable"
13720 + [(set (match_operand:SI 0 "register_operand" "+r")
13721 + (neg:SI (match_dup 0)))]
13722 + "TARGET_V2_INSNS"
13724 + [(set_attr "length" "4")
13725 + (set_attr "cc" "cmp_cond_insn")
13726 + (set_attr "predicable" "yes")])
13728 +;;=============================================================================
13730 +;;-----------------------------------------------------------------------------
13731 +;; Store the absolute value of operand 1 into operand 0.
13732 +;;=============================================================================
13733 +(define_insn "abssi2"
13734 + [(set (match_operand:SI 0 "register_operand" "=r")
13735 + (abs:SI (match_operand:SI 1 "register_operand" "0")))]
13738 + [(set_attr "length" "2")
13739 + (set_attr "cc" "set_z")])
13742 +;;=============================================================================
13744 +;;-----------------------------------------------------------------------------
13745 +;; Store the bitwise-complement of operand 1 into operand 0.
13746 +;;=============================================================================
13748 +(define_insn "one_cmplsi2"
13749 + [(set (match_operand:SI 0 "register_operand" "=r,r")
13750 + (not:SI (match_operand:SI 1 "register_operand" "0,r")))]
13754 + rsub\t%0, %1, -1"
13755 + [(set_attr "length" "2,4")
13756 + (set_attr "cc" "set_z")])
13759 +(define_insn "one_cmplsi2_predicable"
13760 + [(set (match_operand:SI 0 "register_operand" "+r")
13761 + (not:SI (match_dup 0)))]
13762 + "TARGET_V2_INSNS"
13764 + [(set_attr "length" "4")
13765 + (set_attr "cc" "cmp_cond_insn")
13766 + (set_attr "predicable" "yes")])
13769 +;;=============================================================================
13771 +;;-----------------------------------------------------------------------------
13772 +;; Load a bit into Z and C flags
13773 +;;=============================================================================
13774 +(define_insn "bldsi"
13776 + (and:SI (match_operand:SI 0 "register_operand" "r")
13777 + (match_operand:SI 1 "one_bit_set_operand" "i")))]
13780 + [(set_attr "length" "4")
13781 + (set_attr "cc" "bld")]
13785 +;;=============================================================================
13787 +;;-----------------------------------------------------------------------------
13788 +;; Compare reg0 with reg1 or an immediate value.
13789 +;;=============================================================================
13791 +(define_expand "cmp<mode>"
13794 + (match_operand:CMP 0 "register_operand" "")
13795 + (match_operand:CMP 1 "<CMP:cmp_predicate>" "")))]
13798 + avr32_compare_op0 = operands[0];
13799 + avr32_compare_op1 = operands[1];
13803 +(define_insn "cmp<mode>_internal"
13806 + (match_operand:CMP 0 "register_operand" "r")
13807 + (match_operand:CMP 1 "<CMP:cmp_predicate>" "<CMP:cmp_constraint>")))]
13810 + /* Check if the next insn already will output a compare. */
13811 + if (!next_insn_emits_cmp (insn))
13812 + set_next_insn_cond(insn,
13813 + avr32_output_cmp(get_next_insn_cond(insn), GET_MODE (operands[0]), operands[0], operands[1]));
13816 + [(set_attr "length" "4")
13817 + (set_attr "cc" "compare")])
13819 +(define_expand "cmpsf"
13822 + (match_operand:SF 0 "general_operand" "")
13823 + (match_operand:SF 1 "general_operand" "")))]
13824 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
13827 + if ( !REG_P(operands[0]) )
13828 + operands[0] = force_reg(SFmode, operands[0]);
13830 + if ( !REG_P(operands[1]) )
13831 + operands[1] = force_reg(SFmode, operands[1]);
13833 + avr32_compare_op0 = operands[0];
13834 + avr32_compare_op1 = operands[1];
13835 + emit_insn(gen_cmpsf_internal_uc3fp(operands[0], operands[1]));
13840 +;;;=============================================================================
13842 +;;-----------------------------------------------------------------------------
13843 +;; Compare reg against zero and set the condition codes.
13844 +;;=============================================================================
13847 +(define_expand "tstsi"
13849 + (match_operand:SI 0 "register_operand" ""))]
13852 + avr32_compare_op0 = operands[0];
13853 + avr32_compare_op1 = const0_rtx;
13857 +(define_insn "tstsi_internal"
13859 + (match_operand:SI 0 "register_operand" "r"))]
13862 + /* Check if the next insn already will output a compare. */
13863 + if (!next_insn_emits_cmp (insn))
13864 + set_next_insn_cond(insn,
13865 + avr32_output_cmp(get_next_insn_cond(insn), SImode, operands[0], const0_rtx));
13869 + [(set_attr "length" "2")
13870 + (set_attr "cc" "compare")])
13873 +(define_expand "tstdi"
13875 + (match_operand:DI 0 "register_operand" ""))]
13878 + avr32_compare_op0 = operands[0];
13879 + avr32_compare_op1 = const0_rtx;
13883 +(define_insn "tstdi_internal"
13885 + (match_operand:DI 0 "register_operand" "r"))]
13888 + /* Check if the next insn already will output a compare. */
13889 + if (!next_insn_emits_cmp (insn))
13890 + set_next_insn_cond(insn,
13891 + avr32_output_cmp(get_next_insn_cond(insn), DImode, operands[0], const0_rtx));
13894 + [(set_attr "length" "4")
13895 + (set_attr "type" "alu2")
13896 + (set_attr "cc" "compare")])
13900 +;;=============================================================================
13901 +;; Convert operands
13902 +;;-----------------------------------------------------------------------------
13904 +;;=============================================================================
13905 +(define_insn "truncdisi2"
13906 + [(set (match_operand:SI 0 "general_operand" "")
13907 + (truncate:SI (match_operand:DI 1 "general_operand" "")))]
13911 +;;=============================================================================
13913 +;;-----------------------------------------------------------------------------
13915 +;;=============================================================================
13918 +(define_insn "extendhisi2"
13919 + [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
13920 + (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "0,r,<RKu00>,m")))]
13923 + switch ( which_alternative ){
13925 + return "casts.h\t%0";
13927 + return "bfexts\t%0, %1, 0, 16";
13930 + return "ld.sh\t%0, %1";
13935 + [(set_attr "length" "2,4,2,4")
13936 + (set_attr "cc" "set_ncz,set_ncz,none,none")
13937 + (set_attr "type" "alu,alu,load_rm,load_rm")])
13939 +(define_insn "extendqisi2"
13940 + [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
13941 + (sign_extend:SI (match_operand:QI 1 "extendqi_operand" "0,r,RKu00,m")))]
13944 + switch ( which_alternative ){
13946 + return "casts.b\t%0";
13948 + return "bfexts\t%0, %1, 0, 8";
13951 + return "ld.sb\t%0, %1";
13956 + [(set_attr "length" "2,4,2,4")
13957 + (set_attr "cc" "set_ncz,set_ncz,none,none")
13958 + (set_attr "type" "alu,alu,load_rm,load_rm")])
13960 +(define_insn "extendqihi2"
13961 + [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
13962 + (sign_extend:HI (match_operand:QI 1 "extendqi_operand" "0,r,RKu00,m")))]
13965 + switch ( which_alternative ){
13967 + return "casts.b\t%0";
13969 + return "bfexts\t%0, %1, 0, 8";
13972 + return "ld.sb\t%0, %1";
13977 + [(set_attr "length" "2,4,2,4")
13978 + (set_attr "cc" "set_ncz,set_ncz,none,none")
13979 + (set_attr "type" "alu,alu,load_rm,load_rm")])
13982 +;;=============================================================================
13984 +;;-----------------------------------------------------------------------------
13986 +;;=============================================================================
13988 +(define_insn "zero_extendhisi2"
13989 + [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
13990 + (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "0,r,<RKu00>,m")))]
13993 + switch ( which_alternative ){
13995 + return "castu.h\t%0";
13997 + return "bfextu\t%0, %1, 0, 16";
14000 + return "ld.uh\t%0, %1";
14006 + [(set_attr "length" "2,4,2,4")
14007 + (set_attr "cc" "set_ncz,set_ncz,none,none")
14008 + (set_attr "type" "alu,alu,load_rm,load_rm")])
14010 +(define_insn "zero_extendqisi2"
14011 + [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
14012 + (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,r,<RKu00>,m")))]
14015 + switch ( which_alternative ){
14017 + return "castu.b\t%0";
14019 + return "bfextu\t%0, %1, 0, 8";
14022 + return "ld.ub\t%0, %1";
14027 + [(set_attr "length" "2,4,2,4")
14028 + (set_attr "cc" "set_ncz, set_ncz, none, none")
14029 + (set_attr "type" "alu, alu, load_rm, load_rm")])
14031 +(define_insn "zero_extendqihi2"
14032 + [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
14033 + (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,r,<RKu00>,m")))]
14036 + switch ( which_alternative ){
14038 + return "castu.b\t%0";
14040 + return "bfextu\t%0, %1, 0, 8";
14043 + return "ld.ub\t%0, %1";
14048 + [(set_attr "length" "2,4,2,4")
14049 + (set_attr "cc" "set_ncz, set_ncz, none, none")
14050 + (set_attr "type" "alu, alu, load_rm, load_rm")])
14053 +;;=============================================================================
14054 +;; Conditional load and extend insns
14055 +;;=============================================================================
14056 +(define_insn "ldsi<mode>_predicable_se"
14057 + [(set (match_operand:SI 0 "register_operand" "=r")
14059 + (match_operand:INTM 1 "memory_operand" "<INTM:pred_mem_constraint>")))]
14060 + "TARGET_V2_INSNS"
14061 + "ld<INTM:load_postfix_s>%?\t%0, %1"
14062 + [(set_attr "length" "4")
14063 + (set_attr "cc" "cmp_cond_insn")
14064 + (set_attr "type" "load")
14065 + (set_attr "predicable" "yes")]
14068 +(define_insn "ldsi<mode>_predicable_ze"
14069 + [(set (match_operand:SI 0 "register_operand" "=r")
14071 + (match_operand:INTM 1 "memory_operand" "<INTM:pred_mem_constraint>")))]
14072 + "TARGET_V2_INSNS"
14073 + "ld<INTM:load_postfix_u>%?\t%0, %1"
14074 + [(set_attr "length" "4")
14075 + (set_attr "cc" "cmp_cond_insn")
14076 + (set_attr "type" "load")
14077 + (set_attr "predicable" "yes")]
14080 +(define_insn "ldhi_predicable_ze"
14081 + [(set (match_operand:HI 0 "register_operand" "=r")
14083 + (match_operand:QI 1 "memory_operand" "RKs10")))]
14084 + "TARGET_V2_INSNS"
14085 + "ld.ub%?\t%0, %1"
14086 + [(set_attr "length" "4")
14087 + (set_attr "cc" "cmp_cond_insn")
14088 + (set_attr "type" "load")
14089 + (set_attr "predicable" "yes")]
14092 +(define_insn "ldhi_predicable_se"
14093 + [(set (match_operand:HI 0 "register_operand" "=r")
14095 + (match_operand:QI 1 "memory_operand" "RKs10")))]
14096 + "TARGET_V2_INSNS"
14097 + "ld.sb%?\t%0, %1"
14098 + [(set_attr "length" "4")
14099 + (set_attr "cc" "cmp_cond_insn")
14100 + (set_attr "type" "load")
14101 + (set_attr "predicable" "yes")]
14104 +;;=============================================================================
14105 +;; Conditional set register
14107 +;;-----------------------------------------------------------------------------
14109 +;;Because of the same issue as with conditional moves and adds we must
14110 +;;not separate the compare instrcution from the scc instruction as
14111 +;;they might be sheduled "badly".
14113 +(define_insn "s<code>"
14114 + [(set (match_operand:SI 0 "register_operand" "=r")
14115 + (any_cond:SI (cc0)
14119 + [(set_attr "length" "2")
14120 + (set_attr "cc" "none")])
14122 +(define_insn "smi"
14123 + [(set (match_operand:SI 0 "register_operand" "=r")
14124 + (unspec:SI [(cc0)
14125 + (const_int 0)] UNSPEC_COND_MI))]
14128 + [(set_attr "length" "2")
14129 + (set_attr "cc" "none")])
14131 +(define_insn "spl"
14132 + [(set (match_operand:SI 0 "register_operand" "=r")
14133 + (unspec:SI [(cc0)
14134 + (const_int 0)] UNSPEC_COND_PL))]
14137 + [(set_attr "length" "2")
14138 + (set_attr "cc" "none")])
14141 +;;=============================================================================
14142 +;; Conditional branch
14143 +;;-----------------------------------------------------------------------------
14144 +;; Branch to label if the specified condition codes are set.
14145 +;;=============================================================================
14146 +; branch if negative
14147 +(define_insn "bmi"
14149 + (if_then_else (unspec:CC [(cc0) (const_int 0)] UNSPEC_COND_MI)
14150 + (label_ref (match_operand 0 "" ""))
14154 + [(set_attr "type" "branch")
14155 + (set (attr "length")
14156 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
14157 + (le (minus (pc) (match_dup 0)) (const_int 256)))
14158 + (const_int 2)] ; use compact branch
14159 + (const_int 4))) ; use extended branch
14160 + (set_attr "cc" "none")])
14162 +(define_insn "*bmi-reverse"
14164 + (if_then_else (unspec:CC [(cc0) (const_int 0)] UNSPEC_COND_MI)
14166 + (label_ref (match_operand 0 "" ""))))]
14169 + [(set_attr "type" "branch")
14170 + (set (attr "length")
14171 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
14172 + (le (minus (pc) (match_dup 0)) (const_int 256)))
14173 + (const_int 2)] ; use compact branch
14174 + (const_int 4))) ; use extended branch
14175 + (set_attr "cc" "none")])
14177 +; branch if positive
14178 +(define_insn "bpl"
14180 + (if_then_else (unspec:CC [(cc0) (const_int 0)] UNSPEC_COND_PL)
14181 + (label_ref (match_operand 0 "" ""))
14185 + [(set_attr "type" "branch")
14186 + (set (attr "length")
14187 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
14188 + (le (minus (pc) (match_dup 0)) (const_int 256)))
14189 + (const_int 2)] ; use compact branch
14190 + (const_int 4))) ; use extended branch
14191 + (set_attr "cc" "none")])
14193 +(define_insn "*bpl-reverse"
14195 + (if_then_else (unspec:CC [(cc0) (const_int 0)] UNSPEC_COND_PL)
14197 + (label_ref (match_operand 0 "" ""))))]
14200 + [(set_attr "type" "branch")
14201 + (set (attr "length")
14202 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
14203 + (le (minus (pc) (match_dup 0)) (const_int 256)))
14204 + (const_int 2)] ; use compact branch
14205 + (const_int 4))) ; use extended branch
14206 + (set_attr "cc" "none")])
14209 +(define_insn "b<code>"
14211 + (if_then_else (any_cond:CC (cc0)
14213 + (label_ref (match_operand 0 "" ""))
14217 + [(set_attr "type" "branch")
14218 + (set (attr "length")
14219 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
14220 + (le (minus (pc) (match_dup 0)) (const_int 256)))
14221 + (const_int 2)] ; use compact branch
14222 + (const_int 4))) ; use extended branch
14223 + (set_attr "cc" "none")])
14226 +(define_insn "*b<code>-reverse"
14228 + (if_then_else (any_cond:CC (cc0)
14231 + (label_ref (match_operand 0 "" ""))))]
14233 + "br<invcond> %0 "
14234 + [(set_attr "type" "branch")
14235 + (set (attr "length")
14236 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
14237 + (le (minus (pc) (match_dup 0)) (const_int 256)))
14238 + (const_int 2)] ; use compact branch
14239 + (const_int 4))) ; use extended branch
14240 + (set_attr "cc" "none")])
14244 +;=============================================================================
14245 +; Conditional Add/Subtract
14246 +;-----------------------------------------------------------------------------
14247 +; sub{cond4} Rd, imm
14248 +;=============================================================================
14251 +(define_expand "add<mode>cc"
14252 + [(set (match_operand:ADDCC 0 "register_operand" "")
14253 + (if_then_else:ADDCC (match_operator 1 "avr32_comparison_operator"
14256 + (match_operand:ADDCC 2 "register_operand" "")
14259 + (match_operand:ADDCC 3 "" ""))))]
14262 + if ( !(GET_CODE (operands[3]) == CONST_INT
14263 + || (TARGET_V2_INSNS && REG_P(operands[3]))) ){
14267 + /* Delete compare instruction as it is merged into this instruction */
14268 + remove_insn (get_last_insn_anywhere ());
14270 + operands[4] = avr32_compare_op0;
14271 + operands[5] = avr32_compare_op1;
14273 + if ( TARGET_V2_INSNS
14274 + && REG_P(operands[3])
14275 + && REGNO(operands[0]) != REGNO(operands[2]) ){
14276 + emit_move_insn (operands[0], operands[2]);
14277 + operands[2] = operands[0];
14282 +(define_insn "add<ADDCC:mode>cc_cmp<CMP:mode>_reg"
14283 + [(set (match_operand:ADDCC 0 "register_operand" "=r")
14284 + (if_then_else:ADDCC (match_operator 1 "avr32_comparison_operator"
14285 + [(match_operand:CMP 4 "register_operand" "r")
14286 + (match_operand:CMP 5 "<CMP:cmp_predicate>" "<CMP:cmp_constraint>")])
14289 + (match_operand:ADDCC 2 "register_operand" "r")
14290 + (match_operand:ADDCC 3 "register_operand" "r"))))]
14291 + "TARGET_V2_INSNS"
14293 + operands[1] = avr32_output_cmp(operands[1], GET_MODE(operands[4]), operands[4], operands[5]);
14294 + return "add%i1\t%0, %2, %3";
14296 + [(set_attr "length" "8")
14297 + (set_attr "cc" "cmp_cond_insn")])
14299 +(define_insn "add<ADDCC:mode>cc_cmp<CMP:mode>"
14300 + [(set (match_operand:ADDCC 0 "register_operand" "=r")
14301 + (if_then_else:ADDCC (match_operator 1 "avr32_comparison_operator"
14302 + [(match_operand:CMP 4 "register_operand" "r")
14303 + (match_operand:CMP 5 "<CMP:cmp_predicate>" "<CMP:cmp_constraint>")])
14304 + (match_operand:ADDCC 2 "register_operand" "0")
14307 + (match_operand:ADDCC 3 "avr32_cond_immediate_operand" "Is08"))))]
14310 + operands[1] = avr32_output_cmp(operands[1], GET_MODE(operands[4]), operands[4], operands[5]);
14311 + return "sub%i1\t%0, -%3";
14313 + [(set_attr "length" "8")
14314 + (set_attr "cc" "cmp_cond_insn")])
14316 +;=============================================================================
14317 +; Conditional Move
14318 +;-----------------------------------------------------------------------------
14319 +; mov{cond4} Rd, (Rs/imm)
14320 +;=============================================================================
14321 +(define_expand "mov<mode>cc"
14322 + [(set (match_operand:MOVCC 0 "register_operand" "")
14323 + (if_then_else:MOVCC (match_operator 1 "avr32_comparison_operator"
14326 + (match_operand:MOVCC 2 "avr32_cond_register_immediate_operand" "")
14327 + (match_operand:MOVCC 3 "avr32_cond_register_immediate_operand" "")))]
14330 + /* Delete compare instruction as it is merged into this instruction */
14331 + remove_insn (get_last_insn_anywhere ());
14333 + operands[4] = avr32_compare_op0;
14334 + operands[5] = avr32_compare_op1;
14339 +(define_insn "mov<MOVCC:mode>cc_cmp<CMP:mode>"
14340 + [(set (match_operand:MOVCC 0 "register_operand" "=r,r,r")
14341 + (if_then_else:MOVCC (match_operator 1 "avr32_comparison_operator"
14342 + [(match_operand:CMP 4 "register_operand" "r,r,r")
14343 + (match_operand:CMP 5 "<CMP:cmp_predicate>" "<CMP:cmp_constraint>,<CMP:cmp_constraint>,<CMP:cmp_constraint>")])
14344 + (match_operand:MOVCC 2 "avr32_cond_register_immediate_operand" "0, rKs08,rKs08")
14345 + (match_operand:MOVCC 3 "avr32_cond_register_immediate_operand" "rKs08,0,rKs08")))]
14348 + operands[1] = avr32_output_cmp(operands[1], GET_MODE(operands[4]), operands[4], operands[5]);
14350 + switch( which_alternative ){
14352 + return "mov%i1 %0, %3";
14354 + return "mov%1 %0, %2";
14356 + return "mov%1 %0, %2\;mov%i1 %0, %3";
14362 + [(set_attr "length" "8,8,12")
14363 + (set_attr "cc" "cmp_cond_insn")])
14368 +;;=============================================================================
14370 +;;-----------------------------------------------------------------------------
14371 +;; Jump inside a function; an unconditional branch to a label.
14372 +;;=============================================================================
14373 +(define_insn "jump"
14375 + (label_ref (match_operand 0 "" "")))]
14378 + if (get_attr_length(insn) > 4)
14379 + return "Can't jump this far";
14380 + return (get_attr_length(insn) == 2 ?
14381 + "rjmp %0" : "bral %0");
14383 + [(set_attr "type" "branch")
14384 + (set (attr "length")
14385 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 1022))
14386 + (le (minus (pc) (match_dup 0)) (const_int 1024)))
14387 + (const_int 2) ; use rjmp
14388 + (le (match_dup 0) (const_int 1048575))
14389 + (const_int 4)] ; use bral
14390 + (const_int 8))) ; do something else
14391 + (set_attr "cc" "none")])
14393 +;;=============================================================================
14395 +;;-----------------------------------------------------------------------------
14396 +;; Subroutine call instruction returning no value.
14397 +;;=============================================================================
14398 +(define_insn "call_internal"
14399 + [(parallel [(call (mem:SI (match_operand:SI 0 "avr32_call_operand" "r,U,T,W"))
14400 + (match_operand 1 "" ""))
14401 + (clobber (reg:SI LR_REGNUM))])]
14405 + /* Check for a flashvault call. */
14406 + if (avr32_flashvault_call (SYMBOL_REF_DECL (operands[0])))
14408 + /* Assembly is already emitted. */
14412 + switch (which_alternative) {
14414 + return "icall\t%0";
14416 + return "rcall\t%0";
14418 + return "mcall\t%0";
14420 + if (TARGET_HAS_ASM_ADDR_PSEUDOS)
14421 + return "call\t%0";
14423 + return "mcall\tr6[%0@got]";
14428 + [(set_attr "type" "call")
14429 + (set_attr "length" "2,4,4,10")
14430 + (set_attr "cc" "clobber")])
14433 +(define_expand "call"
14434 + [(parallel [(call (match_operand:SI 0 "" "")
14435 + (match_operand 1 "" ""))
14436 + (clobber (reg:SI LR_REGNUM))])]
14439 + rtx call_address;
14440 + if ( GET_CODE(operands[0]) != MEM )
14443 + call_address = XEXP(operands[0], 0);
14445 + /* If assembler supports call pseudo insn and the call address is a symbol then nothing special needs to be done. */
14446 + if (TARGET_HAS_ASM_ADDR_PSEUDOS && (GET_CODE(call_address) == SYMBOL_REF) )
14448 + /* We must however mark the function as using the GOT if flag_pic is set, since the call insn might turn into a mcall using the GOT ptr register. */
14451 + current_function_uses_pic_offset_table = 1;
14452 + emit_call_insn(gen_call_internal(call_address, operands[1]));
14458 + if (flag_pic && GET_CODE(call_address) == SYMBOL_REF )
14460 + current_function_uses_pic_offset_table = 1;
14461 + emit_call_insn(gen_call_internal(call_address, operands[1]));
14465 + if (!SYMBOL_REF_RCALL_FUNCTION_P(operands[0]) )
14467 + if (optimize_size && GET_CODE(call_address) == SYMBOL_REF )
14469 + call_address = force_const_mem(SImode, call_address);
14473 + call_address = force_reg(SImode, call_address);
14477 + emit_call_insn(gen_call_internal(call_address, operands[1]));
14483 +;;=============================================================================
14485 +;;-----------------------------------------------------------------------------
14486 +;; Subroutine call instruction returning a value.
14487 +;;=============================================================================
14488 +(define_expand "call_value"
14489 + [(parallel [(set (match_operand:SI 0 "" "")
14490 + (call (match_operand:SI 1 "" "")
14491 + (match_operand 2 "" "")))
14492 + (clobber (reg:SI LR_REGNUM))])]
14495 + rtx call_address;
14496 + if ( GET_CODE(operands[1]) != MEM )
14499 + call_address = XEXP(operands[1], 0);
14501 + /* Check for a flashvault call.
14502 + if (GET_CODE (call_address) == SYMBOL_REF
14503 + && avr32_flashvault_call (SYMBOL_REF_DECL (call_address)))
14508 + /* If assembler supports call pseudo insn and the call
14509 + address is a symbol then nothing special needs to be done. */
14510 + if ( TARGET_HAS_ASM_ADDR_PSEUDOS
14511 + && (GET_CODE(call_address) == SYMBOL_REF) ){
14512 + /* We must however mark the function as using the GOT if
14513 + flag_pic is set, since the call insn might turn into
14514 + a mcall using the GOT ptr register. */
14515 + if ( flag_pic ) {
14516 + current_function_uses_pic_offset_table = 1;
14517 + emit_call_insn(gen_call_value_internal(operands[0], call_address, operands[2]));
14522 + GET_CODE(call_address) == SYMBOL_REF ){
14523 + current_function_uses_pic_offset_table = 1;
14524 + emit_call_insn(gen_call_value_internal(operands[0], call_address, operands[2]));
14528 + if ( !SYMBOL_REF_RCALL_FUNCTION_P(operands[1]) ){
14529 + if ( optimize_size &&
14530 + GET_CODE(call_address) == SYMBOL_REF){
14531 + call_address = force_const_mem(SImode, call_address);
14533 + call_address = force_reg(SImode, call_address);
14537 + emit_call_insn(gen_call_value_internal(operands[0], call_address,
14543 +(define_insn "call_value_internal"
14544 + [(parallel [(set (match_operand 0 "register_operand" "=r,r,r,r")
14545 + (call (mem:SI (match_operand:SI 1 "avr32_call_operand" "r,U,T,W"))
14546 + (match_operand 2 "" "")))
14547 + (clobber (reg:SI LR_REGNUM))])]
14548 + ;; Operand 2 not used on the AVR32.
14551 + /* Check for a flashvault call. */
14552 + if (avr32_flashvault_call (SYMBOL_REF_DECL (operands[1])))
14554 + /* Assembly is already emitted. */
14559 + switch (which_alternative) {
14561 + return "icall\t%1";
14563 + return "rcall\t%1";
14565 + return "mcall\t%1";
14567 + if ( TARGET_HAS_ASM_ADDR_PSEUDOS )
14568 + return "call\t%1";
14570 + return "mcall\tr6[%1@got]";
14575 + [(set_attr "type" "call")
14576 + (set_attr "length" "2,4,4,10")
14577 + (set_attr "cc" "call_set")])
14580 +;;=============================================================================
14582 +;;-----------------------------------------------------------------------------
14583 +;; Subrutine call instruction returning a value of any type.
14584 +;; The code is copied from m68k.md (except gen_blockage is removed)
14586 +;;=============================================================================
14587 +(define_expand "untyped_call"
14588 + [(parallel [(call (match_operand 0 "avr32_call_operand" "")
14590 + (match_operand 1 "" "")
14591 + (match_operand 2 "" "")])]
14596 + emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
14598 + for (i = 0; i < XVECLEN (operands[2], 0); i++) {
14599 + rtx set = XVECEXP (operands[2], 0, i);
14600 + emit_move_insn (SET_DEST (set), SET_SRC (set));
14603 + /* The optimizer does not know that the call sets the function value
14604 + registers we stored in the result block. We avoid problems by
14605 + claiming that all hard registers are used and clobbered at this
14607 + emit_insn (gen_blockage ());
14613 +;;=============================================================================
14615 +;;=============================================================================
14617 +(define_insn "return"
14619 + "USE_RETURN_INSN (FALSE)"
14621 + avr32_output_return_instruction(TRUE, FALSE, NULL, NULL);
14624 + [(set_attr "length" "4")
14625 + (set_attr "type" "call")]
14629 +(define_insn "return_cond"
14631 + (if_then_else (match_operand 0 "avr32_comparison_operand" "")
14634 + "USE_RETURN_INSN (TRUE)"
14636 + [(set_attr "type" "call")])
14638 +(define_insn "return_cond_predicable"
14640 + "USE_RETURN_INSN (TRUE)"
14642 + [(set_attr "type" "call")
14643 + (set_attr "predicable" "yes")])
14646 +(define_insn "return_imm"
14647 + [(parallel [(set (reg RETVAL_REGNUM) (match_operand 0 "immediate_operand" "i"))
14648 + (use (reg RETVAL_REGNUM))
14650 + "USE_RETURN_INSN (FALSE) &&
14651 + ((INTVAL(operands[0]) == -1) || (INTVAL(operands[0]) == 0) || (INTVAL(operands[0]) == 1))"
14653 + avr32_output_return_instruction(TRUE, FALSE, NULL, operands[0]);
14656 + [(set_attr "length" "4")
14657 + (set_attr "type" "call")]
14660 +(define_insn "return_imm_cond"
14661 + [(parallel [(set (reg RETVAL_REGNUM) (match_operand 0 "immediate_operand" "i"))
14662 + (use (reg RETVAL_REGNUM))
14664 + (if_then_else (match_operand 1 "avr32_comparison_operand" "")
14667 + "USE_RETURN_INSN (TRUE) &&
14668 + ((INTVAL(operands[0]) == -1) || (INTVAL(operands[0]) == 0) || (INTVAL(operands[0]) == 1))"
14670 + [(set_attr "type" "call")]
14673 +(define_insn "return_imm_predicable"
14674 + [(parallel [(set (reg RETVAL_REGNUM) (match_operand 0 "immediate_operand" "i"))
14675 + (use (reg RETVAL_REGNUM))
14677 + "USE_RETURN_INSN (TRUE) &&
14678 + ((INTVAL(operands[0]) == -1) || (INTVAL(operands[0]) == 0) || (INTVAL(operands[0]) == 1))"
14680 + [(set_attr "type" "call")
14681 + (set_attr "predicable" "yes")])
14683 +(define_insn "return_<mode>reg"
14684 + [(set (reg RETVAL_REGNUM) (match_operand:MOVM 0 "register_operand" "r"))
14685 + (use (reg RETVAL_REGNUM))
14687 + "USE_RETURN_INSN (TRUE)"
14689 + [(set_attr "type" "call")
14690 + (set_attr "predicable" "yes")])
14692 +(define_insn "return_<mode>reg_cond"
14693 + [(set (reg RETVAL_REGNUM) (match_operand:MOVM 0 "register_operand" "r"))
14694 + (use (reg RETVAL_REGNUM))
14696 + (if_then_else (match_operator 1 "avr32_comparison_operator"
14697 + [(cc0) (const_int 0)])
14700 + "USE_RETURN_INSN (TRUE)"
14702 + [(set_attr "type" "call")])
14704 +;;=============================================================================
14705 +;; nonlocal_goto_receiver
14706 +;;-----------------------------------------------------------------------------
14707 +;; For targets with a return stack we must make sure to flush the return stack
14708 +;; since it will be corrupt after a nonlocal goto.
14709 +;;=============================================================================
14710 +(define_expand "nonlocal_goto_receiver"
14712 + "TARGET_RETURN_STACK"
14715 + emit_insn ( gen_frs() );
14722 +;;=============================================================================
14723 +;; builtin_setjmp_receiver
14724 +;;-----------------------------------------------------------------------------
14725 +;; For pic code we need to reload the pic register.
14726 +;; For targets with a return stack we must make sure to flush the return stack
14727 +;; since it will probably be corrupted.
14728 +;;=============================================================================
14729 +(define_expand "builtin_setjmp_receiver"
14730 + [(label_ref (match_operand 0 "" ""))]
14734 + if ( TARGET_RETURN_STACK )
14735 + emit_insn ( gen_frs() );
14737 + avr32_load_pic_register ();
14744 +;;=============================================================================
14746 +;;-----------------------------------------------------------------------------
14747 +;; Jump to an address in reg or memory.
14748 +;;=============================================================================
14749 +(define_expand "indirect_jump"
14751 + (match_operand:SI 0 "general_operand" ""))]
14754 + /* One of the ops has to be in a register. */
14755 + if ( (flag_pic || TARGET_HAS_ASM_ADDR_PSEUDOS )
14756 + && !avr32_legitimate_pic_operand_p(operands[0]) )
14757 + operands[0] = legitimize_pic_address (operands[0], SImode, 0);
14758 + else if ( flag_pic && avr32_address_operand(operands[0], GET_MODE(operands[0])) )
14759 + /* If we have an address operand then this function uses the pic register. */
14760 + current_function_uses_pic_offset_table = 1;
14764 +(define_insn "indirect_jump_internal"
14766 + (match_operand:SI 0 "avr32_non_rmw_general_operand" "r,m,W"))]
14769 + switch( which_alternative ){
14771 + return "mov\tpc, %0";
14773 + if ( avr32_const_pool_ref_operand(operands[0], GET_MODE(operands[0])) )
14774 + return "lddpc\tpc, %0";
14776 + return "ld.w\tpc, %0";
14779 + return "ld.w\tpc, r6[%0@got]";
14781 + return "lda.w\tpc, %0";
14786 + [(set_attr "length" "2,4,8")
14787 + (set_attr "type" "call,call,call")
14788 + (set_attr "cc" "none,none,clobber")])
14792 +;;=============================================================================
14793 +;; casesi and tablejump
14794 +;;=============================================================================
14795 +(define_insn "tablejump_add"
14797 + (plus:SI (match_operand:SI 0 "register_operand" "r")
14798 + (mult:SI (match_operand:SI 1 "register_operand" "r")
14799 + (match_operand:SI 2 "immediate_operand" "Ku04" ))))
14800 + (use (label_ref (match_operand 3 "" "")))]
14802 + ((INTVAL(operands[2]) == 0) || (INTVAL(operands[2]) == 2) ||
14803 + (INTVAL(operands[2]) == 4) || (INTVAL(operands[2]) == 8))"
14804 + "add\tpc, %0, %1 << %p2"
14805 + [(set_attr "length" "4")
14806 + (set_attr "cc" "clobber")])
14808 +(define_insn "tablejump_insn"
14809 + [(set (pc) (match_operand:SI 0 "memory_operand" "m"))
14810 + (use (label_ref (match_operand 1 "" "")))]
14813 + [(set_attr "length" "4")
14814 + (set_attr "type" "call")
14815 + (set_attr "cc" "none")])
14817 +(define_expand "casesi"
14818 + [(match_operand:SI 0 "register_operand" "") ; index to jump on
14819 + (match_operand:SI 1 "const_int_operand" "") ; lower bound
14820 + (match_operand:SI 2 "const_int_operand" "") ; total range
14821 + (match_operand:SI 3 "" "") ; table label
14822 + (match_operand:SI 4 "" "")] ; Out of range label
14827 + rtx index = operands[0];
14828 + rtx low_bound = operands[1];
14829 + rtx range = operands[2];
14830 + rtx table_label = operands[3];
14831 + rtx oor_label = operands[4];
14833 + index = force_reg ( SImode, index );
14834 + if (low_bound != const0_rtx)
14836 + if (!avr32_const_ok_for_constraint_p(INTVAL (low_bound), 'I', \"Is21\")){
14837 + reg = force_reg(SImode, GEN_INT (INTVAL (low_bound)));
14838 + emit_insn (gen_subsi3 (reg, index,
14841 + reg = gen_reg_rtx (SImode);
14842 + emit_insn (gen_addsi3 (reg, index,
14843 + GEN_INT (-INTVAL (low_bound))));
14848 + if (!avr32_const_ok_for_constraint_p (INTVAL (range), 'K', \"Ks21\"))
14849 + range = force_reg (SImode, range);
14851 + emit_cmp_and_jump_insns ( index, range, GTU, NULL_RTX, SImode, 1, oor_label );
14852 + reg = gen_reg_rtx (SImode);
14853 + emit_move_insn ( reg, gen_rtx_LABEL_REF (VOIDmode, table_label));
14856 + emit_jump_insn ( gen_tablejump_add ( reg, index, GEN_INT(4), table_label));
14859 + gen_tablejump_insn ( gen_rtx_MEM ( SImode,
14860 + gen_rtx_PLUS ( SImode,
14862 + gen_rtx_MULT ( SImode,
14872 +(define_insn "prefetch"
14873 + [(prefetch (match_operand:SI 0 "avr32_ks16_address_operand" "p")
14874 + (match_operand 1 "const_int_operand" "")
14875 + (match_operand 2 "const_int_operand" ""))]
14878 + return "pref\t%0";
14881 + [(set_attr "length" "4")
14882 + (set_attr "type" "load")
14883 + (set_attr "cc" "none")])
14887 +;;=============================================================================
14889 +;;-----------------------------------------------------------------------------
14890 +;; This pattern, if defined, emits RTL for entry to a function. The function
14891 +;; entry i responsible for setting up the stack frame, initializing the frame
14892 +;; pointer register, saving callee saved registers, etc.
14893 +;;=============================================================================
14894 +(define_expand "prologue"
14895 + [(clobber (const_int 0))]
14898 + avr32_expand_prologue();
14903 +;;=============================================================================
14905 +;;-----------------------------------------------------------------------------
14906 +;; This pattern, if defined, affects the way __builtin_eh_return, and
14907 +;; thence the call frame exception handling library routines, are
14908 +;; built. It is intended to handle non-trivial actions needed along
14909 +;; the abnormal return path.
14911 +;; The address of the exception handler to which the function should
14912 +;; return is passed as operand to this pattern. It will normally need
14913 +;; to copied by the pattern to some special register or memory
14914 +;; location. If the pattern needs to determine the location of the
14915 +;; target call frame in order to do so, it may use
14916 +;; EH_RETURN_STACKADJ_RTX, if defined; it will have already been
14919 +;; If this pattern is not defined, the default action will be to
14920 +;; simply copy the return address to EH_RETURN_HANDLER_RTX. Either
14921 +;; that macro or this pattern needs to be defined if call frame
14922 +;; exception handling is to be used.
14924 +;; We can't expand this before we know where the link register is stored.
14925 +(define_insn_and_split "eh_return"
14926 + [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")]
14927 + VUNSPEC_EH_RETURN)
14928 + (clobber (match_scratch:SI 1 "=&r"))]
14931 + "reload_completed"
14935 + avr32_set_return_address (operands[0], operands[1]);
14941 +;;=============================================================================
14943 +;;-----------------------------------------------------------------------------
14944 +(define_insn "ffssi2"
14945 + [ (set (match_operand:SI 0 "register_operand" "=r")
14946 + (ffs:SI (match_operand:SI 1 "register_operand" "r"))) ]
14954 + [(set_attr "length" "18")
14955 + (set_attr "cc" "clobber")]
14960 +;;=============================================================================
14962 +;;-----------------------------------------------------------------------------
14963 +(define_insn "*swap_h"
14964 + [ (set (match_operand:SI 0 "register_operand" "=r")
14965 + (ior:SI (ashift:SI (match_dup 0) (const_int 16))
14966 + (lshiftrt:SI (match_dup 0) (const_int 16))))]
14969 + [(set_attr "length" "2")]
14972 +(define_insn_and_split "bswap_16"
14973 + [ (set (match_operand:HI 0 "avr32_bswap_operand" "=r,RKs13,r")
14974 + (ior:HI (and:HI (lshiftrt:HI (match_operand:HI 1 "avr32_bswap_operand" "r,r,RKs13")
14977 + (ashift:HI (and:HI (match_dup 1)
14979 + (const_int 8))))]
14982 + switch ( which_alternative ){
14984 + if ( REGNO(operands[0]) == REGNO(operands[1]))
14985 + return "swap.bh\t%0";
14987 + return "mov\t%0, %1\;swap.bh\t%0";
14989 + return "stswp.h\t%0, %1";
14991 + return "ldswp.sh\t%0, %1";
14997 + "(reload_completed &&
14998 + REG_P(operands[0]) && REG_P(operands[1])
14999 + && (REGNO(operands[0]) != REGNO(operands[1])))"
15000 + [(set (match_dup 0) (match_dup 1))
15001 + (set (match_dup 0)
15002 + (ior:HI (and:HI (lshiftrt:HI (match_dup 0)
15005 + (ashift:HI (and:HI (match_dup 0)
15007 + (const_int 8))))]
15010 + [(set_attr "length" "4,4,4")
15011 + (set_attr "type" "alu,store,load_rm")]
15014 +(define_insn_and_split "bswap_32"
15015 + [ (set (match_operand:SI 0 "avr32_bswap_operand" "=r,RKs14,r")
15016 + (ior:SI (ior:SI (lshiftrt:SI (and:SI (match_operand:SI 1 "avr32_bswap_operand" "r,r,RKs14")
15017 + (const_int -16777216))
15019 + (lshiftrt:SI (and:SI (match_dup 1)
15020 + (const_int 16711680))
15022 + (ior:SI (ashift:SI (and:SI (match_dup 1)
15023 + (const_int 65280))
15025 + (ashift:SI (and:SI (match_dup 1)
15027 + (const_int 24)))))]
15030 + switch ( which_alternative ){
15032 + if ( REGNO(operands[0]) == REGNO(operands[1]))
15033 + return "swap.b\t%0";
15037 + return "stswp.w\t%0, %1";
15039 + return "ldswp.w\t%0, %1";
15044 + "(reload_completed &&
15045 + REG_P(operands[0]) && REG_P(operands[1])
15046 + && (REGNO(operands[0]) != REGNO(operands[1])))"
15047 + [(set (match_dup 0) (match_dup 1))
15048 + (set (match_dup 0)
15049 + (ior:SI (ior:SI (lshiftrt:SI (and:SI (match_dup 0)
15050 + (const_int -16777216))
15052 + (lshiftrt:SI (and:SI (match_dup 0)
15053 + (const_int 16711680))
15055 + (ior:SI (ashift:SI (and:SI (match_dup 0)
15056 + (const_int 65280))
15058 + (ashift:SI (and:SI (match_dup 0)
15060 + (const_int 24)))))]
15063 + [(set_attr "length" "4,4,4")
15064 + (set_attr "type" "alu,store,load_rm")]
15068 +;;=============================================================================
15070 +;;-----------------------------------------------------------------------------
15071 +;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
15072 +;; all of memory. This blocks insns from being moved across this point.
15074 +(define_insn "blockage"
15075 + [(unspec_volatile [(const_int 0)] VUNSPEC_BLOCKAGE)]
15078 + [(set_attr "length" "0")]
15081 +;;=============================================================================
15083 +;;-----------------------------------------------------------------------------
15084 +(define_insn "clzsi2"
15085 + [ (set (match_operand:SI 0 "register_operand" "=r")
15086 + (clz:SI (match_operand:SI 1 "register_operand" "r"))) ]
15089 + [(set_attr "length" "4")
15090 + (set_attr "cc" "set_z")]
15093 +;;=============================================================================
15095 +;;-----------------------------------------------------------------------------
15096 +(define_insn "ctzsi2"
15097 + [ (set (match_operand:SI 0 "register_operand" "=r,r")
15098 + (ctz:SI (match_operand:SI 1 "register_operand" "0,r"))) ]
15101 + brev\t%0\;clz\t%0, %0
15102 + mov\t%0, %1\;brev\t%0\;clz\t%0, %0"
15103 + [(set_attr "length" "8")
15104 + (set_attr "cc" "set_z")]
15107 +;;=============================================================================
15108 +;; cache instructions
15109 +;;-----------------------------------------------------------------------------
15110 +(define_insn "cache"
15111 + [ (unspec_volatile [(match_operand:SI 0 "avr32_ks11_address_operand" "p")
15112 + (match_operand:SI 1 "immediate_operand" "Ku05")] VUNSPEC_CACHE)]
15115 + [(set_attr "length" "4")]
15118 +(define_insn "sync"
15119 + [ (unspec_volatile [(match_operand:SI 0 "immediate_operand" "Ku08")] VUNSPEC_SYNC)]
15122 + [(set_attr "length" "4")]
15125 +;;=============================================================================
15126 +;; TLB instructions
15127 +;;-----------------------------------------------------------------------------
15128 +(define_insn "tlbr"
15129 + [ (unspec_volatile [(const_int 0)] VUNSPEC_TLBR)]
15132 + [(set_attr "length" "2")]
15135 +(define_insn "tlbw"
15136 + [ (unspec_volatile [(const_int 0)] VUNSPEC_TLBW)]
15139 + [(set_attr "length" "2")]
15142 +(define_insn "tlbs"
15143 + [ (unspec_volatile [(const_int 0)] VUNSPEC_TLBS)]
15146 + [(set_attr "length" "2")]
15149 +;;=============================================================================
15150 +;; Breakpoint instruction
15151 +;;-----------------------------------------------------------------------------
15152 +(define_insn "breakpoint"
15153 + [ (unspec_volatile [(const_int 0)] VUNSPEC_BREAKPOINT)]
15156 + [(set_attr "length" "2")]
15160 +;;=============================================================================
15161 +;; mtsr/mfsr instruction
15162 +;;-----------------------------------------------------------------------------
15163 +(define_insn "mtsr"
15164 + [ (unspec_volatile [(match_operand 0 "immediate_operand" "i")
15165 + (match_operand:SI 1 "register_operand" "r")] VUNSPEC_MTSR)]
15168 + [(set_attr "length" "4")]
15171 +(define_insn "mfsr"
15172 + [ (set (match_operand:SI 0 "register_operand" "=r")
15173 + (unspec_volatile:SI [(match_operand 1 "immediate_operand" "i")] VUNSPEC_MFSR)) ]
15176 + [(set_attr "length" "4")]
15179 +;;=============================================================================
15180 +;; mtdr/mfdr instruction
15181 +;;-----------------------------------------------------------------------------
15182 +(define_insn "mtdr"
15183 + [ (unspec_volatile [(match_operand 0 "immediate_operand" "i")
15184 + (match_operand:SI 1 "register_operand" "r")] VUNSPEC_MTDR)]
15187 + [(set_attr "length" "4")]
15190 +(define_insn "mfdr"
15191 + [ (set (match_operand:SI 0 "register_operand" "=r")
15192 + (unspec_volatile:SI [(match_operand 1 "immediate_operand" "i")] VUNSPEC_MFDR)) ]
15195 + [(set_attr "length" "4")]
15198 +;;=============================================================================
15200 +;;-----------------------------------------------------------------------------
15201 +(define_insn "musfr"
15202 + [ (unspec_volatile [(match_operand:SI 0 "register_operand" "r")] VUNSPEC_MUSFR)]
15205 + [(set_attr "length" "2")
15206 + (set_attr "cc" "clobber")]
15209 +(define_insn "mustr"
15210 + [ (set (match_operand:SI 0 "register_operand" "=r")
15211 + (unspec_volatile:SI [(const_int 0)] VUNSPEC_MUSTR)) ]
15214 + [(set_attr "length" "2")]
15217 +(define_insn "ssrf"
15218 + [ (unspec_volatile [(match_operand:SI 0 "immediate_operand" "Ku05")] VUNSPEC_SSRF)]
15221 + [(set_attr "length" "2")
15222 + (set_attr "cc" "clobber")]
15225 +(define_insn "csrf"
15226 + [ (unspec_volatile [(match_operand:SI 0 "immediate_operand" "Ku05")] VUNSPEC_CSRF)]
15229 + [(set_attr "length" "2")
15230 + (set_attr "cc" "clobber")]
15233 +;;=============================================================================
15234 +;; Flush Return Stack instruction
15235 +;;-----------------------------------------------------------------------------
15236 +(define_insn "frs"
15237 + [ (unspec_volatile [(const_int 0)] VUNSPEC_FRS)]
15240 + [(set_attr "length" "2")
15241 + (set_attr "cc" "none")]
15245 +;;=============================================================================
15246 +;; Saturation Round Scale instruction
15247 +;;-----------------------------------------------------------------------------
15248 +(define_insn "sats"
15249 + [ (set (match_operand:SI 0 "register_operand" "+r")
15250 + (unspec:SI [(match_dup 0)
15251 + (match_operand 1 "immediate_operand" "Ku05")
15252 + (match_operand 2 "immediate_operand" "Ku05")]
15255 + "sats\t%0 >> %1, %2"
15256 + [(set_attr "type" "alu_sat")
15257 + (set_attr "length" "4")]
15260 +(define_insn "satu"
15261 + [ (set (match_operand:SI 0 "register_operand" "+r")
15262 + (unspec:SI [(match_dup 0)
15263 + (match_operand 1 "immediate_operand" "Ku05")
15264 + (match_operand 2 "immediate_operand" "Ku05")]
15267 + "satu\t%0 >> %1, %2"
15268 + [(set_attr "type" "alu_sat")
15269 + (set_attr "length" "4")]
15272 +(define_insn "satrnds"
15273 + [ (set (match_operand:SI 0 "register_operand" "+r")
15274 + (unspec:SI [(match_dup 0)
15275 + (match_operand 1 "immediate_operand" "Ku05")
15276 + (match_operand 2 "immediate_operand" "Ku05")]
15277 + UNSPEC_SATRNDS)) ]
15279 + "satrnds\t%0 >> %1, %2"
15280 + [(set_attr "type" "alu_sat")
15281 + (set_attr "length" "4")]
15284 +(define_insn "satrndu"
15285 + [ (set (match_operand:SI 0 "register_operand" "+r")
15286 + (unspec:SI [(match_dup 0)
15287 + (match_operand 1 "immediate_operand" "Ku05")
15288 + (match_operand 2 "immediate_operand" "Ku05")]
15289 + UNSPEC_SATRNDU)) ]
15291 + "sats\t%0 >> %1, %2"
15292 + [(set_attr "type" "alu_sat")
15293 + (set_attr "length" "4")]
15296 +(define_insn "sleep"
15297 + [(unspec_volatile [(const_int 0)] VUNSPEC_SLEEP)
15298 + (match_operand:SI 0 "const_int_operand" "")]
15301 + [(set_attr "length" "1")
15302 + (set_attr "cc" "none")
15305 +(define_expand "delay_cycles"
15306 + [(unspec_volatile [(match_operand:SI 0 "const_int_operand" "i")]
15307 + VUNSPEC_DELAY_CYCLES)]
15310 + unsigned int cycles = UINTVAL (operands[0]);
15311 + if (IN_RANGE(cycles,0x10000 ,0xFFFFFFFF))
15313 + unsigned int msb = (cycles & 0xFFFF0000);
15314 + unsigned int shift = 16;
15315 + msb = (msb >> shift);
15316 + unsigned int cycles_used = (msb*0x10000);
15317 + emit_insn (gen_delay_cycles_2 (gen_int_mode (msb, SImode)));
15318 + cycles -= cycles_used;
15320 + if (IN_RANGE(cycles, 4, 0xFFFF))
15322 + unsigned int loop_count = (cycles/ 4);
15323 + unsigned int cycles_used = (loop_count*4);
15324 + emit_insn (gen_delay_cycles_1 (gen_int_mode (loop_count, SImode)));
15325 + cycles -= cycles_used;
15327 + while (cycles >= 3)
15329 + emit_insn (gen_nop3 ());
15332 + if (cycles == 1 || cycles == 2)
15335 + emit_insn (gen_nop ());
15340 +(define_insn "delay_cycles_1"
15341 +[(unspec_volatile [(const_int 0)] VUNSPEC_DELAY_CYCLES_1)
15342 + (match_operand:SI 0 "immediate_operand" "")
15343 + (clobber (match_scratch:SI 1 "=&r"))]
15351 +(define_insn "delay_cycles_2"
15352 +[(unspec_volatile [(const_int 0)] VUNSPEC_DELAY_CYCLES_2)
15353 + (match_operand:SI 0 "immediate_operand" "")
15354 + (clobber (match_scratch:SI 1 "=&r"))
15355 + (clobber (match_scratch:SI 2 "=&r"))]
15358 + 1: mov\t%2, 16383
15367 +;; CPU instructions
15369 +;;=============================================================================
15371 +;;-----------------------------------------------------------------------------
15372 +;; No-op instruction.
15373 +;;=============================================================================
15374 +(define_insn "nop"
15375 + [(unspec_volatile [(const_int 0)] VUNSPEC_NOP)]
15378 + [(set_attr "length" "1")
15379 + (set_attr "type" "alu")
15380 + (set_attr "cc" "none")])
15383 +(define_insn "nop3"
15384 + [(unspec_volatile [(const_int 0)] VUNSPEC_NOP3)]
15387 + [(set_attr "length" "3")
15388 + (set_attr "type" "alu")
15389 + (set_attr "cc" "none")])
15391 +;; Special patterns for dealing with the constant pool
15393 +(define_insn "align_4"
15394 + [(unspec_volatile [(const_int 0)] VUNSPEC_ALIGN)]
15397 + assemble_align (32);
15400 + [(set_attr "length" "2")]
15404 +(define_insn "consttable_start"
15405 + [(unspec_volatile [(const_int 0)] VUNSPEC_POOL_START)]
15410 + [(set_attr "length" "0")]
15413 +(define_insn "consttable_end"
15414 + [(unspec_volatile [(const_int 0)] VUNSPEC_POOL_END)]
15417 + making_const_table = FALSE;
15420 + [(set_attr "length" "0")]
15424 +(define_insn "consttable_4"
15425 + [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_4)]
15428 + making_const_table = TRUE;
15429 + switch (GET_MODE_CLASS (GET_MODE (operands[0])))
15433 + REAL_VALUE_TYPE r;
15434 + char real_string[1024];
15435 + REAL_VALUE_FROM_CONST_DOUBLE (r, operands[0]);
15436 + real_to_decimal(real_string, &r, 1024, 0, 1);
15437 + asm_fprintf (asm_out_file, "\t.float\t%s\n", real_string);
15441 + assemble_integer (operands[0], 4, 0, 1);
15446 + [(set_attr "length" "4")]
15449 +(define_insn "consttable_8"
15450 + [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_8)]
15453 + making_const_table = TRUE;
15454 + switch (GET_MODE_CLASS (GET_MODE (operands[0])))
15458 + REAL_VALUE_TYPE r;
15459 + char real_string[1024];
15460 + REAL_VALUE_FROM_CONST_DOUBLE (r, operands[0]);
15461 + real_to_decimal(real_string, &r, 1024, 0, 1);
15462 + asm_fprintf (asm_out_file, "\t.double\t%s\n", real_string);
15466 + assemble_integer(operands[0], 8, 0, 1);
15471 + [(set_attr "length" "8")]
15474 +(define_insn "consttable_16"
15475 + [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_16)]
15478 + making_const_table = TRUE;
15479 + assemble_integer(operands[0], 16, 0, 1);
15482 + [(set_attr "length" "16")]
15485 +;;=============================================================================
15486 +;; coprocessor instructions
15487 +;;-----------------------------------------------------------------------------
15488 +(define_insn "cop"
15489 + [ (unspec_volatile [(match_operand 0 "immediate_operand" "Ku03")
15490 + (match_operand 1 "immediate_operand" "Ku04")
15491 + (match_operand 2 "immediate_operand" "Ku04")
15492 + (match_operand 3 "immediate_operand" "Ku04")
15493 + (match_operand 4 "immediate_operand" "Ku07")] VUNSPEC_COP)]
15495 + "cop\tcp%0, cr%1, cr%2, cr%3, %4"
15496 + [(set_attr "length" "4")]
15499 +(define_insn "mvcrsi"
15500 + [ (set (match_operand:SI 0 "avr32_cop_move_operand" "=r,<,Z")
15501 + (unspec_volatile:SI [(match_operand 1 "immediate_operand" "Ku03,Ku03,Ku03")
15502 + (match_operand 2 "immediate_operand" "Ku04,Ku04,Ku04")]
15506 + mvcr.w\tcp%1, %0, cr%2
15507 + stcm.w\tcp%1, %0, cr%2
15508 + stc.w\tcp%1, %0, cr%2"
15509 + [(set_attr "length" "4")]
15512 +(define_insn "mvcrdi"
15513 + [ (set (match_operand:DI 0 "avr32_cop_move_operand" "=r,<,Z")
15514 + (unspec_volatile:DI [(match_operand 1 "immediate_operand" "Ku03,Ku03,Ku03")
15515 + (match_operand 2 "immediate_operand" "Ku04,Ku04,Ku04")]
15519 + mvcr.d\tcp%1, %0, cr%2
15520 + stcm.d\tcp%1, %0, cr%2-cr%i2
15521 + stc.d\tcp%1, %0, cr%2"
15522 + [(set_attr "length" "4")]
15525 +(define_insn "mvrcsi"
15526 + [ (unspec_volatile:SI [(match_operand 0 "immediate_operand" "Ku03,Ku03,Ku03")
15527 + (match_operand 1 "immediate_operand" "Ku04,Ku04,Ku04")
15528 + (match_operand:SI 2 "avr32_cop_move_operand" "r,>,Z")]
15532 + switch (which_alternative){
15534 + return "mvrc.w\tcp%0, cr%1, %2";
15536 + return "ldcm.w\tcp%0, %2, cr%1";
15538 + return "ldc.w\tcp%0, cr%1, %2";
15543 + [(set_attr "length" "4")]
15546 +(define_insn "mvrcdi"
15547 + [ (unspec_volatile:DI [(match_operand 0 "immediate_operand" "Ku03,Ku03,Ku03")
15548 + (match_operand 1 "immediate_operand" "Ku04,Ku04,Ku04")
15549 + (match_operand:DI 2 "avr32_cop_move_operand" "r,>,Z")]
15553 + switch (which_alternative){
15555 + return "mvrc.d\tcp%0, cr%1, %2";
15557 + return "ldcm.d\tcp%0, %2, cr%1-cr%i1";
15559 + return "ldc.d\tcp%0, cr%1, %2";
15564 + [(set_attr "length" "4")]
15567 +;;=============================================================================
15569 +;;-----------------------------------------------------------------------------
15570 +;; This pattern emits RTL for exit from a function. The function exit is
15571 +;; responsible for deallocating the stack frame, restoring callee saved
15572 +;; registers and emitting the return instruction.
15573 +;; ToDo: using TARGET_ASM_FUNCTION_PROLOGUE instead.
15574 +;;=============================================================================
15575 +(define_expand "epilogue"
15576 + [(unspec_volatile [(return)] VUNSPEC_EPILOGUE)]
15579 + if (USE_RETURN_INSN (FALSE)){
15580 + emit_jump_insn (gen_return ());
15583 + emit_jump_insn (gen_rtx_UNSPEC_VOLATILE (VOIDmode,
15585 + gen_rtx_RETURN (VOIDmode)),
15586 + VUNSPEC_EPILOGUE));
15591 +(define_insn "*epilogue_insns"
15592 + [(unspec_volatile [(return)] VUNSPEC_EPILOGUE)]
15595 + avr32_output_return_instruction (FALSE, FALSE, NULL, NULL);
15598 + ; Length is absolute worst case
15599 + [(set_attr "type" "branch")
15600 + (set_attr "length" "12")]
15603 +(define_insn "*epilogue_insns_ret_imm"
15604 + [(parallel [(set (reg RETVAL_REGNUM) (match_operand 0 "immediate_operand" "i"))
15605 + (use (reg RETVAL_REGNUM))
15606 + (unspec_volatile [(return)] VUNSPEC_EPILOGUE)])]
15607 + "((INTVAL(operands[0]) == -1) || (INTVAL(operands[0]) == 0) || (INTVAL(operands[0]) == 1))"
15609 + avr32_output_return_instruction (FALSE, FALSE, NULL, operands[0]);
15612 + ; Length is absolute worst case
15613 + [(set_attr "type" "branch")
15614 + (set_attr "length" "12")]
15617 +(define_insn "sibcall_epilogue"
15618 + [(unspec_volatile [(const_int 0)] VUNSPEC_EPILOGUE)]
15621 + avr32_output_return_instruction (FALSE, FALSE, NULL, NULL);
15624 +;; Length is absolute worst case
15625 + [(set_attr "type" "branch")
15626 + (set_attr "length" "12")]
15629 +(define_insn "*sibcall_epilogue_insns_ret_imm"
15630 + [(parallel [(set (reg RETVAL_REGNUM) (match_operand 0 "immediate_operand" "i"))
15631 + (use (reg RETVAL_REGNUM))
15632 + (unspec_volatile [(const_int 0)] VUNSPEC_EPILOGUE)])]
15633 + "((INTVAL(operands[0]) == -1) || (INTVAL(operands[0]) == 0) || (INTVAL(operands[0]) == 1))"
15635 + avr32_output_return_instruction (FALSE, FALSE, NULL, operands[0]);
15638 + ; Length is absolute worst case
15639 + [(set_attr "type" "branch")
15640 + (set_attr "length" "12")]
15643 +(define_insn "ldxi"
15644 + [(set (match_operand:SI 0 "register_operand" "=r")
15646 + (match_operand:SI 1 "register_operand" "r")
15647 + (mult:SI (zero_extract:SI (match_operand:SI 2 "register_operand" "r")
15649 + (match_operand:SI 3 "immediate_operand" "Ku05"))
15650 + (const_int 4)))))]
15651 + "(INTVAL(operands[3]) == 24 || INTVAL(operands[3]) == 16 || INTVAL(operands[3]) == 8
15652 + || INTVAL(operands[3]) == 0)"
15654 + switch ( INTVAL(operands[3]) ){
15656 + return "ld.w %0, %1[%2:b << 2]";
15658 + return "ld.w %0, %1[%2:l << 2]";
15660 + return "ld.w %0, %1[%2:u << 2]";
15662 + return "ld.w %0, %1[%2:t << 2]";
15664 + internal_error("illegal operand for ldxi");
15667 + [(set_attr "type" "load")
15668 + (set_attr "length" "4")
15669 + (set_attr "cc" "none")])
15676 +;;=============================================================================
15677 +;; Peephole optimizing
15678 +;;-----------------------------------------------------------------------------
15681 +;; st.w r8[0x0], r12
15684 +;; st.w r7[-0x8], r12
15685 +;;=============================================================================
15686 +; (set (reg:SI 9 r8)
15687 +; (plus:SI (reg/f:SI 6 r7)
15688 +; (const_int ...)))
15689 +; (set (mem:SI (reg:SI 9 r8))
15690 +; (reg:SI 12 r12))
15692 + [(set (match_operand:SI 0 "register_operand" "")
15693 + (plus:SI (match_operand:SI 1 "register_operand" "")
15694 + (match_operand:SI 2 "immediate_operand" "")))
15695 + (set (mem:SI (match_dup 0))
15696 + (match_operand:SI 3 "register_operand" ""))]
15697 + "REGNO(operands[0]) != REGNO(operands[1]) && avr32_const_ok_for_constraint_p(INTVAL(operands[2]), 'K', \"Ks16\")"
15698 + [(set (match_dup 0)
15699 + (plus:SI (match_dup 1)
15701 + (set (mem:SI (plus:SI (match_dup 1)
15706 +;;=============================================================================
15707 +;; Peephole optimizing
15708 +;;-----------------------------------------------------------------------------
15711 +;; ld.w r6, r6[0x0]
15714 +;; ld.w r6, r7[-0x4]
15715 +;;=============================================================================
15716 +; (set (reg:SI 7 r6)
15717 +; (plus:SI (reg/f:SI 6 r7)
15718 +; (const_int -4 [0xfffffffc])))
15719 +; (set (reg:SI 7 r6)
15720 +; (mem:SI (reg:SI 7 r6)))
15722 + [(set (match_operand:SI 0 "register_operand" "")
15723 + (plus:SI (match_operand:SI 1 "register_operand" "")
15724 + (match_operand:SI 2 "immediate_operand" "")))
15725 + (set (match_operand:SI 3 "register_operand" "")
15726 + (mem:SI (match_dup 0)))]
15727 + "REGNO(operands[0]) != REGNO(operands[1]) && avr32_const_ok_for_constraint_p(INTVAL(operands[2]), 'K', \"Ks16\")"
15728 + [(set (match_dup 0)
15729 + (plus:SI (match_dup 1)
15731 + (set (match_dup 3)
15732 + (mem:SI (plus:SI (match_dup 1)
15733 + (match_dup 2))))]
15736 +;;=============================================================================
15737 +;; Peephole optimizing
15738 +;;-----------------------------------------------------------------------------
15740 +;; ld.sb r0, r7[-0x6]
15743 +;; ld.sb r0, r7[-0x6]
15744 +;;=============================================================================
15746 + [(set (match_operand:QI 0 "register_operand" "")
15747 + (match_operand:QI 1 "load_sb_memory_operand" ""))
15748 + (set (match_operand:SI 2 "register_operand" "")
15749 + (sign_extend:SI (match_dup 0)))]
15750 + "(REGNO(operands[0]) == REGNO(operands[2]) || peep2_reg_dead_p(2, operands[0]))"
15751 + [(set (match_dup 2)
15752 + (sign_extend:SI (match_dup 1)))]
15755 +;;=============================================================================
15756 +;; Peephole optimizing
15757 +;;-----------------------------------------------------------------------------
15759 +;; ld.ub r0, r7[-0x6]
15762 +;; ld.ub r0, r7[-0x6]
15763 +;;=============================================================================
15765 + [(set (match_operand:QI 0 "register_operand" "")
15766 + (match_operand:QI 1 "memory_operand" ""))
15767 + (set (match_operand:SI 2 "register_operand" "")
15768 + (zero_extend:SI (match_dup 0)))]
15769 + "(REGNO(operands[0]) == REGNO(operands[2])) || peep2_reg_dead_p(2, operands[0])"
15770 + [(set (match_dup 2)
15771 + (zero_extend:SI (match_dup 1)))]
15774 +;;=============================================================================
15775 +;; Peephole optimizing
15776 +;;-----------------------------------------------------------------------------
15778 +;; ld.sh r0, r7[-0x6]
15781 +;; ld.sh r0, r7[-0x6]
15782 +;;=============================================================================
15784 + [(set (match_operand:HI 0 "register_operand" "")
15785 + (match_operand:HI 1 "memory_operand" ""))
15786 + (set (match_operand:SI 2 "register_operand" "")
15787 + (sign_extend:SI (match_dup 0)))]
15788 + "(REGNO(operands[0]) == REGNO(operands[2])) || peep2_reg_dead_p(2, operands[0])"
15789 + [(set (match_dup 2)
15790 + (sign_extend:SI (match_dup 1)))]
15793 +;;=============================================================================
15794 +;; Peephole optimizing
15795 +;;-----------------------------------------------------------------------------
15797 +;; ld.uh r0, r7[-0x6]
15800 +;; ld.uh r0, r7[-0x6]
15801 +;;=============================================================================
15803 + [(set (match_operand:HI 0 "register_operand" "")
15804 + (match_operand:HI 1 "memory_operand" ""))
15805 + (set (match_operand:SI 2 "register_operand" "")
15806 + (zero_extend:SI (match_dup 0)))]
15807 + "(REGNO(operands[0]) == REGNO(operands[2])) || peep2_reg_dead_p(2, operands[0])"
15808 + [(set (match_dup 2)
15809 + (zero_extend:SI (match_dup 1)))]
15812 +;;=============================================================================
15813 +;; Peephole optimizing
15814 +;;-----------------------------------------------------------------------------
15819 +;; add rd2, rd, rd2
15821 +;; mac rd2, rx, ry
15822 +;;=============================================================================
15824 + [(set (match_operand:SI 0 "register_operand" "")
15825 + (mult:SI (match_operand:SI 1 "register_operand" "")
15826 + (match_operand:SI 2 "register_operand" "")))
15827 + (set (match_operand:SI 3 "register_operand" "")
15828 + (plus:SI (match_dup 3)
15830 + "peep2_reg_dead_p(2, operands[0])"
15831 + [(set (match_dup 3)
15832 + (plus:SI (mult:SI (match_dup 1)
15838 + [(set (match_operand:SI 0 "register_operand" "")
15839 + (mult:SI (match_operand:SI 1 "register_operand" "")
15840 + (match_operand:SI 2 "register_operand" "")))
15841 + (set (match_operand:SI 3 "register_operand" "")
15842 + (plus:SI (match_dup 0)
15844 + "peep2_reg_dead_p(2, operands[0])"
15845 + [(set (match_dup 3)
15846 + (plus:SI (mult:SI (match_dup 1)
15852 +;;=============================================================================
15853 +;; Peephole optimizing
15854 +;;-----------------------------------------------------------------------------
15856 +;; bfextu rd, rs, k5, 1 or and(h/l) rd, one_bit_set_mask
15860 +;; If rd is dead after the operation.
15861 +;;=============================================================================
15863 + [ (set (match_operand:SI 0 "register_operand" "")
15864 + (zero_extract:SI (match_operand:SI 1 "register_operand" "")
15866 + (match_operand:SI 2 "immediate_operand" "")))
15869 + "peep2_reg_dead_p(2, operands[0])"
15871 + (and:SI (match_dup 1)
15873 + "operands[2] = GEN_INT(1 << INTVAL(operands[2]));")
15876 + [ (set (match_operand:SI 0 "register_operand" "")
15877 + (and:SI (match_operand:SI 1 "register_operand" "")
15878 + (match_operand:SI 2 "one_bit_set_operand" "")))
15881 + "peep2_reg_dead_p(2, operands[0])"
15883 + (and:SI (match_dup 1)
15887 +;;=============================================================================
15888 +;; Peephole optimizing
15889 +;;-----------------------------------------------------------------------------
15890 +;; Load with extracted index: ld.w Rd, Rb[Ri:{t/u/b/l} << 2]
15892 +;;=============================================================================
15896 + [(set (match_operand:SI 0 "register_operand" "")
15897 + (zero_extract:SI (match_operand:SI 1 "register_operand" "")
15899 + (match_operand:SI 2 "avr32_extract_shift_operand" "")))
15900 + (set (match_operand:SI 3 "register_operand" "")
15901 + (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
15902 + (match_operand:SI 4 "register_operand" ""))))]
15904 + "(dead_or_set_p(insn, operands[0]))"
15906 + switch ( INTVAL(operands[2]) ){
15908 + return "ld.w %3, %4[%1:b << 2]";
15910 + return "ld.w %3, %4[%1:l << 2]";
15912 + return "ld.w %3, %4[%1:u << 2]";
15914 + return "ld.w %3, %4[%1:t << 2]";
15916 + internal_error("illegal operand for ldxi");
15919 + [(set_attr "type" "load")
15920 + (set_attr "length" "4")
15921 + (set_attr "cc" "clobber")]
15927 + [(set (match_operand:SI 0 "register_operand" "")
15928 + (and:SI (match_operand:SI 1 "register_operand" "") (const_int 255)))
15929 + (set (match_operand:SI 2 "register_operand" "")
15930 + (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
15931 + (match_operand:SI 3 "register_operand" ""))))]
15933 + "(dead_or_set_p(insn, operands[0]))"
15935 + "ld.w %2, %3[%1:b << 2]"
15936 + [(set_attr "type" "load")
15937 + (set_attr "length" "4")
15938 + (set_attr "cc" "clobber")]
15943 + [(set (match_operand:SI 0 "register_operand" "")
15944 + (zero_extract:SI (match_operand:SI 1 "register_operand" "")
15946 + (match_operand:SI 2 "avr32_extract_shift_operand" "")))
15947 + (set (match_operand:SI 3 "register_operand" "")
15948 + (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
15949 + (match_operand:SI 4 "register_operand" ""))))]
15951 + "(peep2_reg_dead_p(2, operands[0]))
15952 + || (REGNO(operands[0]) == REGNO(operands[3]))"
15953 + [(set (match_dup 3)
15956 + (mult:SI (zero_extract:SI (match_dup 1)
15959 + (const_int 4)))))]
15963 + [(set (match_operand:SI 0 "register_operand" "")
15964 + (zero_extend:SI (match_operand:QI 1 "register_operand" "")))
15965 + (set (match_operand:SI 2 "register_operand" "")
15966 + (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
15967 + (match_operand:SI 3 "register_operand" ""))))]
15969 + "(peep2_reg_dead_p(2, operands[0]))
15970 + || (REGNO(operands[0]) == REGNO(operands[2]))"
15971 + [(set (match_dup 2)
15974 + (mult:SI (zero_extract:SI (match_dup 1)
15977 + (const_int 4)))))]
15978 + "operands[1] = gen_rtx_REG(SImode, REGNO(operands[1]));"
15983 + [(set (match_operand:SI 0 "register_operand" "")
15984 + (and:SI (match_operand:SI 1 "register_operand" "")
15985 + (const_int 255)))
15986 + (set (match_operand:SI 2 "register_operand" "")
15987 + (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
15988 + (match_operand:SI 3 "register_operand" ""))))]
15990 + "(peep2_reg_dead_p(2, operands[0]))
15991 + || (REGNO(operands[0]) == REGNO(operands[2]))"
15992 + [(set (match_dup 2)
15995 + (mult:SI (zero_extract:SI (match_dup 1)
15998 + (const_int 4)))))]
16005 + [(set (match_operand:SI 0 "register_operand" "")
16006 + (lshiftrt:SI (match_operand:SI 1 "register_operand" "")
16008 + (set (match_operand:SI 2 "register_operand" "")
16009 + (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
16010 + (match_operand:SI 3 "register_operand" ""))))]
16012 + "(peep2_reg_dead_p(2, operands[0]))
16013 + || (REGNO(operands[0]) == REGNO(operands[2]))"
16014 + [(set (match_dup 2)
16017 + (mult:SI (zero_extract:SI (match_dup 1)
16020 + (const_int 4)))))]
16025 +;;************************************************
16028 +;;************************************************
16032 + [(set (match_operand:SI 0 "register_operand" "")
16033 + (not:SI (match_operand:SI 1 "register_operand" "")))
16034 + (set (match_operand:SI 2 "register_operand" "")
16035 + (and:SI (match_dup 2)
16037 + "peep2_reg_dead_p(2, operands[0])"
16039 + [(set (match_dup 2)
16040 + (and:SI (match_dup 2)
16041 + (not:SI (match_dup 1))
16047 + [(set (match_operand:SI 0 "register_operand" "")
16048 + (not:SI (match_operand:SI 1 "register_operand" "")))
16049 + (set (match_operand:SI 2 "register_operand" "")
16050 + (and:SI (match_dup 0)
16053 + "peep2_reg_dead_p(2, operands[0])"
16055 + [(set (match_dup 2)
16056 + (and:SI (match_dup 2)
16057 + (not:SI (match_dup 1))
16064 +;;=================================================================
16065 +;; Addabs peephole
16066 +;;=================================================================
16069 + [(set (match_operand:SI 2 "register_operand" "=r")
16070 + (abs:SI (match_operand:SI 1 "register_operand" "r")))
16071 + (set (match_operand:SI 0 "register_operand" "=r")
16072 + (plus:SI (match_operand:SI 3 "register_operand" "r")
16074 + "dead_or_set_p(insn, operands[2])"
16075 + "addabs %0, %3, %1"
16076 + [(set_attr "length" "4")
16077 + (set_attr "cc" "set_z")])
16080 + [(set (match_operand:SI 2 "register_operand" "=r")
16081 + (abs:SI (match_operand:SI 1 "register_operand" "r")))
16082 + (set (match_operand:SI 0 "register_operand" "=r")
16083 + (plus:SI (match_dup 2)
16084 + (match_operand:SI 3 "register_operand" "r")))]
16085 + "dead_or_set_p(insn, operands[2])"
16086 + "addabs %0, %3, %1"
16087 + [(set_attr "length" "4")
16088 + (set_attr "cc" "set_z")])
16091 +;;=================================================================
16092 +;; Detect roundings
16093 +;;=================================================================
16095 +(define_insn "*round"
16096 + [(set (match_operand:SI 0 "register_operand" "+r")
16097 + (ashiftrt:SI (plus:SI (match_dup 0)
16098 + (match_operand:SI 1 "immediate_operand" "i"))
16099 + (match_operand:SI 2 "immediate_operand" "i")))]
16100 + "avr32_rnd_operands(operands[1], operands[2])"
16102 + "satrnds %0 >> %2, 31"
16104 + [(set_attr "type" "alu_sat")
16105 + (set_attr "length" "4")]
16111 + [(set (match_operand:SI 0 "register_operand" "")
16112 + (plus:SI (match_dup 0)
16113 + (match_operand:SI 1 "immediate_operand" "")))
16114 + (set (match_dup 0)
16115 + (ashiftrt:SI (match_dup 0)
16116 + (match_operand:SI 2 "immediate_operand" "")))]
16117 + "avr32_rnd_operands(operands[1], operands[2])"
16119 + [(set (match_dup 0)
16120 + (ashiftrt:SI (plus:SI (match_dup 0)
16126 + [(set (match_operand:SI 0 "register_operand" "r")
16127 + (plus:SI (match_dup 0)
16128 + (match_operand:SI 1 "immediate_operand" "i")))
16129 + (set (match_dup 0)
16130 + (ashiftrt:SI (match_dup 0)
16131 + (match_operand:SI 2 "immediate_operand" "i")))]
16132 + "avr32_rnd_operands(operands[1], operands[2])"
16134 + "satrnds %0 >> %2, 31"
16136 + [(set_attr "type" "alu_sat")
16137 + (set_attr "length" "4")
16138 + (set_attr "cc" "clobber")]
16143 +;;=================================================================
16145 +;;=================================================================
16147 + [(set (match_operand:SI 0 "register_operand" "")
16148 + (match_operand 1 "avr32_const_pool_ref_operand" ""))
16149 + (parallel [(call (mem:SI (match_dup 0))
16150 + (match_operand 2 "" ""))
16151 + (clobber (reg:SI LR_REGNUM))])]
16152 + "dead_or_set_p(insn, operands[0])"
16154 + [(set_attr "type" "call")
16155 + (set_attr "length" "4")
16156 + (set_attr "cc" "clobber")]
16160 + [(set (match_operand:SI 2 "register_operand" "")
16161 + (match_operand 1 "avr32_const_pool_ref_operand" ""))
16162 + (parallel [(set (match_operand 0 "register_operand" "")
16163 + (call (mem:SI (match_dup 2))
16164 + (match_operand 3 "" "")))
16165 + (clobber (reg:SI LR_REGNUM))])]
16166 + "dead_or_set_p(insn, operands[2])"
16168 + [(set_attr "type" "call")
16169 + (set_attr "length" "4")
16170 + (set_attr "cc" "call_set")]
16175 + [(set (match_operand:SI 0 "register_operand" "")
16176 + (match_operand 1 "avr32_const_pool_ref_operand" ""))
16177 + (parallel [(call (mem:SI (match_dup 0))
16178 + (match_operand 2 "" ""))
16179 + (clobber (reg:SI LR_REGNUM))])]
16180 + "peep2_reg_dead_p(2, operands[0])"
16181 + [(parallel [(call (mem:SI (match_dup 1))
16183 + (clobber (reg:SI LR_REGNUM))])]
16188 + [(set (match_operand:SI 0 "register_operand" "")
16189 + (match_operand 1 "avr32_const_pool_ref_operand" ""))
16190 + (parallel [(set (match_operand 2 "register_operand" "")
16191 + (call (mem:SI (match_dup 0))
16192 + (match_operand 3 "" "")))
16193 + (clobber (reg:SI LR_REGNUM))])]
16194 + "(peep2_reg_dead_p(2, operands[0]) || (REGNO(operands[2]) == REGNO(operands[0])))"
16195 + [(parallel [(set (match_dup 2)
16196 + (call (mem:SI (match_dup 1))
16198 + (clobber (reg:SI LR_REGNUM))])]
16202 +;;=================================================================
16203 +;; Returning a value
16204 +;;=================================================================
16208 + [(set (match_operand 0 "register_operand" "")
16209 + (match_operand 1 "register_operand" ""))
16211 + "USE_RETURN_INSN (TRUE) && (REGNO(operands[0]) == RETVAL_REGNUM)
16212 + && (REGNO(operands[1]) != LR_REGNUM)
16213 + && (REGNO_REG_CLASS(REGNO(operands[1])) == GENERAL_REGS)"
16215 + [(set_attr "type" "call")
16216 + (set_attr "length" "2")]
16221 + [(set (match_operand 0 "register_operand" "r")
16222 + (match_operand 1 "immediate_operand" "i"))
16224 + "(USE_RETURN_INSN (FALSE) && (REGNO(operands[0]) == RETVAL_REGNUM) &&
16225 + ((INTVAL(operands[1]) == -1) || (INTVAL(operands[1]) == 0) || (INTVAL(operands[1]) == 1)))"
16227 + avr32_output_return_instruction (TRUE, FALSE, NULL, operands[1]);
16230 + [(set_attr "type" "call")
16231 + (set_attr "length" "4")]
16235 + [(set (match_operand 0 "register_operand" "r")
16236 + (match_operand 1 "immediate_operand" "i"))
16237 + (unspec_volatile [(return)] VUNSPEC_EPILOGUE)]
16238 + "(REGNO(operands[0]) == RETVAL_REGNUM) &&
16239 + ((INTVAL(operands[1]) == -1) || (INTVAL(operands[1]) == 0) || (INTVAL(operands[1]) == 1))"
16241 + avr32_output_return_instruction (FALSE, FALSE, NULL, operands[1]);
16244 + ; Length is absolute worst case
16245 + [(set_attr "type" "branch")
16246 + (set_attr "length" "12")]
16250 + [(set (match_operand 0 "register_operand" "=r")
16251 + (if_then_else (match_operator 1 "avr32_comparison_operator"
16252 + [(match_operand 4 "register_operand" "r")
16253 + (match_operand 5 "register_immediate_operand" "rKs21")])
16254 + (match_operand 2 "avr32_cond_register_immediate_operand" "rKs08")
16255 + (match_operand 3 "avr32_cond_register_immediate_operand" "rKs08")))
16257 + "USE_RETURN_INSN (TRUE) && (REGNO(operands[0]) == RETVAL_REGNUM)"
16259 + operands[1] = avr32_output_cmp(operands[1], GET_MODE(operands[4]), operands[4], operands[5]);
16261 + if ( GET_CODE(operands[2]) == REG
16262 + && GET_CODE(operands[3]) == REG
16263 + && REGNO(operands[2]) != LR_REGNUM
16264 + && REGNO(operands[3]) != LR_REGNUM ){
16265 + return "ret%1 %2\;ret%i1 %3";
16266 + } else if ( GET_CODE(operands[2]) == REG
16267 + && GET_CODE(operands[3]) == CONST_INT ){
16268 + if ( INTVAL(operands[3]) == -1
16269 + || INTVAL(operands[3]) == 0
16270 + || INTVAL(operands[3]) == 1 ){
16271 + return "ret%1 %2\;ret%i1 %d3";
16273 + return "mov%1 r12, %2\;mov%i1 r12, %3\;retal r12";
16275 + } else if ( GET_CODE(operands[2]) == CONST_INT
16276 + && GET_CODE(operands[3]) == REG ){
16277 + if ( INTVAL(operands[2]) == -1
16278 + || INTVAL(operands[2]) == 0
16279 + || INTVAL(operands[2]) == 1 ){
16280 + return "ret%1 %d2\;ret%i1 %3";
16282 + return "mov%1 r12, %2\;mov%i1 r12, %3\;retal r12";
16285 + if ( (INTVAL(operands[2]) == -1
16286 + || INTVAL(operands[2]) == 0
16287 + || INTVAL(operands[2]) == 1 )
16288 + && (INTVAL(operands[3]) == -1
16289 + || INTVAL(operands[3]) == 0
16290 + || INTVAL(operands[3]) == 1 )){
16291 + return "ret%1 %d2\;ret%i1 %d3";
16293 + return "mov%1 r12, %2\;mov%i1 r12, %3\;retal r12";
16298 + [(set_attr "length" "10")
16299 + (set_attr "cc" "none")
16300 + (set_attr "type" "call")])
16304 +;;=================================================================
16306 +;;=================================================================
16309 + [(set (match_operand:HI 0 "register_operand" "")
16310 + (neg:HI (match_operand:HI 1 "register_operand" "")))
16311 + (set (match_operand:SI 2 "register_operand" "")
16313 + (sign_extend:SI (match_dup 0))
16314 + (sign_extend:SI (match_operand:HI 3 "register_operand" ""))))]
16315 + "(peep2_reg_dead_p(2, operands[0])) || (REGNO(operands[2]) == REGNO(operands[0]))"
16316 + [ (set (match_dup 2)
16318 + (sign_extend:SI (neg:HI (match_dup 1)))
16319 + (sign_extend:SI (match_dup 3))))]
16324 + [(set (match_operand:HI 0 "register_operand" "")
16325 + (neg:HI (match_operand:HI 1 "register_operand" "")))
16326 + (set (match_operand:SI 2 "register_operand" "")
16328 + (sign_extend:SI (match_operand:HI 3 "register_operand" ""))
16329 + (sign_extend:SI (match_dup 0))))]
16330 + "(peep2_reg_dead_p(2, operands[0])) || (REGNO(operands[2]) == REGNO(operands[0]))"
16331 + [ (set (match_dup 2)
16333 + (sign_extend:SI (neg:HI (match_dup 1)))
16334 + (sign_extend:SI (match_dup 3))))]
16340 +;;=================================================================
16341 +;; Vector set and extract operations
16342 +;;=================================================================
16343 +(define_insn "vec_setv2hi_hi"
16344 + [(set (match_operand:V2HI 0 "register_operand" "=r")
16347 + (vec_duplicate:V2HI
16348 + (match_operand:HI 1 "register_operand" "r"))
16351 + "bfins\t%0, %1, 16, 16"
16352 + [(set_attr "type" "alu")
16353 + (set_attr "length" "4")
16354 + (set_attr "cc" "clobber")])
16356 +(define_insn "vec_setv2hi_lo"
16357 + [(set (match_operand:V2HI 0 "register_operand" "+r")
16360 + (vec_duplicate:V2HI
16361 + (match_operand:HI 1 "register_operand" "r"))
16364 + "bfins\t%0, %1, 0, 16"
16365 + [(set_attr "type" "alu")
16366 + (set_attr "length" "4")
16367 + (set_attr "cc" "clobber")])
16369 +(define_expand "vec_setv2hi"
16370 + [(set (match_operand:V2HI 0 "register_operand" "")
16373 + (vec_duplicate:V2HI
16374 + (match_operand:HI 1 "register_operand" ""))
16375 + (match_operand 2 "immediate_operand" "")))]
16377 + { operands[2] = GEN_INT(INTVAL(operands[2]) + 1); }
16380 +(define_insn "vec_extractv2hi"
16381 + [(set (match_operand:HI 0 "register_operand" "=r")
16383 + (match_operand:V2HI 1 "register_operand" "r")
16384 + (parallel [(match_operand:SI 2 "immediate_operand" "i")])))]
16387 + if ( INTVAL(operands[2]) == 0 )
16388 + return "bfextu\t%0, %1, 16, 16";
16390 + return "bfextu\t%0, %1, 0, 16";
16392 + [(set_attr "type" "alu")
16393 + (set_attr "length" "4")
16394 + (set_attr "cc" "clobber")])
16396 +(define_insn "vec_extractv4qi"
16397 + [(set (match_operand:QI 0 "register_operand" "=r")
16399 + (match_operand:V4QI 1 "register_operand" "r")
16400 + (parallel [(match_operand:SI 2 "immediate_operand" "i")])))]
16403 + switch ( INTVAL(operands[2]) ){
16405 + return "bfextu\t%0, %1, 24, 8";
16407 + return "bfextu\t%0, %1, 16, 8";
16409 + return "bfextu\t%0, %1, 8, 8";
16411 + return "bfextu\t%0, %1, 0, 8";
16416 + [(set_attr "type" "alu")
16417 + (set_attr "length" "4")
16418 + (set_attr "cc" "clobber")])
16421 +(define_insn "concatv2hi"
16422 + [(set (match_operand:V2HI 0 "register_operand" "=r, r, r")
16424 + (match_operand:HI 1 "register_operand" "r, r, 0")
16425 + (match_operand:HI 2 "register_operand" "r, 0, r")))]
16428 + mov\t%0, %1\;bfins\t%0, %2, 0, 16
16429 + bfins\t%0, %2, 0, 16
16430 + bfins\t%0, %1, 16, 16"
16431 + [(set_attr "length" "6, 4, 4")
16432 + (set_attr "type" "alu")])
16435 +;; Load the atomic operation description
16436 +(include "sync.md")
16438 +;; Load the SIMD description
16439 +(include "simd.md")
16441 +;; Include the FPU for uc3
16442 +(include "uc3fpu.md")
16444 +++ b/gcc/config/avr32/avr32-modes.def
16446 +VECTOR_MODES (INT, 4); /* V4QI V2HI */
16448 +++ b/gcc/config/avr32/avr32.opt
16450 +; Options for the ATMEL AVR32 port of the compiler.
16452 +; Copyright 2007 Atmel Corporation.
16454 +; This file is part of GCC.
16456 +; GCC is free software; you can redistribute it and/or modify it under
16457 +; the terms of the GNU General Public License as published by the Free
16458 +; Software Foundation; either version 2, or (at your option) any later
16461 +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16462 +; WARRANTY; without even the implied warranty of MERCHANTABILITY or
16463 +; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16464 +; for more details.
16466 +; You should have received a copy of the GNU General Public License
16467 +; along with GCC; see the file COPYING. If not, write to the Free
16468 +; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
16469 +; 02110-1301, USA.
16471 +muse-rodata-section
16472 +Target Report Mask(USE_RODATA_SECTION)
16473 +Use section .rodata for read-only data instead of .text.
16476 +Target Report Mask(HARD_FLOAT)
16477 +Use FPU instructions instead of floating point emulation.
16480 +Target Report InverseMask(HARD_FLOAT, SOFT_FLOAT)
16481 +Use floating point emulation for floating point operations.
16483 +mforce-double-align
16484 +Target Report RejectNegative Mask(FORCE_DOUBLE_ALIGN)
16485 +Force double-word alignment for double-word memory accesses.
16488 +Target Report RejectNegative Mask(NO_INIT_GOT)
16489 +Do not initialize GOT register before using it when compiling PIC code.
16492 +Target Report Mask(RELAX)
16493 +Let invoked assembler and linker do relaxing (Enabled by default when optimization level is >1).
16496 +Target Report Undocumented Mask(MD_REORG_OPTIMIZATION)
16497 +Perform machine dependent optimizations in reorg stage.
16500 +Target Report Mask(HAS_ASM_ADDR_PSEUDOS)
16501 +Use assembler pseudo-instructions lda.w and call for handling direct addresses. (Enabled by default)
16504 +Target Report RejectNegative Joined Var(avr32_part_name)
16505 +Specify the AVR32 part name
16508 +Target Report RejectNegative Joined Undocumented Var(avr32_part_name)
16509 +Specify the AVR32 part name (deprecated)
16512 +Target Report RejectNegative Joined Var(avr32_arch_name)
16513 +Specify the AVR32 architecture name
16516 +Target Report Mask(FAST_FLOAT)
16517 +Enable fast floating-point library. Enabled by default if the -funsafe-math-optimizations switch is specified.
16519 +mimm-in-const-pool
16520 +Target Report Var(avr32_imm_in_const_pool) Init(-1)
16521 +Put large immediates in constant pool. This is enabled by default for archs with insn-cache.
16524 +Target Report RejectNegative Mask(NO_PIC)
16525 +Do not generate position-independent code. (deprecated, use -fno-pic instead)
16527 +mcond-exec-before-reload
16528 +Target Report Undocumented Mask(COND_EXEC_BEFORE_RELOAD)
16529 +Enable experimental conditional execution preparation before the reload stage.
16531 +mrmw-addressable-data
16532 +Target Report Mask(RMW_ADDRESSABLE_DATA)
16533 +Signal that all data is in range for the Atomic Read-Modify-Write memory instructions, and that
16534 +gcc can safely generate these whenever possible.
16537 +Target Var(TARGET_FLASHVAULT)
16538 +Generate code for flashvault
16540 +++ b/gcc/config/avr32/avr32-protos.h
16543 + Prototypes for exported functions defined in avr32.c
16544 + Copyright 2003,2004,2005,2006,2007,2008,2009 Atmel Corporation.
16546 + This file is part of GCC.
16548 + This program is free software; you can redistribute it and/or modify
16549 + it under the terms of the GNU General Public License as published by
16550 + the Free Software Foundation; either version 2 of the License, or
16551 + (at your option) any later version.
16553 + This program is distributed in the hope that it will be useful,
16554 + but WITHOUT ANY WARRANTY; without even the implied warranty of
16555 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16556 + GNU General Public License for more details.
16558 + You should have received a copy of the GNU General Public License
16559 + along with this program; if not, write to the Free Software
16560 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16563 +#ifndef AVR32_PROTOS_H
16564 +#define AVR32_PROTOS_H
16566 +extern const int swap_reg[];
16568 +extern int avr32_valid_macmac_bypass (rtx, rtx);
16569 +extern int avr32_valid_mulmac_bypass (rtx, rtx);
16571 +extern int avr32_decode_lcomm_symbol_offset (rtx, int *);
16572 +extern void avr32_encode_lcomm_symbol_offset (tree, char *, int);
16574 +extern const char *avr32_strip_name_encoding (const char *);
16576 +extern rtx avr32_get_note_reg_equiv (rtx insn);
16578 +extern int avr32_use_return_insn (int iscond);
16580 +extern void avr32_make_reglist16 (int reglist16_vect, char *reglist16_string);
16582 +extern void avr32_make_reglist8 (int reglist8_vect, char *reglist8_string);
16583 +extern void avr32_make_fp_reglist_w (int reglist_mask, char *reglist_string);
16584 +extern void avr32_make_fp_reglist_d (int reglist_mask, char *reglist_string);
16586 +extern void avr32_output_return_instruction (int single_ret_inst,
16587 + int iscond, rtx cond,
16589 +extern void avr32_expand_prologue (void);
16590 +extern void avr32_set_return_address (rtx source, rtx scratch);
16592 +extern int avr32_hard_regno_mode_ok (int regno, enum machine_mode mode);
16593 +extern int avr32_extra_constraint_s (rtx value, const int strict);
16594 +extern int avr32_eh_return_data_regno (const int n);
16595 +extern int avr32_initial_elimination_offset (const int from, const int to);
16596 +extern rtx avr32_function_arg (CUMULATIVE_ARGS * cum, enum machine_mode mode,
16597 + tree type, int named);
16598 +extern void avr32_init_cumulative_args (CUMULATIVE_ARGS * cum, tree fntype,
16599 + rtx libname, tree fndecl);
16600 +extern void avr32_function_arg_advance (CUMULATIVE_ARGS * cum,
16601 + enum machine_mode mode,
16602 + tree type, int named);
16603 +#ifdef ARGS_SIZE_RTX
16604 +/* expr.h defines ARGS_SIZE_RTX and `enum direction'. */
16605 +extern enum direction avr32_function_arg_padding (enum machine_mode mode,
16607 +#endif /* ARGS_SIZE_RTX */
16608 +extern rtx avr32_function_value (tree valtype, tree func, bool outgoing);
16609 +extern rtx avr32_libcall_value (enum machine_mode mode);
16610 +extern int avr32_sched_use_dfa_pipeline_interface (void);
16611 +extern bool avr32_return_in_memory (tree type, tree fntype);
16612 +extern void avr32_regs_to_save (char *operand);
16613 +extern void avr32_target_asm_function_prologue (FILE * file,
16614 + HOST_WIDE_INT size);
16615 +extern void avr32_target_asm_function_epilogue (FILE * file,
16616 + HOST_WIDE_INT size);
16617 +extern void avr32_trampoline_template (FILE * file);
16618 +extern void avr32_initialize_trampoline (rtx addr, rtx fnaddr,
16619 + rtx static_chain);
16620 +extern int avr32_legitimate_address (enum machine_mode mode, rtx x,
16622 +extern int avr32_legitimate_constant_p (rtx x);
16624 +extern int avr32_legitimate_pic_operand_p (rtx x);
16626 +extern rtx avr32_find_symbol (rtx x);
16627 +extern void avr32_select_section (rtx exp, int reloc, int align);
16628 +extern void avr32_encode_section_info (tree decl, rtx rtl, int first);
16629 +extern void avr32_asm_file_end (FILE * stream);
16630 +extern void avr32_asm_output_ascii (FILE * stream, char *ptr, int len);
16631 +extern void avr32_asm_output_common (FILE * stream, const char *name,
16632 + int size, int rounded);
16633 +extern void avr32_asm_output_label (FILE * stream, const char *name);
16634 +extern void avr32_asm_declare_object_name (FILE * stream, char *name,
16636 +extern void avr32_asm_globalize_label (FILE * stream, const char *name);
16637 +extern void avr32_asm_weaken_label (FILE * stream, const char *name);
16638 +extern void avr32_asm_output_external (FILE * stream, tree decl,
16639 + const char *name);
16640 +extern void avr32_asm_output_external_libcall (FILE * stream, rtx symref);
16641 +extern void avr32_asm_output_labelref (FILE * stream, const char *name);
16642 +extern void avr32_notice_update_cc (rtx exp, rtx insn);
16643 +extern void avr32_print_operand (FILE * stream, rtx x, int code);
16644 +extern void avr32_print_operand_address (FILE * stream, rtx x);
16646 +extern int avr32_symbol (rtx x);
16648 +extern void avr32_select_rtx_section (enum machine_mode mode, rtx x,
16649 + unsigned HOST_WIDE_INT align);
16651 +extern int avr32_load_multiple_operation (rtx op, enum machine_mode mode);
16652 +extern int avr32_store_multiple_operation (rtx op, enum machine_mode mode);
16654 +extern int avr32_const_ok_for_constraint_p (HOST_WIDE_INT value, char c,
16655 + const char *str);
16657 +extern bool avr32_cannot_force_const_mem (rtx x);
16659 +extern void avr32_init_builtins (void);
16661 +extern rtx avr32_expand_builtin (tree exp, rtx target, rtx subtarget,
16662 + enum machine_mode mode, int ignore);
16664 +extern bool avr32_must_pass_in_stack (enum machine_mode mode, tree type);
16666 +extern bool avr32_strict_argument_naming (CUMULATIVE_ARGS * ca);
16668 +extern bool avr32_pass_by_reference (CUMULATIVE_ARGS * cum,
16669 + enum machine_mode mode,
16670 + tree type, bool named);
16672 +extern rtx avr32_gen_load_multiple (rtx * regs, int count, rtx from,
16673 + int write_back, int in_struct_p,
16675 +extern rtx avr32_gen_store_multiple (rtx * regs, int count, rtx to,
16676 + int in_struct_p, int scalar_p);
16677 +extern int avr32_gen_movmemsi (rtx * operands);
16679 +extern int avr32_rnd_operands (rtx add, rtx shift);
16680 +extern int avr32_adjust_insn_length (rtx insn, int length);
16682 +extern int symbol_mentioned_p (rtx x);
16683 +extern int label_mentioned_p (rtx x);
16684 +extern rtx legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg);
16685 +extern int avr32_address_register_rtx_p (rtx x, int strict_p);
16686 +extern int avr32_legitimate_index_p (enum machine_mode mode, rtx index,
16689 +extern int avr32_const_double_immediate (rtx value);
16690 +extern void avr32_init_expanders (void);
16691 +extern rtx avr32_return_addr (int count, rtx frame);
16692 +extern bool avr32_got_mentioned_p (rtx addr);
16694 +extern void avr32_final_prescan_insn (rtx insn, rtx * opvec, int noperands);
16696 +extern int avr32_expand_movcc (enum machine_mode mode, rtx operands[]);
16697 +extern int avr32_expand_addcc (enum machine_mode mode, rtx operands[]);
16699 +extern int avr32_expand_scc (RTX_CODE cond, rtx * operands);
16702 +extern int avr32_store_bypass (rtx insn_out, rtx insn_in);
16703 +extern int avr32_mul_waw_bypass (rtx insn_out, rtx insn_in);
16704 +extern int avr32_valid_load_double_bypass (rtx insn_out, rtx insn_in);
16705 +extern int avr32_valid_load_quad_bypass (rtx insn_out, rtx insn_in);
16706 +extern rtx avr32_output_cmp (rtx cond, enum machine_mode mode,
16707 + rtx op0, rtx op1);
16709 +rtx get_next_insn_cond (rtx cur_insn);
16710 +int set_next_insn_cond (rtx cur_insn, rtx cond);
16711 +rtx next_insn_emits_cmp (rtx cur_insn);
16712 +void avr32_override_options (void);
16713 +void avr32_load_pic_register (void);
16714 +#ifdef GCC_BASIC_BLOCK_H
16715 +rtx avr32_ifcvt_modify_insn (ce_if_block_t *ce_info, rtx pattern, rtx insn,
16716 + int *num_true_changes);
16717 +rtx avr32_ifcvt_modify_test (ce_if_block_t *ce_info, rtx test );
16718 +void avr32_ifcvt_modify_cancel ( ce_if_block_t *ce_info, int *num_true_changes);
16720 +void avr32_optimization_options (int level, int size);
16721 +int avr32_const_ok_for_move (HOST_WIDE_INT c);
16723 +void avr32_split_const_expr (enum machine_mode mode,
16724 + enum machine_mode new_mode,
16726 + rtx *split_expr);
16727 +void avr32_get_intval (enum machine_mode mode,
16729 + HOST_WIDE_INT *val);
16731 +int avr32_cond_imm_clobber_splittable (rtx insn,
16734 +bool avr32_flashvault_call(tree decl);
16735 +extern void avr32_emit_swdivsf (rtx, rtx, rtx);
16737 +#endif /* AVR32_PROTOS_H */
16739 +++ b/gcc/config/avr32/crti.asm
16742 + Init/fini stuff for AVR32.
16743 + Copyright 2003-2006 Atmel Corporation.
16745 + Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
16747 + This file is part of GCC.
16749 + This program is free software; you can redistribute it and/or modify
16750 + it under the terms of the GNU General Public License as published by
16751 + the Free Software Foundation; either version 2 of the License, or
16752 + (at your option) any later version.
16754 + This program is distributed in the hope that it will be useful,
16755 + but WITHOUT ANY WARRANTY; without even the implied warranty of
16756 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16757 + GNU General Public License for more details.
16759 + You should have received a copy of the GNU General Public License
16760 + along with this program; if not, write to the Free Software
16761 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16764 +/* The code in sections .init and .fini is supposed to be a single
16765 + regular function. The function in .init is called directly from
16766 + start in crt1.asm. The function in .fini is atexit()ed in crt1.asm
16769 + crti.asm contributes the prologue of a function to these sections,
16770 + and crtn.asm comes up the epilogue. STARTFILE_SPEC should list
16771 + crti.o before any other object files that might add code to .init
16772 + or .fini sections, and ENDFILE_SPEC should list crtn.o after any
16773 + such object files. */
16778 +/* Just load the GOT */
16788 +1: .long 0b - _GLOBAL_OFFSET_TABLE_
16792 +/* Just load the GOT */
16802 +1: .long 0b - _GLOBAL_OFFSET_TABLE_
16806 +++ b/gcc/config/avr32/crtn.asm
16808 +/* Copyright (C) 2001 Free Software Foundation, Inc.
16809 + Written By Nick Clifton
16811 + This file is free software; you can redistribute it and/or modify it
16812 + under the terms of the GNU General Public License as published by the
16813 + Free Software Foundation; either version 2, or (at your option) any
16816 + In addition to the permissions in the GNU General Public License, the
16817 + Free Software Foundation gives you unlimited permission to link the
16818 + compiled version of this file with other programs, and to distribute
16819 + those programs without any restriction coming from the use of this
16820 + file. (The General Public License restrictions do apply in other
16821 + respects; for example, they cover modification of the file, and
16822 + distribution when not linked into another program.)
16824 + This file is distributed in the hope that it will be useful, but
16825 + WITHOUT ANY WARRANTY; without even the implied warranty of
16826 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16827 + General Public License for more details.
16829 + You should have received a copy of the GNU General Public License
16830 + along with this program; see the file COPYING. If not, write to
16831 + the Free Software Foundation, 59 Temple Place - Suite 330,
16832 + Boston, MA 02111-1307, USA.
16834 + As a special exception, if you link this library with files
16835 + compiled with GCC to produce an executable, this does not cause
16836 + the resulting executable to be covered by the GNU General Public License.
16837 + This exception does not however invalidate any other reasons why
16838 + the executable file might be covered by the GNU General Public License.
16853 +++ b/gcc/config/avr32/lib1funcs.S
16855 +/* Macro for moving immediate value to register. */
16856 +.macro mov_imm reg, imm
16857 +.if (((\imm & 0xfffff) == \imm) || ((\imm | 0xfff00000) == \imm))
16859 +#if __AVR32_UC__ >= 2
16860 +.elseif ((\imm & 0xffff) == 0)
16861 + movh \reg, hi(\imm)
16865 + mov \reg, lo(\imm)
16866 + orh \reg, hi(\imm)
16872 +/* Adjust the unpacked double number if it is a subnormal number.
16873 + The exponent and mantissa pair are stored
16874 + in [mant_hi,mant_lo] and [exp]. A register with the correct sign bit in
16875 + the MSB is passed in [sign]. Needs two scratch
16876 + registers [scratch1] and [scratch2]. An adjusted and packed double float
16877 + is present in [mant_hi,mant_lo] after macro has executed */
16878 +.macro adjust_subnormal_df exp, mant_lo, mant_hi, sign, scratch1, scratch2
16879 + /* We have an exponent which is <=0 indicating a subnormal number
16880 + As it should be stored as if the exponent was 1 (although the
16881 + exponent field is all zeros to indicate a subnormal number)
16882 + we have to shift down the mantissa to its correct position. */
16884 + sub \exp,-1 /* amount to shift down */
16886 + brlo 50f /* if more than 53 shift steps, the
16887 + entire mantissa will disappear
16888 + without any rounding to occur */
16893 + sub \exp,-10 /* do the shift to position the
16894 + mantissa at the same time
16895 + note! this does not include the
16896 + final 1 step shift to add the sign */
16898 + /* when shifting, save all shifted out bits in [scratch2]. we may need to
16899 + look at them to make correct rounding. */
16901 + rsub \scratch1,\exp,32 /* get inverted shift count */
16902 + cp.w \exp,32 /* handle shifts >= 32 separately */
16905 + /* small (<32) shift amount, both words are part of the shift */
16906 + lsl \scratch2,\mant_lo,\scratch1 /* save bits to shift out from lsw*/
16907 + lsl \scratch1,\mant_hi,\scratch1 /* get bits from msw destined for lsw*/
16908 + lsr \mant_lo,\mant_lo,\exp /* shift down lsw */
16909 + lsr \mant_hi,\mant_hi,\exp /* shift down msw */
16910 + or \mant_hi,\scratch1 /* add bits from msw with prepared lsw */
16913 + /* large (>=32) shift amount, only lsw will have bits left after shift.
16914 + note that shift operations will use ((shift count) mod 32) so
16915 + we do not need to subtract 32 from shift count. */
16917 + lsl \scratch2,\mant_hi,\scratch1 /* save bits to shift out from msw */
16918 + or \scratch2,\mant_lo /* also save all bits from lsw */
16919 + mov \mant_lo,\mant_hi /* msw -> lsw (i.e. "shift 32 first") */
16920 + mov \mant_hi,0 /* clear msw */
16921 + lsr \mant_lo,\mant_lo,\exp /* make rest of shift inside lsw */
16924 + /* result is almost ready to return, except that least significant bit
16925 + and the part we already shifted out may cause the result to be
16927 + bld \mant_lo,0 /* get bit to be shifted out */
16928 + brcc 51f /* if bit was 0, no rounding */
16930 + /* msb of part to remove is 1, so rounding depends on rest of bits */
16931 + tst \scratch2,\scratch2 /* get shifted out tail */
16932 + brne 50f /* if rest > 0, do round */
16933 + bld \mant_lo,1 /* we have to look at lsb in result */
16934 + brcc 51f /* if lsb is 0, don't round */
16937 + /* subnormal result requires rounding
16938 + rounding may cause subnormal to become smallest normal number
16939 + luckily, smallest normal number has exactly the representation
16940 + we got by rippling a one bit up from mantissa into exponent field. */
16942 + subcc \mant_hi,-1
16945 + /* shift and return packed double with correct sign */
16953 +/* Adjust subnormal single float number with exponent [exp]
16954 + and mantissa [mant] and round. */
16955 +.macro adjust_subnormal_sf sf, exp, mant, sign, scratch
16956 + /* subnormal number */
16957 + rsub \exp,\exp, 1 /* shift amount */
16960 + brhs 90f /* Return zero */
16961 + rsub \scratch, \exp, 32
16962 + lsl \scratch, \mant,\scratch/* Check if there are any bits set
16963 + in the bits discarded in the mantissa */
16964 + srne \scratch /* If so set the lsb of the shifted mantissa */
16965 + lsr \mant,\mant,\exp /* Shift the mantissa */
16966 + or \mant, \scratch /* Round lsb if any bits were shifted out */
16967 + /* Rounding : For explaination, see round_sf. */
16968 + mov \scratch, 0x7f /* Set rounding constant */
16970 + subeq \scratch, -1 /* For odd numbers use rounding constant 0x80 */
16971 + add \mant, \scratch /* Add rounding constant to mantissa */
16972 + /* We can't overflow because mantissa is at least shifted one position
16973 + to the right so the implicit bit is zero. We can however get the implicit
16974 + bit set after rounding which means that we have the lowest normal number
16975 + but this is ok since this bit has the same position as the LSB of the
16977 + lsr \sf, \mant, 7
16978 + /* Rotate in sign */
16985 +/* Round the unpacked df number with exponent [exp] and
16986 + mantissa [mant_hi, mant_lo]. Uses scratch register
16988 +.macro round_df exp, mant_lo, mant_hi, scratch
16989 + mov \scratch, 0x3ff /* Rounding constant */
16990 + bld \mant_lo,11 /* Check if lsb in the final result is
16992 + subeq \scratch, -1 /* Adjust rounding constant to 0x400
16993 + if rounding 0.5 upwards */
16994 + add \mant_lo, \scratch /* Round */
16995 + acr \mant_hi /* If overflowing we know that
16996 + we have all zeros in the bits not
16997 + scaled out so we can leave them
16998 + but we must increase the exponent with
16999 + two since we had an implicit bit
17000 + which is lost + the extra overflow bit */
17001 + subcs \exp, -2 /* Update exponent */
17004 +/* Round single float number stored in [mant] and [exp] */
17005 +.macro round_sf exp, mant, scratch
17007 + For 0.5 we round to nearest even integer
17008 + for all other cases we round to nearest integer.
17009 + This means that if the digit left of the "point" (.)
17010 + is 1 we can add 0x80 to the mantissa since the
17011 + corner case 0x180 will round up to 0x200. If the
17012 + digit left of the "point" is 0 we will have to
17013 + add 0x7f since this will give 0xff and hence a
17014 + truncation/rounding downwards for the corner
17015 + case when the 9 lowest bits are 0x080 */
17016 + mov \scratch, 0x7f /* Set rounding constant */
17017 + /* Check if the mantissa is even or odd */
17019 + subeq \scratch, -1 /* Rounding constant should be 0x80 */
17020 + add \mant, \scratch
17021 + subcs \exp, -2 /* Adjust exponent if we overflowed */
17026 +/* Pack a single float number stored in [mant] and [exp]
17027 + into a single float number in [sf] */
17028 +.macro pack_sf sf, exp, mant
17029 + bld \mant,31 /* implicit bit to z */
17030 + subne \exp,1 /* if subnormal (implicit bit 0)
17031 + adjust exponent to storage format */
17033 + lsr \sf, \mant, 7
17034 + bfins \sf, \exp, 24, 8
17037 +/* Pack exponent [exp] and mantissa [mant_hi, mant_lo]
17038 + into [df_hi, df_lo]. [df_hi] is shifted
17039 + one bit up so the sign bit can be shifted into it */
17041 +.macro pack_df exp, mant_lo, mant_hi, df_lo, df_hi
17042 + bld \mant_hi,31 /* implicit bit to z */
17043 + subne \exp,1 /* if subnormal (implicit bit 0)
17044 + adjust exponent to storage format */
17046 + lsr \mant_lo,11 /* shift back lsw */
17047 + or \df_lo,\mant_lo,\mant_hi<<21 /* combine with low bits from msw */
17048 + lsl \mant_hi,1 /* get rid of implicit bit */
17049 + lsr \mant_hi,11 /* shift back msw except for one step*/
17050 + or \df_hi,\mant_hi,\exp<<21 /* combine msw with exponent */
17053 +/* Normalize single float number stored in [mant] and [exp]
17054 + using scratch register [scratch] */
17055 +.macro normalize_sf exp, mant, scratch
17056 + /* Adjust exponent and mantissa */
17057 + clz \scratch, \mant
17058 + sub \exp, \scratch
17059 + lsl \mant, \mant, \scratch
17062 +/* Normalize the exponent and mantissa pair stored
17063 + in [mant_hi,mant_lo] and [exp]. Needs two scratch
17064 + registers [scratch1] and [scratch2]. */
17065 +.macro normalize_df exp, mant_lo, mant_hi, scratch1, scratch2
17066 + clz \scratch1,\mant_hi /* Check if we have zeros in high bits */
17067 + breq 80f /* No need for scaling if no zeros in high bits */
17068 + brcs 81f /* Check for all zeros */
17070 + /* shift amount is smaller than 32, and involves both msw and lsw*/
17071 + rsub \scratch2,\scratch1,32 /* shift mantissa */
17072 + lsl \mant_hi,\mant_hi,\scratch1
17073 + lsr \scratch2,\mant_lo,\scratch2
17074 + or \mant_hi,\scratch2
17075 + lsl \mant_lo,\mant_lo,\scratch1
17076 + sub \exp,\scratch1 /* adjust exponent */
17077 + rjmp 80f /* Finished */
17079 + /* shift amount is greater than 32 */
17080 + clz \scratch1,\mant_lo /* shift mantissa */
17081 + movcs \scratch1, 0
17082 + subcc \scratch1,-32
17083 + lsl \mant_hi,\mant_lo,\scratch1
17085 + sub \exp,\scratch1 /* adjust exponent */
17090 +/* Fast but approximate multiply of two 64-bit numbers to give a 64 bit result.
17091 + The multiplication of [al]x[bl] is discarded.
17092 + Operands in [ah], [al], [bh], [bl].
17093 + Scratch registers in [sh], [sl].
17094 + Returns results in registers [rh], [rl].*/
17095 +.macro mul_approx_df ah, al, bh, bl, rh, rl, sh, sl
17096 + mulu.d \sl, \ah, \bl
17097 + macu.d \sl, \al, \bh
17098 + mulu.d \rl, \ah, \bh
17105 +#if defined(L_avr32_f64_mul) || defined(L_avr32_f64_mul_fast)
17107 +#if defined(L_avr32_f64_mul)
17108 + .global __avr32_f64_mul
17109 + .type __avr32_f64_mul,@function
17112 + .global __avr32_f64_mul_fast
17113 + .type __avr32_f64_mul_fast,@function
17114 +__avr32_f64_mul_fast:
17116 + or r12, r10, r11 << 1
17117 + breq __avr32_f64_mul_op1_zero
17119 +#if defined(L_avr32_f64_mul)
17122 + stm --sp, r5,r6,r7,lr
17125 +#define AVR32_F64_MUL_OP1_INT_BITS 1
17126 +#define AVR32_F64_MUL_OP2_INT_BITS 10
17127 +#define AVR32_F64_MUL_RES_INT_BITS 11
17129 + /* op1 in {r11,r10}*/
17130 + /* op2 in {r9,r8}*/
17131 + eor lr, r11, r9 /* MSB(lr) = Sign(op1) ^ Sign(op2) */
17133 + /* Unpack op1 to 1.63 format*/
17135 + /* sf: r11, r10 */
17136 + bfextu r7, r11, 20, 11 /* Extract exponent */
17140 + /* Check if normalization is needed */
17141 + breq __avr32_f64_mul_op1_subnormal /*If number is subnormal, normalize it */
17143 + lsl r11, (12-AVR32_F64_MUL_OP1_INT_BITS-1) /* Extract mantissa, leave room for implicit bit */
17144 + or r11, r11, r10>>(32-(12-AVR32_F64_MUL_OP1_INT_BITS-1))
17145 + lsl r10, (12-AVR32_F64_MUL_OP1_INT_BITS-1)
17146 + bfins r11, r5, 32 - (1 + AVR32_F64_MUL_OP1_INT_BITS), 1 + AVR32_F64_MUL_OP1_INT_BITS /* Insert implicit bit */
17150 + /* Unpack op2 to 10.54 format */
17153 + bfextu r6, r9, 20, 11 /* Extract exponent */
17155 + /* Check if normalization is needed */
17156 + breq __avr32_f64_mul_op2_subnormal /*If number is subnormal, normalize it */
17158 + lsl r8, 1 /* Extract mantissa, leave room for implicit bit */
17160 + bfins r9, r5, 32 - (1 + AVR32_F64_MUL_OP2_INT_BITS), 1 + AVR32_F64_MUL_OP2_INT_BITS /* Insert implicit bit */
17164 + /* Check if any operands are NaN or INF */
17166 + breq __avr32_f64_mul_op_nan_or_inf /* Check op1 for NaN or Inf */
17168 + breq __avr32_f64_mul_op_nan_or_inf /* Check op2 for NaN or Inf */
17171 + /* Calculate new exponent in r12*/
17173 + sub r12, (1023-1)
17175 +#if defined(L_avr32_f64_mul)
17176 + /* Do the multiplication.
17177 + Place result in [r11, r10, r7, r6]. The result is in 11.117 format. */
17178 + mulu.d r4, r11, r8
17179 + macu.d r4, r10, r9
17180 + mulu.d r6, r10, r8
17181 + mulu.d r10, r11, r9
17186 + /* Do the multiplication using approximate calculation. discard the al x bl
17188 + Place result in [r11, r10, r7]. The result is in 11.85 format. */
17190 + /* Do the multiplication using approximate calculation.
17191 + Place result in r11, r10. Use r7, r6 as scratch registers */
17192 + mulu.d r6, r11, r8
17193 + macu.d r6, r10, r9
17194 + mulu.d r10, r11, r9
17198 + /* Adjust exponent and mantissa */
17199 + /* [r12]:exp, [r11, r10]:mant [r7, r6]:sticky bits */
17200 + /* Mantissa may be of the format 00000000000.0xxx or 00000000000.1xxx. */
17201 + /* In the first case, shift one pos to left.*/
17202 + bld r11, 32-AVR32_F64_MUL_RES_INT_BITS-1
17210 + brle __avr32_f64_mul_res_subnormal /*Result was subnormal.*/
17212 + /* Check for Inf. */
17214 + brge __avr32_f64_mul_res_inf
17216 + /* Insert exponent. */
17217 + bfins r11, r12, 20, 11
17219 + /* Result was not subnormal. Perform rounding. */
17220 + /* For the fast version we discard the sticky bits and always round
17221 + the halfwaycase up. */
17223 +#if defined(L_avr32_f64_mul)
17224 + or r6, r6, r10 << 31 /* Or in parity bit into stickybits */
17225 + or r7, r7, r6 >> 1 /* Or together sticky and still make the msb
17226 + of r7 represent the halfway bit. */
17227 + eorh r7, 0x8000 /* Toggle halfway bit. */
17228 + /* We should now round up by adding one for the following cases:
17230 + halfway sticky|parity round-up
17235 + Since we have inverted the halfway bit we can use the satu instruction
17236 + by saturating to 1 bit to implement this.
17245 + /* Insert sign bit*/
17249 + /* Return result in [r11,r10] */
17250 +#if defined(L_avr32_f64_mul)
17253 + ldm sp++, r5, r6, r7,pc
17257 +__avr32_f64_mul_op1_subnormal:
17258 + andh r11, 0x000f /* Remove sign bit and exponent */
17259 + clz r12, r10 /* Count leading zeros in lsw */
17260 + clz r6, r11 /* Count leading zeros in msw */
17261 + subcs r12, -32 + AVR32_F64_MUL_OP1_INT_BITS
17263 + subcc r6, AVR32_F64_MUL_OP1_INT_BITS
17267 + /* shifting involves both msw and lsw*/
17268 + rsub r12, r6, 32 /* shift mantissa */
17270 + lsr r12, r10, r12
17273 + sub r6, 12-AVR32_F64_MUL_OP1_INT_BITS
17274 + sub r7, r6 /* adjust exponent */
17275 + rjmp 22b /* Finished */
17277 + /* msw is zero so only need to consider lsw */
17279 + breq __avr32_f64_mul_res_zero
17281 + sub r6, 12-AVR32_F64_MUL_OP1_INT_BITS
17282 + sub r7, r6 /* adjust exponent */
17286 +__avr32_f64_mul_op2_subnormal:
17287 + andh r9, 0x000f /* Remove sign bit and exponent */
17288 + clz r12, r8 /* Count leading zeros in lsw */
17289 + clz r5, r9 /* Count leading zeros in msw */
17290 + subcs r12, -32 + AVR32_F64_MUL_OP2_INT_BITS
17292 + subcc r5, AVR32_F64_MUL_OP2_INT_BITS
17296 + /* shifting involves both msw and lsw*/
17297 + rsub r12, r5, 32 /* shift mantissa */
17302 + sub r5, 12 - AVR32_F64_MUL_OP2_INT_BITS
17303 + sub r6, r5 /* adjust exponent */
17304 + rjmp 23b /* Finished */
17306 + /* msw is zero so only need to consider lsw */
17308 + breq __avr32_f64_mul_res_zero
17310 + sub r5, 12 - AVR32_F64_MUL_OP2_INT_BITS
17311 + sub r6, r5 /* adjust exponent */
17315 +__avr32_f64_mul_op_nan_or_inf:
17316 + /* Same code for OP1 and OP2*/
17317 + /* Since we are here, at least one of the OPs were NaN or INF*/
17318 + andh r9, 0x000f /* Remove sign bit and exponent */
17319 + andh r11, 0x000f /* Remove sign bit and exponent */
17320 + /* Merge the regs in each operand to check for zero*/
17321 + or r11, r10 /* op1 */
17322 + or r9, r8 /* op2 */
17323 + /* Check if op1 is NaN or INF */
17325 + brne __avr32_f64_mul_op1_not_naninf
17326 + /* op1 was NaN or INF.*/
17328 + brne __avr32_f64_mul_res_nan /* op1 was NaN. Result will be NaN*/
17329 + /*op1 was INF. check if op2 is NaN or INF*/
17331 + brne __avr32_f64_mul_res_inf /*op1 was INF, op2 was neither NaN nor INF*/
17332 + /* op1 is INF, op2 is either NaN or INF*/
17334 + breq __avr32_f64_mul_res_inf /*op2 was also INF*/
17335 + rjmp __avr32_f64_mul_res_nan /*op2 was NaN*/
17337 +__avr32_f64_mul_op1_not_naninf:
17338 + /* op1 was not NaN nor INF. Then op2 must be NaN or INF*/
17340 + breq __avr32_f64_mul_res_inf /*op2 was INF, return INF*/
17341 + rjmp __avr32_f64_mul_res_nan /*else return NaN*/
17343 +__avr32_f64_mul_res_subnormal:/* Multiply result was subnormal. */
17344 +#if defined(L_avr32_f64_mul)
17345 + /* Check how much we must scale down the mantissa. */
17347 + sub r12, -1 /* We do no longer have an implicit bit. */
17348 + satu r12 >> 0, 6 /* Saturate shift amount to max 63. */
17351 + /* Shift amount <32 */
17357 + lsr r10, r10, r12
17360 + lsr r11, r11, r12
17363 + /* Shift amount >=32 */
17370 + or r6, r6, r10 << 1
17371 + lsr r10, r10, r12
17373 + lsr r10, r11, r12
17377 + /* Flush to zero for the fast version. */
17378 + mov r11, lr /*Get correct sign*/
17379 + andh r11, 0x8000, COH
17381 + ldm sp++, r5, r6, r7,pc
17384 +__avr32_f64_mul_res_zero:/* Multiply result is zero. */
17385 + mov r11, lr /*Get correct sign*/
17386 + andh r11, 0x8000, COH
17388 +#if defined(L_avr32_f64_mul)
17391 + ldm sp++, r5, r6, r7,pc
17394 +__avr32_f64_mul_res_nan: /* Return NaN. */
17397 +#if defined(L_avr32_f64_mul)
17400 + ldm sp++, r5, r6, r7,pc
17403 +__avr32_f64_mul_res_inf: /* Return INF. */
17404 + mov r11, 0xfff00000
17408 +#if defined(L_avr32_f64_mul)
17411 + ldm sp++, r5, r6, r7,pc
17414 +__avr32_f64_mul_op1_zero:
17417 + andh r11, 0x8000, COH
17418 + /* Check if op2 is Inf or NaN. */
17419 + bfextu r12, r9, 20, 11
17421 + retne r12 /* Return 0.0 */
17432 +#if defined(L_avr32_f64_addsub) || defined(L_avr32_f64_addsub_fast)
17435 +__avr32_f64_sub_from_add:
17436 + /* Switch sign on op2 */
17439 +#if defined(L_avr32_f64_addsub_fast)
17440 + .global __avr32_f64_sub_fast
17441 + .type __avr32_f64_sub_fast,@function
17442 +__avr32_f64_sub_fast:
17444 + .global __avr32_f64_sub
17445 + .type __avr32_f64_sub,@function
17449 + /* op1 in {r11,r10}*/
17450 + /* op2 in {r9,r8}*/
17452 +#if defined(L_avr32_f64_addsub_fast)
17453 + /* If op2 is zero just return op1 */
17454 + or r12, r8, r9 << 1
17458 + /* Check signs */
17460 + /* Different signs, use addition. */
17461 + brmi __avr32_f64_add_from_sub
17463 + stm --sp, r5, r6, r7, lr
17465 + /* Get sign of op1 into r12 */
17467 + andh r12, 0x8000, COH
17469 + /* Remove sign from operands */
17473 + /* Put the largest number in [r11, r10]
17474 + and the smallest number in [r9, r8] */
17477 + brhs 1f /* Skip swap if operands already correctly ordered*/
17478 + /* Operands were not correctly ordered, swap them*/
17485 + eorh r12, 0x8000 /* Invert sign in r12*/
17487 + /* Unpack largest operand - opH */
17489 + /* sf: r11, r10 */
17490 + lsr r7, r11, 20 /* Extract exponent */
17491 + lsl r11, 11 /* Extract mantissa, leave room for implicit bit */
17492 + or r11, r11, r10>>21
17494 + sbr r11, 31 /* Insert implicit bit */
17497 + /* Unpack smallest operand - opL */
17500 + lsr r6, r9, 20 /* Extract exponent */
17501 + breq __avr32_f64_sub_opL_subnormal /* If either zero or subnormal */
17502 + lsl r9, 11 /* Extract mantissa, leave room for implicit bit */
17503 + or r9, r9, r8>>21
17505 + sbr r9, 31 /* Insert implicit bit */
17508 +__avr32_f64_sub_opL_subnormal_done:
17509 + /* opH is NaN or Inf. */
17511 + breq __avr32_f64_sub_opH_nan_or_inf
17513 + /* Get shift amount to scale mantissa of op2. */
17515 + breq __avr32_f64_sub_shift_done /* No need to shift, exponents are equal*/
17517 + /* Scale mantissa [r9, r8] with amount [r6].
17518 + Uses scratch registers [r5] and [lr].
17519 + In IEEE mode:Must not forget the sticky bits we intend to shift out. */
17521 + rsub r5,r6,32 /* get (32 - shift count)
17522 + (if shift count > 32 we get a
17523 + negative value, but that will
17524 + work as well in the code below.) */
17526 + cp.w r6,32 /* handle shifts >= 32 separately */
17527 + brhs __avr32_f64_sub_longshift
17529 + /* small (<32) shift amount, both words are part of the shift
17530 + first remember whether part that is lost contains any 1 bits ... */
17531 + lsl lr,r8,r5 /* shift away bits that are part of
17532 + final mantissa. only part that goes
17533 + to lr are bits that will be lost */
17535 + /* ... and now to the actual shift */
17536 + lsl r5,r9,r5 /* get bits from msw destined for lsw*/
17537 + lsr r8,r8,r6 /* shift down lsw of mantissa */
17538 + lsr r9,r9,r6 /* shift down msw of mantissa */
17539 + or r8,r5 /* combine these bits with prepared lsw*/
17540 +#if defined(L_avr32_f64_addsub)
17541 + cp.w lr,0 /* if any '1' bit in part we lost ...*/
17543 + or r8, lr /* ... we need to set sticky bit*/
17546 +__avr32_f64_sub_shift_done:
17547 + /* Now subtract the mantissas. */
17551 + /* Normalize the exponent and mantissa pair stored in
17552 + [r11,r10] and exponent in [r7]. Needs two scratch registers [r6] and [lr]. */
17553 + clz r6,r11 /* Check if we have zeros in high bits */
17554 + breq __avr32_f64_sub_longnormalize_done /* No need for scaling if no zeros in high bits */
17555 + brcs __avr32_f64_sub_longnormalize
17558 + /* shift amount is smaller than 32, and involves both msw and lsw*/
17559 + rsub lr,r6,32 /* shift mantissa */
17565 + sub r7,r6 /* adjust exponent */
17566 + brle __avr32_f64_sub_subnormal_result
17567 +__avr32_f64_sub_longnormalize_done:
17569 +#if defined(L_avr32_f64_addsub)
17570 + /* Insert the bits we will remove from the mantissa r9[31:21] */
17571 + lsl r9, r10, (32 - 11)
17573 + /* Keep the last bit shifted out. */
17574 + bfextu r9, r10, 10, 1
17577 + /* Pack final result*/
17578 + /* Input: [r7]:exp, [r11, r10]:mant, [r12]:sign in MSB */
17579 + /* Result in [r11,r10] */
17580 + /* Insert mantissa */
17582 + or r10, r10, r11<<21
17584 + /* Insert exponent and sign bit*/
17585 + bfins r11, r7, 20, 11
17589 +__avr32_f64_sub_round:
17590 +#if defined(L_avr32_f64_addsub)
17591 + mov_imm r7, 0x80000000
17601 + /* Return result in [r11,r10] */
17602 + ldm sp++, r5, r6, r7,pc
17606 +__avr32_f64_sub_opL_subnormal:
17607 + /* Extract the of mantissa */
17608 + lsl r9, 11 /* Extract mantissa, leave room for implicit bit */
17609 + or r9, r9, r8>>21
17612 + /* Set exponent to 1 if we do not have a zero. */
17616 + /* Check if opH is also subnormal. If so, clear implicit bit in r11*/
17621 + /* Check if op1 is zero, if so set exponent to 0. */
17625 + rjmp __avr32_f64_sub_opL_subnormal_done
17627 +__avr32_f64_sub_opH_nan_or_inf:
17628 + /* Check if opH is NaN, if so return NaN */
17631 + brne __avr32_f64_sub_return_nan
17633 + /* opH is Inf. */
17634 + /* Check if opL is Inf. or NaN */
17636 + breq __avr32_f64_sub_return_nan
17637 + /* Return infinity with correct sign. */
17638 + or r11, r12, r7 << 20
17639 + ldm sp++, r5, r6, r7, pc/* opL not Inf or NaN, return opH */
17640 +__avr32_f64_sub_return_nan:
17641 + mov r10, -1 /* Generate NaN in r11, r10 */
17643 + ldm sp++, r5, r6, r7, pc/* opL Inf or NaN, return NaN */
17646 +__avr32_f64_sub_subnormal_result:
17647 +#if defined(L_avr32_f64_addsub)
17648 + /* Check how much we must scale down the mantissa. */
17650 + sub r7, -1 /* We do no longer have an implicit bit. */
17651 + satu r7 >> 0, 6 /* Saturate shift amount to max 63. */
17654 + /* Shift amount <32 */
17659 + or r10, r6 /* Sticky bit from the
17660 + part that was shifted out. */
17664 + /* Set exponent */
17666 + rjmp __avr32_f64_sub_longnormalize_done
17668 + /* Shift amount >=32 */
17674 + or r10, r6 /* Sticky bit from the
17675 + part that was shifted out. */
17677 + /* Set exponent */
17679 + rjmp __avr32_f64_sub_longnormalize_done
17681 + /* Just flush subnormals to zero. */
17685 + ldm sp++, r5, r6, r7, pc
17687 +__avr32_f64_sub_longshift:
17688 + /* large (>=32) shift amount, only lsw will have bits left after shift.
17689 + note that shift operations will use ((shift count=r6) mod 32) so
17690 + we do not need to subtract 32 from shift count. */
17691 + /* Saturate the shift amount to 63. If the amount
17692 + is any larger op2 is insignificant. */
17695 +#if defined(L_avr32_f64_addsub)
17696 + /* first remember whether part that is lost contains any 1 bits ... */
17697 + moveq lr, r8 /* If shift amount is 32, no bits from msw are lost. */
17699 + lsl lr,r9,r5 /* save all lost bits from msw */
17700 + or lr,r8 /* also save lost bits (all) from lsw
17701 + now lr != 0 if we lose any bits */
17704 + /* ... and now to the actual shift */
17705 + lsr r8,r9,r6 /* Move msw to lsw and shift. */
17706 + mov r9,0 /* clear msw */
17707 +#if defined(L_avr32_f64_addsub)
17708 + cp.w lr,0 /* if any '1' bit in part we lost ...*/
17710 + or r8, lr /* ... we need to set sticky bit*/
17712 + rjmp __avr32_f64_sub_shift_done
17714 +__avr32_f64_sub_longnormalize:
17715 + /* shift amount is greater than 32 */
17716 + clz r6,r10 /* shift mantissa */
17717 + /* If the resulting mantissa is zero the result is
17718 + zero so force exponent to zero. */
17721 + movcs r12, 0 /* Also clear sign bit. A zero result from subtraction
17722 + always is +0.0 */
17726 + sub r7,r6 /* adjust exponent */
17727 + brle __avr32_f64_sub_subnormal_result
17728 + rjmp __avr32_f64_sub_longnormalize_done
17733 +__avr32_f64_add_from_sub:
17734 + /* Switch sign on op2 */
17737 +#if defined(L_avr32_f64_addsub_fast)
17738 + .global __avr32_f64_add_fast
17739 + .type __avr32_f64_add_fast,@function
17740 +__avr32_f64_add_fast:
17742 + .global __avr32_f64_add
17743 + .type __avr32_f64_add,@function
17747 + /* op1 in {r11,r10}*/
17748 + /* op2 in {r9,r8}*/
17750 +#if defined(L_avr32_f64_addsub_fast)
17751 + /* If op2 is zero just return op1 */
17752 + or r12, r8, r9 << 1
17756 + /* Check signs */
17758 + /* Different signs, use subtraction. */
17759 + brmi __avr32_f64_sub_from_add
17761 + stm --sp, r5, r6, r7, lr
17763 + /* Get sign of op1 into r12 */
17765 + andh r12, 0x8000, COH
17767 + /* Remove sign from operands */
17771 + /* Put the number with the largest exponent in [r11, r10]
17772 + and the number with the smallest exponent in [r9, r8] */
17774 + brhs 1f /* Skip swap if operands already correctly ordered */
17775 + /* Operands were not correctly ordered, swap them */
17783 + mov lr, 0 /* Set sticky bits to zero */
17784 + /* Unpack largest operand - opH */
17786 + /* sf: r11, r10 */
17787 + bfextu R7, R11, 20, 11 /* Extract exponent */
17788 + bfextu r11, r11, 0, 20 /* Extract mantissa */
17789 + sbr r11, 20 /* Insert implicit bit */
17791 + /* Unpack smallest operand - opL */
17794 + bfextu R6, R9, 20, 11 /* Extract exponent */
17795 + breq __avr32_f64_add_op2_subnormal
17796 + bfextu r9, r9, 0, 20 /* Extract mantissa */
17797 + sbr r9, 20 /* Insert implicit bit */
17800 + /* opH is NaN or Inf. */
17802 + breq __avr32_f64_add_opH_nan_or_inf
17804 + /* Get shift amount to scale mantissa of op2. */
17806 + breq __avr32_f64_add_shift_done /* No need to shift, exponents are equal*/
17808 + /* Scale mantissa [r9, r8] with amount [r6].
17809 + Uses scratch registers [r5] and [lr].
17810 + In IEEE mode:Must not forget the sticky bits we intend to shift out. */
17811 + rsub r5,r6,32 /* get (32 - shift count)
17812 + (if shift count > 32 we get a
17813 + negative value, but that will
17814 + work as well in the code below.) */
17816 + cp.w r6,32 /* handle shifts >= 32 separately */
17817 + brhs __avr32_f64_add_longshift
17819 + /* small (<32) shift amount, both words are part of the shift
17820 + first remember whether part that is lost contains any 1 bits ... */
17821 + lsl lr,r8,r5 /* shift away bits that are part of
17822 + final mantissa. only part that goes
17823 + to lr are bits that will be lost */
17825 + /* ... and now to the actual shift */
17826 + lsl r5,r9,r5 /* get bits from msw destined for lsw*/
17827 + lsr r8,r8,r6 /* shift down lsw of mantissa */
17828 + lsr r9,r9,r6 /* shift down msw of mantissa */
17829 + or r8,r5 /* combine these bits with prepared lsw*/
17831 +__avr32_f64_add_shift_done:
17832 + /* Now add the mantissas. */
17836 + /* Check if we overflowed. */
17838 + breq __avr32_f64_add_res_of:
17840 +__avr32_f64_add_res_of_done:
17842 + /* Pack final result*/
17843 + /* Input: [r7]:exp, [r11, r10]:mant, [r12]:sign in MSB */
17844 + /* Result in [r11,r10] */
17845 + /* Insert exponent and sign bit*/
17846 + bfins r11, r7, 20, 11
17850 +__avr32_f64_add_round:
17851 +#if defined(L_avr32_f64_addsub)
17852 + bfextu r12, r10, 0, 1 /* Extract parity bit.*/
17853 + or lr, r12 /* or it together with the sticky bits. */
17854 + eorh lr, 0x8000 /* Toggle round bit. */
17855 + /* We should now round up by adding one for the following cases:
17857 + halfway sticky|parity round-up
17862 + Since we have inverted the halfway bit we can use the satu instruction
17863 + by saturating to 1 bit to implement this.
17872 + /* Return result in [r11,r10] */
17873 + ldm sp++, r5, r6, r7,pc
17876 +__avr32_f64_add_opH_nan_or_inf:
17877 + /* Check if opH is NaN, if so return NaN */
17880 + brne __avr32_f64_add_return_nan
17882 + /* opH is Inf. */
17883 + /* Check if opL is Inf. or NaN */
17885 + breq __avr32_f64_add_opL_nan_or_inf
17886 + ldm sp++, r5, r6, r7, pc/* opL not Inf or NaN, return opH */
17887 +__avr32_f64_add_opL_nan_or_inf:
17890 + brne __avr32_f64_add_return_nan
17891 + mov r10, 0 /* Generate Inf in r11, r10 */
17892 + mov_imm r11, 0x7ff00000
17893 + or r11, r12 /* Put sign bit back */
17894 + ldm sp++, r5, r6, r7, pc/* opL Inf, return Inf */
17895 +__avr32_f64_add_return_nan:
17896 + mov r10, -1 /* Generate NaN in r11, r10 */
17898 + ldm sp++, r5, r6, r7, pc/* opL Inf or NaN, return NaN */
17901 +__avr32_f64_add_longshift:
17902 + /* large (>=32) shift amount, only lsw will have bits left after shift.
17903 + note that shift operations will use ((shift count=r6) mod 32) so
17904 + we do not need to subtract 32 from shift count. */
17905 + /* Saturate the shift amount to 63. If the amount
17906 + is any larger op2 is insignificant. */
17908 + /* If shift amount is 32 there are no bits from the msw that are lost. */
17911 + /* first remember whether part that is lost contains any 1 bits ... */
17912 + lsl lr,r9,r5 /* save all lost bits from msw */
17913 +#if defined(L_avr32_f64_addsub)
17916 + or lr,r8 /* also save lost bits (all) from lsw
17917 + now lr != 0 if we lose any bits */
17920 + /* ... and now to the actual shift */
17921 + lsr r8,r9,r6 /* msw -> lsw and make rest of shift inside lsw*/
17922 + mov r9,0 /* clear msw */
17923 + rjmp __avr32_f64_add_shift_done
17925 +__avr32_f64_add_res_of:
17926 + /* We overflowed. Scale down mantissa by shifting right one position. */
17927 + or lr, lr, lr << 1 /* Remember stickybits*/
17931 + sub r7, -1 /* Increment exponent */
17933 + /* Clear mantissa to set result to Inf if the exponent is 255. */
17938 + rjmp __avr32_f64_add_res_of_done
17940 +__avr32_f64_add_op2_subnormal:
17941 + /* Set epxponent to 1 */
17944 + /* Check if op2 is also subnormal. */
17949 + /* Both operands are subnormal. Just addd the mantissas
17950 + and the exponent will automatically be set to 1 if
17951 + we overflow into a normal number. */
17955 + /* Add sign bit */
17958 + /* Return result in [r11,r10] */
17959 + ldm sp++, r5, r6, r7,pc
17965 +#ifdef L_avr32_f64_to_u32
17966 + /* This goes into L_fixdfsi */
17970 +#ifdef L_avr32_f64_to_s32
17971 + .global __avr32_f64_to_u32
17972 + .type __avr32_f64_to_u32,@function
17973 +__avr32_f64_to_u32:
17975 + retmi 0 /* Negative returns 0 */
17977 + /* Fallthrough to df to signed si conversion */
17978 + .global __avr32_f64_to_s32
17979 + .type __avr32_f64_to_s32,@function
17980 +__avr32_f64_to_s32:
17982 + lsr r12,21 /* extract exponent*/
17983 + sub r12,1023 /* convert to unbiased exponent.*/
17984 + retlo 0 /* too small exponent implies zero. */
17987 + rsub r12,r12,31 /* shift count = 31 - exponent */
17988 + mov r9,r11 /* save sign for later...*/
17989 + lsl r11,11 /* remove exponent and sign*/
17990 + sbr r11,31 /* add implicit bit*/
17991 + or r11,r11,r10>>21 /* get rest of bits from lsw of double */
17992 + lsr r11,r11,r12 /* shift down mantissa to final place */
17993 + lsl r9,1 /* sign -> carry */
17994 + retcc r11 /* if positive, we are done */
17995 + neg r11 /* if negative float, negate result */
17998 +#endif /* L_fixdfsi*/
18000 +#ifdef L_avr32_f64_to_u64
18001 + /* Actual function is in L_fixdfdi */
18004 +#ifdef L_avr32_f64_to_s64
18005 + .global __avr32_f64_to_u64
18006 + .type __avr32_f64_to_u64,@function
18007 +__avr32_f64_to_u64:
18009 + /* Negative numbers return zero */
18016 + /* Fallthrough */
18017 + .global __avr32_f64_to_s64
18018 + .type __avr32_f64_to_s64,@function
18019 +__avr32_f64_to_s64:
18021 + lsr r9,21 /* get exponent*/
18022 + sub r9,1023 /* convert to correct range*/
18023 + /* Return zero if exponent to small */
18028 + mov r8,r11 /* save sign for later...*/
18030 + lsl r11,11 /* remove exponent */
18031 + sbr r11,31 /* add implicit bit*/
18032 + or r11,r11,r10>>21 /* get rest of bits from lsw of double*/
18033 + lsl r10,11 /* align lsw correctly as well */
18034 + rsub r9,r9,63 /* shift count = 63 - exponent */
18037 + cp.w r9,32 /* is shift count more than one reg? */
18040 + mov r12,r11 /* save msw */
18041 + lsr r10,r10,r9 /* small shift count, shift down lsw */
18042 + lsr r11,r11,r9 /* small shift count, shift down msw */
18043 + rsub r9,r9,32 /* get 32-size of shifted out tail */
18044 + lsl r12,r12,r9 /* align part to move from msw to lsw */
18045 + or r10,r12 /* combine to get new lsw */
18049 + lsr r10,r11,r9 /* large shift count,only lsw get bits
18050 + note that shift count is modulo 32*/
18051 + mov r11,0 /* msw will be 0 */
18054 + lsl r8,1 /* sign -> carry */
18055 + retcc r11 /* if positive, we are done */
18057 + neg r11 /* if negative float, negate result */
18064 +#ifdef L_avr32_u32_to_f64
18065 + /* Code located in L_floatsidf */
18068 +#ifdef L_avr32_s32_to_f64
18069 + .global __avr32_u32_to_f64
18070 + .type __avr32_u32_to_f64,@function
18071 +__avr32_u32_to_f64:
18072 + sub r11, r12, 0 /* Move to r11 and force Z flag to be updated */
18073 + mov r12, 0 /* always positive */
18074 + rjmp 0f /* Jump to common code for floatsidf */
18076 + .global __avr32_s32_to_f64
18077 + .type __avr32_s32_to_f64,@function
18078 +__avr32_s32_to_f64:
18079 + mov r11, r12 /* Keep original value in r12 for sign */
18080 + abs r11 /* Absolute value if r12 */
18082 + mov r10,0 /* let remaining bits be zero */
18083 + reteq r11 /* zero long will return zero float */
18086 + mov r9,31+1023 /* set exponent */
18088 + normalize_df r9 /*exp*/, r10, r11 /* mantissa */, r8, lr /* scratch */
18090 + /* Check if a subnormal result was created */
18094 + adjust_subnormal_df r9 /* exp */, r10, r11 /* Mantissa */, r12 /*sign*/, r8, lr /* scratch */
18098 + /* Round result */
18099 + round_df r9 /*exp*/, r10, r11 /* Mantissa */, r8 /*scratch*/
18102 + /*Return infinity */
18104 + mov_imm r11, 0xffe00000
18105 + rjmp __floatsidf_return_op1
18110 + pack_df r9 /*exp*/, r10, r11 /* mantissa */, r10, r11 /* Output df number*/
18111 +__floatsidf_return_op1:
18112 + lsl r12,1 /* shift in sign bit */
18119 +#ifdef L_avr32_f32_cmp_eq
18120 + .global __avr32_f32_cmp_eq
18121 + .type __avr32_f32_cmp_eq,@function
18122 +__avr32_f32_cmp_eq:
18125 + /* If not equal check for +/-0 */
18126 + /* Or together the two values and shift out the sign bit.
18127 + If the result is zero, then the two values are both zero. */
18133 + /* Numbers were equal. Check for NaN or Inf */
18134 + mov_imm r11, 0xff000000
18137 + retls 1 /* 0 if NaN, 1 otherwise */
18141 +#if defined(L_avr32_f32_cmp_ge) || defined(L_avr32_f32_cmp_lt)
18142 +#ifdef L_avr32_f32_cmp_ge
18143 + .global __avr32_f32_cmp_ge
18144 + .type __avr32_f32_cmp_ge,@function
18145 +__avr32_f32_cmp_ge:
18147 +#ifdef L_avr32_f32_cmp_lt
18148 + .global __avr32_f32_cmp_lt
18149 + .type __avr32_f32_cmp_lt,@function
18150 +__avr32_f32_cmp_lt:
18152 + lsl r10, r12, 1 /* Remove sign bits */
18155 +#ifdef L_avr32_f32_cmp_ge
18156 + reteq 1 /* Both number are zero. Return true. */
18158 +#ifdef L_avr32_f32_cmp_lt
18159 + reteq 0 /* Both number are zero. Return false. */
18161 + mov_imm r8, 0xff000000
18163 + rethi 0 /* Op0 is NaN */
18165 + rethi 0 /* Op1 is Nan */
18169 +#ifdef L_avr32_f32_cmp_ge
18170 + srcc r8 /* Set result to true if op0 is positive*/
18172 +#ifdef L_avr32_f32_cmp_lt
18173 + srcs r8 /* Set result to true if op0 is negative*/
18175 + retmi r8 /* Return if signs are different */
18176 + brcs 0f /* Both signs negative? */
18178 + /* Both signs positive */
18180 +#ifdef L_avr32_f32_cmp_ge
18184 +#ifdef L_avr32_f32_cmp_lt
18189 + /* Both signs negative */
18191 +#ifdef L_avr32_f32_cmp_ge
18195 +#ifdef L_avr32_f32_cmp_lt
18202 +#ifdef L_avr32_f64_cmp_eq
18203 + .global __avr32_f64_cmp_eq
18204 + .type __avr32_f64_cmp_eq,@function
18205 +__avr32_f64_cmp_eq:
18210 + /* Args were not equal*/
18211 + /* Both args could be zero with different sign bits */
18212 + lsl r11,1 /* get rid of sign bits */
18214 + or r11,r10 /* Check if all bits are zero */
18217 + reteq 1 /* If all zeros the arguments are equal
18218 + so return 1 else return 0 */
18221 + /* check for NaN */
18223 + mov_imm r12, 0xffe00000
18225 + cpc r11,r12 /* check if nan or inf */
18226 + retls 1 /* If Arg is NaN return 0 else 1*/
18227 + ret 0 /* Return */
18232 +#if defined(L_avr32_f64_cmp_ge) || defined(L_avr32_f64_cmp_lt)
18234 +#ifdef L_avr32_f64_cmp_ge
18235 + .global __avr32_f64_cmp_ge
18236 + .type __avr32_f64_cmp_ge,@function
18237 +__avr32_f64_cmp_ge:
18239 +#ifdef L_avr32_f64_cmp_lt
18240 + .global __avr32_f64_cmp_lt
18241 + .type __avr32_f64_cmp_lt,@function
18242 +__avr32_f64_cmp_lt:
18245 + /* compare magnitude of op1 and op2 */
18248 + lsl r11,1 /* Remove sign bit of op1 */
18249 + srcs r12 /* Sign op1 to lsb of r12*/
18250 + lsl r9,1 /* Remove sign bit of op2 */
18252 + rol r12 /* Sign op2 to lsb of lr, sign bit op1 bit 1 of r12*/
18255 + /* Check for Nan */
18256 + mov_imm lr, 0xffe00000
18259 + brhi 0f /* We have NaN */
18262 + brhi 0f /* We have NaN */
18266 + breq 3f /* op1 zero */
18270 + cp.w r12,3 /* both operands negative ?*/
18273 + cp.w r12,1 /* both operands positive? */
18276 + /* Different signs. If sign of op1 is negative the difference
18277 + between op1 and op2 will always be negative, and if op1 is
18278 + positive the difference will always be positive */
18279 +#ifdef L_avr32_f64_cmp_ge
18283 +#ifdef L_avr32_f64_cmp_lt
18289 + /* Both operands positive. Just compute the difference */
18292 +#ifdef L_avr32_f64_cmp_ge
18296 +#ifdef L_avr32_f64_cmp_lt
18302 + /* Both operands negative. Compute the difference with operands switched */
18305 +#ifdef L_avr32_f64_cmp_ge
18309 +#ifdef L_avr32_f64_cmp_lt
18320 + cp.w r7, 1 /* Check sign bit from r9 */
18321 +#ifdef L_avr32_f64_cmp_ge
18322 + sreq r12 /* If op2 is negative then op1 >= op2. */
18324 +#ifdef L_avr32_f64_cmp_lt
18325 + srne r12 /* If op2 is positve then op1 <= op2. */
18331 +#ifdef L_avr32_f64_cmp_ge
18332 + reteq 1 /* Both operands are zero. Return true. */
18334 +#ifdef L_avr32_f64_cmp_lt
18335 + reteq 0 /* Both operands are zero. Return false. */
18340 +#if defined(L_avr32_f64_div) || defined(L_avr32_f64_div_fast)
18343 +#if defined(L_avr32_f64_div_fast)
18344 + .global __avr32_f64_div_fast
18345 + .type __avr32_f64_div_fast,@function
18346 +__avr32_f64_div_fast:
18348 + .global __avr32_f64_div
18349 + .type __avr32_f64_div,@function
18352 + stm --sp, r0, r1, r2, r3, r4, r5, r6, r7,lr
18353 + /* op1 in {r11,r10}*/
18354 + /* op2 in {r9,r8}*/
18355 + eor lr, r11, r9 /* MSB(lr) = Sign(op1) ^ Sign(op2) */
18358 + /* Unpack op1 to 2.62 format*/
18360 + /* sf: r11, r10 */
18361 + lsr r7, r11, 20 /* Extract exponent */
18363 + lsl r11, 9 /* Extract mantissa, leave room for implicit bit */
18364 + or r11, r11, r10>>23
18366 + sbr r11, 29 /* Insert implicit bit */
18367 + andh r11, 0x3fff /*Mask last part of exponent since we use 2.62 format*/
18369 + cbr r7, 11 /* Clear sign bit */
18370 + /* Check if normalization is needed */
18371 + breq 11f /*If number is subnormal, normalize it */
18374 + brge 2f /* Check op1 for NaN or Inf */
18376 + /* Unpack op2 to 2.62 format*/
18379 + lsr r6, r9, 20 /* Extract exponent */
18381 + lsl r9, 9 /* Extract mantissa, leave room for implicit bit */
18382 + or r9, r9, r8>>23
18384 + sbr r9, 29 /* Insert implicit bit */
18385 + andh r9, 0x3fff /*Mask last part of exponent since we use 2.62 format*/
18387 + cbr r6, 11 /* Clear sign bit */
18388 + /* Check if normalization is needed */
18389 + breq 13f /*If number is subnormal, normalize it */
18392 + brge 3f /* Check op2 for NaN or Inf */
18394 + /* Calculate new exponent */
18399 + /* Approximating 1/d with the following recurrence: */
18400 + /* R[j+1] = R[j]*(2-R[j]*d) */
18401 + /* Using 2.62 format */
18403 + /* d = op2 = divisor (2.62 format): r9,r8 */
18404 + /* Multiply result : r5, r4 */
18405 + /* Initial guess : r3, r2 */
18406 + /* New approximations : r3, r2 */
18407 + /* op1 = Dividend (2.62 format) : r11, r10 */
18409 + mov_imm r12, 0x80000000
18411 + /* Load initial guess, using look-up table */
18412 + /* Initial guess is of format 01.XY, where XY is constructed as follows: */
18413 + /* Let d be of following format: 00.1xy....., then XY=~xy */
18414 + /* For d=00.100 = 0,5 -> initial guess=01.11 = 1,75 */
18415 + /* For d=00.101 = 0,625 -> initial guess=01.11 = 1,5 */
18416 + /* For d=00.110 = 0,75 -> initial guess=01.11 = 1,25 */
18417 + /* For d=00.111 = 0,875 -> initial guess=01.11 = 1,0 */
18418 + /* r2 is also part of the reg pair forming initial guess, but it*/
18419 + /* is kept uninitialized to save one cycle since it has so low significance*/
18422 + bfextu r4, r9, 27, 2
18424 + bfins r3, r4, 28, 2
18426 + /* First approximation */
18427 + /* Approximating to 32 bits */
18428 + /* r5 = R[j]*d */
18429 + mulu.d r4, r3, r9
18430 + /* r5 = 2-R[j]*d */
18431 + sub r5, r12, r5<<2
18432 + /* r3 = R[j]*(2-R[j]*d) */
18433 + mulu.d r4, r3, r5
18436 + /* Second approximation */
18437 + /* Approximating to 32 bits */
18438 + /* r5 = R[j]*d */
18439 + mulu.d r4, r3, r9
18440 + /* r5 = 2-R[j]*d */
18441 + sub r5, r12, r5<<2
18442 + /* r3 = R[j]*(2-R[j]*d) */
18443 + mulu.d r4, r3, r5
18446 + /* Third approximation */
18447 + /* Approximating to 32 bits */
18448 + /* r5 = R[j]*d */
18449 + mulu.d r4, r3, r9
18450 + /* r5 = 2-R[j]*d */
18451 + sub r5, r12, r5<<2
18452 + /* r3 = R[j]*(2-R[j]*d) */
18453 + mulu.d r4, r3, r5
18456 + /* Fourth approximation */
18457 + /* Approximating to 64 bits */
18458 + /* r5,r4 = R[j]*d */
18459 + mul_approx_df r3 /*ah*/, r2 /*al*/, r9 /*bh*/, r8 /*bl*/, r5 /*rh*/, r4 /*rl*/, r1 /*sh*/, r0 /*sl*/
18461 + or r5, r5, r4>>30
18463 + /* r5,r4 = 2-R[j]*d */
18466 + /* r3,r2 = R[j]*(2-R[j]*d) */
18467 + mul_approx_df r3 /*ah*/, r2 /*al*/, r5 /*bh*/, r4 /*bl*/, r5 /*rh*/, r4 /*rl*/, r1 /*sh*/, r0 /*sl*/
18469 + or r3, r3, r4>>30
18473 + /* Fifth approximation */
18474 + /* Approximating to 64 bits */
18475 + /* r5,r4 = R[j]*d */
18476 + mul_approx_df r3 /*ah*/, r2 /*al*/, r9 /*bh*/, r8 /*bl*/, r5 /*rh*/, r4 /*rl*/, r1 /*sh*/, r0 /*sl*/
18478 + or r5, r5, r4>>30
18480 + /* r5,r4 = 2-R[j]*d */
18483 + /* r3,r2 = R[j]*(2-R[j]*d) */
18484 + mul_approx_df r3 /*ah*/, r2 /*al*/, r5 /*bh*/, r4 /*bl*/, r5 /*rh*/, r4 /*rl*/, r1 /*sh*/, r0 /*sl*/
18486 + or r3, r3, r4>>30
18490 + /* Multiply with dividend to get quotient */
18491 + mul_approx_df r3 /*ah*/, r2 /*al*/, r11 /*bh*/, r10 /*bl*/, r3 /*rh*/, r2 /*rl*/, r1 /*sh*/, r0 /*sl*/
18494 + /* To increase speed, this result is not corrected before final rounding.*/
18495 + /* This may give a difference to IEEE compliant code of 1 ULP.*/
18498 + /* Adjust exponent and mantissa */
18499 + /* r7:exp, [r3, r2]:mant, [r5, r4]:scratch*/
18500 + /* Mantissa may be of the format 0.xxxx or 1.xxxx. */
18501 + /* In the first case, shift one pos to left.*/
18507 +#if defined(L_avr32_f64_div)
18508 + /* We must scale down the dividend to 5.59 format. */
18510 + or r10, r10, r11 << 29
18515 +#if defined(L_avr32_f64_div)
18516 + /* We must scale down the dividend to 6.58 format. */
18518 + or r10, r10, r11 << 28
18523 + brle __avr32_f64_div_res_subnormal /* Result was subnormal. */
18526 +#if defined(L_avr32_f64_div)
18527 + /* In order to round correctly we calculate the remainder:
18528 + Remainder = dividend[11:r10] - divisor[r9:r8]*quotient[r3:r2]
18529 + for the case when the quotient is halfway between the round-up
18530 + value and the round down value. If the remainder then is negative
18531 + it means that the quotient was to big and that it should not be
18532 + rounded up, if the remainder is positive the quotient was to small
18533 + and we need to round up. If the remainder is zero it means that the
18534 + quotient is exact but since we need to remove the guard bit we should
18535 + round to even. */
18537 + /* Truncate and add guard bit. */
18542 + /* Now do the multiplication. The quotient has the format 4.60
18543 + while the divisor has the format 2.62 which gives a result
18545 + mulu.d r0, r3, r8
18546 + macu.d r0, r2, r9
18547 + mulu.d r4, r2, r8
18548 + mulu.d r8, r3, r9
18554 + /* Check if remainder is positive, negative or equal. */
18555 + bfextu r12, r2, 8, 1 /* Get parity bit into bit 0 of r0 */
18558 +__avr32_f64_div_round_subnormal:
18561 + srlo r6 /* Remainder positive: we need to round up.*/
18562 + moveq r6, r12 /* Remainder zero: round up if mantissa odd. */
18564 + bfextu r6, r2, 7, 1 /* Get guard bit */
18566 + /* Final packing, scale down mantissa. */
18568 + or r10, r10, r3<<24
18570 + /* Insert exponent and sign bit*/
18571 + bfins r11, r7, 20, 11
18575 + /* Final rounding */
18579 + /* Return result in [r11,r10] */
18580 + ldm sp++, r0, r1, r2, r3, r4, r5, r6, r7,pc
18584 + /* Op1 is NaN or inf */
18585 + andh r11, 0x000f /* Extract mantissa */
18587 + brne 16f /* Return NaN if op1 is NaN */
18588 + /* Op1 is inf check op2 */
18589 + lsr r6, r9, 20 /* Extract exponent */
18590 + cbr r6, 11 /* Clear sign bit */
18592 + brne 17f /* Inf/number gives inf, return inf */
18593 + rjmp 16f /* The rest gives NaN*/
18596 + /* Op1 is a valid number. Op 2 is NaN or inf */
18597 + andh r9, 0x000f /* Extract mantissa */
18599 + brne 16f /* Return NaN if op2 is NaN */
18600 + rjmp 15f /* Op2 was inf, return zero*/
18602 +11: /* Op1 was denormal. Fix it. */
18604 + or r11, r11, r10 >> 29
18606 + /* Check if op1 is zero. */
18608 + breq __avr32_f64_div_op1_zero
18609 + normalize_df r7 /*exp*/, r10, r11 /*Mantissa*/, r4, r5 /*scratch*/
18611 + or r10, r10, r11 << 30
18616 +13: /* Op2 was denormal. Fix it */
18618 + or r9, r9, r8 >> 29
18620 + /* Check if op2 is zero. */
18622 + breq 17f /* Divisor is zero -> return Inf */
18623 + normalize_df r6 /*exp*/, r8, r9 /*Mantissa*/, r4, r5 /*scratch*/
18625 + or r8, r8, r9 << 30
18630 +__avr32_f64_div_res_subnormal:/* Divide result was subnormal. */
18631 +#if defined(L_avr32_f64_div)
18632 + /* Check how much we must scale down the mantissa. */
18634 + sub r7, -1 /* We do no longer have an implicit bit. */
18635 + satu r7 >> 0, 6 /* Saturate shift amount to max 63. */
18638 + /* Shift amount <32 */
18639 + /* Scale down quotient */
18645 + /* Scale down the dividend to match the scaling of the quotient. */
18654 + /* Shift amount >=32 */
18664 + /* Scale down the dividend to match the scaling of the quotient. */
18670 + /* Start performing the same rounding as done for normal numbers
18671 + but this time we have scaled the quotient and dividend and hence
18672 + need a little different comparison. */
18673 + /* Truncate and add guard bit. */
18677 + /* Now do the multiplication. */
18678 + mulu.d r6, r3, r8
18679 + macu.d r6, r2, r9
18680 + mulu.d r4, r2, r8
18681 + mulu.d r8, r3, r9
18686 + /* Set exponent to 0 */
18689 + /* Check if remainder is positive, negative or equal. */
18690 + bfextu r12, r2, 8, 1 /* Get parity bit into bit 0 of r0 */
18693 + /* Now the rest of the rounding is the same as for normals. */
18694 + rjmp __avr32_f64_div_round_subnormal
18698 + /* Flush to zero for the fast version. */
18699 + mov r11, lr /*Get correct sign*/
18700 + andh r11, 0x8000, COH
18702 + ldm sp++, r0, r1, r2, r3, r4, r5, r6, r7,pc
18704 +16: /* Return NaN. */
18707 + ldm sp++, r0, r1, r2, r3, r4, r5, r6, r7,pc
18710 + /* Check if op1 is zero. */
18712 + breq __avr32_f64_div_op1_zero
18713 + /* Return INF. */
18714 + mov r11, lr /*Get correct sign*/
18715 + andh r11, 0x8000, COH
18718 + ldm sp++, r0, r1, r2, r3, r4, r5, r6, r7,pc
18720 +__avr32_f64_div_op1_zero:
18721 + or r5, r8, r9 << 1
18722 + breq 16b /* 0.0/0.0 -> NaN */
18723 + bfextu r4, r9, 20, 11
18725 + brne 15b /* Return zero */
18726 + /* Check if divisor is Inf or NaN */
18727 + or r5, r8, r9 << 12
18728 + breq 15b /* Divisor is inf -> return zero */
18729 + rjmp 16b /* Return NaN */
18736 +#if defined(L_avr32_f32_addsub) || defined(L_avr32_f32_addsub_fast)
18739 +__avr32_f32_sub_from_add:
18740 + /* Switch sign on op2 */
18743 +#if defined(L_avr32_f32_addsub_fast)
18744 + .global __avr32_f32_sub_fast
18745 + .type __avr32_f32_sub_fast,@function
18746 +__avr32_f32_sub_fast:
18748 + .global __avr32_f32_sub
18749 + .type __avr32_f32_sub,@function
18753 + /* Check signs */
18755 + /* Different signs, use subtraction. */
18756 + brmi __avr32_f32_add_from_sub
18758 + /* Get sign of op1 */
18760 + andh r12, 0x8000, COH
18762 + /* Remove sign from operands */
18764 +#if defined(L_avr32_f32_addsub_fast)
18765 + reteq r8 /* If op2 is zero return op1 */
18769 + /* Put the number with the largest exponent in r10
18770 + and the number with the smallest exponent in r9 */
18773 + cp r10, r8 /*If largest operand (in R10) is not equal to op1*/
18774 + subne r12, 1 /* Subtract 1 from sign, which will invert MSB of r12*/
18775 + andh r12, 0x8000, COH /*Mask all but MSB*/
18777 + /* Unpack exponent and mantissa of op1 */
18779 + sbr r8, 31 /* Set implicit bit. */
18782 + /* op1 is NaN or Inf. */
18784 + breq __avr32_f32_sub_op1_nan_or_inf
18786 + /* Unpack exponent and mantissa of op2 */
18788 + sbr r11, 31 /* Set implicit bit. */
18791 +#if defined(L_avr32_f32_addsub)
18792 + /* Keep sticky bit for correct IEEE rounding */
18795 + /* op2 is either zero or subnormal. */
18796 + breq __avr32_f32_sub_op2_subnormal
18798 + /* Get shift amount to scale mantissa of op2. */
18801 + breq __avr32_f32_sub_shift_done
18803 + /* Saturate the shift amount to 31. If the amount
18804 + is any larger op2 is insignificant. */
18807 + /* Put the remaining bits into r9.*/
18811 + /* If the remaining bits are non-zero then we must subtract one
18812 + more from opL. */
18814 + srne r9 /* LSB of r9 represents sticky bits. */
18816 + /* Shift mantissa of op2 to same decimal point as the mantissa
18818 + lsr r11, r11, r12
18821 +__avr32_f32_sub_shift_done:
18822 + /* Now subtract the mantissas. */
18827 + /* Normalize resulting mantissa. */
18833 + brle __avr32_f32_sub_subnormal_result
18835 + /* Insert the bits we will remove from the mantissa into r9[31:24] */
18836 + or r9, r9, r8 << 24
18838 + /* Ignore sticky bit to simplify and speed up rounding */
18839 + /* op2 is either zero or subnormal. */
18840 + breq __avr32_f32_sub_op2_subnormal
18842 + /* Get shift amount to scale mantissa of op2. */
18845 + /* Saturate the shift amount to 31. If the amount
18846 + is any larger op2 is insignificant. */
18849 + /* Shift mantissa of op2 to same decimal point as the mantissa
18853 + /* Now subtract the mantissas. */
18856 + /* Normalize resulting mantissa. */
18861 + brle __avr32_f32_sub_subnormal_result
18864 + /* Pack result. */
18865 + or r12, r12, r8 >> 8
18866 + bfins r12, r10, 23, 8
18869 +__avr32_f32_sub_round:
18870 +#if defined(L_avr32_f32_addsub)
18871 + mov_imm r10, 0x80000000
18884 +__avr32_f32_sub_op2_subnormal:
18885 + /* Fix implicit bit and adjust exponent of subnormals. */
18887 + /* Set exponent to 1 if we do not have a zero. */
18890 + /* Check if op1 is also subnormal. */
18895 + /* If op1 is not zero set exponent to 1. */
18900 +__avr32_f32_sub_op1_nan_or_inf:
18901 + /* Check if op1 is NaN, if so return NaN */
18905 + /* op1 is Inf. */
18906 + bfins r12, r10, 23, 8 /* Generate Inf in r12 */
18908 + /* Check if op2 is Inf. or NaN */
18911 + retne r12 /* op2 not Inf or NaN, return op1 */
18913 + ret -1 /* op2 Inf or NaN, return NaN */
18915 +__avr32_f32_sub_subnormal_result:
18916 + /* Check if the number is so small that
18917 + it will be represented with zero. */
18919 + rsub r11, r10, 32
18922 + /* Shift the mantissa into the correct position.*/
18924 + /* Add sign bit. */
18927 + /* Put the shifted out bits in the most significant part
18931 +#if defined(L_avr32_f32_addsub)
18932 + /* Add all the remainder bits used for rounding into r9 */
18937 + rjmp __avr32_f32_sub_round
18942 +__avr32_f32_add_from_sub:
18943 + /* Switch sign on op2 */
18946 +#if defined(L_avr32_f32_addsub_fast)
18947 + .global __avr32_f32_add_fast
18948 + .type __avr32_f32_add_fast,@function
18949 +__avr32_f32_add_fast:
18951 + .global __avr32_f32_add
18952 + .type __avr32_f32_add,@function
18956 + /* Check signs */
18958 + /* Different signs, use subtraction. */
18959 + brmi __avr32_f32_sub_from_add
18961 + /* Get sign of op1 */
18963 + andh r12, 0x8000, COH
18965 + /* Remove sign from operands */
18967 +#if defined(L_avr32_f32_addsub_fast)
18968 + reteq r8 /* If op2 is zero return op1 */
18972 + /* Put the number with the largest exponent in r10
18973 + and the number with the smallest exponent in r9 */
18977 + /* Unpack exponent and mantissa of op1 */
18979 + sbr r8, 31 /* Set implicit bit. */
18982 + /* op1 is NaN or Inf. */
18984 + breq __avr32_f32_add_op1_nan_or_inf
18986 + /* Unpack exponent and mantissa of op2 */
18988 + sbr r11, 31 /* Set implicit bit. */
18991 +#if defined(L_avr32_f32_addsub)
18992 + /* op2 is either zero or subnormal. */
18993 + breq __avr32_f32_add_op2_subnormal
18995 + /* Keep sticky bit for correct IEEE rounding */
18998 + /* Get shift amount to scale mantissa of op2. */
19001 + /* Saturate the shift amount to 31. If the amount
19002 + is any larger op2 is insignificant. */
19005 + /* Shift mantissa of op2 to same decimal point as the mantissa
19009 + /* Put the remainding bits into r11[23:..].*/
19010 + rsub r9, r9, (32-8)
19012 + /* Insert the bits we will remove from the mantissa into r11[31:24] */
19013 + bfins r11, r12, 24, 8
19015 + /* Now add the mantissas. */
19020 + /* Ignore sticky bit to simplify and speed up rounding */
19021 + /* op2 is either zero or subnormal. */
19022 + breq __avr32_f32_add_op2_subnormal
19024 + /* Get shift amount to scale mantissa of op2. */
19027 + /* Saturate the shift amount to 31. If the amount
19028 + is any larger op2 is insignificant. */
19031 + /* Shift mantissa of op2 to same decimal point as the mantissa
19035 + /* Now add the mantissas. */
19039 + /* Check if we overflowed. */
19040 + brcs __avr32_f32_add_res_of
19042 + /* Pack result. */
19043 + or r12, r12, r8 >> 8
19044 + bfins r12, r10, 23, 8
19047 +#if defined(L_avr32_f32_addsub)
19048 + mov_imm r10, 0x80000000
19060 +__avr32_f32_add_op2_subnormal:
19061 + /* Fix implicit bit and adjust exponent of subnormals. */
19063 + /* Set exponent to 1 if we do not have a zero. */
19066 + /* Check if op1 is also subnormal. */
19069 + /* Both operands subnormal, just add the mantissas and
19070 + pack. If the addition of the subnormal numbers results
19071 + in a normal number then the exponent will automatically
19072 + be set to 1 by the addition. */
19075 + or r12, r12, r11 >> 8
19078 +__avr32_f32_add_op1_nan_or_inf:
19079 + /* Check if op1 is NaN, if so return NaN */
19083 + /* op1 is Inf. */
19084 + bfins r12, r10, 23, 8 /* Generate Inf in r12 */
19086 + /* Check if op2 is Inf. or NaN */
19089 + retne r12 /* op2 not Inf or NaN, return op1 */
19092 + reteq r12 /* op2 Inf return op1 */
19093 + ret -1 /* op2 is NaN, return NaN */
19095 +__avr32_f32_add_res_of:
19096 + /* We overflowed. Increase exponent and shift mantissa.*/
19100 + /* Clear mantissa to set result to Inf if the exponent is 255. */
19110 +#if defined(L_avr32_f32_div) || defined(L_avr32_f32_div_fast)
19113 +#if defined(L_avr32_f32_div_fast)
19114 + .global __avr32_f32_div_fast
19115 + .type __avr32_f32_div_fast,@function
19116 +__avr32_f32_div_fast:
19118 + .global __avr32_f32_div
19119 + .type __avr32_f32_div,@function
19123 + eor r8, r11, r12 /* MSB(r8) = Sign(op1) ^ Sign(op2) */
19128 + breq 4f /* Check op2 for zero */
19138 + breq 11f /*If number is subnormal*/
19140 + brhs 2f /* Check op1 for NaN or Inf */
19142 + sbr r12, 31 /*Implicit bit*/
19149 + breq 13f /*If number is subnormal*/
19151 + brhs 3f /* Check op2 for NaN or Inf */
19153 + sbr r11, 31 /*Implicit bit*/
19157 + reteq 0 /* op1 is zero and op2 is not zero */
19158 + /* or NaN so return zero */
19162 + /* For UC3, store with predecrement is faster than stm */
19166 + /* Calculate new exponent */
19171 + /* Approximating 1/d with the following recurrence: */
19172 + /* R[j+1] = R[j]*(2-R[j]*d) */
19173 + /* Using 2.30 format */
19176 + /* Multiply result : r6, r7 */
19177 + /* Initial guess : r11 */
19178 + /* New approximations : r11 */
19179 + /* Dividend : r12 */
19182 + mov_imm r10, 0x80000000
19184 + lsr r12, 2 /* Get significand of Op1 in 2.30 format */
19185 + lsr r5, r11, 2 /* Get significand of Op2 (=d) in 2.30 format */
19187 + /* Load initial guess, using look-up table */
19188 + /* Initial guess is of format 01.XY, where XY is constructed as follows: */
19189 + /* Let d be of following format: 00.1xy....., then XY=~xy */
19190 + /* For d=00.100 = 0,5 -> initial guess=01.11 = 1,75 */
19191 + /* For d=00.101 = 0,625 -> initial guess=01.11 = 1,5 */
19192 + /* For d=00.110 = 0,75 -> initial guess=01.11 = 1,25 */
19193 + /* For d=00.111 = 0,875 -> initial guess=01.11 = 1,0 */
19196 + bfextu r6, r5, 27, 2
19198 + bfins r11, r6, 28, 2
19200 + /* First approximation */
19201 + /* r7 = R[j]*d */
19202 + mulu.d r6, r11, r5
19203 + /* r7 = 2-R[j]*d */
19204 + sub r7, r10, r7<<2
19205 + /* r11 = R[j]*(2-R[j]*d) */
19206 + mulu.d r6, r11, r7
19209 + /* Second approximation */
19210 + /* r7 = R[j]*d */
19211 + mulu.d r6, r11, r5
19212 + /* r7 = 2-R[j]*d */
19213 + sub r7, r10, r7<<2
19214 + /* r11 = R[j]*(2-R[j]*d) */
19215 + mulu.d r6, r11, r7
19218 + /* Third approximation */
19219 + /* r7 = R[j]*d */
19220 + mulu.d r6, r11, r5
19221 + /* r7 = 2-R[j]*d */
19222 + sub r7, r10, r7<<2
19223 + /* r11 = R[j]*(2-R[j]*d) */
19224 + mulu.d r6, r11, r7
19227 + /* Fourth approximation */
19228 + /* r7 = R[j]*d */
19229 + mulu.d r6, r11, r5
19230 + /* r7 = 2-R[j]*d */
19231 + sub r7, r10, r7<<2
19232 + /* r11 = R[j]*(2-R[j]*d) */
19233 + mulu.d r6, r11, r7
19237 + /* Multiply with dividend to get quotient, r7 = sf(op1)/sf(op2) */
19238 + mulu.d r6, r11, r12
19240 + /* Shift by 3 to get result in 1.31 format, as required by the exponent. */
19241 + /* Note that 1.31 format is already used by the exponent in r9, since */
19242 + /* a bias of 127 was added to the result exponent, even though the implicit */
19243 + /* bit was inserted. This gives the exponent an additional bias of 1, which */
19244 + /* supports 1.31 format. */
19247 + /* Adjust exponent and mantissa in case the result is of format
19248 + 0000.1xxx to 0001.xxx*/
19249 +#if defined(L_avr32_f32_div)
19250 + lsr r12, 4 /* Scale dividend to 6.26 format to match the
19251 + result of the multiplication of the divisor and
19252 + quotient to get the remainder. */
19258 +#if defined(L_avr32_f32_div)
19259 + lsl r12, 1 /* Scale dividend to 5.27 format to match the
19260 + result of the multiplication of the divisor and
19261 + quotient to get the remainder. */
19265 + brle __avr32_f32_div_res_subnormal /* Result was subnormal. */
19268 +#if defined(L_avr32_f32_div)
19269 + /* In order to round correctly we calculate the remainder:
19270 + Remainder = dividend[r12] - divisor[r5]*quotient[r7]
19271 + for the case when the quotient is halfway between the round-up
19272 + value and the round down value. If the remainder then is negative
19273 + it means that the quotient was to big and that it should not be
19274 + rounded up, if the remainder is positive the quotient was to small
19275 + and we need to round up. If the remainder is zero it means that the
19276 + quotient is exact but since we need to remove the guard bit we should
19277 + round to even. */
19281 + /* Now do the multiplication. The quotient has the format 4.28
19282 + while the divisor has the format 2.30 which gives a result
19284 + mulu.d r10, r5, r7
19286 + /* Check if remainder is positive, negative or equal. */
19287 + bfextu r5, r7, 5, 1 /* Get parity bit into bit 0 of r5 */
19289 +__avr32_f32_div_round_subnormal:
19291 + srlo r11 /* Remainder positive: we need to round up.*/
19292 + moveq r11, r5 /* Remainder zero: round up if mantissa odd. */
19294 + bfextu r11, r7, 4, 1 /* Get guard bit */
19297 + /* Pack final result*/
19299 + bfins r12, r9, 23, 8
19300 + /* For UC3, load with postincrement is faster than ldm */
19305 + /* Rounding add. */
19309 +__divsf_return_op1:
19316 + /* Op1 is NaN or inf */
19317 + retne -1 /* Return NaN if op1 is NaN */
19318 + /* Op1 is inf check op2 */
19319 + mov_imm r9, 0xff000000
19321 + brlo __divsf_return_op1 /* inf/number gives inf */
19322 + ret -1 /* The rest gives NaN*/
19324 + /* Op2 is NaN or inf */
19325 + reteq 0 /* Return zero if number/inf*/
19326 + ret -1 /* Return NaN*/
19328 + /* Op1 is zero ? */
19330 + reteq -1 /* 0.0/0.0 is NaN */
19331 + /* Op1 is Nan? */
19333 + breq 11f /*If number is subnormal*/
19335 + brhs 2b /* Check op1 for NaN or Inf */
19336 + /* Nonzero/0.0 is Inf. Sign bit will be shifted in before returning*/
19337 + mov_imm r12, 0xff000000
19338 + rjmp __divsf_return_op1
19340 +11: /* Op1 was denormal. Fix it. */
19347 +13: /* Op2 was denormal. Fix it. */
19355 +__avr32_f32_div_res_subnormal: /* Divide result was subnormal */
19356 +#if defined(L_avr32_f32_div)
19357 + /* Check how much we must scale down the mantissa. */
19359 + sub r9, -1 /* We do no longer have an implicit bit. */
19360 + satu r9 >> 0, 5 /* Saturate shift amount to max 32. */
19361 + /* Scale down quotient */
19364 + /* Scale down the dividend to match the scaling of the quotient. */
19365 + lsl r6, r12, r10 /* Make the divident 64-bit and put the lsw in r6 */
19368 + /* Start performing the same rounding as done for normal numbers
19369 + but this time we have scaled the quotient and dividend and hence
19370 + need a little different comparison. */
19374 + /* Now do the multiplication. The quotient has the format 4.28
19375 + while the divisor has the format 2.30 which gives a result
19377 + mulu.d r10, r5, r7
19379 + /* Set exponent to 0 */
19382 + /* Check if remainder is positive, negative or equal. */
19383 + bfextu r5, r7, 5, 1 /* Get parity bit into bit 0 of r5 */
19385 + rjmp __avr32_f32_div_round_subnormal
19390 + /*Flush to zero*/
19395 +#ifdef L_avr32_f32_mul
19396 + .global __avr32_f32_mul
19397 + .type __avr32_f32_mul,@function
19402 + eor r12, r11 /* MSB(r8) = Sign(op1) ^ Sign(op2) */
19403 + andh r12, 0x8000, COH
19405 + /* arrange operands so that that op1 >= op2 */
19407 + breq __avr32_f32_mul_op1_zero
19410 + /* Put the number with the largest exponent in r10
19411 + and the number with the smallest exponent in r9 */
19415 + /* Unpack exponent and mantissa of op1 */
19417 + sbr r8, 31 /* Set implicit bit. */
19420 + /* op1 is NaN or Inf. */
19422 + breq __avr32_f32_mul_op1_nan_or_inf
19424 + /* Unpack exponent and mantissa of op2 */
19426 + sbr r11, 31 /* Set implicit bit. */
19429 + /* op2 is either zero or subnormal. */
19430 + breq __avr32_f32_mul_op2_subnormal
19432 + /* Calculate new exponent */
19435 + /* Do the multiplication */
19436 + mulu.d r10,r8,r11
19438 + /* We might need to scale up by two if the MSB of the result is
19444 + /* Put the shifted out bits of the mantissa into r10 */
19446 + bfins r10, r11, 24, 8
19448 + sub r9,(127-1) /* remove extra exponent bias */
19449 + brle __avr32_f32_mul_res_subnormal
19451 + /* Check for Inf. */
19455 + /* Pack result. */
19456 + or r12, r12, r11 >> 8
19457 + bfins r12, r9, 23, 8
19460 +__avr32_f32_mul_round:
19461 + mov_imm r8, 0x80000000
19475 +__avr32_f32_mul_op2_subnormal:
19478 + retcs 0 /* op2 is zero. Return 0 */
19483 + /* Check if op2 is subnormal. */
19487 + /* op2 is subnormal */
19490 + retcs 0 /* op1 is zero. Return 0 */
19497 +__avr32_f32_mul_op1_nan_or_inf:
19498 + /* Check if op1 is NaN, if so return NaN */
19502 + /* op1 is Inf. */
19504 + reteq -1 /* Inf * 0 -> NaN */
19506 + bfins r12, r10, 23, 8 /* Generate Inf in r12 */
19508 + /* Check if op2 is Inf. or NaN */
19511 + retne r12 /* op2 not Inf or NaN, return Info */
19514 + reteq r12 /* op2 Inf return Inf */
19515 + ret -1 /* op2 is NaN, return NaN */
19517 +__avr32_f32_mul_res_subnormal:
19518 + /* Check if the number is so small that
19519 + it will be represented with zero. */
19524 + /* Shift the mantissa into the correct position.*/
19526 + /* Add sign bit. */
19528 + /* Put the shifted out bits in the most significant part
19532 + /* Add all the remainder bits used for rounding into r11 */
19535 + rjmp __avr32_f32_mul_round
19537 +__avr32_f32_mul_op1_zero:
19538 + bfextu r10, r11, 23, 8
19546 +#ifdef L_avr32_s32_to_f32
19547 + .global __avr32_s32_to_f32
19548 + .type __avr32_s32_to_f32,@function
19549 +__avr32_s32_to_f32:
19551 + reteq r12 /* If zero then return zero float */
19552 + mov r11, r12 /* Keep the sign */
19553 + abs r12 /* Compute the absolute value */
19554 + mov r10, 31 + 127 /* Set the correct exponent */
19557 + normalize_sf r10 /*exp*/, r12 /*mant*/, r9 /*scratch*/
19559 + /* Check for subnormal result */
19561 + brle __avr32_s32_to_f32_subnormal
19563 + round_sf r10 /*exp*/, r12 /*mant*/, r9 /*scratch*/
19564 + pack_sf r12 /*sf*/, r10 /*exp*/, r12 /*mant*/
19569 +__avr32_s32_to_f32_subnormal:
19570 + /* Adjust a subnormal result */
19571 + adjust_subnormal_sf r12/*sf*/, r10 /*exp*/, r12 /*mant*/, r11/*sign*/, r9 /*scratch*/
19576 +#ifdef L_avr32_u32_to_f32
19577 + .global __avr32_u32_to_f32
19578 + .type __avr32_u32_to_f32,@function
19579 +__avr32_u32_to_f32:
19581 + reteq r12 /* If zero then return zero float */
19582 + mov r10, 31 + 127 /* Set the correct exponent */
19585 + normalize_sf r10 /*exp*/, r12 /*mant*/, r9 /*scratch*/
19587 + /* Check for subnormal result */
19589 + brle __avr32_u32_to_f32_subnormal
19591 + round_sf r10 /*exp*/, r12 /*mant*/, r9 /*scratch*/
19592 + pack_sf r12 /*sf*/, r10 /*exp*/, r12 /*mant*/
19593 + lsr r12,1 /* Sign bit is 0 for unsigned int */
19596 +__avr32_u32_to_f32_subnormal:
19597 + /* Adjust a subnormal result */
19599 + adjust_subnormal_sf r12/*sf*/,r10 /*exp*/, r12 /*mant*/,r8/*sign*/, r9 /*scratch*/
19606 +#ifdef L_avr32_f32_to_s32
19607 + .global __avr32_f32_to_s32
19608 + .type __avr32_f32_to_s32,@function
19609 +__avr32_f32_to_s32:
19610 + bfextu r11, r12, 23, 8
19611 + sub r11,127 /* Fix bias */
19612 + retlo 0 /* Negative exponent yields zero integer */
19614 + /* Shift mantissa into correct position */
19615 + rsub r11,r11,31 /* Shift amount */
19616 + lsl r10,r12,8 /* Get mantissa */
19617 + sbr r10,31 /* Add implicit bit */
19618 + lsr r10,r10,r11 /* Perform shift */
19619 + lsl r12,1 /* Check sign */
19620 + retcc r10 /* if positive, we are done */
19621 + neg r10 /* if negative float, negate result */
19626 +#ifdef L_avr32_f32_to_u32
19627 + .global __avr32_f32_to_u32
19628 + .type __avr32_f32_to_u32,@function
19629 +__avr32_f32_to_u32:
19631 + retmi 0 /* Negative numbers gives 0 */
19632 + bfextu r11, r12, 23, 8 /* Extract exponent */
19633 + sub r11,127 /* Fix bias */
19634 + retlo 0 /* Negative exponent yields zero integer */
19636 + /* Shift mantissa into correct position */
19637 + rsub r11,r11,31 /* Shift amount */
19638 + lsl r12,8 /* Get mantissa */
19639 + sbr r12,31 /* Add implicit bit */
19640 + lsr r12,r12,r11 /* Perform shift */
19645 +#ifdef L_avr32_f32_to_f64
19646 + .global __avr32_f32_to_f64
19647 + .type __avr32_f32_to_f64,@function
19649 +__avr32_f32_to_f64:
19650 + lsl r11,r12,1 /* Remove sign bit, keep original value in r12*/
19652 + reteq r11 /* Return zero if input is zero */
19654 + bfextu r9,r11,24,8 /* Get exponent */
19655 + cp.w r9,0xff /* check for NaN or inf */
19658 + lsl r11,7 /* Convert sf mantissa to df format */
19661 + /* Check if implicit bit should be set */
19663 + subeq r9,-1 /* Adjust exponent if it was 0 */
19665 + or r11, r11, r8 << 31 /* Set implicit bit if needed */
19666 + sub r9,(127-0x3ff) /* Convert exponent to df format exponent */
19668 + /*We know that low register of mantissa is 0, and will be unaffected by normalization.*/
19669 + /*We can therefore use the faster normalize_sf function instead of normalize_df.*/
19670 + normalize_sf r9 /*exp*/, r11 /*mantissa*/, r8 /*scratch*/
19671 + pack_df r9 /*exp*/, r10, r11 /*mantissa*/, r10, r11 /*df*/
19673 +__extendsfdf_return_op1:
19674 + /* Rotate in sign bit */
19681 + mov_imm r10, 0xffe00000
19682 + lsl r11,8 /* check mantissa */
19683 + movne r11, -1 /* Return NaN */
19684 + moveq r11, r10 /* Return inf */
19686 + rjmp __extendsfdf_return_op1
19690 +#ifdef L_avr32_f64_to_f32
19691 + .global __avr32_f64_to_f32
19692 + .type __avr32_f64_to_f32,@function
19694 +__avr32_f64_to_f32:
19696 + lsl r9,r11,1 /* Unpack exponent */
19699 + reteq 0 /* If exponent is 0 the number is so small
19700 + that the conversion to single float gives
19703 + lsl r8,r11,10 /* Adjust mantissa */
19704 + or r12,r8,r10>>22
19706 + lsl r10,10 /* Check if there are any remaining bits
19707 + in the low part of the mantissa.*/
19709 + rol r12 /* If there were remaining bits then set lsb
19710 + of mantissa to 1 */
19713 + breq 2f /* Check for NaN or inf */
19715 + sub r9,(0x3ff-127) /* Adjust bias of exponent */
19716 + sbr r12,31 /* set the implicit bit.*/
19718 + cp.w r9, 0 /* Check for subnormal number */
19721 + round_sf r9 /*exp*/, r12 /*mant*/, r10 /*scratch*/
19722 + pack_sf r12 /*sf*/, r9 /*exp*/, r12 /*mant*/
19723 +__truncdfsf_return_op1:
19724 + /* Rotate in sign bit */
19731 + cbr r12,31 /* clear implicit bit */
19732 + retne -1 /* Return NaN if mantissa not zero */
19733 + mov_imm r12, 0x7f800000
19734 + ret r12 /* Return inf */
19736 +3: /* Result is subnormal. Adjust it.*/
19737 + adjust_subnormal_sf r12/*sf*/,r9 /*exp*/, r12 /*mant*/, r11/*sign*/, r10 /*scratch*/
19743 +#if defined(L_mulsi3) && defined(__AVR32_NO_MUL__)
19745 + .type __mulsi3,@function
19751 + addcs r9, r9, r12
19759 +++ b/gcc/config/avr32/lib2funcs.S
19762 + .global __nonlocal_goto
19763 + .type __nonlocal_goto,@function
19765 +/* __nonlocal_goto: This function handles nonlocal_goto's in gcc.
19767 + parameter 0 (r12) = New Frame Pointer
19768 + parameter 1 (r11) = Address to goto
19769 + parameter 2 (r10) = New Stack Pointer
19771 + This function invalidates the return stack, since it returns from a
19772 + function without using a return instruction.
19777 + frs # Flush return stack
19783 +++ b/gcc/config/avr32/linux-elf.h
19786 + Linux/Elf specific definitions.
19787 + Copyright 2003-2006 Atmel Corporation.
19789 + Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
19790 + and H�vard Skinnemoen, Atmel Norway, <hskinnemoen@atmel.com>
19792 + This file is part of GCC.
19794 + This program is free software; you can redistribute it and/or modify
19795 + it under the terms of the GNU General Public License as published by
19796 + the Free Software Foundation; either version 2 of the License, or
19797 + (at your option) any later version.
19799 + This program is distributed in the hope that it will be useful,
19800 + but WITHOUT ANY WARRANTY; without even the implied warranty of
19801 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19802 + GNU General Public License for more details.
19804 + You should have received a copy of the GNU General Public License
19805 + along with this program; if not, write to the Free Software
19806 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19810 +/* elfos.h should have already been included. Now just override
19811 + any conflicting definitions and add any extras. */
19813 +/* Run-time Target Specification. */
19814 +#undef TARGET_VERSION
19815 +#define TARGET_VERSION fputs (" (AVR32 GNU/Linux with ELF)", stderr);
19817 +/* Do not assume anything about header files. */
19818 +#define NO_IMPLICIT_EXTERN_C
19820 +/* The GNU C++ standard library requires that these macros be defined. */
19821 +#undef CPLUSPLUS_CPP_SPEC
19822 +#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
19824 +/* Now we define the strings used to build the spec file. */
19826 +#define LIB_SPEC \
19827 + "%{pthread:-lpthread} \
19829 + %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
19831 +/* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
19832 + the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
19833 + provides part of the support for getting C++ file-scope static
19834 + object constructed before entering `main'. */
19836 +#undef STARTFILE_SPEC
19837 +#define STARTFILE_SPEC \
19839 + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
19840 + %{!p:%{profile:gcrt1.o%s} \
19841 + %{!profile:crt1.o%s}}}} \
19842 + crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
19844 +/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
19845 + the GNU/Linux magical crtend.o file (see crtstuff.c) which
19846 + provides part of the support for getting C++ file-scope static
19847 + object constructed before entering `main', followed by a normal
19848 + GNU/Linux "finalizer" file, `crtn.o'. */
19850 +#undef ENDFILE_SPEC
19851 +#define ENDFILE_SPEC \
19852 + "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
19855 +#define ASM_SPEC "%{!mno-pic:%{!fno-pic:--pic}} %{mrelax|O*:%{mno-relax|O0|O1: ;:--linkrelax}} %{mcpu=*:-mcpu=%*}"
19858 +#define LINK_SPEC "%{version:-v} \
19859 + %{static:-Bstatic} \
19860 + %{shared:-shared} \
19861 + %{symbolic:-Bsymbolic} \
19862 + %{rdynamic:-export-dynamic} \
19863 + %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0} \
19864 + %{mrelax|O*:%{mno-relax|O0|O1: ;:--relax}}"
19866 +#define TARGET_OS_CPP_BUILTINS() LINUX_TARGET_OS_CPP_BUILTINS()
19868 +/* This is how we tell the assembler that two symbols have the same value. */
19869 +#define ASM_OUTPUT_DEF(FILE, NAME1, NAME2) \
19872 + assemble_name (FILE, NAME1); \
19873 + fputs (" = ", FILE); \
19874 + assemble_name (FILE, NAME2); \
19875 + fputc ('\n', FILE); \
19882 +#define CC1_SPEC "%{profile:-p}"
19884 +/* Target CPU builtins. */
19885 +#define TARGET_CPU_CPP_BUILTINS() \
19888 + builtin_define ("__avr32__"); \
19889 + builtin_define ("__AVR32__"); \
19890 + builtin_define ("__AVR32_LINUX__"); \
19891 + builtin_define (avr32_part->macro); \
19892 + builtin_define (avr32_arch->macro); \
19893 + if (avr32_arch->uarch_type == UARCH_TYPE_AVR32A) \
19894 + builtin_define ("__AVR32_AVR32A__"); \
19896 + builtin_define ("__AVR32_AVR32B__"); \
19897 + if (TARGET_UNALIGNED_WORD) \
19898 + builtin_define ("__AVR32_HAS_UNALIGNED_WORD__"); \
19899 + if (TARGET_SIMD) \
19900 + builtin_define ("__AVR32_HAS_SIMD__"); \
19901 + if (TARGET_DSP) \
19902 + builtin_define ("__AVR32_HAS_DSP__"); \
19903 + if (TARGET_RMW) \
19904 + builtin_define ("__AVR32_HAS_RMW__"); \
19905 + if (TARGET_BRANCH_PRED) \
19906 + builtin_define ("__AVR32_HAS_BRANCH_PRED__"); \
19907 + if (TARGET_FAST_FLOAT) \
19908 + builtin_define ("__AVR32_FAST_FLOAT__"); \
19914 +/* Call the function profiler with a given profile label. */
19915 +#undef FUNCTION_PROFILER
19916 +#define FUNCTION_PROFILER(STREAM, LABELNO) \
19919 + fprintf (STREAM, "\tmov\tlr, lo(mcount)\n\torh\tlr, hi(mcount)\n"); \
19920 + fprintf (STREAM, "\ticall lr\n"); \
19924 +#define NO_PROFILE_COUNTERS 1
19926 +/* For dynamic libraries to work */
19927 +/* #define PLT_REG_CALL_CLOBBERED 1 */
19928 +#define AVR32_ALWAYS_PIC 1
19930 +/* uclibc does not implement sinf, cosf etc. */
19931 +#undef TARGET_C99_FUNCTIONS
19932 +#define TARGET_C99_FUNCTIONS 0
19934 +#define LINK_GCC_C_SEQUENCE_SPEC \
19935 + "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
19937 +++ b/gcc/config/avr32/predicates.md
19939 +;; AVR32 predicates file.
19940 +;; Copyright 2003-2006 Atmel Corporation.
19942 +;; Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
19944 +;; This file is part of GCC.
19946 +;; This program is free software; you can redistribute it and/or modify
19947 +;; it under the terms of the GNU General Public License as published by
19948 +;; the Free Software Foundation; either version 2 of the License, or
19949 +;; (at your option) any later version.
19951 +;; This program is distributed in the hope that it will be useful,
19952 +;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19953 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19954 +;; GNU General Public License for more details.
19956 +;; You should have received a copy of the GNU General Public License
19957 +;; along with this program; if not, write to the Free Software
19958 +;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19961 +;; True if the operand is a memory reference which contains an
19962 +;; Address consisting of a single pointer register
19963 +(define_predicate "avr32_indirect_register_operand"
19964 + (and (match_code "mem")
19965 + (match_test "register_operand(XEXP(op, 0), SImode)")))
19969 +;; Address expression with a base pointer offset with
19970 +;; a register displacement
19971 +(define_predicate "avr32_indexed_memory_operand"
19972 + (and (match_code "mem")
19973 + (match_test "GET_CODE(XEXP(op, 0)) == PLUS"))
19976 + rtx op0 = XEXP(XEXP(op, 0), 0);
19977 + rtx op1 = XEXP(XEXP(op, 0), 1);
19979 + return ((avr32_address_register_rtx_p (op0, 0)
19980 + && avr32_legitimate_index_p (GET_MODE(op), op1, 0))
19981 + || (avr32_address_register_rtx_p (op1, 0)
19982 + && avr32_legitimate_index_p (GET_MODE(op), op0, 0)));
19986 +;; Operand suitable for the ld.sb instruction
19987 +(define_predicate "load_sb_memory_operand"
19988 + (ior (match_operand 0 "avr32_indirect_register_operand")
19989 + (match_operand 0 "avr32_indexed_memory_operand")))
19992 +;; Operand suitable as operand to insns sign extending QI values
19993 +(define_predicate "extendqi_operand"
19994 + (ior (match_operand 0 "load_sb_memory_operand")
19995 + (match_operand 0 "register_operand")))
19997 +(define_predicate "post_inc_memory_operand"
19998 + (and (match_code "mem")
19999 + (match_test "(GET_CODE(XEXP(op, 0)) == POST_INC)
20000 + && REG_P(XEXP(XEXP(op, 0), 0))")))
20002 +(define_predicate "pre_dec_memory_operand"
20003 + (and (match_code "mem")
20004 + (match_test "(GET_CODE(XEXP(op, 0)) == PRE_DEC)
20005 + && REG_P(XEXP(XEXP(op, 0), 0))")))
20007 +;; Operand suitable for add instructions
20008 +(define_predicate "avr32_add_operand"
20009 + (ior (match_operand 0 "register_operand")
20010 + (and (match_operand 0 "immediate_operand")
20011 + (match_test "CONST_OK_FOR_CONSTRAINT_P(INTVAL(op), 'I', \"Is21\")"))))
20013 +;; Operand is a power of two immediate
20014 +(define_predicate "power_of_two_operand"
20015 + (match_code "const_int")
20017 + HOST_WIDE_INT value = INTVAL (op);
20019 + return value != 0 && (value & (value - 1)) == 0;
20022 +;; Operand is a multiple of 8 immediate
20023 +(define_predicate "multiple_of_8_operand"
20024 + (match_code "const_int")
20026 + HOST_WIDE_INT value = INTVAL (op);
20028 + return (value & 0x7) == 0 ;
20031 +;; Operand is a multiple of 16 immediate
20032 +(define_predicate "multiple_of_16_operand"
20033 + (match_code "const_int")
20035 + HOST_WIDE_INT value = INTVAL (op);
20037 + return (value & 0xf) == 0 ;
20040 +;; Operand is a mask used for masking away upper bits of a reg
20041 +(define_predicate "avr32_mask_upper_bits_operand"
20042 + (match_code "const_int")
20044 + HOST_WIDE_INT value = INTVAL (op) + 1;
20046 + return value != 1 && value != 0 && (value & (value - 1)) == 0;
20050 +;; Operand suitable for mul instructions
20051 +(define_predicate "avr32_mul_operand"
20052 + (ior (match_operand 0 "register_operand")
20053 + (and (match_operand 0 "immediate_operand")
20054 + (match_test "CONST_OK_FOR_CONSTRAINT_P(INTVAL(op), 'K', \"Ks08\")"))))
20056 +;; True for logical binary operators.
20057 +(define_predicate "logical_binary_operator"
20058 + (match_code "ior,xor,and"))
20060 +;; True for logical shift operators
20061 +(define_predicate "logical_shift_operator"
20062 + (match_code "ashift,lshiftrt"))
20064 +;; True for shift operand for logical and, or and eor insns
20065 +(define_predicate "avr32_logical_shift_operand"
20066 + (and (match_code "ashift,lshiftrt")
20067 + (ior (and (match_test "GET_CODE(XEXP(op, 1)) == CONST_INT")
20068 + (match_test "register_operand(XEXP(op, 0), GET_MODE(XEXP(op, 0)))"))
20069 + (and (match_test "GET_CODE(XEXP(op, 0)) == CONST_INT")
20070 + (match_test "register_operand(XEXP(op, 1), GET_MODE(XEXP(op, 1)))"))))
20074 +;; Predicate for second operand to and, ior and xor insn patterns
20075 +(define_predicate "avr32_logical_insn_operand"
20076 + (ior (match_operand 0 "register_operand")
20077 + (match_operand 0 "avr32_logical_shift_operand"))
20081 +;; True for avr32 comparison operators
20082 +(define_predicate "avr32_comparison_operator"
20083 + (ior (match_code "eq, ne, gt, ge, lt, le, gtu, geu, ltu, leu")
20084 + (and (match_code "unspec")
20085 + (match_test "(XINT(op, 1) == UNSPEC_COND_MI)
20086 + || (XINT(op, 1) == UNSPEC_COND_PL)"))))
20088 +(define_predicate "avr32_cond3_comparison_operator"
20089 + (ior (match_code "eq, ne, ge, lt, geu, ltu")
20090 + (and (match_code "unspec")
20091 + (match_test "(XINT(op, 1) == UNSPEC_COND_MI)
20092 + || (XINT(op, 1) == UNSPEC_COND_PL)"))))
20094 +;; True for avr32 comparison operand
20095 +(define_predicate "avr32_comparison_operand"
20096 + (ior (and (match_code "eq, ne, gt, ge, lt, le, gtu, geu, ltu, leu")
20097 + (match_test "(CC0_P (XEXP(op,0)) && rtx_equal_p (XEXP(op,1), const0_rtx))"))
20098 + (and (match_code "unspec")
20099 + (match_test "(XINT(op, 1) == UNSPEC_COND_MI)
20100 + || (XINT(op, 1) == UNSPEC_COND_PL)"))))
20102 +;; True if this is a const_int with one bit set
20103 +(define_predicate "one_bit_set_operand"
20104 + (match_code "const_int")
20110 + value = INTVAL(op);
20111 + for ( i = 0 ; i < 32; i++ ){
20112 + if ( value & ( 1 << i ) ){
20117 + return ( ones == 1 );
20121 +;; True if this is a const_int with one bit cleared
20122 +(define_predicate "one_bit_cleared_operand"
20123 + (match_code "const_int")
20129 + value = INTVAL(op);
20130 + for ( i = 0 ; i < 32; i++ ){
20131 + if ( !(value & ( 1 << i )) ){
20136 + return ( zeroes == 1 );
20140 +;; Immediate all the low 16-bits cleared
20141 +(define_predicate "avr32_hi16_immediate_operand"
20142 + (match_code "const_int")
20144 + /* If the low 16-bits are zero then this
20145 + is a hi16 immediate. */
20146 + return ((INTVAL(op) & 0xffff) == 0);
20150 +;; True if this is a register or immediate operand
20151 +(define_predicate "register_immediate_operand"
20152 + (ior (match_operand 0 "register_operand")
20153 + (match_operand 0 "immediate_operand")))
20155 +;; True if this is a register or const_int operand
20156 +(define_predicate "register_const_int_operand"
20157 + (ior (match_operand 0 "register_operand")
20158 + (and (match_operand 0 "const_int_operand")
20159 + (match_operand 0 "immediate_operand"))))
20161 +;; True if this is a register or const_double operand
20162 +(define_predicate "register_const_double_operand"
20163 + (ior (match_operand 0 "register_operand")
20164 + (match_operand 0 "const_double_operand")))
20166 +;; True if this is an operand containing a label_ref.
20167 +(define_predicate "avr32_label_ref_operand"
20168 + (and (match_code "mem")
20169 + (match_test "avr32_find_symbol(op)
20170 + && (GET_CODE(avr32_find_symbol(op)) == LABEL_REF)")))
20172 +;; True if this is a valid symbol pointing to the constant pool.
20173 +(define_predicate "avr32_const_pool_operand"
20174 + (and (match_code "symbol_ref")
20175 + (match_test "CONSTANT_POOL_ADDRESS_P(op)"))
20177 + return (flag_pic ? (!(symbol_mentioned_p (get_pool_constant (op))
20178 + || label_mentioned_p (get_pool_constant (op)))
20179 + || avr32_got_mentioned_p(get_pool_constant (op)))
20184 +;; True if this is a memory reference to the constant or mini pool.
20185 +(define_predicate "avr32_const_pool_ref_operand"
20186 + (ior (match_operand 0 "avr32_label_ref_operand")
20187 + (and (match_code "mem")
20188 + (match_test "avr32_const_pool_operand(XEXP(op,0), GET_MODE(XEXP(op,0)))"))))
20191 +;; Legal source operand for movti insns
20192 +(define_predicate "avr32_movti_src_operand"
20193 + (ior (match_operand 0 "avr32_const_pool_ref_operand")
20194 + (ior (ior (match_operand 0 "register_immediate_operand")
20195 + (match_operand 0 "avr32_indirect_register_operand"))
20196 + (match_operand 0 "post_inc_memory_operand"))))
20198 +;; Legal destination operand for movti insns
20199 +(define_predicate "avr32_movti_dst_operand"
20200 + (ior (ior (match_operand 0 "register_operand")
20201 + (match_operand 0 "avr32_indirect_register_operand"))
20202 + (match_operand 0 "pre_dec_memory_operand")))
20205 +;; True if this is a k12 offseted memory operand.
20206 +(define_predicate "avr32_k12_memory_operand"
20207 + (and (match_code "mem")
20208 + (ior (match_test "REG_P(XEXP(op, 0))")
20209 + (match_test "GET_CODE(XEXP(op, 0)) == PLUS
20210 + && REG_P(XEXP(XEXP(op, 0), 0))
20211 + && (GET_CODE(XEXP(XEXP(op, 0), 1)) == CONST_INT)
20212 + && (CONST_OK_FOR_CONSTRAINT_P(INTVAL(XEXP(XEXP(op, 0), 0)),
20213 + 'K', (mode == SImode) ? \"Ks14\" : ((mode == HImode) ? \"Ks13\" : \"Ks12\")))"))))
20215 +;; True if this is a memory operand with an immediate displacement.
20216 +(define_predicate "avr32_imm_disp_memory_operand"
20217 + (and (match_code "mem")
20218 + (match_test "GET_CODE(XEXP(op, 0)) == PLUS
20219 + && REG_P(XEXP(XEXP(op, 0), 0))
20220 + && (GET_CODE(XEXP(XEXP(op, 0), 1)) == CONST_INT)")))
20222 +;; True if this is a bswap operand.
20223 +(define_predicate "avr32_bswap_operand"
20224 + (ior (match_operand 0 "avr32_k12_memory_operand")
20225 + (match_operand 0 "register_operand")))
20227 +;; True if this is a valid coprocessor insn memory operand.
20228 +(define_predicate "avr32_cop_memory_operand"
20229 + (and (match_operand 0 "memory_operand")
20230 + (not (match_test "GET_CODE(XEXP(op, 0)) == PLUS
20231 + && REG_P(XEXP(XEXP(op, 0), 0))
20232 + && (GET_CODE(XEXP(XEXP(op, 0), 1)) == CONST_INT)
20233 + && !(CONST_OK_FOR_CONSTRAINT_P(INTVAL(XEXP(XEXP(op, 0), 0)), 'K', \"Ku10\"))"))))
20235 +;; True if this is a valid source/destination operand.
20236 +;; for moving values to/from a coprocessor
20237 +(define_predicate "avr32_cop_move_operand"
20238 + (ior (match_operand 0 "register_operand")
20239 + (match_operand 0 "avr32_cop_memory_operand")))
20242 +;; True if this is a valid extract byte offset for use in
20243 +;; load extracted index insns.
20244 +(define_predicate "avr32_extract_shift_operand"
20245 + (and (match_operand 0 "const_int_operand")
20246 + (match_test "(INTVAL(op) == 0) || (INTVAL(op) == 8)
20247 + || (INTVAL(op) == 16) || (INTVAL(op) == 24)")))
20249 +;; True if this is a valid avr32 symbol operand.
20250 +(define_predicate "avr32_symbol_operand"
20251 + (and (match_code "label_ref, symbol_ref, const")
20252 + (match_test "avr32_find_symbol(op)")))
20254 +;; True if this is a valid operand for the lda.w and call pseudo insns.
20255 +(define_predicate "avr32_address_operand"
20256 + (and (and (match_code "label_ref, symbol_ref")
20257 + (match_test "avr32_find_symbol(op)"))
20258 + (ior (match_test "TARGET_HAS_ASM_ADDR_PSEUDOS")
20259 + (match_test "flag_pic")) ))
20261 +;; An immediate k16 address operand
20262 +(define_predicate "avr32_ks16_address_operand"
20263 + (and (match_operand 0 "address_operand")
20264 + (ior (match_test "REG_P(op)")
20265 + (match_test "GET_CODE(op) == PLUS
20266 + && ((GET_CODE(XEXP(op,0)) == CONST_INT)
20267 + || (GET_CODE(XEXP(op,1)) == CONST_INT))")) ))
20269 +;; An offset k16 memory operand
20270 +(define_predicate "avr32_ks16_memory_operand"
20271 + (and (match_code "mem")
20272 + (match_test "avr32_ks16_address_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0)))")))
20274 +;; An immediate k11 address operand
20275 +(define_predicate "avr32_ks11_address_operand"
20276 + (and (match_operand 0 "address_operand")
20277 + (ior (match_test "REG_P(op)")
20278 + (match_test "GET_CODE(op) == PLUS
20279 + && (((GET_CODE(XEXP(op,0)) == CONST_INT)
20280 + && avr32_const_ok_for_constraint_p(INTVAL(XEXP(op,0)), 'K', \"Ks11\"))
20281 + || ((GET_CODE(XEXP(op,1)) == CONST_INT)
20282 + && avr32_const_ok_for_constraint_p(INTVAL(XEXP(op,1)), 'K', \"Ks11\")))")) ))
20284 +;; True if this is a avr32 call operand
20285 +(define_predicate "avr32_call_operand"
20286 + (ior (ior (match_operand 0 "register_operand")
20287 + (ior (match_operand 0 "avr32_const_pool_ref_operand")
20288 + (match_operand 0 "avr32_address_operand")))
20289 + (match_test "SYMBOL_REF_RCALL_FUNCTION_P(op)")))
20291 +;; Return true for operators performing ALU operations
20293 +(define_predicate "alu_operator"
20294 + (match_code "ior, xor, and, plus, minus, ashift, lshiftrt, ashiftrt"))
20296 +(define_predicate "avr32_add_shift_immediate_operand"
20297 + (and (match_operand 0 "immediate_operand")
20298 + (match_test "CONST_OK_FOR_CONSTRAINT_P(INTVAL(op), 'K', \"Ku02\")")))
20300 +(define_predicate "avr32_cond_register_immediate_operand"
20301 + (ior (match_operand 0 "register_operand")
20302 + (and (match_operand 0 "immediate_operand")
20303 + (match_test "CONST_OK_FOR_CONSTRAINT_P(INTVAL(op), 'K', \"Ks08\")"))))
20305 +(define_predicate "avr32_cond_immediate_operand"
20306 + (and (match_operand 0 "immediate_operand")
20307 + (match_test "CONST_OK_FOR_CONSTRAINT_P(INTVAL(op), 'I', \"Is08\")")))
20310 +(define_predicate "avr32_cond_move_operand"
20311 + (ior (ior (match_operand 0 "register_operand")
20312 + (and (match_operand 0 "immediate_operand")
20313 + (match_test "CONST_OK_FOR_CONSTRAINT_P(INTVAL(op), 'K', \"Ks08\")")))
20314 + (and (match_test "TARGET_V2_INSNS")
20315 + (match_operand 0 "memory_operand"))))
20317 +(define_predicate "avr32_mov_immediate_operand"
20318 + (and (match_operand 0 "immediate_operand")
20319 + (match_test "avr32_const_ok_for_move(INTVAL(op))")))
20322 +(define_predicate "avr32_rmw_address_operand"
20323 + (ior (and (match_code "symbol_ref")
20324 + (match_test "({rtx symbol = avr32_find_symbol(op); \
20325 + symbol && (GET_CODE (symbol) == SYMBOL_REF) && SYMBOL_REF_RMW_ADDR(symbol);})"))
20326 + (and (match_operand 0 "immediate_operand")
20327 + (match_test "CONST_OK_FOR_CONSTRAINT_P(INTVAL(op), 'K', \"Ks17\")")))
20329 + return TARGET_RMW && !flag_pic;
20333 +(define_predicate "avr32_rmw_memory_operand"
20334 + (and (match_code "mem")
20335 + (match_test "!volatile_refs_p(op) && (GET_MODE(op) == SImode) &&
20336 + avr32_rmw_address_operand(XEXP(op, 0), GET_MODE(XEXP(op, 0)))")))
20338 +(define_predicate "avr32_rmw_memory_or_register_operand"
20339 + (ior (match_operand 0 "avr32_rmw_memory_operand")
20340 + (match_operand 0 "register_operand")))
20342 +(define_predicate "avr32_non_rmw_memory_operand"
20343 + (and (not (match_operand 0 "avr32_rmw_memory_operand"))
20344 + (match_operand 0 "memory_operand")))
20346 +(define_predicate "avr32_non_rmw_general_operand"
20347 + (and (not (match_operand 0 "avr32_rmw_memory_operand"))
20348 + (match_operand 0 "general_operand")))
20350 +(define_predicate "avr32_non_rmw_nonimmediate_operand"
20351 + (and (not (match_operand 0 "avr32_rmw_memory_operand"))
20352 + (match_operand 0 "nonimmediate_operand")))
20354 +;; Return true if the operand is the 1.0f constant.
20356 +(define_predicate "const_1f_operand"
20357 + (match_code "const_int,const_double")
20359 + return (op == CONST1_RTX (SFmode));
20362 +++ b/gcc/config/avr32/simd.md
20364 +;; AVR32 machine description file for SIMD instructions.
20365 +;; Copyright 2003-2006 Atmel Corporation.
20367 +;; Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
20369 +;; This file is part of GCC.
20371 +;; This program is free software; you can redistribute it and/or modify
20372 +;; it under the terms of the GNU General Public License as published by
20373 +;; the Free Software Foundation; either version 2 of the License, or
20374 +;; (at your option) any later version.
20376 +;; This program is distributed in the hope that it will be useful,
20377 +;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20378 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20379 +;; GNU General Public License for more details.
20381 +;; You should have received a copy of the GNU General Public License
20382 +;; along with this program; if not, write to the Free Software
20383 +;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20385 +;; -*- Mode: Scheme -*-
20389 +(define_mode_iterator VECM [V2HI V4QI])
20390 +(define_mode_attr size [(V2HI "h") (V4QI "b")])
20392 +(define_insn "add<mode>3"
20393 + [(set (match_operand:VECM 0 "register_operand" "=r")
20394 + (plus:VECM (match_operand:VECM 1 "register_operand" "r")
20395 + (match_operand:VECM 2 "register_operand" "r")))]
20397 + "padd.<size>\t%0, %1, %2"
20398 + [(set_attr "length" "4")
20399 + (set_attr "type" "alu")])
20402 +(define_insn "sub<mode>3"
20403 + [(set (match_operand:VECM 0 "register_operand" "=r")
20404 + (minus:VECM (match_operand:VECM 1 "register_operand" "r")
20405 + (match_operand:VECM 2 "register_operand" "r")))]
20407 + "psub.<size>\t%0, %1, %2"
20408 + [(set_attr "length" "4")
20409 + (set_attr "type" "alu")])
20412 +(define_insn "abs<mode>2"
20413 + [(set (match_operand:VECM 0 "register_operand" "=r")
20414 + (abs:VECM (match_operand:VECM 1 "register_operand" "r")))]
20416 + "pabs.s<size>\t%0, %1"
20417 + [(set_attr "length" "4")
20418 + (set_attr "type" "alu")])
20420 +(define_insn "ashl<mode>3"
20421 + [(set (match_operand:VECM 0 "register_operand" "=r")
20422 + (ashift:VECM (match_operand:VECM 1 "register_operand" "r")
20423 + (match_operand:SI 2 "immediate_operand" "Ku04")))]
20425 + "plsl.<size>\t%0, %1, %2"
20426 + [(set_attr "length" "4")
20427 + (set_attr "type" "alu")])
20429 +(define_insn "ashr<mode>3"
20430 + [(set (match_operand:VECM 0 "register_operand" "=r")
20431 + (ashiftrt:VECM (match_operand:VECM 1 "register_operand" "r")
20432 + (match_operand:SI 2 "immediate_operand" "Ku04")))]
20434 + "pasr.<size>\t%0, %1, %2"
20435 + [(set_attr "length" "4")
20436 + (set_attr "type" "alu")])
20438 +(define_insn "lshr<mode>3"
20439 + [(set (match_operand:VECM 0 "register_operand" "=r")
20440 + (lshiftrt:VECM (match_operand:VECM 1 "register_operand" "r")
20441 + (match_operand:SI 2 "immediate_operand" "Ku04")))]
20443 + "plsr.<size>\t%0, %1, %2"
20444 + [(set_attr "length" "4")
20445 + (set_attr "type" "alu")])
20447 +(define_insn "smaxv2hi3"
20448 + [(set (match_operand:V2HI 0 "register_operand" "=r")
20449 + (smax:V2HI (match_operand:V2HI 1 "register_operand" "r")
20450 + (match_operand:V2HI 2 "register_operand" "r")))]
20453 + "pmax.sh\t%0, %1, %2"
20454 + [(set_attr "length" "4")
20455 + (set_attr "type" "alu")])
20457 +(define_insn "sminv2hi3"
20458 + [(set (match_operand:V2HI 0 "register_operand" "=r")
20459 + (smin:V2HI (match_operand:V2HI 1 "register_operand" "r")
20460 + (match_operand:V2HI 2 "register_operand" "r")))]
20463 + "pmin.sh\t%0, %1, %2"
20464 + [(set_attr "length" "4")
20465 + (set_attr "type" "alu")])
20467 +(define_insn "umaxv4qi3"
20468 + [(set (match_operand:V4QI 0 "register_operand" "=r")
20469 + (umax:V4QI (match_operand:V4QI 1 "register_operand" "r")
20470 + (match_operand:V4QI 2 "register_operand" "r")))]
20473 + "pmax.ub\t%0, %1, %2"
20474 + [(set_attr "length" "4")
20475 + (set_attr "type" "alu")])
20477 +(define_insn "uminv4qi3"
20478 + [(set (match_operand:V4QI 0 "register_operand" "=r")
20479 + (umin:V4QI (match_operand:V4QI 1 "register_operand" "r")
20480 + (match_operand:V4QI 2 "register_operand" "r")))]
20483 + "pmin.ub\t%0, %1, %2"
20484 + [(set_attr "length" "4")
20485 + (set_attr "type" "alu")])
20488 +(define_insn "addsubv2hi"
20489 + [(set (match_operand:V2HI 0 "register_operand" "=r")
20491 + (plus:HI (match_operand:HI 1 "register_operand" "r")
20492 + (match_operand:HI 2 "register_operand" "r"))
20493 + (minus:HI (match_dup 1) (match_dup 2))))]
20495 + "paddsub.h\t%0, %1:b, %2:b"
20496 + [(set_attr "length" "4")
20497 + (set_attr "type" "alu")])
20499 +(define_insn "subaddv2hi"
20500 + [(set (match_operand:V2HI 0 "register_operand" "=r")
20502 + (minus:HI (match_operand:HI 1 "register_operand" "r")
20503 + (match_operand:HI 2 "register_operand" "r"))
20504 + (plus:HI (match_dup 1) (match_dup 2))))]
20506 + "psubadd.h\t%0, %1:b, %2:b"
20507 + [(set_attr "length" "4")
20508 + (set_attr "type" "alu")])
20510 +++ b/gcc/config/avr32/sync.md
20512 +;;=================================================================
20513 +;; Atomic operations
20514 +;;=================================================================
20517 +(define_insn "sync_compare_and_swapsi"
20518 + [(set (match_operand:SI 0 "register_operand" "=&r,&r")
20519 + (match_operand:SI 1 "memory_operand" "+RKs16,+RKs16"))
20520 + (set (match_dup 1)
20521 + (unspec_volatile:SI
20523 + (match_operand:SI 2 "register_immediate_operand" "r,Ks21")
20524 + (match_operand:SI 3 "register_operand" "r,r")]
20525 + VUNSPEC_SYNC_CMPXCHG)) ]
20536 + [(set_attr "length" "16,18")
20537 + (set_attr "cc" "clobber")]
20541 +(define_code_iterator atomic_op [plus minus and ior xor])
20542 +(define_code_attr atomic_asm_insn [(plus "add") (minus "sub") (and "and") (ior "or") (xor "eor")])
20543 +(define_code_attr atomic_insn [(plus "add") (minus "sub") (and "and") (ior "ior") (xor "xor")])
20545 +(define_insn "sync_loadsi"
20546 + ; NB! Put an early clobber on the destination operand to
20547 + ; avoid gcc using the same register in the source and
20548 + ; destination. This is done in order to avoid gcc to
20549 + ; clobber the source operand since these instructions
20550 + ; are actually inside a "loop".
20551 + [(set (match_operand:SI 0 "register_operand" "=&r")
20552 + (unspec_volatile:SI
20553 + [(match_operand:SI 1 "avr32_ks16_memory_operand" "RKs16")
20554 + (label_ref (match_operand 2 "" ""))]
20555 + VUNSPEC_SYNC_SET_LOCK_AND_LOAD) )]
20560 + [(set_attr "length" "6")
20561 + (set_attr "cc" "clobber")]
20564 +(define_insn "sync_store_if_lock"
20565 + [(set (match_operand:SI 0 "avr32_ks16_memory_operand" "=RKs16")
20566 + (unspec_volatile:SI
20567 + [(match_operand:SI 1 "register_operand" "r")
20568 + (label_ref (match_operand 2 "" ""))]
20569 + VUNSPEC_SYNC_STORE_IF_LOCK) )]
20573 + [(set_attr "length" "6")
20574 + (set_attr "cc" "clobber")]
20578 +(define_expand "sync_<atomic_insn>si"
20579 + [(set (match_dup 2)
20580 + (unspec_volatile:SI
20581 + [(match_operand:SI 0 "avr32_ks16_memory_operand" "")
20583 + VUNSPEC_SYNC_SET_LOCK_AND_LOAD))
20584 + (set (match_dup 2)
20585 + (atomic_op:SI (match_dup 2)
20586 + (match_operand:SI 1 "register_immediate_operand" "")))
20587 + (set (match_dup 0)
20588 + (unspec_volatile:SI
20591 + VUNSPEC_SYNC_STORE_IF_LOCK) )
20592 + (use (match_dup 1))
20593 + (use (match_dup 4))]
20596 + rtx *mem_expr = &operands[0];
20598 + if ( !avr32_ks16_memory_operand (*mem_expr, GET_MODE (*mem_expr)) )
20600 + ptr_reg = force_reg (Pmode, XEXP (*mem_expr, 0));
20601 + XEXP (*mem_expr, 0) = ptr_reg;
20605 + rtx address = XEXP (*mem_expr, 0);
20606 + if ( REG_P (address) )
20607 + ptr_reg = address;
20608 + else if ( REG_P (XEXP (address, 0)) )
20609 + ptr_reg = XEXP (address, 0);
20611 + ptr_reg = XEXP (address, 1);
20614 + operands[2] = gen_reg_rtx (SImode);
20615 + operands[3] = gen_rtx_LABEL_REF(Pmode, gen_label_rtx ());
20616 + operands[4] = ptr_reg;
20623 +(define_expand "sync_old_<atomic_insn>si"
20624 + [(set (match_operand:SI 0 "register_operand" "")
20625 + (unspec_volatile:SI
20626 + [(match_operand:SI 1 "avr32_ks16_memory_operand" "")
20628 + VUNSPEC_SYNC_SET_LOCK_AND_LOAD))
20629 + (set (match_dup 3)
20630 + (atomic_op:SI (match_dup 0)
20631 + (match_operand:SI 2 "register_immediate_operand" "")))
20632 + (set (match_dup 1)
20633 + (unspec_volatile:SI
20636 + VUNSPEC_SYNC_STORE_IF_LOCK) )
20637 + (use (match_dup 2))
20638 + (use (match_dup 5))]
20641 + rtx *mem_expr = &operands[1];
20643 + if ( !avr32_ks16_memory_operand (*mem_expr, GET_MODE (*mem_expr)) )
20645 + ptr_reg = force_reg (Pmode, XEXP (*mem_expr, 0));
20646 + XEXP (*mem_expr, 0) = ptr_reg;
20650 + rtx address = XEXP (*mem_expr, 0);
20651 + if ( REG_P (address) )
20652 + ptr_reg = address;
20653 + else if ( REG_P (XEXP (address, 0)) )
20654 + ptr_reg = XEXP (address, 0);
20656 + ptr_reg = XEXP (address, 1);
20659 + operands[3] = gen_reg_rtx (SImode);
20660 + operands[4] = gen_rtx_LABEL_REF(Pmode, gen_label_rtx ());
20661 + operands[5] = ptr_reg;
20665 +(define_expand "sync_new_<atomic_insn>si"
20666 + [(set (match_operand:SI 0 "register_operand" "")
20667 + (unspec_volatile:SI
20668 + [(match_operand:SI 1 "avr32_ks16_memory_operand" "")
20670 + VUNSPEC_SYNC_SET_LOCK_AND_LOAD))
20671 + (set (match_dup 0)
20672 + (atomic_op:SI (match_dup 0)
20673 + (match_operand:SI 2 "register_immediate_operand" "")))
20674 + (set (match_dup 1)
20675 + (unspec_volatile:SI
20678 + VUNSPEC_SYNC_STORE_IF_LOCK) )
20679 + (use (match_dup 2))
20680 + (use (match_dup 4))]
20683 + rtx *mem_expr = &operands[1];
20685 + if ( !avr32_ks16_memory_operand (*mem_expr, GET_MODE (*mem_expr)) )
20687 + ptr_reg = force_reg (Pmode, XEXP (*mem_expr, 0));
20688 + XEXP (*mem_expr, 0) = ptr_reg;
20692 + rtx address = XEXP (*mem_expr, 0);
20693 + if ( REG_P (address) )
20694 + ptr_reg = address;
20695 + else if ( REG_P (XEXP (address, 0)) )
20696 + ptr_reg = XEXP (address, 0);
20698 + ptr_reg = XEXP (address, 1);
20701 + operands[3] = gen_rtx_LABEL_REF(Pmode, gen_label_rtx ());
20702 + operands[4] = ptr_reg;
20707 +;(define_insn "sync_<atomic_insn>si"
20708 +; [(set (match_operand:SI 0 "memory_operand" "+RKs16")
20709 +; (unspec_volatile:SI
20710 +; [(atomic_op:SI (match_dup 0)
20711 +; (match_operand:SI 1 "register_operand" "r"))]
20712 +; VUNSPEC_SYNC_CMPXCHG))
20713 +; (clobber (match_scratch:SI 2 "=&r"))]
20718 +; <atomic_asm_insn>\t%2,%1
20722 +; [(set_attr "length" "14")
20723 +; (set_attr "cc" "clobber")]
20726 +;(define_insn "sync_new_<atomic_insn>si"
20727 +; [(set (match_operand:SI 1 "memory_operand" "+RKs16")
20728 +; (unspec_volatile:SI
20729 +; [(atomic_op:SI (match_dup 1)
20730 +; (match_operand:SI 2 "register_operand" "r"))]
20731 +; VUNSPEC_SYNC_CMPXCHG))
20732 +; (set (match_operand:SI 0 "register_operand" "=&r")
20733 +; (atomic_op:SI (match_dup 1)
20734 +; (match_dup 2)))]
20739 +; <atomic_asm_insn>\t%0,%2
20743 +; [(set_attr "length" "14")
20744 +; (set_attr "cc" "clobber")]
20747 +(define_insn "sync_lock_test_and_setsi"
20748 + [ (set (match_operand:SI 0 "register_operand" "=&r")
20749 + (match_operand:SI 1 "memory_operand" "+RKu00"))
20750 + (set (match_dup 1)
20751 + (match_operand:SI 2 "register_operand" "r")) ]
20753 + "xchg\t%0, %p1, %2"
20754 + [(set_attr "length" "4")]
20757 +++ b/gcc/config/avr32/t-avr32
20760 +MD_INCLUDES= $(srcdir)/config/avr32/avr32.md \
20761 + $(srcdir)/config/avr32/sync.md \
20762 + $(srcdir)/config/avr32/simd.md \
20763 + $(srcdir)/config/avr32/predicates.md
20765 +s-config s-conditions s-flags s-codes s-constants s-emit s-recog s-preds \
20766 + s-opinit s-extract s-peep s-attr s-attrtab s-output: $(MD_INCLUDES)
20768 +# We want fine grained libraries, so use the new code
20769 +# to build the floating point emulation libraries.
20773 +LIB1ASMSRC = avr32/lib1funcs.S
20774 +LIB1ASMFUNCS = _avr32_f64_mul _avr32_f64_mul_fast _avr32_f64_addsub _avr32_f64_addsub_fast _avr32_f64_to_u32 \
20775 + _avr32_f64_to_s32 _avr32_f64_to_u64 _avr32_f64_to_s64 _avr32_u32_to_f64 \
20776 + _avr32_s32_to_f64 _avr32_f64_cmp_eq _avr32_f64_cmp_ge _avr32_f64_cmp_lt \
20777 + _avr32_f32_cmp_eq _avr32_f32_cmp_ge _avr32_f32_cmp_lt _avr32_f64_div _avr32_f64_div_fast \
20778 + _avr32_f32_div _avr32_f32_div_fast _avr32_f32_addsub _avr32_f32_addsub_fast \
20779 + _avr32_f32_mul _avr32_s32_to_f32 _avr32_u32_to_f32 _avr32_f32_to_s32 \
20780 + _avr32_f32_to_u32 _avr32_f32_to_f64 _avr32_f64_to_f32 _mulsi3
20782 +#LIB2FUNCS_EXTRA += $(srcdir)/config/avr32/lib2funcs.S
20784 +MULTILIB_OPTIONS = march=ap/march=ucr1/march=ucr2/march=ucr2nomul/march=ucr3/march=ucr3fp
20785 +MULTILIB_DIRNAMES = ap ucr1 ucr2 ucr2nomul ucr3 ucr3fp
20786 +MULTILIB_EXCEPTIONS =
20787 +MULTILIB_MATCHES += march?ap=mpart?ap7000
20788 +MULTILIB_MATCHES += march?ap=mpart?ap7001
20789 +MULTILIB_MATCHES += march?ap=mpart?ap7002
20790 +MULTILIB_MATCHES += march?ap=mpart?ap7200
20791 +MULTILIB_MATCHES += march?ucr1=march?uc
20792 +MULTILIB_MATCHES += march?ucr1=mpart?uc3a0512es
20793 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a0128
20794 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a0256
20795 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a0512
20796 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a1128
20797 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a1256
20798 +MULTILIB_MATCHES += march?ucr1=mpart?uc3a1512es
20799 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a1512
20800 +MULTILIB_MATCHES += march?ucr2nomul=mpart?uc3a3revd
20801 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a364
20802 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a364s
20803 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a3128
20804 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a3128s
20805 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a3256
20806 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a3256s
20807 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b064
20808 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b0128
20809 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b0256es
20810 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b0256
20811 +MULTILIB_MATCHES += march?ucr2=mpart?uc3b0512
20812 +MULTILIB_MATCHES += march?ucr2=mpart?uc3b0512revc
20813 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b164
20814 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b1128
20815 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b1256es
20816 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b1256
20817 +MULTILIB_MATCHES += march?ucr2=mpart?uc3b1512
20818 +MULTILIB_MATCHES += march?ucr2=mpart?uc3b1512revc
20819 +MULTILIB_MATCHES += march?ucr3=mpart?uc3c0512crevc
20820 +MULTILIB_MATCHES += march?ucr3=mpart?uc3c1512crevc
20821 +MULTILIB_MATCHES += march?ucr3=mpart?uc3c2512crevc
20822 +MULTILIB_MATCHES += march?ucr3=mpart?uc3l0256
20823 +MULTILIB_MATCHES += march?ucr3=mpart?uc3l0128
20824 +MULTILIB_MATCHES += march?ucr3=mpart?uc3l064
20825 +MULTILIB_MATCHES += march?ucr3=mpart?uc3l032
20826 +MULTILIB_MATCHES += march?ucr3=mpart?uc3l016
20827 +MULTILIB_MATCHES += march?ucr3=mpart?uc3l064revb
20828 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c064c
20829 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c0128c
20830 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c0256c
20831 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c0512c
20832 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c164c
20833 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c1128c
20834 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c1256c
20835 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c1512c
20836 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c264c
20837 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c2128c
20838 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c2256c
20839 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c2512c
20840 +MULTILIB_MATCHES += march?ucr3=mpart?mxt768e
20843 +EXTRA_MULTILIB_PARTS = crtbegin.o crtbeginS.o crtend.o crtendS.o crti.o crtn.o
20845 +CRTSTUFF_T_CFLAGS = -mrelax
20846 +CRTSTUFF_T_CFLAGS_S = -mrelax -fPIC
20847 +TARGET_LIBGCC2_CFLAGS += -mrelax
20849 +LIBGCC = stmp-multilib
20850 +INSTALL_LIBGCC = install-multilib
20852 +fp-bit.c: $(srcdir)/config/fp-bit.c
20853 + echo '#define FLOAT' > fp-bit.c
20854 + cat $(srcdir)/config/fp-bit.c >> fp-bit.c
20856 +dp-bit.c: $(srcdir)/config/fp-bit.c
20857 + cat $(srcdir)/config/fp-bit.c > dp-bit.c
20862 +++ b/gcc/config/avr32/t-avr32-linux
20865 +MD_INCLUDES= $(srcdir)/config/avr32/avr32.md \
20866 + $(srcdir)/config/avr32/sync.md \
20867 + $(srcdir)/config/avr32/simd.md \
20868 + $(srcdir)/config/avr32/predicates.md
20870 +s-config s-conditions s-flags s-codes s-constants s-emit s-recog s-preds \
20871 + s-opinit s-extract s-peep s-attr s-attrtab s-output: $(MD_INCLUDES)
20873 +# We want fine grained libraries, so use the new code
20874 +# to build the floating point emulation libraries.
20878 +LIB1ASMSRC = avr32/lib1funcs.S
20879 +LIB1ASMFUNCS = _avr32_f64_mul _avr32_f64_mul_fast _avr32_f64_addsub _avr32_f64_addsub_fast _avr32_f64_to_u32 \
20880 + _avr32_f64_to_s32 _avr32_f64_to_u64 _avr32_f64_to_s64 _avr32_u32_to_f64 \
20881 + _avr32_s32_to_f64 _avr32_f64_cmp_eq _avr32_f64_cmp_ge _avr32_f64_cmp_lt \
20882 + _avr32_f32_cmp_eq _avr32_f32_cmp_ge _avr32_f32_cmp_lt _avr32_f64_div _avr32_f64_div_fast \
20883 + _avr32_f32_div _avr32_f32_div_fast _avr32_f32_addsub _avr32_f32_addsub_fast \
20884 + _avr32_f32_mul _avr32_s32_to_f32 _avr32_u32_to_f32 _avr32_f32_to_s32 \
20885 + _avr32_f32_to_u32 _avr32_f32_to_f64 _avr32_f64_to_f32 _mulsi3
20887 +#LIB2FUNCS_EXTRA += $(srcdir)/config/avr32/lib2funcs.S
20889 +MULTILIB_OPTIONS = march=ap/march=ucr1/march=ucr2/march=ucr2nomul/march=ucr3/march=ucr3fp
20890 +MULTILIB_DIRNAMES = ap ucr1 ucr2 ucr2nomul ucr3 ucr3fp
20891 +MULTILIB_EXCEPTIONS =
20892 +MULTILIB_MATCHES += march?ap=mpart?ap7000
20893 +MULTILIB_MATCHES += march?ap=mpart?ap7001
20894 +MULTILIB_MATCHES += march?ap=mpart?ap7002
20895 +MULTILIB_MATCHES += march?ap=mpart?ap7200
20896 +MULTILIB_MATCHES += march?ucr1=march?uc
20897 +MULTILIB_MATCHES += march?ucr1=mpart?uc3a0512es
20898 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a0128
20899 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a0256
20900 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a0512
20901 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a1128
20902 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a1256
20903 +MULTILIB_MATCHES += march?ucr1=mpart?uc3a1512es
20904 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a1512
20905 +MULTILIB_MATCHES += march?ucr2nomul=mpart?uc3a3revd
20906 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a364
20907 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a364s
20908 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a3128
20909 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a3128s
20910 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a3256
20911 +MULTILIB_MATCHES += march?ucr2=mpart?uc3a3256s
20912 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b064
20913 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b0128
20914 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b0256es
20915 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b0256
20916 +MULTILIB_MATCHES += march?ucr2=mpart?uc3b0512
20917 +MULTILIB_MATCHES += march?ucr2=mpart?uc3b0512revc
20918 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b164
20919 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b1128
20920 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b1256es
20921 +MULTILIB_MATCHES += march?ucr1=mpart?uc3b1256
20922 +MULTILIB_MATCHES += march?ucr2=mpart?uc3b1512
20923 +MULTILIB_MATCHES += march?ucr2=mpart?uc3b1512revc
20924 +MULTILIB_MATCHES += march?ucr3=mpart?uc3c0512crevc
20925 +MULTILIB_MATCHES += march?ucr3=mpart?uc3c1512crevc
20926 +MULTILIB_MATCHES += march?ucr3=mpart?uc3c2512crevc
20927 +MULTILIB_MATCHES += march?ucr3=mpart?uc3l0256
20928 +MULTILIB_MATCHES += march?ucr3=mpart?uc3l0128
20929 +MULTILIB_MATCHES += march?ucr3=mpart?uc3l064
20930 +MULTILIB_MATCHES += march?ucr3=mpart?uc3l032
20931 +MULTILIB_MATCHES += march?ucr3=mpart?uc3l016
20932 +MULTILIB_MATCHES += march?ucr3=mpart?uc3l064revb
20933 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c064c
20934 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c0128c
20935 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c0256c
20936 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c0512c
20937 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c164c
20938 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c1128c
20939 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c1256c
20940 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c1512c
20941 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c264c
20942 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c2128c
20943 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c2256c
20944 +MULTILIB_MATCHES += march?ucr3fp=mpart?uc3c2512c
20945 +MULTILIB_MATCHES += march?ucr3=mpart?mxt768e
20948 +EXTRA_MULTILIB_PARTS = crtbegin.o crtbeginS.o crtend.o crtendS.o
20950 +CRTSTUFF_T_CFLAGS = -mrelax
20951 +CRTSTUFF_T_CFLAGS_S = -mrelax -fPIC
20952 +TARGET_LIBGCC2_CFLAGS += -mrelax
20954 +LIBGCC = stmp-multilib
20955 +INSTALL_LIBGCC = install-multilib
20957 +fp-bit.c: $(srcdir)/config/fp-bit.c
20958 + echo '#define FLOAT' > fp-bit.c
20959 + cat $(srcdir)/config/fp-bit.c >> fp-bit.c
20961 +dp-bit.c: $(srcdir)/config/fp-bit.c
20962 + cat $(srcdir)/config/fp-bit.c > dp-bit.c
20967 +++ b/gcc/config/avr32/t-elf
20970 +# Assemble startup files.
20971 +$(T)crti.o: $(srcdir)/config/avr32/crti.asm $(GCC_PASSES)
20972 + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) $(INCLUDES) \
20973 + -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/avr32/crti.asm
20975 +$(T)crtn.o: $(srcdir)/config/avr32/crtn.asm $(GCC_PASSES)
20976 + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) $(INCLUDES) \
20977 + -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/avr32/crtn.asm
20980 +# Build the libraries for both hard and soft floating point
20981 +EXTRA_MULTILIB_PARTS = crtbegin.o crtbeginS.o crtend.o crtendS.o crti.o crtn.o
20983 +LIBGCC = stmp-multilib
20984 +INSTALL_LIBGCC = install-multilib
20986 +++ b/gcc/config/avr32/uc3fpu.md
20988 +;; AVR32 machine description file for Floating-Point instructions.
20989 +;; Copyright 2003-2006 Atmel Corporation.
20992 +;; This file is part of GCC.
20994 +;; This program is free software; you can redistribute it and/or modify
20995 +;; it under the terms of the GNU General Public License as published by
20996 +;; the Free Software Foundation; either version 2 of the License, or
20997 +;; (at your option) any later version.
20999 +;; This program is distributed in the hope that it will be useful,
21000 +;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21001 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21002 +;; GNU General Public License for more details.
21004 +;; You should have received a copy of the GNU General Public License
21005 +;; along with this program; if not, write to the Free Software
21006 +;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21008 +(define_insn "*movsf_uc3fp"
21009 + [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,r,m")
21010 + (match_operand:SF 1 "general_operand" "r,G,m,r"))]
21011 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21017 + [(set_attr "length" "2,4,4,4")
21018 + (set_attr "type" "alu,alu,load,store")])
21020 +(define_insn "mulsf3"
21021 + [(set (match_operand:SF 0 "register_operand" "=r")
21022 + (mult:SF (match_operand:SF 1 "register_operand" "r")
21023 + (match_operand:SF 2 "register_operand" "r")))]
21024 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21025 + "fmul.s\t%0, %1, %2"
21026 + [(set_attr "length" "4")
21027 + (set_attr "type" "fmul")])
21029 +(define_insn "nmulsf3"
21030 + [(set (match_operand:SF 0 "register_operand" "=r")
21031 + (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "%r")
21032 + (match_operand:SF 2 "register_operand" "r"))))]
21033 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21034 + "fnmul.s\t%0, %1, %2"
21035 + [(set_attr "length" "4")
21036 + (set_attr "type" "fmul")])
21038 +(define_insn "macsf3"
21039 + [(set (match_operand:SF 0 "register_operand" "=r")
21040 + (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "r")
21041 + (match_operand:SF 2 "register_operand" "r"))
21042 + (match_operand:SF 3 "register_operand" "r")))]
21043 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21044 + "fmac.s\t%0, %3, %1, %2"
21045 + [(set_attr "length" "4")
21046 + (set_attr "type" "fmul")])
21048 +;(define_insn "nmacsf3"
21049 +; [(set (match_operand:SF 0 "register_operand" "=r")
21050 +; (plus:SF (neg:SF (match_operand:SF 1 "register_operand" "r"))
21051 +; (mult:SF(match_operand:SF 2 "register_operand" "r")
21052 +; (match_operand:SF 3 "register_operand" "r"))))]
21053 +; "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21054 +; "fnmac.s\t%0, %1, %2, %3"
21055 +; [(set_attr "length" "4")
21056 +; (set_attr "type" "fmul")])
21058 +(define_insn "nmacsf3"
21059 + [(set (match_operand:SF 0 "register_operand" "=r")
21060 + (minus:SF (mult:SF (match_operand:SF 2 "register_operand" "r")
21061 + (match_operand:SF 3 "register_operand" "r"))
21062 + (match_operand:SF 1 "register_operand" "r")))]
21063 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21064 + "fnmac.s\t%0, %1, %2, %3"
21065 + [(set_attr "length" "4")
21066 + (set_attr "type" "fmul")])
21068 +(define_insn "msubacsf3"
21069 + [(set (match_operand:SF 0 "register_operand" "=r")
21070 + (minus:SF (match_operand:SF 3 "register_operand" "r")
21071 + (mult:SF (match_operand:SF 1 "register_operand" "r")
21072 + (match_operand:SF 2 "register_operand" "r"))))]
21073 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21074 + "fmsc.s\t%0, %3, %1, %2"
21075 + [(set_attr "length" "4")
21076 + (set_attr "type" "fmul")])
21078 +(define_insn "nmsubacsf3"
21079 + [(set (match_operand:SF 0 "register_operand" "=r")
21080 + (minus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "r")
21081 + (match_operand:SF 2 "register_operand" "r")))
21082 + (match_operand:SF 3 "register_operand" "r")))]
21083 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21084 + "fnmsc.s\t%0, %3, %1, %2"
21085 + [(set_attr "length" "4")
21086 + (set_attr "type" "fmul")])
21088 +(define_insn "addsf3"
21089 + [(set (match_operand:SF 0 "register_operand" "=r")
21090 + (plus:SF (match_operand:SF 1 "register_operand" "%r")
21091 + (match_operand:SF 2 "register_operand" "r")))]
21092 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21093 + "fadd.s\t%0, %1, %2"
21094 + [(set_attr "length" "4")
21095 + (set_attr "type" "fmul")])
21097 +(define_insn "subsf3"
21098 + [(set (match_operand:SF 0 "register_operand" "=r")
21099 + (minus:SF (match_operand:SF 1 "register_operand" "r")
21100 + (match_operand:SF 2 "register_operand" "r")))]
21101 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21102 + "fsub.s\t%0, %1, %2"
21103 + [(set_attr "length" "4")
21104 + (set_attr "type" "fmul")])
21106 +(define_insn "fixuns_truncsfsi2"
21107 + [(set (match_operand:SI 0 "register_operand" "=r")
21108 + (unsigned_fix:SI (match_operand:SF 1 "register_operand" "r")))]
21109 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21110 + "fcastrs.uw\t%0, %1"
21111 + [(set_attr "length" "4")])
21113 +(define_insn "fix_truncsfsi2"
21114 + [(set (match_operand:SI 0 "register_operand" "=r")
21115 + (fix:SI (match_operand:SF 1 "register_operand" "r")))]
21116 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21117 + "fcastrs.sw\t%0, %1"
21118 + [(set_attr "length" "4")])
21120 +(define_insn "floatunssisf2"
21121 + [(set (match_operand:SF 0 "register_operand" "=r")
21122 + (unsigned_float:SF (match_operand:SI 1 "register_operand" "r")))]
21123 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21124 + "fcastuw.s\t%0, %1"
21125 + [(set_attr "length" "4")])
21127 +(define_insn "floatsisf2"
21128 + [(set (match_operand:SF 0 "register_operand" "=r")
21129 + (float:SF (match_operand:SI 1 "register_operand" "r")))]
21130 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21131 + "fcastsw.s\t%0, %1"
21132 + [(set_attr "length" "4")])
21134 +(define_insn "cmpsf_internal_uc3fp"
21137 + (match_operand:SF 0 "register_operand" "r")
21138 + (match_operand:SF 1 "register_operand" "r")))]
21139 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21141 + if (!rtx_equal_p(cc_prev_status.mdep.value, SET_SRC(PATTERN (insn))) )
21142 + return "fcmp.s\t%0, %1";
21145 + [(set_attr "length" "4")
21146 + (set_attr "cc" "compare")])
21148 +(define_expand "divsf3"
21149 + [(set (match_operand:SF 0 "register_operand" "=r")
21150 + (div:SF (match_operand:SF 1 "register_operand" "r")
21151 + (match_operand:SF 2 "register_operand" "r")))]
21152 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT && flag_unsafe_math_optimizations"
21154 + emit_insn(gen_frcpa_internal(operands[0],operands[2]));
21155 + emit_insn(gen_mulsf3(operands[0],operands[0],operands[1]));
21160 +(define_insn "frcpa_internal"
21161 + [(set (match_operand:SF 0 "register_operand" "=r")
21162 + (unspec:SF [(match_operand:SF 1 "register_operand" "r")] UNSPEC_FRCPA))]
21163 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21165 + [(set_attr "length" "4")])
21167 +(define_expand "sqrtsf2"
21168 + [(set (match_operand:SF 0 "register_operand" "")
21169 + (sqrt:SF (match_operand:SF 1 "register_operand" "")))]
21170 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT && flag_unsafe_math_optimizations"
21173 + rtx scratch = gen_reg_rtx (SFmode);
21174 + emit_insn (gen_rsqrtsf2 (scratch, operands[1], CONST1_RTX (SFmode)));
21175 + emit_insn (gen_divsf3(operands[0], force_reg (SFmode, CONST1_RTX (SFmode)),
21180 +(define_insn "rsqrtsf2"
21181 + [(set (match_operand:SF 0 "register_operand" "=r")
21182 + (div:SF (match_operand:SF 2 "const_1f_operand" "F")
21183 + (sqrt:SF (match_operand:SF 1 "register_operand" "?r"))))]
21184 + "TARGET_ARCH_FPU && TARGET_HARD_FLOAT"
21185 + "frsqrta.s %1, %0")
21187 +++ b/gcc/config/avr32/uclinux-elf.h
21190 +/* Run-time Target Specification. */
21191 +#undef TARGET_VERSION
21192 +#define TARGET_VERSION fputs (" (AVR32 uClinux with ELF)", stderr)
21194 +/* We don't want a .jcr section on uClinux. As if this makes a difference... */
21195 +#define TARGET_USE_JCR_SECTION 0
21197 +/* Here we go. Drop the crtbegin/crtend stuff completely. */
21198 +#undef STARTFILE_SPEC
21199 +#define STARTFILE_SPEC \
21200 + "%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s}" \
21201 + " %{!p:%{profile:gcrt1.o%s}" \
21202 + " %{!profile:crt1.o%s}}}} crti.o%s"
21204 +#undef ENDFILE_SPEC
21205 +#define ENDFILE_SPEC "crtn.o%s"
21207 +#undef TARGET_DEFAULT
21208 +#define TARGET_DEFAULT (AVR32_FLAG_NO_INIT_GOT)
21209 --- a/gcc/config/host-linux.c
21210 +++ b/gcc/config/host-linux.c
21212 #include "hosthooks.h"
21213 #include "hosthooks-def.h"
21216 +#define SSIZE_MAX LONG_MAX
21219 /* Linux has a feature called exec-shield-randomize that perturbs the
21220 address of non-fixed mapped segments by a (relatively) small amount.
21221 --- a/gcc/config.gcc
21222 +++ b/gcc/config.gcc
21223 @@ -834,6 +834,24 @@ avr-*-*)
21224 tm_file="avr/avr.h dbxelf.h"
21228 + tm_file="dbxelf.h elfos.h linux.h avr32/linux-elf.h avr32/avr32.h "
21229 + tmake_file="t-linux avr32/t-avr32-linux"
21230 + extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
21231 + extra_modes=avr32/avr32-modes.def
21234 +avr32*-*-uclinux*)
21235 + tm_file="dbxelf.h elfos.h linux.h avr32/linux-elf.h avr32/uclinux-elf.h avr32/avr32.h"
21236 + tmake_file="t-linux avr32/t-avr32-linux"
21237 + extra_modes=avr32/avr32-modes.def
21241 + tm_file="dbxelf.h elfos.h avr32/avr32.h avr32/avr32-elf.h"
21242 + tmake_file="avr32/t-avr32 avr32/t-elf"
21243 + extra_modes=avr32/avr32-modes.def
21246 tm_file="${tm_file} dbxelf.h elfos.h bfin/elf.h"
21247 tmake_file=bfin/t-bfin-elf
21248 @@ -2950,6 +2968,32 @@ case "${target}" in
21253 + supported_defaults="part arch"
21255 + case "$with_part" in
21257 + | "ap7000" | "ap7010" | "ap7020" | "uc3a0256" | "uc3a0512" | "uc3a1128" | "uc3a1256" | "uc3a1512" )
21261 + echo "Unknown part used in --with-part=$with_part" 1>&2
21266 + case "$with_arch" in
21272 + echo "Unknown arch used in --with-arch=$with_arch" 1>&2
21279 supported_defaults=cpu
21280 case "$with_cpu" in
21281 --- a/gcc/configure.ac
21282 +++ b/gcc/configure.ac
21283 @@ -2174,10 +2174,9 @@ L2:],
21284 as_ver=`$gcc_cv_as --version 2>/dev/null | sed 1q`
21285 if echo "$as_ver" | grep GNU > /dev/null; then
21287 - as_vers=`echo $as_ver | sed -n \
21288 - -e 's,^.*[ ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'`
21289 - as_major=`expr "$as_vers" : '\([0-9]*\)'`
21290 - as_minor=`expr "$as_vers" : '[0-9]*\.\([0-9]*\)'`
21291 + as_ver=`echo $as_ver | sed -e 's/GNU assembler\( (GNU Binutils)\)\? \([0-9.][0-9.]*\).*/\2/'`
21292 + as_major=`echo $as_ver | sed 's/\..*//'`
21293 + as_minor=`echo $as_ver | sed 's/[^.]*\.\([0-9]*\).*/\1/'`
21294 changequote([,])dnl
21295 if test $as_major -eq 2 && test $as_minor -lt 11
21297 @@ -3077,7 +3076,7 @@ esac
21299 i?86*-*-* | mips*-*-* | alpha*-*-* | powerpc*-*-* | sparc*-*-* | m68*-*-* \
21300 | x86_64*-*-* | hppa*-*-* | arm*-*-* | strongarm*-*-* | xscale*-*-* \
21301 - | xstormy16*-*-* | cris-*-* | xtensa-*-* | bfin-*-* | score*-*-* | spu-*-*)
21302 + | xstormy16*-*-* | cris-*-* | xtensa-*-* | bfin-*-* | score*-*-* | spu-*-* | avr32-*-*)
21305 ia64*-*-* | s390*-*-*)
21306 --- a/gcc/doc/extend.texi
21307 +++ b/gcc/doc/extend.texi
21308 @@ -2336,7 +2336,7 @@ This attribute is ignored for R8C target
21311 @cindex interrupt handler functions
21312 -Use this attribute on the ARM, AVR, CRX, M32C, M32R/D, m68k, MS1,
21313 +Use this attribute on the ARM, AVR, AVR32, CRX, M32C, M32R/D, m68k, MS1,
21314 and Xstormy16 ports to indicate that the specified function is an
21315 interrupt handler. The compiler will generate function entry and exit
21316 sequences suitable for use in an interrupt handler when this attribute
21317 @@ -2356,6 +2356,15 @@ void f () __attribute__ ((interrupt ("IR
21319 Permissible values for this parameter are: IRQ, FIQ, SWI, ABORT and UNDEF@.
21321 +Note, for the AVR32, you can specify which banking scheme is used for
21322 +the interrupt mode this interrupt handler is used in like this:
21325 +void f () __attribute__ ((interrupt ("FULL")));
21328 +Permissible values for this parameter are: FULL, HALF, NONE and UNDEF.
21330 On ARMv7-M the interrupt type is ignored, and the attribute means the function
21331 may be called with a word aligned stack pointer.
21333 @@ -3925,6 +3934,23 @@ placed in either the @code{.bss_below100
21337 +@subsection AVR32 Variable Attributes
21339 +One attribute is currently defined for AVR32 configurations:
21340 +@code{rmw_addressable}
21343 +@item rmw_addressable
21344 +@cindex @code{rmw_addressable} attribute
21346 +This attribute can be used to signal that a variable can be accessed
21347 +with the addressing mode of the AVR32 Atomic Read-Modify-Write memory
21348 +instructions and hence make it possible for gcc to generate these
21349 +instructions without using built-in functions or inline assembly statements.
21350 +Variables used within the AVR32 Atomic Read-Modify-Write built-in
21351 +functions will automatically get the @code{rmw_addressable} attribute.
21354 @subsection AVR Variable Attributes
21357 @@ -6708,6 +6734,7 @@ instructions, but allow the compiler to
21358 * Alpha Built-in Functions::
21359 * ARM iWMMXt Built-in Functions::
21360 * ARM NEON Intrinsics::
21361 +* AVR32 Built-in Functions::
21362 * Blackfin Built-in Functions::
21363 * FR-V Built-in Functions::
21364 * X86 Built-in Functions::
21365 @@ -6947,6 +6974,7 @@ long long __builtin_arm_wxor (long long,
21366 long long __builtin_arm_wzero ()
21370 @node ARM NEON Intrinsics
21371 @subsection ARM NEON Intrinsics
21373 @@ -6955,6 +6983,74 @@ when the @option{-mfpu=neon} switch is u
21375 @include arm-neon-intrinsics.texi
21377 +@node AVR32 Built-in Functions
21378 +@subsection AVR32 Built-in Functions
21380 +Built-in functions for atomic memory (RMW) instructions. Note that these
21381 +built-ins will fail for targets where the RMW instructions are not
21382 +implemented. Also note that these instructions only that a Ks15 << 2
21383 +memory address and will therefor not work with any runtime computed
21384 +memory addresses. The user is responsible for making sure that any
21385 +pointers used within these functions points to a valid memory address.
21388 +void __builtin_mems(int */*ptr*/, int /*bit*/)
21389 +void __builtin_memc(int */*ptr*/, int /*bit*/)
21390 +void __builtin_memt(int */*ptr*/, int /*bit*/)
21393 +Built-in functions for DSP instructions. Note that these built-ins will
21394 +fail for targets where the DSP instructions are not implemented.
21397 +int __builtin_sats (int /*Rd*/,int /*sa*/, int /*bn*/)
21398 +int __builtin_satu (int /*Rd*/,int /*sa*/, int /*bn*/)
21399 +int __builtin_satrnds (int /*Rd*/,int /*sa*/, int /*bn*/)
21400 +int __builtin_satrndu (int /*Rd*/,int /*sa*/, int /*bn*/)
21401 +short __builtin_mulsathh_h (short, short)
21402 +int __builtin_mulsathh_w (short, short)
21403 +short __builtin_mulsatrndhh_h (short, short)
21404 +int __builtin_mulsatrndwh_w (int, short)
21405 +int __builtin_mulsatwh_w (int, short)
21406 +int __builtin_macsathh_w (int, short, short)
21407 +short __builtin_satadd_h (short, short)
21408 +short __builtin_satsub_h (short, short)
21409 +int __builtin_satadd_w (int, int)
21410 +int __builtin_satsub_w (int, int)
21411 +long long __builtin_mulwh_d(int, short)
21412 +long long __builtin_mulnwh_d(int, short)
21413 +long long __builtin_macwh_d(long long, int, short)
21414 +long long __builtin_machh_d(long long, short, short)
21417 +Other built-in functions for instructions that cannot easily be
21418 +generated by the compiler.
21421 +void __builtin_ssrf(int);
21422 +void __builtin_csrf(int);
21423 +void __builtin_musfr(int);
21424 +int __builtin_mustr(void);
21425 +int __builtin_mfsr(int /*Status Register Address*/)
21426 +void __builtin_mtsr(int /*Status Register Address*/, int /*Value*/)
21427 +int __builtin_mfdr(int /*Debug Register Address*/)
21428 +void __builtin_mtdr(int /*Debug Register Address*/, int /*Value*/)
21429 +void __builtin_cache(void * /*Address*/, int /*Cache Operation*/)
21430 +void __builtin_sync(int /*Sync Operation*/)
21431 +void __builtin_tlbr(void)
21432 +void __builtin_tlbs(void)
21433 +void __builtin_tlbw(void)
21434 +void __builtin_breakpoint(void)
21435 +int __builtin_xchg(void * /*Address*/, int /*Value*/ )
21436 +short __builtin_bswap_16(short)
21437 +int __builtin_bswap_32(int)
21438 +void __builtin_cop(int/*cpnr*/, int/*crd*/, int/*crx*/, int/*cry*/, int/*op*/)
21439 +int __builtin_mvcr_w(int/*cpnr*/, int/*crs*/)
21440 +void __builtin_mvrc_w(int/*cpnr*/, int/*crd*/, int/*value*/)
21441 +long long __builtin_mvcr_d(int/*cpnr*/, int/*crs*/)
21442 +void __builtin_mvrc_d(int/*cpnr*/, int/*crd*/, long long/*value*/)
21445 @node Blackfin Built-in Functions
21446 @subsection Blackfin Built-in Functions
21448 --- a/gcc/doc/invoke.texi
21449 +++ b/gcc/doc/invoke.texi
21450 @@ -195,7 +195,7 @@ in the following sections.
21451 -fvisibility-ms-compat @gol
21452 -Wabi -Wctor-dtor-privacy @gol
21453 -Wnon-virtual-dtor -Wreorder @gol
21454 --Weffc++ -Wno-deprecated -Wstrict-null-sentinel @gol
21455 +-Weffc++ -Wno-deprecated @gol
21456 -Wno-non-template-friend -Wold-style-cast @gol
21457 -Woverloaded-virtual -Wno-pmf-conversions @gol
21459 @@ -609,6 +609,12 @@ Objective-C and Objective-C++ Dialects}.
21460 -mauto-incdec -minmax -mlong-calls -mshort @gol
21461 -msoft-reg-count=@var{count}}
21463 +@emph{AVR32 Options}
21464 +@gccoptlist{-muse-rodata-section -mhard-float -msoft-float -mrelax @gol
21465 +-mforce-double-align -mno-init-got -mrelax -mmd-reorg-opt -masm-addr-pseudos @gol
21466 +-mpart=@var{part} -mcpu=@var{cpu} -march=@var{arch} @gol
21467 +-mfast-float -mimm-in-const-pool}
21469 @emph{MCore Options}
21470 @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
21471 -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
21472 @@ -3163,13 +3169,11 @@ requiring @option{-O}.
21473 If you want to warn about code which uses the uninitialized value of the
21474 variable in its own initializer, use the @option{-Winit-self} option.
21476 -These warnings occur for individual uninitialized or clobbered
21477 -elements of structure, union or array variables as well as for
21478 -variables which are uninitialized or clobbered as a whole. They do
21479 -not occur for variables or elements declared @code{volatile}. Because
21480 -these warnings depend on optimization, the exact variables or elements
21481 -for which there are warnings will depend on the precise optimization
21482 -options and version of GCC used.
21483 +These warnings occur only for variables that are candidates for
21484 +register allocation. Therefore, they do not occur for a variable that
21485 +is declared @code{volatile}, or whose address is taken, or whose size
21486 +is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
21487 +structures, unions or arrays, even when they are in registers.
21489 Note that there may be no warning about a variable that is used only
21490 to compute a value that itself is never used, because such
21491 @@ -7034,10 +7038,6 @@ If number of candidates in the set is sm
21492 we always try to remove unnecessary ivs from the set during its
21493 optimization when a new iv is added to the set.
21495 -@item scev-max-expr-size
21496 -Bound on size of expressions used in the scalar evolutions analyzer.
21497 -Large expressions slow the analyzer.
21499 @item omega-max-vars
21500 The maximum number of variables in an Omega constraint system.
21501 The default value is 128.
21502 @@ -8363,6 +8363,7 @@ platform.
21507 * Blackfin Options::
21510 @@ -8834,6 +8835,129 @@ comply to the C standards, but it will p
21514 +@node AVR32 Options
21515 +@subsection AVR32 Options
21516 +@cindex AVR32 Options
21518 +These options are defined for AVR32 implementations:
21521 +@item -muse-rodata-section
21522 +@opindex muse-rodata-section
21523 +Use section @samp{.rodata} for read-only data instead of @samp{.text}.
21525 +@item -mhard-float
21526 +@opindex mhard-float
21527 +Use floating point coprocessor instructions.
21529 +@item -msoft-float
21530 +@opindex msoft-float
21531 +Use software floating-point library for floating-point operations.
21533 +@item -mforce-double-align
21534 +@opindex mforce-double-align
21535 +Force double-word alignment for double-word memory accesses.
21537 +@item -masm-addr-pseudos
21538 +@opindex masm-addr-pseudos
21539 +Use assembler pseudo-instructions lda.w and call for handling direct
21540 +addresses. (Enabled by default)
21542 +@item -mno-init-got
21543 +@opindex mno-init-got
21544 +Do not initialize the GOT register before using it when compiling PIC
21549 +Let invoked assembler and linker do relaxing
21550 +(Enabled by default when optimization level is >1).
21551 +This means that when the address of symbols are known at link time,
21552 +the linker can optimize @samp{icall} and @samp{mcall}
21553 +instructions into a @samp{rcall} instruction if possible.
21554 +Loading the address of a symbol can also be optimized.
21556 +@item -mmd-reorg-opt
21557 +@opindex mmd-reorg-opt
21558 +Perform machine dependent optimizations in reorg stage.
21560 +@item -mpart=@var{part}
21562 +Generate code for the specified part. Permissible parts are:
21570 +@samp{uc3a0512es},
21574 +@samp{uc3a1512es},
21585 +@samp{uc3b0256es},
21587 +@samp{uc3b0512revc},
21591 +@samp{uc3b1256es},
21593 +@samp{uc3b1512revc}
21594 +@samp{uc3c0512crevc},
21595 +@samp{uc3c1512crevc},
21596 +@samp{uc3c2512crevc},
21602 +@samp{uc3l064revb},
21617 +@item -mcpu=@var{cpu-type}
21619 +Same as -mpart. Obsolete.
21621 +@item -march=@var{arch}
21623 +Generate code for the specified architecture. Permissible architectures are:
21624 +@samp{ap}, @samp{uc} and @samp{ucr2}.
21626 +@item -mfast-float
21627 +@opindex mfast-float
21628 +Enable fast floating-point library that does not conform to IEEE-754 but is still good enough
21629 +for most applications. The fast floating-point library does not round to the nearest even
21630 +but away from zero. Enabled by default if the -funsafe-math-optimizations switch is specified.
21632 +@item -mimm-in-const-pool
21633 +@opindex mimm-in-const-pool
21634 +Put large immediates in constant pool. This is enabled by default for archs with insn-cache.
21637 @node Blackfin Options
21638 @subsection Blackfin Options
21639 @cindex Blackfin Options
21640 @@ -8889,29 +9013,12 @@ When enabled, the compiler will ensure t
21641 contain speculative loads after jump instructions. If this option is used,
21642 @code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
21644 -@item -mno-specld-anomaly
21645 -@opindex mno-specld-anomaly
21646 -Don't generate extra code to prevent speculative loads from occurring.
21648 @item -mcsync-anomaly
21649 @opindex mcsync-anomaly
21650 When enabled, the compiler will ensure that the generated code does not
21651 contain CSYNC or SSYNC instructions too soon after conditional branches.
21652 If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
21654 -@item -mno-csync-anomaly
21655 -@opindex mno-csync-anomaly
21656 -Don't generate extra code to prevent CSYNC or SSYNC instructions from
21657 -occurring too soon after a conditional branch.
21661 -When enabled, the compiler is free to take advantage of the knowledge that
21662 -the entire program fits into the low 64k of memory.
21664 -@item -mno-low-64k
21665 -@opindex mno-low-64k
21666 -Assume that the program is arbitrarily large. This is the default.
21668 @item -mstack-check-l1
21669 @opindex mstack-check-l1
21670 @@ -8925,11 +9032,6 @@ This allows for execute in place and sha
21671 without virtual memory management. This option implies @option{-fPIC}.
21672 With a @samp{bfin-elf} target, this option implies @option{-msim}.
21674 -@item -mno-id-shared-library
21675 -@opindex mno-id-shared-library
21676 -Generate code that doesn't assume ID based shared libraries are being used.
21677 -This is the default.
21679 @item -mleaf-id-shared-library
21680 @opindex mleaf-id-shared-library
21681 Generate code that supports shared libraries via the library ID method,
21682 @@ -8971,11 +9073,6 @@ call on this register. This switch is n
21683 will lie outside of the 24 bit addressing range of the offset based
21684 version of subroutine call instruction.
21686 -This feature is not enabled by default. Specifying
21687 -@option{-mno-long-calls} will restore the default behavior. Note these
21688 -switches have no effect on how the compiler generates code to handle
21689 -function calls via function pointers.
21693 Link with the fast floating-point library. This library relaxes some of
21694 --- a/gcc/doc/md.texi
21695 +++ b/gcc/doc/md.texi
21697 @c This is part of the GCC manual.
21698 @c For copying conditions, see the file gcc.texi.
21703 @chapter Machine Descriptions
21704 @@ -1681,6 +1682,58 @@ A memory reference suitable for iWMMXt l
21705 A memory reference suitable for the ARMv4 ldrsb instruction.
21708 +@item AVR32 family---@file{avr32.h}
21711 +Floating-point registers (f0 to f15)
21713 +@item Ku@var{bits}
21714 +Unsigned constant representable with @var{bits} number of bits (Must be
21715 +two digits). I.e: An unsigned 8-bit constant is written as @samp{Ku08}
21717 +@item Ks@var{bits}
21718 +Signed constant representable with @var{bits} number of bits (Must be
21719 +two digits). I.e: A signed 12-bit constant is written as @samp{Ks12}
21721 +@item Is@var{bits}
21722 +The negated range of a signed constant representable with @var{bits}
21723 +number of bits. The same as @samp{Ks@var{bits}} with a negated range.
21724 +This means that the constant must be in the range @math{-2^{bits-1}-1} to @math{2^{bits-1}}
21727 +A single/double precision floating-point immediate or 64-bit integer
21728 +immediate where the least and most significant words both can be
21729 +loaded with a move instruction. That is the the integer form of the
21730 +values in the least and most significant words both are in the range
21731 +@math{-2^{20}} to @math{2^{20}-1}.
21733 +@item RKs@var{bits}
21734 +A memory reference where the address consists of a base register
21735 +plus a signed immediate displacement with range given by @samp{Ks@var{bits}}
21736 +which has the same format as for the signed immediate integer constraint
21739 +@item RKu@var{bits}
21740 +A memory reference where the address consists of a base register
21741 +plus an unsigned immediate displacement with range given by @samp{Ku@var{bits}}
21742 +which has the same format as for the unsigned immediate integer constraint
21746 +A memory reference with an immediate or register offset
21749 +A memory reference to a constant pool entry
21752 +A valid operand for use in the @samp{lda.w} instruction macro when
21753 +relaxing is enabled
21756 +A memory reference valid for coprocessor memory instructions
21760 @item AVR family---@file{config/avr/constraints.md}
21765 @@ -463,9 +463,9 @@ store_bit_field_1 (rtx str_rtx, unsigned
21766 ? ((GET_MODE_SIZE (fieldmode) >= UNITS_PER_WORD
21767 || GET_MODE_SIZE (GET_MODE (op0)) == GET_MODE_SIZE (fieldmode))
21768 && byte_offset % GET_MODE_SIZE (fieldmode) == 0)
21769 - : (! SLOW_UNALIGNED_ACCESS (fieldmode, MEM_ALIGN (op0))
21770 + : ( (! SLOW_UNALIGNED_ACCESS (fieldmode, MEM_ALIGN (op0))
21771 || (offset * BITS_PER_UNIT % bitsize == 0
21772 - && MEM_ALIGN (op0) % GET_MODE_BITSIZE (fieldmode) == 0))))
21773 + && MEM_ALIGN (op0) % GET_MODE_BITSIZE (fieldmode) == 0)))))
21776 op0 = adjust_address (op0, fieldmode, offset);
21779 @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.
21780 #include "tree-flow.h"
21781 #include "target.h"
21782 #include "timevar.h"
21783 +#include "c-common.h"
21785 #include "diagnostic.h"
21787 @@ -3620,16 +3621,17 @@ emit_single_push_insn (enum machine_mode
21791 + emit_move_insn (stack_pointer_rtx,
21792 + expand_binop (Pmode,
21793 #ifdef STACK_GROWS_DOWNWARD
21794 - /* ??? This seems wrong if STACK_PUSH_CODE == POST_DEC. */
21795 - dest_addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
21796 - GEN_INT (-(HOST_WIDE_INT) rounded_size));
21799 - /* ??? This seems wrong if STACK_PUSH_CODE == POST_INC. */
21800 - dest_addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
21801 - GEN_INT (rounded_size));
21804 - dest_addr = gen_rtx_PRE_MODIFY (Pmode, stack_pointer_rtx, dest_addr);
21805 + stack_pointer_rtx,
21806 + GEN_INT (rounded_size),
21807 + NULL_RTX, 0, OPTAB_LIB_WIDEN));
21808 + dest_addr = stack_pointer_rtx;
21811 dest = gen_rtx_MEM (mode, dest_addr);
21812 @@ -5739,7 +5741,8 @@ store_field (rtx target, HOST_WIDE_INT b
21813 is a bit field, we cannot use addressing to access it.
21814 Use bit-field techniques or SUBREG to store in it. */
21816 - if (mode == VOIDmode
21819 || (mode != BLKmode && ! direct_store[(int) mode]
21820 && GET_MODE_CLASS (mode) != MODE_COMPLEX_INT
21821 && GET_MODE_CLASS (mode) != MODE_COMPLEX_FLOAT)
21822 @@ -5896,7 +5899,18 @@ get_inner_reference (tree exp, HOST_WIDE
21824 tree field = TREE_OPERAND (exp, 1);
21825 size_tree = DECL_SIZE (field);
21826 - if (!DECL_BIT_FIELD (field))
21827 + if (!DECL_BIT_FIELD (field)
21828 + /* Added for AVR32:
21829 + Bitfields with a size equal to a target storage
21830 + type might not cause DECL_BIT_FIELD to return
21831 + true since it can be optimized into a normal array
21832 + access operation. But for volatile bitfields we do
21833 + not allow this when targetm.narrow_volatile_bitfield ()
21834 + is false. We can use DECL_C_BIT_FIELD to check if this
21835 + really is a c-bitfield. */
21836 + && !(TREE_THIS_VOLATILE (exp)
21837 + && !targetm.narrow_volatile_bitfield ()
21838 + && DECL_C_BIT_FIELD (field)) )
21839 mode = DECL_MODE (field);
21840 else if (DECL_MODE (field) == BLKmode)
21841 blkmode_bitfield = true;
21842 @@ -7889,7 +7903,8 @@ expand_expr_real_1 (tree exp, rtx target
21843 by doing the extract into an object as wide as the field
21844 (which we know to be the width of a basic mode), then
21845 storing into memory, and changing the mode to BLKmode. */
21846 - if (mode1 == VOIDmode
21848 + mode1 == VOIDmode
21849 || REG_P (op0) || GET_CODE (op0) == SUBREG
21850 || (mode1 != BLKmode && ! direct_load[(int) mode1]
21851 && GET_MODE_CLASS (mode) != MODE_COMPLEX_INT
21852 --- a/gcc/function.c
21853 +++ b/gcc/function.c
21854 @@ -2715,7 +2715,11 @@ assign_parm_setup_reg (struct assign_par
21855 SET_DECL_RTL (parm, parmreg);
21857 /* Copy the value into the register. */
21858 - if (data->nominal_mode != data->passed_mode
21859 + if ( (data->nominal_mode != data->passed_mode
21860 + /* Added for AVR32: If passed_mode is equal
21861 + to promoted nominal mode why should be convert?
21862 + The conversion should make no difference. */
21863 + && data->passed_mode != promoted_nominal_mode)
21864 || promoted_nominal_mode != data->promoted_mode)
21866 int save_tree_used;
21867 --- a/gcc/genemit.c
21868 +++ b/gcc/genemit.c
21869 @@ -121,6 +121,24 @@ max_operand_vec (rtx insn, int arg)
21873 +gen_vararg_prologue(int operands)
21877 + if (operands > 1)
21879 + for (i = 1; i < operands; i++)
21880 + printf(" rtx operand%d ATTRIBUTE_UNUSED;\n", i);
21882 + printf(" va_list args;\n\n");
21883 + printf(" va_start(args, operand0);\n");
21884 + for (i = 1; i < operands; i++)
21885 + printf(" operand%d = va_arg(args, rtx);\n", i);
21886 + printf(" va_end(args);\n\n");
21891 print_code (RTX_CODE code)
21894 @@ -406,18 +424,16 @@ gen_insn (rtx insn, int lineno)
21895 fatal ("match_dup operand number has no match_operand");
21897 /* Output the function name and argument declarations. */
21898 - printf ("rtx\ngen_%s (", XSTR (insn, 0));
21899 + printf ("rtx\ngen_%s ", XSTR (insn, 0));
21902 - for (i = 0; i < operands; i++)
21904 - printf (",\n\trtx operand%d ATTRIBUTE_UNUSED", i);
21905 + printf("(rtx operand0 ATTRIBUTE_UNUSED, ...)\n");
21907 - printf ("rtx operand%d ATTRIBUTE_UNUSED", i);
21911 + printf("(void)\n");
21914 + gen_vararg_prologue(operands);
21916 /* Output code to construct and return the rtl for the instruction body. */
21918 if (XVECLEN (insn, 1) == 1)
21919 @@ -461,16 +477,12 @@ gen_expand (rtx expand)
21920 operands = max_operand_vec (expand, 1);
21922 /* Output the function name and argument declarations. */
21923 - printf ("rtx\ngen_%s (", XSTR (expand, 0));
21924 + printf ("rtx\ngen_%s ", XSTR (expand, 0));
21926 - for (i = 0; i < operands; i++)
21928 - printf (",\n\trtx operand%d", i);
21930 - printf ("rtx operand%d", i);
21931 + printf("(rtx operand0 ATTRIBUTE_UNUSED, ...)\n");
21935 + printf("(void)\n");
21939 /* If we don't have any C code to write, only one insn is being written,
21940 @@ -480,6 +492,8 @@ gen_expand (rtx expand)
21941 && operands > max_dup_opno
21942 && XVECLEN (expand, 1) == 1)
21944 + gen_vararg_prologue(operands);
21946 printf (" return ");
21947 gen_exp (XVECEXP (expand, 1, 0), DEFINE_EXPAND, NULL);
21948 printf (";\n}\n\n");
21949 @@ -493,6 +507,7 @@ gen_expand (rtx expand)
21950 for (; i <= max_scratch_opno; i++)
21951 printf (" rtx operand%d ATTRIBUTE_UNUSED;\n", i);
21952 printf (" rtx _val = 0;\n");
21953 + gen_vararg_prologue(operands);
21954 printf (" start_sequence ();\n");
21956 /* The fourth operand of DEFINE_EXPAND is some code to be executed
21957 --- a/gcc/genflags.c
21958 +++ b/gcc/genflags.c
21959 @@ -127,7 +127,6 @@ static void
21960 gen_proto (rtx insn)
21962 int num = num_operands (insn);
21964 const char *name = XSTR (insn, 0);
21965 int truth = maybe_eval_c_test (XSTR (insn, 2));
21967 @@ -158,12 +157,7 @@ gen_proto (rtx insn)
21969 fputs ("void", stdout);
21972 - for (i = 1; i < num; i++)
21973 - fputs ("rtx, ", stdout);
21975 - fputs ("rtx", stdout);
21977 + fputs("rtx, ...", stdout);
21981 @@ -173,12 +167,7 @@ gen_proto (rtx insn)
21983 printf ("static inline rtx\ngen_%s", name);
21987 - for (i = 0; i < num-1; i++)
21988 - printf ("rtx ARG_UNUSED (%c), ", 'a' + i);
21989 - printf ("rtx ARG_UNUSED (%c))\n", 'a' + i);
21991 + puts("(rtx ARG_UNUSED(a), ...)");
21994 puts ("{\n return 0;\n}");
21995 --- a/gcc/genoutput.c
21996 +++ b/gcc/genoutput.c
21997 @@ -386,7 +386,7 @@ output_insn_data (void)
22000 if (d->name && d->name[0] != '*')
22001 - printf (" (insn_gen_fn) gen_%s,\n", d->name);
22002 + printf (" gen_%s,\n", d->name);
22008 @@ -81,7 +81,7 @@ static int num_possible_if_blocks;
22009 static int num_updated_if_blocks;
22011 /* # of changes made. */
22012 -static int num_true_changes;
22013 +int num_true_changes;
22015 /* Whether conditional execution changes were made. */
22016 static int cond_exec_changed_p;
22017 @@ -286,6 +286,9 @@ cond_exec_process_insns (ce_if_block_t *
22021 +#ifdef IFCVT_ALLOW_MODIFY_TEST_IN_INSN
22022 + if ( !IFCVT_ALLOW_MODIFY_TEST_IN_INSN )
22024 if (modified_in_p (test, insn))
22027 @@ -566,15 +569,18 @@ cond_exec_process_if_block (ce_if_block_
22028 IFCVT_MODIFY_FINAL (ce_info);
22031 + /* Merge the blocks! */
22032 + if ( reload_completed ){
22033 /* Conversion succeeded. */
22035 fprintf (dump_file, "%d insn%s converted to conditional execution.\n",
22036 n_insns, (n_insns == 1) ? " was" : "s were");
22038 - /* Merge the blocks! */
22039 merge_if_block (ce_info);
22040 cond_exec_changed_p = TRUE;
22046 #ifdef IFCVT_MODIFY_CANCEL
22047 @@ -1080,7 +1086,11 @@ noce_try_addcc (struct noce_if_info *if_
22050 rtx cond = if_info->cond;
22051 - enum rtx_code code = reversed_comparison_code (cond, if_info->jump);
22052 + /* This generates wrong code for AVR32. The cond code need not be reversed
22053 + since the addmodecc patterns add if the condition is NOT met. */
22054 + /* enum rtx_code code = reversed_comparison_code (cond, if_info->jump);*/
22055 + enum rtx_code code = GET_CODE(cond);
22058 /* First try to use addcc pattern. */
22059 if (general_operand (XEXP (cond, 0), VOIDmode)
22060 @@ -3017,7 +3027,12 @@ find_if_header (basic_block test_bb, int
22061 && noce_find_if_block (test_bb, then_edge, else_edge, pass))
22064 - if (HAVE_conditional_execution && reload_completed
22065 + if (HAVE_conditional_execution &&
22066 +#ifdef IFCVT_COND_EXEC_BEFORE_RELOAD
22067 + (reload_completed || IFCVT_COND_EXEC_BEFORE_RELOAD)
22071 && cond_exec_find_if_block (&ce_info))
22074 @@ -3132,7 +3147,11 @@ cond_exec_find_if_block (struct ce_if_bl
22076 /* We only ever should get here after reload,
22077 and only if we have conditional execution. */
22078 +#ifdef IFCVT_COND_EXEC_BEFORE_RELOAD
22079 + gcc_assert (HAVE_conditional_execution && (reload_completed||IFCVT_COND_EXEC_BEFORE_RELOAD));
22081 gcc_assert (HAVE_conditional_execution && reload_completed);
22084 /* Discover if any fall through predecessors of the current test basic block
22085 were && tests (which jump to the else block) or || tests (which jump to
22086 @@ -4226,6 +4245,14 @@ gate_handle_if_after_reload (void)
22087 static unsigned int
22088 rest_of_handle_if_after_reload (void)
22090 + /* Hack for the AVR32 experimental ifcvt processing before reload.
22091 + The AVR32 specific ifcvt code needs to know when ifcvt after reload
22093 +#ifdef IFCVT_COND_EXEC_BEFORE_RELOAD
22094 + if ( IFCVT_COND_EXEC_BEFORE_RELOAD )
22095 + cfun->machine->ifcvt_after_reload = 1;
22101 --- a/gcc/longlong.h
22102 +++ b/gcc/longlong.h
22103 @@ -239,6 +239,41 @@ UDItype __umulsidi3 (USItype, USItype);
22104 #define UDIV_TIME 100
22105 #endif /* __arm__ */
22107 +#if defined (__avr32__) && W_TYPE_SIZE == 32
22108 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
22109 + __asm__ ("add\t%1, %4, %5\n\tadc\t%0, %2, %3" \
22110 + : "=r" ((USItype) (sh)), \
22111 + "=&r" ((USItype) (sl)) \
22112 + : "r" ((USItype) (ah)), \
22113 + "r" ((USItype) (bh)), \
22114 + "r" ((USItype) (al)), \
22115 + "r" ((USItype) (bl)) __CLOBBER_CC)
22116 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
22117 + __asm__ ("sub\t%1, %4, %5\n\tsbc\t%0, %2, %3" \
22118 + : "=r" ((USItype) (sh)), \
22119 + "=&r" ((USItype) (sl)) \
22120 + : "r" ((USItype) (ah)), \
22121 + "r" ((USItype) (bh)), \
22122 + "r" ((USItype) (al)), \
22123 + "r" ((USItype) (bl)) __CLOBBER_CC)
22125 +#if !defined (__AVR32_NO_MUL__)
22126 +#define __umulsidi3(a,b) ((UDItype)(a) * (UDItype)(b))
22128 +#define umul_ppmm(w1, w0, u, v) \
22131 + __w.ll = __umulsidi3 (u, v); \
22132 + w1 = __w.s.high; \
22133 + w0 = __w.s.low; \
22137 +#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X))
22138 +#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctz (X))
22139 +#define COUNT_LEADING_ZEROS_0 32
22142 #if defined (__CRIS__) && __CRIS_arch_version >= 3
22143 #define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X))
22144 #if __CRIS_arch_version >= 8
22147 @@ -586,7 +586,7 @@ extern enum insn_code reload_out_optab[N
22148 extern optab code_to_optab[NUM_RTX_CODE + 1];
22151 -typedef rtx (*rtxfun) (rtx);
22152 +typedef rtx (*rtxfun) (rtx, ...);
22154 /* Indexed by the rtx-code for a conditional (e.g. EQ, LT,...)
22155 gives the gen_function to make a branch to test that condition. */
22156 --- a/gcc/regrename.c
22157 +++ b/gcc/regrename.c
22158 @@ -1580,6 +1580,9 @@ copyprop_hardreg_forward_1 (basic_block
22159 bool changed = false;
22162 + rtx prev_pred_test;
22163 + int prev_pred_insn_skipped = 0;
22165 for (insn = BB_HEAD (bb); ; insn = NEXT_INSN (insn))
22167 int n_ops, i, alt, predicated;
22168 @@ -1619,6 +1622,58 @@ copyprop_hardreg_forward_1 (basic_block
22169 recog_data.operand_type[i] = OP_INOUT;
22173 + /* Added for targets (AVR32) which supports test operands to be modified
22174 + in cond_exec instruction. For these targets we cannot make a change to
22175 + the test operands if one of the test operands is an output operand This beacuse
22176 + changing the test operands might cause the need for inserting a new test
22177 + insns in the middle of a sequence of cond_exec insns and if the test operands
22178 + are modified these tests will fail.
22180 + if ( IFCVT_ALLOW_MODIFY_TEST_IN_INSN
22183 + int insn_skipped = 0;
22184 + rtx test = COND_EXEC_TEST (PATTERN (insn));
22186 + /* Check if the previous insn was a skipped predicated insn with the same
22187 + test as this predicated insns. If so we cannot do any modification to
22188 + this insn either since we cannot emit the test insn because the operands
22189 + are clobbered. */
22190 + if ( prev_pred_insn_skipped
22191 + && (rtx_equal_p (test, prev_pred_test)
22192 + || rtx_equal_p (test, reversed_condition (prev_pred_test))) )
22194 + insn_skipped = 1;
22198 + /* Check if the output operand is used in the test expression. */
22199 + for (i = 0; i < n_ops; ++i)
22200 + if ( recog_data.operand_type[i] == OP_INOUT
22201 + && reg_mentioned_p (recog_data.operand[i], test) )
22203 + insn_skipped = 1;
22209 + prev_pred_test = test;
22210 + prev_pred_insn_skipped = insn_skipped;
22211 + if ( insn_skipped )
22213 + if (insn == BB_END (bb))
22221 + prev_pred_insn_skipped = 0;
22224 /* For each earlyclobber operand, zap the value data. */
22225 for (i = 0; i < n_ops; i++)
22226 if (recog_op_alt[i][alt].earlyclobber)
22227 --- a/gcc/sched-deps.c
22228 +++ b/gcc/sched-deps.c
22229 @@ -1406,7 +1406,14 @@ fixup_sched_groups (rtx insn)
22231 prev_nonnote = prev_nonnote_insn (insn);
22232 if (BLOCK_FOR_INSN (insn) == BLOCK_FOR_INSN (prev_nonnote)
22233 - && ! sched_insns_conditions_mutex_p (insn, prev_nonnote))
22234 + /* Modification for AVR32 by RP: Why is this here, this will
22235 + cause instruction to be without any dependencies which might
22236 + cause it to be moved anywhere. For the AVR32 we try to keep
22237 + a group of conditionals together even if they are mutual exclusive.
22239 + && (! sched_insns_conditions_mutex_p (insn, prev_nonnote)
22240 + || GET_CODE (PATTERN (insn)) == COND_EXEC )
22242 add_dependence (insn, prev_nonnote, REG_DEP_ANTI);
22245 @@ -1905,8 +1912,29 @@ sched_analyze_insn (struct deps *deps, r
22247 if (code == COND_EXEC)
22249 +#ifdef IFCVT_ALLOW_MODIFY_TEST_IN_INSN
22250 + if (IFCVT_ALLOW_MODIFY_TEST_IN_INSN)
22252 + /* Check if we have a group og conditional instructions with the same test.
22253 + If so we must make sure that they are not scheduled apart in order to
22254 + avoid unnecesarry tests and if one of the registers in the test is modified
22255 + in the instruction this is needed to ensure correct code. */
22256 + if ( prev_nonnote_insn (insn)
22257 + && INSN_P (prev_nonnote_insn (insn))
22258 + && GET_CODE (PATTERN (prev_nonnote_insn (insn))) == COND_EXEC
22259 + && rtx_equal_p (XEXP(COND_EXEC_TEST (PATTERN (prev_nonnote_insn (insn))), 0), XEXP (COND_EXEC_TEST (x), 0))
22260 + && rtx_equal_p (XEXP(COND_EXEC_TEST (PATTERN (prev_nonnote_insn (insn))), 1), XEXP (COND_EXEC_TEST (x), 1))
22261 + && ( GET_CODE (COND_EXEC_TEST (PATTERN (prev_nonnote_insn (insn)))) == GET_CODE (COND_EXEC_TEST (x))
22262 + || GET_CODE (COND_EXEC_TEST (PATTERN (prev_nonnote_insn (insn)))) == reversed_comparison_code (COND_EXEC_TEST (x), insn)))
22264 + SCHED_GROUP_P (insn) = 1;
22265 + //CANT_MOVE (prev_nonnote_insn (insn)) = 1;
22269 sched_analyze_2 (deps, COND_EXEC_TEST (x), insn);
22272 /* ??? Should be recording conditions so we reduce the number of
22273 false dependencies. */
22274 x = COND_EXEC_CODE (x);
22275 --- a/gcc/testsuite/gcc.dg/sibcall-3.c
22276 +++ b/gcc/testsuite/gcc.dg/sibcall-3.c
22278 Copyright (C) 2002 Free Software Foundation Inc.
22279 Contributed by Hans-Peter Nilsson <hp@bitrange.com> */
22281 -/* { dg-do run { xfail arc-*-* avr-*-* cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* m32r-*-* m68hc1?-*-* mcore-*-* mn10300-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa-*-* } } */
22282 +/* { dg-do run { xfail arc-*-* avr-*-* avr32-*-* cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* m32r-*-* m68hc1?-*-* mcore-*-* mn10300-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa-*-* } } */
22283 /* -mlongcall disables sibcall patterns. */
22284 /* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */
22285 /* { dg-options "-O2 -foptimize-sibling-calls" } */
22286 --- a/gcc/testsuite/gcc.dg/sibcall-4.c
22287 +++ b/gcc/testsuite/gcc.dg/sibcall-4.c
22289 Copyright (C) 2002 Free Software Foundation Inc.
22290 Contributed by Hans-Peter Nilsson <hp@bitrange.com> */
22292 -/* { dg-do run { xfail arc-*-* avr-*-* cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* m32r-*-* m68hc1?-*-* mcore-*-* mn10300-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa-*-* } } */
22293 +/* { dg-do run { xfail arc-*-* avr-*-* avr32-*-* cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* m32r-*-* m68hc1?-*-* mcore-*-* mn10300-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa-*-* } } */
22294 /* -mlongcall disables sibcall patterns. */
22295 /* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */
22296 /* { dg-options "-O2 -foptimize-sibling-calls" } */
22297 --- a/gcc/testsuite/gcc.dg/trampoline-1.c
22298 +++ b/gcc/testsuite/gcc.dg/trampoline-1.c
22299 @@ -46,6 +46,8 @@ void foo (void)
22303 +#ifndef NO_TRAMPOLINES
22308 --- a/gcc/testsuite/g++.old-deja/g++.pt/static11.C
22309 +++ b/gcc/testsuite/g++.old-deja/g++.pt/static11.C
22311 // in their dejagnu baseboard description) require that the status is
22312 // final when exit is entered (or main returns), and not "overruled" by a
22313 // destructor calling _exit. It's not really worth it to handle that.
22314 -// { dg-do run { xfail mmix-knuth-mmixware arm*-*-elf arm*-*-eabi m68k-*-elf } }
22315 +// { dg-do run { xfail mmix-knuth-mmixware avr32-*-elf arm*-*-elf arm*-*-eabi m68k-*-elf } }
22317 // Bug: g++ was failing to destroy C<int>::a because it was using two
22318 // different sentry variables for construction and destruction.
22319 --- a/libgcc/config.host
22320 +++ b/libgcc/config.host
22321 @@ -240,6 +240,13 @@ arm-*-pe*)
22326 + # No need to build crtbeginT.o on uClibc systems. Should probably be
22327 + # moved to the OS specific section above.
22328 + extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
22335 --- a/libstdc++-v3/config/os/gnu-linux/ctype_base.h
22336 +++ b/libstdc++-v3/config/os/gnu-linux/ctype_base.h
22339 // ISO C++ 14882: 22.1 Locales
22341 +#include <features.h>
22342 +#include <ctype.h>
22344 /** @file ctype_base.h
22345 * This is an internal header file, included by other library headers.
22346 @@ -45,7 +47,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
22349 // Non-standard typedefs.
22351 + typedef const __ctype_touplow_t* __to_type;
22353 typedef const int* __to_type;
22356 // NB: Offsets into ctype<char>::_M_table force a particular size
22357 // on the mask type. Because of this, we don't use an enum.
22358 --- a/libstdc++-v3/include/Makefile.in
22359 +++ b/libstdc++-v3/include/Makefile.in
22360 @@ -36,6 +36,7 @@ POST_UNINSTALL = :
22361 build_triplet = @build@
22362 host_triplet = @host@
22363 target_triplet = @target@
22365 DIST_COMMON = $(top_srcdir)/fragment.am $(srcdir)/Makefile.in \
22366 $(srcdir)/Makefile.am
22368 --- a/libstdc++-v3/libmath/Makefile.in
22369 +++ b/libstdc++-v3/libmath/Makefile.in
22370 @@ -37,6 +37,7 @@ POST_UNINSTALL = :
22371 build_triplet = @build@
22372 host_triplet = @host@
22373 target_triplet = @target@
22376 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
22377 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
22378 --- a/libstdc++-v3/libsupc++/Makefile.in
22379 +++ b/libstdc++-v3/libsupc++/Makefile.in
22380 @@ -38,6 +38,7 @@ POST_UNINSTALL = :
22381 build_triplet = @build@
22382 host_triplet = @host@
22383 target_triplet = @target@
22385 DIST_COMMON = $(top_srcdir)/fragment.am $(srcdir)/Makefile.in \
22386 $(srcdir)/Makefile.am $(glibcxxinstall_HEADERS)
22388 --- a/libstdc++-v3/Makefile.in
22389 +++ b/libstdc++-v3/Makefile.in
22390 @@ -36,6 +36,7 @@ POST_UNINSTALL = :
22391 build_triplet = @build@
22392 host_triplet = @host@
22393 target_triplet = @target@
22395 DIST_COMMON = $(top_srcdir)/fragment.am $(srcdir)/../config.guess \
22396 $(srcdir)/../config.sub README ChangeLog $(srcdir)/Makefile.in \
22397 $(srcdir)/Makefile.am $(top_srcdir)/configure \
22398 --- a/libstdc++-v3/po/Makefile.in
22399 +++ b/libstdc++-v3/po/Makefile.in
22400 @@ -36,6 +36,7 @@ POST_UNINSTALL = :
22401 build_triplet = @build@
22402 host_triplet = @host@
22403 target_triplet = @target@
22405 DIST_COMMON = $(top_srcdir)/fragment.am $(srcdir)/Makefile.in \
22406 $(srcdir)/Makefile.am
22408 --- a/libstdc++-v3/src/Makefile.in
22409 +++ b/libstdc++-v3/src/Makefile.in
22410 @@ -37,6 +37,7 @@ POST_UNINSTALL = :
22411 build_triplet = @build@
22412 host_triplet = @host@
22413 target_triplet = @target@
22415 DIST_COMMON = $(top_srcdir)/fragment.am $(srcdir)/Makefile.in \
22416 $(srcdir)/Makefile.am