gcc 4.2.4 support
[openwrt/openwrt.git] / toolchain / gcc / patches / 4.2.4 / 900-avr32_support.patch
1 Index: gcc-4.2.3/configure.in
2 ===================================================================
3 --- gcc-4.2.3.orig/configure.in 2007-09-15 02:42:24.000000000 +0200
4 +++ gcc-4.2.3/configure.in 2008-05-21 13:45:54.101287819 +0200
5 @@ -503,6 +503,9 @@
6 arm-*-riscix*)
7 noconfigdirs="$noconfigdirs ld target-libgloss ${libgcj}"
8 ;;
9 + avr32-*-*)
10 + noconfigdirs="$noconfigdirs target-libiberty target-libmudflap target-libffi ${libgcj}"
11 + ;;
12 avr-*-*)
13 noconfigdirs="$noconfigdirs target-libiberty target-libstdc++-v3 ${libgcj}"
14 ;;
15 Index: gcc-4.2.3/gcc/builtins.c
16 ===================================================================
17 --- gcc-4.2.3.orig/gcc/builtins.c 2008-01-23 11:38:21.000000000 +0100
18 +++ gcc-4.2.3/gcc/builtins.c 2008-05-21 13:45:54.109288559 +0200
19 @@ -9223,7 +9223,7 @@
20
21 do
22 {
23 - code = va_arg (ap, enum tree_code);
24 + code = va_arg (ap, int);
25 switch (code)
26 {
27 case 0:
28 Index: gcc-4.2.3/gcc/calls.c
29 ===================================================================
30 --- gcc-4.2.3.orig/gcc/calls.c 2007-09-01 17:28:30.000000000 +0200
31 +++ gcc-4.2.3/gcc/calls.c 2008-05-21 13:45:54.117288181 +0200
32 @@ -3447,7 +3447,7 @@
33 for (; count < nargs; count++)
34 {
35 rtx val = va_arg (p, rtx);
36 - enum machine_mode mode = va_arg (p, enum machine_mode);
37 + enum machine_mode mode = va_arg (p, int);
38
39 /* We cannot convert the arg value to the mode the library wants here;
40 must do it earlier where we know the signedness of the arg. */
41 Index: gcc-4.2.3/gcc/config/avr32/avr32.c
42 ===================================================================
43 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
44 +++ gcc-4.2.3/gcc/config/avr32/avr32.c 2008-05-21 13:45:54.145288116 +0200
45 @@ -0,0 +1,7060 @@
46 +/*
47 + Target hooks and helper functions for AVR32.
48 + Copyright 2003-2006 Atmel Corporation.
49 +
50 + Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
51 + Initial porting by Anders �dland.
52 +
53 + This file is part of GCC.
54 +
55 + This program is free software; you can redistribute it and/or modify
56 + it under the terms of the GNU General Public License as published by
57 + the Free Software Foundation; either version 2 of the License, or
58 + (at your option) any later version.
59 +
60 + This program is distributed in the hope that it will be useful,
61 + but WITHOUT ANY WARRANTY; without even the implied warranty of
62 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63 + GNU General Public License for more details.
64 +
65 + You should have received a copy of the GNU General Public License
66 + along with this program; if not, write to the Free Software
67 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
68 +
69 +#include "config.h"
70 +#include "system.h"
71 +#include "coretypes.h"
72 +#include "tm.h"
73 +#include "rtl.h"
74 +#include "tree.h"
75 +#include "obstack.h"
76 +#include "regs.h"
77 +#include "hard-reg-set.h"
78 +#include "real.h"
79 +#include "insn-config.h"
80 +#include "conditions.h"
81 +#include "output.h"
82 +#include "insn-attr.h"
83 +#include "flags.h"
84 +#include "reload.h"
85 +#include "function.h"
86 +#include "expr.h"
87 +#include "optabs.h"
88 +#include "toplev.h"
89 +#include "recog.h"
90 +#include "ggc.h"
91 +#include "except.h"
92 +#include "c-pragma.h"
93 +#include "integrate.h"
94 +#include "tm_p.h"
95 +#include "langhooks.h"
96 +
97 +#include "target.h"
98 +#include "target-def.h"
99 +
100 +#include <ctype.h>
101 +
102 +/* Forward definitions of types. */
103 +typedef struct minipool_node Mnode;
104 +typedef struct minipool_fixup Mfix;
105 +
106 +/* Obstack for minipool constant handling. */
107 +static struct obstack minipool_obstack;
108 +static char *minipool_startobj;
109 +static rtx minipool_vector_label;
110 +
111 +/* True if we are currently building a constant table. */
112 +int making_const_table;
113 +
114 +/* Some forward function declarations */
115 +static unsigned long avr32_isr_value (tree);
116 +static unsigned long avr32_compute_func_type (void);
117 +static tree avr32_handle_isr_attribute (tree *, tree, tree, int, bool *);
118 +static tree avr32_handle_acall_attribute (tree *, tree, tree, int, bool *);
119 +static tree avr32_handle_fndecl_attribute (tree * node, tree name, tree args,
120 + int flags, bool * no_add_attrs);
121 +static void avr32_reorg (void);
122 +bool avr32_return_in_msb (tree type);
123 +bool avr32_vector_mode_supported (enum machine_mode mode);
124 +static void avr32_init_libfuncs (void);
125 +
126 +
127 +static void
128 +avr32_add_gc_roots (void)
129 + {
130 + gcc_obstack_init (&minipool_obstack);
131 + minipool_startobj = (char *) obstack_alloc (&minipool_obstack, 0);
132 + }
133 +
134 +
135 +/* List of all known AVR32 parts */
136 +static const struct part_type_s avr32_part_types[] = {
137 + /* name, part_type, architecture type, macro */
138 + {"none", PART_TYPE_AVR32_NONE, ARCH_TYPE_AVR32_AP, "__AVR32__"},
139 + {"ap7000", PART_TYPE_AVR32_AP7000, ARCH_TYPE_AVR32_AP, "__AVR32_AP7000__"},
140 + {"ap7010", PART_TYPE_AVR32_AP7010, ARCH_TYPE_AVR32_AP, "__AVR32_AP7010__"},
141 + {"ap7020", PART_TYPE_AVR32_AP7020, ARCH_TYPE_AVR32_AP, "__AVR32_AP7020__"},
142 + {"uc3a0256", PART_TYPE_AVR32_UC3A0256, ARCH_TYPE_AVR32_UC,
143 + "__AVR32_UC3A0256__"},
144 + {"uc3a0512", PART_TYPE_AVR32_UC3A0512, ARCH_TYPE_AVR32_UC,
145 + "__AVR32_UC3A0512__"},
146 + {"uc3a1128", PART_TYPE_AVR32_UC3A1128, ARCH_TYPE_AVR32_UC,
147 + "__AVR32_UC3A1128__"},
148 + {"uc3a1256", PART_TYPE_AVR32_UC3A1256, ARCH_TYPE_AVR32_UC,
149 + "__AVR32_UC3A1256__"},
150 + {"uc3a1512", PART_TYPE_AVR32_UC3A1512, ARCH_TYPE_AVR32_UC,
151 + "__AVR32_UC3A1512__"},
152 + {"uc3b064", PART_TYPE_AVR32_UC3B064, ARCH_TYPE_AVR32_UC,
153 + "__AVR32_UC3B064__"},
154 + {"uc3b0128", PART_TYPE_AVR32_UC3B0128, ARCH_TYPE_AVR32_UC,
155 + "__AVR32_UC3B0128__"},
156 + {"uc3b0256", PART_TYPE_AVR32_UC3B0256, ARCH_TYPE_AVR32_UC,
157 + "__AVR32_UC3B0256__"},
158 + {"uc3b164", PART_TYPE_AVR32_UC3B164, ARCH_TYPE_AVR32_UC,
159 + "__AVR32_UC3B164__"},
160 + {"uc3b1128", PART_TYPE_AVR32_UC3B1128, ARCH_TYPE_AVR32_UC,
161 + "__AVR32_UC3B1128__"},
162 + {"uc3b1256", PART_TYPE_AVR32_UC3B1256, ARCH_TYPE_AVR32_UC,
163 + "__AVR32_UC3B1256__"},
164 + {NULL, 0, 0, NULL}
165 +};
166 +
167 +/* List of all known AVR32 architectures */
168 +static const struct arch_type_s avr32_arch_types[] = {
169 + /* name, architecture type, microarchitecture type, feature flags, macro */
170 + {"ap", ARCH_TYPE_AVR32_AP, UARCH_TYPE_AVR32B,
171 + (FLAG_AVR32_HAS_DSP
172 + | FLAG_AVR32_HAS_SIMD
173 + | FLAG_AVR32_HAS_UNALIGNED_WORD
174 + | FLAG_AVR32_HAS_CACHES
175 + | FLAG_AVR32_HAS_BRANCH_PRED
176 + | FLAG_AVR32_HAS_RETURN_STACK),
177 + "__AVR32_AP__"},
178 + {"uc", ARCH_TYPE_AVR32_UC, UARCH_TYPE_AVR32A,
179 + (FLAG_AVR32_HAS_DSP | FLAG_AVR32_HAS_RMW),
180 + "__AVR32_UC__"},
181 + {NULL, 0, 0, 0, NULL}
182 +};
183 +
184 +/* Default arch name */
185 +const char *avr32_arch_name = "ap";
186 +const char *avr32_part_name = "none";
187 +
188 +const struct part_type_s *avr32_part;
189 +const struct arch_type_s *avr32_arch;
190 +
191 +/* Set default target_flags. */
192 +#undef TARGET_DEFAULT_TARGET_FLAGS
193 +#define TARGET_DEFAULT_TARGET_FLAGS \
194 + (MASK_HAS_ASM_ADDR_PSEUDOS | MASK_MD_REORG_OPTIMIZATION)
195 +
196 +void
197 +avr32_optimization_options (int level,
198 + int size){
199 + if (AVR32_ALWAYS_PIC)
200 + flag_pic = 1;
201 +
202 + /* Enable section anchors if optimization is enabled. */
203 + if (level > 0 || size)
204 + flag_section_anchors = 1;
205 +}
206 +
207 +/* Override command line options */
208 +void
209 +avr32_override_options (void)
210 + {
211 + const struct part_type_s *part;
212 + const struct arch_type_s *arch;
213 +
214 + /* Check if part type is set. */
215 + for (part = avr32_part_types; part->name; part++)
216 + if (strcmp (part->name, avr32_part_name) == 0)
217 + break;
218 +
219 + avr32_part = part;
220 +
221 + if (!part->name)
222 + {
223 + fprintf (stderr, "Unknown part `%s' specified\nKnown part names:\n",
224 + avr32_part_name);
225 + for (part = avr32_part_types; part->name; part++)
226 + fprintf (stderr, "\t%s\n", part->name);
227 + avr32_part = &avr32_part_types[PART_TYPE_AVR32_NONE];
228 + }
229 +
230 + avr32_arch = &avr32_arch_types[avr32_part->arch_type];
231 +
232 + /* If part was set to "none" then check if arch was set. */
233 + if (strcmp (avr32_part->name, "none") == 0)
234 + {
235 + /* Check if arch type is set. */
236 + for (arch = avr32_arch_types; arch->name; arch++)
237 + if (strcmp (arch->name, avr32_arch_name) == 0)
238 + break;
239 +
240 + avr32_arch = arch;
241 +
242 + if (!arch->name)
243 + {
244 + fprintf (stderr, "Unknown arch `%s' specified\nKnown arch names:\n",
245 + avr32_arch_name);
246 + for (arch = avr32_arch_types; arch->name; arch++)
247 + fprintf (stderr, "\t%s\n", arch->name);
248 + avr32_arch = &avr32_arch_types[ARCH_TYPE_AVR32_AP];
249 + }
250 + }
251 +
252 + /* If optimization level is two or greater, then align start of loops to a
253 + word boundary since this will allow folding the first insn of the loop.
254 + Do this only for targets supporting branch prediction. */
255 + if (optimize >= 2 && TARGET_BRANCH_PRED)
256 + align_loops = 2;
257 +
258 +
259 + /* Enable section anchors if optimization is enabled. */
260 + if (optimize > 0 || optimize_size)
261 + flag_section_anchors = 1;
262 +
263 + /* Enable fast-float library if unsafe math optimizations
264 + are used. */
265 + if (flag_unsafe_math_optimizations)
266 + target_flags |= MASK_FAST_FLOAT;
267 +
268 + /* Check if we should set avr32_imm_in_const_pool
269 + based on if caches are present or not. */
270 + if ( avr32_imm_in_const_pool == -1 )
271 + {
272 + if ( TARGET_CACHES )
273 + avr32_imm_in_const_pool = 1;
274 + else
275 + avr32_imm_in_const_pool = 0;
276 + }
277 +
278 + avr32_add_gc_roots ();
279 + }
280 +
281 +
282 +/*
283 +If defined, a function that outputs the assembler code for entry to a
284 +function. The prologue is responsible for setting up the stack frame,
285 +initializing the frame pointer register, saving registers that must be
286 +saved, and allocating size additional bytes of storage for the
287 +local variables. size is an integer. file is a stdio
288 +stream to which the assembler code should be output.
289 +
290 +The label for the beginning of the function need not be output by this
291 +macro. That has already been done when the macro is run.
292 +
293 +To determine which registers to save, the macro can refer to the array
294 +regs_ever_live: element r is nonzero if hard register
295 +r is used anywhere within the function. This implies the function
296 +prologue should save register r, provided it is not one of the
297 +call-used registers. (TARGET_ASM_FUNCTION_EPILOGUE must likewise use
298 +regs_ever_live.)
299 +
300 +On machines that have ``register windows'', the function entry code does
301 +not save on the stack the registers that are in the windows, even if
302 +they are supposed to be preserved by function calls; instead it takes
303 +appropriate steps to ``push'' the register stack, if any non-call-used
304 +registers are used in the function.
305 +
306 +On machines where functions may or may not have frame-pointers, the
307 +function entry code must vary accordingly; it must set up the frame
308 +pointer if one is wanted, and not otherwise. To determine whether a
309 +frame pointer is in wanted, the macro can refer to the variable
310 +frame_pointer_needed. The variable's value will be 1 at run
311 +time in a function that needs a frame pointer. (see Elimination).
312 +
313 +The function entry code is responsible for allocating any stack space
314 +required for the function. This stack space consists of the regions
315 +listed below. In most cases, these regions are allocated in the
316 +order listed, with the last listed region closest to the top of the
317 +stack (the lowest address if STACK_GROWS_DOWNWARD is defined, and
318 +the highest address if it is not defined). You can use a different order
319 +for a machine if doing so is more convenient or required for
320 +compatibility reasons. Except in cases where required by standard
321 +or by a debugger, there is no reason why the stack layout used by GCC
322 +need agree with that used by other compilers for a machine.
323 + */
324 +
325 +#undef TARGET_ASM_FUNCTION_PROLOGUE
326 +#define TARGET_ASM_FUNCTION_PROLOGUE avr32_target_asm_function_prologue
327 +
328 +
329 +#undef TARGET_DEFAULT_SHORT_ENUMS
330 +#define TARGET_DEFAULT_SHORT_ENUMS hook_bool_void_false
331 +
332 +#undef TARGET_PROMOTE_FUNCTION_ARGS
333 +#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true
334 +
335 +#undef TARGET_PROMOTE_FUNCTION_RETURN
336 +#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
337 +
338 +#undef TARGET_PROMOTE_PROTOTYPES
339 +#define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true
340 +
341 +#undef TARGET_MUST_PASS_IN_STACK
342 +#define TARGET_MUST_PASS_IN_STACK avr32_must_pass_in_stack
343 +
344 +#undef TARGET_PASS_BY_REFERENCE
345 +#define TARGET_PASS_BY_REFERENCE avr32_pass_by_reference
346 +
347 +#undef TARGET_STRICT_ARGUMENT_NAMING
348 +#define TARGET_STRICT_ARGUMENT_NAMING avr32_strict_argument_naming
349 +
350 +#undef TARGET_VECTOR_MODE_SUPPORTED_P
351 +#define TARGET_VECTOR_MODE_SUPPORTED_P avr32_vector_mode_supported
352 +
353 +#undef TARGET_RETURN_IN_MEMORY
354 +#define TARGET_RETURN_IN_MEMORY avr32_return_in_memory
355 +
356 +#undef TARGET_RETURN_IN_MSB
357 +#define TARGET_RETURN_IN_MSB avr32_return_in_msb
358 +
359 +#undef TARGET_ARG_PARTIAL_BYTES
360 +#define TARGET_ARG_PARTIAL_BYTES avr32_arg_partial_bytes
361 +
362 +#undef TARGET_STRIP_NAME_ENCODING
363 +#define TARGET_STRIP_NAME_ENCODING avr32_strip_name_encoding
364 +
365 +#define streq(string1, string2) (strcmp (string1, string2) == 0)
366 +
367 +#undef TARGET_NARROW_VOLATILE_BITFIELD
368 +#define TARGET_NARROW_VOLATILE_BITFIELD hook_bool_void_false
369 +
370 +#undef TARGET_ATTRIBUTE_TABLE
371 +#define TARGET_ATTRIBUTE_TABLE avr32_attribute_table
372 +
373 +#undef TARGET_COMP_TYPE_ATTRIBUTES
374 +#define TARGET_COMP_TYPE_ATTRIBUTES avr32_comp_type_attributes
375 +
376 +
377 +#undef TARGET_RTX_COSTS
378 +#define TARGET_RTX_COSTS avr32_rtx_costs
379 +
380 +#undef TARGET_CANNOT_FORCE_CONST_MEM
381 +#define TARGET_CANNOT_FORCE_CONST_MEM avr32_cannot_force_const_mem
382 +
383 +#undef TARGET_ASM_INTEGER
384 +#define TARGET_ASM_INTEGER avr32_assemble_integer
385 +
386 +#undef TARGET_FUNCTION_VALUE
387 +#define TARGET_FUNCTION_VALUE avr32_function_value
388 +
389 +#undef TARGET_MIN_ANCHOR_OFFSET
390 +#define TARGET_MIN_ANCHOR_OFFSET (0)
391 +
392 +#undef TARGET_MAX_ANCHOR_OFFSET
393 +#define TARGET_MAX_ANCHOR_OFFSET ((1 << 15) - 1)
394 +
395 +
396 +/*
397 + * Switches to the appropriate section for output of constant pool
398 + * entry x in mode. You can assume that x is some kind of constant in
399 + * RTL. The argument mode is redundant except in the case of a
400 + * const_int rtx. Select the section by calling readonly_data_ section
401 + * or one of the alternatives for other sections. align is the
402 + * constant alignment in bits.
403 + *
404 + * The default version of this function takes care of putting symbolic
405 + * constants in flag_ pic mode in data_section and everything else in
406 + * readonly_data_section.
407 + */
408 +//#undef TARGET_ASM_SELECT_RTX_SECTION
409 +//#define TARGET_ASM_SELECT_RTX_SECTION avr32_select_rtx_section
410 +
411 +
412 +/*
413 + * If non-null, this hook performs a target-specific pass over the
414 + * instruction stream. The compiler will run it at all optimization
415 + * levels, just before the point at which it normally does
416 + * delayed-branch scheduling.
417 + *
418 + * The exact purpose of the hook varies from target to target. Some
419 + * use it to do transformations that are necessary for correctness,
420 + * such as laying out in-function constant pools or avoiding hardware
421 + * hazards. Others use it as an opportunity to do some
422 + * machine-dependent optimizations.
423 + *
424 + * You need not implement the hook if it has nothing to do. The
425 + * default definition is null.
426 + */
427 +#undef TARGET_MACHINE_DEPENDENT_REORG
428 +#define TARGET_MACHINE_DEPENDENT_REORG avr32_reorg
429 +
430 +/* Target hook for assembling integer objects.
431 + Need to handle integer vectors */
432 +static bool
433 +avr32_assemble_integer (rtx x, unsigned int size, int aligned_p)
434 + {
435 + if (avr32_vector_mode_supported (GET_MODE (x)))
436 + {
437 + int i, units;
438 +
439 + if (GET_CODE (x) != CONST_VECTOR)
440 + abort ();
441 +
442 + units = CONST_VECTOR_NUNITS (x);
443 +
444 + switch (GET_MODE (x))
445 + {
446 + case V2HImode:
447 + size = 2;
448 + break;
449 + case V4QImode:
450 + size = 1;
451 + break;
452 + default:
453 + abort ();
454 + }
455 +
456 + for (i = 0; i < units; i++)
457 + {
458 + rtx elt;
459 +
460 + elt = CONST_VECTOR_ELT (x, i);
461 + assemble_integer (elt, size, i == 0 ? 32 : size * BITS_PER_UNIT, 1);
462 + }
463 +
464 + return true;
465 + }
466 +
467 + return default_assemble_integer (x, size, aligned_p);
468 + }
469 +
470 +/*
471 + * This target hook describes the relative costs of RTL expressions.
472 + *
473 + * The cost may depend on the precise form of the expression, which is
474 + * available for examination in x, and the rtx code of the expression
475 + * in which it is contained, found in outer_code. code is the
476 + * expression code--redundant, since it can be obtained with GET_CODE
477 + * (x).
478 + *
479 + * In implementing this hook, you can use the construct COSTS_N_INSNS
480 + * (n) to specify a cost equal to n fast instructions.
481 + *
482 + * On entry to the hook, *total contains a default estimate for the
483 + * cost of the expression. The hook should modify this value as
484 + * necessary. Traditionally, the default costs are COSTS_N_INSNS (5)
485 + * for multiplications, COSTS_N_INSNS (7) for division and modulus
486 + * operations, and COSTS_N_INSNS (1) for all other operations.
487 + *
488 + * When optimizing for code size, i.e. when optimize_size is non-zero,
489 + * this target hook should be used to estimate the relative size cost
490 + * of an expression, again relative to COSTS_N_INSNS.
491 + *
492 + * The hook returns true when all subexpressions of x have been
493 + * processed, and false when rtx_cost should recurse.
494 + */
495 +
496 +/* Worker routine for avr32_rtx_costs. */
497 +static inline int
498 +avr32_rtx_costs_1 (rtx x, enum rtx_code code ATTRIBUTE_UNUSED,
499 + enum rtx_code outer ATTRIBUTE_UNUSED)
500 + {
501 + enum machine_mode mode = GET_MODE (x);
502 +
503 + switch (GET_CODE (x))
504 + {
505 + case MEM:
506 + /* Using pre decrement / post increment memory operations on the
507 + avr32_uc architecture means that two writebacks must be performed
508 + and hence two cycles are needed. */
509 + if (!optimize_size
510 + && GET_MODE_SIZE (mode) <= 2 * UNITS_PER_WORD
511 + && avr32_arch->arch_type == ARCH_TYPE_AVR32_UC
512 + && (GET_CODE (XEXP (x, 0)) == PRE_DEC
513 + || GET_CODE (XEXP (x, 0)) == POST_INC))
514 + return COSTS_N_INSNS (5);
515 +
516 + /* Memory costs quite a lot for the first word, but subsequent words
517 + load at the equivalent of a single insn each. */
518 + if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
519 + return COSTS_N_INSNS (3 + (GET_MODE_SIZE (mode) / UNITS_PER_WORD));
520 +
521 + return COSTS_N_INSNS (4);
522 + case SYMBOL_REF:
523 + case CONST:
524 + /* These are valid for the pseudo insns: lda.w and call which operates
525 + on direct addresses. We assume that the cost of a lda.w is the same
526 + as the cost of a ld.w insn. */
527 + return (outer == SET) ? COSTS_N_INSNS (4) : COSTS_N_INSNS (1);
528 + case DIV:
529 + case MOD:
530 + case UDIV:
531 + case UMOD:
532 + return optimize_size ? COSTS_N_INSNS (1) : COSTS_N_INSNS (16);
533 +
534 + case ROTATE:
535 + case ROTATERT:
536 + if (mode == TImode)
537 + return COSTS_N_INSNS (100);
538 +
539 + if (mode == DImode)
540 + return COSTS_N_INSNS (10);
541 + return COSTS_N_INSNS (4);
542 + case ASHIFT:
543 + case LSHIFTRT:
544 + case ASHIFTRT:
545 + case NOT:
546 + if (mode == TImode)
547 + return COSTS_N_INSNS (10);
548 +
549 + if (mode == DImode)
550 + return COSTS_N_INSNS (4);
551 + return COSTS_N_INSNS (1);
552 + case PLUS:
553 + case MINUS:
554 + case NEG:
555 + case COMPARE:
556 + case ABS:
557 + if (GET_MODE_CLASS (mode) == MODE_FLOAT)
558 + return COSTS_N_INSNS (100);
559 +
560 + if (mode == TImode)
561 + return COSTS_N_INSNS (50);
562 +
563 + if (mode == DImode)
564 + return COSTS_N_INSNS (2);
565 + return COSTS_N_INSNS (1);
566 +
567 + case MULT:
568 + {
569 + if (GET_MODE_CLASS (mode) == MODE_FLOAT)
570 + return COSTS_N_INSNS (300);
571 +
572 + if (mode == TImode)
573 + return COSTS_N_INSNS (16);
574 +
575 + if (mode == DImode)
576 + return COSTS_N_INSNS (4);
577 +
578 + if (mode == HImode)
579 + return COSTS_N_INSNS (2);
580 +
581 + return COSTS_N_INSNS (3);
582 + }
583 + case IF_THEN_ELSE:
584 + if (GET_CODE (XEXP (x, 1)) == PC || GET_CODE (XEXP (x, 2)) == PC)
585 + return COSTS_N_INSNS (4);
586 + return COSTS_N_INSNS (1);
587 + case SIGN_EXTEND:
588 + case ZERO_EXTEND:
589 + /* Sign/Zero extensions of registers cost quite much since these
590 + instrcutions only take one register operand which means that gcc
591 + often must insert some move instrcutions */
592 + if (mode == QImode || mode == HImode)
593 + return (COSTS_N_INSNS (GET_CODE (XEXP (x, 0)) == MEM ? 0 : 1));
594 + return COSTS_N_INSNS (4);
595 + case UNSPEC:
596 + /* divmod operations */
597 + if (XINT (x, 1) == UNSPEC_UDIVMODSI4_INTERNAL
598 + || XINT (x, 1) == UNSPEC_DIVMODSI4_INTERNAL)
599 + {
600 + return optimize_size ? COSTS_N_INSNS (1) : COSTS_N_INSNS (16);
601 + }
602 + /* Fallthrough */
603 + default:
604 + return COSTS_N_INSNS (1);
605 + }
606 + }
607 +
608 +static bool
609 +avr32_rtx_costs (rtx x, int code, int outer_code, int *total)
610 + {
611 + *total = avr32_rtx_costs_1 (x, code, outer_code);
612 + return true;
613 + }
614 +
615 +
616 +bool
617 +avr32_cannot_force_const_mem (rtx x ATTRIBUTE_UNUSED)
618 + {
619 + /* Do not want symbols in the constant pool when compiling pic or if using
620 + address pseudo instructions. */
621 + return ((flag_pic || TARGET_HAS_ASM_ADDR_PSEUDOS)
622 + && avr32_find_symbol (x) != NULL_RTX);
623 + }
624 +
625 +
626 +/* Table of machine attributes. */
627 +const struct attribute_spec avr32_attribute_table[] = {
628 + /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
629 + /* Interrupt Service Routines have special prologue and epilogue
630 + requirements. */
631 + {"isr", 0, 1, false, false, false, avr32_handle_isr_attribute},
632 + {"interrupt", 0, 1, false, false, false, avr32_handle_isr_attribute},
633 + {"acall", 0, 1, false, true, true, avr32_handle_acall_attribute},
634 + {"naked", 0, 0, true, false, false, avr32_handle_fndecl_attribute},
635 + {NULL, 0, 0, false, false, false, NULL}
636 +};
637 +
638 +
639 +typedef struct
640 +{
641 + const char *const arg;
642 + const unsigned long return_value;
643 +}
644 +isr_attribute_arg;
645 +
646 +static const isr_attribute_arg isr_attribute_args[] = {
647 + {"FULL", AVR32_FT_ISR_FULL},
648 + {"full", AVR32_FT_ISR_FULL},
649 + {"HALF", AVR32_FT_ISR_HALF},
650 + {"half", AVR32_FT_ISR_HALF},
651 + {"NONE", AVR32_FT_ISR_NONE},
652 + {"none", AVR32_FT_ISR_NONE},
653 + {"UNDEF", AVR32_FT_ISR_NONE},
654 + {"undef", AVR32_FT_ISR_NONE},
655 + {"SWI", AVR32_FT_ISR_NONE},
656 + {"swi", AVR32_FT_ISR_NONE},
657 + {NULL, AVR32_FT_ISR_NONE}
658 +};
659 +
660 +/* Returns the (interrupt) function type of the current
661 + function, or AVR32_FT_UNKNOWN if the type cannot be determined. */
662 +
663 +static unsigned long
664 +avr32_isr_value (tree argument)
665 + {
666 + const isr_attribute_arg *ptr;
667 + const char *arg;
668 +
669 + /* No argument - default to ISR_NONE. */
670 + if (argument == NULL_TREE)
671 + return AVR32_FT_ISR_NONE;
672 +
673 + /* Get the value of the argument. */
674 + if (TREE_VALUE (argument) == NULL_TREE
675 + || TREE_CODE (TREE_VALUE (argument)) != STRING_CST)
676 + return AVR32_FT_UNKNOWN;
677 +
678 + arg = TREE_STRING_POINTER (TREE_VALUE (argument));
679 +
680 + /* Check it against the list of known arguments. */
681 + for (ptr = isr_attribute_args; ptr->arg != NULL; ptr++)
682 + if (streq (arg, ptr->arg))
683 + return ptr->return_value;
684 +
685 + /* An unrecognized interrupt type. */
686 + return AVR32_FT_UNKNOWN;
687 + }
688 +
689 +
690 +
691 +/*
692 +These hooks specify assembly directives for creating certain kinds
693 +of integer object. The TARGET_ASM_BYTE_OP directive creates a
694 +byte-sized object, the TARGET_ASM_ALIGNED_HI_OP one creates an
695 +aligned two-byte object, and so on. Any of the hooks may be
696 +NULL, indicating that no suitable directive is available.
697 +
698 +The compiler will print these strings at the start of a new line,
699 +followed immediately by the object's initial value. In most cases,
700 +the string should contain a tab, a pseudo-op, and then another tab.
701 + */
702 +#undef TARGET_ASM_BYTE_OP
703 +#define TARGET_ASM_BYTE_OP "\t.byte\t"
704 +#undef TARGET_ASM_ALIGNED_HI_OP
705 +#define TARGET_ASM_ALIGNED_HI_OP "\t.align 1\n\t.short\t"
706 +#undef TARGET_ASM_ALIGNED_SI_OP
707 +#define TARGET_ASM_ALIGNED_SI_OP "\t.align 2\n\t.int\t"
708 +#undef TARGET_ASM_ALIGNED_DI_OP
709 +#define TARGET_ASM_ALIGNED_DI_OP NULL
710 +#undef TARGET_ASM_ALIGNED_TI_OP
711 +#define TARGET_ASM_ALIGNED_TI_OP NULL
712 +#undef TARGET_ASM_UNALIGNED_HI_OP
713 +#define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t"
714 +#undef TARGET_ASM_UNALIGNED_SI_OP
715 +#define TARGET_ASM_UNALIGNED_SI_OP "\t.int\t"
716 +#undef TARGET_ASM_UNALIGNED_DI_OP
717 +#define TARGET_ASM_UNALIGNED_DI_OP NULL
718 +#undef TARGET_ASM_UNALIGNED_TI_OP
719 +#define TARGET_ASM_UNALIGNED_TI_OP NULL
720 +
721 +#undef TARGET_ASM_OUTPUT_MI_THUNK
722 +#define TARGET_ASM_OUTPUT_MI_THUNK avr32_output_mi_thunk
723 +
724 +#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
725 +#define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_tree_hwi_hwi_tree_true
726 +
727 +static void
728 +avr32_output_mi_thunk (FILE * file,
729 + tree thunk ATTRIBUTE_UNUSED,
730 + HOST_WIDE_INT delta,
731 + HOST_WIDE_INT vcall_offset, tree function)
732 + {
733 + int mi_delta = delta;
734 + int this_regno =
735 + (aggregate_value_p (TREE_TYPE (TREE_TYPE (function)), function) ?
736 + INTERNAL_REGNUM (11) : INTERNAL_REGNUM (12));
737 +
738 +
739 + if (!avr32_const_ok_for_constraint_p (mi_delta, 'I', "Is21")
740 + || vcall_offset
741 + || flag_pic)
742 + {
743 + fputs ("\tpushm\tlr\n", file);
744 + }
745 +
746 +
747 + if (mi_delta != 0)
748 + {
749 + if (avr32_const_ok_for_constraint_p (mi_delta, 'I', "Is21"))
750 + {
751 + fprintf (file, "\tsub\t%s, -0x%x\n", reg_names[this_regno],
752 + mi_delta);
753 + }
754 + else
755 + {
756 + /* Immediate is larger than k21 we must make us a temp register by
757 + pushing a register to the stack. */
758 + fprintf (file, "\tmov\tlr, lo(%x)\n", mi_delta);
759 + fprintf (file, "\torh\tlr, hi(%x)\n", mi_delta);
760 + fprintf (file, "\tadd\t%s, lr\n", reg_names[this_regno]);
761 + }
762 + }
763 +
764 +
765 + if (vcall_offset != 0)
766 + {
767 + fprintf (file, "\tld.w\tlr, %s[0]\n", reg_names[this_regno]);
768 + fprintf (file, "\tld.w\tlr, lr[%i]\n", (int) vcall_offset);
769 + fprintf (file, "\tadd\t%s, lr\n", reg_names[this_regno]);
770 + }
771 +
772 +
773 + if ( (!avr32_const_ok_for_constraint_p (mi_delta, 'I', "Is21")
774 + || vcall_offset)
775 + && !flag_pic )
776 + {
777 + fputs ("\tpopm\tlr\n", file);
778 + }
779 +
780 + if (flag_pic)
781 + {
782 + /* Load the got into lr and then load the pointer
783 + to the function from the got and put it on the stack.
784 + We can then call the function and restore lr by issuing
785 + a doubleword load from the stack. We do not use a popm/ldm
786 + since it will be treated as a return and might need a flushing
787 + of the return-stack if available. */
788 + rtx label = gen_label_rtx ();
789 + /* Load the got. */
790 + fputs ("\tlddpc\tlr, 0f\n", file);
791 + (*targetm.asm_out.internal_label) (file, "L",
792 + CODE_LABEL_NUMBER (label));
793 + fputs ("\trsub\tlr, pc\n", file);
794 + /* Load the function pointer. */
795 + fputs ("\tld.w\tlr, lr[", file);
796 + assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
797 + fputs ("@got]\n", file);
798 + /* Push the function pointer on the stack.*/
799 + fputs ("\tpushm\tlr\n", file);
800 + /* Restore the old lr value and load the function pointer into
801 + pc. */
802 + fputs ("\tld.d\tlr,sp++\n", file);
803 + fprintf (file, "\t.align 2\n");
804 + fprintf (file, "0:\t.long\t.L%d - _GLOBAL_OFFSET_TABLE_\n", CODE_LABEL_NUMBER (label));
805 + }
806 + else
807 + {
808 + fprintf (file, "\tlddpc\tpc, 0f\n");
809 + fprintf (file, "\t.align 2\n");
810 + fputs ("0:\t.long\t", file);
811 + assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
812 + fputc ('\n', file);
813 + }
814 + }
815 +
816 +/* Implements target hook vector_mode_supported. */
817 +bool
818 +avr32_vector_mode_supported (enum machine_mode mode)
819 + {
820 + if ((mode == V2HImode) || (mode == V4QImode))
821 + return true;
822 +
823 + return false;
824 + }
825 +
826 +
827 +#undef TARGET_INIT_LIBFUNCS
828 +#define TARGET_INIT_LIBFUNCS avr32_init_libfuncs
829 +
830 +#undef TARGET_INIT_BUILTINS
831 +#define TARGET_INIT_BUILTINS avr32_init_builtins
832 +
833 +#undef TARGET_EXPAND_BUILTIN
834 +#define TARGET_EXPAND_BUILTIN avr32_expand_builtin
835 +
836 +tree int_ftype_int, int_ftype_void, short_ftype_short, void_ftype_int_int,
837 +void_ftype_ptr_int;
838 +tree void_ftype_int, void_ftype_void, int_ftype_ptr_int;
839 +tree short_ftype_short, int_ftype_int_short, int_ftype_short_short,
840 +short_ftype_short_short;
841 +tree int_ftype_int_int, longlong_ftype_int_short, longlong_ftype_short_short;
842 +tree void_ftype_int_int_int_int_int, void_ftype_int_int_int;
843 +tree longlong_ftype_int_int, void_ftype_int_int_longlong;
844 +tree int_ftype_int_int_int, longlong_ftype_longlong_int_short;
845 +tree longlong_ftype_longlong_short_short, int_ftype_int_short_short;
846 +
847 +#define def_builtin(NAME, TYPE, CODE) \
848 + lang_hooks.builtin_function ((NAME), (TYPE), (CODE), \
849 + BUILT_IN_MD, NULL, NULL_TREE)
850 +
851 +#define def_mbuiltin(MASK, NAME, TYPE, CODE) \
852 + do \
853 + { \
854 + if ((MASK)) \
855 + lang_hooks.builtin_function ((NAME), (TYPE), (CODE), \
856 + BUILT_IN_MD, NULL, NULL_TREE); \
857 + } \
858 + while (0)
859 +
860 +struct builtin_description
861 +{
862 + const unsigned int mask;
863 + const enum insn_code icode;
864 + const char *const name;
865 + const int code;
866 + const enum rtx_code comparison;
867 + const unsigned int flag;
868 + const tree *ftype;
869 +};
870 +
871 +static const struct builtin_description bdesc_2arg[] = {
872 +#define DSP_BUILTIN(code, builtin, ftype) \
873 + { 1, CODE_FOR_##code, "__builtin_" #code , \
874 + AVR32_BUILTIN_##builtin, 0, 0, ftype }
875 +
876 + DSP_BUILTIN (mulsathh_h, MULSATHH_H, &short_ftype_short_short),
877 + DSP_BUILTIN (mulsathh_w, MULSATHH_W, &int_ftype_short_short),
878 + DSP_BUILTIN (mulsatrndhh_h, MULSATRNDHH_H, &short_ftype_short_short),
879 + DSP_BUILTIN (mulsatrndwh_w, MULSATRNDWH_W, &int_ftype_int_short),
880 + DSP_BUILTIN (mulsatwh_w, MULSATWH_W, &int_ftype_int_short),
881 + DSP_BUILTIN (satadd_h, SATADD_H, &short_ftype_short_short),
882 + DSP_BUILTIN (satsub_h, SATSUB_H, &short_ftype_short_short),
883 + DSP_BUILTIN (satadd_w, SATADD_W, &int_ftype_int_int),
884 + DSP_BUILTIN (satsub_w, SATSUB_W, &int_ftype_int_int),
885 + DSP_BUILTIN (mulwh_d, MULWH_D, &longlong_ftype_int_short),
886 + DSP_BUILTIN (mulnwh_d, MULNWH_D, &longlong_ftype_int_short)
887 +};
888 +
889 +
890 +void
891 +avr32_init_builtins (void)
892 + {
893 + unsigned int i;
894 + const struct builtin_description *d;
895 + tree endlink = void_list_node;
896 + tree int_endlink = tree_cons (NULL_TREE, integer_type_node, endlink);
897 + tree longlong_endlink =
898 + tree_cons (NULL_TREE, long_long_integer_type_node, endlink);
899 + tree short_endlink =
900 + tree_cons (NULL_TREE, short_integer_type_node, endlink);
901 + tree void_endlink = tree_cons (NULL_TREE, void_type_node, endlink);
902 +
903 + /* int func (int) */
904 + int_ftype_int = build_function_type (integer_type_node, int_endlink);
905 +
906 + /* short func (short) */
907 + short_ftype_short
908 + = build_function_type (short_integer_type_node, short_endlink);
909 +
910 + /* short func (short, short) */
911 + short_ftype_short_short
912 + = build_function_type (short_integer_type_node,
913 + tree_cons (NULL_TREE, short_integer_type_node,
914 + short_endlink));
915 +
916 + /* long long func (long long, short, short) */
917 + longlong_ftype_longlong_short_short
918 + = build_function_type (long_long_integer_type_node,
919 + tree_cons (NULL_TREE, long_long_integer_type_node,
920 + tree_cons (NULL_TREE,
921 + short_integer_type_node,
922 + short_endlink)));
923 +
924 + /* long long func (short, short) */
925 + longlong_ftype_short_short
926 + = build_function_type (long_long_integer_type_node,
927 + tree_cons (NULL_TREE, short_integer_type_node,
928 + short_endlink));
929 +
930 + /* int func (int, int) */
931 + int_ftype_int_int
932 + = build_function_type (integer_type_node,
933 + tree_cons (NULL_TREE, integer_type_node,
934 + int_endlink));
935 +
936 + /* long long func (int, int) */
937 + longlong_ftype_int_int
938 + = build_function_type (long_long_integer_type_node,
939 + tree_cons (NULL_TREE, integer_type_node,
940 + int_endlink));
941 +
942 + /* long long int func (long long, int, short) */
943 + longlong_ftype_longlong_int_short
944 + = build_function_type (long_long_integer_type_node,
945 + tree_cons (NULL_TREE, long_long_integer_type_node,
946 + tree_cons (NULL_TREE, integer_type_node,
947 + short_endlink)));
948 +
949 + /* long long int func (int, short) */
950 + longlong_ftype_int_short
951 + = build_function_type (long_long_integer_type_node,
952 + tree_cons (NULL_TREE, integer_type_node,
953 + short_endlink));
954 +
955 + /* int func (int, short, short) */
956 + int_ftype_int_short_short
957 + = build_function_type (integer_type_node,
958 + tree_cons (NULL_TREE, integer_type_node,
959 + tree_cons (NULL_TREE,
960 + short_integer_type_node,
961 + short_endlink)));
962 +
963 + /* int func (short, short) */
964 + int_ftype_short_short
965 + = build_function_type (integer_type_node,
966 + tree_cons (NULL_TREE, short_integer_type_node,
967 + short_endlink));
968 +
969 + /* int func (int, short) */
970 + int_ftype_int_short
971 + = build_function_type (integer_type_node,
972 + tree_cons (NULL_TREE, integer_type_node,
973 + short_endlink));
974 +
975 + /* void func (int, int) */
976 + void_ftype_int_int
977 + = build_function_type (void_type_node,
978 + tree_cons (NULL_TREE, integer_type_node,
979 + int_endlink));
980 +
981 + /* void func (int, int, int) */
982 + void_ftype_int_int_int
983 + = build_function_type (void_type_node,
984 + tree_cons (NULL_TREE, integer_type_node,
985 + tree_cons (NULL_TREE, integer_type_node,
986 + int_endlink)));
987 +
988 + /* void func (int, int, long long) */
989 + void_ftype_int_int_longlong
990 + = build_function_type (void_type_node,
991 + tree_cons (NULL_TREE, integer_type_node,
992 + tree_cons (NULL_TREE, integer_type_node,
993 + longlong_endlink)));
994 +
995 + /* void func (int, int, int, int, int) */
996 + void_ftype_int_int_int_int_int
997 + = build_function_type (void_type_node,
998 + tree_cons (NULL_TREE, integer_type_node,
999 + tree_cons (NULL_TREE, integer_type_node,
1000 + tree_cons (NULL_TREE,
1001 + integer_type_node,
1002 + tree_cons
1003 + (NULL_TREE,
1004 + integer_type_node,
1005 + int_endlink)))));
1006 +
1007 + /* void func (void *, int) */
1008 + void_ftype_ptr_int
1009 + = build_function_type (void_type_node,
1010 + tree_cons (NULL_TREE, ptr_type_node, int_endlink));
1011 +
1012 + /* void func (int) */
1013 + void_ftype_int = build_function_type (void_type_node, int_endlink);
1014 +
1015 + /* void func (void) */
1016 + void_ftype_void = build_function_type (void_type_node, void_endlink);
1017 +
1018 + /* int func (void) */
1019 + int_ftype_void = build_function_type (integer_type_node, void_endlink);
1020 +
1021 + /* int func (void *, int) */
1022 + int_ftype_ptr_int
1023 + = build_function_type (integer_type_node,
1024 + tree_cons (NULL_TREE, ptr_type_node, int_endlink));
1025 +
1026 + /* int func (int, int, int) */
1027 + int_ftype_int_int_int
1028 + = build_function_type (integer_type_node,
1029 + tree_cons (NULL_TREE, integer_type_node,
1030 + tree_cons (NULL_TREE, integer_type_node,
1031 + int_endlink)));
1032 +
1033 + /* Initialize avr32 builtins. */
1034 + def_builtin ("__builtin_mfsr", int_ftype_int, AVR32_BUILTIN_MFSR);
1035 + def_builtin ("__builtin_mtsr", void_ftype_int_int, AVR32_BUILTIN_MTSR);
1036 + def_builtin ("__builtin_mfdr", int_ftype_int, AVR32_BUILTIN_MFDR);
1037 + def_builtin ("__builtin_mtdr", void_ftype_int_int, AVR32_BUILTIN_MTDR);
1038 + def_builtin ("__builtin_cache", void_ftype_ptr_int, AVR32_BUILTIN_CACHE);
1039 + def_builtin ("__builtin_sync", void_ftype_int, AVR32_BUILTIN_SYNC);
1040 + def_builtin ("__builtin_tlbr", void_ftype_void, AVR32_BUILTIN_TLBR);
1041 + def_builtin ("__builtin_tlbs", void_ftype_void, AVR32_BUILTIN_TLBS);
1042 + def_builtin ("__builtin_tlbw", void_ftype_void, AVR32_BUILTIN_TLBW);
1043 + def_builtin ("__builtin_breakpoint", void_ftype_void,
1044 + AVR32_BUILTIN_BREAKPOINT);
1045 + def_builtin ("__builtin_xchg", int_ftype_ptr_int, AVR32_BUILTIN_XCHG);
1046 + def_builtin ("__builtin_ldxi", int_ftype_ptr_int, AVR32_BUILTIN_LDXI);
1047 + def_builtin ("__builtin_bswap_16", short_ftype_short,
1048 + AVR32_BUILTIN_BSWAP16);
1049 + def_builtin ("__builtin_bswap_32", int_ftype_int, AVR32_BUILTIN_BSWAP32);
1050 + def_builtin ("__builtin_cop", void_ftype_int_int_int_int_int,
1051 + AVR32_BUILTIN_COP);
1052 + def_builtin ("__builtin_mvcr_w", int_ftype_int_int, AVR32_BUILTIN_MVCR_W);
1053 + def_builtin ("__builtin_mvrc_w", void_ftype_int_int_int,
1054 + AVR32_BUILTIN_MVRC_W);
1055 + def_builtin ("__builtin_mvcr_d", longlong_ftype_int_int,
1056 + AVR32_BUILTIN_MVCR_D);
1057 + def_builtin ("__builtin_mvrc_d", void_ftype_int_int_longlong,
1058 + AVR32_BUILTIN_MVRC_D);
1059 + def_builtin ("__builtin_sats", int_ftype_int_int_int, AVR32_BUILTIN_SATS);
1060 + def_builtin ("__builtin_satu", int_ftype_int_int_int, AVR32_BUILTIN_SATU);
1061 + def_builtin ("__builtin_satrnds", int_ftype_int_int_int,
1062 + AVR32_BUILTIN_SATRNDS);
1063 + def_builtin ("__builtin_satrndu", int_ftype_int_int_int,
1064 + AVR32_BUILTIN_SATRNDU);
1065 + def_builtin ("__builtin_musfr", void_ftype_int, AVR32_BUILTIN_MUSFR);
1066 + def_builtin ("__builtin_mustr", int_ftype_void, AVR32_BUILTIN_MUSTR);
1067 + def_builtin ("__builtin_macsathh_w", int_ftype_int_short_short,
1068 + AVR32_BUILTIN_MACSATHH_W);
1069 + def_builtin ("__builtin_macwh_d", longlong_ftype_longlong_int_short,
1070 + AVR32_BUILTIN_MACWH_D);
1071 + def_builtin ("__builtin_machh_d", longlong_ftype_longlong_short_short,
1072 + AVR32_BUILTIN_MACHH_D);
1073 +
1074 + /* Add all builtins that are more or less simple operations on two
1075 + operands. */
1076 + for (i = 0, d = bdesc_2arg; i < ARRAY_SIZE (bdesc_2arg); i++, d++)
1077 + {
1078 + /* Use one of the operands; the target can have a different mode for
1079 + mask-generating compares. */
1080 +
1081 + if (d->name == 0)
1082 + continue;
1083 +
1084 + def_mbuiltin (d->mask, d->name, *(d->ftype), d->code);
1085 + }
1086 + }
1087 +
1088 +
1089 +/* Subroutine of avr32_expand_builtin to take care of binop insns. */
1090 +
1091 +static rtx
1092 +avr32_expand_binop_builtin (enum insn_code icode, tree arglist, rtx target)
1093 + {
1094 + rtx pat;
1095 + tree arg0 = TREE_VALUE (arglist);
1096 + tree arg1 = TREE_VALUE (TREE_CHAIN (arglist));
1097 + rtx op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1098 + rtx op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
1099 + enum machine_mode tmode = insn_data[icode].operand[0].mode;
1100 + enum machine_mode mode0 = insn_data[icode].operand[1].mode;
1101 + enum machine_mode mode1 = insn_data[icode].operand[2].mode;
1102 +
1103 + if (!target
1104 + || GET_MODE (target) != tmode
1105 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1106 + target = gen_reg_rtx (tmode);
1107 +
1108 + /* In case the insn wants input operands in modes different from the
1109 + result, abort. */
1110 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1111 + {
1112 + /* If op0 is already a reg we must cast it to the correct mode. */
1113 + if (REG_P (op0))
1114 + op0 = convert_to_mode (mode0, op0, 1);
1115 + else
1116 + op0 = copy_to_mode_reg (mode0, op0);
1117 + }
1118 + if (!(*insn_data[icode].operand[2].predicate) (op1, mode1))
1119 + {
1120 + /* If op1 is already a reg we must cast it to the correct mode. */
1121 + if (REG_P (op1))
1122 + op1 = convert_to_mode (mode1, op1, 1);
1123 + else
1124 + op1 = copy_to_mode_reg (mode1, op1);
1125 + }
1126 + pat = GEN_FCN (icode) (target, op0, op1);
1127 + if (!pat)
1128 + return 0;
1129 + emit_insn (pat);
1130 + return target;
1131 + }
1132 +
1133 +/* Expand an expression EXP that calls a built-in function,
1134 + with result going to TARGET if that's convenient
1135 + (and in mode MODE if that's convenient).
1136 + SUBTARGET may be used as the target for computing one of EXP's operands.
1137 + IGNORE is nonzero if the value is to be ignored. */
1138 +
1139 +rtx
1140 +avr32_expand_builtin (tree exp,
1141 + rtx target,
1142 + rtx subtarget ATTRIBUTE_UNUSED,
1143 + enum machine_mode mode ATTRIBUTE_UNUSED,
1144 + int ignore ATTRIBUTE_UNUSED)
1145 + {
1146 + const struct builtin_description *d;
1147 + unsigned int i;
1148 + enum insn_code icode;
1149 + tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
1150 + tree arglist = TREE_OPERAND (exp, 1);
1151 + tree arg0, arg1, arg2;
1152 + rtx op0, op1, op2, pat;
1153 + enum machine_mode tmode, mode0, mode1;
1154 + enum machine_mode arg0_mode;
1155 + int fcode = DECL_FUNCTION_CODE (fndecl);
1156 +
1157 + switch (fcode)
1158 + {
1159 + default:
1160 + break;
1161 +
1162 + case AVR32_BUILTIN_SATS:
1163 + case AVR32_BUILTIN_SATU:
1164 + case AVR32_BUILTIN_SATRNDS:
1165 + case AVR32_BUILTIN_SATRNDU:
1166 + {
1167 + const char *fname;
1168 + switch (fcode)
1169 + {
1170 + default:
1171 + case AVR32_BUILTIN_SATS:
1172 + icode = CODE_FOR_sats;
1173 + fname = "sats";
1174 + break;
1175 + case AVR32_BUILTIN_SATU:
1176 + icode = CODE_FOR_satu;
1177 + fname = "satu";
1178 + break;
1179 + case AVR32_BUILTIN_SATRNDS:
1180 + icode = CODE_FOR_satrnds;
1181 + fname = "satrnds";
1182 + break;
1183 + case AVR32_BUILTIN_SATRNDU:
1184 + icode = CODE_FOR_satrndu;
1185 + fname = "satrndu";
1186 + break;
1187 + }
1188 +
1189 + arg0 = TREE_VALUE (arglist);
1190 + arg1 = TREE_VALUE (TREE_CHAIN (arglist));
1191 + arg2 = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
1192 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1193 + op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
1194 + op2 = expand_expr (arg2, NULL_RTX, VOIDmode, 0);
1195 +
1196 + tmode = insn_data[icode].operand[0].mode;
1197 +
1198 +
1199 + if (target == 0
1200 + || GET_MODE (target) != tmode
1201 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1202 + target = gen_reg_rtx (tmode);
1203 +
1204 +
1205 + if (!(*insn_data[icode].operand[0].predicate) (op0, GET_MODE (op0)))
1206 + {
1207 + op0 = copy_to_mode_reg (insn_data[icode].operand[0].mode, op0);
1208 + }
1209 +
1210 + if (!(*insn_data[icode].operand[1].predicate) (op1, SImode))
1211 + {
1212 + error ("Parameter 2 to __builtin_%s should be a constant number.",
1213 + fname);
1214 + return NULL_RTX;
1215 + }
1216 +
1217 + if (!(*insn_data[icode].operand[1].predicate) (op2, SImode))
1218 + {
1219 + error ("Parameter 3 to __builtin_%s should be a constant number.",
1220 + fname);
1221 + return NULL_RTX;
1222 + }
1223 +
1224 + emit_move_insn (target, op0);
1225 + pat = GEN_FCN (icode) (target, op1, op2);
1226 + if (!pat)
1227 + return 0;
1228 + emit_insn (pat);
1229 +
1230 + return target;
1231 + }
1232 + case AVR32_BUILTIN_MUSTR:
1233 + icode = CODE_FOR_mustr;
1234 + tmode = insn_data[icode].operand[0].mode;
1235 +
1236 + if (target == 0
1237 + || GET_MODE (target) != tmode
1238 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1239 + target = gen_reg_rtx (tmode);
1240 + pat = GEN_FCN (icode) (target);
1241 + if (!pat)
1242 + return 0;
1243 + emit_insn (pat);
1244 + return target;
1245 +
1246 + case AVR32_BUILTIN_MFSR:
1247 + icode = CODE_FOR_mfsr;
1248 + arg0 = TREE_VALUE (arglist);
1249 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1250 + tmode = insn_data[icode].operand[0].mode;
1251 + mode0 = insn_data[icode].operand[1].mode;
1252 +
1253 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1254 + {
1255 + error ("Parameter 1 to __builtin_mfsr must be a constant number");
1256 + }
1257 +
1258 + if (target == 0
1259 + || GET_MODE (target) != tmode
1260 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1261 + target = gen_reg_rtx (tmode);
1262 + pat = GEN_FCN (icode) (target, op0);
1263 + if (!pat)
1264 + return 0;
1265 + emit_insn (pat);
1266 + return target;
1267 + case AVR32_BUILTIN_MTSR:
1268 + icode = CODE_FOR_mtsr;
1269 + arg0 = TREE_VALUE (arglist);
1270 + arg1 = TREE_VALUE (TREE_CHAIN (arglist));
1271 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1272 + op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
1273 + mode0 = insn_data[icode].operand[0].mode;
1274 + mode1 = insn_data[icode].operand[1].mode;
1275 +
1276 + if (!(*insn_data[icode].operand[0].predicate) (op0, mode0))
1277 + {
1278 + error ("Parameter 1 to __builtin_mtsr must be a constant number");
1279 + return gen_reg_rtx (mode0);
1280 + }
1281 + if (!(*insn_data[icode].operand[1].predicate) (op1, mode1))
1282 + op1 = copy_to_mode_reg (mode1, op1);
1283 + pat = GEN_FCN (icode) (op0, op1);
1284 + if (!pat)
1285 + return 0;
1286 + emit_insn (pat);
1287 + return NULL_RTX;
1288 + case AVR32_BUILTIN_MFDR:
1289 + icode = CODE_FOR_mfdr;
1290 + arg0 = TREE_VALUE (arglist);
1291 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1292 + tmode = insn_data[icode].operand[0].mode;
1293 + mode0 = insn_data[icode].operand[1].mode;
1294 +
1295 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1296 + {
1297 + error ("Parameter 1 to __builtin_mfdr must be a constant number");
1298 + }
1299 +
1300 + if (target == 0
1301 + || GET_MODE (target) != tmode
1302 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1303 + target = gen_reg_rtx (tmode);
1304 + pat = GEN_FCN (icode) (target, op0);
1305 + if (!pat)
1306 + return 0;
1307 + emit_insn (pat);
1308 + return target;
1309 + case AVR32_BUILTIN_MTDR:
1310 + icode = CODE_FOR_mtdr;
1311 + arg0 = TREE_VALUE (arglist);
1312 + arg1 = TREE_VALUE (TREE_CHAIN (arglist));
1313 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1314 + op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
1315 + mode0 = insn_data[icode].operand[0].mode;
1316 + mode1 = insn_data[icode].operand[1].mode;
1317 +
1318 + if (!(*insn_data[icode].operand[0].predicate) (op0, mode0))
1319 + {
1320 + error ("Parameter 1 to __builtin_mtdr must be a constant number");
1321 + return gen_reg_rtx (mode0);
1322 + }
1323 + if (!(*insn_data[icode].operand[1].predicate) (op1, mode1))
1324 + op1 = copy_to_mode_reg (mode1, op1);
1325 + pat = GEN_FCN (icode) (op0, op1);
1326 + if (!pat)
1327 + return 0;
1328 + emit_insn (pat);
1329 + return NULL_RTX;
1330 + case AVR32_BUILTIN_CACHE:
1331 + icode = CODE_FOR_cache;
1332 + arg0 = TREE_VALUE (arglist);
1333 + arg1 = TREE_VALUE (TREE_CHAIN (arglist));
1334 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1335 + op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
1336 + mode0 = insn_data[icode].operand[0].mode;
1337 + mode1 = insn_data[icode].operand[1].mode;
1338 +
1339 + if (!(*insn_data[icode].operand[1].predicate) (op1, mode1))
1340 + {
1341 + error ("Parameter 2 to __builtin_cache must be a constant number");
1342 + return gen_reg_rtx (mode1);
1343 + }
1344 +
1345 + if (!(*insn_data[icode].operand[0].predicate) (op0, mode0))
1346 + op0 = copy_to_mode_reg (mode0, op0);
1347 +
1348 + pat = GEN_FCN (icode) (op0, op1);
1349 + if (!pat)
1350 + return 0;
1351 + emit_insn (pat);
1352 + return NULL_RTX;
1353 + case AVR32_BUILTIN_SYNC:
1354 + case AVR32_BUILTIN_MUSFR:
1355 + {
1356 + const char *fname;
1357 + switch (fcode)
1358 + {
1359 + default:
1360 + case AVR32_BUILTIN_SYNC:
1361 + icode = CODE_FOR_sync;
1362 + fname = "sync";
1363 + break;
1364 + case AVR32_BUILTIN_MUSFR:
1365 + icode = CODE_FOR_musfr;
1366 + fname = "musfr";
1367 + break;
1368 + }
1369 +
1370 + arg0 = TREE_VALUE (arglist);
1371 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1372 + mode0 = insn_data[icode].operand[0].mode;
1373 +
1374 + if (!(*insn_data[icode].operand[0].predicate) (op0, mode0))
1375 + {
1376 + if (icode == CODE_FOR_musfr)
1377 + op0 = copy_to_mode_reg (mode0, op0);
1378 + else
1379 + {
1380 + error ("Parameter to __builtin_%s is illegal.", fname);
1381 + return gen_reg_rtx (mode0);
1382 + }
1383 + }
1384 + pat = GEN_FCN (icode) (op0);
1385 + if (!pat)
1386 + return 0;
1387 + emit_insn (pat);
1388 + return NULL_RTX;
1389 + }
1390 + case AVR32_BUILTIN_TLBR:
1391 + icode = CODE_FOR_tlbr;
1392 + pat = GEN_FCN (icode) (NULL_RTX);
1393 + if (!pat)
1394 + return 0;
1395 + emit_insn (pat);
1396 + return NULL_RTX;
1397 + case AVR32_BUILTIN_TLBS:
1398 + icode = CODE_FOR_tlbs;
1399 + pat = GEN_FCN (icode) (NULL_RTX);
1400 + if (!pat)
1401 + return 0;
1402 + emit_insn (pat);
1403 + return NULL_RTX;
1404 + case AVR32_BUILTIN_TLBW:
1405 + icode = CODE_FOR_tlbw;
1406 + pat = GEN_FCN (icode) (NULL_RTX);
1407 + if (!pat)
1408 + return 0;
1409 + emit_insn (pat);
1410 + return NULL_RTX;
1411 + case AVR32_BUILTIN_BREAKPOINT:
1412 + icode = CODE_FOR_breakpoint;
1413 + pat = GEN_FCN (icode) (NULL_RTX);
1414 + if (!pat)
1415 + return 0;
1416 + emit_insn (pat);
1417 + return NULL_RTX;
1418 + case AVR32_BUILTIN_XCHG:
1419 + icode = CODE_FOR_sync_lock_test_and_setsi;
1420 + arg0 = TREE_VALUE (arglist);
1421 + arg1 = TREE_VALUE (TREE_CHAIN (arglist));
1422 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1423 + op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
1424 + tmode = insn_data[icode].operand[0].mode;
1425 + mode0 = insn_data[icode].operand[1].mode;
1426 + mode1 = insn_data[icode].operand[2].mode;
1427 +
1428 + if (!(*insn_data[icode].operand[2].predicate) (op1, mode1))
1429 + {
1430 + op1 = copy_to_mode_reg (mode1, op1);
1431 + }
1432 +
1433 + op0 = gen_rtx_MEM (SImode, op0);
1434 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1435 + {
1436 + error
1437 + ("Parameter 1 to __builtin_xchg must be a pointer to an integer.");
1438 + }
1439 +
1440 + if (target == 0
1441 + || GET_MODE (target) != tmode
1442 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1443 + target = gen_reg_rtx (tmode);
1444 + pat = GEN_FCN (icode) (target, op0, op1);
1445 + if (!pat)
1446 + return 0;
1447 + emit_insn (pat);
1448 + return target;
1449 + case AVR32_BUILTIN_LDXI:
1450 + icode = CODE_FOR_ldxi;
1451 + arg0 = TREE_VALUE (arglist);
1452 + arg1 = TREE_VALUE (TREE_CHAIN (arglist));
1453 + arg2 = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
1454 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1455 + op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
1456 + op2 = expand_expr (arg2, NULL_RTX, VOIDmode, 0);
1457 + tmode = insn_data[icode].operand[0].mode;
1458 + mode0 = insn_data[icode].operand[1].mode;
1459 + mode1 = insn_data[icode].operand[2].mode;
1460 +
1461 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1462 + {
1463 + op0 = copy_to_mode_reg (mode0, op0);
1464 + }
1465 +
1466 + if (!(*insn_data[icode].operand[2].predicate) (op1, mode1))
1467 + {
1468 + op1 = copy_to_mode_reg (mode1, op1);
1469 + }
1470 +
1471 + if (!(*insn_data[icode].operand[3].predicate) (op2, SImode))
1472 + {
1473 + error
1474 + ("Parameter 3 to __builtin_ldxi must be a valid extract shift operand: (0|8|16|24)");
1475 + return gen_reg_rtx (mode0);
1476 + }
1477 +
1478 + if (target == 0
1479 + || GET_MODE (target) != tmode
1480 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1481 + target = gen_reg_rtx (tmode);
1482 + pat = GEN_FCN (icode) (target, op0, op1, op2);
1483 + if (!pat)
1484 + return 0;
1485 + emit_insn (pat);
1486 + return target;
1487 + case AVR32_BUILTIN_BSWAP16:
1488 + {
1489 + icode = CODE_FOR_bswap_16;
1490 + arg0 = TREE_VALUE (arglist);
1491 + arg0_mode = TYPE_MODE (TREE_TYPE (arg0));
1492 + mode0 = insn_data[icode].operand[1].mode;
1493 + if (arg0_mode != mode0)
1494 + arg0 = build1 (NOP_EXPR,
1495 + (*lang_hooks.types.type_for_mode) (mode0, 0), arg0);
1496 +
1497 + op0 = expand_expr (arg0, NULL_RTX, HImode, 0);
1498 + tmode = insn_data[icode].operand[0].mode;
1499 +
1500 +
1501 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1502 + {
1503 + op0 = copy_to_mode_reg (mode0, op0);
1504 + }
1505 +
1506 + if (target == 0
1507 + || GET_MODE (target) != tmode
1508 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1509 + {
1510 + target = gen_reg_rtx (tmode);
1511 + }
1512 +
1513 +
1514 + pat = GEN_FCN (icode) (target, op0);
1515 + if (!pat)
1516 + return 0;
1517 + emit_insn (pat);
1518 +
1519 + return target;
1520 + }
1521 + case AVR32_BUILTIN_BSWAP32:
1522 + {
1523 + icode = CODE_FOR_bswap_32;
1524 + arg0 = TREE_VALUE (arglist);
1525 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1526 + tmode = insn_data[icode].operand[0].mode;
1527 + mode0 = insn_data[icode].operand[1].mode;
1528 +
1529 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
1530 + {
1531 + op0 = copy_to_mode_reg (mode0, op0);
1532 + }
1533 +
1534 + if (target == 0
1535 + || GET_MODE (target) != tmode
1536 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1537 + target = gen_reg_rtx (tmode);
1538 +
1539 +
1540 + pat = GEN_FCN (icode) (target, op0);
1541 + if (!pat)
1542 + return 0;
1543 + emit_insn (pat);
1544 +
1545 + return target;
1546 + }
1547 + case AVR32_BUILTIN_MVCR_W:
1548 + case AVR32_BUILTIN_MVCR_D:
1549 + {
1550 + arg0 = TREE_VALUE (arglist);
1551 + arg1 = TREE_VALUE (TREE_CHAIN (arglist));
1552 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1553 + op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
1554 +
1555 + if (fcode == AVR32_BUILTIN_MVCR_W)
1556 + icode = CODE_FOR_mvcrsi;
1557 + else
1558 + icode = CODE_FOR_mvcrdi;
1559 +
1560 + tmode = insn_data[icode].operand[0].mode;
1561 +
1562 + if (target == 0
1563 + || GET_MODE (target) != tmode
1564 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1565 + target = gen_reg_rtx (tmode);
1566 +
1567 + if (!(*insn_data[icode].operand[1].predicate) (op0, SImode))
1568 + {
1569 + error
1570 + ("Parameter 1 to __builtin_cop is not a valid coprocessor number.");
1571 + error ("Number should be between 0 and 7.");
1572 + return NULL_RTX;
1573 + }
1574 +
1575 + if (!(*insn_data[icode].operand[2].predicate) (op1, SImode))
1576 + {
1577 + error
1578 + ("Parameter 2 to __builtin_cop is not a valid coprocessor register number.");
1579 + error ("Number should be between 0 and 15.");
1580 + return NULL_RTX;
1581 + }
1582 +
1583 + pat = GEN_FCN (icode) (target, op0, op1);
1584 + if (!pat)
1585 + return 0;
1586 + emit_insn (pat);
1587 +
1588 + return target;
1589 + }
1590 + case AVR32_BUILTIN_MACSATHH_W:
1591 + case AVR32_BUILTIN_MACWH_D:
1592 + case AVR32_BUILTIN_MACHH_D:
1593 + {
1594 + arg0 = TREE_VALUE (arglist);
1595 + arg1 = TREE_VALUE (TREE_CHAIN (arglist));
1596 + arg2 = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
1597 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1598 + op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
1599 + op2 = expand_expr (arg2, NULL_RTX, VOIDmode, 0);
1600 +
1601 + icode = ((fcode == AVR32_BUILTIN_MACSATHH_W) ? CODE_FOR_macsathh_w :
1602 + (fcode == AVR32_BUILTIN_MACWH_D) ? CODE_FOR_macwh_d :
1603 + CODE_FOR_machh_d);
1604 +
1605 + tmode = insn_data[icode].operand[0].mode;
1606 + mode0 = insn_data[icode].operand[1].mode;
1607 + mode1 = insn_data[icode].operand[2].mode;
1608 +
1609 +
1610 + if (!target
1611 + || GET_MODE (target) != tmode
1612 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
1613 + target = gen_reg_rtx (tmode);
1614 +
1615 + if (!(*insn_data[icode].operand[0].predicate) (op0, tmode))
1616 + {
1617 + /* If op0 is already a reg we must cast it to the correct mode. */
1618 + if (REG_P (op0))
1619 + op0 = convert_to_mode (tmode, op0, 1);
1620 + else
1621 + op0 = copy_to_mode_reg (tmode, op0);
1622 + }
1623 +
1624 + if (!(*insn_data[icode].operand[1].predicate) (op1, mode0))
1625 + {
1626 + /* If op1 is already a reg we must cast it to the correct mode. */
1627 + if (REG_P (op1))
1628 + op1 = convert_to_mode (mode0, op1, 1);
1629 + else
1630 + op1 = copy_to_mode_reg (mode0, op1);
1631 + }
1632 +
1633 + if (!(*insn_data[icode].operand[2].predicate) (op2, mode1))
1634 + {
1635 + /* If op1 is already a reg we must cast it to the correct mode. */
1636 + if (REG_P (op2))
1637 + op2 = convert_to_mode (mode1, op2, 1);
1638 + else
1639 + op2 = copy_to_mode_reg (mode1, op2);
1640 + }
1641 +
1642 + emit_move_insn (target, op0);
1643 +
1644 + pat = GEN_FCN (icode) (target, op1, op2);
1645 + if (!pat)
1646 + return 0;
1647 + emit_insn (pat);
1648 + return target;
1649 + }
1650 + case AVR32_BUILTIN_MVRC_W:
1651 + case AVR32_BUILTIN_MVRC_D:
1652 + {
1653 + arg0 = TREE_VALUE (arglist);
1654 + arg1 = TREE_VALUE (TREE_CHAIN (arglist));
1655 + arg2 = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
1656 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1657 + op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
1658 + op2 = expand_expr (arg2, NULL_RTX, VOIDmode, 0);
1659 +
1660 + if (fcode == AVR32_BUILTIN_MVRC_W)
1661 + icode = CODE_FOR_mvrcsi;
1662 + else
1663 + icode = CODE_FOR_mvrcdi;
1664 +
1665 + if (!(*insn_data[icode].operand[0].predicate) (op0, SImode))
1666 + {
1667 + error ("Parameter 1 is not a valid coprocessor number.");
1668 + error ("Number should be between 0 and 7.");
1669 + return NULL_RTX;
1670 + }
1671 +
1672 + if (!(*insn_data[icode].operand[1].predicate) (op1, SImode))
1673 + {
1674 + error ("Parameter 2 is not a valid coprocessor register number.");
1675 + error ("Number should be between 0 and 15.");
1676 + return NULL_RTX;
1677 + }
1678 +
1679 + if (GET_CODE (op2) == CONST_INT
1680 + || GET_CODE (op2) == CONST
1681 + || GET_CODE (op2) == SYMBOL_REF || GET_CODE (op2) == LABEL_REF)
1682 + {
1683 + op2 = force_const_mem (insn_data[icode].operand[2].mode, op2);
1684 + }
1685 +
1686 + if (!(*insn_data[icode].operand[2].predicate) (op2, GET_MODE (op2)))
1687 + op2 = copy_to_mode_reg (insn_data[icode].operand[2].mode, op2);
1688 +
1689 +
1690 + pat = GEN_FCN (icode) (op0, op1, op2);
1691 + if (!pat)
1692 + return 0;
1693 + emit_insn (pat);
1694 +
1695 + return NULL_RTX;
1696 + }
1697 + case AVR32_BUILTIN_COP:
1698 + {
1699 + rtx op3, op4;
1700 + tree arg3, arg4;
1701 + icode = CODE_FOR_cop;
1702 + arg0 = TREE_VALUE (arglist);
1703 + arg1 = TREE_VALUE (TREE_CHAIN (arglist));
1704 + arg2 = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
1705 + arg3 = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (arglist))));
1706 + arg4 =
1707 + TREE_VALUE (TREE_CHAIN
1708 + (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (arglist)))));
1709 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
1710 + op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
1711 + op2 = expand_expr (arg2, NULL_RTX, VOIDmode, 0);
1712 + op3 = expand_expr (arg3, NULL_RTX, VOIDmode, 0);
1713 + op4 = expand_expr (arg4, NULL_RTX, VOIDmode, 0);
1714 +
1715 + if (!(*insn_data[icode].operand[0].predicate) (op0, SImode))
1716 + {
1717 + error
1718 + ("Parameter 1 to __builtin_cop is not a valid coprocessor number.");
1719 + error ("Number should be between 0 and 7.");
1720 + return NULL_RTX;
1721 + }
1722 +
1723 + if (!(*insn_data[icode].operand[1].predicate) (op1, SImode))
1724 + {
1725 + error
1726 + ("Parameter 2 to __builtin_cop is not a valid coprocessor register number.");
1727 + error ("Number should be between 0 and 15.");
1728 + return NULL_RTX;
1729 + }
1730 +
1731 + if (!(*insn_data[icode].operand[2].predicate) (op2, SImode))
1732 + {
1733 + error
1734 + ("Parameter 3 to __builtin_cop is not a valid coprocessor register number.");
1735 + error ("Number should be between 0 and 15.");
1736 + return NULL_RTX;
1737 + }
1738 +
1739 + if (!(*insn_data[icode].operand[3].predicate) (op3, SImode))
1740 + {
1741 + error
1742 + ("Parameter 4 to __builtin_cop is not a valid coprocessor register number.");
1743 + error ("Number should be between 0 and 15.");
1744 + return NULL_RTX;
1745 + }
1746 +
1747 + if (!(*insn_data[icode].operand[4].predicate) (op4, SImode))
1748 + {
1749 + error
1750 + ("Parameter 5 to __builtin_cop is not a valid coprocessor operation.");
1751 + error ("Number should be between 0 and 127.");
1752 + return NULL_RTX;
1753 + }
1754 +
1755 + pat = GEN_FCN (icode) (op0, op1, op2, op3, op4);
1756 + if (!pat)
1757 + return 0;
1758 + emit_insn (pat);
1759 +
1760 + return target;
1761 + }
1762 + }
1763 +
1764 + for (i = 0, d = bdesc_2arg; i < ARRAY_SIZE (bdesc_2arg); i++, d++)
1765 + if (d->code == fcode)
1766 + return avr32_expand_binop_builtin (d->icode, arglist, target);
1767 +
1768 +
1769 + /* @@@ Should really do something sensible here. */
1770 + return NULL_RTX;
1771 + }
1772 +
1773 +
1774 +/* Handle an "interrupt" or "isr" attribute;
1775 + arguments as in struct attribute_spec.handler. */
1776 +
1777 +static tree
1778 +avr32_handle_isr_attribute (tree * node, tree name, tree args,
1779 + int flags, bool * no_add_attrs)
1780 + {
1781 + if (DECL_P (*node))
1782 + {
1783 + if (TREE_CODE (*node) != FUNCTION_DECL)
1784 + {
1785 + warning ("`%s' attribute only applies to functions",
1786 + IDENTIFIER_POINTER (name));
1787 + *no_add_attrs = true;
1788 + }
1789 + /* FIXME: the argument if any is checked for type attributes; should it
1790 + be checked for decl ones? */
1791 + }
1792 + else
1793 + {
1794 + if (TREE_CODE (*node) == FUNCTION_TYPE
1795 + || TREE_CODE (*node) == METHOD_TYPE)
1796 + {
1797 + if (avr32_isr_value (args) == AVR32_FT_UNKNOWN)
1798 + {
1799 + warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
1800 + *no_add_attrs = true;
1801 + }
1802 + }
1803 + else if (TREE_CODE (*node) == POINTER_TYPE
1804 + && (TREE_CODE (TREE_TYPE (*node)) == FUNCTION_TYPE
1805 + || TREE_CODE (TREE_TYPE (*node)) == METHOD_TYPE)
1806 + && avr32_isr_value (args) != AVR32_FT_UNKNOWN)
1807 + {
1808 + *node = build_variant_type_copy (*node);
1809 + TREE_TYPE (*node) = build_type_attribute_variant
1810 + (TREE_TYPE (*node),
1811 + tree_cons (name, args, TYPE_ATTRIBUTES (TREE_TYPE (*node))));
1812 + *no_add_attrs = true;
1813 + }
1814 + else
1815 + {
1816 + /* Possibly pass this attribute on from the type to a decl. */
1817 + if (flags & ((int) ATTR_FLAG_DECL_NEXT
1818 + | (int) ATTR_FLAG_FUNCTION_NEXT
1819 + | (int) ATTR_FLAG_ARRAY_NEXT))
1820 + {
1821 + *no_add_attrs = true;
1822 + return tree_cons (name, args, NULL_TREE);
1823 + }
1824 + else
1825 + {
1826 + warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
1827 + }
1828 + }
1829 + }
1830 +
1831 + return NULL_TREE;
1832 + }
1833 +
1834 +/* Handle an attribute requiring a FUNCTION_DECL;
1835 + arguments as in struct attribute_spec.handler. */
1836 +static tree
1837 +avr32_handle_fndecl_attribute (tree * node, tree name,
1838 + tree args ATTRIBUTE_UNUSED,
1839 + int flags ATTRIBUTE_UNUSED,
1840 + bool * no_add_attrs)
1841 + {
1842 + if (TREE_CODE (*node) != FUNCTION_DECL)
1843 + {
1844 + warning ("%qs attribute only applies to functions",
1845 + IDENTIFIER_POINTER (name));
1846 + *no_add_attrs = true;
1847 + }
1848 +
1849 + return NULL_TREE;
1850 + }
1851 +
1852 +
1853 +/* Handle an acall attribute;
1854 + arguments as in struct attribute_spec.handler. */
1855 +
1856 +static tree
1857 +avr32_handle_acall_attribute (tree * node, tree name,
1858 + tree args ATTRIBUTE_UNUSED,
1859 + int flags ATTRIBUTE_UNUSED, bool * no_add_attrs)
1860 + {
1861 + if (TREE_CODE (*node) == FUNCTION_TYPE || TREE_CODE (*node) == METHOD_TYPE)
1862 + {
1863 + warning ("`%s' attribute not yet supported...",
1864 + IDENTIFIER_POINTER (name));
1865 + *no_add_attrs = true;
1866 + return NULL_TREE;
1867 + }
1868 +
1869 + warning ("`%s' attribute only applies to functions",
1870 + IDENTIFIER_POINTER (name));
1871 + *no_add_attrs = true;
1872 + return NULL_TREE;
1873 + }
1874 +
1875 +
1876 +/* Return 0 if the attributes for two types are incompatible, 1 if they
1877 + are compatible, and 2 if they are nearly compatible (which causes a
1878 + warning to be generated). */
1879 +
1880 +static int
1881 +avr32_comp_type_attributes (tree type1, tree type2)
1882 + {
1883 + int acall1, acall2, isr1, isr2, naked1, naked2;
1884 +
1885 + /* Check for mismatch of non-default calling convention. */
1886 + if (TREE_CODE (type1) != FUNCTION_TYPE)
1887 + return 1;
1888 +
1889 + /* Check for mismatched call attributes. */
1890 + acall1 = lookup_attribute ("acall", TYPE_ATTRIBUTES (type1)) != NULL;
1891 + acall2 = lookup_attribute ("acall", TYPE_ATTRIBUTES (type2)) != NULL;
1892 + naked1 = lookup_attribute ("naked", TYPE_ATTRIBUTES (type1)) != NULL;
1893 + naked2 = lookup_attribute ("naked", TYPE_ATTRIBUTES (type2)) != NULL;
1894 + isr1 = lookup_attribute ("isr", TYPE_ATTRIBUTES (type1)) != NULL;
1895 + if (!isr1)
1896 + isr1 = lookup_attribute ("interrupt", TYPE_ATTRIBUTES (type1)) != NULL;
1897 +
1898 + isr2 = lookup_attribute ("isr", TYPE_ATTRIBUTES (type2)) != NULL;
1899 + if (!isr2)
1900 + isr2 = lookup_attribute ("interrupt", TYPE_ATTRIBUTES (type2)) != NULL;
1901 +
1902 + if ((acall1 && isr2)
1903 + || (acall2 && isr1) || (naked1 && isr2) || (naked2 && isr1))
1904 + return 0;
1905 +
1906 + return 1;
1907 + }
1908 +
1909 +
1910 +/* Computes the type of the current function. */
1911 +
1912 +static unsigned long
1913 +avr32_compute_func_type (void)
1914 + {
1915 + unsigned long type = AVR32_FT_UNKNOWN;
1916 + tree a;
1917 + tree attr;
1918 +
1919 + if (TREE_CODE (current_function_decl) != FUNCTION_DECL)
1920 + abort ();
1921 +
1922 + /* Decide if the current function is volatile. Such functions never
1923 + return, and many memory cycles can be saved by not storing register
1924 + values that will never be needed again. This optimization was added to
1925 + speed up context switching in a kernel application. */
1926 + if (optimize > 0
1927 + && TREE_NOTHROW (current_function_decl)
1928 + && TREE_THIS_VOLATILE (current_function_decl))
1929 + type |= AVR32_FT_VOLATILE;
1930 +
1931 + if (cfun->static_chain_decl != NULL)
1932 + type |= AVR32_FT_NESTED;
1933 +
1934 + attr = DECL_ATTRIBUTES (current_function_decl);
1935 +
1936 + a = lookup_attribute ("isr", attr);
1937 + if (a == NULL_TREE)
1938 + a = lookup_attribute ("interrupt", attr);
1939 +
1940 + if (a == NULL_TREE)
1941 + type |= AVR32_FT_NORMAL;
1942 + else
1943 + type |= avr32_isr_value (TREE_VALUE (a));
1944 +
1945 +
1946 + a = lookup_attribute ("acall", attr);
1947 + if (a != NULL_TREE)
1948 + type |= AVR32_FT_ACALL;
1949 +
1950 + a = lookup_attribute ("naked", attr);
1951 + if (a != NULL_TREE)
1952 + type |= AVR32_FT_NAKED;
1953 +
1954 + return type;
1955 + }
1956 +
1957 +/* Returns the type of the current function. */
1958 +
1959 +static unsigned long
1960 +avr32_current_func_type (void)
1961 + {
1962 + if (AVR32_FUNC_TYPE (cfun->machine->func_type) == AVR32_FT_UNKNOWN)
1963 + cfun->machine->func_type = avr32_compute_func_type ();
1964 +
1965 + return cfun->machine->func_type;
1966 + }
1967 +
1968 +/*
1969 + This target hook should return true if we should not pass type solely
1970 + in registers. The file expr.h defines a definition that is usually appropriate,
1971 + refer to expr.h for additional documentation.
1972 + */
1973 +bool
1974 +avr32_must_pass_in_stack (enum machine_mode mode ATTRIBUTE_UNUSED, tree type)
1975 + {
1976 + if (type && AGGREGATE_TYPE_P (type)
1977 + /* If the alignment is less than the size then pass in the struct on
1978 + the stack. */
1979 + && ((unsigned int) TYPE_ALIGN_UNIT (type) <
1980 + (unsigned int) int_size_in_bytes (type))
1981 + /* If we support unaligned word accesses then structs of size 4 and 8
1982 + can have any alignment and still be passed in registers. */
1983 + && !(TARGET_UNALIGNED_WORD
1984 + && (int_size_in_bytes (type) == 4
1985 + || int_size_in_bytes (type) == 8))
1986 + /* Double word structs need only a word alignment. */
1987 + && !(int_size_in_bytes (type) == 8 && TYPE_ALIGN_UNIT (type) >= 4))
1988 + return true;
1989 +
1990 + if (type && AGGREGATE_TYPE_P (type)
1991 + /* Structs of size 3,5,6,7 are always passed in registers. */
1992 + && (int_size_in_bytes (type) == 3
1993 + || int_size_in_bytes (type) == 5
1994 + || int_size_in_bytes (type) == 6 || int_size_in_bytes (type) == 7))
1995 + return true;
1996 +
1997 +
1998 + return (type && TREE_ADDRESSABLE (type));
1999 + }
2000 +
2001 +
2002 +bool
2003 +avr32_strict_argument_naming (CUMULATIVE_ARGS * ca ATTRIBUTE_UNUSED)
2004 + {
2005 + return true;
2006 + }
2007 +
2008 +/*
2009 + This target hook should return true if an argument at the position indicated
2010 + by cum should be passed by reference. This predicate is queried after target
2011 + independent reasons for being passed by reference, such as TREE_ADDRESSABLE (type).
2012 +
2013 + If the hook returns true, a copy of that argument is made in memory and a
2014 + pointer to the argument is passed instead of the argument itself. The pointer
2015 + is passed in whatever way is appropriate for passing a pointer to that type.
2016 + */
2017 +bool
2018 +avr32_pass_by_reference (CUMULATIVE_ARGS * cum ATTRIBUTE_UNUSED,
2019 + enum machine_mode mode ATTRIBUTE_UNUSED,
2020 + tree type, bool named ATTRIBUTE_UNUSED)
2021 + {
2022 + return (type && (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST));
2023 + }
2024 +
2025 +static int
2026 +avr32_arg_partial_bytes (CUMULATIVE_ARGS * pcum ATTRIBUTE_UNUSED,
2027 + enum machine_mode mode ATTRIBUTE_UNUSED,
2028 + tree type ATTRIBUTE_UNUSED,
2029 + bool named ATTRIBUTE_UNUSED)
2030 + {
2031 + return 0;
2032 + }
2033 +
2034 +
2035 +struct gcc_target targetm = TARGET_INITIALIZER;
2036 +
2037 +/*
2038 + Table used to convert from register number in the assembler instructions and
2039 + the register numbers used in gcc.
2040 + */
2041 +const int avr32_function_arg_reglist[] = {
2042 + INTERNAL_REGNUM (12),
2043 + INTERNAL_REGNUM (11),
2044 + INTERNAL_REGNUM (10),
2045 + INTERNAL_REGNUM (9),
2046 + INTERNAL_REGNUM (8)
2047 +};
2048 +
2049 +rtx avr32_compare_op0 = NULL_RTX;
2050 +rtx avr32_compare_op1 = NULL_RTX;
2051 +rtx avr32_compare_operator = NULL_RTX;
2052 +rtx avr32_acc_cache = NULL_RTX;
2053 +
2054 +/*
2055 + Returns nonzero if it is allowed to store a value of mode mode in hard
2056 + register number regno.
2057 + */
2058 +int
2059 +avr32_hard_regno_mode_ok (int regnr, enum machine_mode mode)
2060 + {
2061 + /* We allow only float modes in the fp-registers */
2062 + if (regnr >= FIRST_FP_REGNUM
2063 + && regnr <= LAST_FP_REGNUM && GET_MODE_CLASS (mode) != MODE_FLOAT)
2064 + {
2065 + return 0;
2066 + }
2067 +
2068 + switch (mode)
2069 + {
2070 + case DImode: /* long long */
2071 + case DFmode: /* double */
2072 + case SCmode: /* __complex__ float */
2073 + case CSImode: /* __complex__ int */
2074 + if (regnr < 4)
2075 + { /* long long int not supported in r12, sp, lr
2076 + or pc. */
2077 + return 0;
2078 + }
2079 + else
2080 + {
2081 + if (regnr % 2) /* long long int has to be refered in even
2082 + registers. */
2083 + return 0;
2084 + else
2085 + return 1;
2086 + }
2087 + case CDImode: /* __complex__ long long */
2088 + case DCmode: /* __complex__ double */
2089 + case TImode: /* 16 bytes */
2090 + if (regnr < 7)
2091 + return 0;
2092 + else if (regnr % 2)
2093 + return 0;
2094 + else
2095 + return 1;
2096 + default:
2097 + return 1;
2098 + }
2099 + }
2100 +
2101 +
2102 +int
2103 +avr32_rnd_operands (rtx add, rtx shift)
2104 + {
2105 + if (GET_CODE (shift) == CONST_INT &&
2106 + GET_CODE (add) == CONST_INT && INTVAL (shift) > 0)
2107 + {
2108 + if ((1 << (INTVAL (shift) - 1)) == INTVAL (add))
2109 + return TRUE;
2110 + }
2111 +
2112 + return FALSE;
2113 + }
2114 +
2115 +
2116 +
2117 +int
2118 +avr32_const_ok_for_constraint_p (HOST_WIDE_INT value, char c, const char *str)
2119 + {
2120 + switch (c)
2121 + {
2122 + case 'K':
2123 + case 'I':
2124 + {
2125 + HOST_WIDE_INT min_value = 0, max_value = 0;
2126 + char size_str[3];
2127 + int const_size;
2128 +
2129 + size_str[0] = str[2];
2130 + size_str[1] = str[3];
2131 + size_str[2] = '\0';
2132 + const_size = atoi (size_str);
2133 +
2134 + if (toupper (str[1]) == 'U')
2135 + {
2136 + min_value = 0;
2137 + max_value = (1 << const_size) - 1;
2138 + }
2139 + else if (toupper (str[1]) == 'S')
2140 + {
2141 + min_value = -(1 << (const_size - 1));
2142 + max_value = (1 << (const_size - 1)) - 1;
2143 + }
2144 +
2145 + if (c == 'I')
2146 + {
2147 + value = -value;
2148 + }
2149 +
2150 + if (value >= min_value && value <= max_value)
2151 + {
2152 + return 1;
2153 + }
2154 + break;
2155 + }
2156 + case 'M':
2157 + return avr32_mask_upper_bits_operand (GEN_INT (value), VOIDmode);
2158 + }
2159 +
2160 + return 0;
2161 + }
2162 +
2163 +
2164 +/*Compute mask of which floating-point registers needs saving upon
2165 + entry to this function*/
2166 +static unsigned long
2167 +avr32_compute_save_fp_reg_mask (void)
2168 + {
2169 + unsigned long func_type = avr32_current_func_type ();
2170 + unsigned int save_reg_mask = 0;
2171 + unsigned int reg;
2172 + unsigned int max_reg = 7;
2173 + int save_all_call_used_regs = FALSE;
2174 +
2175 + /* This only applies for hardware floating-point implementation. */
2176 + if (!TARGET_HARD_FLOAT)
2177 + return 0;
2178 +
2179 + if (IS_INTERRUPT (func_type))
2180 + {
2181 +
2182 + /* Interrupt functions must not corrupt any registers, even call
2183 + clobbered ones. If this is a leaf function we can just examine the
2184 + registers used by the RTL, but otherwise we have to assume that
2185 + whatever function is called might clobber anything, and so we have
2186 + to save all the call-clobbered registers as well. */
2187 + max_reg = 13;
2188 + save_all_call_used_regs = !current_function_is_leaf;
2189 + }
2190 +
2191 + /* All used registers used must be saved */
2192 + for (reg = 0; reg <= max_reg; reg++)
2193 + if (regs_ever_live[INTERNAL_FP_REGNUM (reg)]
2194 + || (save_all_call_used_regs
2195 + && call_used_regs[INTERNAL_FP_REGNUM (reg)]))
2196 + save_reg_mask |= (1 << reg);
2197 +
2198 + return save_reg_mask;
2199 + }
2200 +
2201 +/*Compute mask of registers which needs saving upon function entry */
2202 +static unsigned long
2203 +avr32_compute_save_reg_mask (int push)
2204 + {
2205 + unsigned long func_type;
2206 + unsigned int save_reg_mask = 0;
2207 + unsigned int reg;
2208 +
2209 + func_type = avr32_current_func_type ();
2210 +
2211 + if (IS_INTERRUPT (func_type))
2212 + {
2213 + unsigned int max_reg = 12;
2214 +
2215 +
2216 + /* Get the banking scheme for the interrupt */
2217 + switch (func_type)
2218 + {
2219 + case AVR32_FT_ISR_FULL:
2220 + max_reg = 0;
2221 + break;
2222 + case AVR32_FT_ISR_HALF:
2223 + max_reg = 7;
2224 + break;
2225 + case AVR32_FT_ISR_NONE:
2226 + max_reg = 12;
2227 + break;
2228 + }
2229 +
2230 + /* Interrupt functions must not corrupt any registers, even call
2231 + clobbered ones. If this is a leaf function we can just examine the
2232 + registers used by the RTL, but otherwise we have to assume that
2233 + whatever function is called might clobber anything, and so we have
2234 + to save all the call-clobbered registers as well. */
2235 +
2236 + /* Need not push the registers r8-r12 for AVR32A architectures, as this
2237 + is automatially done in hardware. We also do not have any shadow
2238 + registers. */
2239 + if (avr32_arch->uarch_type == UARCH_TYPE_AVR32A)
2240 + {
2241 + max_reg = 7;
2242 + func_type = AVR32_FT_ISR_NONE;
2243 + }
2244 +
2245 + /* All registers which are used and is not shadowed must be saved */
2246 + for (reg = 0; reg <= max_reg; reg++)
2247 + if (regs_ever_live[INTERNAL_REGNUM (reg)]
2248 + || (!current_function_is_leaf
2249 + && call_used_regs[INTERNAL_REGNUM (reg)]))
2250 + save_reg_mask |= (1 << reg);
2251 +
2252 + /* Check LR */
2253 + if ((regs_ever_live[LR_REGNUM]
2254 + || !current_function_is_leaf || frame_pointer_needed)
2255 + /* Only non-shadowed register models */
2256 + && (func_type == AVR32_FT_ISR_NONE))
2257 + save_reg_mask |= (1 << ASM_REGNUM (LR_REGNUM));
2258 +
2259 + /* Make sure that the GOT register is pushed. */
2260 + if (max_reg >= ASM_REGNUM (PIC_OFFSET_TABLE_REGNUM)
2261 + && current_function_uses_pic_offset_table)
2262 + save_reg_mask |= (1 << ASM_REGNUM (PIC_OFFSET_TABLE_REGNUM));
2263 +
2264 + }
2265 + else
2266 + {
2267 + int use_pushm = optimize_size;
2268 +
2269 + /* In the normal case we only need to save those registers which are
2270 + call saved and which are used by this function. */
2271 + for (reg = 0; reg <= 7; reg++)
2272 + if (regs_ever_live[INTERNAL_REGNUM (reg)]
2273 + && !call_used_regs[INTERNAL_REGNUM (reg)])
2274 + save_reg_mask |= (1 << reg);
2275 +
2276 + /* Make sure that the GOT register is pushed. */
2277 + if (current_function_uses_pic_offset_table)
2278 + save_reg_mask |= (1 << ASM_REGNUM (PIC_OFFSET_TABLE_REGNUM));
2279 +
2280 +
2281 + /* If we optimize for size and do not have anonymous arguments: use
2282 + popm/pushm always */
2283 + if (use_pushm)
2284 + {
2285 + if ((save_reg_mask & (1 << 0))
2286 + || (save_reg_mask & (1 << 1))
2287 + || (save_reg_mask & (1 << 2)) || (save_reg_mask & (1 << 3)))
2288 + save_reg_mask |= 0xf;
2289 +
2290 + if ((save_reg_mask & (1 << 4))
2291 + || (save_reg_mask & (1 << 5))
2292 + || (save_reg_mask & (1 << 6)) || (save_reg_mask & (1 << 7)))
2293 + save_reg_mask |= 0xf0;
2294 +
2295 + if ((save_reg_mask & (1 << 8)) || (save_reg_mask & (1 << 9)))
2296 + save_reg_mask |= 0x300;
2297 + }
2298 +
2299 +
2300 + /* Check LR */
2301 + if ((regs_ever_live[LR_REGNUM]
2302 + || !current_function_is_leaf
2303 + || (optimize_size
2304 + && save_reg_mask
2305 + && !current_function_calls_eh_return) || frame_pointer_needed))
2306 + {
2307 + if (push
2308 + /* Never pop LR into PC for functions which
2309 + calls __builtin_eh_return, since we need to
2310 + fix the SP after the restoring of the registers
2311 + and before returning. */
2312 + || current_function_calls_eh_return)
2313 + {
2314 + /* Push/Pop LR */
2315 + save_reg_mask |= (1 << ASM_REGNUM (LR_REGNUM));
2316 + }
2317 + else
2318 + {
2319 + /* Pop PC */
2320 + save_reg_mask |= (1 << ASM_REGNUM (PC_REGNUM));
2321 + }
2322 + }
2323 + }
2324 +
2325 +
2326 + /* Save registers so the exception handler can modify them. */
2327 + if (current_function_calls_eh_return)
2328 + {
2329 + unsigned int i;
2330 +
2331 + for (i = 0;; i++)
2332 + {
2333 + reg = EH_RETURN_DATA_REGNO (i);
2334 + if (reg == INVALID_REGNUM)
2335 + break;
2336 + save_reg_mask |= 1 << ASM_REGNUM (reg);
2337 + }
2338 + }
2339 +
2340 + return save_reg_mask;
2341 + }
2342 +
2343 +/*Compute total size in bytes of all saved registers */
2344 +static int
2345 +avr32_get_reg_mask_size (int reg_mask)
2346 + {
2347 + int reg, size;
2348 + size = 0;
2349 +
2350 + for (reg = 0; reg <= 15; reg++)
2351 + if (reg_mask & (1 << reg))
2352 + size += 4;
2353 +
2354 + return size;
2355 + }
2356 +
2357 +/*Get a register from one of the registers which are saved onto the stack
2358 + upon function entry */
2359 +
2360 +static int
2361 +avr32_get_saved_reg (int save_reg_mask)
2362 + {
2363 + unsigned int reg;
2364 +
2365 + /* Find the first register which is saved in the saved_reg_mask */
2366 + for (reg = 0; reg <= 15; reg++)
2367 + if (save_reg_mask & (1 << reg))
2368 + return reg;
2369 +
2370 + return -1;
2371 + }
2372 +
2373 +/* Return 1 if it is possible to return using a single instruction. */
2374 +int
2375 +avr32_use_return_insn (int iscond)
2376 + {
2377 + unsigned int func_type = avr32_current_func_type ();
2378 + unsigned long saved_int_regs;
2379 + unsigned long saved_fp_regs;
2380 +
2381 + /* Never use a return instruction before reload has run. */
2382 + if (!reload_completed)
2383 + return 0;
2384 +
2385 + /* Must adjust the stack for vararg functions. */
2386 + if (current_function_args_info.uses_anonymous_args)
2387 + return 0;
2388 +
2389 + /* If there a stack adjstment. */
2390 + if (get_frame_size ())
2391 + return 0;
2392 +
2393 + saved_int_regs = avr32_compute_save_reg_mask (TRUE);
2394 + saved_fp_regs = avr32_compute_save_fp_reg_mask ();
2395 +
2396 + /* Functions which have saved fp-regs on the stack can not be performed in
2397 + one instruction */
2398 + if (saved_fp_regs)
2399 + return 0;
2400 +
2401 + /* Conditional returns can not be performed in one instruction if we need
2402 + to restore registers from the stack */
2403 + if (iscond && saved_int_regs)
2404 + return 0;
2405 +
2406 + /* Conditional return can not be used for interrupt handlers. */
2407 + if (iscond && IS_INTERRUPT (func_type))
2408 + return 0;
2409 +
2410 + /* For interrupt handlers which needs to pop registers */
2411 + if (saved_int_regs && IS_INTERRUPT (func_type))
2412 + return 0;
2413 +
2414 +
2415 + /* If there are saved registers but the LR isn't saved, then we need two
2416 + instructions for the return. */
2417 + if (saved_int_regs && !(saved_int_regs & (1 << ASM_REGNUM (LR_REGNUM))))
2418 + return 0;
2419 +
2420 +
2421 + return 1;
2422 + }
2423 +
2424 +
2425 +/*Generate some function prologue info in the assembly file*/
2426 +
2427 +void
2428 +avr32_target_asm_function_prologue (FILE * f, HOST_WIDE_INT frame_size)
2429 + {
2430 + if (IS_NAKED (avr32_current_func_type ()))
2431 + fprintf (f,
2432 + "\t# Function is naked: Prologue and epilogue provided by programmer\n");
2433 +
2434 + if (IS_INTERRUPT (avr32_current_func_type ()))
2435 + {
2436 + switch (avr32_current_func_type ())
2437 + {
2438 + case AVR32_FT_ISR_FULL:
2439 + fprintf (f,
2440 + "\t# Interrupt Function: Fully shadowed register file\n");
2441 + break;
2442 + case AVR32_FT_ISR_HALF:
2443 + fprintf (f,
2444 + "\t# Interrupt Function: Half shadowed register file\n");
2445 + break;
2446 + default:
2447 + case AVR32_FT_ISR_NONE:
2448 + fprintf (f, "\t# Interrupt Function: No shadowed register file\n");
2449 + break;
2450 + }
2451 + }
2452 +
2453 +
2454 + fprintf (f, "\t# args = %i, frame = %li, pretend = %i\n",
2455 + current_function_args_size, frame_size,
2456 + current_function_pretend_args_size);
2457 +
2458 + fprintf (f, "\t# frame_needed = %i, leaf_function = %i\n",
2459 + frame_pointer_needed, current_function_is_leaf);
2460 +
2461 + fprintf (f, "\t# uses_anonymous_args = %i\n",
2462 + current_function_args_info.uses_anonymous_args);
2463 + if (current_function_calls_eh_return)
2464 + fprintf (f, "\t# Calls __builtin_eh_return.\n");
2465 +
2466 + }
2467 +
2468 +
2469 +/* Generate and emit an insn that we will recognize as a pushm or stm.
2470 + Unfortunately, since this insn does not reflect very well the actual
2471 + semantics of the operation, we need to annotate the insn for the benefit
2472 + of DWARF2 frame unwind information. */
2473 +
2474 +int avr32_convert_to_reglist16 (int reglist8_vect);
2475 +
2476 +static rtx
2477 +emit_multi_reg_push (int reglist, int usePUSHM)
2478 + {
2479 + rtx insn;
2480 + rtx dwarf;
2481 + rtx tmp;
2482 + rtx reg;
2483 + int i;
2484 + int nr_regs;
2485 + int index = 0;
2486 +
2487 + if (usePUSHM)
2488 + {
2489 + insn = emit_insn (gen_pushm (gen_rtx_CONST_INT (SImode, reglist)));
2490 + reglist = avr32_convert_to_reglist16 (reglist);
2491 + }
2492 + else
2493 + {
2494 + insn = emit_insn (gen_stm (stack_pointer_rtx,
2495 + gen_rtx_CONST_INT (SImode, reglist),
2496 + gen_rtx_CONST_INT (SImode, 1)));
2497 + }
2498 +
2499 + nr_regs = avr32_get_reg_mask_size (reglist) / 4;
2500 + dwarf = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (nr_regs + 1));
2501 +
2502 + for (i = 15; i >= 0; i--)
2503 + {
2504 + if (reglist & (1 << i))
2505 + {
2506 + reg = gen_rtx_REG (SImode, INTERNAL_REGNUM (i));
2507 + tmp = gen_rtx_SET (VOIDmode,
2508 + gen_rtx_MEM (SImode,
2509 + plus_constant (stack_pointer_rtx,
2510 + 4 * index)), reg);
2511 + RTX_FRAME_RELATED_P (tmp) = 1;
2512 + XVECEXP (dwarf, 0, 1 + index++) = tmp;
2513 + }
2514 + }
2515 +
2516 + tmp = gen_rtx_SET (SImode,
2517 + stack_pointer_rtx,
2518 + gen_rtx_PLUS (SImode,
2519 + stack_pointer_rtx,
2520 + GEN_INT (-4 * nr_regs)));
2521 + RTX_FRAME_RELATED_P (tmp) = 1;
2522 + XVECEXP (dwarf, 0, 0) = tmp;
2523 + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR, dwarf,
2524 + REG_NOTES (insn));
2525 + return insn;
2526 + }
2527 +
2528 +
2529 +static rtx
2530 +emit_multi_fp_reg_push (int reglist)
2531 + {
2532 + rtx insn;
2533 + rtx dwarf;
2534 + rtx tmp;
2535 + rtx reg;
2536 + int i;
2537 + int nr_regs;
2538 + int index = 0;
2539 +
2540 + insn = emit_insn (gen_stm_fp (stack_pointer_rtx,
2541 + gen_rtx_CONST_INT (SImode, reglist),
2542 + gen_rtx_CONST_INT (SImode, 1)));
2543 +
2544 + nr_regs = avr32_get_reg_mask_size (reglist) / 4;
2545 + dwarf = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (nr_regs + 1));
2546 +
2547 + for (i = 15; i >= 0; i--)
2548 + {
2549 + if (reglist & (1 << i))
2550 + {
2551 + reg = gen_rtx_REG (SImode, INTERNAL_FP_REGNUM (i));
2552 + tmp = gen_rtx_SET (VOIDmode,
2553 + gen_rtx_MEM (SImode,
2554 + plus_constant (stack_pointer_rtx,
2555 + 4 * index)), reg);
2556 + RTX_FRAME_RELATED_P (tmp) = 1;
2557 + XVECEXP (dwarf, 0, 1 + index++) = tmp;
2558 + }
2559 + }
2560 +
2561 + tmp = gen_rtx_SET (SImode,
2562 + stack_pointer_rtx,
2563 + gen_rtx_PLUS (SImode,
2564 + stack_pointer_rtx,
2565 + GEN_INT (-4 * nr_regs)));
2566 + RTX_FRAME_RELATED_P (tmp) = 1;
2567 + XVECEXP (dwarf, 0, 0) = tmp;
2568 + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR, dwarf,
2569 + REG_NOTES (insn));
2570 + return insn;
2571 + }
2572 +
2573 +rtx
2574 +avr32_gen_load_multiple (rtx * regs, int count, rtx from,
2575 + int write_back, int in_struct_p, int scalar_p)
2576 + {
2577 +
2578 + rtx result;
2579 + int i = 0, j;
2580 +
2581 + result =
2582 + gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + (write_back ? 1 : 0)));
2583 +
2584 + if (write_back)
2585 + {
2586 + XVECEXP (result, 0, 0)
2587 + = gen_rtx_SET (GET_MODE (from), from,
2588 + plus_constant (from, count * 4));
2589 + i = 1;
2590 + count++;
2591 + }
2592 +
2593 +
2594 + for (j = 0; i < count; i++, j++)
2595 + {
2596 + rtx unspec;
2597 + rtx mem = gen_rtx_MEM (SImode, plus_constant (from, j * 4));
2598 + MEM_IN_STRUCT_P (mem) = in_struct_p;
2599 + MEM_SCALAR_P (mem) = scalar_p;
2600 + unspec = gen_rtx_UNSPEC (VOIDmode, gen_rtvec (1, mem), UNSPEC_LDM);
2601 + XVECEXP (result, 0, i) = gen_rtx_SET (VOIDmode, regs[j], unspec);
2602 + }
2603 +
2604 + return result;
2605 + }
2606 +
2607 +
2608 +rtx
2609 +avr32_gen_store_multiple (rtx * regs, int count, rtx to,
2610 + int in_struct_p, int scalar_p)
2611 + {
2612 + rtx result;
2613 + int i = 0, j;
2614 +
2615 + result = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2616 +
2617 + for (j = 0; i < count; i++, j++)
2618 + {
2619 + rtx mem = gen_rtx_MEM (SImode, plus_constant (to, j * 4));
2620 + MEM_IN_STRUCT_P (mem) = in_struct_p;
2621 + MEM_SCALAR_P (mem) = scalar_p;
2622 + XVECEXP (result, 0, i)
2623 + = gen_rtx_SET (VOIDmode, mem,
2624 + gen_rtx_UNSPEC (VOIDmode,
2625 + gen_rtvec (1, regs[j]),
2626 + UNSPEC_STORE_MULTIPLE));
2627 + }
2628 +
2629 + return result;
2630 + }
2631 +
2632 +
2633 +/* Move a block of memory if it is word aligned or we support unaligned
2634 + word memory accesses. The size must be maximum 64 bytes. */
2635 +
2636 +int
2637 +avr32_gen_movmemsi (rtx * operands)
2638 + {
2639 + HOST_WIDE_INT bytes_to_go;
2640 + rtx src, dst;
2641 + rtx st_src, st_dst;
2642 + int ptr_offset = 0;
2643 + int block_size;
2644 + int dst_in_struct_p, src_in_struct_p;
2645 + int dst_scalar_p, src_scalar_p;
2646 + int unaligned;
2647 +
2648 + if (GET_CODE (operands[2]) != CONST_INT
2649 + || GET_CODE (operands[3]) != CONST_INT
2650 + || INTVAL (operands[2]) > 64
2651 + || ((INTVAL (operands[3]) & 3) && !TARGET_UNALIGNED_WORD))
2652 + return 0;
2653 +
2654 + unaligned = (INTVAL (operands[3]) & 3) != 0;
2655 +
2656 + block_size = 4;
2657 +
2658 + st_dst = XEXP (operands[0], 0);
2659 + st_src = XEXP (operands[1], 0);
2660 +
2661 + dst_in_struct_p = MEM_IN_STRUCT_P (operands[0]);
2662 + dst_scalar_p = MEM_SCALAR_P (operands[0]);
2663 + src_in_struct_p = MEM_IN_STRUCT_P (operands[1]);
2664 + src_scalar_p = MEM_SCALAR_P (operands[1]);
2665 +
2666 + dst = copy_to_mode_reg (SImode, st_dst);
2667 + src = copy_to_mode_reg (SImode, st_src);
2668 +
2669 + bytes_to_go = INTVAL (operands[2]);
2670 +
2671 + while (bytes_to_go)
2672 + {
2673 + enum machine_mode move_mode;
2674 + /* (Seems to be a problem with reloads for the movti pattern so this is
2675 + disabled until that problem is resolved)
2676 + UPDATE: Problem seems to be solved now.... */
2677 + if (bytes_to_go >= GET_MODE_SIZE (TImode) && !unaligned
2678 + /* Do not emit ldm/stm for UC3 as ld.d/st.d is more optimal. */
2679 + && avr32_arch->arch_type != ARCH_TYPE_AVR32_UC)
2680 + move_mode = TImode;
2681 + else if ((bytes_to_go >= GET_MODE_SIZE (DImode)) && !unaligned)
2682 + move_mode = DImode;
2683 + else if (bytes_to_go >= GET_MODE_SIZE (SImode))
2684 + move_mode = SImode;
2685 + else
2686 + move_mode = QImode;
2687 +
2688 + {
2689 + rtx dst_mem = gen_rtx_MEM (move_mode,
2690 + gen_rtx_PLUS (SImode, dst,
2691 + GEN_INT (ptr_offset)));
2692 + rtx src_mem = gen_rtx_MEM (move_mode,
2693 + gen_rtx_PLUS (SImode, src,
2694 + GEN_INT (ptr_offset)));
2695 + ptr_offset += GET_MODE_SIZE (move_mode);
2696 + bytes_to_go -= GET_MODE_SIZE (move_mode);
2697 +
2698 + MEM_IN_STRUCT_P (dst_mem) = dst_in_struct_p;
2699 + MEM_SCALAR_P (dst_mem) = dst_scalar_p;
2700 +
2701 + MEM_IN_STRUCT_P (src_mem) = src_in_struct_p;
2702 + MEM_SCALAR_P (src_mem) = src_scalar_p;
2703 + emit_move_insn (dst_mem, src_mem);
2704 +
2705 + }
2706 + }
2707 +
2708 + return 1;
2709 + }
2710 +
2711 +
2712 +
2713 +/*Expand the prologue instruction*/
2714 +void
2715 +avr32_expand_prologue (void)
2716 + {
2717 + rtx insn, dwarf;
2718 + unsigned long saved_reg_mask, saved_fp_reg_mask;
2719 + int reglist8 = 0;
2720 +
2721 + /* Naked functions does not have a prologue */
2722 + if (IS_NAKED (avr32_current_func_type ()))
2723 + return;
2724 +
2725 + saved_reg_mask = avr32_compute_save_reg_mask (TRUE);
2726 +
2727 + if (saved_reg_mask)
2728 + {
2729 + /* Must push used registers */
2730 +
2731 + /* Should we use POPM or LDM? */
2732 + int usePUSHM = TRUE;
2733 + reglist8 = 0;
2734 + if (((saved_reg_mask & (1 << 0)) ||
2735 + (saved_reg_mask & (1 << 1)) ||
2736 + (saved_reg_mask & (1 << 2)) || (saved_reg_mask & (1 << 3))))
2737 + {
2738 + /* One of R0-R3 should at least be pushed */
2739 + if (((saved_reg_mask & (1 << 0)) &&
2740 + (saved_reg_mask & (1 << 1)) &&
2741 + (saved_reg_mask & (1 << 2)) && (saved_reg_mask & (1 << 3))))
2742 + {
2743 + /* All should be pushed */
2744 + reglist8 |= 0x01;
2745 + }
2746 + else
2747 + {
2748 + usePUSHM = FALSE;
2749 + }
2750 + }
2751 +
2752 + if (((saved_reg_mask & (1 << 4)) ||
2753 + (saved_reg_mask & (1 << 5)) ||
2754 + (saved_reg_mask & (1 << 6)) || (saved_reg_mask & (1 << 7))))
2755 + {
2756 + /* One of R4-R7 should at least be pushed */
2757 + if (((saved_reg_mask & (1 << 4)) &&
2758 + (saved_reg_mask & (1 << 5)) &&
2759 + (saved_reg_mask & (1 << 6)) && (saved_reg_mask & (1 << 7))))
2760 + {
2761 + if (usePUSHM)
2762 + /* All should be pushed */
2763 + reglist8 |= 0x02;
2764 + }
2765 + else
2766 + {
2767 + usePUSHM = FALSE;
2768 + }
2769 + }
2770 +
2771 + if (((saved_reg_mask & (1 << 8)) || (saved_reg_mask & (1 << 9))))
2772 + {
2773 + /* One of R8-R9 should at least be pushed */
2774 + if (((saved_reg_mask & (1 << 8)) && (saved_reg_mask & (1 << 9))))
2775 + {
2776 + if (usePUSHM)
2777 + /* All should be pushed */
2778 + reglist8 |= 0x04;
2779 + }
2780 + else
2781 + {
2782 + usePUSHM = FALSE;
2783 + }
2784 + }
2785 +
2786 + if (saved_reg_mask & (1 << 10))
2787 + reglist8 |= 0x08;
2788 +
2789 + if (saved_reg_mask & (1 << 11))
2790 + reglist8 |= 0x10;
2791 +
2792 + if (saved_reg_mask & (1 << 12))
2793 + reglist8 |= 0x20;
2794 +
2795 + if (saved_reg_mask & (1 << ASM_REGNUM (LR_REGNUM)))
2796 + {
2797 + /* Push LR */
2798 + reglist8 |= 0x40;
2799 + }
2800 +
2801 + if (usePUSHM)
2802 + {
2803 + insn = emit_multi_reg_push (reglist8, TRUE);
2804 + }
2805 + else
2806 + {
2807 + insn = emit_multi_reg_push (saved_reg_mask, FALSE);
2808 + }
2809 + RTX_FRAME_RELATED_P (insn) = 1;
2810 +
2811 + /* Prevent this instruction from being scheduled after any other
2812 + instructions. */
2813 + emit_insn (gen_blockage ());
2814 + }
2815 +
2816 + saved_fp_reg_mask = avr32_compute_save_fp_reg_mask ();
2817 + if (saved_fp_reg_mask)
2818 + {
2819 + insn = emit_multi_fp_reg_push (saved_fp_reg_mask);
2820 + RTX_FRAME_RELATED_P (insn) = 1;
2821 +
2822 + /* Prevent this instruction from being scheduled after any other
2823 + instructions. */
2824 + emit_insn (gen_blockage ());
2825 + }
2826 +
2827 + /* Set frame pointer */
2828 + if (frame_pointer_needed)
2829 + {
2830 + insn = emit_move_insn (frame_pointer_rtx, stack_pointer_rtx);
2831 + RTX_FRAME_RELATED_P (insn) = 1;
2832 + }
2833 +
2834 + if (get_frame_size () > 0)
2835 + {
2836 + if (avr32_const_ok_for_constraint_p (get_frame_size (), 'K', "Ks21"))
2837 + {
2838 + insn = emit_insn (gen_rtx_SET (SImode,
2839 + stack_pointer_rtx,
2840 + gen_rtx_PLUS (SImode,
2841 + stack_pointer_rtx,
2842 + gen_rtx_CONST_INT
2843 + (SImode,
2844 + -get_frame_size
2845 + ()))));
2846 + RTX_FRAME_RELATED_P (insn) = 1;
2847 + }
2848 + else
2849 + {
2850 + /* Immediate is larger than k21 We must either check if we can use
2851 + one of the pushed reegisters as temporary storage or we must
2852 + make us a temp register by pushing a register to the stack. */
2853 + rtx temp_reg, const_pool_entry, insn;
2854 + if (saved_reg_mask)
2855 + {
2856 + temp_reg =
2857 + gen_rtx_REG (SImode,
2858 + INTERNAL_REGNUM (avr32_get_saved_reg
2859 + (saved_reg_mask)));
2860 + }
2861 + else
2862 + {
2863 + temp_reg = gen_rtx_REG (SImode, INTERNAL_REGNUM (7));
2864 + emit_move_insn (gen_rtx_MEM
2865 + (SImode,
2866 + gen_rtx_PRE_DEC (SImode, stack_pointer_rtx)),
2867 + temp_reg);
2868 + }
2869 +
2870 + const_pool_entry =
2871 + force_const_mem (SImode,
2872 + gen_rtx_CONST_INT (SImode, get_frame_size ()));
2873 + emit_move_insn (temp_reg, const_pool_entry);
2874 +
2875 + insn = emit_insn (gen_rtx_SET (SImode,
2876 + stack_pointer_rtx,
2877 + gen_rtx_MINUS (SImode,
2878 + stack_pointer_rtx,
2879 + temp_reg)));
2880 +
2881 + dwarf = gen_rtx_SET (VOIDmode, stack_pointer_rtx,
2882 + gen_rtx_PLUS (SImode, stack_pointer_rtx,
2883 + GEN_INT (-get_frame_size ())));
2884 + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
2885 + dwarf, REG_NOTES (insn));
2886 + RTX_FRAME_RELATED_P (insn) = 1;
2887 +
2888 + if (!saved_reg_mask)
2889 + {
2890 + insn =
2891 + emit_move_insn (temp_reg,
2892 + gen_rtx_MEM (SImode,
2893 + gen_rtx_POST_INC (SImode,
2894 + gen_rtx_REG
2895 + (SImode,
2896 + 13))));
2897 + }
2898 +
2899 + /* Mark the temp register as dead */
2900 + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_DEAD, temp_reg,
2901 + REG_NOTES (insn));
2902 +
2903 +
2904 + }
2905 +
2906 + /* Prevent the the stack adjustment to be scheduled after any
2907 + instructions using the frame pointer. */
2908 + emit_insn (gen_blockage ());
2909 + }
2910 +
2911 + /* Load GOT */
2912 + if (flag_pic)
2913 + {
2914 + avr32_load_pic_register ();
2915 +
2916 + /* gcc does not know that load or call instructions might use the pic
2917 + register so it might schedule these instructions before the loading
2918 + of the pic register. To avoid this emit a barrier for now. TODO!
2919 + Find out a better way to let gcc know which instructions might use
2920 + the pic register. */
2921 + emit_insn (gen_blockage ());
2922 + }
2923 + return;
2924 + }
2925 +
2926 +void
2927 +avr32_set_return_address (rtx source, rtx scratch)
2928 + {
2929 + rtx addr;
2930 + unsigned long saved_regs;
2931 +
2932 + saved_regs = avr32_compute_save_reg_mask (TRUE);
2933 +
2934 + if (!(saved_regs & (1 << ASM_REGNUM (LR_REGNUM))))
2935 + emit_move_insn (gen_rtx_REG (Pmode, LR_REGNUM), source);
2936 + else
2937 + {
2938 + if (frame_pointer_needed)
2939 + addr = gen_rtx_REG (Pmode, FRAME_POINTER_REGNUM);
2940 + else
2941 + if (avr32_const_ok_for_constraint_p (get_frame_size (), 'K', "Ks16"))
2942 + {
2943 + addr = plus_constant (stack_pointer_rtx, get_frame_size ());
2944 + }
2945 + else
2946 + {
2947 + emit_insn (gen_movsi (scratch, GEN_INT (get_frame_size ())));
2948 + addr = scratch;
2949 + }
2950 + emit_move_insn (gen_rtx_MEM (Pmode, addr), source);
2951 + }
2952 + }
2953 +
2954 +
2955 +
2956 +/* Return the length of INSN. LENGTH is the initial length computed by
2957 + attributes in the machine-description file. */
2958 +
2959 +int
2960 +avr32_adjust_insn_length (rtx insn ATTRIBUTE_UNUSED,
2961 + int length ATTRIBUTE_UNUSED)
2962 + {
2963 + return length;
2964 + }
2965 +
2966 +void
2967 +avr32_output_return_instruction (int single_ret_inst ATTRIBUTE_UNUSED,
2968 + int iscond ATTRIBUTE_UNUSED,
2969 + rtx cond ATTRIBUTE_UNUSED, rtx r12_imm)
2970 + {
2971 +
2972 + unsigned long saved_reg_mask, saved_fp_reg_mask;
2973 + int insert_ret = TRUE;
2974 + int reglist8 = 0;
2975 + int stack_adjustment = get_frame_size ();
2976 + unsigned int func_type = avr32_current_func_type ();
2977 + FILE *f = asm_out_file;
2978 +
2979 + /* Naked functions does not have an epilogue */
2980 + if (IS_NAKED (func_type))
2981 + return;
2982 +
2983 + saved_fp_reg_mask = avr32_compute_save_fp_reg_mask ();
2984 +
2985 + saved_reg_mask = avr32_compute_save_reg_mask (FALSE);
2986 +
2987 + /* Reset frame pointer */
2988 + if (stack_adjustment > 0)
2989 + {
2990 + if (avr32_const_ok_for_constraint_p (stack_adjustment, 'I', "Is21"))
2991 + {
2992 + fprintf (f, "\tsub\tsp, %i # Reset Frame Pointer\n",
2993 + -stack_adjustment);
2994 + }
2995 + else
2996 + {
2997 + /* TODO! Is it safe to use r8 as scratch?? */
2998 + fprintf (f, "\tmov\tr8, lo(%i) # Reset Frame Pointer\n",
2999 + -stack_adjustment);
3000 + fprintf (f, "\torh\tr8, hi(%i) # Reset Frame Pointer\n",
3001 + -stack_adjustment);
3002 + fprintf (f, "\tadd\tsp, r8 # Reset Frame Pointer\n");
3003 + }
3004 + }
3005 +
3006 + if (saved_fp_reg_mask)
3007 + {
3008 + char reglist[64]; /* 64 bytes should be enough... */
3009 + avr32_make_fp_reglist_w (saved_fp_reg_mask, (char *) reglist);
3010 + fprintf (f, "\tldcm.w\tcp0, sp++, %s\n", reglist);
3011 + if (saved_fp_reg_mask & ~0xff)
3012 + {
3013 + saved_fp_reg_mask &= ~0xff;
3014 + avr32_make_fp_reglist_d (saved_fp_reg_mask, (char *) reglist);
3015 + fprintf (f, "\tldcm.d\tcp0, sp++, %s\n", reglist);
3016 + }
3017 + }
3018 +
3019 + if (saved_reg_mask)
3020 + {
3021 + /* Must pop used registers */
3022 +
3023 + /* Should we use POPM or LDM? */
3024 + int usePOPM = TRUE;
3025 + if (((saved_reg_mask & (1 << 0)) ||
3026 + (saved_reg_mask & (1 << 1)) ||
3027 + (saved_reg_mask & (1 << 2)) || (saved_reg_mask & (1 << 3))))
3028 + {
3029 + /* One of R0-R3 should at least be popped */
3030 + if (((saved_reg_mask & (1 << 0)) &&
3031 + (saved_reg_mask & (1 << 1)) &&
3032 + (saved_reg_mask & (1 << 2)) && (saved_reg_mask & (1 << 3))))
3033 + {
3034 + /* All should be popped */
3035 + reglist8 |= 0x01;
3036 + }
3037 + else
3038 + {
3039 + usePOPM = FALSE;
3040 + }
3041 + }
3042 +
3043 + if (((saved_reg_mask & (1 << 4)) ||
3044 + (saved_reg_mask & (1 << 5)) ||
3045 + (saved_reg_mask & (1 << 6)) || (saved_reg_mask & (1 << 7))))
3046 + {
3047 + /* One of R0-R3 should at least be popped */
3048 + if (((saved_reg_mask & (1 << 4)) &&
3049 + (saved_reg_mask & (1 << 5)) &&
3050 + (saved_reg_mask & (1 << 6)) && (saved_reg_mask & (1 << 7))))
3051 + {
3052 + if (usePOPM)
3053 + /* All should be popped */
3054 + reglist8 |= 0x02;
3055 + }
3056 + else
3057 + {
3058 + usePOPM = FALSE;
3059 + }
3060 + }
3061 +
3062 + if (((saved_reg_mask & (1 << 8)) || (saved_reg_mask & (1 << 9))))
3063 + {
3064 + /* One of R8-R9 should at least be pushed */
3065 + if (((saved_reg_mask & (1 << 8)) && (saved_reg_mask & (1 << 9))))
3066 + {
3067 + if (usePOPM)
3068 + /* All should be pushed */
3069 + reglist8 |= 0x04;
3070 + }
3071 + else
3072 + {
3073 + usePOPM = FALSE;
3074 + }
3075 + }
3076 +
3077 + if (saved_reg_mask & (1 << 10))
3078 + reglist8 |= 0x08;
3079 +
3080 + if (saved_reg_mask & (1 << 11))
3081 + reglist8 |= 0x10;
3082 +
3083 + if (saved_reg_mask & (1 << 12))
3084 + reglist8 |= 0x20;
3085 +
3086 + if (saved_reg_mask & (1 << ASM_REGNUM (LR_REGNUM)))
3087 + /* Pop LR */
3088 + reglist8 |= 0x40;
3089 +
3090 + if (saved_reg_mask & (1 << ASM_REGNUM (PC_REGNUM)))
3091 + /* Pop LR into PC. */
3092 + reglist8 |= 0x80;
3093 +
3094 + if (usePOPM)
3095 + {
3096 + char reglist[64]; /* 64 bytes should be enough... */
3097 + avr32_make_reglist8 (reglist8, (char *) reglist);
3098 +
3099 + if (reglist8 & 0x80)
3100 + /* This instruction is also a return */
3101 + insert_ret = FALSE;
3102 +
3103 + if (r12_imm && !insert_ret)
3104 + fprintf (f, "\tpopm\t%s, r12=%li\n", reglist, INTVAL (r12_imm));
3105 + else
3106 + fprintf (f, "\tpopm\t%s\n", reglist);
3107 +
3108 + }
3109 + else
3110 + {
3111 + char reglist[64]; /* 64 bytes should be enough... */
3112 + avr32_make_reglist16 (saved_reg_mask, (char *) reglist);
3113 + if (saved_reg_mask & (1 << ASM_REGNUM (PC_REGNUM)))
3114 + /* This instruction is also a return */
3115 + insert_ret = FALSE;
3116 +
3117 + if (r12_imm && !insert_ret)
3118 + fprintf (f, "\tldm\tsp++, %s, r12=%li\n", reglist,
3119 + INTVAL (r12_imm));
3120 + else
3121 + fprintf (f, "\tldm\tsp++, %s\n", reglist);
3122 +
3123 + }
3124 +
3125 + }
3126 +
3127 + /* Stack adjustment for exception handler. */
3128 + if (current_function_calls_eh_return)
3129 + fprintf (f, "\tadd\tsp, r%d\n", ASM_REGNUM (EH_RETURN_STACKADJ_REGNO));
3130 +
3131 +
3132 + if (IS_INTERRUPT (func_type))
3133 + {
3134 + fprintf (f, "\trete\n");
3135 + }
3136 + else if (insert_ret)
3137 + {
3138 + if (r12_imm)
3139 + fprintf (f, "\tretal\t%li\n", INTVAL (r12_imm));
3140 + else
3141 + fprintf (f, "\tretal\tr12\n");
3142 + }
3143 + }
3144 +
3145 +/* Function for converting a fp-register mask to a
3146 + reglistCPD8 register list string. */
3147 +void
3148 +avr32_make_fp_reglist_d (int reglist_mask, char *reglist_string)
3149 + {
3150 + int i;
3151 +
3152 + /* Make sure reglist_string is empty */
3153 + reglist_string[0] = '\0';
3154 +
3155 + for (i = 0; i < NUM_FP_REGS; i += 2)
3156 + {
3157 + if (reglist_mask & (1 << i))
3158 + {
3159 + strlen (reglist_string) ?
3160 + sprintf (reglist_string, "%s, %s-%s", reglist_string,
3161 + reg_names[INTERNAL_FP_REGNUM (i)],
3162 + reg_names[INTERNAL_FP_REGNUM (i + 1)]) :
3163 + sprintf (reglist_string, "%s-%s",
3164 + reg_names[INTERNAL_FP_REGNUM (i)],
3165 + reg_names[INTERNAL_FP_REGNUM (i + 1)]);
3166 + }
3167 + }
3168 + }
3169 +
3170 +/* Function for converting a fp-register mask to a
3171 + reglistCP8 register list string. */
3172 +void
3173 +avr32_make_fp_reglist_w (int reglist_mask, char *reglist_string)
3174 + {
3175 + int i;
3176 +
3177 + /* Make sure reglist_string is empty */
3178 + reglist_string[0] = '\0';
3179 +
3180 + for (i = 0; i < NUM_FP_REGS; ++i)
3181 + {
3182 + if (reglist_mask & (1 << i))
3183 + {
3184 + strlen (reglist_string) ?
3185 + sprintf (reglist_string, "%s, %s", reglist_string,
3186 + reg_names[INTERNAL_FP_REGNUM (i)]) :
3187 + sprintf (reglist_string, "%s", reg_names[INTERNAL_FP_REGNUM (i)]);
3188 + }
3189 + }
3190 + }
3191 +
3192 +void
3193 +avr32_make_reglist16 (int reglist16_vect, char *reglist16_string)
3194 + {
3195 + int i;
3196 +
3197 + /* Make sure reglist16_string is empty */
3198 + reglist16_string[0] = '\0';
3199 +
3200 + for (i = 0; i < 16; ++i)
3201 + {
3202 + if (reglist16_vect & (1 << i))
3203 + {
3204 + strlen (reglist16_string) ?
3205 + sprintf (reglist16_string, "%s, %s", reglist16_string,
3206 + reg_names[INTERNAL_REGNUM (i)]) :
3207 + sprintf (reglist16_string, "%s", reg_names[INTERNAL_REGNUM (i)]);
3208 + }
3209 + }
3210 + }
3211 +
3212 +int
3213 +avr32_convert_to_reglist16 (int reglist8_vect)
3214 + {
3215 + int reglist16_vect = 0;
3216 + if (reglist8_vect & 0x1)
3217 + reglist16_vect |= 0xF;
3218 + if (reglist8_vect & 0x2)
3219 + reglist16_vect |= 0xF0;
3220 + if (reglist8_vect & 0x4)
3221 + reglist16_vect |= 0x300;
3222 + if (reglist8_vect & 0x8)
3223 + reglist16_vect |= 0x400;
3224 + if (reglist8_vect & 0x10)
3225 + reglist16_vect |= 0x800;
3226 + if (reglist8_vect & 0x20)
3227 + reglist16_vect |= 0x1000;
3228 + if (reglist8_vect & 0x40)
3229 + reglist16_vect |= 0x4000;
3230 + if (reglist8_vect & 0x80)
3231 + reglist16_vect |= 0x8000;
3232 +
3233 + return reglist16_vect;
3234 + }
3235 +
3236 +void
3237 +avr32_make_reglist8 (int reglist8_vect, char *reglist8_string)
3238 + {
3239 + /* Make sure reglist8_string is empty */
3240 + reglist8_string[0] = '\0';
3241 +
3242 + if (reglist8_vect & 0x1)
3243 + sprintf (reglist8_string, "r0-r3");
3244 + if (reglist8_vect & 0x2)
3245 + strlen (reglist8_string) ? sprintf (reglist8_string, "%s, r4-r7",
3246 + reglist8_string) :
3247 + sprintf (reglist8_string, "r4-r7");
3248 + if (reglist8_vect & 0x4)
3249 + strlen (reglist8_string) ? sprintf (reglist8_string, "%s, r8-r9",
3250 + reglist8_string) :
3251 + sprintf (reglist8_string, "r8-r9");
3252 + if (reglist8_vect & 0x8)
3253 + strlen (reglist8_string) ? sprintf (reglist8_string, "%s, r10",
3254 + reglist8_string) :
3255 + sprintf (reglist8_string, "r10");
3256 + if (reglist8_vect & 0x10)
3257 + strlen (reglist8_string) ? sprintf (reglist8_string, "%s, r11",
3258 + reglist8_string) :
3259 + sprintf (reglist8_string, "r11");
3260 + if (reglist8_vect & 0x20)
3261 + strlen (reglist8_string) ? sprintf (reglist8_string, "%s, r12",
3262 + reglist8_string) :
3263 + sprintf (reglist8_string, "r12");
3264 + if (reglist8_vect & 0x40)
3265 + strlen (reglist8_string) ? sprintf (reglist8_string, "%s, lr",
3266 + reglist8_string) :
3267 + sprintf (reglist8_string, "lr");
3268 + if (reglist8_vect & 0x80)
3269 + strlen (reglist8_string) ? sprintf (reglist8_string, "%s, pc",
3270 + reglist8_string) :
3271 + sprintf (reglist8_string, "pc");
3272 + }
3273 +
3274 +int
3275 +avr32_eh_return_data_regno (int n)
3276 + {
3277 + if (n >= 0 && n <= 3)
3278 + return 8 + n;
3279 + else
3280 + return INVALID_REGNUM;
3281 + }
3282 +
3283 +/* Compute the distance from register FROM to register TO.
3284 + These can be the arg pointer, the frame pointer or
3285 + the stack pointer.
3286 + Typical stack layout looks like this:
3287 +
3288 + old stack pointer -> | |
3289 + ----
3290 + | | \
3291 + | | saved arguments for
3292 + | | vararg functions
3293 + arg_pointer -> | | /
3294 + --
3295 + | | \
3296 + | | call saved
3297 + | | registers
3298 + | | /
3299 + frame ptr -> --
3300 + | | \
3301 + | | local
3302 + | | variables
3303 + stack ptr --> | | /
3304 + --
3305 + | | \
3306 + | | outgoing
3307 + | | arguments
3308 + | | /
3309 + --
3310 +
3311 + For a given funciton some or all of these stack compomnents
3312 + may not be needed, giving rise to the possibility of
3313 + eliminating some of the registers.
3314 +
3315 + The values returned by this function must reflect the behaviour
3316 + of avr32_expand_prologue() and avr32_compute_save_reg_mask().
3317 +
3318 + The sign of the number returned reflects the direction of stack
3319 + growth, so the values are positive for all eliminations except
3320 + from the soft frame pointer to the hard frame pointer. */
3321 +
3322 +
3323 +int
3324 +avr32_initial_elimination_offset (int from, int to)
3325 + {
3326 + int i;
3327 + int call_saved_regs = 0;
3328 + unsigned long saved_reg_mask, saved_fp_reg_mask;
3329 + unsigned int local_vars = get_frame_size ();
3330 +
3331 + saved_reg_mask = avr32_compute_save_reg_mask (TRUE);
3332 + saved_fp_reg_mask = avr32_compute_save_fp_reg_mask ();
3333 +
3334 + for (i = 0; i < 16; ++i)
3335 + {
3336 + if (saved_reg_mask & (1 << i))
3337 + call_saved_regs += 4;
3338 + }
3339 +
3340 + for (i = 0; i < NUM_FP_REGS; ++i)
3341 + {
3342 + if (saved_fp_reg_mask & (1 << i))
3343 + call_saved_regs += 4;
3344 + }
3345 +
3346 + switch (from)
3347 + {
3348 + case ARG_POINTER_REGNUM:
3349 + switch (to)
3350 + {
3351 + case STACK_POINTER_REGNUM:
3352 + return call_saved_regs + local_vars;
3353 + case FRAME_POINTER_REGNUM:
3354 + return call_saved_regs;
3355 + default:
3356 + abort ();
3357 + }
3358 + case FRAME_POINTER_REGNUM:
3359 + switch (to)
3360 + {
3361 + case STACK_POINTER_REGNUM:
3362 + return local_vars;
3363 + default:
3364 + abort ();
3365 + }
3366 + default:
3367 + abort ();
3368 + }
3369 + }
3370 +
3371 +
3372 +/*
3373 + Returns a rtx used when passing the next argument to a function.
3374 + avr32_init_cumulative_args() and avr32_function_arg_advance() sets witch
3375 + register to use.
3376 + */
3377 +rtx
3378 +avr32_function_arg (CUMULATIVE_ARGS * cum, enum machine_mode mode,
3379 + tree type, int named)
3380 + {
3381 + int index = -1;
3382 +
3383 + HOST_WIDE_INT arg_size, arg_rsize;
3384 + if (type)
3385 + {
3386 + arg_size = int_size_in_bytes (type);
3387 + }
3388 + else
3389 + {
3390 + arg_size = GET_MODE_SIZE (mode);
3391 + }
3392 + arg_rsize = PUSH_ROUNDING (arg_size);
3393 +
3394 + /*
3395 + The last time this macro is called, it is called with mode == VOIDmode,
3396 + and its result is passed to the call or call_value pattern as operands 2
3397 + and 3 respectively. */
3398 + if (mode == VOIDmode)
3399 + {
3400 + return gen_rtx_CONST_INT (SImode, 22); /* ToDo: fixme. */
3401 + }
3402 +
3403 + if ((*targetm.calls.must_pass_in_stack) (mode, type) || !named)
3404 + {
3405 + return NULL_RTX;
3406 + }
3407 +
3408 + if (arg_rsize == 8)
3409 + {
3410 + /* use r11:r10 or r9:r8. */
3411 + if (!(GET_USED_INDEX (cum, 1) || GET_USED_INDEX (cum, 2)))
3412 + index = 1;
3413 + else if (!(GET_USED_INDEX (cum, 3) || GET_USED_INDEX (cum, 4)))
3414 + index = 3;
3415 + else
3416 + index = -1;
3417 + }
3418 + else if (arg_rsize == 4)
3419 + { /* Use first available register */
3420 + index = 0;
3421 + while (index <= LAST_CUM_REG_INDEX && GET_USED_INDEX (cum, index))
3422 + index++;
3423 + if (index > LAST_CUM_REG_INDEX)
3424 + index = -1;
3425 + }
3426 +
3427 + SET_REG_INDEX (cum, index);
3428 +
3429 + if (GET_REG_INDEX (cum) >= 0)
3430 + return gen_rtx_REG (mode,
3431 + avr32_function_arg_reglist[GET_REG_INDEX (cum)]);
3432 +
3433 + return NULL_RTX;
3434 + }
3435 +
3436 +/*
3437 + Set the register used for passing the first argument to a function.
3438 + */
3439 +void
3440 +avr32_init_cumulative_args (CUMULATIVE_ARGS * cum, tree fntype,
3441 + rtx libname ATTRIBUTE_UNUSED,
3442 + tree fndecl ATTRIBUTE_UNUSED)
3443 + {
3444 + /* Set all registers as unused. */
3445 + SET_INDEXES_UNUSED (cum);
3446 +
3447 + /* Reset uses_anonymous_args */
3448 + cum->uses_anonymous_args = 0;
3449 +
3450 + /* Reset size of stack pushed arguments */
3451 + cum->stack_pushed_args_size = 0;
3452 + }
3453 +
3454 +/*
3455 + Set register used for passing the next argument to a function. Only the
3456 + Scratch Registers are used.
3457 +
3458 + number name
3459 + 15 r15 PC
3460 + 14 r14 LR
3461 + 13 r13 _SP_________
3462 + FIRST_CUM_REG 12 r12 _||_
3463 + 10 r11 ||
3464 + 11 r10 _||_ Scratch Registers
3465 + 8 r9 ||
3466 + LAST_SCRATCH_REG 9 r8 _\/_________
3467 + 6 r7 /\
3468 + 7 r6 ||
3469 + 4 r5 ||
3470 + 5 r4 ||
3471 + 2 r3 ||
3472 + 3 r2 ||
3473 + 0 r1 ||
3474 + 1 r0 _||_________
3475 +
3476 + */
3477 +void
3478 +avr32_function_arg_advance (CUMULATIVE_ARGS * cum, enum machine_mode mode,
3479 + tree type, int named ATTRIBUTE_UNUSED)
3480 + {
3481 + HOST_WIDE_INT arg_size, arg_rsize;
3482 +
3483 + if (type)
3484 + {
3485 + arg_size = int_size_in_bytes (type);
3486 + }
3487 + else
3488 + {
3489 + arg_size = GET_MODE_SIZE (mode);
3490 + }
3491 + arg_rsize = PUSH_ROUNDING (arg_size);
3492 +
3493 + /* It the argument had to be passed in stack, no register is used. */
3494 + if ((*targetm.calls.must_pass_in_stack) (mode, type))
3495 + {
3496 + cum->stack_pushed_args_size += PUSH_ROUNDING (int_size_in_bytes (type));
3497 + return;
3498 + }
3499 +
3500 + /* Mark the used registers as "used". */
3501 + if (GET_REG_INDEX (cum) >= 0)
3502 + {
3503 + SET_USED_INDEX (cum, GET_REG_INDEX (cum));
3504 + if (arg_rsize == 8)
3505 + {
3506 + SET_USED_INDEX (cum, (GET_REG_INDEX (cum) + 1));
3507 + }
3508 + }
3509 + else
3510 + {
3511 + /* Had to use stack */
3512 + cum->stack_pushed_args_size += arg_rsize;
3513 + }
3514 + }
3515 +
3516 +/*
3517 + Defines witch direction to go to find the next register to use if the
3518 + argument is larger then one register or for arguments shorter than an
3519 + int which is not promoted, such as the last part of structures with
3520 + size not a multiple of 4. */
3521 +enum direction
3522 +avr32_function_arg_padding (enum machine_mode mode ATTRIBUTE_UNUSED,
3523 + tree type)
3524 + {
3525 + /* Pad upward for all aggregates except byte and halfword sized aggregates
3526 + which can be passed in registers. */
3527 + if (type
3528 + && AGGREGATE_TYPE_P (type)
3529 + && (int_size_in_bytes (type) != 1)
3530 + && !((int_size_in_bytes (type) == 2)
3531 + && TYPE_ALIGN_UNIT (type) >= 2)
3532 + && (int_size_in_bytes (type) & 0x3))
3533 + {
3534 + return upward;
3535 + }
3536 +
3537 + return downward;
3538 + }
3539 +
3540 +/*
3541 + Return a rtx used for the return value from a function call.
3542 + */
3543 +rtx
3544 +avr32_function_value (tree type, tree func, bool outgoing ATTRIBUTE_UNUSED)
3545 + {
3546 + if (avr32_return_in_memory (type, func))
3547 + return NULL_RTX;
3548 +
3549 + if (int_size_in_bytes (type) <= 4)
3550 + if (avr32_return_in_msb (type))
3551 + /* Aggregates of size less than a word which does align the data in the
3552 + MSB must use SImode for r12. */
3553 + return gen_rtx_REG (SImode, RET_REGISTER);
3554 + else
3555 + return gen_rtx_REG (TYPE_MODE (type), RET_REGISTER);
3556 + else if (int_size_in_bytes (type) <= 8)
3557 + return gen_rtx_REG (TYPE_MODE (type), INTERNAL_REGNUM (11));
3558 +
3559 + return NULL_RTX;
3560 + }
3561 +
3562 +/*
3563 + Return a rtx used for the return value from a library function call.
3564 + */
3565 +rtx
3566 +avr32_libcall_value (enum machine_mode mode)
3567 + {
3568 +
3569 + if (GET_MODE_SIZE (mode) <= 4)
3570 + return gen_rtx_REG (mode, RET_REGISTER);
3571 + else if (GET_MODE_SIZE (mode) <= 8)
3572 + return gen_rtx_REG (mode, INTERNAL_REGNUM (11));
3573 + else
3574 + return NULL_RTX;
3575 + }
3576 +
3577 +/* Return TRUE if X references a SYMBOL_REF. */
3578 +int
3579 +symbol_mentioned_p (rtx x)
3580 + {
3581 + const char *fmt;
3582 + int i;
3583 +
3584 + if (GET_CODE (x) == SYMBOL_REF)
3585 + return 1;
3586 +
3587 + fmt = GET_RTX_FORMAT (GET_CODE (x));
3588 +
3589 + for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
3590 + {
3591 + if (fmt[i] == 'E')
3592 + {
3593 + int j;
3594 +
3595 + for (j = XVECLEN (x, i) - 1; j >= 0; j--)
3596 + if (symbol_mentioned_p (XVECEXP (x, i, j)))
3597 + return 1;
3598 + }
3599 + else if (fmt[i] == 'e' && symbol_mentioned_p (XEXP (x, i)))
3600 + return 1;
3601 + }
3602 +
3603 + return 0;
3604 + }
3605 +
3606 +/* Return TRUE if X references a LABEL_REF. */
3607 +int
3608 +label_mentioned_p (rtx x)
3609 + {
3610 + const char *fmt;
3611 + int i;
3612 +
3613 + if (GET_CODE (x) == LABEL_REF)
3614 + return 1;
3615 +
3616 + fmt = GET_RTX_FORMAT (GET_CODE (x));
3617 + for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
3618 + {
3619 + if (fmt[i] == 'E')
3620 + {
3621 + int j;
3622 +
3623 + for (j = XVECLEN (x, i) - 1; j >= 0; j--)
3624 + if (label_mentioned_p (XVECEXP (x, i, j)))
3625 + return 1;
3626 + }
3627 + else if (fmt[i] == 'e' && label_mentioned_p (XEXP (x, i)))
3628 + return 1;
3629 + }
3630 +
3631 + return 0;
3632 + }
3633 +
3634 +
3635 +int
3636 +avr32_legitimate_pic_operand_p (rtx x)
3637 + {
3638 +
3639 + /* We can't have const, this must be broken down to a symbol. */
3640 + if (GET_CODE (x) == CONST)
3641 + return FALSE;
3642 +
3643 + /* Can't access symbols or labels via the constant pool either */
3644 + if ((GET_CODE (x) == SYMBOL_REF
3645 + && CONSTANT_POOL_ADDRESS_P (x)
3646 + && (symbol_mentioned_p (get_pool_constant (x))
3647 + || label_mentioned_p (get_pool_constant (x)))))
3648 + return FALSE;
3649 +
3650 + return TRUE;
3651 + }
3652 +
3653 +
3654 +rtx
3655 +legitimize_pic_address (rtx orig, enum machine_mode mode ATTRIBUTE_UNUSED,
3656 + rtx reg)
3657 + {
3658 +
3659 + if (GET_CODE (orig) == SYMBOL_REF || GET_CODE (orig) == LABEL_REF)
3660 + {
3661 + int subregs = 0;
3662 +
3663 + if (reg == 0)
3664 + {
3665 + if (no_new_pseudos)
3666 + abort ();
3667 + else
3668 + reg = gen_reg_rtx (Pmode);
3669 +
3670 + subregs = 1;
3671 + }
3672 +
3673 + emit_move_insn (reg, orig);
3674 +
3675 + /* Only set current function as using pic offset table if flag_pic is
3676 + set. This is because this function is also used if
3677 + TARGET_HAS_ASM_ADDR_PSEUDOS is set. */
3678 + if (flag_pic)
3679 + current_function_uses_pic_offset_table = 1;
3680 +
3681 + /* Put a REG_EQUAL note on this insn, so that it can be optimized by
3682 + loop. */
3683 + return reg;
3684 + }
3685 + else if (GET_CODE (orig) == CONST)
3686 + {
3687 + rtx base, offset;
3688 +
3689 + if (flag_pic
3690 + && GET_CODE (XEXP (orig, 0)) == PLUS
3691 + && XEXP (XEXP (orig, 0), 0) == pic_offset_table_rtx)
3692 + return orig;
3693 +
3694 + if (reg == 0)
3695 + {
3696 + if (no_new_pseudos)
3697 + abort ();
3698 + else
3699 + reg = gen_reg_rtx (Pmode);
3700 + }
3701 +
3702 + if (GET_CODE (XEXP (orig, 0)) == PLUS)
3703 + {
3704 + base =
3705 + legitimize_pic_address (XEXP (XEXP (orig, 0), 0), Pmode, reg);
3706 + offset =
3707 + legitimize_pic_address (XEXP (XEXP (orig, 0), 1), Pmode,
3708 + base == reg ? 0 : reg);
3709 + }
3710 + else
3711 + abort ();
3712 +
3713 + if (GET_CODE (offset) == CONST_INT)
3714 + {
3715 + /* The base register doesn't really matter, we only want to test
3716 + the index for the appropriate mode. */
3717 + if (!avr32_const_ok_for_constraint_p (INTVAL (offset), 'I', "Is21"))
3718 + {
3719 + if (!no_new_pseudos)
3720 + offset = force_reg (Pmode, offset);
3721 + else
3722 + abort ();
3723 + }
3724 +
3725 + if (GET_CODE (offset) == CONST_INT)
3726 + return plus_constant (base, INTVAL (offset));
3727 + }
3728 +
3729 + return gen_rtx_PLUS (Pmode, base, offset);
3730 + }
3731 +
3732 + return orig;
3733 + }
3734 +
3735 +/* Generate code to load the PIC register. */
3736 +void
3737 +avr32_load_pic_register (void)
3738 + {
3739 + rtx l1, pic_tmp;
3740 + rtx global_offset_table;
3741 +
3742 + if ((current_function_uses_pic_offset_table == 0) || TARGET_NO_INIT_GOT)
3743 + return;
3744 +
3745 + if (!flag_pic)
3746 + abort ();
3747 +
3748 + l1 = gen_label_rtx ();
3749 +
3750 + global_offset_table = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
3751 + pic_tmp =
3752 + gen_rtx_CONST (Pmode,
3753 + gen_rtx_MINUS (SImode, gen_rtx_LABEL_REF (Pmode, l1),
3754 + global_offset_table));
3755 + emit_insn (gen_pic_load_addr
3756 + (pic_offset_table_rtx, force_const_mem (SImode, pic_tmp)));
3757 + emit_insn (gen_pic_compute_got_from_pc (pic_offset_table_rtx, l1));
3758 +
3759 + /* Need to emit this whether or not we obey regdecls, since setjmp/longjmp
3760 + can cause life info to screw up. */
3761 + emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
3762 + }
3763 +
3764 +
3765 +
3766 +/* This hook should return true if values of type type are returned at the most
3767 + significant end of a register (in other words, if they are padded at the
3768 + least significant end). You can assume that type is returned in a register;
3769 + the caller is required to check this. Note that the register provided by
3770 + FUNCTION_VALUE must be able to hold the complete return value. For example,
3771 + if a 1-, 2- or 3-byte structure is returned at the most significant end of a
3772 + 4-byte register, FUNCTION_VALUE should provide an SImode rtx. */
3773 +bool
3774 +avr32_return_in_msb (tree type ATTRIBUTE_UNUSED)
3775 + {
3776 + /* if ( AGGREGATE_TYPE_P (type) ) if ((int_size_in_bytes(type) == 1) ||
3777 + ((int_size_in_bytes(type) == 2) && TYPE_ALIGN_UNIT(type) >= 2)) return
3778 + false; else return true; */
3779 +
3780 + return false;
3781 + }
3782 +
3783 +
3784 +/*
3785 + Returns one if a certain function value is going to be returned in memory
3786 + and zero if it is going to be returned in a register.
3787 +
3788 + BLKmode and all other modes that is larger than 64 bits are returned in
3789 + memory.
3790 + */
3791 +bool
3792 +avr32_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
3793 + {
3794 + if (TYPE_MODE (type) == VOIDmode)
3795 + return false;
3796 +
3797 + if (int_size_in_bytes (type) > (2 * UNITS_PER_WORD)
3798 + || int_size_in_bytes (type) == -1)
3799 + {
3800 + return true;
3801 + }
3802 +
3803 + /* If we have an aggregate then use the same mechanism as when checking if
3804 + it should be passed on the stack. */
3805 + if (type
3806 + && AGGREGATE_TYPE_P (type)
3807 + && (*targetm.calls.must_pass_in_stack) (TYPE_MODE (type), type))
3808 + return true;
3809 +
3810 + return false;
3811 + }
3812 +
3813 +
3814 +/* Output the constant part of the trampoline.
3815 + lddpc r0, pc[0x8:e] ; load static chain register
3816 + lddpc pc, pc[0x8:e] ; jump to subrutine
3817 + .long 0 ; Address to static chain,
3818 + ; filled in by avr32_initialize_trampoline()
3819 + .long 0 ; Address to subrutine,
3820 + ; filled in by avr32_initialize_trampoline()
3821 + */
3822 +void
3823 +avr32_trampoline_template (FILE * file)
3824 + {
3825 + fprintf (file, "\tlddpc r0, pc[8]\n");
3826 + fprintf (file, "\tlddpc pc, pc[8]\n");
3827 + /* make room for the address of the static chain. */
3828 + fprintf (file, "\t.long\t0\n");
3829 + /* make room for the address to the subrutine. */
3830 + fprintf (file, "\t.long\t0\n");
3831 + }
3832 +
3833 +
3834 +/*
3835 + Initialize the variable parts of a trampoline.
3836 + */
3837 +void
3838 +avr32_initialize_trampoline (rtx addr, rtx fnaddr, rtx static_chain)
3839 + {
3840 + /* Store the address to the static chain. */
3841 + emit_move_insn (gen_rtx_MEM
3842 + (SImode, plus_constant (addr, TRAMPOLINE_SIZE - 4)),
3843 + static_chain);
3844 +
3845 + /* Store the address to the function. */
3846 + emit_move_insn (gen_rtx_MEM (SImode, plus_constant (addr, TRAMPOLINE_SIZE)),
3847 + fnaddr);
3848 +
3849 + emit_insn (gen_cache (gen_rtx_REG (SImode, 13),
3850 + gen_rtx_CONST_INT (SImode,
3851 + AVR32_CACHE_INVALIDATE_ICACHE)));
3852 + }
3853 +
3854 +/* Return nonzero if X is valid as an addressing register. */
3855 +int
3856 +avr32_address_register_rtx_p (rtx x, int strict_p)
3857 + {
3858 + int regno;
3859 +
3860 + if (!register_operand(x, GET_MODE(x)))
3861 + return 0;
3862 +
3863 + /* If strict we require the register to be a hard register. */
3864 + if (strict_p
3865 + && !REG_P(x))
3866 + return 0;
3867 +
3868 + regno = REGNO (x);
3869 +
3870 + if (strict_p)
3871 + return REGNO_OK_FOR_BASE_P (regno);
3872 +
3873 + return (regno <= LAST_REGNUM || regno >= FIRST_PSEUDO_REGISTER);
3874 + }
3875 +
3876 +/* Return nonzero if INDEX is valid for an address index operand. */
3877 +int
3878 +avr32_legitimate_index_p (enum machine_mode mode, rtx index, int strict_p)
3879 + {
3880 + enum rtx_code code = GET_CODE (index);
3881 +
3882 + if (GET_MODE_SIZE (mode) > 8)
3883 + return 0;
3884 +
3885 + /* Standard coprocessor addressing modes. */
3886 + if (code == CONST_INT)
3887 + {
3888 + if (TARGET_HARD_FLOAT && GET_MODE_CLASS (mode) == MODE_FLOAT)
3889 + /* Coprocessor mem insns has a smaller reach than ordinary mem insns */
3890 + return CONST_OK_FOR_CONSTRAINT_P (INTVAL (index), 'K', "Ku14");
3891 + else
3892 + return CONST_OK_FOR_CONSTRAINT_P (INTVAL (index), 'K', "Ks16");
3893 + }
3894 +
3895 + if (avr32_address_register_rtx_p (index, strict_p))
3896 + return 1;
3897 +
3898 + if (code == MULT)
3899 + {
3900 + rtx xiop0 = XEXP (index, 0);
3901 + rtx xiop1 = XEXP (index, 1);
3902 + return ((avr32_address_register_rtx_p (xiop0, strict_p)
3903 + && power_of_two_operand (xiop1, SImode)
3904 + && (INTVAL (xiop1) <= 8))
3905 + || (avr32_address_register_rtx_p (xiop1, strict_p)
3906 + && power_of_two_operand (xiop0, SImode)
3907 + && (INTVAL (xiop0) <= 8)));
3908 + }
3909 + else if (code == ASHIFT)
3910 + {
3911 + rtx op = XEXP (index, 1);
3912 +
3913 + return (avr32_address_register_rtx_p (XEXP (index, 0), strict_p)
3914 + && GET_CODE (op) == CONST_INT
3915 + && INTVAL (op) > 0 && INTVAL (op) <= 3);
3916 + }
3917 +
3918 + return 0;
3919 + }
3920 +
3921 +/*
3922 + Used in the GO_IF_LEGITIMATE_ADDRESS macro. Returns a nonzero value if
3923 + the RTX x is a legitimate memory address.
3924 +
3925 + Returns NO_REGS if the address is not legatime, GENERAL_REGS or ALL_REGS
3926 + if it is.
3927 + */
3928 +
3929 +/* Forward declaration*/
3930 +int is_minipool_label (rtx label);
3931 +
3932 +int
3933 +avr32_legitimate_address (enum machine_mode mode, rtx x, int strict)
3934 + {
3935 +
3936 + switch (GET_CODE (x))
3937 + {
3938 + case REG:
3939 + return avr32_address_register_rtx_p (x, strict);
3940 + case CONST:
3941 + {
3942 + rtx label = avr32_find_symbol (x);
3943 + if (label
3944 + &&
3945 + ((CONSTANT_POOL_ADDRESS_P (label)
3946 + && !(flag_pic
3947 + && (symbol_mentioned_p (get_pool_constant (label))
3948 + || label_mentioned_p (get_pool_constant (label)))))
3949 + /* TODO! Can this ever happen??? */
3950 + || ((GET_CODE (label) == LABEL_REF)
3951 + && GET_CODE (XEXP (label, 0)) == CODE_LABEL
3952 + && is_minipool_label (XEXP (label, 0)))))
3953 + {
3954 + return TRUE;
3955 + }
3956 + }
3957 + break;
3958 + case LABEL_REF:
3959 + if (GET_CODE (XEXP (x, 0)) == CODE_LABEL
3960 + && is_minipool_label (XEXP (x, 0)))
3961 + {
3962 + return TRUE;
3963 + }
3964 + break;
3965 + case SYMBOL_REF:
3966 + {
3967 + if (CONSTANT_POOL_ADDRESS_P (x)
3968 + && !(flag_pic
3969 + && (symbol_mentioned_p (get_pool_constant (x))
3970 + || label_mentioned_p (get_pool_constant (x)))))
3971 + return TRUE;
3972 + /*
3973 + A symbol_ref is only legal if it is a function. If all of them are
3974 + legal, a pseudo reg that is a constant will be replaced by a
3975 + symbol_ref and make illegale code. SYMBOL_REF_FLAG is set by
3976 + ENCODE_SECTION_INFO. */
3977 + else if (SYMBOL_REF_RCALL_FUNCTION_P (x))
3978 + return TRUE;
3979 + break;
3980 + }
3981 + case PRE_DEC: /* (pre_dec (...)) */
3982 + case POST_INC: /* (post_inc (...)) */
3983 + return avr32_address_register_rtx_p (XEXP (x, 0), strict);
3984 + case PLUS: /* (plus (...) (...)) */
3985 + {
3986 + rtx xop0 = XEXP (x, 0);
3987 + rtx xop1 = XEXP (x, 1);
3988 +
3989 + return ((avr32_address_register_rtx_p (xop0, strict)
3990 + && avr32_legitimate_index_p (mode, xop1, strict))
3991 + || (avr32_address_register_rtx_p (xop1, strict)
3992 + && avr32_legitimate_index_p (mode, xop0, strict)));
3993 + }
3994 + default:
3995 + break;
3996 + }
3997 +
3998 + return FALSE;
3999 + }
4000 +
4001 +
4002 +int
4003 +avr32_const_double_immediate (rtx value)
4004 + {
4005 + HOST_WIDE_INT hi, lo;
4006 +
4007 + if (GET_CODE (value) != CONST_DOUBLE)
4008 + return FALSE;
4009 +
4010 + if (SCALAR_FLOAT_MODE_P (GET_MODE (value)))
4011 + {
4012 + HOST_WIDE_INT target_float[2];
4013 + hi = lo = 0;
4014 + real_to_target (target_float, CONST_DOUBLE_REAL_VALUE (value),
4015 + GET_MODE (value));
4016 + lo = target_float[0];
4017 + hi = target_float[1];
4018 + }
4019 + else
4020 + {
4021 + hi = CONST_DOUBLE_HIGH (value);
4022 + lo = CONST_DOUBLE_LOW (value);
4023 + }
4024 +
4025 + if (avr32_const_ok_for_constraint_p (lo, 'K', "Ks21")
4026 + && (GET_MODE (value) == SFmode
4027 + || avr32_const_ok_for_constraint_p (hi, 'K', "Ks21")))
4028 + {
4029 + return TRUE;
4030 + }
4031 +
4032 + return FALSE;
4033 + }
4034 +
4035 +
4036 +int
4037 +avr32_legitimate_constant_p (rtx x)
4038 + {
4039 + switch (GET_CODE (x))
4040 + {
4041 + case CONST_INT:
4042 + /* Check if we should put large immediate into constant pool
4043 + or load them directly with mov/orh.*/
4044 + if (!avr32_imm_in_const_pool)
4045 + return 1;
4046 +
4047 + return avr32_const_ok_for_constraint_p (INTVAL (x), 'K', "Ks21");
4048 + case CONST_DOUBLE:
4049 + /* Check if we should put large immediate into constant pool
4050 + or load them directly with mov/orh.*/
4051 + if (!avr32_imm_in_const_pool)
4052 + return 1;
4053 +
4054 + if (GET_MODE (x) == SFmode
4055 + || GET_MODE (x) == DFmode || GET_MODE (x) == DImode)
4056 + return avr32_const_double_immediate (x);
4057 + else
4058 + return 0;
4059 + case LABEL_REF:
4060 + return flag_pic || TARGET_HAS_ASM_ADDR_PSEUDOS;
4061 + case SYMBOL_REF:
4062 + return flag_pic || TARGET_HAS_ASM_ADDR_PSEUDOS;
4063 + case CONST:
4064 + case HIGH:
4065 + case CONST_VECTOR:
4066 + return 0;
4067 + default:
4068 + printf ("%s():\n", __FUNCTION__);
4069 + debug_rtx (x);
4070 + return 1;
4071 + }
4072 + }
4073 +
4074 +
4075 +/* Strip any special encoding from labels */
4076 +const char *
4077 +avr32_strip_name_encoding (const char *name)
4078 +{
4079 + const char *stripped = name;
4080 +
4081 + while (1)
4082 + {
4083 + switch (stripped[0])
4084 + {
4085 + case '#':
4086 + stripped = strchr (name + 1, '#') + 1;
4087 + break;
4088 + case '*':
4089 + stripped = &stripped[1];
4090 + break;
4091 + default:
4092 + return stripped;
4093 + }
4094 + }
4095 +}
4096 +
4097 +
4098 +
4099 +/* Do anything needed before RTL is emitted for each function. */
4100 +static struct machine_function *
4101 +avr32_init_machine_status (void)
4102 +{
4103 + struct machine_function *machine;
4104 + machine =
4105 + (machine_function *) ggc_alloc_cleared (sizeof (machine_function));
4106 +
4107 +#if AVR32_FT_UNKNOWN != 0
4108 + machine->func_type = AVR32_FT_UNKNOWN;
4109 +#endif
4110 +
4111 + machine->minipool_label_head = 0;
4112 + machine->minipool_label_tail = 0;
4113 + return machine;
4114 +}
4115 +
4116 +void
4117 +avr32_init_expanders (void)
4118 + {
4119 + /* Arrange to initialize and mark the machine per-function status. */
4120 + init_machine_status = avr32_init_machine_status;
4121 + }
4122 +
4123 +
4124 +/* Return an RTX indicating where the return address to the
4125 + calling function can be found. */
4126 +
4127 +rtx
4128 +avr32_return_addr (int count, rtx frame ATTRIBUTE_UNUSED)
4129 + {
4130 + if (count != 0)
4131 + return NULL_RTX;
4132 +
4133 + return get_hard_reg_initial_val (Pmode, LR_REGNUM);
4134 + }
4135 +
4136 +
4137 +void
4138 +avr32_encode_section_info (tree decl, rtx rtl, int first)
4139 + {
4140 +
4141 + if (first && DECL_P (decl))
4142 + {
4143 + /* Set SYMBOL_REG_FLAG for local functions */
4144 + if (!TREE_PUBLIC (decl) && TREE_CODE (decl) == FUNCTION_DECL)
4145 + {
4146 + if ((*targetm.binds_local_p) (decl))
4147 + {
4148 + SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
4149 + }
4150 + }
4151 + }
4152 + }
4153 +
4154 +
4155 +void
4156 +avr32_asm_output_ascii (FILE * stream, char *ptr, int len)
4157 + {
4158 + int i, i_new = 0;
4159 + char *new_ptr = xmalloc (4 * len);
4160 + if (new_ptr == NULL)
4161 + internal_error ("Out of memory.");
4162 +
4163 + for (i = 0; i < len; i++)
4164 + {
4165 + if (ptr[i] == '\n')
4166 + {
4167 + new_ptr[i_new++] = '\\';
4168 + new_ptr[i_new++] = '0';
4169 + new_ptr[i_new++] = '1';
4170 + new_ptr[i_new++] = '2';
4171 + }
4172 + else if (ptr[i] == '\"')
4173 + {
4174 + new_ptr[i_new++] = '\\';
4175 + new_ptr[i_new++] = '\"';
4176 + }
4177 + else if (ptr[i] == '\\')
4178 + {
4179 + new_ptr[i_new++] = '\\';
4180 + new_ptr[i_new++] = '\\';
4181 + }
4182 + else if (ptr[i] == '\0' && i + 1 < len)
4183 + {
4184 + new_ptr[i_new++] = '\\';
4185 + new_ptr[i_new++] = '0';
4186 + }
4187 + else
4188 + {
4189 + new_ptr[i_new++] = ptr[i];
4190 + }
4191 + }
4192 +
4193 + /* Terminate new_ptr. */
4194 + new_ptr[i_new] = '\0';
4195 + fprintf (stream, "\t.ascii\t\"%s\"\n", new_ptr);
4196 + free (new_ptr);
4197 + }
4198 +
4199 +
4200 +void
4201 +avr32_asm_output_label (FILE * stream, const char *name)
4202 + {
4203 + name = avr32_strip_name_encoding (name);
4204 +
4205 + /* Print the label. */
4206 + assemble_name (stream, name);
4207 + fprintf (stream, ":\n");
4208 + }
4209 +
4210 +
4211 +
4212 +void
4213 +avr32_asm_weaken_label (FILE * stream, const char *name)
4214 + {
4215 + fprintf (stream, "\t.weak ");
4216 + assemble_name (stream, name);
4217 + fprintf (stream, "\n");
4218 + }
4219 +
4220 +/*
4221 + Checks if a labelref is equal to a reserved word in the assembler. If it is,
4222 + insert a '_' before the label name.
4223 + */
4224 +void
4225 +avr32_asm_output_labelref (FILE * stream, const char *name)
4226 + {
4227 + int verbatim = FALSE;
4228 + const char *stripped = name;
4229 + int strip_finished = FALSE;
4230 +
4231 + while (!strip_finished)
4232 + {
4233 + switch (stripped[0])
4234 + {
4235 + case '#':
4236 + stripped = strchr (name + 1, '#') + 1;
4237 + break;
4238 + case '*':
4239 + stripped = &stripped[1];
4240 + verbatim = TRUE;
4241 + break;
4242 + default:
4243 + strip_finished = TRUE;
4244 + break;
4245 + }
4246 + }
4247 +
4248 + if (verbatim)
4249 + fputs (stripped, stream);
4250 + else
4251 + asm_fprintf (stream, "%U%s", stripped);
4252 + }
4253 +
4254 +
4255 +
4256 +/*
4257 + Check if the comparison in compare_exp is redundant
4258 + for the condition given in next_cond given that the
4259 + needed flags are already set by an earlier instruction.
4260 + Uses cc_prev_status to check this.
4261 +
4262 + Returns NULL_RTX if the compare is not redundant
4263 + or the new condition to use in the conditional
4264 + instruction if the compare is redundant.
4265 + */
4266 +static rtx
4267 +is_compare_redundant (rtx compare_exp, rtx next_cond)
4268 + {
4269 + int z_flag_valid = FALSE;
4270 + int n_flag_valid = FALSE;
4271 + rtx new_cond;
4272 +
4273 + if (GET_CODE (compare_exp) != COMPARE)
4274 + return NULL_RTX;
4275 +
4276 +
4277 + if (rtx_equal_p (cc_prev_status.mdep.value, compare_exp))
4278 + {
4279 + /* cc0 already contains the correct comparison -> delete cmp insn */
4280 + return next_cond;
4281 + }
4282 +
4283 + if (GET_MODE (compare_exp) != SImode)
4284 + return NULL_RTX;
4285 +
4286 + switch (cc_prev_status.mdep.flags)
4287 + {
4288 + case CC_SET_VNCZ:
4289 + case CC_SET_NCZ:
4290 + n_flag_valid = TRUE;
4291 + case CC_SET_CZ:
4292 + case CC_SET_Z:
4293 + z_flag_valid = TRUE;
4294 + }
4295 +
4296 + if (cc_prev_status.mdep.value
4297 + && REG_P (XEXP (compare_exp, 0))
4298 + && REGNO (XEXP (compare_exp, 0)) == REGNO (cc_prev_status.mdep.value)
4299 + && GET_CODE (XEXP (compare_exp, 1)) == CONST_INT
4300 + && next_cond != NULL_RTX)
4301 + {
4302 + if (INTVAL (XEXP (compare_exp, 1)) == 0
4303 + && z_flag_valid
4304 + && (GET_CODE (next_cond) == EQ || GET_CODE (next_cond) == NE))
4305 + /* We can skip comparison Z flag is already reflecting ops[0] */
4306 + return next_cond;
4307 + else if (n_flag_valid
4308 + && ((INTVAL (XEXP (compare_exp, 1)) == 0
4309 + && (GET_CODE (next_cond) == GE
4310 + || GET_CODE (next_cond) == LT))
4311 + || (INTVAL (XEXP (compare_exp, 1)) == -1
4312 + && (GET_CODE (next_cond) == GT
4313 + || GET_CODE (next_cond) == LE))))
4314 + {
4315 + /* We can skip comparison N flag is already reflecting ops[0],
4316 + which means that we can use the mi/pl conditions to check if
4317 + ops[0] is GE or LT 0. */
4318 + if ((GET_CODE (next_cond) == GE) || (GET_CODE (next_cond) == GT))
4319 + new_cond =
4320 + gen_rtx_UNSPEC (GET_MODE (next_cond), gen_rtvec (2, cc0_rtx, const0_rtx),
4321 + UNSPEC_COND_PL);
4322 + else
4323 + new_cond =
4324 + gen_rtx_UNSPEC (GET_MODE (next_cond), gen_rtvec (2, cc0_rtx, const0_rtx),
4325 + UNSPEC_COND_MI);
4326 + return new_cond;
4327 + }
4328 + }
4329 + return NULL_RTX;
4330 + }
4331 +
4332 +/* Updates cc_status. */
4333 +void
4334 +avr32_notice_update_cc (rtx exp, rtx insn)
4335 + {
4336 + switch (get_attr_cc (insn))
4337 + {
4338 + case CC_CALL_SET:
4339 + CC_STATUS_INIT;
4340 + FPCC_STATUS_INIT;
4341 + /* Check if the function call returns a value in r12 */
4342 + if (REG_P (recog_data.operand[0])
4343 + && REGNO (recog_data.operand[0]) == RETVAL_REGNUM)
4344 + {
4345 + cc_status.flags = 0;
4346 + cc_status.mdep.value =
4347 + gen_rtx_COMPARE (SImode, recog_data.operand[0], const0_rtx);
4348 + cc_status.mdep.flags = CC_SET_VNCZ;
4349 +
4350 + }
4351 + break;
4352 + case CC_COMPARE:
4353 + /* Check that compare will not be optimized away if so nothing should
4354 + be done */
4355 + if (is_compare_redundant (SET_SRC (exp), get_next_insn_cond (insn)) ==
4356 + NULL_RTX)
4357 + {
4358 +
4359 + /* Reset the nonstandard flag */
4360 + CC_STATUS_INIT;
4361 + cc_status.flags = 0;
4362 + cc_status.mdep.value = SET_SRC (exp);
4363 + cc_status.mdep.flags = CC_SET_VNCZ;
4364 + }
4365 + break;
4366 + case CC_CMP_COND_INSN:
4367 + {
4368 + /* Conditional insn that emit the compare itself. */
4369 + rtx cmp = gen_rtx_COMPARE (GET_MODE (recog_data.operand[4]),
4370 + recog_data.operand[4],
4371 + recog_data.operand[5]);
4372 +
4373 + if (is_compare_redundant (cmp, recog_data.operand[1]) == NULL_RTX)
4374 + {
4375 +
4376 + /* Reset the nonstandard flag */
4377 + CC_STATUS_INIT;
4378 + cc_status.flags = 0;
4379 + cc_status.mdep.value = cmp;
4380 + cc_status.mdep.flags = CC_SET_VNCZ;
4381 + }
4382 + }
4383 + break;
4384 + case CC_FPCOMPARE:
4385 + /* Check that floating-point compare will not be optimized away if so
4386 + nothing should be done */
4387 + if (!rtx_equal_p (cc_prev_status.mdep.fpvalue, SET_SRC (exp)))
4388 + {
4389 + /* cc0 already contains the correct comparison -> delete cmp insn */
4390 + /* Reset the nonstandard flag */
4391 + cc_status.mdep.fpvalue = SET_SRC (exp);
4392 + cc_status.mdep.fpflags = CC_SET_CZ;
4393 + }
4394 + break;
4395 + case CC_FROM_FPCC:
4396 + /* Flags are updated with flags from Floating-point coprocessor, set
4397 + CC_NOT_SIGNED flag since the flags are set so that unsigned
4398 + condidion codes can be used directly. */
4399 + CC_STATUS_INIT;
4400 + cc_status.flags = CC_NOT_SIGNED;
4401 + cc_status.mdep.value = cc_status.mdep.fpvalue;
4402 + cc_status.mdep.flags = cc_status.mdep.fpflags;
4403 + break;
4404 + case CC_BLD:
4405 + /* Bit load is kind of like an inverted testsi, because the Z flag is
4406 + inverted */
4407 + CC_STATUS_INIT;
4408 + cc_status.flags = CC_INVERTED;
4409 + cc_status.mdep.value = SET_SRC (exp);
4410 + cc_status.mdep.flags = CC_SET_Z;
4411 + break;
4412 + case CC_NONE:
4413 + /* Insn does not affect CC at all. Check if the instruction updates
4414 + some of the register currently reflected in cc0 */
4415 +
4416 + if ((GET_CODE (exp) == SET)
4417 + && (cc_status.value1 || cc_status.value2 || cc_status.mdep.value)
4418 + && (reg_mentioned_p (SET_DEST (exp), cc_status.value1)
4419 + || reg_mentioned_p (SET_DEST (exp), cc_status.value2)
4420 + || reg_mentioned_p (SET_DEST (exp), cc_status.mdep.value)))
4421 + {
4422 + CC_STATUS_INIT;
4423 + }
4424 +
4425 + /* If this is a parallel we must step through each of the parallel
4426 + expressions */
4427 + if (GET_CODE (exp) == PARALLEL)
4428 + {
4429 + int i;
4430 + for (i = 0; i < XVECLEN (exp, 0); ++i)
4431 + {
4432 + rtx vec_exp = XVECEXP (exp, 0, i);
4433 + if ((GET_CODE (vec_exp) == SET)
4434 + && (cc_status.value1 || cc_status.value2
4435 + || cc_status.mdep.value)
4436 + && (reg_mentioned_p (SET_DEST (vec_exp), cc_status.value1)
4437 + || reg_mentioned_p (SET_DEST (vec_exp),
4438 + cc_status.value2)
4439 + || reg_mentioned_p (SET_DEST (vec_exp),
4440 + cc_status.mdep.value)))
4441 + {
4442 + CC_STATUS_INIT;
4443 + }
4444 + }
4445 + }
4446 +
4447 + /* Check if we have memory opartions with post_inc or pre_dec on the
4448 + register currently reflected in cc0 */
4449 + if (GET_CODE (exp) == SET
4450 + && GET_CODE (SET_SRC (exp)) == MEM
4451 + && (GET_CODE (XEXP (SET_SRC (exp), 0)) == POST_INC
4452 + || GET_CODE (XEXP (SET_SRC (exp), 0)) == PRE_DEC)
4453 + &&
4454 + (reg_mentioned_p
4455 + (XEXP (XEXP (SET_SRC (exp), 0), 0), cc_status.value1)
4456 + || reg_mentioned_p (XEXP (XEXP (SET_SRC (exp), 0), 0),
4457 + cc_status.value2)
4458 + || reg_mentioned_p (XEXP (XEXP (SET_SRC (exp), 0), 0),
4459 + cc_status.mdep.value)))
4460 + CC_STATUS_INIT;
4461 +
4462 + if (GET_CODE (exp) == SET
4463 + && GET_CODE (SET_DEST (exp)) == MEM
4464 + && (GET_CODE (XEXP (SET_DEST (exp), 0)) == POST_INC
4465 + || GET_CODE (XEXP (SET_DEST (exp), 0)) == PRE_DEC)
4466 + &&
4467 + (reg_mentioned_p
4468 + (XEXP (XEXP (SET_DEST (exp), 0), 0), cc_status.value1)
4469 + || reg_mentioned_p (XEXP (XEXP (SET_DEST (exp), 0), 0),
4470 + cc_status.value2)
4471 + || reg_mentioned_p (XEXP (XEXP (SET_DEST (exp), 0), 0),
4472 + cc_status.mdep.value)))
4473 + CC_STATUS_INIT;
4474 + break;
4475 +
4476 + case CC_SET_VNCZ:
4477 + CC_STATUS_INIT;
4478 + cc_status.mdep.value = recog_data.operand[0];
4479 + cc_status.mdep.flags = CC_SET_VNCZ;
4480 + break;
4481 +
4482 + case CC_SET_NCZ:
4483 + CC_STATUS_INIT;
4484 + cc_status.mdep.value = recog_data.operand[0];
4485 + cc_status.mdep.flags = CC_SET_NCZ;
4486 + break;
4487 +
4488 + case CC_SET_CZ:
4489 + CC_STATUS_INIT;
4490 + cc_status.mdep.value = recog_data.operand[0];
4491 + cc_status.mdep.flags = CC_SET_CZ;
4492 + break;
4493 +
4494 + case CC_SET_Z:
4495 + CC_STATUS_INIT;
4496 + cc_status.mdep.value = recog_data.operand[0];
4497 + cc_status.mdep.flags = CC_SET_Z;
4498 + break;
4499 +
4500 + case CC_CLOBBER:
4501 + CC_STATUS_INIT;
4502 + break;
4503 +
4504 + default:
4505 + CC_STATUS_INIT;
4506 + }
4507 + }
4508 +
4509 +
4510 +/*
4511 + Outputs to stdio stream stream the assembler syntax for an instruction
4512 + operand x. x is an RTL expression.
4513 + */
4514 +void
4515 +avr32_print_operand (FILE * stream, rtx x, int code)
4516 + {
4517 + int error = 0;
4518 +
4519 + switch (GET_CODE (x))
4520 + {
4521 + case UNSPEC:
4522 + switch (XINT (x, 1))
4523 + {
4524 + case UNSPEC_COND_PL:
4525 + if (code == 'i')
4526 + fputs ("mi", stream);
4527 + else
4528 + fputs ("pl", stream);
4529 + break;
4530 + case UNSPEC_COND_MI:
4531 + if (code == 'i')
4532 + fputs ("pl", stream);
4533 + else
4534 + fputs ("mi", stream);
4535 + break;
4536 + default:
4537 + error = 1;
4538 + }
4539 + break;
4540 + case EQ:
4541 + if (code == 'i')
4542 + fputs ("ne", stream);
4543 + else
4544 + fputs ("eq", stream);
4545 + break;
4546 + case NE:
4547 + if (code == 'i')
4548 + fputs ("eq", stream);
4549 + else
4550 + fputs ("ne", stream);
4551 + break;
4552 + case GT:
4553 + if (code == 'i')
4554 + fputs ("le", stream);
4555 + else
4556 + fputs ("gt", stream);
4557 + break;
4558 + case GTU:
4559 + if (code == 'i')
4560 + fputs ("ls", stream);
4561 + else
4562 + fputs ("hi", stream);
4563 + break;
4564 + case LT:
4565 + if (code == 'i')
4566 + fputs ("ge", stream);
4567 + else
4568 + fputs ("lt", stream);
4569 + break;
4570 + case LTU:
4571 + if (code == 'i')
4572 + fputs ("hs", stream);
4573 + else
4574 + fputs ("lo", stream);
4575 + break;
4576 + case GE:
4577 + if (code == 'i')
4578 + fputs ("lt", stream);
4579 + else
4580 + fputs ("ge", stream);
4581 + break;
4582 + case GEU:
4583 + if (code == 'i')
4584 + fputs ("lo", stream);
4585 + else
4586 + fputs ("hs", stream);
4587 + break;
4588 + case LE:
4589 + if (code == 'i')
4590 + fputs ("gt", stream);
4591 + else
4592 + fputs ("le", stream);
4593 + break;
4594 + case LEU:
4595 + if (code == 'i')
4596 + fputs ("hi", stream);
4597 + else
4598 + fputs ("ls", stream);
4599 + break;
4600 + case CONST_INT:
4601 + {
4602 + HOST_WIDE_INT value = INTVAL (x);
4603 +
4604 + switch (code)
4605 + {
4606 + case 'm':
4607 + if ( HOST_BITS_PER_WIDE_INT > BITS_PER_WORD )
4608 + {
4609 + /* A const_int can be used to represent DImode constants. */
4610 + value >>= BITS_PER_WORD;
4611 + }
4612 + /* We might get a const_int immediate for setting a DI register,
4613 + we then must then return the correct sign extended DI. The most
4614 + significant word is just a sign extension. */
4615 + else if (value < 0)
4616 + value = -1;
4617 + else
4618 + value = 0;
4619 + break;
4620 + case 'i':
4621 + value++;
4622 + break;
4623 + case 'p':
4624 + {
4625 + /* Set to bit position of first bit set in immediate */
4626 + int i, bitpos = 32;
4627 + for (i = 0; i < 32; i++)
4628 + if (value & (1 << i))
4629 + {
4630 + bitpos = i;
4631 + break;
4632 + }
4633 + value = bitpos;
4634 + }
4635 + break;
4636 + case 'r':
4637 + {
4638 + /* Reglist 8 */
4639 + char op[50];
4640 + op[0] = '\0';
4641 +
4642 + if (value & 0x01)
4643 + sprintf (op, "r0-r3");
4644 + if (value & 0x02)
4645 + strlen (op) ? sprintf (op, "%s, r4-r7", op) : sprintf (op,
4646 + "r4-r7");
4647 + if (value & 0x04)
4648 + strlen (op) ? sprintf (op, "%s, r8-r9", op) : sprintf (op,
4649 + "r8-r9");
4650 + if (value & 0x08)
4651 + strlen (op) ? sprintf (op, "%s, r10", op) : sprintf (op,
4652 + "r10");
4653 + if (value & 0x10)
4654 + strlen (op) ? sprintf (op, "%s, r11", op) : sprintf (op,
4655 + "r11");
4656 + if (value & 0x20)
4657 + strlen (op) ? sprintf (op, "%s, r12", op) : sprintf (op,
4658 + "r12");
4659 + if (value & 0x40)
4660 + strlen (op) ? sprintf (op, "%s, lr", op) : sprintf (op, "lr");
4661 + if (value & 0x80)
4662 + strlen (op) ? sprintf (op, "%s, pc", op) : sprintf (op, "pc");
4663 +
4664 + fputs (op, stream);
4665 + return;
4666 + }
4667 + case 's':
4668 + {
4669 + /* Reglist 16 */
4670 + char reglist16_string[100];
4671 + int i;
4672 + reglist16_string[0] = '\0';
4673 +
4674 + for (i = 0; i < 16; ++i)
4675 + {
4676 + if (value & (1 << i))
4677 + {
4678 + strlen (reglist16_string) ? sprintf (reglist16_string,
4679 + "%s, %s",
4680 + reglist16_string,
4681 + reg_names
4682 + [INTERNAL_REGNUM
4683 + (i)]) :
4684 + sprintf (reglist16_string, "%s",
4685 + reg_names[INTERNAL_REGNUM (i)]);
4686 + }
4687 + }
4688 + fputs (reglist16_string, stream);
4689 + return;
4690 + }
4691 + case 'C':
4692 + {
4693 + /* RegListCP8 */
4694 + char reglist_string[100];
4695 + avr32_make_fp_reglist_w (value, (char *) reglist_string);
4696 + fputs (reglist_string, stream);
4697 + return;
4698 + }
4699 + case 'D':
4700 + {
4701 + /* RegListCPD8 */
4702 + char reglist_string[100];
4703 + avr32_make_fp_reglist_d (value, (char *) reglist_string);
4704 + fputs (reglist_string, stream);
4705 + return;
4706 + }
4707 + case 'h':
4708 + /* Print halfword part of word */
4709 + fputs (value ? "b" : "t", stream);
4710 + return;
4711 + }
4712 +
4713 + /* Print Value */
4714 + fprintf (stream, "%d", value);
4715 + break;
4716 + }
4717 + case CONST_DOUBLE:
4718 + {
4719 + HOST_WIDE_INT hi, lo;
4720 + if (SCALAR_FLOAT_MODE_P (GET_MODE (x)))
4721 + {
4722 + HOST_WIDE_INT target_float[2];
4723 + hi = lo = 0;
4724 + real_to_target (target_float, CONST_DOUBLE_REAL_VALUE (x),
4725 + GET_MODE (x));
4726 + /* For doubles the most significant part starts at index 0. */
4727 + if (GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
4728 + {
4729 + hi = target_float[0];
4730 + lo = target_float[1];
4731 + }
4732 + else
4733 + {
4734 + lo = target_float[0];
4735 + }
4736 + }
4737 + else
4738 + {
4739 + hi = CONST_DOUBLE_HIGH (x);
4740 + lo = CONST_DOUBLE_LOW (x);
4741 + }
4742 +
4743 + if (code == 'm')
4744 + fprintf (stream, "%ld", hi);
4745 + else
4746 + fprintf (stream, "%ld", lo);
4747 +
4748 + break;
4749 + }
4750 + case CONST:
4751 + output_addr_const (stream, XEXP (XEXP (x, 0), 0));
4752 + fprintf (stream, "+%ld", INTVAL (XEXP (XEXP (x, 0), 1)));
4753 + break;
4754 + case REG:
4755 + /* Swap register name if the register is DImode or DFmode. */
4756 + if (GET_MODE (x) == DImode || GET_MODE (x) == DFmode)
4757 + {
4758 + /* Double register must have an even numbered address */
4759 + gcc_assert (!(REGNO (x) % 2));
4760 + if (code == 'm')
4761 + fputs (reg_names[true_regnum (x)], stream);
4762 + else
4763 + fputs (reg_names[true_regnum (x) + 1], stream);
4764 + }
4765 + else if (GET_MODE (x) == TImode)
4766 + {
4767 + switch (code)
4768 + {
4769 + case 'T':
4770 + fputs (reg_names[true_regnum (x)], stream);
4771 + break;
4772 + case 'U':
4773 + fputs (reg_names[true_regnum (x) + 1], stream);
4774 + break;
4775 + case 'L':
4776 + fputs (reg_names[true_regnum (x) + 2], stream);
4777 + break;
4778 + case 'B':
4779 + fputs (reg_names[true_regnum (x) + 3], stream);
4780 + break;
4781 + default:
4782 + fprintf (stream, "%s, %s, %s, %s",
4783 + reg_names[true_regnum (x) + 3],
4784 + reg_names[true_regnum (x) + 2],
4785 + reg_names[true_regnum (x) + 1],
4786 + reg_names[true_regnum (x)]);
4787 + break;
4788 + }
4789 + }
4790 + else
4791 + {
4792 + fputs (reg_names[true_regnum (x)], stream);
4793 + }
4794 + break;
4795 + case CODE_LABEL:
4796 + case LABEL_REF:
4797 + case SYMBOL_REF:
4798 + output_addr_const (stream, x);
4799 + break;
4800 + case MEM:
4801 + switch (GET_CODE (XEXP (x, 0)))
4802 + {
4803 + case LABEL_REF:
4804 + case SYMBOL_REF:
4805 + output_addr_const (stream, XEXP (x, 0));
4806 + break;
4807 + case MEM:
4808 + switch (GET_CODE (XEXP (XEXP (x, 0), 0)))
4809 + {
4810 + case SYMBOL_REF:
4811 + output_addr_const (stream, XEXP (XEXP (x, 0), 0));
4812 + break;
4813 + default:
4814 + error = 1;
4815 + break;
4816 + }
4817 + break;
4818 + case REG:
4819 + avr32_print_operand (stream, XEXP (x, 0), 0);
4820 + if (code != 'p')
4821 + fputs ("[0]", stream);
4822 + break;
4823 + case PRE_DEC:
4824 + fputs ("--", stream);
4825 + avr32_print_operand (stream, XEXP (XEXP (x, 0), 0), 0);
4826 + break;
4827 + case POST_INC:
4828 + avr32_print_operand (stream, XEXP (XEXP (x, 0), 0), 0);
4829 + fputs ("++", stream);
4830 + break;
4831 + case PLUS:
4832 + {
4833 + rtx op0 = XEXP (XEXP (x, 0), 0);
4834 + rtx op1 = XEXP (XEXP (x, 0), 1);
4835 + rtx base = NULL_RTX, offset = NULL_RTX;
4836 +
4837 + if (avr32_address_register_rtx_p (op0, 1))
4838 + {
4839 + base = op0;
4840 + offset = op1;
4841 + }
4842 + else if (avr32_address_register_rtx_p (op1, 1))
4843 + {
4844 + /* Operands are switched. */
4845 + base = op1;
4846 + offset = op0;
4847 + }
4848 +
4849 + gcc_assert (base && offset
4850 + && avr32_address_register_rtx_p (base, 1)
4851 + && avr32_legitimate_index_p (GET_MODE (x), offset,
4852 + 1));
4853 +
4854 + avr32_print_operand (stream, base, 0);
4855 + fputs ("[", stream);
4856 + avr32_print_operand (stream, offset, 0);
4857 + fputs ("]", stream);
4858 + break;
4859 + }
4860 + case CONST:
4861 + output_addr_const (stream, XEXP (XEXP (XEXP (x, 0), 0), 0));
4862 + fprintf (stream, " + %ld",
4863 + INTVAL (XEXP (XEXP (XEXP (x, 0), 0), 1)));
4864 + break;
4865 + default:
4866 + error = 1;
4867 + }
4868 + break;
4869 + case MULT:
4870 + {
4871 + int value = INTVAL (XEXP (x, 1));
4872 +
4873 + /* Convert immediate in multiplication into a shift immediate */
4874 + switch (value)
4875 + {
4876 + case 2:
4877 + value = 1;
4878 + break;
4879 + case 4:
4880 + value = 2;
4881 + break;
4882 + case 8:
4883 + value = 3;
4884 + break;
4885 + default:
4886 + value = 0;
4887 + }
4888 + fprintf (stream, "%s << %i", reg_names[true_regnum (XEXP (x, 0))],
4889 + value);
4890 + break;
4891 + }
4892 + case ASHIFT:
4893 + if (GET_CODE (XEXP (x, 1)) == CONST_INT)
4894 + fprintf (stream, "%s << %i", reg_names[true_regnum (XEXP (x, 0))],
4895 + (int) INTVAL (XEXP (x, 1)));
4896 + else if (REG_P (XEXP (x, 1)))
4897 + fprintf (stream, "%s << %s", reg_names[true_regnum (XEXP (x, 0))],
4898 + reg_names[true_regnum (XEXP (x, 1))]);
4899 + else
4900 + {
4901 + error = 1;
4902 + }
4903 + break;
4904 + case LSHIFTRT:
4905 + if (GET_CODE (XEXP (x, 1)) == CONST_INT)
4906 + fprintf (stream, "%s >> %i", reg_names[true_regnum (XEXP (x, 0))],
4907 + (int) INTVAL (XEXP (x, 1)));
4908 + else if (REG_P (XEXP (x, 1)))
4909 + fprintf (stream, "%s >> %s", reg_names[true_regnum (XEXP (x, 0))],
4910 + reg_names[true_regnum (XEXP (x, 1))]);
4911 + else
4912 + {
4913 + error = 1;
4914 + }
4915 + fprintf (stream, ">>");
4916 + break;
4917 + case PARALLEL:
4918 + {
4919 + /* Load store multiple */
4920 + int i;
4921 + int count = XVECLEN (x, 0);
4922 + int reglist16 = 0;
4923 + char reglist16_string[100];
4924 +
4925 + for (i = 0; i < count; ++i)
4926 + {
4927 + rtx vec_elm = XVECEXP (x, 0, i);
4928 + if (GET_MODE (vec_elm) != SET)
4929 + {
4930 + debug_rtx (vec_elm);
4931 + internal_error ("Unknown element in parallel expression!");
4932 + }
4933 + if (GET_MODE (XEXP (vec_elm, 0)) == REG)
4934 + {
4935 + /* Load multiple */
4936 + reglist16 |= 1 << ASM_REGNUM (REGNO (XEXP (vec_elm, 0)));
4937 + }
4938 + else
4939 + {
4940 + /* Store multiple */
4941 + reglist16 |= 1 << ASM_REGNUM (REGNO (XEXP (vec_elm, 1)));
4942 + }
4943 + }
4944 +
4945 + avr32_make_reglist16 (reglist16, reglist16_string);
4946 + fputs (reglist16_string, stream);
4947 +
4948 + break;
4949 + }
4950 +
4951 + default:
4952 + error = 1;
4953 + }
4954 +
4955 + if (error)
4956 + {
4957 + debug_rtx (x);
4958 + internal_error ("Illegal expression for avr32_print_operand");
4959 + }
4960 + }
4961 +
4962 +rtx
4963 +avr32_get_note_reg_equiv (rtx insn)
4964 + {
4965 + rtx note;
4966 +
4967 + note = find_reg_note (insn, REG_EQUIV, NULL_RTX);
4968 +
4969 + if (note != NULL_RTX)
4970 + return XEXP (note, 0);
4971 + else
4972 + return NULL_RTX;
4973 + }
4974 +
4975 +/*
4976 + Outputs to stdio stream stream the assembler syntax for an instruction
4977 + operand that is a memory reference whose address is x. x is an RTL
4978 + expression.
4979 +
4980 + ToDo: fixme.
4981 + */
4982 +void
4983 +avr32_print_operand_address (FILE * stream, rtx x)
4984 + {
4985 + fprintf (stream, "(%d) /* address */", REGNO (x));
4986 + }
4987 +
4988 +/* Return true if _GLOBAL_OFFSET_TABLE_ symbol is mentioned. */
4989 +bool
4990 +avr32_got_mentioned_p (rtx addr)
4991 + {
4992 + if (GET_CODE (addr) == MEM)
4993 + addr = XEXP (addr, 0);
4994 + while (GET_CODE (addr) == CONST)
4995 + addr = XEXP (addr, 0);
4996 + if (GET_CODE (addr) == SYMBOL_REF)
4997 + {
4998 + return streq (XSTR (addr, 0), "_GLOBAL_OFFSET_TABLE_");
4999 + }
5000 + if (GET_CODE (addr) == PLUS || GET_CODE (addr) == MINUS)
5001 + {
5002 + bool l1, l2;
5003 +
5004 + l1 = avr32_got_mentioned_p (XEXP (addr, 0));
5005 + l2 = avr32_got_mentioned_p (XEXP (addr, 1));
5006 + return l1 || l2;
5007 + }
5008 + return false;
5009 + }
5010 +
5011 +
5012 +/* Find the symbol in an address expression. */
5013 +
5014 +rtx
5015 +avr32_find_symbol (rtx addr)
5016 + {
5017 + if (GET_CODE (addr) == MEM)
5018 + addr = XEXP (addr, 0);
5019 +
5020 + while (GET_CODE (addr) == CONST)
5021 + addr = XEXP (addr, 0);
5022 +
5023 + if (GET_CODE (addr) == SYMBOL_REF || GET_CODE (addr) == LABEL_REF)
5024 + return addr;
5025 + if (GET_CODE (addr) == PLUS)
5026 + {
5027 + rtx l1, l2;
5028 +
5029 + l1 = avr32_find_symbol (XEXP (addr, 0));
5030 + l2 = avr32_find_symbol (XEXP (addr, 1));
5031 + if (l1 != NULL_RTX && l2 == NULL_RTX)
5032 + return l1;
5033 + else if (l1 == NULL_RTX && l2 != NULL_RTX)
5034 + return l2;
5035 + }
5036 +
5037 + return NULL_RTX;
5038 + }
5039 +
5040 +
5041 +/* Routines for manipulation of the constant pool. */
5042 +
5043 +/* AVR32 instructions cannot load a large constant directly into a
5044 + register; they have to come from a pc relative load. The constant
5045 + must therefore be placed in the addressable range of the pc
5046 + relative load. Depending on the precise pc relative load
5047 + instruction the range is somewhere between 256 bytes and 4k. This
5048 + means that we often have to dump a constant inside a function, and
5049 + generate code to branch around it.
5050 +
5051 + It is important to minimize this, since the branches will slow
5052 + things down and make the code larger.
5053 +
5054 + Normally we can hide the table after an existing unconditional
5055 + branch so that there is no interruption of the flow, but in the
5056 + worst case the code looks like this:
5057 +
5058 + lddpc rn, L1
5059 + ...
5060 + rjmp L2
5061 + align
5062 + L1: .long value
5063 + L2:
5064 + ...
5065 +
5066 + lddpc rn, L3
5067 + ...
5068 + rjmp L4
5069 + align
5070 + L3: .long value
5071 + L4:
5072 + ...
5073 +
5074 + We fix this by performing a scan after scheduling, which notices
5075 + which instructions need to have their operands fetched from the
5076 + constant table and builds the table.
5077 +
5078 + The algorithm starts by building a table of all the constants that
5079 + need fixing up and all the natural barriers in the function (places
5080 + where a constant table can be dropped without breaking the flow).
5081 + For each fixup we note how far the pc-relative replacement will be
5082 + able to reach and the offset of the instruction into the function.
5083 +
5084 + Having built the table we then group the fixes together to form
5085 + tables that are as large as possible (subject to addressing
5086 + constraints) and emit each table of constants after the last
5087 + barrier that is within range of all the instructions in the group.
5088 + If a group does not contain a barrier, then we forcibly create one
5089 + by inserting a jump instruction into the flow. Once the table has
5090 + been inserted, the insns are then modified to reference the
5091 + relevant entry in the pool.
5092 +
5093 + Possible enhancements to the algorithm (not implemented) are:
5094 +
5095 + 1) For some processors and object formats, there may be benefit in
5096 + aligning the pools to the start of cache lines; this alignment
5097 + would need to be taken into account when calculating addressability
5098 + of a pool. */
5099 +
5100 +/* These typedefs are located at the start of this file, so that
5101 + they can be used in the prototypes there. This comment is to
5102 + remind readers of that fact so that the following structures
5103 + can be understood more easily.
5104 +
5105 + typedef struct minipool_node Mnode;
5106 + typedef struct minipool_fixup Mfix; */
5107 +
5108 +struct minipool_node
5109 +{
5110 + /* Doubly linked chain of entries. */
5111 + Mnode *next;
5112 + Mnode *prev;
5113 + /* The maximum offset into the code that this entry can be placed. While
5114 + pushing fixes for forward references, all entries are sorted in order of
5115 + increasing max_address. */
5116 + HOST_WIDE_INT max_address;
5117 + /* Similarly for an entry inserted for a backwards ref. */
5118 + HOST_WIDE_INT min_address;
5119 + /* The number of fixes referencing this entry. This can become zero if we
5120 + "unpush" an entry. In this case we ignore the entry when we come to
5121 + emit the code. */
5122 + int refcount;
5123 + /* The offset from the start of the minipool. */
5124 + HOST_WIDE_INT offset;
5125 + /* The value in table. */
5126 + rtx value;
5127 + /* The mode of value. */
5128 + enum machine_mode mode;
5129 + /* The size of the value. */
5130 + int fix_size;
5131 +};
5132 +
5133 +struct minipool_fixup
5134 +{
5135 + Mfix *next;
5136 + rtx insn;
5137 + HOST_WIDE_INT address;
5138 + rtx *loc;
5139 + enum machine_mode mode;
5140 + int fix_size;
5141 + rtx value;
5142 + Mnode *minipool;
5143 + HOST_WIDE_INT forwards;
5144 + HOST_WIDE_INT backwards;
5145 +};
5146 +
5147 +
5148 +/* Fixes less than a word need padding out to a word boundary. */
5149 +#define MINIPOOL_FIX_SIZE(mode, value) \
5150 + (IS_FORCE_MINIPOOL(value) ? 0 : \
5151 + (GET_MODE_SIZE ((mode)) >= 4 ? GET_MODE_SIZE ((mode)) : 4))
5152 +
5153 +#define IS_FORCE_MINIPOOL(x) \
5154 + (GET_CODE(x) == UNSPEC && \
5155 + XINT(x, 1) == UNSPEC_FORCE_MINIPOOL)
5156 +
5157 +static Mnode *minipool_vector_head;
5158 +static Mnode *minipool_vector_tail;
5159 +
5160 +/* The linked list of all minipool fixes required for this function. */
5161 +Mfix *minipool_fix_head;
5162 +Mfix *minipool_fix_tail;
5163 +/* The fix entry for the current minipool, once it has been placed. */
5164 +Mfix *minipool_barrier;
5165 +
5166 +/* Determines if INSN is the start of a jump table. Returns the end
5167 + of the TABLE or NULL_RTX. */
5168 +static rtx
5169 +is_jump_table (rtx insn)
5170 + {
5171 + rtx table;
5172 +
5173 + if (GET_CODE (insn) == JUMP_INSN
5174 + && JUMP_LABEL (insn) != NULL
5175 + && ((table = next_real_insn (JUMP_LABEL (insn)))
5176 + == next_real_insn (insn))
5177 + && table != NULL
5178 + && GET_CODE (table) == JUMP_INSN
5179 + && (GET_CODE (PATTERN (table)) == ADDR_VEC
5180 + || GET_CODE (PATTERN (table)) == ADDR_DIFF_VEC))
5181 + return table;
5182 +
5183 + return NULL_RTX;
5184 + }
5185 +
5186 +static HOST_WIDE_INT
5187 +get_jump_table_size (rtx insn)
5188 + {
5189 + /* ADDR_VECs only take room if read-only data does into the text section. */
5190 + if (JUMP_TABLES_IN_TEXT_SECTION
5191 +#if !defined(READONLY_DATA_SECTION_ASM_OP)
5192 + || 1
5193 +#endif
5194 + )
5195 + {
5196 + rtx body = PATTERN (insn);
5197 + int elt = GET_CODE (body) == ADDR_DIFF_VEC ? 1 : 0;
5198 +
5199 + return GET_MODE_SIZE (GET_MODE (body)) * XVECLEN (body, elt);
5200 + }
5201 +
5202 + return 0;
5203 + }
5204 +
5205 +/* Move a minipool fix MP from its current location to before MAX_MP.
5206 + If MAX_MP is NULL, then MP doesn't need moving, but the addressing
5207 + constraints may need updating. */
5208 +static Mnode *
5209 +move_minipool_fix_forward_ref (Mnode * mp, Mnode * max_mp,
5210 + HOST_WIDE_INT max_address)
5211 + {
5212 + /* This should never be true and the code below assumes these are
5213 + different. */
5214 + if (mp == max_mp)
5215 + abort ();
5216 +
5217 + if (max_mp == NULL)
5218 + {
5219 + if (max_address < mp->max_address)
5220 + mp->max_address = max_address;
5221 + }
5222 + else
5223 + {
5224 + if (max_address > max_mp->max_address - mp->fix_size)
5225 + mp->max_address = max_mp->max_address - mp->fix_size;
5226 + else
5227 + mp->max_address = max_address;
5228 +
5229 + /* Unlink MP from its current position. Since max_mp is non-null,
5230 + mp->prev must be non-null. */
5231 + mp->prev->next = mp->next;
5232 + if (mp->next != NULL)
5233 + mp->next->prev = mp->prev;
5234 + else
5235 + minipool_vector_tail = mp->prev;
5236 +
5237 + /* Re-insert it before MAX_MP. */
5238 + mp->next = max_mp;
5239 + mp->prev = max_mp->prev;
5240 + max_mp->prev = mp;
5241 +
5242 + if (mp->prev != NULL)
5243 + mp->prev->next = mp;
5244 + else
5245 + minipool_vector_head = mp;
5246 + }
5247 +
5248 + /* Save the new entry. */
5249 + max_mp = mp;
5250 +
5251 + /* Scan over the preceding entries and adjust their addresses as required.
5252 + */
5253 + while (mp->prev != NULL
5254 + && mp->prev->max_address > mp->max_address - mp->prev->fix_size)
5255 + {
5256 + mp->prev->max_address = mp->max_address - mp->prev->fix_size;
5257 + mp = mp->prev;
5258 + }
5259 +
5260 + return max_mp;
5261 + }
5262 +
5263 +/* Add a constant to the minipool for a forward reference. Returns the
5264 + node added or NULL if the constant will not fit in this pool. */
5265 +static Mnode *
5266 +add_minipool_forward_ref (Mfix * fix)
5267 +{
5268 + /* If set, max_mp is the first pool_entry that has a lower constraint than
5269 + the one we are trying to add. */
5270 + Mnode *max_mp = NULL;
5271 + HOST_WIDE_INT max_address = fix->address + fix->forwards;
5272 + Mnode *mp;
5273 +
5274 + /* If this fix's address is greater than the address of the first entry,
5275 + then we can't put the fix in this pool. We subtract the size of the
5276 + current fix to ensure that if the table is fully packed we still have
5277 + enough room to insert this value by suffling the other fixes forwards. */
5278 + if (minipool_vector_head &&
5279 + fix->address >= minipool_vector_head->max_address - fix->fix_size)
5280 + return NULL;
5281 +
5282 + /* Scan the pool to see if a constant with the same value has already been
5283 + added. While we are doing this, also note the location where we must
5284 + insert the constant if it doesn't already exist. */
5285 + for (mp = minipool_vector_head; mp != NULL; mp = mp->next)
5286 + {
5287 + if (GET_CODE (fix->value) == GET_CODE (mp->value)
5288 + && fix->mode == mp->mode
5289 + && (GET_CODE (fix->value) != CODE_LABEL
5290 + || (CODE_LABEL_NUMBER (fix->value)
5291 + == CODE_LABEL_NUMBER (mp->value)))
5292 + && rtx_equal_p (fix->value, mp->value))
5293 + {
5294 + /* More than one fix references this entry. */
5295 + mp->refcount++;
5296 + return move_minipool_fix_forward_ref (mp, max_mp, max_address);
5297 + }
5298 +
5299 + /* Note the insertion point if necessary. */
5300 + if (max_mp == NULL && mp->max_address > max_address)
5301 + max_mp = mp;
5302 +
5303 + }
5304 +
5305 + /* The value is not currently in the minipool, so we need to create a new
5306 + entry for it. If MAX_MP is NULL, the entry will be put on the end of
5307 + the list since the placement is less constrained than any existing
5308 + entry. Otherwise, we insert the new fix before MAX_MP and, if
5309 + necessary, adjust the constraints on the other entries. */
5310 + mp = xmalloc (sizeof (*mp));
5311 + mp->fix_size = fix->fix_size;
5312 + mp->mode = fix->mode;
5313 + mp->value = fix->value;
5314 + mp->refcount = 1;
5315 + /* Not yet required for a backwards ref. */
5316 + mp->min_address = -65536;
5317 +
5318 + if (max_mp == NULL)
5319 + {
5320 + mp->max_address = max_address;
5321 + mp->next = NULL;
5322 + mp->prev = minipool_vector_tail;
5323 +
5324 + if (mp->prev == NULL)
5325 + {
5326 + minipool_vector_head = mp;
5327 + minipool_vector_label = gen_label_rtx ();
5328 + }
5329 + else
5330 + mp->prev->next = mp;
5331 +
5332 + minipool_vector_tail = mp;
5333 + }
5334 + else
5335 + {
5336 + if (max_address > max_mp->max_address - mp->fix_size)
5337 + mp->max_address = max_mp->max_address - mp->fix_size;
5338 + else
5339 + mp->max_address = max_address;
5340 +
5341 + mp->next = max_mp;
5342 + mp->prev = max_mp->prev;
5343 + max_mp->prev = mp;
5344 + if (mp->prev != NULL)
5345 + mp->prev->next = mp;
5346 + else
5347 + minipool_vector_head = mp;
5348 + }
5349 +
5350 + /* Save the new entry. */
5351 + max_mp = mp;
5352 +
5353 + /* Scan over the preceding entries and adjust their addresses as required.
5354 + */
5355 + while (mp->prev != NULL
5356 + && mp->prev->max_address > mp->max_address - mp->prev->fix_size)
5357 + {
5358 + mp->prev->max_address = mp->max_address - mp->prev->fix_size;
5359 + mp = mp->prev;
5360 + }
5361 +
5362 + return max_mp;
5363 +}
5364 +
5365 +static Mnode *
5366 +move_minipool_fix_backward_ref (Mnode * mp, Mnode * min_mp,
5367 + HOST_WIDE_INT min_address)
5368 + {
5369 + HOST_WIDE_INT offset;
5370 +
5371 + /* This should never be true, and the code below assumes these are
5372 + different. */
5373 + if (mp == min_mp)
5374 + abort ();
5375 +
5376 + if (min_mp == NULL)
5377 + {
5378 + if (min_address > mp->min_address)
5379 + mp->min_address = min_address;
5380 + }
5381 + else
5382 + {
5383 + /* We will adjust this below if it is too loose. */
5384 + mp->min_address = min_address;
5385 +
5386 + /* Unlink MP from its current position. Since min_mp is non-null,
5387 + mp->next must be non-null. */
5388 + mp->next->prev = mp->prev;
5389 + if (mp->prev != NULL)
5390 + mp->prev->next = mp->next;
5391 + else
5392 + minipool_vector_head = mp->next;
5393 +
5394 + /* Reinsert it after MIN_MP. */
5395 + mp->prev = min_mp;
5396 + mp->next = min_mp->next;
5397 + min_mp->next = mp;
5398 + if (mp->next != NULL)
5399 + mp->next->prev = mp;
5400 + else
5401 + minipool_vector_tail = mp;
5402 + }
5403 +
5404 + min_mp = mp;
5405 +
5406 + offset = 0;
5407 + for (mp = minipool_vector_head; mp != NULL; mp = mp->next)
5408 + {
5409 + mp->offset = offset;
5410 + if (mp->refcount > 0)
5411 + offset += mp->fix_size;
5412 +
5413 + if (mp->next && mp->next->min_address < mp->min_address + mp->fix_size)
5414 + mp->next->min_address = mp->min_address + mp->fix_size;
5415 + }
5416 +
5417 + return min_mp;
5418 + }
5419 +
5420 +/* Add a constant to the minipool for a backward reference. Returns the
5421 + node added or NULL if the constant will not fit in this pool.
5422 +
5423 + Note that the code for insertion for a backwards reference can be
5424 + somewhat confusing because the calculated offsets for each fix do
5425 + not take into account the size of the pool (which is still under
5426 + construction. */
5427 +static Mnode *
5428 +add_minipool_backward_ref (Mfix * fix)
5429 +{
5430 + /* If set, min_mp is the last pool_entry that has a lower constraint than
5431 + the one we are trying to add. */
5432 + Mnode *min_mp = NULL;
5433 + /* This can be negative, since it is only a constraint. */
5434 + HOST_WIDE_INT min_address = fix->address - fix->backwards;
5435 + Mnode *mp;
5436 +
5437 + /* If we can't reach the current pool from this insn, or if we can't insert
5438 + this entry at the end of the pool without pushing other fixes out of
5439 + range, then we don't try. This ensures that we can't fail later on. */
5440 + if (min_address >= minipool_barrier->address
5441 + || (minipool_vector_tail->min_address + fix->fix_size
5442 + >= minipool_barrier->address))
5443 + return NULL;
5444 +
5445 + /* Scan the pool to see if a constant with the same value has already been
5446 + added. While we are doing this, also note the location where we must
5447 + insert the constant if it doesn't already exist. */
5448 + for (mp = minipool_vector_tail; mp != NULL; mp = mp->prev)
5449 + {
5450 + if (GET_CODE (fix->value) == GET_CODE (mp->value)
5451 + && fix->mode == mp->mode
5452 + && (GET_CODE (fix->value) != CODE_LABEL
5453 + || (CODE_LABEL_NUMBER (fix->value)
5454 + == CODE_LABEL_NUMBER (mp->value)))
5455 + && rtx_equal_p (fix->value, mp->value)
5456 + /* Check that there is enough slack to move this entry to the end
5457 + of the table (this is conservative). */
5458 + && (mp->max_address
5459 + > (minipool_barrier->address
5460 + + minipool_vector_tail->offset
5461 + + minipool_vector_tail->fix_size)))
5462 + {
5463 + mp->refcount++;
5464 + return move_minipool_fix_backward_ref (mp, min_mp, min_address);
5465 + }
5466 +
5467 + if (min_mp != NULL)
5468 + mp->min_address += fix->fix_size;
5469 + else
5470 + {
5471 + /* Note the insertion point if necessary. */
5472 + if (mp->min_address < min_address)
5473 + {
5474 + min_mp = mp;
5475 + }
5476 + else if (mp->max_address
5477 + < minipool_barrier->address + mp->offset + fix->fix_size)
5478 + {
5479 + /* Inserting before this entry would push the fix beyond its
5480 + maximum address (which can happen if we have re-located a
5481 + forwards fix); force the new fix to come after it. */
5482 + min_mp = mp;
5483 + min_address = mp->min_address + fix->fix_size;
5484 + }
5485 + }
5486 + }
5487 +
5488 + /* We need to create a new entry. */
5489 + mp = xmalloc (sizeof (*mp));
5490 + mp->fix_size = fix->fix_size;
5491 + mp->mode = fix->mode;
5492 + mp->value = fix->value;
5493 + mp->refcount = 1;
5494 + mp->max_address = minipool_barrier->address + 65536;
5495 +
5496 + mp->min_address = min_address;
5497 +
5498 + if (min_mp == NULL)
5499 + {
5500 + mp->prev = NULL;
5501 + mp->next = minipool_vector_head;
5502 +
5503 + if (mp->next == NULL)
5504 + {
5505 + minipool_vector_tail = mp;
5506 + minipool_vector_label = gen_label_rtx ();
5507 + }
5508 + else
5509 + mp->next->prev = mp;
5510 +
5511 + minipool_vector_head = mp;
5512 + }
5513 + else
5514 + {
5515 + mp->next = min_mp->next;
5516 + mp->prev = min_mp;
5517 + min_mp->next = mp;
5518 +
5519 + if (mp->next != NULL)
5520 + mp->next->prev = mp;
5521 + else
5522 + minipool_vector_tail = mp;
5523 + }
5524 +
5525 + /* Save the new entry. */
5526 + min_mp = mp;
5527 +
5528 + if (mp->prev)
5529 + mp = mp->prev;
5530 + else
5531 + mp->offset = 0;
5532 +
5533 + /* Scan over the following entries and adjust their offsets. */
5534 + while (mp->next != NULL)
5535 + {
5536 + if (mp->next->min_address < mp->min_address + mp->fix_size)
5537 + mp->next->min_address = mp->min_address + mp->fix_size;
5538 +
5539 + if (mp->refcount)
5540 + mp->next->offset = mp->offset + mp->fix_size;
5541 + else
5542 + mp->next->offset = mp->offset;
5543 +
5544 + mp = mp->next;
5545 + }
5546 +
5547 + return min_mp;
5548 +}
5549 +
5550 +static void
5551 +assign_minipool_offsets (Mfix * barrier)
5552 + {
5553 + HOST_WIDE_INT offset = 0;
5554 + Mnode *mp;
5555 +
5556 + minipool_barrier = barrier;
5557 +
5558 + for (mp = minipool_vector_head; mp != NULL; mp = mp->next)
5559 + {
5560 + mp->offset = offset;
5561 +
5562 + if (mp->refcount > 0)
5563 + offset += mp->fix_size;
5564 + }
5565 + }
5566 +
5567 +/* Print a symbolic form of X to the debug file, F. */
5568 +static void
5569 +avr32_print_value (FILE * f, rtx x)
5570 + {
5571 + switch (GET_CODE (x))
5572 + {
5573 + case CONST_INT:
5574 + fprintf (f, "0x%x", (int) INTVAL (x));
5575 + return;
5576 +
5577 + case CONST_DOUBLE:
5578 + fprintf (f, "<0x%lx,0x%lx>", (long) XWINT (x, 2), (long) XWINT (x, 3));
5579 + return;
5580 +
5581 + case CONST_VECTOR:
5582 + {
5583 + int i;
5584 +
5585 + fprintf (f, "<");
5586 + for (i = 0; i < CONST_VECTOR_NUNITS (x); i++)
5587 + {
5588 + fprintf (f, "0x%x", (int) INTVAL (CONST_VECTOR_ELT (x, i)));
5589 + if (i < (CONST_VECTOR_NUNITS (x) - 1))
5590 + fputc (',', f);
5591 + }
5592 + fprintf (f, ">");
5593 + }
5594 + return;
5595 +
5596 + case CONST_STRING:
5597 + fprintf (f, "\"%s\"", XSTR (x, 0));
5598 + return;
5599 +
5600 + case SYMBOL_REF:
5601 + fprintf (f, "`%s'", XSTR (x, 0));
5602 + return;
5603 +
5604 + case LABEL_REF:
5605 + fprintf (f, "L%d", INSN_UID (XEXP (x, 0)));
5606 + return;
5607 +
5608 + case CONST:
5609 + avr32_print_value (f, XEXP (x, 0));
5610 + return;
5611 +
5612 + case PLUS:
5613 + avr32_print_value (f, XEXP (x, 0));
5614 + fprintf (f, "+");
5615 + avr32_print_value (f, XEXP (x, 1));
5616 + return;
5617 +
5618 + case PC:
5619 + fprintf (f, "pc");
5620 + return;
5621 +
5622 + default:
5623 + fprintf (f, "????");
5624 + return;
5625 + }
5626 + }
5627 +
5628 +int
5629 +is_minipool_label (rtx label)
5630 + {
5631 + minipool_labels *cur_mp_label = cfun->machine->minipool_label_head;
5632 +
5633 + if (GET_CODE (label) != CODE_LABEL)
5634 + return FALSE;
5635 +
5636 + while (cur_mp_label)
5637 + {
5638 + if (CODE_LABEL_NUMBER (label)
5639 + == CODE_LABEL_NUMBER (cur_mp_label->label))
5640 + return TRUE;
5641 + cur_mp_label = cur_mp_label->next;
5642 + }
5643 + return FALSE;
5644 + }
5645 +
5646 +static void
5647 +new_minipool_label (rtx label)
5648 + {
5649 + if (!cfun->machine->minipool_label_head)
5650 + {
5651 + cfun->machine->minipool_label_head =
5652 + ggc_alloc (sizeof (minipool_labels));
5653 + cfun->machine->minipool_label_tail = cfun->machine->minipool_label_head;
5654 + cfun->machine->minipool_label_head->label = label;
5655 + cfun->machine->minipool_label_head->next = 0;
5656 + cfun->machine->minipool_label_head->prev = 0;
5657 + }
5658 + else
5659 + {
5660 + cfun->machine->minipool_label_tail->next =
5661 + ggc_alloc (sizeof (minipool_labels));
5662 + cfun->machine->minipool_label_tail->next->label = label;
5663 + cfun->machine->minipool_label_tail->next->next = 0;
5664 + cfun->machine->minipool_label_tail->next->prev =
5665 + cfun->machine->minipool_label_tail;
5666 + cfun->machine->minipool_label_tail =
5667 + cfun->machine->minipool_label_tail->next;
5668 + }
5669 + }
5670 +
5671 +/* Output the literal table */
5672 +static void
5673 +dump_minipool (rtx scan)
5674 + {
5675 + Mnode *mp;
5676 + Mnode *nmp;
5677 +
5678 + if (dump_file)
5679 + fprintf (dump_file,
5680 + ";; Emitting minipool after insn %u; address %ld; align %d (bytes)\n",
5681 + INSN_UID (scan), (unsigned long) minipool_barrier->address, 4);
5682 +
5683 + scan = emit_insn_after (gen_consttable_start (), scan);
5684 + scan = emit_insn_after (gen_align_4 (), scan);
5685 + scan = emit_label_after (minipool_vector_label, scan);
5686 + new_minipool_label (minipool_vector_label);
5687 +
5688 + for (mp = minipool_vector_head; mp != NULL; mp = nmp)
5689 + {
5690 + if (mp->refcount > 0)
5691 + {
5692 + if (dump_file)
5693 + {
5694 + fprintf (dump_file,
5695 + ";; Offset %u, min %ld, max %ld ",
5696 + (unsigned) mp->offset, (unsigned long) mp->min_address,
5697 + (unsigned long) mp->max_address);
5698 + avr32_print_value (dump_file, mp->value);
5699 + fputc ('\n', dump_file);
5700 + }
5701 +
5702 + switch (mp->fix_size)
5703 + {
5704 +#ifdef HAVE_consttable_4
5705 + case 4:
5706 + scan = emit_insn_after (gen_consttable_4 (mp->value), scan);
5707 + break;
5708 +
5709 +#endif
5710 +#ifdef HAVE_consttable_8
5711 + case 8:
5712 + scan = emit_insn_after (gen_consttable_8 (mp->value), scan);
5713 + break;
5714 +
5715 +#endif
5716 +#ifdef HAVE_consttable_16
5717 + case 16:
5718 + scan = emit_insn_after (gen_consttable_16 (mp->value), scan);
5719 + break;
5720 +
5721 +#endif
5722 + case 0:
5723 + /* This can happen for force-minipool entries which just are
5724 + there to force the minipool to be generate. */
5725 + break;
5726 + default:
5727 + abort ();
5728 + break;
5729 + }
5730 + }
5731 +
5732 + nmp = mp->next;
5733 + free (mp);
5734 + }
5735 +
5736 + minipool_vector_head = minipool_vector_tail = NULL;
5737 + scan = emit_insn_after (gen_consttable_end (), scan);
5738 + scan = emit_barrier_after (scan);
5739 + }
5740 +
5741 +/* Return the cost of forcibly inserting a barrier after INSN. */
5742 +static int
5743 +avr32_barrier_cost (rtx insn)
5744 + {
5745 + /* Basing the location of the pool on the loop depth is preferable, but at
5746 + the moment, the basic block information seems to be corrupt by this
5747 + stage of the compilation. */
5748 + int base_cost = 50;
5749 + rtx next = next_nonnote_insn (insn);
5750 +
5751 + if (next != NULL && GET_CODE (next) == CODE_LABEL)
5752 + base_cost -= 20;
5753 +
5754 + switch (GET_CODE (insn))
5755 + {
5756 + case CODE_LABEL:
5757 + /* It will always be better to place the table before the label, rather
5758 + than after it. */
5759 + return 50;
5760 +
5761 + case INSN:
5762 + case CALL_INSN:
5763 + return base_cost;
5764 +
5765 + case JUMP_INSN:
5766 + return base_cost - 10;
5767 +
5768 + default:
5769 + return base_cost + 10;
5770 + }
5771 + }
5772 +
5773 +/* Find the best place in the insn stream in the range
5774 + (FIX->address,MAX_ADDRESS) to forcibly insert a minipool barrier.
5775 + Create the barrier by inserting a jump and add a new fix entry for
5776 + it. */
5777 +static Mfix *
5778 +create_fix_barrier (Mfix * fix, HOST_WIDE_INT max_address)
5779 +{
5780 + HOST_WIDE_INT count = 0;
5781 + rtx barrier;
5782 + rtx from = fix->insn;
5783 + rtx selected = from;
5784 + int selected_cost;
5785 + HOST_WIDE_INT selected_address;
5786 + Mfix *new_fix;
5787 + HOST_WIDE_INT max_count = max_address - fix->address;
5788 + rtx label = gen_label_rtx ();
5789 +
5790 + selected_cost = avr32_barrier_cost (from);
5791 + selected_address = fix->address;
5792 +
5793 + while (from && count < max_count)
5794 + {
5795 + rtx tmp;
5796 + int new_cost;
5797 +
5798 + /* This code shouldn't have been called if there was a natural barrier
5799 + within range. */
5800 + if (GET_CODE (from) == BARRIER)
5801 + abort ();
5802 +
5803 + /* Count the length of this insn. */
5804 + count += get_attr_length (from);
5805 +
5806 + /* If there is a jump table, add its length. */
5807 + tmp = is_jump_table (from);
5808 + if (tmp != NULL)
5809 + {
5810 + count += get_jump_table_size (tmp);
5811 +
5812 + /* Jump tables aren't in a basic block, so base the cost on the
5813 + dispatch insn. If we select this location, we will still put
5814 + the pool after the table. */
5815 + new_cost = avr32_barrier_cost (from);
5816 +
5817 + if (count < max_count && new_cost <= selected_cost)
5818 + {
5819 + selected = tmp;
5820 + selected_cost = new_cost;
5821 + selected_address = fix->address + count;
5822 + }
5823 +
5824 + /* Continue after the dispatch table. */
5825 + from = NEXT_INSN (tmp);
5826 + continue;
5827 + }
5828 +
5829 + new_cost = avr32_barrier_cost (from);
5830 +
5831 + if (count < max_count && new_cost <= selected_cost)
5832 + {
5833 + selected = from;
5834 + selected_cost = new_cost;
5835 + selected_address = fix->address + count;
5836 + }
5837 +
5838 + from = NEXT_INSN (from);
5839 + }
5840 +
5841 + /* Create a new JUMP_INSN that branches around a barrier. */
5842 + from = emit_jump_insn_after (gen_jump (label), selected);
5843 + JUMP_LABEL (from) = label;
5844 + barrier = emit_barrier_after (from);
5845 + emit_label_after (label, barrier);
5846 +
5847 + /* Create a minipool barrier entry for the new barrier. */
5848 + new_fix = (Mfix *) obstack_alloc (&minipool_obstack, sizeof (*new_fix));
5849 + new_fix->insn = barrier;
5850 + new_fix->address = selected_address;
5851 + new_fix->next = fix->next;
5852 + fix->next = new_fix;
5853 +
5854 + return new_fix;
5855 +}
5856 +
5857 +/* Record that there is a natural barrier in the insn stream at
5858 + ADDRESS. */
5859 +static void
5860 +push_minipool_barrier (rtx insn, HOST_WIDE_INT address)
5861 + {
5862 + Mfix *fix = (Mfix *) obstack_alloc (&minipool_obstack, sizeof (*fix));
5863 +
5864 + fix->insn = insn;
5865 + fix->address = address;
5866 +
5867 + fix->next = NULL;
5868 + if (minipool_fix_head != NULL)
5869 + minipool_fix_tail->next = fix;
5870 + else
5871 + minipool_fix_head = fix;
5872 +
5873 + minipool_fix_tail = fix;
5874 + }
5875 +
5876 +/* Record INSN, which will need fixing up to load a value from the
5877 + minipool. ADDRESS is the offset of the insn since the start of the
5878 + function; LOC is a pointer to the part of the insn which requires
5879 + fixing; VALUE is the constant that must be loaded, which is of type
5880 + MODE. */
5881 +static void
5882 +push_minipool_fix (rtx insn, HOST_WIDE_INT address, rtx * loc,
5883 + enum machine_mode mode, rtx value)
5884 + {
5885 + Mfix *fix = (Mfix *) obstack_alloc (&minipool_obstack, sizeof (*fix));
5886 + rtx body = PATTERN (insn);
5887 +
5888 + fix->insn = insn;
5889 + fix->address = address;
5890 + fix->loc = loc;
5891 + fix->mode = mode;
5892 + fix->fix_size = MINIPOOL_FIX_SIZE (mode, value);
5893 + fix->value = value;
5894 +
5895 + if (GET_CODE (body) == PARALLEL)
5896 + {
5897 + /* Mcall : Ks16 << 2 */
5898 + fix->forwards = ((1 << 15) - 1) << 2;
5899 + fix->backwards = (1 << 15) << 2;
5900 + }
5901 + else if (GET_CODE (body) == SET
5902 + && GET_MODE_SIZE (GET_MODE (SET_DEST (body))) == 4)
5903 + {
5904 + /* Word Load */
5905 + if (TARGET_HARD_FLOAT
5906 + && GET_MODE_CLASS (GET_MODE (SET_DEST (body))) == MODE_FLOAT)
5907 + {
5908 + /* Ldc0.w : Ku12 << 2 */
5909 + fix->forwards = ((1 << 12) - 1) << 2;
5910 + fix->backwards = 0;
5911 + }
5912 + else
5913 + {
5914 + if (optimize_size)
5915 + {
5916 + /* Lddpc : Ku7 << 2 */
5917 + fix->forwards = ((1 << 7) - 1) << 2;
5918 + fix->backwards = 0;
5919 + }
5920 + else
5921 + {
5922 + /* Ld.w : Ks16 */
5923 + fix->forwards = ((1 << 15) - 4);
5924 + fix->backwards = (1 << 15);
5925 + }
5926 + }
5927 + }
5928 + else if (GET_CODE (body) == SET
5929 + && GET_MODE_SIZE (GET_MODE (SET_DEST (body))) == 8)
5930 + {
5931 + /* Double word load */
5932 + if (TARGET_HARD_FLOAT
5933 + && GET_MODE_CLASS (GET_MODE (SET_DEST (body))) == MODE_FLOAT)
5934 + {
5935 + /* Ldc0.d : Ku12 << 2 */
5936 + fix->forwards = ((1 << 12) - 1) << 2;
5937 + fix->backwards = 0;
5938 + }
5939 + else
5940 + {
5941 + /* Ld.d : Ks16 */
5942 + fix->forwards = ((1 << 15) - 4);
5943 + fix->backwards = (1 << 15);
5944 + }
5945 + }
5946 + else if (GET_CODE (body) == UNSPEC_VOLATILE
5947 + && XINT (body, 1) == VUNSPEC_MVRC)
5948 + {
5949 + /* Coprocessor load */
5950 + /* Ldc : Ku8 << 2 */
5951 + fix->forwards = ((1 << 8) - 1) << 2;
5952 + fix->backwards = 0;
5953 + }
5954 + else
5955 + {
5956 + /* Assume worst case which is lddpc insn. */
5957 + fix->forwards = ((1 << 7) - 1) << 2;
5958 + fix->backwards = 0;
5959 + }
5960 +
5961 + fix->minipool = NULL;
5962 +
5963 + /* If an insn doesn't have a range defined for it, then it isn't expecting
5964 + to be reworked by this code. Better to abort now than to generate duff
5965 + assembly code. */
5966 + if (fix->forwards == 0 && fix->backwards == 0)
5967 + abort ();
5968 +
5969 + if (dump_file)
5970 + {
5971 + fprintf (dump_file,
5972 + ";; %smode fixup for i%d; addr %lu, range (%ld,%ld): ",
5973 + GET_MODE_NAME (mode),
5974 + INSN_UID (insn), (unsigned long) address,
5975 + -1 * (long) fix->backwards, (long) fix->forwards);
5976 + avr32_print_value (dump_file, fix->value);
5977 + fprintf (dump_file, "\n");
5978 + }
5979 +
5980 + /* Add it to the chain of fixes. */
5981 + fix->next = NULL;
5982 +
5983 + if (minipool_fix_head != NULL)
5984 + minipool_fix_tail->next = fix;
5985 + else
5986 + minipool_fix_head = fix;
5987 +
5988 + minipool_fix_tail = fix;
5989 + }
5990 +
5991 +/* Scan INSN and note any of its operands that need fixing.
5992 + If DO_PUSHES is false we do not actually push any of the fixups
5993 + needed. The function returns TRUE is any fixups were needed/pushed.
5994 + This is used by avr32_memory_load_p() which needs to know about loads
5995 + of constants that will be converted into minipool loads. */
5996 +static bool
5997 +note_invalid_constants (rtx insn, HOST_WIDE_INT address, int do_pushes)
5998 + {
5999 + bool result = false;
6000 + int opno;
6001 +
6002 + extract_insn (insn);
6003 +
6004 + if (!constrain_operands (1))
6005 + fatal_insn_not_found (insn);
6006 +
6007 + if (recog_data.n_alternatives == 0)
6008 + return false;
6009 +
6010 + /* Fill in recog_op_alt with information about the constraints of this
6011 + insn. */
6012 + preprocess_constraints ();
6013 +
6014 + for (opno = 0; opno < recog_data.n_operands; opno++)
6015 + {
6016 + rtx op;
6017 +
6018 + /* Things we need to fix can only occur in inputs. */
6019 + if (recog_data.operand_type[opno] != OP_IN)
6020 + continue;
6021 +
6022 + op = recog_data.operand[opno];
6023 +
6024 + if (avr32_const_pool_ref_operand (op, GET_MODE (op)))
6025 + {
6026 + if (do_pushes)
6027 + {
6028 + rtx cop = avoid_constant_pool_reference (op);
6029 +
6030 + /* Casting the address of something to a mode narrower than a
6031 + word can cause avoid_constant_pool_reference() to return the
6032 + pool reference itself. That's no good to us here. Lets
6033 + just hope that we can use the constant pool value directly.
6034 + */
6035 + if (op == cop)
6036 + cop = get_pool_constant (XEXP (op, 0));
6037 +
6038 + push_minipool_fix (insn, address,
6039 + recog_data.operand_loc[opno],
6040 + recog_data.operand_mode[opno], cop);
6041 + }
6042 +
6043 + result = true;
6044 + }
6045 + else if (TARGET_HAS_ASM_ADDR_PSEUDOS
6046 + && avr32_address_operand (op, GET_MODE (op)))
6047 + {
6048 + /* Handle pseudo instructions using a direct address. These pseudo
6049 + instructions might need entries in the constant pool and we must
6050 + therefor create a constant pool for them, in case the
6051 + assembler/linker needs to insert entries. */
6052 + if (do_pushes)
6053 + {
6054 + /* Push a dummy constant pool entry so that the .cpool
6055 + directive should be inserted on the appropriate place in the
6056 + code even if there are no real constant pool entries. This
6057 + is used by the assembler and linker to know where to put
6058 + generated constant pool entries. */
6059 + push_minipool_fix (insn, address,
6060 + recog_data.operand_loc[opno],
6061 + recog_data.operand_mode[opno],
6062 + gen_rtx_UNSPEC (VOIDmode,
6063 + gen_rtvec (1, const0_rtx),
6064 + UNSPEC_FORCE_MINIPOOL));
6065 + result = true;
6066 + }
6067 + }
6068 + }
6069 + return result;
6070 + }
6071 +
6072 +
6073 +static int
6074 +avr32_insn_is_cast (rtx insn)
6075 + {
6076 +
6077 + if (NONJUMP_INSN_P (insn)
6078 + && GET_CODE (PATTERN (insn)) == SET
6079 + && (GET_CODE (SET_SRC (PATTERN (insn))) == ZERO_EXTEND
6080 + || GET_CODE (SET_SRC (PATTERN (insn))) == SIGN_EXTEND)
6081 + && REG_P (XEXP (SET_SRC (PATTERN (insn)), 0))
6082 + && REG_P (SET_DEST (PATTERN (insn))))
6083 + return true;
6084 + return false;
6085 + }
6086 +
6087 +/* FIXME: The level of nesting in this function is way too deep. It needs to be
6088 + torn apart. */
6089 +static void
6090 +avr32_reorg_optimization (void)
6091 + {
6092 + rtx first = get_insns ();
6093 + rtx insn;
6094 +
6095 + if (TARGET_MD_REORG_OPTIMIZATION && (optimize_size || (optimize > 0)))
6096 + {
6097 +
6098 + /* Scan through all insns looking for cast operations. */
6099 + if (dump_file)
6100 + {
6101 + fprintf (dump_file, ";; Deleting redundant cast operations:\n");
6102 + }
6103 + for (insn = first; insn; insn = NEXT_INSN (insn))
6104 + {
6105 + rtx reg, src_reg, scan;
6106 + enum machine_mode mode;
6107 + int unused_cast;
6108 + rtx label_ref;
6109 +
6110 + if (avr32_insn_is_cast (insn)
6111 + && (GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 0)) == QImode
6112 + || GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 0)) == HImode))
6113 + {
6114 + mode = GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 0));
6115 + reg = SET_DEST (PATTERN (insn));
6116 + src_reg = XEXP (SET_SRC (PATTERN (insn)), 0);
6117 + }
6118 + else
6119 + {
6120 + continue;
6121 + }
6122 +
6123 + unused_cast = false;
6124 + label_ref = NULL_RTX;
6125 + for (scan = NEXT_INSN (insn); scan; scan = NEXT_INSN (scan))
6126 + {
6127 + /* Check if we have reached the destination of a simple
6128 + conditional jump which we have already scanned past. If so,
6129 + we can safely continue scanning. */
6130 + if (LABEL_P (scan) && label_ref != NULL_RTX)
6131 + {
6132 + if (CODE_LABEL_NUMBER (scan) ==
6133 + CODE_LABEL_NUMBER (XEXP (label_ref, 0)))
6134 + label_ref = NULL_RTX;
6135 + else
6136 + break;
6137 + }
6138 +
6139 + if (!INSN_P (scan))
6140 + continue;
6141 +
6142 + /* For conditional jumps we can manage to keep on scanning if
6143 + we meet the destination label later on before any new jump
6144 + insns occure. */
6145 + if (GET_CODE (scan) == JUMP_INSN)
6146 + {
6147 + if (any_condjump_p (scan) && label_ref == NULL_RTX)
6148 + label_ref = condjump_label (scan);
6149 + else
6150 + break;
6151 + }
6152 +
6153 + if (!reg_mentioned_p (reg, PATTERN (scan)))
6154 + continue;
6155 +
6156 + /* Check if casted register is used in this insn */
6157 + if ((regno_use_in (REGNO (reg), PATTERN (scan)) != NULL_RTX)
6158 + && (GET_MODE (regno_use_in (REGNO (reg), PATTERN (scan))) ==
6159 + GET_MODE (reg)))
6160 + {
6161 + /* If not used in the source to the set or in a memory
6162 + expression in the destiantion then the register is used
6163 + as a destination and is really dead. */
6164 + if (single_set (scan)
6165 + && GET_CODE (PATTERN (scan)) == SET
6166 + && REG_P (SET_DEST (PATTERN (scan)))
6167 + && !regno_use_in (REGNO (reg), SET_SRC (PATTERN (scan)))
6168 + && label_ref == NULL_RTX)
6169 + {
6170 + unused_cast = true;
6171 + }
6172 + break;
6173 + }
6174 +
6175 + /* Check if register is dead or set in this insn */
6176 + if (dead_or_set_p (scan, reg))
6177 + {
6178 + unused_cast = true;
6179 + break;
6180 + }
6181 + }
6182 +
6183 + /* Check if we have unresolved conditional jumps */
6184 + if (label_ref != NULL_RTX)
6185 + continue;
6186 +
6187 + if (unused_cast)
6188 + {
6189 + if (REGNO (reg) == REGNO (XEXP (SET_SRC (PATTERN (insn)), 0)))
6190 + {
6191 + /* One operand cast, safe to delete */
6192 + if (dump_file)
6193 + {
6194 + fprintf (dump_file,
6195 + ";; INSN %i removed, casted register %i value not used.\n",
6196 + INSN_UID (insn), REGNO (reg));
6197 + }
6198 + SET_INSN_DELETED (insn);
6199 + /* Force the instruction to be recognized again */
6200 + INSN_CODE (insn) = -1;
6201 + }
6202 + else
6203 + {
6204 + /* Two operand cast, which really could be substituted with
6205 + a move, if the source register is dead after the cast
6206 + insn and then the insn which sets the source register
6207 + could instead directly set the destination register for
6208 + the cast. As long as there are no insns in between which
6209 + uses the register. */
6210 + rtx link = NULL_RTX;
6211 + rtx set;
6212 + rtx src_reg = XEXP (SET_SRC (PATTERN (insn)), 0);
6213 + unused_cast = false;
6214 +
6215 + if (!find_reg_note (insn, REG_DEAD, src_reg))
6216 + continue;
6217 +
6218 + /* Search for the insn which sets the source register */
6219 + for (link = LOG_LINKS (insn); link; link = XEXP (link, 1))
6220 + {
6221 + if (REG_NOTE_KIND (link) != 0)
6222 + continue;
6223 + set = single_set (XEXP (link, 0));
6224 + if (set && rtx_equal_p (src_reg, SET_DEST (set)))
6225 + {
6226 + link = XEXP (link, 0);
6227 + break;
6228 + }
6229 + }
6230 +
6231 + /* Found no link or link is a call insn where we can not
6232 + change the destination register */
6233 + if (link == NULL_RTX || CALL_P (link))
6234 + continue;
6235 +
6236 + /* Scan through all insn between link and insn */
6237 + for (scan = NEXT_INSN (link); scan; scan = NEXT_INSN (scan))
6238 + {
6239 + /* Don't try to trace forward past a CODE_LABEL if we
6240 + haven't seen INSN yet. Ordinarily, we will only
6241 + find the setting insn in LOG_LINKS if it is in the
6242 + same basic block. However, cross-jumping can insert
6243 + code labels in between the load and the call, and
6244 + can result in situations where a single call insn
6245 + may have two targets depending on where we came
6246 + from. */
6247 +
6248 + if (GET_CODE (scan) == CODE_LABEL)
6249 + break;
6250 +
6251 + if (!INSN_P (scan))
6252 + continue;
6253 +
6254 + /* Don't try to trace forward past a JUMP. To optimize
6255 + safely, we would have to check that all the
6256 + instructions at the jump destination did not use REG.
6257 + */
6258 +
6259 + if (GET_CODE (scan) == JUMP_INSN)
6260 + {
6261 + break;
6262 + }
6263 +
6264 + if (!reg_mentioned_p (src_reg, PATTERN (scan)))
6265 + continue;
6266 +
6267 + /* We have reached the cast insn */
6268 + if (scan == insn)
6269 + {
6270 + /* We can remove cast and replace the destination
6271 + register of the link insn with the destination
6272 + of the cast */
6273 + if (dump_file)
6274 + {
6275 + fprintf (dump_file,
6276 + ";; INSN %i removed, casted value unused. "
6277 + "Destination of removed cast operation: register %i, folded into INSN %i.\n",
6278 + INSN_UID (insn), REGNO (reg),
6279 + INSN_UID (link));
6280 + }
6281 + /* Update link insn */
6282 + SET_DEST (PATTERN (link)) =
6283 + gen_rtx_REG (mode, REGNO (reg));
6284 + /* Force the instruction to be recognized again */
6285 + INSN_CODE (link) = -1;
6286 +
6287 + /* Delete insn */
6288 + SET_INSN_DELETED (insn);
6289 + /* Force the instruction to be recognized again */
6290 + INSN_CODE (insn) = -1;
6291 + break;
6292 + }
6293 + }
6294 + }
6295 + }
6296 + }
6297 + }
6298 +
6299 + if (TARGET_MD_REORG_OPTIMIZATION && (optimize_size || (optimize > 0)))
6300 + {
6301 +
6302 + /* Scan through all insns looking for shifted add operations */
6303 + if (dump_file)
6304 + {
6305 + fprintf (dump_file,
6306 + ";; Deleting redundant shifted add operations:\n");
6307 + }
6308 + for (insn = first; insn; insn = NEXT_INSN (insn))
6309 + {
6310 + rtx reg, mem_expr, scan, op0, op1;
6311 + int add_only_used_as_pointer;
6312 +
6313 + if (INSN_P (insn)
6314 + && GET_CODE (PATTERN (insn)) == SET
6315 + && GET_CODE (SET_SRC (PATTERN (insn))) == PLUS
6316 + && (GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 0)) == MULT
6317 + || GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 0)) == ASHIFT)
6318 + && GET_CODE (XEXP (XEXP (SET_SRC (PATTERN (insn)), 0), 1)) ==
6319 + CONST_INT && REG_P (SET_DEST (PATTERN (insn)))
6320 + && REG_P (XEXP (SET_SRC (PATTERN (insn)), 1))
6321 + && REG_P (XEXP (XEXP (SET_SRC (PATTERN (insn)), 0), 0)))
6322 + {
6323 + reg = SET_DEST (PATTERN (insn));
6324 + mem_expr = SET_SRC (PATTERN (insn));
6325 + op0 = XEXP (XEXP (mem_expr, 0), 0);
6326 + op1 = XEXP (mem_expr, 1);
6327 + }
6328 + else
6329 + {
6330 + continue;
6331 + }
6332 +
6333 + /* Scan forward the check if the result of the shifted add
6334 + operation is only used as an address in memory operations and
6335 + that the operands to the shifted add are not clobbered. */
6336 + add_only_used_as_pointer = false;
6337 + for (scan = NEXT_INSN (insn); scan; scan = NEXT_INSN (scan))
6338 + {
6339 + if (!INSN_P (scan))
6340 + continue;
6341 +
6342 + /* Don't try to trace forward past a JUMP or CALL. To optimize
6343 + safely, we would have to check that all the instructions at
6344 + the jump destination did not use REG. */
6345 +
6346 + if (GET_CODE (scan) == JUMP_INSN)
6347 + {
6348 + break;
6349 + }
6350 +
6351 + /* If used in a call insn then we cannot optimize it away */
6352 + if (CALL_P (scan) && find_regno_fusage (scan, USE, REGNO (reg)))
6353 + break;
6354 +
6355 + /* If any of the operands of the shifted add are clobbered we
6356 + cannot optimize the shifted adda away */
6357 + if ((reg_set_p (op0, scan) && (REGNO (op0) != REGNO (reg)))
6358 + || (reg_set_p (op1, scan) && (REGNO (op1) != REGNO (reg))))
6359 + break;
6360 +
6361 + if (!reg_mentioned_p (reg, PATTERN (scan)))
6362 + continue;
6363 +
6364 + /* If used any other place than as a pointer or as the
6365 + destination register we failed */
6366 + if (!(single_set (scan)
6367 + && GET_CODE (PATTERN (scan)) == SET
6368 + && ((MEM_P (SET_DEST (PATTERN (scan)))
6369 + && REG_P (XEXP (SET_DEST (PATTERN (scan)), 0))
6370 + && REGNO (XEXP (SET_DEST (PATTERN (scan)), 0)) ==
6371 + REGNO (reg)) || (MEM_P (SET_SRC (PATTERN (scan)))
6372 + &&
6373 + REG_P (XEXP
6374 + (SET_SRC (PATTERN (scan)),
6375 + 0))
6376 + &&
6377 + REGNO (XEXP
6378 + (SET_SRC (PATTERN (scan)),
6379 + 0)) == REGNO (reg))))
6380 + && !(GET_CODE (PATTERN (scan)) == SET
6381 + && REG_P (SET_DEST (PATTERN (scan)))
6382 + && !regno_use_in (REGNO (reg),
6383 + SET_SRC (PATTERN (scan)))))
6384 + break;
6385 +
6386 + /* Check if register is dead or set in this insn */
6387 + if (dead_or_set_p (scan, reg))
6388 + {
6389 + add_only_used_as_pointer = true;
6390 + break;
6391 + }
6392 + }
6393 +
6394 + if (add_only_used_as_pointer)
6395 + {
6396 + /* Lets delete the add insn and replace all memory references
6397 + which uses the pointer with the full expression. */
6398 + if (dump_file)
6399 + {
6400 + fprintf (dump_file,
6401 + ";; Deleting INSN %i since address expression can be folded into all "
6402 + "memory references using this expression\n",
6403 + INSN_UID (insn));
6404 + }
6405 + SET_INSN_DELETED (insn);
6406 + /* Force the instruction to be recognized again */
6407 + INSN_CODE (insn) = -1;
6408 +
6409 + for (scan = NEXT_INSN (insn); scan; scan = NEXT_INSN (scan))
6410 + {
6411 + if (!INSN_P (scan))
6412 + continue;
6413 +
6414 + if (!reg_mentioned_p (reg, PATTERN (scan)))
6415 + continue;
6416 +
6417 + /* If used any other place than as a pointer or as the
6418 + destination register we failed */
6419 + if ((single_set (scan)
6420 + && GET_CODE (PATTERN (scan)) == SET
6421 + && ((MEM_P (SET_DEST (PATTERN (scan)))
6422 + && REG_P (XEXP (SET_DEST (PATTERN (scan)), 0))
6423 + && REGNO (XEXP (SET_DEST (PATTERN (scan)), 0)) ==
6424 + REGNO (reg)) || (MEM_P (SET_SRC (PATTERN (scan)))
6425 + &&
6426 + REG_P (XEXP
6427 + (SET_SRC (PATTERN (scan)),
6428 + 0))
6429 + &&
6430 + REGNO (XEXP
6431 + (SET_SRC (PATTERN (scan)),
6432 + 0)) == REGNO (reg)))))
6433 + {
6434 + if (dump_file)
6435 + {
6436 + fprintf (dump_file,
6437 + ";; Register %i replaced by indexed address in INSN %i\n",
6438 + REGNO (reg), INSN_UID (scan));
6439 + }
6440 + if (MEM_P (SET_DEST (PATTERN (scan))))
6441 + XEXP (SET_DEST (PATTERN (scan)), 0) = mem_expr;
6442 + else
6443 + XEXP (SET_SRC (PATTERN (scan)), 0) = mem_expr;
6444 + }
6445 +
6446 + /* Check if register is dead or set in this insn */
6447 + if (dead_or_set_p (scan, reg))
6448 + {
6449 + break;
6450 + }
6451 +
6452 + }
6453 + }
6454 + }
6455 + }
6456 + }
6457 +
6458 +/* Exported to toplev.c.
6459 +
6460 + Do a final pass over the function, just before delayed branch
6461 + scheduling. */
6462 +
6463 +static void
6464 +avr32_reorg (void)
6465 + {
6466 + rtx insn;
6467 + HOST_WIDE_INT address = 0;
6468 + Mfix *fix;
6469 +
6470 + minipool_fix_head = minipool_fix_tail = NULL;
6471 +
6472 + /* The first insn must always be a note, or the code below won't scan it
6473 + properly. */
6474 + insn = get_insns ();
6475 + if (GET_CODE (insn) != NOTE)
6476 + abort ();
6477 +
6478 + /* Scan all the insns and record the operands that will need fixing. */
6479 + for (insn = next_nonnote_insn (insn); insn; insn = next_nonnote_insn (insn))
6480 + {
6481 + if (GET_CODE (insn) == BARRIER)
6482 + push_minipool_barrier (insn, address);
6483 + else if (INSN_P (insn))
6484 + {
6485 + rtx table;
6486 +
6487 + note_invalid_constants (insn, address, true);
6488 + address += get_attr_length (insn);
6489 +
6490 + /* If the insn is a vector jump, add the size of the table and skip
6491 + the table. */
6492 + if ((table = is_jump_table (insn)) != NULL)
6493 + {
6494 + address += get_jump_table_size (table);
6495 + insn = table;
6496 + }
6497 + }
6498 + }
6499 +
6500 + fix = minipool_fix_head;
6501 +
6502 + /* Now scan the fixups and perform the required changes. */
6503 + while (fix)
6504 + {
6505 + Mfix *ftmp;
6506 + Mfix *fdel;
6507 + Mfix *last_added_fix;
6508 + Mfix *last_barrier = NULL;
6509 + Mfix *this_fix;
6510 +
6511 + /* Skip any further barriers before the next fix. */
6512 + while (fix && GET_CODE (fix->insn) == BARRIER)
6513 + fix = fix->next;
6514 +
6515 + /* No more fixes. */
6516 + if (fix == NULL)
6517 + break;
6518 +
6519 + last_added_fix = NULL;
6520 +
6521 + for (ftmp = fix; ftmp; ftmp = ftmp->next)
6522 + {
6523 + if (GET_CODE (ftmp->insn) == BARRIER)
6524 + {
6525 + if (ftmp->address >= minipool_vector_head->max_address)
6526 + break;
6527 +
6528 + last_barrier = ftmp;
6529 + }
6530 + else if ((ftmp->minipool = add_minipool_forward_ref (ftmp)) == NULL)
6531 + break;
6532 +
6533 + last_added_fix = ftmp; /* Keep track of the last fix added.
6534 + */
6535 + }
6536 +
6537 + /* If we found a barrier, drop back to that; any fixes that we could
6538 + have reached but come after the barrier will now go in the next
6539 + mini-pool. */
6540 + if (last_barrier != NULL)
6541 + {
6542 + /* Reduce the refcount for those fixes that won't go into this pool
6543 + after all. */
6544 + for (fdel = last_barrier->next;
6545 + fdel && fdel != ftmp; fdel = fdel->next)
6546 + {
6547 + fdel->minipool->refcount--;
6548 + fdel->minipool = NULL;
6549 + }
6550 +
6551 + ftmp = last_barrier;
6552 + }
6553 + else
6554 + {
6555 + /* ftmp is first fix that we can't fit into this pool and there no
6556 + natural barriers that we could use. Insert a new barrier in the
6557 + code somewhere between the previous fix and this one, and
6558 + arrange to jump around it. */
6559 + HOST_WIDE_INT max_address;
6560 +
6561 + /* The last item on the list of fixes must be a barrier, so we can
6562 + never run off the end of the list of fixes without last_barrier
6563 + being set. */
6564 + if (ftmp == NULL)
6565 + abort ();
6566 +
6567 + max_address = minipool_vector_head->max_address;
6568 + /* Check that there isn't another fix that is in range that we
6569 + couldn't fit into this pool because the pool was already too
6570 + large: we need to put the pool before such an instruction. */
6571 + if (ftmp->address < max_address)
6572 + max_address = ftmp->address;
6573 +
6574 + last_barrier = create_fix_barrier (last_added_fix, max_address);
6575 + }
6576 +
6577 + assign_minipool_offsets (last_barrier);
6578 +
6579 + while (ftmp)
6580 + {
6581 + if (GET_CODE (ftmp->insn) != BARRIER
6582 + && ((ftmp->minipool = add_minipool_backward_ref (ftmp))
6583 + == NULL))
6584 + break;
6585 +
6586 + ftmp = ftmp->next;
6587 + }
6588 +
6589 + /* Scan over the fixes we have identified for this pool, fixing them up
6590 + and adding the constants to the pool itself. */
6591 + for (this_fix = fix; this_fix && ftmp != this_fix;
6592 + this_fix = this_fix->next)
6593 + if (GET_CODE (this_fix->insn) != BARRIER
6594 + /* Do nothing for entries present just to force the insertion of
6595 + a minipool. */
6596 + && !IS_FORCE_MINIPOOL (this_fix->value))
6597 + {
6598 + rtx addr = plus_constant (gen_rtx_LABEL_REF (VOIDmode,
6599 + minipool_vector_label),
6600 + this_fix->minipool->offset);
6601 + *this_fix->loc = gen_rtx_MEM (this_fix->mode, addr);
6602 + }
6603 +
6604 + dump_minipool (last_barrier->insn);
6605 + fix = ftmp;
6606 + }
6607 +
6608 + /* Free the minipool memory. */
6609 + obstack_free (&minipool_obstack, minipool_startobj);
6610 +
6611 + avr32_reorg_optimization ();
6612 + }
6613 +
6614 +
6615 +/*
6616 + Hook for doing some final scanning of instructions. Does nothing yet...*/
6617 +void
6618 +avr32_final_prescan_insn (rtx insn ATTRIBUTE_UNUSED,
6619 + rtx * opvec ATTRIBUTE_UNUSED,
6620 + int noperands ATTRIBUTE_UNUSED)
6621 + {
6622 + return;
6623 + }
6624 +
6625 +
6626 +/* Function for changing the condition on the next instruction,
6627 + should be used when emmiting compare instructions and
6628 + the condition of the next instruction needs to change.
6629 + */
6630 +int
6631 +set_next_insn_cond (rtx cur_insn, rtx new_cond)
6632 + {
6633 + rtx next_insn = next_nonnote_insn (cur_insn);
6634 + if ((next_insn != NULL_RTX)
6635 + && (INSN_P (next_insn))
6636 + && (GET_CODE (PATTERN (next_insn)) == SET)
6637 + && (GET_CODE (SET_SRC (PATTERN (next_insn))) == IF_THEN_ELSE))
6638 + {
6639 + /* Branch instructions */
6640 + XEXP (SET_SRC (PATTERN (next_insn)), 0) = new_cond;
6641 + /* Force the instruction to be recognized again */
6642 + INSN_CODE (next_insn) = -1;
6643 + return TRUE;
6644 + }
6645 + else if ((next_insn != NULL_RTX)
6646 + && (INSN_P (next_insn))
6647 + && (GET_CODE (PATTERN (next_insn)) == SET)
6648 + && comparison_operator (SET_SRC (PATTERN (next_insn)),
6649 + GET_MODE (SET_SRC (PATTERN (next_insn)))))
6650 + {
6651 + /* scc with no compare */
6652 + SET_SRC (PATTERN (next_insn)) = new_cond;
6653 + /* Force the instruction to be recognized again */
6654 + INSN_CODE (next_insn) = -1;
6655 + return TRUE;
6656 + }
6657 +
6658 + return FALSE;
6659 + }
6660 +
6661 +/* Function for obtaining the condition for the next instruction
6662 + after cur_insn.
6663 + */
6664 +rtx
6665 +get_next_insn_cond (rtx cur_insn)
6666 + {
6667 + rtx next_insn = next_nonnote_insn (cur_insn);
6668 + rtx cond = NULL_RTX;
6669 + if ((next_insn != NULL_RTX)
6670 + && (INSN_P (next_insn))
6671 + && (GET_CODE (PATTERN (next_insn)) == SET)
6672 + && (GET_CODE (SET_SRC (PATTERN (next_insn))) == IF_THEN_ELSE))
6673 + {
6674 + /* Branch instructions */
6675 + cond = XEXP (SET_SRC (PATTERN (next_insn)), 0);
6676 + }
6677 + else if ((next_insn != NULL_RTX)
6678 + && (INSN_P (next_insn))
6679 + && (GET_CODE (PATTERN (next_insn)) == SET)
6680 + && comparison_operator (SET_SRC (PATTERN (next_insn)),
6681 + GET_MODE (SET_SRC (PATTERN (next_insn)))))
6682 + {
6683 + /* scc with no compare */
6684 + cond = SET_SRC (PATTERN (next_insn));
6685 + }
6686 +
6687 + return cond;
6688 + }
6689 +
6690 +
6691 +rtx
6692 +avr32_output_cmp (rtx cond, enum machine_mode mode, rtx op0, rtx op1)
6693 + {
6694 +
6695 + rtx new_cond = NULL_RTX;
6696 + rtx ops[2];
6697 + rtx compare_pattern;
6698 + ops[0] = op0;
6699 + ops[1] = op1;
6700 +
6701 + compare_pattern = gen_rtx_COMPARE (mode, op0, op1);
6702 +
6703 + new_cond = is_compare_redundant (compare_pattern, cond);
6704 +
6705 + if (new_cond != NULL_RTX)
6706 + return new_cond;
6707 +
6708 + /* Insert compare */
6709 + switch (mode)
6710 + {
6711 + case QImode:
6712 + output_asm_insn ("cp.b\t%0, %1", ops);
6713 + break;
6714 + case HImode:
6715 + output_asm_insn ("cp.h\t%0, %1", ops);
6716 + break;
6717 + case SImode:
6718 + output_asm_insn ("cp.w\t%0, %1", ops);
6719 + break;
6720 + case DImode:
6721 + if (GET_CODE (op1) != REG)
6722 + output_asm_insn ("cp.w\t%0, %1\ncpc\t%m0", ops);
6723 + else
6724 + output_asm_insn ("cp.w\t%0, %1\ncpc\t%m0, %m1", ops);
6725 + break;
6726 + default:
6727 + internal_error ("Unknown comparison mode");
6728 + break;
6729 + }
6730 +
6731 + return cond;
6732 + }
6733 +
6734 +int
6735 +avr32_load_multiple_operation (rtx op,
6736 + enum machine_mode mode ATTRIBUTE_UNUSED)
6737 + {
6738 + int count = XVECLEN (op, 0);
6739 + unsigned int dest_regno;
6740 + rtx src_addr;
6741 + rtx elt;
6742 + int i = 1, base = 0;
6743 +
6744 + if (count <= 1 || GET_CODE (XVECEXP (op, 0, 0)) != SET)
6745 + return 0;
6746 +
6747 + /* Check to see if this might be a write-back. */
6748 + if (GET_CODE (SET_SRC (elt = XVECEXP (op, 0, 0))) == PLUS)
6749 + {
6750 + i++;
6751 + base = 1;
6752 +
6753 + /* Now check it more carefully. */
6754 + if (GET_CODE (SET_DEST (elt)) != REG
6755 + || GET_CODE (XEXP (SET_SRC (elt), 0)) != REG
6756 + || GET_CODE (XEXP (SET_SRC (elt), 1)) != CONST_INT
6757 + || INTVAL (XEXP (SET_SRC (elt), 1)) != (count - 1) * 4)
6758 + return 0;
6759 + }
6760 +
6761 + /* Perform a quick check so we don't blow up below. */
6762 + if (count <= 1
6763 + || GET_CODE (XVECEXP (op, 0, i - 1)) != SET
6764 + || GET_CODE (SET_DEST (XVECEXP (op, 0, i - 1))) != REG
6765 + || GET_CODE (SET_SRC (XVECEXP (op, 0, i - 1))) != UNSPEC)
6766 + return 0;
6767 +
6768 + dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, i - 1)));
6769 + src_addr = XEXP (SET_SRC (XVECEXP (op, 0, i - 1)), 0);
6770 +
6771 + for (; i < count; i++)
6772 + {
6773 + elt = XVECEXP (op, 0, i);
6774 +
6775 + if (GET_CODE (elt) != SET
6776 + || GET_CODE (SET_DEST (elt)) != REG
6777 + || GET_MODE (SET_DEST (elt)) != SImode
6778 + || GET_CODE (SET_SRC (elt)) != UNSPEC)
6779 + return 0;
6780 + }
6781 +
6782 + return 1;
6783 + }
6784 +
6785 +int
6786 +avr32_store_multiple_operation (rtx op,
6787 + enum machine_mode mode ATTRIBUTE_UNUSED)
6788 + {
6789 + int count = XVECLEN (op, 0);
6790 + int src_regno;
6791 + rtx dest_addr;
6792 + rtx elt;
6793 + int i = 1;
6794 +
6795 + if (count <= 1 || GET_CODE (XVECEXP (op, 0, 0)) != SET)
6796 + return 0;
6797 +
6798 + /* Perform a quick check so we don't blow up below. */
6799 + if (count <= i
6800 + || GET_CODE (XVECEXP (op, 0, i - 1)) != SET
6801 + || GET_CODE (SET_DEST (XVECEXP (op, 0, i - 1))) != MEM
6802 + || GET_CODE (SET_SRC (XVECEXP (op, 0, i - 1))) != UNSPEC)
6803 + return 0;
6804 +
6805 + src_regno = REGNO (SET_SRC (XVECEXP (op, 0, i - 1)));
6806 + dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, i - 1)), 0);
6807 +
6808 + for (; i < count; i++)
6809 + {
6810 + elt = XVECEXP (op, 0, i);
6811 +
6812 + if (GET_CODE (elt) != SET
6813 + || GET_CODE (SET_DEST (elt)) != MEM
6814 + || GET_MODE (SET_DEST (elt)) != SImode
6815 + || GET_CODE (SET_SRC (elt)) != UNSPEC)
6816 + return 0;
6817 + }
6818 +
6819 + return 1;
6820 + }
6821 +
6822 +int
6823 +avr32_valid_macmac_bypass (rtx insn_out, rtx insn_in)
6824 + {
6825 + /* Check if they use the same accumulator */
6826 + if (rtx_equal_p
6827 + (SET_DEST (PATTERN (insn_out)), SET_DEST (PATTERN (insn_in))))
6828 + {
6829 + return TRUE;
6830 + }
6831 +
6832 + return FALSE;
6833 + }
6834 +
6835 +int
6836 +avr32_valid_mulmac_bypass (rtx insn_out, rtx insn_in)
6837 + {
6838 + /*
6839 + Check if the mul instruction produces the accumulator for the mac
6840 + instruction. */
6841 + if (rtx_equal_p
6842 + (SET_DEST (PATTERN (insn_out)), SET_DEST (PATTERN (insn_in))))
6843 + {
6844 + return TRUE;
6845 + }
6846 + return FALSE;
6847 + }
6848 +
6849 +int
6850 +avr32_store_bypass (rtx insn_out, rtx insn_in)
6851 + {
6852 + /* Only valid bypass if the output result is used as an src in the store
6853 + instruction, NOT if used as a pointer or base. */
6854 + if (rtx_equal_p
6855 + (SET_DEST (PATTERN (insn_out)), SET_SRC (PATTERN (insn_in))))
6856 + {
6857 + return TRUE;
6858 + }
6859 +
6860 + return FALSE;
6861 + }
6862 +
6863 +int
6864 +avr32_mul_waw_bypass (rtx insn_out, rtx insn_in)
6865 + {
6866 + /* Check if the register holding the result from the mul instruction is
6867 + used as a result register in the input instruction. */
6868 + if (rtx_equal_p
6869 + (SET_DEST (PATTERN (insn_out)), SET_DEST (PATTERN (insn_in))))
6870 + {
6871 + return TRUE;
6872 + }
6873 +
6874 + return FALSE;
6875 + }
6876 +
6877 +int
6878 +avr32_valid_load_double_bypass (rtx insn_out, rtx insn_in)
6879 + {
6880 + /* Check if the first loaded word in insn_out is used in insn_in. */
6881 + rtx dst_reg;
6882 + rtx second_loaded_reg;
6883 +
6884 + /* If this is a double alu operation then the bypass is not valid */
6885 + if ((get_attr_type (insn_in) == TYPE_ALU
6886 + || get_attr_type (insn_in) == TYPE_ALU2)
6887 + && (GET_MODE_SIZE (GET_MODE (SET_DEST (PATTERN (insn_out)))) > 4))
6888 + return FALSE;
6889 +
6890 + /* Get the destination register in the load */
6891 + if (!REG_P (SET_DEST (PATTERN (insn_out))))
6892 + return FALSE;
6893 +
6894 + dst_reg = SET_DEST (PATTERN (insn_out));
6895 + second_loaded_reg = gen_rtx_REG (SImode, REGNO (dst_reg) + 1);
6896 +
6897 + if (!reg_mentioned_p (second_loaded_reg, PATTERN (insn_in)))
6898 + return TRUE;
6899 +
6900 + return FALSE;
6901 + }
6902 +
6903 +
6904 +int
6905 +avr32_valid_load_quad_bypass (rtx insn_out, rtx insn_in)
6906 + {
6907 + /*
6908 + Check if the two first loaded word in insn_out are used in insn_in. */
6909 + rtx dst_reg;
6910 + rtx third_loaded_reg, fourth_loaded_reg;
6911 +
6912 + /* Get the destination register in the load */
6913 + if (!REG_P (SET_DEST (PATTERN (insn_out))))
6914 + return FALSE;
6915 +
6916 + dst_reg = SET_DEST (PATTERN (insn_out));
6917 + third_loaded_reg = gen_rtx_REG (SImode, REGNO (dst_reg) + 2);
6918 + fourth_loaded_reg = gen_rtx_REG (SImode, REGNO (dst_reg) + 3);
6919 +
6920 + if (!reg_mentioned_p (third_loaded_reg, PATTERN (insn_in))
6921 + && !reg_mentioned_p (fourth_loaded_reg, PATTERN (insn_in)))
6922 + {
6923 + return TRUE;
6924 + }
6925 +
6926 + return FALSE;
6927 + }
6928 +
6929 +
6930 +//section *
6931 +//avr32_select_rtx_section (enum machine_mode mode ATTRIBUTE_UNUSED,
6932 +// rtx x ATTRIBUTE_UNUSED,
6933 +// unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
6934 +// {
6935 +// /* Let ASM_OUTPUT_POOL_PROLOGUE take care of this */
6936 +// return 0;
6937 +// }
6938 +
6939 +
6940 +/* Function for getting an integer value from a const_int or const_double
6941 + expression regardless of the HOST_WIDE_INT size. Each target cpu word
6942 + will be put into the val array where the LSW will be stored at the lowest
6943 + address and so forth. Assumes that const_expr is either a const_int or
6944 + const_double. Only valid for modes which have sizes that are a multiple
6945 + of the word size.
6946 +*/
6947 +void
6948 +avr32_get_intval (enum machine_mode mode,
6949 + rtx const_expr,
6950 + HOST_WIDE_INT *val)
6951 +{
6952 + int words_in_mode = GET_MODE_SIZE (mode)/UNITS_PER_WORD;
6953 + const int words_in_const_int = HOST_BITS_PER_WIDE_INT / BITS_PER_WORD;
6954 +
6955 + if ( GET_CODE(const_expr) == CONST_DOUBLE ){
6956 + HOST_WIDE_INT hi = CONST_DOUBLE_HIGH(const_expr);
6957 + HOST_WIDE_INT lo = CONST_DOUBLE_LOW(const_expr);
6958 + /* Evaluate hi and lo values of const_double. */
6959 + avr32_get_intval (mode_for_size (HOST_BITS_PER_WIDE_INT, MODE_INT, 0),
6960 + GEN_INT (lo),
6961 + &val[0]);
6962 + avr32_get_intval (mode_for_size (HOST_BITS_PER_WIDE_INT, MODE_INT, 0),
6963 + GEN_INT (hi),
6964 + &val[words_in_const_int]);
6965 + } else if ( GET_CODE(const_expr) == CONST_INT ){
6966 + HOST_WIDE_INT value = INTVAL(const_expr);
6967 + int word;
6968 + for ( word = 0; (word < words_in_mode) && (word < words_in_const_int); word++ ){
6969 + /* Shift word up to the MSW and shift down again to extract the
6970 + word and sign-extend. */
6971 + int lshift = (words_in_const_int - word - 1) * BITS_PER_WORD;
6972 + int rshift = (words_in_const_int-1) * BITS_PER_WORD;
6973 + val[word] = (value << lshift) >> rshift;
6974 + }
6975 +
6976 + for ( ; word < words_in_mode; word++ ){
6977 + /* Just put the sign bits in the remaining words. */
6978 + val[word] = value < 0 ? -1 : 0;
6979 + }
6980 + }
6981 +}
6982 +
6983 +void
6984 +avr32_split_const_expr (enum machine_mode mode,
6985 + enum machine_mode new_mode,
6986 + rtx expr,
6987 + rtx *split_expr)
6988 +{
6989 + int i, word;
6990 + int words_in_intval = GET_MODE_SIZE (mode)/UNITS_PER_WORD;
6991 + int words_in_split_values = GET_MODE_SIZE (new_mode)/UNITS_PER_WORD;
6992 + const int words_in_const_int = HOST_BITS_PER_WIDE_INT / BITS_PER_WORD;
6993 + HOST_WIDE_INT *val = alloca (words_in_intval * UNITS_PER_WORD);
6994 +
6995 + avr32_get_intval (mode, expr, val);
6996 +
6997 + for ( i=0; i < (words_in_intval/words_in_split_values); i++ )
6998 + {
6999 + HOST_WIDE_INT value_lo = 0, value_hi = 0;
7000 + for ( word = 0; word < words_in_split_values; word++ )
7001 + {
7002 + if ( word >= words_in_const_int )
7003 + value_hi |= ((val[i * words_in_split_values + word] &
7004 + (((HOST_WIDE_INT)1 << BITS_PER_WORD)-1))
7005 + << (BITS_PER_WORD * (word - words_in_const_int)));
7006 + else
7007 + value_lo |= ((val[i * words_in_split_values + word] &
7008 + (((HOST_WIDE_INT)1 << BITS_PER_WORD)-1))
7009 + << (BITS_PER_WORD * word));
7010 + }
7011 + split_expr[i] = immed_double_const(value_lo, value_hi, new_mode);
7012 + }
7013 +}
7014 +
7015 +
7016 +
7017 +/* Set up library functions to comply to AVR32 ABI */
7018 +
7019 +
7020 +/* Set up library functions to comply to AVR32 ABI */
7021 +
7022 +static void
7023 +avr32_init_libfuncs (void)
7024 +{
7025 + /* Convert gcc run-time function names to AVR32 ABI names */
7026 +
7027 + /* Double-precision floating-point arithmetic. */
7028 + set_optab_libfunc (sdiv_optab, DFmode, "__avr32_f64_div");
7029 + set_optab_libfunc (smul_optab, DFmode, "__avr32_f64_mul");
7030 + set_optab_libfunc (neg_optab, DFmode, NULL);
7031 +
7032 + /* Double-precision comparisons. */
7033 + set_optab_libfunc (eq_optab, DFmode, "__avr32_f64_cmp_eq");
7034 + set_optab_libfunc (ne_optab, DFmode, NULL);
7035 + set_optab_libfunc (lt_optab, DFmode, "__avr32_f64_cmp_lt");
7036 + set_optab_libfunc (le_optab, DFmode, NULL);
7037 + set_optab_libfunc (ge_optab, DFmode, "__avr32_f64_cmp_ge");
7038 + set_optab_libfunc (gt_optab, DFmode, NULL);
7039 +
7040 + /* Single-precision floating-point arithmetic. */
7041 + set_optab_libfunc (smul_optab, SFmode, "__avr32_f32_mul");
7042 + set_optab_libfunc (neg_optab, SFmode, NULL);
7043 +
7044 + /* Single-precision comparisons. */
7045 + set_optab_libfunc (eq_optab, SFmode, "__avr32_f32_cmp_eq");
7046 + set_optab_libfunc (ne_optab, SFmode, NULL);
7047 + set_optab_libfunc (lt_optab, SFmode, "__avr32_f32_cmp_lt");
7048 + set_optab_libfunc (le_optab, SFmode, NULL);
7049 + set_optab_libfunc (ge_optab, SFmode, "__avr32_f32_cmp_ge");
7050 + set_optab_libfunc (gt_optab, SFmode, NULL);
7051 +
7052 + /* Floating-point to integer conversions. */
7053 + set_conv_libfunc (sfix_optab, SImode, DFmode, "__avr32_f64_to_s32");
7054 + set_conv_libfunc (ufix_optab, SImode, DFmode, "__avr32_f64_to_u32");
7055 + set_conv_libfunc (sfix_optab, DImode, DFmode, "__avr32_f64_to_s64");
7056 + set_conv_libfunc (ufix_optab, DImode, DFmode, "__avr32_f64_to_u64");
7057 + set_conv_libfunc (sfix_optab, SImode, SFmode, "__avr32_f32_to_s32");
7058 + set_conv_libfunc (ufix_optab, SImode, SFmode, "__avr32_f32_to_u32");
7059 + set_conv_libfunc (sfix_optab, DImode, SFmode, "__avr32_f32_to_s64");
7060 + set_conv_libfunc (ufix_optab, DImode, SFmode, "__avr32_f32_to_u64");
7061 +
7062 + /* Conversions between floating types. */
7063 + set_conv_libfunc (trunc_optab, SFmode, DFmode, "__avr32_f64_to_f32");
7064 + set_conv_libfunc (sext_optab, DFmode, SFmode, "__avr32_f32_to_f64");
7065 +
7066 + /* Integer to floating-point conversions. Table 8. */
7067 + set_conv_libfunc (sfloat_optab, DFmode, SImode, "__avr32_s32_to_f64");
7068 + set_conv_libfunc (sfloat_optab, DFmode, DImode, "__avr32_s64_to_f64");
7069 + set_conv_libfunc (sfloat_optab, SFmode, SImode, "__avr32_s32_to_f32");
7070 + set_conv_libfunc (sfloat_optab, SFmode, DImode, "__avr32_s64_to_f32");
7071 + set_conv_libfunc (ufloat_optab, DFmode, SImode, "__avr32_u32_to_f64");
7072 + set_conv_libfunc (ufloat_optab, SFmode, SImode, "__avr32_u32_to_f32");
7073 + /* TODO: Add these to gcc library functions */
7074 + //set_conv_libfunc (ufloat_optab, DFmode, DImode, NULL);
7075 + //set_conv_libfunc (ufloat_optab, SFmode, DImode, NULL);
7076 +
7077 + /* Long long. Table 9. */
7078 + set_optab_libfunc (smul_optab, DImode, "__avr32_mul64");
7079 + set_optab_libfunc (sdiv_optab, DImode, "__avr32_sdiv64");
7080 + set_optab_libfunc (udiv_optab, DImode, "__avr32_udiv64");
7081 + set_optab_libfunc (smod_optab, DImode, "__avr32_smod64");
7082 + set_optab_libfunc (umod_optab, DImode, "__avr32_umod64");
7083 + set_optab_libfunc (ashl_optab, DImode, "__avr32_lsl64");
7084 + set_optab_libfunc (lshr_optab, DImode, "__avr32_lsr64");
7085 + set_optab_libfunc (ashr_optab, DImode, "__avr32_asr64");
7086 +
7087 + /* Floating point library functions which have fast versions. */
7088 + if ( TARGET_FAST_FLOAT )
7089 + {
7090 + set_optab_libfunc (add_optab, DFmode, "__avr32_f64_add_fast");
7091 + set_optab_libfunc (sub_optab, DFmode, "__avr32_f64_sub_fast");
7092 + set_optab_libfunc (add_optab, SFmode, "__avr32_f32_add_fast");
7093 + set_optab_libfunc (sub_optab, SFmode, "__avr32_f32_sub_fast");
7094 + set_optab_libfunc (sdiv_optab, SFmode, "__avr32_f32_div_fast");
7095 + }
7096 + else
7097 + {
7098 + set_optab_libfunc (add_optab, DFmode, "__avr32_f64_add");
7099 + set_optab_libfunc (sub_optab, DFmode, "__avr32_f64_sub");
7100 + set_optab_libfunc (add_optab, SFmode, "__avr32_f32_add");
7101 + set_optab_libfunc (sub_optab, SFmode, "__avr32_f32_sub");
7102 + set_optab_libfunc (sdiv_optab, SFmode, "__avr32_f32_div");
7103 + }
7104 +}
7105 +
7106 Index: gcc-4.2.3/gcc/config/avr32/avr32-elf.h
7107 ===================================================================
7108 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
7109 +++ gcc-4.2.3/gcc/config/avr32/avr32-elf.h 2008-05-21 13:45:54.149288905 +0200
7110 @@ -0,0 +1,84 @@
7111 +/*
7112 + Elf specific definitions.
7113 + Copyright 2003-2006 Atmel Corporation.
7114 +
7115 + Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
7116 +
7117 + This file is part of GCC.
7118 +
7119 + This program is free software; you can redistribute it and/or modify
7120 + it under the terms of the GNU General Public License as published by
7121 + the Free Software Foundation; either version 2 of the License, or
7122 + (at your option) any later version.
7123 +
7124 + This program is distributed in the hope that it will be useful,
7125 + but WITHOUT ANY WARRANTY; without even the implied warranty of
7126 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7127 + GNU General Public License for more details.
7128 +
7129 + You should have received a copy of the GNU General Public License
7130 + along with this program; if not, write to the Free Software
7131 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
7132 +
7133 +
7134 +/*****************************************************************************
7135 + * Controlling the Compilator Driver, 'gcc'
7136 + *****************************************************************************/
7137 +
7138 +/* Run-time Target Specification. */
7139 +#undef TARGET_VERSION
7140 +#define TARGET_VERSION fputs (" (AVR32 GNU with ELF)", stderr);
7141 +
7142 +/*
7143 +Another C string constant used much like LINK_SPEC. The
7144 +difference between the two is that STARTFILE_SPEC is used at
7145 +the very beginning of the command given to the linker.
7146 +
7147 +If this macro is not defined, a default is provided that loads the
7148 +standard C startup file from the usual place. See gcc.c.
7149 +*/
7150 +#undef STARTFILE_SPEC
7151 +#define STARTFILE_SPEC "crt0%O%s crti%O%s crtbegin%O%s"
7152 +
7153 +#undef LINK_SPEC
7154 +#define LINK_SPEC "%{muse-oscall:--defsym __do_not_use_oscall_coproc__=0} %{mrelax|O*:%{mno-relax|O0|O1: ;:--relax}} %{mpart=*:-mavr32elf_%*} %{mcpu=*:-mavr32elf_%*}"
7155 +
7156 +
7157 +/*
7158 +Another C string constant used much like LINK_SPEC. The
7159 +difference between the two is that ENDFILE_SPEC is used at
7160 +the very end of the command given to the linker.
7161 +
7162 +Do not define this macro if it does not need to do anything.
7163 +*/
7164 +#undef ENDFILE_SPEC
7165 +#define ENDFILE_SPEC "crtend%O%s crtn%O%s"
7166 +
7167 +
7168 +/* Target CPU builtins. */
7169 +#define TARGET_CPU_CPP_BUILTINS() \
7170 + do \
7171 + { \
7172 + builtin_define ("__avr32__"); \
7173 + builtin_define ("__AVR32__"); \
7174 + builtin_define ("__AVR32_ELF__"); \
7175 + builtin_define (avr32_part->macro); \
7176 + builtin_define (avr32_arch->macro); \
7177 + if (avr32_arch->uarch_type == UARCH_TYPE_AVR32A) \
7178 + builtin_define ("__AVR32_AVR32A__"); \
7179 + else \
7180 + builtin_define ("__AVR32_AVR32B__"); \
7181 + if (TARGET_UNALIGNED_WORD) \
7182 + builtin_define ("__AVR32_HAS_UNALIGNED_WORD__"); \
7183 + if (TARGET_SIMD) \
7184 + builtin_define ("__AVR32_HAS_SIMD__"); \
7185 + if (TARGET_DSP) \
7186 + builtin_define ("__AVR32_HAS_DSP__"); \
7187 + if (TARGET_RMW) \
7188 + builtin_define ("__AVR32_HAS_RMW__"); \
7189 + if (TARGET_BRANCH_PRED) \
7190 + builtin_define ("__AVR32_HAS_BRANCH_PRED__"); \
7191 + if (TARGET_FAST_FLOAT) \
7192 + builtin_define ("__AVR32_FAST_FLOAT__"); \
7193 + } \
7194 + while (0)
7195 Index: gcc-4.2.3/gcc/config/avr32/avr32.h
7196 ===================================================================
7197 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
7198 +++ gcc-4.2.3/gcc/config/avr32/avr32.h 2008-05-21 13:45:54.157287690 +0200
7199 @@ -0,0 +1,3281 @@
7200 +/*
7201 + Definitions of target machine for AVR32.
7202 + Copyright 2003-2006 Atmel Corporation.
7203 +
7204 + Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
7205 + Initial porting by Anders �dland.
7206 +
7207 + This file is part of GCC.
7208 +
7209 + This program is free software; you can redistribute it and/or modify
7210 + it under the terms of the GNU General Public License as published by
7211 + the Free Software Foundation; either version 2 of the License, or
7212 + (at your option) any later version.
7213 +
7214 + This program is distributed in the hope that it will be useful,
7215 + but WITHOUT ANY WARRANTY; without even the implied warranty of
7216 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7217 + GNU General Public License for more details.
7218 +
7219 + You should have received a copy of the GNU General Public License
7220 + along with this program; if not, write to the Free Software
7221 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
7222 +
7223 +#ifndef GCC_AVR32_H
7224 +#define GCC_AVR32_H
7225 +
7226 +
7227 +#ifndef OBJECT_FORMAT_ELF
7228 +#error avr32.h included before elfos.h
7229 +#endif
7230 +
7231 +#ifndef LOCAL_LABEL_PREFIX
7232 +#define LOCAL_LABEL_PREFIX "."
7233 +#endif
7234 +
7235 +#ifndef SUBTARGET_CPP_SPEC
7236 +#define SUBTARGET_CPP_SPEC "-D__ELF__"
7237 +#endif
7238 +
7239 +
7240 +extern struct rtx_def *avr32_compare_op0;
7241 +extern struct rtx_def *avr32_compare_op1;
7242 +
7243 +
7244 +extern struct rtx_def *avr32_acc_cache;
7245 +
7246 +/* cache instruction op5 codes */
7247 +#define AVR32_CACHE_INVALIDATE_ICACHE 1
7248 +
7249 +/* These bits describe the different types of function supported
7250 + by the AVR32 backend. They are exclusive. ie a function cannot be both a
7251 + normal function and an interworked function, for example. Knowing the
7252 + type of a function is important for determining its prologue and
7253 + epilogue sequences.
7254 + Note value 7 is currently unassigned. Also note that the interrupt
7255 + function types all have bit 2 set, so that they can be tested for easily.
7256 + Note that 0 is deliberately chosen for AVR32_FT_UNKNOWN so that when the
7257 + machine_function structure is initialized (to zero) func_type will
7258 + default to unknown. This will force the first use of avr32_current_func_type
7259 + to call avr32_compute_func_type. */
7260 +#define AVR32_FT_UNKNOWN 0 /* Type has not yet been determined.
7261 + */
7262 +#define AVR32_FT_NORMAL 1 /* Your normal, straightforward
7263 + function. */
7264 +#define AVR32_FT_ACALL 2 /* An acall function. */
7265 +#define AVR32_FT_EXCEPTION_HANDLER 3 /* A C++ exception handler. */
7266 +#define AVR32_FT_ISR_FULL 4 /* A fully shadowed interrupt mode. */
7267 +#define AVR32_FT_ISR_HALF 5 /* A half shadowed interrupt mode. */
7268 +#define AVR32_FT_ISR_NONE 6 /* No shadow registers. */
7269 +
7270 +#define AVR32_FT_TYPE_MASK ((1 << 3) - 1)
7271 +
7272 +/* In addition functions can have several type modifiers,
7273 + outlined by these bit masks: */
7274 +#define AVR32_FT_INTERRUPT (1 << 2) /* Note overlap with FT_ISR
7275 + and above. */
7276 +#define AVR32_FT_NAKED (1 << 3) /* No prologue or epilogue. */
7277 +#define AVR32_FT_VOLATILE (1 << 4) /* Does not return. */
7278 +#define AVR32_FT_NESTED (1 << 5) /* Embedded inside another
7279 + func. */
7280 +
7281 +/* Some macros to test these flags. */
7282 +#define AVR32_FUNC_TYPE(t) (t & AVR32_FT_TYPE_MASK)
7283 +#define IS_INTERRUPT(t) (t & AVR32_FT_INTERRUPT)
7284 +#define IS_VOLATILE(t) (t & AVR32_FT_VOLATILE)
7285 +#define IS_NAKED(t) (t & AVR32_FT_NAKED)
7286 +#define IS_NESTED(t) (t & AVR32_FT_NESTED)
7287 +
7288 +
7289 +typedef struct minipool_labels
7290 +GTY ((chain_next ("%h.next"), chain_prev ("%h.prev")))
7291 +{
7292 + rtx label;
7293 + struct minipool_labels *prev;
7294 + struct minipool_labels *next;
7295 +} minipool_labels;
7296 +
7297 +/* A C structure for machine-specific, per-function data.
7298 + This is added to the cfun structure. */
7299 +
7300 +typedef struct machine_function
7301 +GTY (())
7302 +{
7303 + /* Records the type of the current function. */
7304 + unsigned long func_type;
7305 + /* List of minipool labels, use for checking if code label is valid in a
7306 + memory expression */
7307 + minipool_labels *minipool_label_head;
7308 + minipool_labels *minipool_label_tail;
7309 +} machine_function;
7310 +
7311 +/* Initialize data used by insn expanders. This is called from insn_emit,
7312 + once for every function before code is generated. */
7313 +#define INIT_EXPANDERS avr32_init_expanders ()
7314 +
7315 +/******************************************************************************
7316 + * SPECS
7317 + *****************************************************************************/
7318 +
7319 +#ifndef ASM_SPEC
7320 +#define ASM_SPEC "%{fpic:--pic} %{mrelax|O*:%{mno-relax|O0|O1: ;:--linkrelax}} %{march=*:-march=%*} %{mpart=*:-mpart=%*}"
7321 +#endif
7322 +
7323 +#ifndef MULTILIB_DEFAULTS
7324 +#define MULTILIB_DEFAULTS { "march=ap", "" }
7325 +#endif
7326 +
7327 +/******************************************************************************
7328 + * Run-time Target Specification
7329 + *****************************************************************************/
7330 +#ifndef TARGET_VERSION
7331 +#define TARGET_VERSION fprintf(stderr, " (AVR32, GNU assembler syntax)");
7332 +#endif
7333 +
7334 +/* Part types. Keep this in sync with the order of avr32_part_types in avr32.c*/
7335 +enum part_type
7336 +{
7337 + PART_TYPE_AVR32_NONE,
7338 + PART_TYPE_AVR32_AP7000,
7339 + PART_TYPE_AVR32_AP7010,
7340 + PART_TYPE_AVR32_AP7020,
7341 + PART_TYPE_AVR32_UC3A0256,
7342 + PART_TYPE_AVR32_UC3A0512,
7343 + PART_TYPE_AVR32_UC3A1128,
7344 + PART_TYPE_AVR32_UC3A1256,
7345 + PART_TYPE_AVR32_UC3A1512,
7346 + PART_TYPE_AVR32_UC3B064,
7347 + PART_TYPE_AVR32_UC3B0128,
7348 + PART_TYPE_AVR32_UC3B0256,
7349 + PART_TYPE_AVR32_UC3B164,
7350 + PART_TYPE_AVR32_UC3B1128,
7351 + PART_TYPE_AVR32_UC3B1256
7352 +};
7353 +
7354 +/* Microarchitectures. */
7355 +enum microarchitecture_type
7356 +{
7357 + UARCH_TYPE_AVR32A,
7358 + UARCH_TYPE_AVR32B,
7359 + UARCH_TYPE_NONE
7360 +};
7361 +
7362 +/* Architectures types which specifies the pipeline.
7363 + Keep this in sync with avr32_arch_types in avr32.c
7364 + and the pipeline attribute in avr32.md */
7365 +enum architecture_type
7366 +{
7367 + ARCH_TYPE_AVR32_AP,
7368 + ARCH_TYPE_AVR32_UC,
7369 + ARCH_TYPE_AVR32_NONE
7370 +};
7371 +
7372 +/* Flag specifying if the cpu has support for DSP instructions.*/
7373 +#define FLAG_AVR32_HAS_DSP (1 << 0)
7374 +/* Flag specifying if the cpu has support for Read-Modify-Write
7375 + instructions.*/
7376 +#define FLAG_AVR32_HAS_RMW (1 << 1)
7377 +/* Flag specifying if the cpu has support for SIMD instructions. */
7378 +#define FLAG_AVR32_HAS_SIMD (1 << 2)
7379 +/* Flag specifying if the cpu has support for unaligned memory word access. */
7380 +#define FLAG_AVR32_HAS_UNALIGNED_WORD (1 << 3)
7381 +/* Flag specifying if the cpu has support for branch prediction. */
7382 +#define FLAG_AVR32_HAS_BRANCH_PRED (1 << 4)
7383 +/* Flag specifying if the cpu has support for a return stack. */
7384 +#define FLAG_AVR32_HAS_RETURN_STACK (1 << 5)
7385 +/* Flag specifying if the cpu has caches. */
7386 +#define FLAG_AVR32_HAS_CACHES (1 << 6)
7387 +
7388 +/* Structure for holding information about different avr32 CPUs/parts */
7389 +struct part_type_s
7390 +{
7391 + const char *const name;
7392 + enum part_type part_type;
7393 + enum architecture_type arch_type;
7394 + /* Must lie outside user's namespace. NULL == no macro. */
7395 + const char *const macro;
7396 +};
7397 +
7398 +/* Structure for holding information about different avr32 pipeline
7399 + architectures. */
7400 +struct arch_type_s
7401 +{
7402 + const char *const name;
7403 + enum architecture_type arch_type;
7404 + enum microarchitecture_type uarch_type;
7405 + const unsigned long feature_flags;
7406 + /* Must lie outside user's namespace. NULL == no macro. */
7407 + const char *const macro;
7408 +};
7409 +
7410 +extern const struct part_type_s *avr32_part;
7411 +extern const struct arch_type_s *avr32_arch;
7412 +
7413 +#define TARGET_SIMD (avr32_arch->feature_flags & FLAG_AVR32_HAS_SIMD)
7414 +#define TARGET_DSP (avr32_arch->feature_flags & FLAG_AVR32_HAS_DSP)
7415 +#define TARGET_RMW (avr32_arch->feature_flags & FLAG_AVR32_HAS_RMW)
7416 +#define TARGET_UNALIGNED_WORD (avr32_arch->feature_flags & FLAG_AVR32_HAS_UNALIGNED_WORD)
7417 +#define TARGET_BRANCH_PRED (avr32_arch->feature_flags & FLAG_AVR32_HAS_BRANCH_PRED)
7418 +#define TARGET_RETURN_STACK (avr32_arch->feature_flags & FLAG_AVR32_HAS_RETURN_STACK)
7419 +#define TARGET_CACHES (avr32_arch->feature_flags & FLAG_AVR32_HAS_CACHES)
7420 +
7421 +#define CAN_DEBUG_WITHOUT_FP
7422 +
7423 +/******************************************************************************
7424 + * Storage Layout
7425 + *****************************************************************************/
7426 +
7427 +/*
7428 +Define this macro to have the value 1 if the most significant bit in a
7429 +byte has the lowest number; otherwise define it to have the value zero.
7430 +This means that bit-field instructions count from the most significant
7431 +bit. If the machine has no bit-field instructions, then this must still
7432 +be defined, but it doesn't matter which value it is defined to. This
7433 +macro need not be a constant.
7434 +
7435 +This macro does not affect the way structure fields are packed into
7436 +bytes or words; that is controlled by BYTES_BIG_ENDIAN.
7437 +*/
7438 +#define BITS_BIG_ENDIAN 0
7439 +
7440 +/*
7441 +Define this macro to have the value 1 if the most significant byte in a
7442 +word has the lowest number. This macro need not be a constant.
7443 +*/
7444 +/*
7445 + Data is stored in an big-endian way.
7446 +*/
7447 +#define BYTES_BIG_ENDIAN 1
7448 +
7449 +/*
7450 +Define this macro to have the value 1 if, in a multiword object, the
7451 +most significant word has the lowest number. This applies to both
7452 +memory locations and registers; GCC fundamentally assumes that the
7453 +order of words in memory is the same as the order in registers. This
7454 +macro need not be a constant.
7455 +*/
7456 +/*
7457 + Data is stored in an bin-endian way.
7458 +*/
7459 +#define WORDS_BIG_ENDIAN 1
7460 +
7461 +/*
7462 +Define this macro if WORDS_BIG_ENDIAN is not constant. This must be a
7463 +constant value with the same meaning as WORDS_BIG_ENDIAN, which will be
7464 +used only when compiling libgcc2.c. Typically the value will be set
7465 +based on preprocessor defines.
7466 +*/
7467 +#define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
7468 +
7469 +/*
7470 +Define this macro to have the value 1 if DFmode, XFmode or
7471 +TFmode floating point numbers are stored in memory with the word
7472 +containing the sign bit at the lowest address; otherwise define it to
7473 +have the value 0. This macro need not be a constant.
7474 +
7475 +You need not define this macro if the ordering is the same as for
7476 +multi-word integers.
7477 +*/
7478 +/* #define FLOAT_WORDS_BIG_ENDIAN 1 */
7479 +
7480 +/*
7481 +Define this macro to be the number of bits in an addressable storage
7482 +unit (byte); normally 8.
7483 +*/
7484 +#define BITS_PER_UNIT 8
7485 +
7486 +/*
7487 +Number of bits in a word; normally 32.
7488 +*/
7489 +#define BITS_PER_WORD 32
7490 +
7491 +/*
7492 +Maximum number of bits in a word. If this is undefined, the default is
7493 +BITS_PER_WORD. Otherwise, it is the constant value that is the
7494 +largest value that BITS_PER_WORD can have at run-time.
7495 +*/
7496 +/* MAX_BITS_PER_WORD not defined*/
7497 +
7498 +/*
7499 +Number of storage units in a word; normally 4.
7500 +*/
7501 +#define UNITS_PER_WORD 4
7502 +
7503 +/*
7504 +Minimum number of units in a word. If this is undefined, the default is
7505 +UNITS_PER_WORD. Otherwise, it is the constant value that is the
7506 +smallest value that UNITS_PER_WORD can have at run-time.
7507 +*/
7508 +/* MIN_UNITS_PER_WORD not defined */
7509 +
7510 +/*
7511 +Width of a pointer, in bits. You must specify a value no wider than the
7512 +width of Pmode. If it is not equal to the width of Pmode,
7513 +you must define POINTERS_EXTEND_UNSIGNED.
7514 +*/
7515 +#define POINTER_SIZE 32
7516 +
7517 +/*
7518 +A C expression whose value is greater than zero if pointers that need to be
7519 +extended from being POINTER_SIZE bits wide to Pmode are to
7520 +be zero-extended and zero if they are to be sign-extended. If the value
7521 +is less then zero then there must be an "ptr_extend" instruction that
7522 +extends a pointer from POINTER_SIZE to Pmode.
7523 +
7524 +You need not define this macro if the POINTER_SIZE is equal
7525 +to the width of Pmode.
7526 +*/
7527 +/* #define POINTERS_EXTEND_UNSIGNED */
7528 +
7529 +/*
7530 +A Macro to update M and UNSIGNEDP when an object whose type
7531 +is TYPE and which has the specified mode and signedness is to be
7532 +stored in a register. This macro is only called when TYPE is a
7533 +scalar type.
7534 +
7535 +On most RISC machines, which only have operations that operate on a full
7536 +register, define this macro to set M to word_mode if
7537 +M is an integer mode narrower than BITS_PER_WORD. In most
7538 +cases, only integer modes should be widened because wider-precision
7539 +floating-point operations are usually more expensive than their narrower
7540 +counterparts.
7541 +
7542 +For most machines, the macro definition does not change UNSIGNEDP.
7543 +However, some machines, have instructions that preferentially handle
7544 +either signed or unsigned quantities of certain modes. For example, on
7545 +the DEC Alpha, 32-bit loads from memory and 32-bit add instructions
7546 +sign-extend the result to 64 bits. On such machines, set
7547 +UNSIGNEDP according to which kind of extension is more efficient.
7548 +
7549 +Do not define this macro if it would never modify M.
7550 +*/
7551 +#define PROMOTE_MODE(M, UNSIGNEDP, TYPE) \
7552 + { \
7553 + if (GET_MODE_CLASS (M) == MODE_INT \
7554 + && GET_MODE_SIZE (M) < 4) \
7555 + { \
7556 + if (M == QImode) \
7557 + UNSIGNEDP = 1; \
7558 + else if (M == SImode) \
7559 + UNSIGNEDP = 0; \
7560 + (M) = SImode; \
7561 + } \
7562 + }
7563 +
7564 +#define PROMOTE_FUNCTION_MODE(M, UNSIGNEDP, TYPE) \
7565 + { \
7566 + if (GET_MODE_CLASS (M) == MODE_INT \
7567 + && GET_MODE_SIZE (M) < 4) \
7568 + { \
7569 + (M) = SImode; \
7570 + } \
7571 + }
7572 +
7573 +/* Define if operations between registers always perform the operation
7574 + on the full register even if a narrower mode is specified. */
7575 +#define WORD_REGISTER_OPERATIONS
7576 +
7577 +/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
7578 + will either zero-extend or sign-extend. The value of this macro should
7579 + be the code that says which one of the two operations is implicitly
7580 + done, UNKNOWN if not known. */
7581 +#define LOAD_EXTEND_OP(MODE) \
7582 + (((MODE) == QImode) ? ZERO_EXTEND \
7583 + : ((MODE) == HImode) ? SIGN_EXTEND : UNKNOWN)
7584 +
7585 +
7586 +/*
7587 +Define this macro if the promotion described by PROMOTE_MODE
7588 +should only be performed for outgoing function arguments or
7589 +function return values, as specified by PROMOTE_FUNCTION_ARGS
7590 +and PROMOTE_FUNCTION_RETURN, respectively.
7591 +*/
7592 +/* #define PROMOTE_FOR_CALL_ONLY */
7593 +
7594 +/*
7595 +Normal alignment required for function parameters on the stack, in
7596 +bits. All stack parameters receive at least this much alignment
7597 +regardless of data type. On most machines, this is the same as the
7598 +size of an integer.
7599 +*/
7600 +#define PARM_BOUNDARY 32
7601 +
7602 +/*
7603 +Define this macro to the minimum alignment enforced by hardware for the
7604 +stack pointer on this machine. The definition is a C expression for the
7605 +desired alignment (measured in bits). This value is used as a default
7606 +if PREFERRED_STACK_BOUNDARY is not defined. On most machines,
7607 +this should be the same as PARM_BOUNDARY.
7608 +*/
7609 +#define STACK_BOUNDARY 32
7610 +
7611 +/*
7612 +Define this macro if you wish to preserve a certain alignment for the
7613 +stack pointer, greater than what the hardware enforces. The definition
7614 +is a C expression for the desired alignment (measured in bits). This
7615 +macro must evaluate to a value equal to or larger than
7616 +STACK_BOUNDARY.
7617 +*/
7618 +#define PREFERRED_STACK_BOUNDARY (TARGET_FORCE_DOUBLE_ALIGN ? 64 : 32 )
7619 +
7620 +/*
7621 +Alignment required for a function entry point, in bits.
7622 +*/
7623 +#define FUNCTION_BOUNDARY 16
7624 +
7625 +/*
7626 +Biggest alignment that any data type can require on this machine, in bits.
7627 +*/
7628 +#define BIGGEST_ALIGNMENT (TARGET_FORCE_DOUBLE_ALIGN ? 64 : 32 )
7629 +
7630 +/*
7631 +If defined, the smallest alignment, in bits, that can be given to an
7632 +object that can be referenced in one operation, without disturbing any
7633 +nearby object. Normally, this is BITS_PER_UNIT, but may be larger
7634 +on machines that don't have byte or half-word store operations.
7635 +*/
7636 +#define MINIMUM_ATOMIC_ALIGNMENT BITS_PER_UNIT
7637 +
7638 +
7639 +/*
7640 +An integer expression for the size in bits of the largest integer machine mode that
7641 +should actually be used. All integer machine modes of this size or smaller can be
7642 +used for structures and unions with the appropriate sizes. If this macro is undefined,
7643 +GET_MODE_BITSIZE (DImode) is assumed.*/
7644 +#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (DImode)
7645 +
7646 +
7647 +/*
7648 +If defined, a C expression to compute the alignment given to a constant
7649 +that is being placed in memory. CONSTANT is the constant and
7650 +BASIC_ALIGN is the alignment that the object would ordinarily
7651 +have. The value of this macro is used instead of that alignment to
7652 +align the object.
7653 +
7654 +If this macro is not defined, then BASIC_ALIGN is used.
7655 +
7656 +The typical use of this macro is to increase alignment for string
7657 +constants to be word aligned so that strcpy calls that copy
7658 +constants can be done inline.
7659 +*/
7660 +#define CONSTANT_ALIGNMENT(CONSTANT, BASIC_ALIGN) \
7661 + ((TREE_CODE(CONSTANT) == STRING_CST) ? BITS_PER_WORD : BASIC_ALIGN)
7662 +
7663 +/* Try to align string to a word. */
7664 +#define DATA_ALIGNMENT(TYPE, ALIGN) \
7665 + ({(TREE_CODE (TYPE) == ARRAY_TYPE \
7666 + && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
7667 + && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN));})
7668 +
7669 +/* Try to align local store strings to a word. */
7670 +#define LOCAL_ALIGNMENT(TYPE, ALIGN) \
7671 + ({(TREE_CODE (TYPE) == ARRAY_TYPE \
7672 + && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
7673 + && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN));})
7674 +
7675 +/*
7676 +Define this macro to be the value 1 if instructions will fail to work
7677 +if given data not on the nominal alignment. If instructions will merely
7678 +go slower in that case, define this macro as 0.
7679 +*/
7680 +#define STRICT_ALIGNMENT 1
7681 +
7682 +/*
7683 +Define this if you wish to imitate the way many other C compilers handle
7684 +alignment of bit-fields and the structures that contain them.
7685 +
7686 +The behavior is that the type written for a bit-field (int,
7687 +short, or other integer type) imposes an alignment for the
7688 +entire structure, as if the structure really did contain an ordinary
7689 +field of that type. In addition, the bit-field is placed within the
7690 +structure so that it would fit within such a field, not crossing a
7691 +boundary for it.
7692 +
7693 +Thus, on most machines, a bit-field whose type is written as int
7694 +would not cross a four-byte boundary, and would force four-byte
7695 +alignment for the whole structure. (The alignment used may not be four
7696 +bytes; it is controlled by the other alignment parameters.)
7697 +
7698 +If the macro is defined, its definition should be a C expression;
7699 +a nonzero value for the expression enables this behavior.
7700 +
7701 +Note that if this macro is not defined, or its value is zero, some
7702 +bit-fields may cross more than one alignment boundary. The compiler can
7703 +support such references if there are insv, extv, and
7704 +extzv insns that can directly reference memory.
7705 +
7706 +The other known way of making bit-fields work is to define
7707 +STRUCTURE_SIZE_BOUNDARY as large as BIGGEST_ALIGNMENT.
7708 +Then every structure can be accessed with fullwords.
7709 +
7710 +Unless the machine has bit-field instructions or you define
7711 +STRUCTURE_SIZE_BOUNDARY that way, you must define
7712 +PCC_BITFIELD_TYPE_MATTERS to have a nonzero value.
7713 +
7714 +If your aim is to make GCC use the same conventions for laying out
7715 +bit-fields as are used by another compiler, here is how to investigate
7716 +what the other compiler does. Compile and run this program:
7717 +
7718 +struct foo1
7719 +{
7720 + char x;
7721 + char :0;
7722 + char y;
7723 +};
7724 +
7725 +struct foo2
7726 +{
7727 + char x;
7728 + int :0;
7729 + char y;
7730 +};
7731 +
7732 +main ()
7733 +{
7734 + printf ("Size of foo1 is %d\n",
7735 + sizeof (struct foo1));
7736 + printf ("Size of foo2 is %d\n",
7737 + sizeof (struct foo2));
7738 + exit (0);
7739 +}
7740 +
7741 +If this prints 2 and 5, then the compiler's behavior is what you would
7742 +get from PCC_BITFIELD_TYPE_MATTERS.
7743 +*/
7744 +#define PCC_BITFIELD_TYPE_MATTERS 1
7745 +
7746 +
7747 +/******************************************************************************
7748 + * Layout of Source Language Data Types
7749 + *****************************************************************************/
7750 +
7751 +/*
7752 +A C expression for the size in bits of the type int on the
7753 +target machine. If you don't define this, the default is one word.
7754 +*/
7755 +#define INT_TYPE_SIZE 32
7756 +
7757 +/*
7758 +A C expression for the size in bits of the type short on the
7759 +target machine. If you don't define this, the default is half a word. (If
7760 +this would be less than one storage unit, it is rounded up to one unit.)
7761 +*/
7762 +#define SHORT_TYPE_SIZE 16
7763 +
7764 +/*
7765 +A C expression for the size in bits of the type long on the
7766 +target machine. If you don't define this, the default is one word.
7767 +*/
7768 +#define LONG_TYPE_SIZE 32
7769 +
7770 +
7771 +/*
7772 +A C expression for the size in bits of the type long long on the
7773 +target machine. If you don't define this, the default is two
7774 +words. If you want to support GNU Ada on your machine, the value of this
7775 +macro must be at least 64.
7776 +*/
7777 +#define LONG_LONG_TYPE_SIZE 64
7778 +
7779 +/*
7780 +A C expression for the size in bits of the type char on the
7781 +target machine. If you don't define this, the default is
7782 +BITS_PER_UNIT.
7783 +*/
7784 +#define CHAR_TYPE_SIZE 8
7785 +
7786 +
7787 +/*
7788 +A C expression for the size in bits of the C++ type bool and
7789 +C99 type _Bool on the target machine. If you don't define
7790 +this, and you probably shouldn't, the default is CHAR_TYPE_SIZE.
7791 +*/
7792 +#define BOOL_TYPE_SIZE 8
7793 +
7794 +
7795 +/*
7796 +An expression whose value is 1 or 0, according to whether the type
7797 +char should be signed or unsigned by default. The user can
7798 +always override this default with the options -fsigned-char
7799 +and -funsigned-char.
7800 +*/
7801 +/* We are using unsigned char */
7802 +#define DEFAULT_SIGNED_CHAR 0
7803 +
7804 +
7805 +/*
7806 +A C expression for a string describing the name of the data type to use
7807 +for size values. The typedef name size_t is defined using the
7808 +contents of the string.
7809 +
7810 +The string can contain more than one keyword. If so, separate them with
7811 +spaces, and write first any length keyword, then unsigned if
7812 +appropriate, and finally int. The string must exactly match one
7813 +of the data type names defined in the function
7814 +init_decl_processing in the file c-decl.c. You may not
7815 +omit int or change the order - that would cause the compiler to
7816 +crash on startup.
7817 +
7818 +If you don't define this macro, the default is "long unsigned int".
7819 +*/
7820 +#define SIZE_TYPE "long unsigned int"
7821 +
7822 +/*
7823 +A C expression for a string describing the name of the data type to use
7824 +for the result of subtracting two pointers. The typedef name
7825 +ptrdiff_t is defined using the contents of the string. See
7826 +SIZE_TYPE above for more information.
7827 +
7828 +If you don't define this macro, the default is "long int".
7829 +*/
7830 +#define PTRDIFF_TYPE "long int"
7831 +
7832 +
7833 +/*
7834 +A C expression for the size in bits of the data type for wide
7835 +characters. This is used in cpp, which cannot make use of
7836 +WCHAR_TYPE.
7837 +*/
7838 +#define WCHAR_TYPE_SIZE 32
7839 +
7840 +
7841 +/*
7842 +A C expression for a string describing the name of the data type to
7843 +use for wide characters passed to printf and returned from
7844 +getwc. The typedef name wint_t is defined using the
7845 +contents of the string. See SIZE_TYPE above for more
7846 +information.
7847 +
7848 +If you don't define this macro, the default is "unsigned int".
7849 +*/
7850 +#define WINT_TYPE "unsigned int"
7851 +
7852 +/*
7853 +A C expression for a string describing the name of the data type that
7854 +can represent any value of any standard or extended signed integer type.
7855 +The typedef name intmax_t is defined using the contents of the
7856 +string. See SIZE_TYPE above for more information.
7857 +
7858 +If you don't define this macro, the default is the first of
7859 +"int", "long int", or "long long int" that has as
7860 +much precision as long long int.
7861 +*/
7862 +#define INTMAX_TYPE "long long int"
7863 +
7864 +/*
7865 +A C expression for a string describing the name of the data type that
7866 +can represent any value of any standard or extended unsigned integer
7867 +type. The typedef name uintmax_t is defined using the contents
7868 +of the string. See SIZE_TYPE above for more information.
7869 +
7870 +If you don't define this macro, the default is the first of
7871 +"unsigned int", "long unsigned int", or "long long unsigned int"
7872 +that has as much precision as long long unsigned int.
7873 +*/
7874 +#define UINTMAX_TYPE "long long unsigned int"
7875 +
7876 +
7877 +/******************************************************************************
7878 + * Register Usage
7879 + *****************************************************************************/
7880 +
7881 +/* Convert from gcc internal register number to register number
7882 + used in assembly code */
7883 +#define ASM_REGNUM(reg) (LAST_REGNUM - (reg))
7884 +#define ASM_FP_REGNUM(reg) (LAST_FP_REGNUM - (reg))
7885 +
7886 +/* Convert between register number used in assembly to gcc
7887 + internal register number */
7888 +#define INTERNAL_REGNUM(reg) (LAST_REGNUM - (reg))
7889 +#define INTERNAL_FP_REGNUM(reg) (LAST_FP_REGNUM - (reg))
7890 +
7891 +/** Basic Characteristics of Registers **/
7892 +
7893 +/*
7894 +Number of hardware registers known to the compiler. They receive
7895 +numbers 0 through FIRST_PSEUDO_REGISTER-1; thus, the first
7896 +pseudo register's number really is assigned the number
7897 +FIRST_PSEUDO_REGISTER.
7898 +*/
7899 +#define FIRST_PSEUDO_REGISTER (LAST_FP_REGNUM + 1)
7900 +
7901 +#define FIRST_REGNUM 0
7902 +#define LAST_REGNUM 15
7903 +#define NUM_FP_REGS 16
7904 +#define FIRST_FP_REGNUM 16
7905 +#define LAST_FP_REGNUM (16+NUM_FP_REGS-1)
7906 +
7907 +/*
7908 +An initializer that says which registers are used for fixed purposes
7909 +all throughout the compiled code and are therefore not available for
7910 +general allocation. These would include the stack pointer, the frame
7911 +pointer (except on machines where that can be used as a general
7912 +register when no frame pointer is needed), the program counter on
7913 +machines where that is considered one of the addressable registers,
7914 +and any other numbered register with a standard use.
7915 +
7916 +This information is expressed as a sequence of numbers, separated by
7917 +commas and surrounded by braces. The nth number is 1 if
7918 +register n is fixed, 0 otherwise.
7919 +
7920 +The table initialized from this macro, and the table initialized by
7921 +the following one, may be overridden at run time either automatically,
7922 +by the actions of the macro CONDITIONAL_REGISTER_USAGE, or by
7923 +the user with the command options -ffixed-[reg],
7924 +-fcall-used-[reg] and -fcall-saved-[reg].
7925 +*/
7926 +
7927 +/* The internal gcc register numbers are reversed
7928 + compared to the real register numbers since
7929 + gcc expects data types stored over multiple
7930 + registers in the register file to be big endian
7931 + if the memory layout is big endian. But this
7932 + is not the case for avr32 so we fake a big
7933 + endian register file. */
7934 +
7935 +#define FIXED_REGISTERS { \
7936 + 1, /* Program Counter */ \
7937 + 0, /* Link Register */ \
7938 + 1, /* Stack Pointer */ \
7939 + 0, /* r12 */ \
7940 + 0, /* r11 */ \
7941 + 0, /* r10 */ \
7942 + 0, /* r9 */ \
7943 + 0, /* r8 */ \
7944 + 0, /* r7 */ \
7945 + 0, /* r6 */ \
7946 + 0, /* r5 */ \
7947 + 0, /* r4 */ \
7948 + 0, /* r3 */ \
7949 + 0, /* r2 */ \
7950 + 0, /* r1 */ \
7951 + 0, /* r0 */ \
7952 + 0, /* f15 */ \
7953 + 0, /* f14 */ \
7954 + 0, /* f13 */ \
7955 + 0, /* f12 */ \
7956 + 0, /* f11 */ \
7957 + 0, /* f10 */ \
7958 + 0, /* f9 */ \
7959 + 0, /* f8 */ \
7960 + 0, /* f7 */ \
7961 + 0, /* f6 */ \
7962 + 0, /* f5 */ \
7963 + 0, /* f4 */ \
7964 + 0, /* f3 */ \
7965 + 0, /* f2*/ \
7966 + 0, /* f1 */ \
7967 + 0 /* f0 */ \
7968 +}
7969 +
7970 +/*
7971 +Like FIXED_REGISTERS but has 1 for each register that is
7972 +clobbered (in general) by function calls as well as for fixed
7973 +registers. This macro therefore identifies the registers that are not
7974 +available for general allocation of values that must live across
7975 +function calls.
7976 +
7977 +If a register has 0 in CALL_USED_REGISTERS, the compiler
7978 +automatically saves it on function entry and restores it on function
7979 +exit, if the register is used within the function.
7980 +*/
7981 +#define CALL_USED_REGISTERS { \
7982 + 1, /* Program Counter */ \
7983 + 0, /* Link Register */ \
7984 + 1, /* Stack Pointer */ \
7985 + 1, /* r12 */ \
7986 + 1, /* r11 */ \
7987 + 1, /* r10 */ \
7988 + 1, /* r9 */ \
7989 + 1, /* r8 */ \
7990 + 0, /* r7 */ \
7991 + 0, /* r6 */ \
7992 + 0, /* r5 */ \
7993 + 0, /* r4 */ \
7994 + 0, /* r3 */ \
7995 + 0, /* r2 */ \
7996 + 0, /* r1 */ \
7997 + 0, /* r0 */ \
7998 + 1, /* f15 */ \
7999 + 1, /* f14 */ \
8000 + 1, /* f13 */ \
8001 + 1, /* f12 */ \
8002 + 1, /* f11 */ \
8003 + 1, /* f10 */ \
8004 + 1, /* f9 */ \
8005 + 1, /* f8 */ \
8006 + 0, /* f7 */ \
8007 + 0, /* f6 */ \
8008 + 0, /* f5 */ \
8009 + 0, /* f4 */ \
8010 + 0, /* f3 */ \
8011 + 0, /* f2*/ \
8012 + 0, /* f1*/ \
8013 + 0, /* f0 */ \
8014 +}
8015 +
8016 +/* Interrupt functions can only use registers that have already been
8017 + saved by the prologue, even if they would normally be
8018 + call-clobbered. */
8019 +#define HARD_REGNO_RENAME_OK(SRC, DST) \
8020 + (! IS_INTERRUPT (cfun->machine->func_type) || \
8021 + regs_ever_live[DST])
8022 +
8023 +
8024 +/*
8025 +Zero or more C statements that may conditionally modify five variables
8026 +fixed_regs, call_used_regs, global_regs,
8027 +reg_names, and reg_class_contents, to take into account
8028 +any dependence of these register sets on target flags. The first three
8029 +of these are of type char [] (interpreted as Boolean vectors).
8030 +global_regs is a const char *[], and
8031 +reg_class_contents is a HARD_REG_SET. Before the macro is
8032 +called, fixed_regs, call_used_regs,
8033 +reg_class_contents, and reg_names have been initialized
8034 +from FIXED_REGISTERS, CALL_USED_REGISTERS,
8035 +REG_CLASS_CONTENTS, and REGISTER_NAMES, respectively.
8036 +global_regs has been cleared, and any -ffixed-[reg],
8037 +-fcall-used-[reg] and -fcall-saved-[reg]
8038 +command options have been applied.
8039 +
8040 +You need not define this macro if it has no work to do.
8041 +
8042 +If the usage of an entire class of registers depends on the target
8043 +flags, you may indicate this to GCC by using this macro to modify
8044 +fixed_regs and call_used_regs to 1 for each of the
8045 +registers in the classes which should not be used by GCC. Also define
8046 +the macro REG_CLASS_FROM_LETTER to return NO_REGS if it
8047 +is called with a letter for a class that shouldn't be used.
8048 +
8049 + (However, if this class is not included in GENERAL_REGS and all
8050 +of the insn patterns whose constraints permit this class are
8051 +controlled by target switches, then GCC will automatically avoid using
8052 +these registers when the target switches are opposed to them.)
8053 +*/
8054 +#define CONDITIONAL_REGISTER_USAGE \
8055 + do \
8056 + { \
8057 + int regno; \
8058 + \
8059 + if (TARGET_SOFT_FLOAT) \
8060 + { \
8061 + for (regno = FIRST_FP_REGNUM; \
8062 + regno <= LAST_FP_REGNUM; ++regno) \
8063 + fixed_regs[regno] = call_used_regs[regno] = 1; \
8064 + } \
8065 + if (flag_pic) \
8066 + { \
8067 + fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
8068 + call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
8069 + } \
8070 + } \
8071 + while (0)
8072 +
8073 +
8074 +/*
8075 +If the program counter has a register number, define this as that
8076 +register number. Otherwise, do not define it.
8077 +*/
8078 +
8079 +#define LAST_AVR32_REGNUM 16
8080 +
8081 +
8082 +/** Order of Allocation of Registers **/
8083 +
8084 +/*
8085 +If defined, an initializer for a vector of integers, containing the
8086 +numbers of hard registers in the order in which GCC should prefer
8087 +to use them (from most preferred to least).
8088 +
8089 +If this macro is not defined, registers are used lowest numbered first
8090 +(all else being equal).
8091 +
8092 +One use of this macro is on machines where the highest numbered
8093 +registers must always be saved and the save-multiple-registers
8094 +instruction supports only sequences of consecutive registers. On such
8095 +machines, define REG_ALLOC_ORDER to be an initializer that lists
8096 +the highest numbered allocable register first.
8097 +*/
8098 +#define REG_ALLOC_ORDER \
8099 +{ \
8100 + INTERNAL_REGNUM(8), \
8101 + INTERNAL_REGNUM(9), \
8102 + INTERNAL_REGNUM(10), \
8103 + INTERNAL_REGNUM(11), \
8104 + INTERNAL_REGNUM(12), \
8105 + LR_REGNUM, \
8106 + INTERNAL_REGNUM(7), \
8107 + INTERNAL_REGNUM(6), \
8108 + INTERNAL_REGNUM(5), \
8109 + INTERNAL_REGNUM(4), \
8110 + INTERNAL_REGNUM(3), \
8111 + INTERNAL_REGNUM(2), \
8112 + INTERNAL_REGNUM(1), \
8113 + INTERNAL_REGNUM(0), \
8114 + INTERNAL_FP_REGNUM(15), \
8115 + INTERNAL_FP_REGNUM(14), \
8116 + INTERNAL_FP_REGNUM(13), \
8117 + INTERNAL_FP_REGNUM(12), \
8118 + INTERNAL_FP_REGNUM(11), \
8119 + INTERNAL_FP_REGNUM(10), \
8120 + INTERNAL_FP_REGNUM(9), \
8121 + INTERNAL_FP_REGNUM(8), \
8122 + INTERNAL_FP_REGNUM(7), \
8123 + INTERNAL_FP_REGNUM(6), \
8124 + INTERNAL_FP_REGNUM(5), \
8125 + INTERNAL_FP_REGNUM(4), \
8126 + INTERNAL_FP_REGNUM(3), \
8127 + INTERNAL_FP_REGNUM(2), \
8128 + INTERNAL_FP_REGNUM(1), \
8129 + INTERNAL_FP_REGNUM(0), \
8130 + SP_REGNUM, \
8131 + PC_REGNUM \
8132 +}
8133 +
8134 +
8135 +/** How Values Fit in Registers **/
8136 +
8137 +/*
8138 +A C expression for the number of consecutive hard registers, starting
8139 +at register number REGNO, required to hold a value of mode
8140 +MODE.
8141 +
8142 +On a machine where all registers are exactly one word, a suitable
8143 +definition of this macro is
8144 +
8145 +#define HARD_REGNO_NREGS(REGNO, MODE) \
8146 + ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
8147 + / UNITS_PER_WORD)
8148 +*/
8149 +#define HARD_REGNO_NREGS(REGNO, MODE) \
8150 + ((unsigned int)((GET_MODE_SIZE(MODE) + UNITS_PER_WORD -1 ) / UNITS_PER_WORD))
8151 +
8152 +/*
8153 +A C expression that is nonzero if it is permissible to store a value
8154 +of mode MODE in hard register number REGNO (or in several
8155 +registers starting with that one). For a machine where all registers
8156 +are equivalent, a suitable definition is
8157 +
8158 + #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
8159 +
8160 +You need not include code to check for the numbers of fixed registers,
8161 +because the allocation mechanism considers them to be always occupied.
8162 +
8163 +On some machines, double-precision values must be kept in even/odd
8164 +register pairs. You can implement that by defining this macro to reject
8165 +odd register numbers for such modes.
8166 +
8167 +The minimum requirement for a mode to be OK in a register is that the
8168 +mov[mode] instruction pattern support moves between the
8169 +register and other hard register in the same class and that moving a
8170 +value into the register and back out not alter it.
8171 +
8172 +Since the same instruction used to move word_mode will work for
8173 +all narrower integer modes, it is not necessary on any machine for
8174 +HARD_REGNO_MODE_OK to distinguish between these modes, provided
8175 +you define patterns movhi, etc., to take advantage of this. This
8176 +is useful because of the interaction between HARD_REGNO_MODE_OK
8177 +and MODES_TIEABLE_P; it is very desirable for all integer modes
8178 +to be tieable.
8179 +
8180 +Many machines have special registers for floating point arithmetic.
8181 +Often people assume that floating point machine modes are allowed only
8182 +in floating point registers. This is not true. Any registers that
8183 +can hold integers can safely hold a floating point machine
8184 +mode, whether or not floating arithmetic can be done on it in those
8185 +registers. Integer move instructions can be used to move the values.
8186 +
8187 +On some machines, though, the converse is true: fixed-point machine
8188 +modes may not go in floating registers. This is true if the floating
8189 +registers normalize any value stored in them, because storing a
8190 +non-floating value there would garble it. In this case,
8191 +HARD_REGNO_MODE_OK should reject fixed-point machine modes in
8192 +floating registers. But if the floating registers do not automatically
8193 +normalize, if you can store any bit pattern in one and retrieve it
8194 +unchanged without a trap, then any machine mode may go in a floating
8195 +register, so you can define this macro to say so.
8196 +
8197 +The primary significance of special floating registers is rather that
8198 +they are the registers acceptable in floating point arithmetic
8199 +instructions. However, this is of no concern to
8200 +HARD_REGNO_MODE_OK. You handle it by writing the proper
8201 +constraints for those instructions.
8202 +
8203 +On some machines, the floating registers are especially slow to access,
8204 +so that it is better to store a value in a stack frame than in such a
8205 +register if floating point arithmetic is not being done. As long as the
8206 +floating registers are not in class GENERAL_REGS, they will not
8207 +be used unless some pattern's constraint asks for one.
8208 +*/
8209 +#define HARD_REGNO_MODE_OK(REGNO, MODE) avr32_hard_regno_mode_ok(REGNO, MODE)
8210 +
8211 +/*
8212 +A C expression that is nonzero if a value of mode
8213 +MODE1 is accessible in mode MODE2 without copying.
8214 +
8215 +If HARD_REGNO_MODE_OK(R, MODE1) and
8216 +HARD_REGNO_MODE_OK(R, MODE2) are always the same for
8217 +any R, then MODES_TIEABLE_P(MODE1, MODE2)
8218 +should be nonzero. If they differ for any R, you should define
8219 +this macro to return zero unless some other mechanism ensures the
8220 +accessibility of the value in a narrower mode.
8221 +
8222 +You should define this macro to return nonzero in as many cases as
8223 +possible since doing so will allow GCC to perform better register
8224 +allocation.
8225 +*/
8226 +#define MODES_TIEABLE_P(MODE1, MODE2) \
8227 + (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
8228 +
8229 +
8230 +
8231 +/******************************************************************************
8232 + * Register Classes
8233 + *****************************************************************************/
8234 +
8235 +/*
8236 +An enumeral type that must be defined with all the register class names
8237 +as enumeral values. NO_REGS must be first. ALL_REGS
8238 +must be the last register class, followed by one more enumeral value,
8239 +LIM_REG_CLASSES, which is not a register class but rather
8240 +tells how many classes there are.
8241 +
8242 +Each register class has a number, which is the value of casting
8243 +the class name to type int. The number serves as an index
8244 +in many of the tables described below.
8245 +*/
8246 +enum reg_class
8247 +{
8248 + NO_REGS,
8249 + GENERAL_REGS,
8250 + FP_REGS,
8251 + ALL_REGS,
8252 + LIM_REG_CLASSES
8253 +};
8254 +
8255 +/*
8256 +The number of distinct register classes, defined as follows:
8257 + #define N_REG_CLASSES (int) LIM_REG_CLASSES
8258 +*/
8259 +#define N_REG_CLASSES (int)LIM_REG_CLASSES
8260 +
8261 +/*
8262 +An initializer containing the names of the register classes as C string
8263 +constants. These names are used in writing some of the debugging dumps.
8264 +*/
8265 +#define REG_CLASS_NAMES \
8266 +{ \
8267 + "NO_REGS", \
8268 + "GENERAL_REGS", \
8269 + "FLOATING_POINT_REGS", \
8270 + "ALL_REGS" \
8271 +}
8272 +
8273 +/*
8274 +An initializer containing the contents of the register classes, as integers
8275 +which are bit masks. The nth integer specifies the contents of class
8276 +n. The way the integer mask is interpreted is that
8277 +register r is in the class if mask & (1 << r) is 1.
8278 +
8279 +When the machine has more than 32 registers, an integer does not suffice.
8280 +Then the integers are replaced by sub-initializers, braced groupings containing
8281 +several integers. Each sub-initializer must be suitable as an initializer
8282 +for the type HARD_REG_SET which is defined in hard-reg-set.h.
8283 +In this situation, the first integer in each sub-initializer corresponds to
8284 +registers 0 through 31, the second integer to registers 32 through 63, and
8285 +so on.
8286 +*/
8287 +#define REG_CLASS_CONTENTS { \
8288 + {0x00000000}, /* NO_REGS */ \
8289 + {0x0000FFFF}, /* GENERAL_REGS */ \
8290 + {0xFFFF0000}, /* FP_REGS */ \
8291 + {0x7FFFFFFF}, /* ALL_REGS */ \
8292 +}
8293 +
8294 +
8295 +/*
8296 +A C expression whose value is a register class containing hard register
8297 +REGNO. In general there is more than one such class; choose a class
8298 +which is minimal, meaning that no smaller class also contains the
8299 +register.
8300 +*/
8301 +#define REGNO_REG_CLASS(REGNO) ((REGNO < 16) ? GENERAL_REGS : FP_REGS)
8302 +
8303 +/*
8304 +A macro whose definition is the name of the class to which a valid
8305 +base register must belong. A base register is one used in an address
8306 +which is the register value plus a displacement.
8307 +*/
8308 +#define BASE_REG_CLASS GENERAL_REGS
8309 +
8310 +/*
8311 +This is a variation of the BASE_REG_CLASS macro which allows
8312 +the selection of a base register in a mode depenedent manner. If
8313 +mode is VOIDmode then it should return the same value as
8314 +BASE_REG_CLASS.
8315 +*/
8316 +#define MODE_BASE_REG_CLASS(MODE) BASE_REG_CLASS
8317 +
8318 +/*
8319 +A macro whose definition is the name of the class to which a valid
8320 +index register must belong. An index register is one used in an
8321 +address where its value is either multiplied by a scale factor or
8322 +added to another register (as well as added to a displacement).
8323 +*/
8324 +#define INDEX_REG_CLASS BASE_REG_CLASS
8325 +
8326 +/*
8327 +A C expression which defines the machine-dependent operand constraint
8328 +letters for register classes. If CHAR is such a letter, the
8329 +value should be the register class corresponding to it. Otherwise,
8330 +the value should be NO_REGS. The register letter r,
8331 +corresponding to class GENERAL_REGS, will not be passed
8332 +to this macro; you do not need to handle it.
8333 +*/
8334 +#define REG_CLASS_FROM_LETTER(CHAR) ((CHAR) == 'f' ? FP_REGS : NO_REGS)
8335 +
8336 +
8337 +/* These assume that REGNO is a hard or pseudo reg number.
8338 + They give nonzero only if REGNO is a hard reg of the suitable class
8339 + or a pseudo reg currently allocated to a suitable hard reg.
8340 + Since they use reg_renumber, they are safe only once reg_renumber
8341 + has been allocated, which happens in local-alloc.c. */
8342 +#define TEST_REGNO(R, TEST, VALUE) \
8343 + ((R TEST VALUE) || ((unsigned) reg_renumber[R] TEST VALUE))
8344 +
8345 +/*
8346 +A C expression which is nonzero if register number num is suitable for use as a base
8347 +register in operand addresses. It may be either a suitable hard register or a pseudo
8348 +register that has been allocated such a hard register.
8349 +*/
8350 +#define REGNO_OK_FOR_BASE_P(NUM) TEST_REGNO(NUM, <=, LAST_REGNUM)
8351 +
8352 +/*
8353 +A C expression which is nonzero if register number NUM is
8354 +suitable for use as an index register in operand addresses. It may be
8355 +either a suitable hard register or a pseudo register that has been
8356 +allocated such a hard register.
8357 +
8358 +The difference between an index register and a base register is that
8359 +the index register may be scaled. If an address involves the sum of
8360 +two registers, neither one of them scaled, then either one may be
8361 +labeled the ``base'' and the other the ``index''; but whichever
8362 +labeling is used must fit the machine's constraints of which registers
8363 +may serve in each capacity. The compiler will try both labelings,
8364 +looking for one that is valid, and will reload one or both registers
8365 +only if neither labeling works.
8366 +*/
8367 +#define REGNO_OK_FOR_INDEX_P(NUM) TEST_REGNO(NUM, <=, LAST_REGNUM)
8368 +
8369 +/*
8370 +A C expression that places additional restrictions on the register class
8371 +to use when it is necessary to copy value X into a register in class
8372 +CLASS. The value is a register class; perhaps CLASS, or perhaps
8373 +another, smaller class. On many machines, the following definition is
8374 +safe: #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
8375 +
8376 +Sometimes returning a more restrictive class makes better code. For
8377 +example, on the 68000, when X is an integer constant that is in range
8378 +for a 'moveq' instruction, the value of this macro is always
8379 +DATA_REGS as long as CLASS includes the data registers.
8380 +Requiring a data register guarantees that a 'moveq' will be used.
8381 +
8382 +If X is a const_double, by returning NO_REGS
8383 +you can force X into a memory constant. This is useful on
8384 +certain machines where immediate floating values cannot be loaded into
8385 +certain kinds of registers.
8386 +*/
8387 +#define PREFERRED_RELOAD_CLASS(X, CLASS) CLASS
8388 +
8389 +
8390 +
8391 +/*
8392 +A C expression for the maximum number of consecutive registers
8393 +of class CLASS needed to hold a value of mode MODE.
8394 +
8395 +This is closely related to the macro HARD_REGNO_NREGS. In fact,
8396 +the value of the macro CLASS_MAX_NREGS(CLASS, MODE)
8397 +should be the maximum value of HARD_REGNO_NREGS(REGNO, MODE)
8398 +for all REGNO values in the class CLASS.
8399 +
8400 +This macro helps control the handling of multiple-word values
8401 +in the reload pass.
8402 +*/
8403 +#define CLASS_MAX_NREGS(CLASS, MODE) /* ToDo:fixme */ \
8404 + (unsigned int)((GET_MODE_SIZE(MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
8405 +
8406 +
8407 +/*
8408 + Using CONST_OK_FOR_CONSTRAINT_P instead of CONS_OK_FOR_LETTER_P
8409 + in order to support constraints with more than one letter.
8410 + Only two letters are then used for constant constraints,
8411 + the letter 'K' and the letter 'I'. The constraint starting with
8412 + these letters must consist of four characters. The character following
8413 + 'K' or 'I' must be either 'u' (unsigned) or 's' (signed) to specify
8414 + if the constant is zero or sign extended. The last two characters specify
8415 + the length in bits of the constant. The base constraint letter 'I' means
8416 + that this is an negated constant, meaning that actually -VAL should be
8417 + checked to lie withing the valid range instead of VAL which is used when
8418 + 'K' is the base constraint letter.
8419 +
8420 +*/
8421 +
8422 +#define CONSTRAINT_LEN(C, STR) \
8423 + ( ((C) == 'K' || (C) == 'I') ? 4 : \
8424 + ((C) == 'R') ? 5 : \
8425 + ((C) == 'N' || (C) == 'O' || \
8426 + (C) == 'P' || (C) == 'L' || (C) == 'J') ? -1 : \
8427 + DEFAULT_CONSTRAINT_LEN((C), (STR)) )
8428 +
8429 +#define CONST_OK_FOR_CONSTRAINT_P(VALUE, C, STR) \
8430 + avr32_const_ok_for_constraint_p(VALUE, C, STR)
8431 +
8432 +/*
8433 +A C expression that defines the machine-dependent operand constraint
8434 +letters that specify particular ranges of const_double values ('G' or 'H').
8435 +
8436 +If C is one of those letters, the expression should check that
8437 +VALUE, an RTX of code const_double, is in the appropriate
8438 +range and return 1 if so, 0 otherwise. If C is not one of those
8439 +letters, the value should be 0 regardless of VALUE.
8440 +
8441 +const_double is used for all floating-point constants and for
8442 +DImode fixed-point constants. A given letter can accept either
8443 +or both kinds of values. It can use GET_MODE to distinguish
8444 +between these kinds.
8445 +*/
8446 +#define CONST_DOUBLE_OK_FOR_LETTER_P(OP, C) \
8447 + ((C) == 'G' ? avr32_const_double_immediate(OP) : 0)
8448 +
8449 +/*
8450 +A C expression that defines the optional machine-dependent constraint
8451 +letters that can be used to segregate specific types of operands, usually
8452 +memory references, for the target machine. Any letter that is not
8453 +elsewhere defined and not matched by REG_CLASS_FROM_LETTER
8454 +may be used. Normally this macro will not be defined.
8455 +
8456 +If it is required for a particular target machine, it should return 1
8457 +if VALUE corresponds to the operand type represented by the
8458 +constraint letter C. If C is not defined as an extra
8459 +constraint, the value returned should be 0 regardless of VALUE.
8460 +
8461 +For example, on the ROMP, load instructions cannot have their output
8462 +in r0 if the memory reference contains a symbolic address. Constraint
8463 +letter 'Q' is defined as representing a memory address that does
8464 +not contain a symbolic address. An alternative is specified with
8465 +a 'Q' constraint on the input and 'r' on the output. The next
8466 +alternative specifies 'm' on the input and a register class that
8467 +does not include r0 on the output.
8468 +*/
8469 +#define EXTRA_CONSTRAINT_STR(OP, C, STR) \
8470 + ((C) == 'W' ? avr32_address_operand(OP, GET_MODE(OP)) : \
8471 + (C) == 'R' ? (avr32_indirect_register_operand(OP, GET_MODE(OP)) || \
8472 + (avr32_imm_disp_memory_operand(OP, GET_MODE(OP)) \
8473 + && avr32_const_ok_for_constraint_p( \
8474 + INTVAL(XEXP(XEXP(OP, 0), 1)), \
8475 + (STR)[1], &(STR)[1]))) : \
8476 + (C) == 'S' ? avr32_indexed_memory_operand(OP, GET_MODE(OP)) : \
8477 + (C) == 'T' ? avr32_const_pool_ref_operand(OP, GET_MODE(OP)) : \
8478 + (C) == 'U' ? SYMBOL_REF_RCALL_FUNCTION_P(OP) : \
8479 + (C) == 'Z' ? avr32_cop_memory_operand(OP, GET_MODE(OP)) : \
8480 + 0)
8481 +
8482 +
8483 +#define EXTRA_MEMORY_CONSTRAINT(C, STR) ( ((C) == 'R') || \
8484 + ((C) == 'S') || \
8485 + ((C) == 'Z') )
8486 +
8487 +
8488 +/* Returns nonzero if op is a function SYMBOL_REF which
8489 + can be called using an rcall instruction */
8490 +#define SYMBOL_REF_RCALL_FUNCTION_P(op) \
8491 + ( GET_CODE(op) == SYMBOL_REF \
8492 + && SYMBOL_REF_FUNCTION_P(op) \
8493 + && SYMBOL_REF_LOCAL_P(op) \
8494 + && !SYMBOL_REF_EXTERNAL_P(op) \
8495 + && !TARGET_HAS_ASM_ADDR_PSEUDOS )
8496 +
8497 +/******************************************************************************
8498 + * Stack Layout and Calling Conventions
8499 + *****************************************************************************/
8500 +
8501 +/** Basic Stack Layout **/
8502 +
8503 +/*
8504 +Define this macro if pushing a word onto the stack moves the stack
8505 +pointer to a smaller address.
8506 +
8507 +When we say, ``define this macro if ...,'' it means that the
8508 +compiler checks this macro only with #ifdef so the precise
8509 +definition used does not matter.
8510 +*/
8511 +/* pushm decrece SP: *(--SP) <-- Rx */
8512 +#define STACK_GROWS_DOWNWARD
8513 +
8514 +/*
8515 +This macro defines the operation used when something is pushed
8516 +on the stack. In RTL, a push operation will be
8517 +(set (mem (STACK_PUSH_CODE (reg sp))) ...)
8518 +
8519 +The choices are PRE_DEC, POST_DEC, PRE_INC,
8520 +and POST_INC. Which of these is correct depends on
8521 +the stack direction and on whether the stack pointer points
8522 +to the last item on the stack or whether it points to the
8523 +space for the next item on the stack.
8524 +
8525 +The default is PRE_DEC when STACK_GROWS_DOWNWARD is
8526 +defined, which is almost always right, and PRE_INC otherwise,
8527 +which is often wrong.
8528 +*/
8529 +/* pushm: *(--SP) <-- Rx */
8530 +#define STACK_PUSH_CODE PRE_DEC
8531 +
8532 +/* Define this to nonzero if the nominal address of the stack frame
8533 + is at the high-address end of the local variables;
8534 + that is, each additional local variable allocated
8535 + goes at a more negative offset in the frame. */
8536 +#define FRAME_GROWS_DOWNWARD 1
8537 +
8538 +
8539 +/*
8540 +Offset from the frame pointer to the first local variable slot to be allocated.
8541 +
8542 +If FRAME_GROWS_DOWNWARD, find the next slot's offset by
8543 +subtracting the first slot's length from STARTING_FRAME_OFFSET.
8544 +Otherwise, it is found by adding the length of the first slot to the
8545 +value STARTING_FRAME_OFFSET.
8546 + (i'm not sure if the above is still correct.. had to change it to get
8547 + rid of an overfull. --mew 2feb93 )
8548 +*/
8549 +#define STARTING_FRAME_OFFSET 0
8550 +
8551 +/*
8552 +Offset from the stack pointer register to the first location at which
8553 +outgoing arguments are placed. If not specified, the default value of
8554 +zero is used. This is the proper value for most machines.
8555 +
8556 +If ARGS_GROW_DOWNWARD, this is the offset to the location above
8557 +the first location at which outgoing arguments are placed.
8558 +*/
8559 +#define STACK_POINTER_OFFSET 0
8560 +
8561 +/*
8562 +Offset from the argument pointer register to the first argument's
8563 +address. On some machines it may depend on the data type of the
8564 +function.
8565 +
8566 +If ARGS_GROW_DOWNWARD, this is the offset to the location above
8567 +the first argument's address.
8568 +*/
8569 +#define FIRST_PARM_OFFSET(FUNDECL) 0
8570 +
8571 +
8572 +/*
8573 +A C expression whose value is RTL representing the address in a stack
8574 +frame where the pointer to the caller's frame is stored. Assume that
8575 +FRAMEADDR is an RTL expression for the address of the stack frame
8576 +itself.
8577 +
8578 +If you don't define this macro, the default is to return the value
8579 +of FRAMEADDR - that is, the stack frame address is also the
8580 +address of the stack word that points to the previous frame.
8581 +*/
8582 +#define DYNAMIC_CHAIN_ADDRESS(FRAMEADDR) plus_constant ((FRAMEADDR), 4)
8583 +
8584 +
8585 +/*
8586 +A C expression whose value is RTL representing the value of the return
8587 +address for the frame COUNT steps up from the current frame, after
8588 +the prologue. FRAMEADDR is the frame pointer of the COUNT
8589 +frame, or the frame pointer of the COUNT - 1 frame if
8590 +RETURN_ADDR_IN_PREVIOUS_FRAME is defined.
8591 +
8592 +The value of the expression must always be the correct address when
8593 +COUNT is zero, but may be NULL_RTX if there is not way to
8594 +determine the return address of other frames.
8595 +*/
8596 +#define RETURN_ADDR_RTX(COUNT, FRAMEADDR) avr32_return_addr(COUNT, FRAMEADDR)
8597 +
8598 +
8599 +/*
8600 +A C expression whose value is RTL representing the location of the
8601 +incoming return address at the beginning of any function, before the
8602 +prologue. This RTL is either a REG, indicating that the return
8603 +value is saved in 'REG', or a MEM representing a location in
8604 +the stack.
8605 +
8606 +You only need to define this macro if you want to support call frame
8607 +debugging information like that provided by DWARF 2.
8608 +
8609 +If this RTL is a REG, you should also define
8610 +DWARF_FRAME_RETURN_COLUMN to DWARF_FRAME_REGNUM (REGNO).
8611 +*/
8612 +#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LR_REGNUM)
8613 +
8614 +
8615 +
8616 +/*
8617 +A C expression whose value is an integer giving the offset, in bytes,
8618 +from the value of the stack pointer register to the top of the stack
8619 +frame at the beginning of any function, before the prologue. The top of
8620 +the frame is defined to be the value of the stack pointer in the
8621 +previous frame, just before the call instruction.
8622 +
8623 +You only need to define this macro if you want to support call frame
8624 +debugging information like that provided by DWARF 2.
8625 +*/
8626 +#define INCOMING_FRAME_SP_OFFSET 0
8627 +
8628 +
8629 +/** Exception Handling Support **/
8630 +
8631 +/* Use setjump/longjump for exception handling. */
8632 +#define DWARF2_UNWIND_INFO 0
8633 +#define MUST_USE_SJLJ_EXCEPTIONS 1
8634 +
8635 +/*
8636 +A C expression whose value is the Nth register number used for
8637 +data by exception handlers, or INVALID_REGNUM if fewer than
8638 +N registers are usable.
8639 +
8640 +The exception handling library routines communicate with the exception
8641 +handlers via a set of agreed upon registers. Ideally these registers
8642 +should be call-clobbered; it is possible to use call-saved registers,
8643 +but may negatively impact code size. The target must support at least
8644 +2 data registers, but should define 4 if there are enough free registers.
8645 +
8646 +You must define this macro if you want to support call frame exception
8647 +handling like that provided by DWARF 2.
8648 +*/
8649 +/*
8650 + Use r9-r11
8651 +*/
8652 +#define EH_RETURN_DATA_REGNO(N) \
8653 + ((N<3) ? INTERNAL_REGNUM(N+9) : INVALID_REGNUM)
8654 +
8655 +/*
8656 +A C expression whose value is RTL representing a location in which
8657 +to store a stack adjustment to be applied before function return.
8658 +This is used to unwind the stack to an exception handler's call frame.
8659 +It will be assigned zero on code paths that return normally.
8660 +
8661 +Typically this is a call-clobbered hard register that is otherwise
8662 +untouched by the epilogue, but could also be a stack slot.
8663 +
8664 +You must define this macro if you want to support call frame exception
8665 +handling like that provided by DWARF 2.
8666 +*/
8667 +/*
8668 + Use r8
8669 +*/
8670 +#define EH_RETURN_STACKADJ_REGNO INTERNAL_REGNUM(8)
8671 +#define EH_RETURN_STACKADJ_RTX gen_rtx_REG(SImode, EH_RETURN_STACKADJ_REGNO)
8672 +
8673 +/*
8674 +A C expression whose value is RTL representing a location in which
8675 +to store the address of an exception handler to which we should
8676 +return. It will not be assigned on code paths that return normally.
8677 +
8678 +Typically this is the location in the call frame at which the normal
8679 +return address is stored. For targets that return by popping an
8680 +address off the stack, this might be a memory address just below
8681 +the target call frame rather than inside the current call
8682 +frame. EH_RETURN_STACKADJ_RTX will have already been assigned,
8683 +so it may be used to calculate the location of the target call frame.
8684 +
8685 +Some targets have more complex requirements than storing to an
8686 +address calculable during initial code generation. In that case
8687 +the eh_return instruction pattern should be used instead.
8688 +
8689 +If you want to support call frame exception handling, you must
8690 +define either this macro or the eh_return instruction pattern.
8691 +*/
8692 +/*
8693 + We define the eh_return instruction pattern, so this isn't needed.
8694 +*/
8695 +/* #define EH_RETURN_HANDLER_RTX gen_rtx_REG(Pmode, RET_REGISTER) */
8696 +
8697 +/*
8698 + This macro chooses the encoding of pointers embedded in the
8699 + exception handling sections. If at all possible, this should be
8700 + defined such that the exception handling section will not require
8701 + dynamic relocations, and so may be read-only.
8702 +
8703 + code is 0 for data, 1 for code labels, 2 for function
8704 + pointers. global is true if the symbol may be affected by dynamic
8705 + relocations. The macro should return a combination of the DW_EH_PE_*
8706 + defines as found in dwarf2.h.
8707 +
8708 + If this macro is not defined, pointers will not be encoded but
8709 + represented directly.
8710 +*/
8711 +#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
8712 + ((flag_pic && (GLOBAL) ? DW_EH_PE_indirect : 0) \
8713 + | (flag_pic ? DW_EH_PE_pcrel : DW_EH_PE_absptr) \
8714 + | DW_EH_PE_sdata4)
8715 +
8716 +/* ToDo: The rest of this subsection */
8717 +
8718 +/** Specifying How Stack Checking is Done **/
8719 +/* ToDo: All in this subsection */
8720 +
8721 +/** Registers That Address the Stack Frame **/
8722 +
8723 +/*
8724 +The register number of the stack pointer register, which must also be a
8725 +fixed register according to FIXED_REGISTERS. On most machines,
8726 +the hardware determines which register this is.
8727 +*/
8728 +/* Using r13 as stack pointer. */
8729 +#define STACK_POINTER_REGNUM INTERNAL_REGNUM(13)
8730 +
8731 +/*
8732 +The register number of the frame pointer register, which is used to
8733 +access automatic variables in the stack frame. On some machines, the
8734 +hardware determines which register this is. On other machines, you can
8735 +choose any register you wish for this purpose.
8736 +*/
8737 +/* Use r7 */
8738 +#define FRAME_POINTER_REGNUM INTERNAL_REGNUM(7)
8739 +
8740 +
8741 +
8742 +/*
8743 +The register number of the arg pointer register, which is used to access
8744 +the function's argument list. On some machines, this is the same as the
8745 +frame pointer register. On some machines, the hardware determines which
8746 +register this is. On other machines, you can choose any register you
8747 +wish for this purpose. If this is not the same register as the frame
8748 +pointer register, then you must mark it as a fixed register according to
8749 +FIXED_REGISTERS, or arrange to be able to eliminate it (see Section
8750 +10.10.5 [Elimination], page 224).
8751 +*/
8752 +/* Using r5 */
8753 +#define ARG_POINTER_REGNUM INTERNAL_REGNUM(4)
8754 +
8755 +
8756 +/*
8757 +Register numbers used for passing a function's static chain pointer. If
8758 +register windows are used, the register number as seen by the called
8759 +function is STATIC_CHAIN_INCOMING_REGNUM, while the register
8760 +number as seen by the calling function is STATIC_CHAIN_REGNUM. If
8761 +these registers are the same, STATIC_CHAIN_INCOMING_REGNUM need
8762 +not be defined.
8763 +
8764 +The static chain register need not be a fixed register.
8765 +
8766 +If the static chain is passed in memory, these macros should not be
8767 +defined; instead, the next two macros should be defined.
8768 +*/
8769 +/* Using r0 */
8770 +#define STATIC_CHAIN_REGNUM INTERNAL_REGNUM(0)
8771 +
8772 +
8773 +/** Eliminating Frame Pointer and Arg Pointer **/
8774 +
8775 +/*
8776 +A C expression which is nonzero if a function must have and use a frame
8777 +pointer. This expression is evaluated in the reload pass. If its value is
8778 +nonzero the function will have a frame pointer.
8779 +
8780 +The expression can in principle examine the current function and decide
8781 +according to the facts, but on most machines the constant 0 or the
8782 +constant 1 suffices. Use 0 when the machine allows code to be generated
8783 +with no frame pointer, and doing so saves some time or space. Use 1
8784 +when there is no possible advantage to avoiding a frame pointer.
8785 +
8786 +In certain cases, the compiler does not know how to produce valid code
8787 +without a frame pointer. The compiler recognizes those cases and
8788 +automatically gives the function a frame pointer regardless of what
8789 +FRAME_POINTER_REQUIRED says. You don't need to worry about
8790 +them.
8791 +
8792 +In a function that does not require a frame pointer, the frame pointer
8793 +register can be allocated for ordinary usage, unless you mark it as a
8794 +fixed register. See FIXED_REGISTERS for more information.
8795 +*/
8796 +/* We need the frame pointer when compiling for profiling */
8797 +#define FRAME_POINTER_REQUIRED (current_function_profile)
8798 +
8799 +/*
8800 +A C statement to store in the variable DEPTH_VAR the difference
8801 +between the frame pointer and the stack pointer values immediately after
8802 +the function prologue. The value would be computed from information
8803 +such as the result of get_frame_size () and the tables of
8804 +registers regs_ever_live and call_used_regs.
8805 +
8806 +If ELIMINABLE_REGS is defined, this macro will be not be used and
8807 +need not be defined. Otherwise, it must be defined even if
8808 +FRAME_POINTER_REQUIRED is defined to always be true; in that
8809 +case, you may set DEPTH_VAR to anything.
8810 +*/
8811 +#define INITIAL_FRAME_POINTER_OFFSET(DEPTH_VAR) ((DEPTH_VAR) = get_frame_size())
8812 +
8813 +/*
8814 +If defined, this macro specifies a table of register pairs used to
8815 +eliminate unneeded registers that point into the stack frame. If it is not
8816 +defined, the only elimination attempted by the compiler is to replace
8817 +references to the frame pointer with references to the stack pointer.
8818 +
8819 +The definition of this macro is a list of structure initializations, each
8820 +of which specifies an original and replacement register.
8821 +
8822 +On some machines, the position of the argument pointer is not known until
8823 +the compilation is completed. In such a case, a separate hard register
8824 +must be used for the argument pointer. This register can be eliminated by
8825 +replacing it with either the frame pointer or the argument pointer,
8826 +depending on whether or not the frame pointer has been eliminated.
8827 +
8828 +In this case, you might specify:
8829 + #define ELIMINABLE_REGS \
8830 + {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
8831 + {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
8832 + {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
8833 +
8834 +Note that the elimination of the argument pointer with the stack pointer is
8835 +specified first since that is the preferred elimination.
8836 +*/
8837 +#define ELIMINABLE_REGS \
8838 +{ \
8839 + { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
8840 + { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
8841 + { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM } \
8842 +}
8843 +
8844 +/*
8845 +A C expression that returns nonzero if the compiler is allowed to try
8846 +to replace register number FROM with register number
8847 +TO. This macro need only be defined if ELIMINABLE_REGS
8848 +is defined, and will usually be the constant 1, since most of the cases
8849 +preventing register elimination are things that the compiler already
8850 +knows about.
8851 +*/
8852 +#define CAN_ELIMINATE(FROM, TO) 1
8853 +
8854 +/*
8855 +This macro is similar to INITIAL_FRAME_POINTER_OFFSET. It
8856 +specifies the initial difference between the specified pair of
8857 +registers. This macro must be defined if ELIMINABLE_REGS is
8858 +defined.
8859 +*/
8860 +#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
8861 + ((OFFSET) = avr32_initial_elimination_offset(FROM, TO))
8862 +
8863 +/** Passing Function Arguments on the Stack **/
8864 +
8865 +
8866 +/*
8867 +A C expression. If nonzero, push insns will be used to pass
8868 +outgoing arguments.
8869 +If the target machine does not have a push instruction, set it to zero.
8870 +That directs GCC to use an alternate strategy: to
8871 +allocate the entire argument block and then store the arguments into
8872 +it. When PUSH_ARGS is nonzero, PUSH_ROUNDING must be defined too.
8873 +*/
8874 +#define PUSH_ARGS 1
8875 +
8876 +
8877 +/*
8878 +A C expression that is the number of bytes actually pushed onto the
8879 +stack when an instruction attempts to push NPUSHED bytes.
8880 +
8881 +On some machines, the definition
8882 +
8883 + #define PUSH_ROUNDING(BYTES) (BYTES)
8884 +
8885 +will suffice. But on other machines, instructions that appear
8886 +to push one byte actually push two bytes in an attempt to maintain
8887 +alignment. Then the definition should be
8888 +
8889 + #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
8890 +*/
8891 +/* Push 4 bytes at the time. */
8892 +#define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3)
8893 +
8894 +/*
8895 +A C expression. If nonzero, the maximum amount of space required for
8896 +outgoing arguments will be computed and placed into the variable
8897 +current_function_outgoing_args_size. No space will be pushed
8898 +onto the stack for each call; instead, the function prologue should
8899 +increase the stack frame size by this amount.
8900 +
8901 +Setting both PUSH_ARGS and ACCUMULATE_OUTGOING_ARGS is not proper.
8902 +*/
8903 +#define ACCUMULATE_OUTGOING_ARGS 0
8904 +
8905 +
8906 +
8907 +
8908 +/*
8909 +A C expression that should indicate the number of bytes of its own
8910 +arguments that a function pops on returning, or 0 if the
8911 +function pops no arguments and the caller must therefore pop them all
8912 +after the function returns.
8913 +
8914 +FUNDECL is a C variable whose value is a tree node that describes
8915 +the function in question. Normally it is a node of type
8916 +FUNCTION_DECL that describes the declaration of the function.
8917 +From this you can obtain the DECL_ATTRIBUTES of the function.
8918 +
8919 +FUNTYPE is a C variable whose value is a tree node that
8920 +describes the function in question. Normally it is a node of type
8921 +FUNCTION_TYPE that describes the data type of the function.
8922 +From this it is possible to obtain the data types of the value and
8923 +arguments (if known).
8924 +
8925 +When a call to a library function is being considered, FUNDECL
8926 +will contain an identifier node for the library function. Thus, if
8927 +you need to distinguish among various library functions, you can do so
8928 +by their names. Note that ``library function'' in this context means
8929 +a function used to perform arithmetic, whose name is known specially
8930 +in the compiler and was not mentioned in the C code being compiled.
8931 +
8932 +STACK_SIZE is the number of bytes of arguments passed on the
8933 +stack. If a variable number of bytes is passed, it is zero, and
8934 +argument popping will always be the responsibility of the calling function.
8935 +
8936 +On the VAX, all functions always pop their arguments, so the definition
8937 +of this macro is STACK_SIZE. On the 68000, using the standard
8938 +calling convention, no functions pop their arguments, so the value of
8939 +the macro is always 0 in this case. But an alternative calling
8940 +convention is available in which functions that take a fixed number of
8941 +arguments pop them but other functions (such as printf) pop
8942 +nothing (the caller pops all). When this convention is in use,
8943 +FUNTYPE is examined to determine whether a function takes a fixed
8944 +number of arguments.
8945 +*/
8946 +#define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACK_SIZE) 0
8947 +
8948 +
8949 +/*Return true if this function can we use a single return instruction*/
8950 +#define USE_RETURN_INSN(ISCOND) avr32_use_return_insn(ISCOND)
8951 +
8952 +/*
8953 +A C expression that should indicate the number of bytes a call sequence
8954 +pops off the stack. It is added to the value of RETURN_POPS_ARGS
8955 +when compiling a function call.
8956 +
8957 +CUM is the variable in which all arguments to the called function
8958 +have been accumulated.
8959 +
8960 +On certain architectures, such as the SH5, a call trampoline is used
8961 +that pops certain registers off the stack, depending on the arguments
8962 +that have been passed to the function. Since this is a property of the
8963 +call site, not of the called function, RETURN_POPS_ARGS is not
8964 +appropriate.
8965 +*/
8966 +#define CALL_POPS_ARGS(CUM) 0
8967 +
8968 +/* Passing Arguments in Registers */
8969 +
8970 +/*
8971 +A C expression that controls whether a function argument is passed
8972 +in a register, and which register.
8973 +
8974 +The arguments are CUM, which summarizes all the previous
8975 +arguments; MODE, the machine mode of the argument; TYPE,
8976 +the data type of the argument as a tree node or 0 if that is not known
8977 +(which happens for C support library functions); and NAMED,
8978 +which is 1 for an ordinary argument and 0 for nameless arguments that
8979 +correspond to '...' in the called function's prototype.
8980 +TYPE can be an incomplete type if a syntax error has previously
8981 +occurred.
8982 +
8983 +The value of the expression is usually either a reg RTX for the
8984 +hard register in which to pass the argument, or zero to pass the
8985 +argument on the stack.
8986 +
8987 +For machines like the VAX and 68000, where normally all arguments are
8988 +pushed, zero suffices as a definition.
8989 +
8990 +The value of the expression can also be a parallel RTX. This is
8991 +used when an argument is passed in multiple locations. The mode of the
8992 +of the parallel should be the mode of the entire argument. The
8993 +parallel holds any number of expr_list pairs; each one
8994 +describes where part of the argument is passed. In each
8995 +expr_list the first operand must be a reg RTX for the hard
8996 +register in which to pass this part of the argument, and the mode of the
8997 +register RTX indicates how large this part of the argument is. The
8998 +second operand of the expr_list is a const_int which gives
8999 +the offset in bytes into the entire argument of where this part starts.
9000 +As a special exception the first expr_list in the parallel
9001 +RTX may have a first operand of zero. This indicates that the entire
9002 +argument is also stored on the stack.
9003 +
9004 +The last time this macro is called, it is called with MODE == VOIDmode,
9005 +and its result is passed to the call or call_value
9006 +pattern as operands 2 and 3 respectively.
9007 +
9008 +The usual way to make the ISO library 'stdarg.h' work on a machine
9009 +where some arguments are usually passed in registers, is to cause
9010 +nameless arguments to be passed on the stack instead. This is done
9011 +by making FUNCTION_ARG return 0 whenever NAMED is 0.
9012 +
9013 +You may use the macro MUST_PASS_IN_STACK (MODE, TYPE)
9014 +in the definition of this macro to determine if this argument is of a
9015 +type that must be passed in the stack. If REG_PARM_STACK_SPACE
9016 +is not defined and FUNCTION_ARG returns nonzero for such an
9017 +argument, the compiler will abort. If REG_PARM_STACK_SPACE is
9018 +defined, the argument will be computed in the stack and then loaded into
9019 +a register. */
9020 +
9021 +#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
9022 + avr32_function_arg(&(CUM), MODE, TYPE, NAMED)
9023 +
9024 +
9025 +
9026 +
9027 +/*
9028 +A C type for declaring a variable that is used as the first argument of
9029 +FUNCTION_ARG and other related values. For some target machines,
9030 +the type int suffices and can hold the number of bytes of
9031 +argument so far.
9032 +
9033 +There is no need to record in CUMULATIVE_ARGS anything about the
9034 +arguments that have been passed on the stack. The compiler has other
9035 +variables to keep track of that. For target machines on which all
9036 +arguments are passed on the stack, there is no need to store anything in
9037 +CUMULATIVE_ARGS; however, the data structure must exist and
9038 +should not be empty, so use int.
9039 +*/
9040 +typedef struct avr32_args
9041 +{
9042 + /* Index representing the argument register the current function argument
9043 + will occupy */
9044 + int index;
9045 + /* A mask with bits representing the argument registers: if a bit is set
9046 + then this register is used for an arguemnt */
9047 + int used_index;
9048 + /* TRUE if this function has anonymous arguments */
9049 + int uses_anonymous_args;
9050 + /* The size in bytes of the named arguments pushed on the stack */
9051 + int stack_pushed_args_size;
9052 + /* Set to true if this function needs a Return Value Pointer */
9053 + int use_rvp;
9054 +
9055 +} CUMULATIVE_ARGS;
9056 +
9057 +
9058 +#define FIRST_CUM_REG_INDEX 0
9059 +#define LAST_CUM_REG_INDEX 4
9060 +#define GET_REG_INDEX(CUM) ((CUM)->index)
9061 +#define SET_REG_INDEX(CUM, INDEX) ((CUM)->index = (INDEX));
9062 +#define GET_USED_INDEX(CUM, INDEX) ((CUM)->used_index & (1 << (INDEX)))
9063 +#define SET_USED_INDEX(CUM, INDEX) \
9064 + do \
9065 + { \
9066 + if (INDEX >= 0) \
9067 + (CUM)->used_index |= (1 << (INDEX)); \
9068 + } \
9069 + while (0)
9070 +#define SET_INDEXES_UNUSED(CUM) ((CUM)->used_index = 0)
9071 +
9072 +
9073 +/*
9074 + A C statement (sans semicolon) for initializing the variable cum for the
9075 + state at the beginning of the argument list. The variable has type
9076 + CUMULATIVE_ARGS. The value of FNTYPE is the tree node for the data type of
9077 + the function which will receive the args, or 0 if the args are to a compiler
9078 + support library function. For direct calls that are not libcalls, FNDECL
9079 + contain the declaration node of the function. FNDECL is also set when
9080 + INIT_CUMULATIVE_ARGS is used to find arguments for the function being
9081 + compiled. N_NAMED_ARGS is set to the number of named arguments, including a
9082 + structure return address if it is passed as a parameter, when making a call.
9083 + When processing incoming arguments, N_NAMED_ARGS is set to -1.
9084 +
9085 + When processing a call to a compiler support library function, LIBNAME
9086 + identifies which one. It is a symbol_ref rtx which contains the name of the
9087 + function, as a string. LIBNAME is 0 when an ordinary C function call is
9088 + being processed. Thus, each time this macro is called, either LIBNAME or
9089 + FNTYPE is nonzero, but never both of them at once.
9090 +*/
9091 +#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
9092 + avr32_init_cumulative_args(&(CUM), FNTYPE, LIBNAME, FNDECL)
9093 +
9094 +
9095 +/*
9096 +A C statement (sans semicolon) to update the summarizer variable
9097 +CUM to advance past an argument in the argument list. The
9098 +values MODE, TYPE and NAMED describe that argument.
9099 +Once this is done, the variable CUM is suitable for analyzing
9100 +the following argument with FUNCTION_ARG, etc.
9101 +
9102 +This macro need not do anything if the argument in question was passed
9103 +on the stack. The compiler knows how to track the amount of stack space
9104 +used for arguments without any special help.
9105 +*/
9106 +#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
9107 + avr32_function_arg_advance(&(CUM), MODE, TYPE, NAMED)
9108 +
9109 +/*
9110 +If defined, a C expression which determines whether, and in which direction,
9111 +to pad out an argument with extra space. The value should be of type
9112 +enum direction: either 'upward' to pad above the argument,
9113 +'downward' to pad below, or 'none' to inhibit padding.
9114 +
9115 +The amount of padding is always just enough to reach the next
9116 +multiple of FUNCTION_ARG_BOUNDARY; this macro does not control
9117 +it.
9118 +
9119 +This macro has a default definition which is right for most systems.
9120 +For little-endian machines, the default is to pad upward. For
9121 +big-endian machines, the default is to pad downward for an argument of
9122 +constant size shorter than an int, and upward otherwise.
9123 +*/
9124 +#define FUNCTION_ARG_PADDING(MODE, TYPE) \
9125 + avr32_function_arg_padding(MODE, TYPE)
9126 +
9127 +/*
9128 + Specify padding for the last element of a block move between registers
9129 + and memory. First is nonzero if this is the only element. Defining
9130 + this macro allows better control of register function parameters on
9131 + big-endian machines, without using PARALLEL rtl. In particular,
9132 + MUST_PASS_IN_STACK need not test padding and mode of types in registers,
9133 + as there is no longer a "wrong" part of a register; For example, a three
9134 + byte aggregate may be passed in the high part of a register if so required.
9135 +*/
9136 +#define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
9137 + avr32_function_arg_padding(MODE, TYPE)
9138 +
9139 +/*
9140 +If defined, a C expression which determines whether the default
9141 +implementation of va_arg will attempt to pad down before reading the
9142 +next argument, if that argument is smaller than its aligned space as
9143 +controlled by PARM_BOUNDARY. If this macro is not defined, all such
9144 +arguments are padded down if BYTES_BIG_ENDIAN is true.
9145 +*/
9146 +#define PAD_VARARGS_DOWN \
9147 + (FUNCTION_ARG_PADDING (TYPE_MODE (type), type) == downward)
9148 +
9149 +
9150 +/*
9151 +A C expression that is nonzero if REGNO is the number of a hard
9152 +register in which function arguments are sometimes passed. This does
9153 +not include implicit arguments such as the static chain and
9154 +the structure-value address. On many machines, no registers can be
9155 +used for this purpose since all function arguments are pushed on the
9156 +stack.
9157 +*/
9158 +/*
9159 + Use r8 - r12 for function arguments.
9160 +*/
9161 +#define FUNCTION_ARG_REGNO_P(REGNO) \
9162 + (REGNO >= 3 && REGNO <= 7)
9163 +
9164 +/* Number of registers used for passing function arguments */
9165 +#define NUM_ARG_REGS 5
9166 +
9167 +/*
9168 +If defined, the order in which arguments are loaded into their
9169 +respective argument registers is reversed so that the last
9170 +argument is loaded first. This macro only affects arguments
9171 +passed in registers.
9172 +*/
9173 +/* #define LOAD_ARGS_REVERSED */
9174 +
9175 +/** How Scalar Function Values Are Returned **/
9176 +
9177 +/* AVR32 is using r12 as return register. */
9178 +#define RET_REGISTER (15 - 12)
9179 +
9180 +
9181 +/*
9182 +A C expression to create an RTX representing the place where a library
9183 +function returns a value of mode MODE. If the precise function
9184 +being called is known, FUNC is a tree node
9185 +(FUNCTION_DECL) for it; otherwise, func is a null
9186 +pointer. This makes it possible to use a different value-returning
9187 +convention for specific functions when all their calls are
9188 +known.
9189 +
9190 +Note that "library function" in this context means a compiler
9191 +support routine, used to perform arithmetic, whose name is known
9192 +specially by the compiler and was not mentioned in the C code being
9193 +compiled.
9194 +
9195 +The definition of LIBRARY_VALUE need not be concerned aggregate
9196 +data types, because none of the library functions returns such types.
9197 +*/
9198 +#define LIBCALL_VALUE(MODE) avr32_libcall_value(MODE)
9199 +
9200 +/*
9201 +A C expression that is nonzero if REGNO is the number of a hard
9202 +register in which the values of called function may come back.
9203 +
9204 +A register whose use for returning values is limited to serving as the
9205 +second of a pair (for a value of type double, say) need not be
9206 +recognized by this macro. So for most machines, this definition
9207 +suffices:
9208 + #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
9209 +
9210 +If the machine has register windows, so that the caller and the called
9211 +function use different registers for the return value, this macro
9212 +should recognize only the caller's register numbers.
9213 +*/
9214 +/*
9215 + When returning a value of mode DImode, r11:r10 is used, else r12 is used.
9216 +*/
9217 +#define FUNCTION_VALUE_REGNO_P(REGNO) ((REGNO) == RET_REGISTER \
9218 + || (REGNO) == INTERNAL_REGNUM(11))
9219 +
9220 +
9221 +/** How Large Values Are Returned **/
9222 +
9223 +
9224 +/*
9225 +Define this macro to be 1 if all structure and union return values must be
9226 +in memory. Since this results in slower code, this should be defined
9227 +only if needed for compatibility with other compilers or with an ABI.
9228 +If you define this macro to be 0, then the conventions used for structure
9229 +and union return values are decided by the RETURN_IN_MEMORY macro.
9230 +
9231 +If not defined, this defaults to the value 1.
9232 +*/
9233 +#define DEFAULT_PCC_STRUCT_RETURN 0
9234 +
9235 +
9236 +
9237 +
9238 +/** Generating Code for Profiling **/
9239 +
9240 +/*
9241 +A C statement or compound statement to output to FILE some
9242 +assembler code to call the profiling subroutine mcount.
9243 +
9244 +The details of how mcount expects to be called are determined by
9245 +your operating system environment, not by GCC. To figure them out,
9246 +compile a small program for profiling using the system's installed C
9247 +compiler and look at the assembler code that results.
9248 +
9249 +Older implementations of mcount expect the address of a counter
9250 +variable to be loaded into some register. The name of this variable is
9251 +'LP' followed by the number LABELNO, so you would generate
9252 +the name using 'LP%d' in a fprintf.
9253 +*/
9254 +/* ToDo: fixme */
9255 +#ifndef FUNCTION_PROFILER
9256 +#define FUNCTION_PROFILER(FILE, LABELNO) \
9257 + fprintf((FILE), "/* profiler %d */", (LABELNO))
9258 +#endif
9259 +
9260 +
9261 +/*****************************************************************************
9262 + * Trampolines for Nested Functions *
9263 + *****************************************************************************/
9264 +
9265 +/*
9266 +A C statement to output, on the stream FILE, assembler code for a
9267 +block of data that contains the constant parts of a trampoline. This
9268 +code should not include a label - the label is taken care of
9269 +automatically.
9270 +
9271 +If you do not define this macro, it means no template is needed
9272 +for the target. Do not define this macro on systems where the block move
9273 +code to copy the trampoline into place would be larger than the code
9274 +to generate it on the spot.
9275 +*/
9276 +/* ToDo: correct? */
9277 +#define TRAMPOLINE_TEMPLATE(FILE) avr32_trampoline_template(FILE);
9278 +
9279 +
9280 +/*
9281 +A C expression for the size in bytes of the trampoline, as an integer.
9282 +*/
9283 +/* ToDo: fixme */
9284 +#define TRAMPOLINE_SIZE 0x0C
9285 +
9286 +/*
9287 +Alignment required for trampolines, in bits.
9288 +
9289 +If you don't define this macro, the value of BIGGEST_ALIGNMENT
9290 +is used for aligning trampolines.
9291 +*/
9292 +#define TRAMPOLINE_ALIGNMENT 16
9293 +
9294 +/*
9295 +A C statement to initialize the variable parts of a trampoline.
9296 +ADDR is an RTX for the address of the trampoline; FNADDR is
9297 +an RTX for the address of the nested function; STATIC_CHAIN is an
9298 +RTX for the static chain value that should be passed to the function
9299 +when it is called.
9300 +*/
9301 +#define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, STATIC_CHAIN) \
9302 + avr32_initialize_trampoline(ADDR, FNADDR, STATIC_CHAIN)
9303 +
9304 +
9305 +/******************************************************************************
9306 + * Implicit Calls to Library Routines
9307 + *****************************************************************************/
9308 +
9309 +/* Tail calling. */
9310 +
9311 +/* A C expression that evaluates to true if it is ok to perform a sibling
9312 + call to DECL. */
9313 +#define FUNCTION_OK_FOR_SIBCALL(DECL) 0
9314 +
9315 +#define OVERRIDE_OPTIONS avr32_override_options ()
9316 +
9317 +#define OPTIMIZATION_OPTIONS(LEVEL, SIZE) avr32_optimization_options (LEVEL, SIZE)
9318 +
9319 +
9320 +/******************************************************************************
9321 + * Addressing Modes
9322 + *****************************************************************************/
9323 +
9324 +/*
9325 +A C expression that is nonzero if the machine supports pre-increment,
9326 +pre-decrement, post-increment, or post-decrement addressing respectively.
9327 +*/
9328 +/*
9329 + AVR32 supports Rp++ and --Rp
9330 +*/
9331 +#define HAVE_PRE_INCREMENT 0
9332 +#define HAVE_PRE_DECREMENT 1
9333 +#define HAVE_POST_INCREMENT 1
9334 +#define HAVE_POST_DECREMENT 0
9335 +
9336 +/*
9337 +A C expression that is nonzero if the machine supports pre- or
9338 +post-address side-effect generation involving constants other than
9339 +the size of the memory operand.
9340 +*/
9341 +#define HAVE_PRE_MODIFY_DISP 0
9342 +#define HAVE_POST_MODIFY_DISP 0
9343 +
9344 +/*
9345 +A C expression that is nonzero if the machine supports pre- or
9346 +post-address side-effect generation involving a register displacement.
9347 +*/
9348 +#define HAVE_PRE_MODIFY_REG 0
9349 +#define HAVE_POST_MODIFY_REG 0
9350 +
9351 +/*
9352 +A C expression that is 1 if the RTX X is a constant which
9353 +is a valid address. On most machines, this can be defined as
9354 +CONSTANT_P (X), but a few machines are more restrictive
9355 +in which constant addresses are supported.
9356 +
9357 +CONSTANT_P accepts integer-values expressions whose values are
9358 +not explicitly known, such as symbol_ref, label_ref, and
9359 +high expressions and const arithmetic expressions, in
9360 +addition to const_int and const_double expressions.
9361 +*/
9362 +#define CONSTANT_ADDRESS_P(X) CONSTANT_P(X)
9363 +
9364 +/*
9365 +A number, the maximum number of registers that can appear in a valid
9366 +memory address. Note that it is up to you to specify a value equal to
9367 +the maximum number that GO_IF_LEGITIMATE_ADDRESS would ever
9368 +accept.
9369 +*/
9370 +#define MAX_REGS_PER_ADDRESS 2
9371 +
9372 +/*
9373 +A C compound statement with a conditional goto LABEL;
9374 +executed if X (an RTX) is a legitimate memory address on the
9375 +target machine for a memory operand of mode MODE.
9376 +
9377 +It usually pays to define several simpler macros to serve as
9378 +subroutines for this one. Otherwise it may be too complicated to
9379 +understand.
9380 +
9381 +This macro must exist in two variants: a strict variant and a
9382 +non-strict one. The strict variant is used in the reload pass. It
9383 +must be defined so that any pseudo-register that has not been
9384 +allocated a hard register is considered a memory reference. In
9385 +contexts where some kind of register is required, a pseudo-register
9386 +with no hard register must be rejected.
9387 +
9388 +The non-strict variant is used in other passes. It must be defined to
9389 +accept all pseudo-registers in every context where some kind of
9390 +register is required.
9391 +
9392 +Compiler source files that want to use the strict variant of this
9393 +macro define the macro REG_OK_STRICT. You should use an
9394 +#ifdef REG_OK_STRICT conditional to define the strict variant
9395 +in that case and the non-strict variant otherwise.
9396 +
9397 +Subroutines to check for acceptable registers for various purposes (one
9398 +for base registers, one for index registers, and so on) are typically
9399 +among the subroutines used to define GO_IF_LEGITIMATE_ADDRESS.
9400 +Then only these subroutine macros need have two variants; the higher
9401 +levels of macros may be the same whether strict or not.
9402 +
9403 +Normally, constant addresses which are the sum of a symbol_ref
9404 +and an integer are stored inside a const RTX to mark them as
9405 +constant. Therefore, there is no need to recognize such sums
9406 +specifically as legitimate addresses. Normally you would simply
9407 +recognize any const as legitimate.
9408 +
9409 +Usually PRINT_OPERAND_ADDRESS is not prepared to handle constant
9410 +sums that are not marked with const. It assumes that a naked
9411 +plus indicates indexing. If so, then you must reject such
9412 +naked constant sums as illegitimate addresses, so that none of them will
9413 +be given to PRINT_OPERAND_ADDRESS.
9414 +
9415 +On some machines, whether a symbolic address is legitimate depends on
9416 +the section that the address refers to. On these machines, define the
9417 +macro ENCODE_SECTION_INFO to store the information into the
9418 +symbol_ref, and then check for it here. When you see a
9419 +const, you will have to look inside it to find the
9420 +symbol_ref in order to determine the section.
9421 +
9422 +The best way to modify the name string is by adding text to the
9423 +beginning, with suitable punctuation to prevent any ambiguity. Allocate
9424 +the new name in saveable_obstack. You will have to modify
9425 +ASM_OUTPUT_LABELREF to remove and decode the added text and
9426 +output the name accordingly, and define STRIP_NAME_ENCODING to
9427 +access the original name string.
9428 +
9429 +You can check the information stored here into the symbol_ref in
9430 +the definitions of the macros GO_IF_LEGITIMATE_ADDRESS and
9431 +PRINT_OPERAND_ADDRESS.
9432 +*/
9433 +#ifdef REG_OK_STRICT
9434 +# define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
9435 + do \
9436 + { \
9437 + if (avr32_legitimate_address(MODE, X, 1)) \
9438 + goto LABEL; \
9439 + } \
9440 + while (0)
9441 +#else
9442 +# define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
9443 + do \
9444 + { \
9445 + if (avr32_legitimate_address(MODE, X, 0)) \
9446 + goto LABEL; \
9447 + } \
9448 + while (0)
9449 +#endif
9450 +
9451 +
9452 +
9453 +/*
9454 +A C compound statement that attempts to replace X with a valid
9455 +memory address for an operand of mode MODE. win will be a
9456 +C statement label elsewhere in the code; the macro definition may use
9457 +
9458 + GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN);
9459 +
9460 +to avoid further processing if the address has become legitimate.
9461 +
9462 +X will always be the result of a call to break_out_memory_refs,
9463 +and OLDX will be the operand that was given to that function to produce
9464 +X.
9465 +
9466 +The code generated by this macro should not alter the substructure of
9467 +X. If it transforms X into a more legitimate form, it
9468 +should assign X (which will always be a C variable) a new value.
9469 +
9470 +It is not necessary for this macro to come up with a legitimate
9471 +address. The compiler has standard ways of doing so in all cases. In
9472 +fact, it is safe for this macro to do nothing. But often a
9473 +machine-dependent strategy can generate better code.
9474 +*/
9475 +#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
9476 + do \
9477 + { \
9478 + if (GET_CODE(X) == PLUS \
9479 + && GET_CODE(XEXP(X, 0)) == REG \
9480 + && GET_CODE(XEXP(X, 1)) == CONST_INT \
9481 + && !CONST_OK_FOR_CONSTRAINT_P(INTVAL(XEXP(X, 1)), \
9482 + 'K', "Ks16")) \
9483 + { \
9484 + rtx index = force_reg(SImode, XEXP(X, 1)); \
9485 + X = gen_rtx_PLUS( SImode, XEXP(X, 0), index); \
9486 + } \
9487 + GO_IF_LEGITIMATE_ADDRESS(MODE, X, WIN); \
9488 + } \
9489 + while(0)
9490 +
9491 +
9492 +/*
9493 +A C statement or compound statement with a conditional
9494 +goto LABEL; executed if memory address X (an RTX) can have
9495 +different meanings depending on the machine mode of the memory
9496 +reference it is used for or if the address is valid for some modes
9497 +but not others.
9498 +
9499 +Autoincrement and autodecrement addresses typically have mode-dependent
9500 +effects because the amount of the increment or decrement is the size
9501 +of the operand being addressed. Some machines have other mode-dependent
9502 +addresses. Many RISC machines have no mode-dependent addresses.
9503 +
9504 +You may assume that ADDR is a valid address for the machine.
9505 +*/
9506 +#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \
9507 + do \
9508 + { \
9509 + if (GET_CODE (ADDR) == POST_INC \
9510 + || GET_CODE (ADDR) == PRE_DEC) \
9511 + goto LABEL; \
9512 + } \
9513 + while (0)
9514 +
9515 +/*
9516 +A C expression that is nonzero if X is a legitimate constant for
9517 +an immediate operand on the target machine. You can assume that
9518 +X satisfies CONSTANT_P, so you need not check this. In fact,
9519 +'1' is a suitable definition for this macro on machines where
9520 +anything CONSTANT_P is valid.
9521 +*/
9522 +#define LEGITIMATE_CONSTANT_P(X) avr32_legitimate_constant_p(X)
9523 +
9524 +
9525 +/******************************************************************************
9526 + * Condition Code Status
9527 + *****************************************************************************/
9528 +
9529 +#define HAVE_conditional_move 1
9530 +
9531 +/*
9532 +C code for a data type which is used for declaring the mdep
9533 +component of cc_status. It defaults to int.
9534 +
9535 +This macro is not used on machines that do not use cc0.
9536 +*/
9537 +
9538 +typedef struct
9539 +{
9540 + int flags;
9541 + rtx value;
9542 + int fpflags;
9543 + rtx fpvalue;
9544 +} avr32_status_reg;
9545 +
9546 +
9547 +#define CC_STATUS_MDEP avr32_status_reg
9548 +
9549 +/*
9550 +A C expression to initialize the mdep field to "empty".
9551 +The default definition does nothing, since most machines don't use
9552 +the field anyway. If you want to use the field, you should probably
9553 +define this macro to initialize it.
9554 +
9555 +This macro is not used on machines that do not use cc0.
9556 +*/
9557 +
9558 +#define CC_STATUS_MDEP_INIT \
9559 + (cc_status.mdep.flags = CC_NONE , cc_status.mdep.value = 0)
9560 +
9561 +#define FPCC_STATUS_INIT \
9562 + (cc_status.mdep.fpflags = CC_NONE , cc_status.mdep.fpvalue = 0)
9563 +
9564 +/*
9565 +A C compound statement to set the components of cc_status
9566 +appropriately for an insn INSN whose body is EXP. It is
9567 +this macro's responsibility to recognize insns that set the condition
9568 +code as a byproduct of other activity as well as those that explicitly
9569 +set (cc0).
9570 +
9571 +This macro is not used on machines that do not use cc0.
9572 +
9573 +If there are insns that do not set the condition code but do alter
9574 +other machine registers, this macro must check to see whether they
9575 +invalidate the expressions that the condition code is recorded as
9576 +reflecting. For example, on the 68000, insns that store in address
9577 +registers do not set the condition code, which means that usually
9578 +NOTICE_UPDATE_CC can leave cc_status unaltered for such
9579 +insns. But suppose that the previous insn set the condition code
9580 +based on location 'a4@@(102)' and the current insn stores a new
9581 +value in 'a4'. Although the condition code is not changed by
9582 +this, it will no longer be true that it reflects the contents of
9583 +'a4@@(102)'. Therefore, NOTICE_UPDATE_CC must alter
9584 +cc_status in this case to say that nothing is known about the
9585 +condition code value.
9586 +
9587 +The definition of NOTICE_UPDATE_CC must be prepared to deal
9588 +with the results of peephole optimization: insns whose patterns are
9589 +parallel RTXs containing various reg, mem or
9590 +constants which are just the operands. The RTL structure of these
9591 +insns is not sufficient to indicate what the insns actually do. What
9592 +NOTICE_UPDATE_CC should do when it sees one is just to run
9593 +CC_STATUS_INIT.
9594 +
9595 +A possible definition of NOTICE_UPDATE_CC is to call a function
9596 +that looks at an attribute (see Insn Attributes) named, for example,
9597 +'cc'. This avoids having detailed information about patterns in
9598 +two places, the 'md' file and in NOTICE_UPDATE_CC.
9599 +*/
9600 +
9601 +#define NOTICE_UPDATE_CC(EXP, INSN) avr32_notice_update_cc(EXP, INSN)
9602 +
9603 +
9604 +
9605 +
9606 +/******************************************************************************
9607 + * Describing Relative Costs of Operations
9608 + *****************************************************************************/
9609 +
9610 +
9611 +
9612 +/*
9613 +A C expression for the cost of moving data of mode MODE from a
9614 +register in class FROM to one in class TO. The classes are
9615 +expressed using the enumeration values such as GENERAL_REGS. A
9616 +value of 2 is the default; other values are interpreted relative to
9617 +that.
9618 +
9619 +It is not required that the cost always equal 2 when FROM is the
9620 +same as TO; on some machines it is expensive to move between
9621 +registers if they are not general registers.
9622 +
9623 +If reload sees an insn consisting of a single set between two
9624 +hard registers, and if REGISTER_MOVE_COST applied to their
9625 +classes returns a value of 2, reload does not check to ensure that the
9626 +constraints of the insn are met. Setting a cost of other than 2 will
9627 +allow reload to verify that the constraints are met. You should do this
9628 +if the movm pattern's constraints do not allow such copying.
9629 +*/
9630 +#define REGISTER_MOVE_COST(MODE, FROM, TO) \
9631 + ((GET_MODE_SIZE(MODE) <= 4) ? 2: \
9632 + (GET_MODE_SIZE(MODE) <= 8) ? 3: \
9633 + 4)
9634 +
9635 +/*
9636 +A C expression for the cost of moving data of mode MODE between a
9637 +register of class CLASS and memory; IN is zero if the value
9638 +is to be written to memory, nonzero if it is to be read in. This cost
9639 +is relative to those in REGISTER_MOVE_COST. If moving between
9640 +registers and memory is more expensive than between two registers, you
9641 +should define this macro to express the relative cost.
9642 +
9643 +If you do not define this macro, GCC uses a default cost of 4 plus
9644 +the cost of copying via a secondary reload register, if one is
9645 +needed. If your machine requires a secondary reload register to copy
9646 +between memory and a register of CLASS but the reload mechanism is
9647 +more complex than copying via an intermediate, define this macro to
9648 +reflect the actual cost of the move.
9649 +
9650 +GCC defines the function memory_move_secondary_cost if
9651 +secondary reloads are needed. It computes the costs due to copying via
9652 +a secondary register. If your machine copies from memory using a
9653 +secondary register in the conventional way but the default base value of
9654 +4 is not correct for your machine, define this macro to add some other
9655 +value to the result of that function. The arguments to that function
9656 +are the same as to this macro.
9657 +*/
9658 +/*
9659 + Memory moves are costly
9660 +*/
9661 +#define MEMORY_MOVE_COST(MODE, CLASS, IN) \
9662 + (((IN) ? ((GET_MODE_SIZE(MODE) < 4) ? 4 : \
9663 + (GET_MODE_SIZE(MODE) > 8) ? 6 : \
9664 + 3) \
9665 + : ((GET_MODE_SIZE(MODE) > 8) ? 6 : 3)))
9666 +
9667 +/*
9668 +A C expression for the cost of a branch instruction. A value of 1 is
9669 +the default; other values are interpreted relative to that.
9670 +*/
9671 + /* Try to use conditionals as much as possible */
9672 +#define BRANCH_COST (TARGET_BRANCH_PRED ? 3 : 4)
9673 +
9674 +/*A C expression for the maximum number of instructions to execute via conditional
9675 + execution instructions instead of a branch. A value of BRANCH_COST+1 is the default
9676 + if the machine does not use cc0, and 1 if it does use cc0.*/
9677 +#define MAX_CONDITIONAL_EXECUTE 4
9678 +
9679 +/*
9680 +Define this macro as a C expression which is nonzero if accessing less
9681 +than a word of memory (i.e.: a char or a short) is no
9682 +faster than accessing a word of memory, i.e., if such access
9683 +require more than one instruction or if there is no difference in cost
9684 +between byte and (aligned) word loads.
9685 +
9686 +When this macro is not defined, the compiler will access a field by
9687 +finding the smallest containing object; when it is defined, a fullword
9688 +load will be used if alignment permits. Unless bytes accesses are
9689 +faster than word accesses, using word accesses is preferable since it
9690 +may eliminate subsequent memory access if subsequent accesses occur to
9691 +other fields in the same word of the structure, but to different bytes.
9692 +*/
9693 +#define SLOW_BYTE_ACCESS 1
9694 +
9695 +
9696 +/*
9697 +Define this macro if it is as good or better to call a constant
9698 +function address than to call an address kept in a register.
9699 +*/
9700 +#define NO_FUNCTION_CSE
9701 +
9702 +
9703 +/******************************************************************************
9704 + * Adjusting the Instruction Scheduler
9705 + *****************************************************************************/
9706 +
9707 +/*****************************************************************************
9708 + * Dividing the Output into Sections (Texts, Data, ...) *
9709 + *****************************************************************************/
9710 +
9711 +/*
9712 +A C expression whose value is a string, including spacing, containing the
9713 +assembler operation that should precede instructions and read-only data.
9714 +Normally "\t.text" is right.
9715 +*/
9716 +#define TEXT_SECTION_ASM_OP "\t.text"
9717 +/*
9718 +A C statement that switches to the default section containing instructions.
9719 +Normally this is not needed, as simply defining TEXT_SECTION_ASM_OP
9720 +is enough. The MIPS port uses this to sort all functions after all data
9721 +declarations.
9722 +*/
9723 +/* #define TEXT_SECTION */
9724 +
9725 +/*
9726 +A C expression whose value is a string, including spacing, containing the
9727 +assembler operation to identify the following data as writable initialized
9728 +data. Normally "\t.data" is right.
9729 +*/
9730 +#define DATA_SECTION_ASM_OP "\t.data"
9731 +
9732 +/*
9733 +If defined, a C expression whose value is a string, including spacing,
9734 +containing the assembler operation to identify the following data as
9735 +shared data. If not defined, DATA_SECTION_ASM_OP will be used.
9736 +*/
9737 +
9738 +/*
9739 +A C expression whose value is a string, including spacing, containing
9740 +the assembler operation to identify the following data as read-only
9741 +initialized data.
9742 +*/
9743 +#undef READONLY_DATA_SECTION_ASM_OP
9744 +#define READONLY_DATA_SECTION_ASM_OP \
9745 + ((TARGET_USE_RODATA_SECTION) ? \
9746 + "\t.section\t.rodata" : \
9747 + TEXT_SECTION_ASM_OP )
9748 +
9749 +
9750 +/*
9751 +If defined, a C expression whose value is a string, including spacing,
9752 +containing the assembler operation to identify the following data as
9753 +uninitialized global data. If not defined, and neither
9754 +ASM_OUTPUT_BSS nor ASM_OUTPUT_ALIGNED_BSS are defined,
9755 +uninitialized global data will be output in the data section if
9756 +-fno-common is passed, otherwise ASM_OUTPUT_COMMON will be
9757 +used.
9758 +*/
9759 +#define BSS_SECTION_ASM_OP "\t.section\t.bss"
9760 +
9761 +/*
9762 +If defined, a C expression whose value is a string, including spacing,
9763 +containing the assembler operation to identify the following data as
9764 +uninitialized global shared data. If not defined, and
9765 +BSS_SECTION_ASM_OP is, the latter will be used.
9766 +*/
9767 +/*#define SHARED_BSS_SECTION_ASM_OP "\trseg\tshared_bbs_section:data:noroot(0)\n"*/
9768 +/*
9769 +If defined, a C expression whose value is a string, including spacing,
9770 +containing the assembler operation to identify the following data as
9771 +initialization code. If not defined, GCC will assume such a section does
9772 +not exist.
9773 +*/
9774 +#undef INIT_SECTION_ASM_OP
9775 +#define INIT_SECTION_ASM_OP "\t.section\t.init"
9776 +
9777 +/*
9778 +If defined, a C expression whose value is a string, including spacing,
9779 +containing the assembler operation to identify the following data as
9780 +finalization code. If not defined, GCC will assume such a section does
9781 +not exist.
9782 +*/
9783 +#undef FINI_SECTION_ASM_OP
9784 +#define FINI_SECTION_ASM_OP "\t.section\t.fini"
9785 +
9786 +/*
9787 +If defined, an ASM statement that switches to a different section
9788 +via SECTION_OP, calls FUNCTION, and switches back to
9789 +the text section. This is used in crtstuff.c if
9790 +INIT_SECTION_ASM_OP or FINI_SECTION_ASM_OP to calls
9791 +to initialization and finalization functions from the init and fini
9792 +sections. By default, this macro uses a simple function call. Some
9793 +ports need hand-crafted assembly code to avoid dependencies on
9794 +registers initialized in the function prologue or to ensure that
9795 +constant pools don't end up too far way in the text section.
9796 +*/
9797 +#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
9798 + asm ( SECTION_OP "\n" \
9799 + "mcall r6[" USER_LABEL_PREFIX #FUNC "@got]\n" \
9800 + TEXT_SECTION_ASM_OP);
9801 +
9802 +
9803 +/*
9804 +Define this macro to be an expression with a nonzero value if jump
9805 +tables (for tablejump insns) should be output in the text
9806 +section, along with the assembler instructions. Otherwise, the
9807 +readonly data section is used.
9808 +
9809 +This macro is irrelevant if there is no separate readonly data section.
9810 +*/
9811 +/* Put jump tables in text section if we have caches. Otherwise assume that
9812 + loading data from code memory is slow. */
9813 +#define JUMP_TABLES_IN_TEXT_SECTION \
9814 + (TARGET_CACHES ? 1 : 0)
9815 +
9816 +
9817 +/******************************************************************************
9818 + * Position Independent Code (PIC)
9819 + *****************************************************************************/
9820 +
9821 +#ifndef AVR32_ALWAYS_PIC
9822 +#define AVR32_ALWAYS_PIC 0
9823 +#endif
9824 +
9825 +/* GOT is set to r6 */
9826 +#define PIC_OFFSET_TABLE_REGNUM INTERNAL_REGNUM(6)
9827 +
9828 +/*
9829 +A C expression that is nonzero if X is a legitimate immediate
9830 +operand on the target machine when generating position independent code.
9831 +You can assume that X satisfies CONSTANT_P, so you need not
9832 +check this. You can also assume flag_pic is true, so you need not
9833 +check it either. You need not define this macro if all constants
9834 +(including SYMBOL_REF) can be immediate operands when generating
9835 +position independent code.
9836 +*/
9837 +/* We can't directly access anything that contains a symbol,
9838 + nor can we indirect via the constant pool. */
9839 +#define LEGITIMATE_PIC_OPERAND_P(X) avr32_legitimate_pic_operand_p(X)
9840 +
9841 +
9842 +/* We need to know when we are making a constant pool; this determines
9843 + whether data needs to be in the GOT or can be referenced via a GOT
9844 + offset. */
9845 +extern int making_const_table;
9846 +
9847 +/******************************************************************************
9848 + * Defining the Output Assembler Language
9849 + *****************************************************************************/
9850 +
9851 +
9852 +/*
9853 +A C string constant describing how to begin a comment in the target
9854 +assembler language. The compiler assumes that the comment will end at
9855 +the end of the line.
9856 +*/
9857 +#define ASM_COMMENT_START "# "
9858 +
9859 +/*
9860 +A C string constant for text to be output before each asm
9861 +statement or group of consecutive ones. Normally this is
9862 +"#APP", which is a comment that has no effect on most
9863 +assemblers but tells the GNU assembler that it must check the lines
9864 +that follow for all valid assembler constructs.
9865 +*/
9866 +#undef ASM_APP_ON
9867 +#define ASM_APP_ON "#APP\n"
9868 +
9869 +/*
9870 +A C string constant for text to be output after each asm
9871 +statement or group of consecutive ones. Normally this is
9872 +"#NO_APP", which tells the GNU assembler to resume making the
9873 +time-saving assumptions that are valid for ordinary compiler output.
9874 +*/
9875 +#undef ASM_APP_OFF
9876 +#define ASM_APP_OFF "#NO_APP\n"
9877 +
9878 +
9879 +
9880 +#define FILE_ASM_OP "\t.file\n"
9881 +#define IDENT_ASM_OP "\t.ident\t"
9882 +#define SET_ASM_OP "\t.set\t"
9883 +
9884 +
9885 +/*
9886 + * Output assembly directives to switch to section name. The section
9887 + * should have attributes as specified by flags, which is a bit mask
9888 + * of the SECTION_* flags defined in 'output.h'. If align is nonzero,
9889 + * it contains an alignment in bytes to be used for the section,
9890 + * otherwise some target default should be used. Only targets that
9891 + * must specify an alignment within the section directive need pay
9892 + * attention to align -- we will still use ASM_OUTPUT_ALIGN.
9893 + *
9894 + * NOTE: This one must not be moved to avr32.c
9895 + */
9896 +#undef TARGET_ASM_NAMED_SECTION
9897 +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
9898 +
9899 +
9900 +/*
9901 +You may define this macro as a C expression. You should define the
9902 +expression to have a nonzero value if GCC should output the constant
9903 +pool for a function before the code for the function, or a zero value if
9904 +GCC should output the constant pool after the function. If you do
9905 +not define this macro, the usual case, GCC will output the constant
9906 +pool before the function.
9907 +*/
9908 +#define CONSTANT_POOL_BEFORE_FUNCTION 0
9909 +
9910 +
9911 +/*
9912 +Define this macro as a C expression which is nonzero if the constant
9913 +EXP, of type tree, should be output after the code for a
9914 +function. The compiler will normally output all constants before the
9915 +function; you need not define this macro if this is OK.
9916 +*/
9917 +#define CONSTANT_AFTER_FUNCTION_P(EXP) 1
9918 +
9919 +
9920 +/*
9921 +Define this macro as a C expression which is nonzero if C is
9922 +used as a logical line separator by the assembler.
9923 +
9924 +If you do not define this macro, the default is that only
9925 +the character ';' is treated as a logical line separator.
9926 +*/
9927 +#define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == '\n')
9928 +
9929 +
9930 +/** Output of Uninitialized Variables **/
9931 +
9932 +/*
9933 +A C statement (sans semicolon) to output to the stdio stream
9934 +STREAM the assembler definition of a common-label named
9935 +NAME whose size is SIZE bytes. The variable ROUNDED
9936 +is the size rounded up to whatever alignment the caller wants.
9937 +
9938 +Use the expression assemble_name(STREAM, NAME) to
9939 +output the name itself; before and after that, output the additional
9940 +assembler syntax for defining the name, and a newline.
9941 +
9942 +This macro controls how the assembler definitions of uninitialized
9943 +common global variables are output.
9944 +*/
9945 +/*
9946 +#define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \
9947 + avr32_asm_output_common(STREAM, NAME, SIZE, ROUNDED)
9948 +*/
9949 +
9950 +#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
9951 + do \
9952 + { \
9953 + fputs ("\t.comm ", (FILE)); \
9954 + assemble_name ((FILE), (NAME)); \
9955 + fprintf ((FILE), ",%d\n", (SIZE)); \
9956 + } \
9957 + while (0)
9958 +
9959 +/*
9960 + * Like ASM_OUTPUT_BSS except takes the required alignment as a
9961 + * separate, explicit argument. If you define this macro, it is used
9962 + * in place of ASM_OUTPUT_BSS, and gives you more flexibility in
9963 + * handling the required alignment of the variable. The alignment is
9964 + * specified as the number of bits.
9965 + *
9966 + * Try to use function asm_output_aligned_bss defined in file varasm.c
9967 + * when defining this macro.
9968 + */
9969 +#define ASM_OUTPUT_ALIGNED_BSS(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
9970 + asm_output_aligned_bss (STREAM, DECL, NAME, SIZE, ALIGNMENT)
9971 +
9972 +/*
9973 +A C statement (sans semicolon) to output to the stdio stream
9974 +STREAM the assembler definition of a local-common-label named
9975 +NAME whose size is SIZE bytes. The variable ROUNDED
9976 +is the size rounded up to whatever alignment the caller wants.
9977 +
9978 +Use the expression assemble_name(STREAM, NAME) to
9979 +output the name itself; before and after that, output the additional
9980 +assembler syntax for defining the name, and a newline.
9981 +
9982 +This macro controls how the assembler definitions of uninitialized
9983 +static variables are output.
9984 +*/
9985 +#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
9986 + do \
9987 + { \
9988 + fputs ("\t.lcomm ", (FILE)); \
9989 + assemble_name ((FILE), (NAME)); \
9990 + fprintf ((FILE), ",%d, %d\n", (SIZE), 2); \
9991 + } \
9992 + while (0)
9993 +
9994 +
9995 +/*
9996 +A C statement (sans semicolon) to output to the stdio stream
9997 +STREAM the assembler definition of a label named NAME.
9998 +Use the expression assemble_name(STREAM, NAME) to
9999 +output the name itself; before and after that, output the additional
10000 +assembler syntax for defining the name, and a newline.
10001 +*/
10002 +#define ASM_OUTPUT_LABEL(STREAM, NAME) avr32_asm_output_label(STREAM, NAME)
10003 +
10004 +/* A C string containing the appropriate assembler directive to
10005 + * specify the size of a symbol, without any arguments. On systems
10006 + * that use ELF, the default (in 'config/elfos.h') is '"\t.size\t"';
10007 + * on other systems, the default is not to define this macro.
10008 + *
10009 + * Define this macro only if it is correct to use the default
10010 + * definitions of ASM_ OUTPUT_SIZE_DIRECTIVE and
10011 + * ASM_OUTPUT_MEASURED_SIZE for your system. If you need your own
10012 + * custom definitions of those macros, or if you do not need explicit
10013 + * symbol sizes at all, do not define this macro.
10014 + */
10015 +#define SIZE_ASM_OP "\t.size\t"
10016 +
10017 +
10018 +/*
10019 +A C statement (sans semicolon) to output to the stdio stream
10020 +STREAM some commands that will make the label NAME global;
10021 +that is, available for reference from other files. Use the expression
10022 +assemble_name(STREAM, NAME) to output the name
10023 +itself; before and after that, output the additional assembler syntax
10024 +for making that name global, and a newline.
10025 +*/
10026 +#define GLOBAL_ASM_OP "\t.globl\t"
10027 +
10028 +
10029 +
10030 +/*
10031 +A C expression which evaluates to true if the target supports weak symbols.
10032 +
10033 +If you don't define this macro, defaults.h provides a default
10034 +definition. If either ASM_WEAKEN_LABEL or ASM_WEAKEN_DECL
10035 +is defined, the default definition is '1'; otherwise, it is
10036 +'0'. Define this macro if you want to control weak symbol support
10037 +with a compiler flag such as -melf.
10038 +*/
10039 +#define SUPPORTS_WEAK 1
10040 +
10041 +/*
10042 +A C statement (sans semicolon) to output to the stdio stream
10043 +STREAM a reference in assembler syntax to a label named
10044 +NAME. This should add '_' to the front of the name, if that
10045 +is customary on your operating system, as it is in most Berkeley Unix
10046 +systems. This macro is used in assemble_name.
10047 +*/
10048 +#define ASM_OUTPUT_LABELREF(STREAM, NAME) \
10049 + avr32_asm_output_labelref(STREAM, NAME)
10050 +
10051 +
10052 +
10053 +/*
10054 +A C expression to assign to OUTVAR (which is a variable of type
10055 +char *) a newly allocated string made from the string
10056 +NAME and the number NUMBER, with some suitable punctuation
10057 +added. Use alloca to get space for the string.
10058 +
10059 +The string will be used as an argument to ASM_OUTPUT_LABELREF to
10060 +produce an assembler label for an internal static variable whose name is
10061 +NAME. Therefore, the string must be such as to result in valid
10062 +assembler code. The argument NUMBER is different each time this
10063 +macro is executed; it prevents conflicts between similarly-named
10064 +internal static variables in different scopes.
10065 +
10066 +Ideally this string should not be a valid C identifier, to prevent any
10067 +conflict with the user's own symbols. Most assemblers allow periods
10068 +or percent signs in assembler symbols; putting at least one of these
10069 +between the name and the number will suffice.
10070 +*/
10071 +#define ASM_FORMAT_PRIVATE_NAME(OUTVAR, NAME, NUMBER) \
10072 + do \
10073 + { \
10074 + (OUTVAR) = (char *) alloca (strlen ((NAME)) + 10); \
10075 + sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)); \
10076 + } \
10077 + while (0)
10078 +
10079 +
10080 +/** Macros Controlling Initialization Routines **/
10081 +
10082 +
10083 +/*
10084 +If defined, main will not call __main as described above.
10085 +This macro should be defined for systems that control start-up code
10086 +on a symbol-by-symbol basis, such as OSF/1, and should not
10087 +be defined explicitly for systems that support INIT_SECTION_ASM_OP.
10088 +*/
10089 +/*
10090 + __main is not defined when debugging.
10091 +*/
10092 +#define HAS_INIT_SECTION
10093 +
10094 +
10095 +/** Output of Assembler Instructions **/
10096 +
10097 +/*
10098 +A C initializer containing the assembler's names for the machine
10099 +registers, each one as a C string constant. This is what translates
10100 +register numbers in the compiler into assembler language.
10101 +*/
10102 +
10103 +#define REGISTER_NAMES \
10104 +{ \
10105 + "pc", "lr", \
10106 + "sp", "r12", \
10107 + "r11", "r10", \
10108 + "r9", "r8", \
10109 + "r7", "r6", \
10110 + "r5", "r4", \
10111 + "r3", "r2", \
10112 + "r1", "r0", \
10113 + "f15","f14", \
10114 + "f13","f12", \
10115 + "f11","f10", \
10116 + "f9", "f8", \
10117 + "f7", "f6", \
10118 + "f5", "f4", \
10119 + "f3", "f2", \
10120 + "f1", "f0" \
10121 +}
10122 +
10123 +/*
10124 +A C compound statement to output to stdio stream STREAM the
10125 +assembler syntax for an instruction operand X. X is an
10126 +RTL expression.
10127 +
10128 +CODE is a value that can be used to specify one of several ways
10129 +of printing the operand. It is used when identical operands must be
10130 +printed differently depending on the context. CODE comes from
10131 +the '%' specification that was used to request printing of the
10132 +operand. If the specification was just '%digit' then
10133 +CODE is 0; if the specification was '%ltr digit'
10134 +then CODE is the ASCII code for ltr.
10135 +
10136 +If X is a register, this macro should print the register's name.
10137 +The names can be found in an array reg_names whose type is
10138 +char *[]. reg_names is initialized from REGISTER_NAMES.
10139 +
10140 +When the machine description has a specification '%punct'
10141 +(a '%' followed by a punctuation character), this macro is called
10142 +with a null pointer for X and the punctuation character for
10143 +CODE.
10144 +*/
10145 +#define PRINT_OPERAND(STREAM, X, CODE) avr32_print_operand(STREAM, X, CODE)
10146 +
10147 +/* A C statement to be executed just prior to the output of
10148 + assembler code for INSN, to modify the extracted operands so
10149 + they will be output differently.
10150 +
10151 + Here the argument OPVEC is the vector containing the operands
10152 + extracted from INSN, and NOPERANDS is the number of elements of
10153 + the vector which contain meaningful data for this insn.
10154 + The contents of this vector are what will be used to convert the insn
10155 + template into assembler code, so you can change the assembler output
10156 + by changing the contents of the vector. */
10157 +#define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
10158 + avr32_final_prescan_insn ((INSN), (OPVEC), (NOPERANDS))
10159 +
10160 +/*
10161 +A C expression which evaluates to true if CODE is a valid
10162 +punctuation character for use in the PRINT_OPERAND macro. If
10163 +PRINT_OPERAND_PUNCT_VALID_P is not defined, it means that no
10164 +punctuation characters (except for the standard one, '%') are used
10165 +in this way.
10166 +*/
10167 +/*
10168 + 'm' refers to the most significant word in a two-register mode.
10169 +*/
10170 +#define PRINT_OPERAND_PUNCT_VALID_P(CODE) ((CODE) == 'm' || (CODE) == 'e')
10171 +
10172 +/*
10173 +A C compound statement to output to stdio stream STREAM the
10174 +assembler syntax for an instruction operand that is a memory reference
10175 +whose address is X. X is an RTL expression.
10176 +
10177 +On some machines, the syntax for a symbolic address depends on the
10178 +section that the address refers to. On these machines, define the macro
10179 +ENCODE_SECTION_INFO to store the information into the
10180 +symbol_ref, and then check for it here. (see Assembler Format.)
10181 +*/
10182 +#define PRINT_OPERAND_ADDRESS(STREAM, X) avr32_print_operand_address(STREAM, X)
10183 +
10184 +
10185 +/** Output of Dispatch Tables **/
10186 +
10187 +/*
10188 + * A C statement to output to the stdio stream stream an assembler
10189 + * pseudo-instruction to generate a difference between two
10190 + * labels. value and rel are the numbers of two internal labels. The
10191 + * definitions of these labels are output using
10192 + * (*targetm.asm_out.internal_label), and they must be printed in the
10193 + * same way here. For example,
10194 + *
10195 + * fprintf (stream, "\t.word L%d-L%d\n",
10196 + * value, rel)
10197 + *
10198 + * You must provide this macro on machines where the addresses in a
10199 + * dispatch table are relative to the table's own address. If defined,
10200 + * GCC will also use this macro on all machines when producing
10201 + * PIC. body is the body of the ADDR_DIFF_VEC; it is provided so that
10202 + * the mode and flags can be read.
10203 + */
10204 +#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL) \
10205 + fprintf(STREAM, "\tbral\t%sL%d\n", LOCAL_LABEL_PREFIX, VALUE)
10206 +
10207 +/*
10208 +This macro should be provided on machines where the addresses
10209 +in a dispatch table are absolute.
10210 +
10211 +The definition should be a C statement to output to the stdio stream
10212 +STREAM an assembler pseudo-instruction to generate a reference to
10213 +a label. VALUE is the number of an internal label whose
10214 +definition is output using ASM_OUTPUT_INTERNAL_LABEL.
10215 +For example,
10216 +
10217 +fprintf(STREAM, "\t.word L%d\n", VALUE)
10218 +*/
10219 +
10220 +#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \
10221 + fprintf(STREAM, "\t.long %sL%d\n", LOCAL_LABEL_PREFIX, VALUE)
10222 +
10223 +/** Assembler Commands for Exception Regions */
10224 +
10225 +/* ToDo: All of this subsection */
10226 +
10227 +/** Assembler Commands for Alignment */
10228 +
10229 +
10230 +/*
10231 +A C statement to output to the stdio stream STREAM an assembler
10232 +command to advance the location counter to a multiple of 2 to the
10233 +POWER bytes. POWER will be a C expression of type int.
10234 +*/
10235 +#define ASM_OUTPUT_ALIGN(STREAM, POWER) \
10236 + do \
10237 + { \
10238 + if ((POWER) != 0) \
10239 + fprintf(STREAM, "\t.align\t%d\n", POWER); \
10240 + } \
10241 + while (0)
10242 +
10243 +/*
10244 +Like ASM_OUTPUT_ALIGN, except that the \nop" instruction is used for padding, if
10245 +necessary.
10246 +*/
10247 +#define ASM_OUTPUT_ALIGN_WITH_NOP(STREAM, POWER) \
10248 + fprintf(STREAM, "\t.balignw\t%d, 0xd703\n", (1 << POWER))
10249 +
10250 +
10251 +
10252 +/******************************************************************************
10253 + * Controlling Debugging Information Format
10254 + *****************************************************************************/
10255 +
10256 +/* How to renumber registers for dbx and gdb. */
10257 +#define DBX_REGISTER_NUMBER(REGNO) ASM_REGNUM (REGNO)
10258 +
10259 +/* The DWARF 2 CFA column which tracks the return address. */
10260 +#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM(LR_REGNUM)
10261 +
10262 +/*
10263 +Define this macro if GCC should produce dwarf version 2 format
10264 +debugging output in response to the -g option.
10265 +
10266 +To support optional call frame debugging information, you must also
10267 +define INCOMING_RETURN_ADDR_RTX and either set
10268 +RTX_FRAME_RELATED_P on the prologue insns if you use RTL for the
10269 +prologue, or call dwarf2out_def_cfa and dwarf2out_reg_save
10270 +as appropriate from TARGET_ASM_FUNCTION_PROLOGUE if you don't.
10271 +*/
10272 +#define DWARF2_DEBUGGING_INFO 1
10273 +
10274 +
10275 +#define DWARF2_ASM_LINE_DEBUG_INFO 1
10276 +#define DWARF2_FRAME_INFO 1
10277 +
10278 +
10279 +/******************************************************************************
10280 + * Miscellaneous Parameters
10281 + *****************************************************************************/
10282 +
10283 +/* ToDo: a lot */
10284 +
10285 +/*
10286 +An alias for a machine mode name. This is the machine mode that
10287 +elements of a jump-table should have.
10288 +*/
10289 +#define CASE_VECTOR_MODE SImode
10290 +
10291 +/*
10292 +Define this macro to be a C expression to indicate when jump-tables
10293 +should contain relative addresses. If jump-tables never contain
10294 +relative addresses, then you need not define this macro.
10295 +*/
10296 +#define CASE_VECTOR_PC_RELATIVE 0
10297 +
10298 +/* Increase the threshold for using table jumps on the UC arch. */
10299 +#define CASE_VALUES_THRESHOLD ((avr32_arch->arch_type == ARCH_TYPE_AVR32_UC) ? 7 : 4)
10300 +
10301 +/*
10302 +The maximum number of bytes that a single instruction can move quickly
10303 +between memory and registers or between two memory locations.
10304 +*/
10305 +#define MOVE_MAX (2*UNITS_PER_WORD)
10306 +
10307 +
10308 +/* A C expression that is nonzero if on this machine the number of bits actually used
10309 + for the count of a shift operation is equal to the number of bits needed to represent
10310 + the size of the object being shifted. When this macro is nonzero, the compiler will
10311 + assume that it is safe to omit a sign-extend, zero-extend, and certain bitwise 'and'
10312 + instructions that truncates the count of a shift operation. On machines that have
10313 + instructions that act on bit-fields at variable positions, which may include 'bit test'
10314 + 378 GNU Compiler Collection (GCC) Internals
10315 + instructions, a nonzero SHIFT_COUNT_TRUNCATED also enables deletion of truncations
10316 + of the values that serve as arguments to bit-field instructions.
10317 + If both types of instructions truncate the count (for shifts) and position (for bit-field
10318 + operations), or if no variable-position bit-field instructions exist, you should define
10319 + this macro.
10320 + However, on some machines, such as the 80386 and the 680x0, truncation only applies
10321 + to shift operations and not the (real or pretended) bit-field operations. Define SHIFT_
10322 + COUNT_TRUNCATED to be zero on such machines. Instead, add patterns to the 'md' file
10323 + that include the implied truncation of the shift instructions.
10324 + You need not de\fne this macro if it would always have the value of zero. */
10325 +#define SHIFT_COUNT_TRUNCATED 1
10326 +
10327 +/*
10328 +A C expression which is nonzero if on this machine it is safe to
10329 +convert an integer of INPREC bits to one of OUTPREC
10330 +bits (where OUTPREC is smaller than INPREC) by merely
10331 +operating on it as if it had only OUTPREC bits.
10332 +
10333 +On many machines, this expression can be 1.
10334 +
10335 +When TRULY_NOOP_TRUNCATION returns 1 for a pair of sizes for
10336 +modes for which MODES_TIEABLE_P is 0, suboptimal code can result.
10337 +If this is the case, making TRULY_NOOP_TRUNCATION return 0 in
10338 +such cases may improve things.
10339 +*/
10340 +#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
10341 +
10342 +/*
10343 +An alias for the machine mode for pointers. On most machines, define
10344 +this to be the integer mode corresponding to the width of a hardware
10345 +pointer; SImode on 32-bit machine or DImode on 64-bit machines.
10346 +On some machines you must define this to be one of the partial integer
10347 +modes, such as PSImode.
10348 +
10349 +The width of Pmode must be at least as large as the value of
10350 +POINTER_SIZE. If it is not equal, you must define the macro
10351 +POINTERS_EXTEND_UNSIGNED to specify how pointers are extended
10352 +to Pmode.
10353 +*/
10354 +#define Pmode SImode
10355 +
10356 +/*
10357 +An alias for the machine mode used for memory references to functions
10358 +being called, in call RTL expressions. On most machines this
10359 +should be QImode.
10360 +*/
10361 +#define FUNCTION_MODE SImode
10362 +
10363 +
10364 +#define REG_S_P(x) \
10365 + (REG_P (x) || (GET_CODE (x) == SUBREG && REG_P (XEXP (x, 0))))
10366 +
10367 +
10368 +/* If defined, modifies the length assigned to instruction INSN as a
10369 + function of the context in which it is used. LENGTH is an lvalue
10370 + that contains the initially computed length of the insn and should
10371 + be updated with the correct length of the insn. */
10372 +#define ADJUST_INSN_LENGTH(INSN, LENGTH) \
10373 + ((LENGTH) = avr32_adjust_insn_length ((INSN), (LENGTH)))
10374 +
10375 +
10376 +#define CLZ_DEFINED_VALUE_AT_ZERO(mode, value) \
10377 + (value = 32, (mode == SImode))
10378 +
10379 +#define CTZ_DEFINED_VALUE_AT_ZERO(mode, value) \
10380 + (value = 32, (mode == SImode))
10381 +
10382 +#define UNITS_PER_SIMD_WORD UNITS_PER_WORD
10383 +
10384 +#define STORE_FLAG_VALUE 1
10385 +
10386 +enum avr32_builtins
10387 +{
10388 + AVR32_BUILTIN_MTSR,
10389 + AVR32_BUILTIN_MFSR,
10390 + AVR32_BUILTIN_MTDR,
10391 + AVR32_BUILTIN_MFDR,
10392 + AVR32_BUILTIN_CACHE,
10393 + AVR32_BUILTIN_SYNC,
10394 + AVR32_BUILTIN_TLBR,
10395 + AVR32_BUILTIN_TLBS,
10396 + AVR32_BUILTIN_TLBW,
10397 + AVR32_BUILTIN_BREAKPOINT,
10398 + AVR32_BUILTIN_XCHG,
10399 + AVR32_BUILTIN_LDXI,
10400 + AVR32_BUILTIN_BSWAP16,
10401 + AVR32_BUILTIN_BSWAP32,
10402 + AVR32_BUILTIN_COP,
10403 + AVR32_BUILTIN_MVCR_W,
10404 + AVR32_BUILTIN_MVRC_W,
10405 + AVR32_BUILTIN_MVCR_D,
10406 + AVR32_BUILTIN_MVRC_D,
10407 + AVR32_BUILTIN_MULSATHH_H,
10408 + AVR32_BUILTIN_MULSATHH_W,
10409 + AVR32_BUILTIN_MULSATRNDHH_H,
10410 + AVR32_BUILTIN_MULSATRNDWH_W,
10411 + AVR32_BUILTIN_MULSATWH_W,
10412 + AVR32_BUILTIN_MACSATHH_W,
10413 + AVR32_BUILTIN_SATADD_H,
10414 + AVR32_BUILTIN_SATSUB_H,
10415 + AVR32_BUILTIN_SATADD_W,
10416 + AVR32_BUILTIN_SATSUB_W,
10417 + AVR32_BUILTIN_MULWH_D,
10418 + AVR32_BUILTIN_MULNWH_D,
10419 + AVR32_BUILTIN_MACWH_D,
10420 + AVR32_BUILTIN_MACHH_D,
10421 + AVR32_BUILTIN_MUSFR,
10422 + AVR32_BUILTIN_MUSTR,
10423 + AVR32_BUILTIN_SATS,
10424 + AVR32_BUILTIN_SATU,
10425 + AVR32_BUILTIN_SATRNDS,
10426 + AVR32_BUILTIN_SATRNDU
10427 +};
10428 +
10429 +
10430 +#define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) \
10431 + ((MODE == SFmode) || (MODE == DFmode))
10432 +
10433 +#define RENAME_LIBRARY_SET ".set"
10434 +
10435 +/* Make ABI_NAME an alias for __GCC_NAME. */
10436 +#define RENAME_LIBRARY(GCC_NAME, ABI_NAME) \
10437 + __asm__ (".globl\t__avr32_" #ABI_NAME "\n" \
10438 + ".set\t__avr32_" #ABI_NAME \
10439 + ", __" #GCC_NAME "\n");
10440 +
10441 +/* Give libgcc functions avr32 ABI name. */
10442 +#ifdef L_muldi3
10443 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (muldi3, mul64)
10444 +#endif
10445 +#ifdef L_divdi3
10446 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (divdi3, sdiv64)
10447 +#endif
10448 +#ifdef L_udivdi3
10449 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (udivdi3, udiv64)
10450 +#endif
10451 +#ifdef L_moddi3
10452 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (moddi3, smod64)
10453 +#endif
10454 +#ifdef L_umoddi3
10455 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (umoddi3, umod64)
10456 +#endif
10457 +#ifdef L_ashldi3
10458 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (ashldi3, lsl64)
10459 +#endif
10460 +#ifdef L_lshrdi3
10461 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (lshrdi3, lsr64)
10462 +#endif
10463 +#ifdef L_ashrdi3
10464 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (ashrdi3, asr64)
10465 +#endif
10466 +
10467 +#ifdef L_fixsfdi
10468 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (fixsfdi, f32_to_s64)
10469 +#endif
10470 +#ifdef L_fixunssfdi
10471 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (fixunssfdi, f32_to_u64)
10472 +#endif
10473 +#ifdef L_floatdidf
10474 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (floatdidf, s64_to_f64)
10475 +#endif
10476 +#ifdef L_floatdisf
10477 +#define DECLARE_LIBRARY_RENAMES RENAME_LIBRARY (floatdisf, s64_to_f32)
10478 +#endif
10479 +
10480 +#endif
10481 Index: gcc-4.2.3/gcc/config/avr32/avr32.md
10482 ===================================================================
10483 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
10484 +++ gcc-4.2.3/gcc/config/avr32/avr32.md 2008-05-21 13:45:54.165287871 +0200
10485 @@ -0,0 +1,4606 @@
10486 +;; AVR32 machine description file.
10487 +;; Copyright 2003-2006 Atmel Corporation.
10488 +;;
10489 +;; Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
10490 +;;
10491 +;; This file is part of GCC.
10492 +;;
10493 +;; This program is free software; you can redistribute it and/or modify
10494 +;; it under the terms of the GNU General Public License as published by
10495 +;; the Free Software Foundation; either version 2 of the License, or
10496 +;; (at your option) any later version.
10497 +;;
10498 +;; This program is distributed in the hope that it will be useful,
10499 +;; but WITHOUT ANY WARRANTY; without even the implied warranty of
10500 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10501 +;; GNU General Public License for more details.
10502 +;;
10503 +;; You should have received a copy of the GNU General Public License
10504 +;; along with this program; if not, write to the Free Software
10505 +;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
10506 +
10507 +;; -*- Mode: Scheme -*-
10508 +
10509 +(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"
10510 + (const_string "alu"))
10511 +
10512 +
10513 +(define_attr "cc" "none,set_vncz,set_ncz,set_cz,set_z,bld,compare,cmp_cond_insn,clobber,call_set,fpcompare,from_fpcc"
10514 + (const_string "none"))
10515 +
10516 +
10517 +; NB! Keep this in sync with enum architecture_type in avr32.h
10518 +(define_attr "pipeline" "ap,uc"
10519 + (const (symbol_ref "avr32_arch->arch_type")))
10520 +
10521 +(define_attr "length" ""
10522 + (const_int 4))
10523 +
10524 +
10525 +;; Uses of UNSPEC in this file:
10526 +(define_constants
10527 + [(UNSPEC_PUSHM 0)
10528 + (UNSPEC_POPM 1)
10529 + (UNSPEC_UDIVMODSI4_INTERNAL 2)
10530 + (UNSPEC_DIVMODSI4_INTERNAL 3)
10531 + (UNSPEC_STM 4)
10532 + (UNSPEC_LDM 5)
10533 + (UNSPEC_MOVSICC 6)
10534 + (UNSPEC_ADDSICC 7)
10535 + (UNSPEC_COND_MI 8)
10536 + (UNSPEC_COND_PL 9)
10537 + (UNSPEC_PIC_SYM 10)
10538 + (UNSPEC_PIC_BASE 11)
10539 + (UNSPEC_STORE_MULTIPLE 12)
10540 + (UNSPEC_STMFP 13)
10541 + (UNSPEC_FPCC_TO_REG 14)
10542 + (UNSPEC_REG_TO_CC 15)
10543 + (UNSPEC_FORCE_MINIPOOL 16)
10544 + (UNSPEC_SATS 17)
10545 + (UNSPEC_SATU 18)
10546 + (UNSPEC_SATRNDS 19)
10547 + (UNSPEC_SATRNDU 20)
10548 + ])
10549 +
10550 +(define_constants
10551 + [(VUNSPEC_EPILOGUE 0)
10552 + (VUNSPEC_CACHE 1)
10553 + (VUNSPEC_MTSR 2)
10554 + (VUNSPEC_MFSR 3)
10555 + (VUNSPEC_BLOCKAGE 4)
10556 + (VUNSPEC_SYNC 5)
10557 + (VUNSPEC_TLBR 6)
10558 + (VUNSPEC_TLBW 7)
10559 + (VUNSPEC_TLBS 8)
10560 + (VUNSPEC_BREAKPOINT 9)
10561 + (VUNSPEC_MTDR 10)
10562 + (VUNSPEC_MFDR 11)
10563 + (VUNSPEC_MVCR 12)
10564 + (VUNSPEC_MVRC 13)
10565 + (VUNSPEC_COP 14)
10566 + (VUNSPEC_ALIGN 15)
10567 + (VUNSPEC_POOL_START 16)
10568 + (VUNSPEC_POOL_END 17)
10569 + (VUNSPEC_POOL_4 18)
10570 + (VUNSPEC_POOL_8 19)
10571 + (VUNSPEC_POOL_16 20)
10572 + (VUNSPEC_MUSFR 21)
10573 + (VUNSPEC_MUSTR 22)
10574 + (VUNSPEC_SYNC_CMPXCHG 23)
10575 + (VUNSPEC_SYNC_SET_LOCK_AND_LOAD 24)
10576 + (VUNSPEC_SYNC_STORE_IF_LOCK 25)
10577 + (VUNSPEC_EH_RETURN 26)
10578 + (VUNSPEC_FRS 27)
10579 + ])
10580 +
10581 +(define_constants
10582 + [
10583 + ;; R7 = 15-7 = 8
10584 + (FP_REGNUM 8)
10585 + ;; Return Register = R12 = 15 - 12 = 3
10586 + (RETVAL_REGNUM 3)
10587 + ;; SP = R13 = 15 - 13 = 2
10588 + (SP_REGNUM 2)
10589 + ;; LR = R14 = 15 - 14 = 1
10590 + (LR_REGNUM 1)
10591 + ;; PC = R15 = 15 - 15 = 0
10592 + (PC_REGNUM 0)
10593 + ;; FPSR = GENERAL_REGS + 1 = 17
10594 + (FPCC_REGNUM 17)
10595 + ])
10596 +
10597 +
10598 +
10599 +
10600 +;;******************************************************************************
10601 +;; Macros
10602 +;;******************************************************************************
10603 +
10604 +;; Integer Modes for basic alu insns
10605 +(define_mode_macro INTM [SI HI QI])
10606 +(define_mode_attr alu_cc_attr [(SI "set_vncz") (HI "clobber") (QI "clobber")])
10607 +
10608 +;; Move word modes
10609 +(define_mode_macro MOVM [SI V2HI V4QI])
10610 +
10611 +;; For mov/addcc insns
10612 +(define_mode_macro ADDCC [SI HI QI])
10613 +(define_mode_macro MOVCC [SI HI QI])
10614 +(define_mode_macro CMP [DI SI HI QI])
10615 +(define_mode_attr cmp_constraint [(DI "rKu20") (SI "rKs21") (HI "r") (QI "r")])
10616 +(define_mode_attr cmp_predicate [(DI "register_immediate_operand")
10617 + (SI "register_immediate_operand")
10618 + (HI "register_operand")
10619 + (QI "register_operand")])
10620 +
10621 +;; For all conditional insns
10622 +(define_code_macro any_cond [eq ne gt ge lt le gtu geu ltu leu])
10623 +(define_code_attr cond [(eq "eq") (ne "ne") (gt "gt") (ge "ge") (lt "lt") (le "le")
10624 + (gtu "hi") (geu "hs") (ltu "lo") (leu "ls")])
10625 +(define_code_attr invcond [(eq "ne") (ne "eq") (gt "le") (ge "lt") (lt "ge") (le "gt")
10626 + (gtu "ls") (geu "lo") (ltu "hs") (leu "hi")])
10627 +
10628 +;; For logical operations
10629 +(define_code_macro logical [and ior xor])
10630 +(define_code_attr logical_insn [(and "and") (ior "or") (xor "eor")])
10631 +
10632 +;; Load the predicates
10633 +(include "predicates.md")
10634 +
10635 +
10636 +;;******************************************************************************
10637 +;; Automaton pipeline description for avr32
10638 +;;******************************************************************************
10639 +
10640 +(define_automaton "avr32_ap")
10641 +
10642 +
10643 +(define_cpu_unit "is" "avr32_ap")
10644 +(define_cpu_unit "a1,m1,da" "avr32_ap")
10645 +(define_cpu_unit "a2,m2,d" "avr32_ap")
10646 +
10647 +;;Alu instructions
10648 +(define_insn_reservation "alu_op" 1
10649 + (and (eq_attr "pipeline" "ap")
10650 + (eq_attr "type" "alu"))
10651 + "is,a1,a2")
10652 +
10653 +(define_insn_reservation "alu2_op" 2
10654 + (and (eq_attr "pipeline" "ap")
10655 + (eq_attr "type" "alu2"))
10656 + "is,is+a1,a1+a2,a2")
10657 +
10658 +(define_insn_reservation "alu_sat_op" 2
10659 + (and (eq_attr "pipeline" "ap")
10660 + (eq_attr "type" "alu_sat"))
10661 + "is,a1,a2")
10662 +
10663 +
10664 +;;Mul instructions
10665 +(define_insn_reservation "mulhh_op" 2
10666 + (and (eq_attr "pipeline" "ap")
10667 + (eq_attr "type" "mulhh,mulwh"))
10668 + "is,m1,m2")
10669 +
10670 +(define_insn_reservation "mulww_w_op" 3
10671 + (and (eq_attr "pipeline" "ap")
10672 + (eq_attr "type" "mulww_w"))
10673 + "is,m1,m1+m2,m2")
10674 +
10675 +(define_insn_reservation "mulww_d_op" 5
10676 + (and (eq_attr "pipeline" "ap")
10677 + (eq_attr "type" "mulww_d"))
10678 + "is,m1,m1+m2,m1+m2,m2,m2")
10679 +
10680 +(define_insn_reservation "div_op" 33
10681 + (and (eq_attr "pipeline" "ap")
10682 + (eq_attr "type" "div"))
10683 + "is,m1,m1*31 + m2*31,m2")
10684 +
10685 +(define_insn_reservation "machh_w_op" 3
10686 + (and (eq_attr "pipeline" "ap")
10687 + (eq_attr "type" "machh_w"))
10688 + "is*2,m1,m2")
10689 +
10690 +
10691 +(define_insn_reservation "macww_w_op" 4
10692 + (and (eq_attr "pipeline" "ap")
10693 + (eq_attr "type" "macww_w"))
10694 + "is*2,m1,m1,m2")
10695 +
10696 +
10697 +(define_insn_reservation "macww_d_op" 6
10698 + (and (eq_attr "pipeline" "ap")
10699 + (eq_attr "type" "macww_d"))
10700 + "is*2,m1,m1+m2,m1+m2,m2")
10701 +
10702 +;;Bypasses for Mac instructions, because of accumulator cache.
10703 +;;Set latency as low as possible in order to let the compiler let
10704 +;;mul -> mac and mac -> mac combinations which use the same
10705 +;;accumulator cache be placed close together to avoid any
10706 +;;instructions which can ruin the accumulator cache come inbetween.
10707 +(define_bypass 4 "machh_w_op" "alu_op,alu2_op,alu_sat_op,load_op" "avr32_mul_waw_bypass")
10708 +(define_bypass 5 "macww_w_op" "alu_op,alu2_op,alu_sat_op,load_op" "avr32_mul_waw_bypass")
10709 +(define_bypass 7 "macww_d_op" "alu_op,alu2_op,alu_sat_op,load_op" "avr32_mul_waw_bypass")
10710 +
10711 +(define_bypass 3 "mulhh_op" "alu_op,alu2_op,alu_sat_op,load_op" "avr32_mul_waw_bypass")
10712 +(define_bypass 4 "mulww_w_op" "alu_op,alu2_op,alu_sat_op,load_op" "avr32_mul_waw_bypass")
10713 +(define_bypass 6 "mulww_d_op" "alu_op,alu2_op,alu_sat_op,load_op" "avr32_mul_waw_bypass")
10714 +
10715 +
10716 +;;Bypasses for all mul/mac instructions followed by an instruction
10717 +;;which reads the output AND writes the result to the same register.
10718 +;;This will generate an Write After Write hazard which gives an
10719 +;;extra cycle before the result is ready.
10720 +(define_bypass 0 "machh_w_op" "machh_w_op" "avr32_valid_macmac_bypass")
10721 +(define_bypass 0 "macww_w_op" "macww_w_op" "avr32_valid_macmac_bypass")
10722 +(define_bypass 0 "macww_d_op" "macww_d_op" "avr32_valid_macmac_bypass")
10723 +
10724 +(define_bypass 0 "mulhh_op" "machh_w_op" "avr32_valid_mulmac_bypass")
10725 +(define_bypass 0 "mulww_w_op" "macww_w_op" "avr32_valid_mulmac_bypass")
10726 +(define_bypass 0 "mulww_d_op" "macww_d_op" "avr32_valid_mulmac_bypass")
10727 +
10728 +;;Branch and call instructions
10729 +;;We assume that all branches and rcalls are predicted correctly :-)
10730 +;;while calls use a lot of cycles.
10731 +(define_insn_reservation "branch_op" 0
10732 + (and (eq_attr "pipeline" "ap")
10733 + (eq_attr "type" "branch"))
10734 + "nothing")
10735 +
10736 +(define_insn_reservation "call_op" 10
10737 + (and (eq_attr "pipeline" "ap")
10738 + (eq_attr "type" "call"))
10739 + "nothing")
10740 +
10741 +
10742 +;;Load store instructions
10743 +(define_insn_reservation "load_op" 2
10744 + (and (eq_attr "pipeline" "ap")
10745 + (eq_attr "type" "load"))
10746 + "is,da,d")
10747 +
10748 +(define_insn_reservation "load_rm_op" 3
10749 + (and (eq_attr "pipeline" "ap")
10750 + (eq_attr "type" "load_rm"))
10751 + "is,da,d")
10752 +
10753 +
10754 +(define_insn_reservation "store_op" 0
10755 + (and (eq_attr "pipeline" "ap")
10756 + (eq_attr "type" "store"))
10757 + "is,da,d")
10758 +
10759 +
10760 +(define_insn_reservation "load_double_op" 3
10761 + (and (eq_attr "pipeline" "ap")
10762 + (eq_attr "type" "load2"))
10763 + "is,da,da+d,d")
10764 +
10765 +(define_insn_reservation "load_quad_op" 4
10766 + (and (eq_attr "pipeline" "ap")
10767 + (eq_attr "type" "load4"))
10768 + "is,da,da+d,da+d,d")
10769 +
10770 +(define_insn_reservation "store_double_op" 0
10771 + (and (eq_attr "pipeline" "ap")
10772 + (eq_attr "type" "store2"))
10773 + "is,da,da+d,d")
10774 +
10775 +
10776 +(define_insn_reservation "store_quad_op" 0
10777 + (and (eq_attr "pipeline" "ap")
10778 + (eq_attr "type" "store4"))
10779 + "is,da,da+d,da+d,d")
10780 +
10781 +;;For store the operand to write to memory is read in d and
10782 +;;the real latency between any instruction and a store is therefore
10783 +;;one less than for the instructions which reads the operands in the first
10784 +;;excecution stage
10785 +(define_bypass 2 "load_double_op" "store_double_op" "avr32_store_bypass")
10786 +(define_bypass 3 "load_quad_op" "store_quad_op" "avr32_store_bypass")
10787 +(define_bypass 1 "load_op" "store_op" "avr32_store_bypass")
10788 +(define_bypass 2 "load_rm_op" "store_op" "avr32_store_bypass")
10789 +(define_bypass 1 "alu_sat_op" "store_op" "avr32_store_bypass")
10790 +(define_bypass 1 "alu2_op" "store_op" "avr32_store_bypass")
10791 +(define_bypass 1 "mulhh_op" "store_op" "avr32_store_bypass")
10792 +(define_bypass 2 "mulww_w_op" "store_op" "avr32_store_bypass")
10793 +(define_bypass 4 "mulww_d_op" "store_op" "avr32_store_bypass" )
10794 +(define_bypass 2 "machh_w_op" "store_op" "avr32_store_bypass")
10795 +(define_bypass 3 "macww_w_op" "store_op" "avr32_store_bypass")
10796 +(define_bypass 5 "macww_d_op" "store_op" "avr32_store_bypass")
10797 +
10798 +
10799 +; Bypass for load double operation. If only the first loaded word is needed
10800 +; then the latency is 2
10801 +(define_bypass 2 "load_double_op"
10802 + "load_op,load_rm_op,alu_sat_op, alu2_op, alu_op, mulhh_op, mulww_w_op,
10803 + mulww_d_op, machh_w_op, macww_w_op, macww_d_op"
10804 + "avr32_valid_load_double_bypass")
10805 +
10806 +; Bypass for load quad operation. If only the first or second loaded word is needed
10807 +; we set the latency to 2
10808 +(define_bypass 2 "load_quad_op"
10809 + "load_op,load_rm_op,alu_sat_op, alu2_op, alu_op, mulhh_op, mulww_w_op,
10810 + mulww_d_op, machh_w_op, macww_w_op, macww_d_op"
10811 + "avr32_valid_load_quad_bypass")
10812 +
10813 +
10814 +;;******************************************************************************
10815 +;; End of Automaton pipeline description for avr32
10816 +;;******************************************************************************
10817 +
10818 +
10819 +
10820 +;;=============================================================================
10821 +;; move
10822 +;;-----------------------------------------------------------------------------
10823 +
10824 +;;== char - 8 bits ============================================================
10825 +(define_expand "movqi"
10826 + [(set (match_operand:QI 0 "nonimmediate_operand" "")
10827 + (match_operand:QI 1 "general_operand" ""))]
10828 + ""
10829 + {
10830 + if ( !no_new_pseudos ){
10831 + if (GET_CODE (operands[1]) == MEM && optimize){
10832 + rtx reg = gen_reg_rtx (SImode);
10833 +
10834 + emit_insn (gen_zero_extendqisi2 (reg, operands[1]));
10835 + operands[1] = gen_lowpart (QImode, reg);
10836 + }
10837 +
10838 + /* One of the ops has to be in a register. */
10839 + if (GET_CODE (operands[0]) == MEM)
10840 + operands[1] = force_reg (QImode, operands[1]);
10841 + }
10842 +
10843 + })
10844 +
10845 +(define_insn "*movqi_internal"
10846 + [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r")
10847 + (match_operand:QI 1 "general_operand" "rKs08,m,r,i"))]
10848 + ""
10849 + "@
10850 + mov\t%0, %1
10851 + ld.ub\t%0, %1
10852 + st.b\t%0, %1
10853 + mov\t%0, %1"
10854 + [(set_attr "length" "2,4,4,4")
10855 + (set_attr "type" "alu,load_rm,store,alu")])
10856 +
10857 +
10858 +
10859 +;;== short - 16 bits ==========================================================
10860 +(define_expand "movhi"
10861 + [(set (match_operand:HI 0 "nonimmediate_operand" "")
10862 + (match_operand:HI 1 "general_operand" ""))]
10863 + ""
10864 + {
10865 + if ( !no_new_pseudos ){
10866 + if (GET_CODE (operands[1]) == MEM && optimize){
10867 + rtx reg = gen_reg_rtx (SImode);
10868 +
10869 + emit_insn (gen_extendhisi2 (reg, operands[1]));
10870 + operands[1] = gen_lowpart (HImode, reg);
10871 + }
10872 +
10873 + /* One of the ops has to be in a register. */
10874 + if (GET_CODE (operands[0]) == MEM)
10875 + operands[1] = force_reg (HImode, operands[1]);
10876 + }
10877 +
10878 + })
10879 +
10880 +(define_insn "*movhi_internal"
10881 + [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r")
10882 + (match_operand:HI 1 "general_operand" "rKs08,m,r,i"))]
10883 + ""
10884 + "@
10885 + mov\t%0, %1
10886 + ld.sh\t%0, %1
10887 + st.h\t%0, %1
10888 + mov\t%0, %1"
10889 + [(set_attr "length" "2,4,4,4")
10890 + (set_attr "type" "alu,load_rm,store,alu")])
10891 +
10892 +
10893 +;;== int - 32 bits ============================================================
10894 +
10895 +(define_expand "movmisalignsi"
10896 + [(set (match_operand:SI 0 "nonimmediate_operand" "")
10897 + (match_operand:SI 1 "nonimmediate_operand" ""))]
10898 + "TARGET_UNALIGNED_WORD"
10899 + {
10900 + }
10901 +)
10902 +
10903 +(define_expand "mov<mode>"
10904 + [(set (match_operand:MOVM 0 "register_operand" "")
10905 + (match_operand:MOVM 1 "general_operand" ""))]
10906 + ""
10907 + {
10908 +
10909 + /* One of the ops has to be in a register. */
10910 + if (GET_CODE (operands[0]) == MEM)
10911 + operands[1] = force_reg (<MODE>mode, operands[1]);
10912 +
10913 +
10914 + /* Check for out of range immediate constants as these may
10915 + occur during reloading, since it seems like reload does
10916 + not check if the immediate is legitimate. Don't know if
10917 + this is a bug? */
10918 + if ( reload_in_progress
10919 + && avr32_arch->arch_type != ARCH_TYPE_AVR32_UC
10920 + && GET_CODE(operands[1]) == CONST_INT
10921 + && !avr32_const_ok_for_constraint_p(INTVAL(operands[1]), 'K', "Ks21") ){
10922 + operands[1] = force_const_mem(SImode, operands[1]);
10923 + }
10924 +
10925 + if ( (flag_pic || TARGET_HAS_ASM_ADDR_PSEUDOS)
10926 + && !avr32_legitimate_pic_operand_p(operands[1]) )
10927 + operands[1] = legitimize_pic_address (operands[1], <MODE>mode,
10928 + (no_new_pseudos ? operands[0] : 0));
10929 + else if ( flag_pic && avr32_address_operand(operands[1], GET_MODE(operands[1])) )
10930 + /* If we have an address operand then this function uses the pic register. */
10931 + current_function_uses_pic_offset_table = 1;
10932 + })
10933 +
10934 +
10935 +(define_insn "mov<mode>_internal"
10936 + [(set (match_operand:MOVM 0 "nonimmediate_operand" "=r, r, r,r,m,r")
10937 + (match_operand:MOVM 1 "general_operand" "rKs08,Ks21,n,m,r,W"))]
10938 + ""
10939 + {
10940 + switch (which_alternative) {
10941 + case 0:
10942 + case 1: return "mov\t%0, %1";
10943 + case 2: return "mov\t%0, lo(%1)\;orh\t%0,hi(%1)";
10944 + case 3:
10945 + if ( (REG_P(XEXP(operands[1], 0))
10946 + && REGNO(XEXP(operands[1], 0)) == SP_REGNUM)
10947 + || (GET_CODE(XEXP(operands[1], 0)) == PLUS
10948 + && REGNO(XEXP(XEXP(operands[1], 0), 0)) == SP_REGNUM
10949 + && GET_CODE(XEXP(XEXP(operands[1], 0), 1)) == CONST_INT
10950 + && INTVAL(XEXP(XEXP(operands[1], 0), 1)) % 4 == 0
10951 + && INTVAL(XEXP(XEXP(operands[1], 0), 1)) <= 0x1FC) )
10952 + return "lddsp\t%0, %1";
10953 + else if ( avr32_const_pool_ref_operand(operands[1], GET_MODE(operands[1])) )
10954 + return "lddpc\t%0, %1";
10955 + else
10956 + return "ld.w\t%0, %1";
10957 + case 4:
10958 + if ( (REG_P(XEXP(operands[0], 0))
10959 + && REGNO(XEXP(operands[0], 0)) == SP_REGNUM)
10960 + || (GET_CODE(XEXP(operands[0], 0)) == PLUS
10961 + && REGNO(XEXP(XEXP(operands[0], 0), 0)) == SP_REGNUM
10962 + && GET_CODE(XEXP(XEXP(operands[0], 0), 1)) == CONST_INT
10963 + && INTVAL(XEXP(XEXP(operands[0], 0), 1)) % 4 == 0
10964 + && INTVAL(XEXP(XEXP(operands[0], 0), 1)) <= 0x1FC) )
10965 + return "stdsp\t%0, %1";
10966 + else
10967 + return "st.w\t%0, %1";
10968 + case 5:
10969 + if ( TARGET_HAS_ASM_ADDR_PSEUDOS )
10970 + return "lda.w\t%0, %1";
10971 + else
10972 + return "ld.w\t%0, r6[%1@got]";
10973 + default:
10974 + abort();
10975 + }
10976 + }
10977 +
10978 + [(set_attr "length" "2,4,8,4,4,8")
10979 + (set_attr "type" "alu,alu,alu2,load,store,load")
10980 + (set_attr "cc" "none,none,set_z,none,none,clobber")])
10981 +
10982 +
10983 +;; These instructions are for loading constants which cannot be loaded
10984 +;; directly from the constant pool because the offset is too large
10985 +;; high and lo_sum are used even tough for our case it should be
10986 +;; low and high sum :-)
10987 +(define_insn "mov_symbol_lo"
10988 + [(set (match_operand:SI 0 "register_operand" "=r")
10989 + (high:SI (match_operand:SI 1 "immediate_operand" "i" )))]
10990 + ""
10991 + "mov\t%0, lo(%1)"
10992 + [(set_attr "type" "alu")
10993 + (set_attr "length" "4")]
10994 +)
10995 +
10996 +(define_insn "add_symbol_hi"
10997 + [(set (match_operand:SI 0 "register_operand" "=r")
10998 + (lo_sum:SI (match_dup 0)
10999 + (match_operand:SI 1 "immediate_operand" "i" )))]
11000 + ""
11001 + "orh\t%0, hi(%1)"
11002 + [(set_attr "type" "alu")
11003 + (set_attr "length" "4")]
11004 +)
11005 +
11006 +
11007 +
11008 +;; When generating pic, we need to load the symbol offset into a register.
11009 +;; So that the optimizer does not confuse this with a normal symbol load
11010 +;; we use an unspec. The offset will be loaded from a constant pool entry,
11011 +;; since that is the only type of relocation we can use.
11012 +(define_insn "pic_load_addr"
11013 + [(set (match_operand:SI 0 "register_operand" "=r")
11014 + (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PIC_SYM))]
11015 + "flag_pic && CONSTANT_POOL_ADDRESS_P(XEXP(operands[1], 0))"
11016 + "lddpc\t%0, %1"
11017 + [(set_attr "type" "load")
11018 + (set_attr "length" "4")]
11019 +)
11020 +
11021 +(define_insn "pic_compute_got_from_pc"
11022 + [(set (match_operand:SI 0 "register_operand" "+r")
11023 + (unspec:SI [(minus:SI (pc)
11024 + (match_dup 0))] UNSPEC_PIC_BASE))
11025 + (use (label_ref (match_operand 1 "" "")))]
11026 + "flag_pic"
11027 + {
11028 + (*targetm.asm_out.internal_label) (asm_out_file, "L",
11029 + CODE_LABEL_NUMBER (operands[1]));
11030 + return \"rsub\t%0, pc\";
11031 + }
11032 + [(set_attr "cc" "clobber")
11033 + (set_attr "length" "2")]
11034 +)
11035 +
11036 +;;== long long int - 64 bits ==================================================
11037 +
11038 +(define_expand "movdi"
11039 + [(set (match_operand:DI 0 "nonimmediate_operand" "")
11040 + (match_operand:DI 1 "general_operand" ""))]
11041 + ""
11042 + {
11043 +
11044 + /* One of the ops has to be in a register. */
11045 + if (GET_CODE (operands[0]) != REG)
11046 + operands[1] = force_reg (DImode, operands[1]);
11047 +
11048 + })
11049 +
11050 +
11051 +(define_insn_and_split "*movdi_internal"
11052 + [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r, r, r,r,r,m")
11053 + (match_operand:DI 1 "general_operand" "r, Ks08,Ks21,G,n,m,r"))]
11054 + ""
11055 + {
11056 + switch (which_alternative ){
11057 + case 0:
11058 + case 1:
11059 + case 2:
11060 + case 3:
11061 + case 4:
11062 + return "#";
11063 + case 5:
11064 + if ( avr32_const_pool_ref_operand(operands[1], GET_MODE(operands[1])))
11065 + return "ld.d\t%0, pc[%1 - .]";
11066 + else
11067 + return "ld.d\t%0, %1";
11068 + case 6:
11069 + return "st.d\t%0, %1";
11070 + default:
11071 + abort();
11072 + }
11073 + }
11074 +;; Lets split all reg->reg or imm->reg transfers into two SImode transfers
11075 + "reload_completed &&
11076 + (REG_P (operands[0]) &&
11077 + (REG_P (operands[1])
11078 + || GET_CODE (operands[1]) == CONST_INT
11079 + || GET_CODE (operands[1]) == CONST_DOUBLE))"
11080 + [(set (match_dup 0) (match_dup 1))
11081 + (set (match_dup 2) (match_dup 3))]
11082 + {
11083 + operands[2] = gen_highpart (SImode, operands[0]);
11084 + operands[0] = gen_lowpart (SImode, operands[0]);
11085 + if ( REG_P(operands[1]) ){
11086 + operands[3] = gen_highpart(SImode, operands[1]);
11087 + operands[1] = gen_lowpart(SImode, operands[1]);
11088 + } else if ( GET_CODE(operands[1]) == CONST_DOUBLE
11089 + || GET_CODE(operands[1]) == CONST_INT ){
11090 + rtx split_const[2];
11091 + avr32_split_const_expr (DImode, SImode, operands[1], split_const);
11092 + operands[3] = split_const[1];
11093 + operands[1] = split_const[0];
11094 + } else {
11095 + internal_error("Illegal operand[1] for movdi split!");
11096 + }
11097 + }
11098 +
11099 + [(set_attr "length" "*,*,*,*,*,4,4")
11100 + (set_attr "type" "*,*,*,*,*,load2,store2")
11101 + (set_attr "cc" "*,*,*,*,*,none,none")])
11102 +
11103 +
11104 +;;== 128 bits ==================================================
11105 +(define_expand "movti"
11106 + [(set (match_operand:TI 0 "nonimmediate_operand" "")
11107 + (match_operand:TI 1 "nonimmediate_operand" ""))]
11108 + ""
11109 + {
11110 +
11111 + /* One of the ops has to be in a register. */
11112 + if (GET_CODE (operands[0]) != REG)
11113 + operands[1] = force_reg (TImode, operands[1]);
11114 +
11115 + /* We must fix any pre_dec for loads and post_inc stores */
11116 + if ( GET_CODE (operands[0]) == MEM
11117 + && GET_CODE (XEXP(operands[0],0)) == POST_INC ){
11118 + emit_move_insn(gen_rtx_MEM(TImode, XEXP(XEXP(operands[0],0),0)), operands[1]);
11119 + emit_insn(gen_addsi3(XEXP(XEXP(operands[0],0),0), XEXP(XEXP(operands[0],0),0), GEN_INT(GET_MODE_SIZE(TImode))));
11120 + DONE;
11121 + }
11122 +
11123 + if ( GET_CODE (operands[1]) == MEM
11124 + && GET_CODE (XEXP(operands[1],0)) == PRE_DEC ){
11125 + emit_insn(gen_addsi3(XEXP(XEXP(operands[1],0),0), XEXP(XEXP(operands[1],0),0), GEN_INT(-GET_MODE_SIZE(TImode))));
11126 + emit_move_insn(operands[0], gen_rtx_MEM(TImode, XEXP(XEXP(operands[1],0),0)));
11127 + DONE;
11128 + }
11129 + })
11130 +
11131 +
11132 +(define_insn_and_split "*movti_internal"
11133 + [(set (match_operand:TI 0 "avr32_movti_dst_operand" "=r,r,<RKu00,r,r")
11134 + (match_operand:TI 1 "avr32_movti_src_operand" " r,RKu00>,r,n,m"))]
11135 + ""
11136 + {
11137 + switch (which_alternative ){
11138 + case 0:
11139 + case 3:
11140 + return "#";
11141 + case 1:
11142 + return "ldm\t%p1, %0";
11143 + case 2:
11144 + return "stm\t%p0, %1";
11145 + case 4:
11146 + return "ld.d\t%U0, pc[%1 - .]\;ld.d\t%B0, pc[%1 - . + 8]";
11147 + }
11148 + }
11149 +
11150 + "reload_completed &&
11151 + (REG_P (operands[0]) &&
11152 + (REG_P (operands[1])
11153 + || (GET_CODE (operands[1]) == MEM
11154 + && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
11155 + && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0)))
11156 + || GET_CODE (operands[1]) == CONST_INT
11157 + || GET_CODE (operands[1]) == CONST_DOUBLE))"
11158 + [(set (match_dup 0) (match_dup 1))
11159 + (set (match_dup 2) (match_dup 3))]
11160 + {
11161 + operands[2] = simplify_gen_subreg ( DImode, operands[0],
11162 + TImode, 0 );
11163 + operands[0] = simplify_gen_subreg ( DImode, operands[0],
11164 + TImode, 8 );
11165 + if ( REG_P(operands[1]) ){
11166 + operands[3] = simplify_gen_subreg ( DImode, operands[1],
11167 + TImode, 0 );
11168 + operands[1] = simplify_gen_subreg ( DImode, operands[1],
11169 + TImode, 8 );
11170 + } else if ( GET_CODE(operands[1]) == CONST_DOUBLE
11171 + || GET_CODE(operands[1]) == CONST_INT ){
11172 + rtx split_const[2];
11173 + avr32_split_const_expr (TImode, DImode, operands[1], split_const);
11174 + operands[3] = split_const[1];
11175 + operands[1] = split_const[0];
11176 + } else if (avr32_const_pool_ref_operand (operands[1], GET_MODE(operands[1]))){
11177 + rtx split_const[2];
11178 + rtx cop = avoid_constant_pool_reference (operands[1]);
11179 + if (operands[1] == cop)
11180 + cop = get_pool_constant (XEXP (operands[1], 0));
11181 + avr32_split_const_expr (TImode, DImode, cop, split_const);
11182 + operands[3] = force_const_mem (DImode, split_const[1]);
11183 + operands[1] = force_const_mem (DImode, split_const[0]);
11184 + } else {
11185 + internal_error("Illegal operand[1] for movdi split!");
11186 + }
11187 + }
11188 + [(set_attr "length" "*,4,4,*,8")
11189 + (set_attr "type" "*,load4,store4,*,load4")])
11190 +
11191 +
11192 +;;== float - 32 bits ==========================================================
11193 +(define_expand "movsf"
11194 + [(set (match_operand:SF 0 "nonimmediate_operand" "")
11195 + (match_operand:SF 1 "general_operand" ""))]
11196 + ""
11197 + {
11198 +
11199 +
11200 + /* One of the ops has to be in a register. */
11201 + if (GET_CODE (operands[0]) != REG)
11202 + operands[1] = force_reg (SFmode, operands[1]);
11203 +
11204 + })
11205 +
11206 +(define_insn "*movsf_internal"
11207 + [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,r,r,m")
11208 + (match_operand:SF 1 "general_operand" "r, G,F,m,r"))]
11209 + "TARGET_SOFT_FLOAT"
11210 + {
11211 + switch (which_alternative) {
11212 + case 0:
11213 + case 1: return "mov\t%0, %1";
11214 + case 2: return "mov\t%0, lo(%1)\;orh\t%0, hi(%1)";
11215 + case 3:
11216 + if ( (REG_P(XEXP(operands[1], 0))
11217 + && REGNO(XEXP(operands[1], 0)) == SP_REGNUM)
11218 + || (GET_CODE(XEXP(operands[1], 0)) == PLUS
11219 + && REGNO(XEXP(XEXP(operands[1], 0), 0)) == SP_REGNUM
11220 + && GET_CODE(XEXP(XEXP(operands[1], 0), 1)) == CONST_INT
11221 + && INTVAL(XEXP(XEXP(operands[1], 0), 1)) % 4 == 0
11222 + && INTVAL(XEXP(XEXP(operands[1], 0), 1)) <= 0x1FC) )
11223 + return "lddsp\t%0, %1";
11224 + else if ( avr32_const_pool_ref_operand(operands[1], GET_MODE(operands[1])) )
11225 + return "lddpc\t%0, %1";
11226 + else
11227 + return "ld.w\t%0, %1";
11228 + case 4:
11229 + if ( (REG_P(XEXP(operands[0], 0))
11230 + && REGNO(XEXP(operands[0], 0)) == SP_REGNUM)
11231 + || (GET_CODE(XEXP(operands[0], 0)) == PLUS
11232 + && REGNO(XEXP(XEXP(operands[0], 0), 0)) == SP_REGNUM
11233 + && GET_CODE(XEXP(XEXP(operands[0], 0), 1)) == CONST_INT
11234 + && INTVAL(XEXP(XEXP(operands[0], 0), 1)) % 4 == 0
11235 + && INTVAL(XEXP(XEXP(operands[0], 0), 1)) <= 0x1FC) )
11236 + return "stdsp\t%0, %1";
11237 + else
11238 + return "st.w\t%0, %1";
11239 + default:
11240 + abort();
11241 + }
11242 + }
11243 +
11244 + [(set_attr "length" "2,4,8,4,4")
11245 + (set_attr "type" "alu,alu,alu2,load,store")
11246 + (set_attr "cc" "none,none,clobber,none,none")])
11247 +
11248 +
11249 +
11250 +;;== double - 64 bits =========================================================
11251 +(define_expand "movdf"
11252 + [(set (match_operand:DF 0 "nonimmediate_operand" "")
11253 + (match_operand:DF 1 "general_operand" ""))]
11254 + ""
11255 + {
11256 + /* One of the ops has to be in a register. */
11257 + if (GET_CODE (operands[0]) != REG){
11258 + operands[1] = force_reg (DFmode, operands[1]);
11259 + }
11260 + })
11261 +
11262 +
11263 +(define_insn_and_split "*movdf_internal"
11264 + [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,r,r,m")
11265 + (match_operand:DF 1 "general_operand" " r,G,F,m,r"))]
11266 + "TARGET_SOFT_FLOAT"
11267 + {
11268 + switch (which_alternative ){
11269 + case 0:
11270 + case 1:
11271 + case 2:
11272 + return "#";
11273 + case 3:
11274 + if ( avr32_const_pool_ref_operand(operands[1], GET_MODE(operands[1])))
11275 + return "ld.d\t%0, pc[%1 - .]";
11276 + else
11277 + return "ld.d\t%0, %1";
11278 + case 4:
11279 + return "st.d\t%0, %1";
11280 + default:
11281 + abort();
11282 + }
11283 + }
11284 + "TARGET_SOFT_FLOAT
11285 + && reload_completed
11286 + && (REG_P (operands[0])
11287 + && (REG_P (operands[1])
11288 + || GET_CODE (operands[1]) == CONST_DOUBLE))"
11289 + [(set (match_dup 0) (match_dup 1))
11290 + (set (match_dup 2) (match_dup 3))]
11291 + "
11292 + {
11293 + operands[2] = gen_highpart (SImode, operands[0]);
11294 + operands[0] = gen_lowpart (SImode, operands[0]);
11295 + operands[3] = gen_highpart(SImode, operands[1]);
11296 + operands[1] = gen_lowpart(SImode, operands[1]);
11297 + }
11298 + "
11299 +
11300 + [(set_attr "length" "*,*,*,4,4")
11301 + (set_attr "type" "*,*,*,load2,store2")
11302 + (set_attr "cc" "*,*,*,none,none")])
11303 +
11304 +
11305 +
11306 +
11307 +;;=============================================================================
11308 +;; Move chunks of memory
11309 +;;=============================================================================
11310 +
11311 +(define_expand "movmemsi"
11312 + [(match_operand:BLK 0 "general_operand" "")
11313 + (match_operand:BLK 1 "general_operand" "")
11314 + (match_operand:SI 2 "const_int_operand" "")
11315 + (match_operand:SI 3 "const_int_operand" "")]
11316 + ""
11317 + "
11318 + if (avr32_gen_movmemsi (operands))
11319 + DONE;
11320 + FAIL;
11321 + "
11322 +
11323 + )
11324 +
11325 +
11326 +
11327 +;;=============================================================================
11328 +;; Bit field instructions
11329 +;;-----------------------------------------------------------------------------
11330 +;; Instructions to insert or extract bit-fields
11331 +;;=============================================================================
11332 +
11333 +(define_insn "insv"
11334 + [ (set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
11335 + (match_operand:SI 1 "immediate_operand" "Ku05")
11336 + (match_operand:SI 2 "immediate_operand" "Ku05"))
11337 + (match_operand 3 "register_operand" "r"))]
11338 + ""
11339 + "bfins\t%0, %3, %2, %1"
11340 + [(set_attr "type" "alu")
11341 + (set_attr "length" "4")
11342 + (set_attr "cc" "set_ncz")])
11343 +
11344 +
11345 +
11346 +(define_expand "extv"
11347 + [ (set (match_operand:SI 0 "register_operand" "")
11348 + (sign_extract:SI (match_operand:SI 1 "register_operand" "")
11349 + (match_operand:SI 2 "immediate_operand" "")
11350 + (match_operand:SI 3 "immediate_operand" "")))]
11351 + ""
11352 + {
11353 + if ( INTVAL(operands[2]) >= 32 )
11354 + FAIL;
11355 + }
11356 +)
11357 +
11358 +(define_expand "extzv"
11359 + [ (set (match_operand:SI 0 "register_operand" "")
11360 + (zero_extract:SI (match_operand:SI 1 "register_operand" "")
11361 + (match_operand:SI 2 "immediate_operand" "")
11362 + (match_operand:SI 3 "immediate_operand" "")))]
11363 + ""
11364 + {
11365 + if ( INTVAL(operands[2]) >= 32 )
11366 + FAIL;
11367 + }
11368 +)
11369 +
11370 +(define_insn "extv_internal"
11371 + [ (set (match_operand:SI 0 "register_operand" "=r")
11372 + (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
11373 + (match_operand:SI 2 "immediate_operand" "Ku05")
11374 + (match_operand:SI 3 "immediate_operand" "Ku05")))]
11375 + "INTVAL(operands[2]) < 32"
11376 + "bfexts\t%0, %1, %3, %2"
11377 + [(set_attr "type" "alu")
11378 + (set_attr "length" "4")
11379 + (set_attr "cc" "set_ncz")])
11380 +
11381 +
11382 +(define_insn "extzv_internal"
11383 + [ (set (match_operand:SI 0 "register_operand" "=r")
11384 + (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
11385 + (match_operand:SI 2 "immediate_operand" "Ku05")
11386 + (match_operand:SI 3 "immediate_operand" "Ku05")))]
11387 + "INTVAL(operands[2]) < 32"
11388 + "bfextu\t%0, %1, %3, %2"
11389 + [(set_attr "type" "alu")
11390 + (set_attr "length" "4")
11391 + (set_attr "cc" "set_ncz")])
11392 +
11393 +
11394 +
11395 +;;=============================================================================
11396 +;; Some peepholes for avoiding unnecessary cast instructions
11397 +;; followed by bfins.
11398 +;;-----------------------------------------------------------------------------
11399 +
11400 +(define_peephole2
11401 + [(set (match_operand:SI 0 "register_operand" "")
11402 + (zero_extend:SI (match_operand:QI 1 "register_operand" "")))
11403 + (set (zero_extract:SI (match_operand 2 "register_operand" "")
11404 + (match_operand:SI 3 "immediate_operand" "")
11405 + (match_operand:SI 4 "immediate_operand" ""))
11406 + (match_dup 0))]
11407 + "((peep2_reg_dead_p(2, operands[0]) &&
11408 + (INTVAL(operands[3]) <= 8)))"
11409 + [(set (zero_extract:SI (match_dup 2)
11410 + (match_dup 3)
11411 + (match_dup 4))
11412 + (match_dup 1))]
11413 + )
11414 +
11415 +(define_peephole2
11416 + [(set (match_operand:SI 0 "register_operand" "")
11417 + (zero_extend:SI (match_operand:HI 1 "register_operand" "")))
11418 + (set (zero_extract:SI (match_operand 2 "register_operand" "")
11419 + (match_operand:SI 3 "immediate_operand" "")
11420 + (match_operand:SI 4 "immediate_operand" ""))
11421 + (match_dup 0))]
11422 + "((peep2_reg_dead_p(2, operands[0]) &&
11423 + (INTVAL(operands[3]) <= 16)))"
11424 + [(set (zero_extract:SI (match_dup 2)
11425 + (match_dup 3)
11426 + (match_dup 4))
11427 + (match_dup 1))]
11428 + )
11429 +
11430 +;;=============================================================================
11431 +;; push bytes
11432 +;;-----------------------------------------------------------------------------
11433 +;; Implements the push instruction
11434 +;;=============================================================================
11435 +(define_insn "pushm"
11436 + [(set (mem:BLK (pre_dec:BLK (reg:SI SP_REGNUM)))
11437 + (unspec:BLK [(match_operand 0 "const_int_operand" "")]
11438 + UNSPEC_PUSHM))]
11439 + ""
11440 + {
11441 + if (INTVAL(operands[0])) {
11442 + return "pushm\t%r0";
11443 + } else {
11444 + return "";
11445 + }
11446 + }
11447 + [(set_attr "type" "store")
11448 + (set_attr "length" "2")
11449 + (set_attr "cc" "none")])
11450 +
11451 +(define_insn "stm"
11452 + [(unspec [(match_operand 0 "register_operand" "r")
11453 + (match_operand 1 "const_int_operand" "")
11454 + (match_operand 2 "const_int_operand" "")]
11455 + UNSPEC_STM)]
11456 + ""
11457 + {
11458 + if (INTVAL(operands[1])) {
11459 + if (INTVAL(operands[2]) != 0)
11460 + return "stm\t--%0, %s1";
11461 + else
11462 + return "stm\t%0, %s1";
11463 + } else {
11464 + return "";
11465 + }
11466 + }
11467 + [(set_attr "type" "store")
11468 + (set_attr "length" "4")
11469 + (set_attr "cc" "none")])
11470 +
11471 +
11472 +
11473 +(define_insn "popm"
11474 + [(unspec [(match_operand 0 "const_int_operand" "")]
11475 + UNSPEC_POPM)]
11476 + ""
11477 + {
11478 + if (INTVAL(operands[0])) {
11479 + return "popm %r0";
11480 + } else {
11481 + return "";
11482 + }
11483 + }
11484 + [(set_attr "type" "load")
11485 + (set_attr "length" "2")])
11486 +
11487 +
11488 +
11489 +;;=============================================================================
11490 +;; add
11491 +;;-----------------------------------------------------------------------------
11492 +;; Adds reg1 with reg2 and puts the result in reg0.
11493 +;;=============================================================================
11494 +(define_insn "add<mode>3"
11495 + [(set (match_operand:INTM 0 "register_operand" "=r,r,r,r,r")
11496 + (plus:INTM (match_operand:INTM 1 "register_operand" "%0,r,0,r,0")
11497 + (match_operand:INTM 2 "avr32_add_operand" "r,r,Is08,Is16,Is21")))]
11498 + ""
11499 + "@
11500 + add %0, %2
11501 + add %0, %1, %2
11502 + sub %0, %n2
11503 + sub %0, %1, %n2
11504 + sub %0, %n2"
11505 +
11506 + [(set_attr "length" "2,4,2,4,4")
11507 + (set_attr "cc" "<INTM:alu_cc_attr>")])
11508 +
11509 +(define_insn "add<mode>3_lsl"
11510 + [(set (match_operand:INTM 0 "register_operand" "=r")
11511 + (plus:INTM (ashift:INTM (match_operand:INTM 1 "register_operand" "r")
11512 + (match_operand:INTM 3 "avr32_add_shift_immediate_operand" "Ku02"))
11513 + (match_operand:INTM 2 "register_operand" "r")))]
11514 + ""
11515 + "add %0, %2, %1 << %3"
11516 + [(set_attr "length" "4")
11517 + (set_attr "cc" "<INTM:alu_cc_attr>")])
11518 +
11519 +(define_insn "add<mode>3_lsl2"
11520 + [(set (match_operand:INTM 0 "register_operand" "=r")
11521 + (plus:INTM (match_operand:INTM 1 "register_operand" "r")
11522 + (ashift:INTM (match_operand:INTM 2 "register_operand" "r")
11523 + (match_operand:INTM 3 "avr32_add_shift_immediate_operand" "Ku02"))))]
11524 + ""
11525 + "add %0, %1, %2 << %3"
11526 + [(set_attr "length" "4")
11527 + (set_attr "cc" "<INTM:alu_cc_attr>")])
11528 +
11529 +
11530 +
11531 +(define_insn "add<mode>3_mul"
11532 + [(set (match_operand:INTM 0 "register_operand" "=r")
11533 + (plus:INTM (mult:INTM (match_operand:INTM 1 "register_operand" "r")
11534 + (match_operand:INTM 3 "immediate_operand" "Ku04" ))
11535 + (match_operand:INTM 2 "register_operand" "r")))]
11536 + "(INTVAL(operands[3]) == 0) || (INTVAL(operands[3]) == 2) ||
11537 + (INTVAL(operands[3]) == 4) || (INTVAL(operands[3]) == 8)"
11538 + "add %0, %2, %1 << %p3"
11539 + [(set_attr "length" "4")
11540 + (set_attr "cc" "<INTM:alu_cc_attr>")])
11541 +
11542 +(define_insn "add<mode>3_mul2"
11543 + [(set (match_operand:INTM 0 "register_operand" "=r")
11544 + (plus:INTM (match_operand:INTM 1 "register_operand" "r")
11545 + (mult:INTM (match_operand:INTM 2 "register_operand" "r")
11546 + (match_operand:INTM 3 "immediate_operand" "Ku04" ))))]
11547 + "(INTVAL(operands[3]) == 0) || (INTVAL(operands[3]) == 2) ||
11548 + (INTVAL(operands[3]) == 4) || (INTVAL(operands[3]) == 8)"
11549 + "add %0, %1, %2 << %p3"
11550 + [(set_attr "length" "4")
11551 + (set_attr "cc" "<INTM:alu_cc_attr>")])
11552 +
11553 +
11554 +(define_peephole2
11555 + [(set (match_operand:SI 0 "register_operand" "")
11556 + (ashift:SI (match_operand:SI 1 "register_operand" "")
11557 + (match_operand:SI 2 "immediate_operand" "")))
11558 + (set (match_operand:SI 3 "register_operand" "")
11559 + (plus:SI (match_dup 0)
11560 + (match_operand:SI 4 "register_operand" "")))]
11561 + "(peep2_reg_dead_p(2, operands[0]) &&
11562 + (INTVAL(operands[2]) < 4 && INTVAL(operands[2]) > 0))"
11563 + [(set (match_dup 3)
11564 + (plus:SI (ashift:SI (match_dup 1)
11565 + (match_dup 2))
11566 + (match_dup 4)))]
11567 + )
11568 +
11569 +(define_peephole2
11570 + [(set (match_operand:SI 0 "register_operand" "")
11571 + (ashift:SI (match_operand:SI 1 "register_operand" "")
11572 + (match_operand:SI 2 "immediate_operand" "")))
11573 + (set (match_operand:SI 3 "register_operand" "")
11574 + (plus:SI (match_operand:SI 4 "register_operand" "")
11575 + (match_dup 0)))]
11576 + "(peep2_reg_dead_p(2, operands[0]) &&
11577 + (INTVAL(operands[2]) < 4 && INTVAL(operands[2]) > 0))"
11578 + [(set (match_dup 3)
11579 + (plus:SI (ashift:SI (match_dup 1)
11580 + (match_dup 2))
11581 + (match_dup 4)))]
11582 + )
11583 +
11584 +(define_insn "adddi3"
11585 + [(set (match_operand:DI 0 "register_operand" "=r,r")
11586 + (plus:DI (match_operand:DI 1 "register_operand" "%r,0")
11587 + (match_operand:DI 2 "register_operand" "r,r")))]
11588 + ""
11589 + "@
11590 + add %0, %1, %2\;adc %m0, %m1, %m2
11591 + add %0, %2\;adc %m0, %m0, %m2"
11592 + [(set_attr "length" "8,6")
11593 + (set_attr "type" "alu2")
11594 + (set_attr "cc" "set_vncz")])
11595 +
11596 +
11597 +
11598 +;;=============================================================================
11599 +;; subtract
11600 +;;-----------------------------------------------------------------------------
11601 +;; Subtract reg2 or immediate value from reg0 and puts the result in reg0.
11602 +;;=============================================================================
11603 +
11604 +(define_insn "sub<mode>3"
11605 + [(set (match_operand:INTM 0 "general_operand" "=r,r,r,r,r,r,r")
11606 + (minus:INTM (match_operand:INTM 1 "nonmemory_operand" "0,r,0,r,0,r,Ks08")
11607 + (match_operand:INTM 2 "nonmemory_operand" "r,r,Ks08,Ks16,Ks21,0,r")))]
11608 + ""
11609 + "@
11610 + sub %0, %2
11611 + sub %0, %1, %2
11612 + sub %0, %2
11613 + sub %0, %1, %2
11614 + sub %0, %2
11615 + rsub %0, %1
11616 + rsub %0, %2, %1"
11617 + [(set_attr "length" "2,4,2,4,4,2,4")
11618 + (set_attr "cc" "<INTM:alu_cc_attr>")])
11619 +
11620 +(define_insn "*sub<mode>3_mul"
11621 + [(set (match_operand:INTM 0 "register_operand" "=r,r,r")
11622 + (minus:INTM (match_operand:INTM 1 "register_operand" "r,0,r")
11623 + (mult:INTM (match_operand:INTM 2 "register_operand" "r,r,0")
11624 + (match_operand:SI 3 "immediate_operand" "Ku04,Ku04,Ku04" ))))]
11625 + "(INTVAL(operands[3]) == 0) || (INTVAL(operands[3]) == 2) ||
11626 + (INTVAL(operands[3]) == 4) || (INTVAL(operands[3]) == 8)"
11627 + "@
11628 + sub %0, %1, %2 << %p3
11629 + sub %0, %0, %2 << %p3
11630 + sub %0, %1, %0 << %p3"
11631 + [(set_attr "length" "4,4,4")
11632 + (set_attr "cc" "<INTM:alu_cc_attr>")])
11633 +
11634 +(define_insn "*sub<mode>3_lsl"
11635 + [(set (match_operand:INTM 0 "register_operand" "=r")
11636 + (minus:INTM (match_operand:INTM 1 "register_operand" "r")
11637 + (ashift:INTM (match_operand:INTM 2 "register_operand" "r")
11638 + (match_operand:SI 3 "avr32_add_shift_immediate_operand" "Ku02"))))]
11639 + ""
11640 + "sub %0, %1, %2 << %3"
11641 + [(set_attr "length" "4")
11642 + (set_attr "cc" "<INTM:alu_cc_attr>")])
11643 +
11644 +
11645 +(define_insn "subdi3"
11646 + [(set (match_operand:DI 0 "register_operand" "=r,r")
11647 + (minus:DI (match_operand:DI 1 "register_operand" "%r,0")
11648 + (match_operand:DI 2 "register_operand" "r,r")))]
11649 + ""
11650 + "@
11651 + sub %0, %1, %2\;sbc %m0, %m1, %m2
11652 + sub %0, %2\;sbc %m0, %m0, %m2"
11653 + [(set_attr "length" "8,6")
11654 + (set_attr "type" "alu2")
11655 + (set_attr "cc" "set_vncz")])
11656 +
11657 +
11658 +
11659 +;;=============================================================================
11660 +;; multiply
11661 +;;-----------------------------------------------------------------------------
11662 +;; Multiply op1 and op2 and put the value in op0.
11663 +;;=============================================================================
11664 +
11665 +
11666 +(define_insn "mulqi3"
11667 + [(set (match_operand:QI 0 "register_operand" "=r,r,r")
11668 + (mult:QI (match_operand:QI 1 "register_operand" "%0,r,r")
11669 + (match_operand:QI 2 "avr32_mul_operand" "r,r,Ks08")))]
11670 + ""
11671 + {
11672 + switch (which_alternative){
11673 + case 0:
11674 + return "mul %0, %2";
11675 + case 1:
11676 + return "mul %0, %1, %2";
11677 + case 2:
11678 + return "mul %0, %1, %2";
11679 + default:
11680 + abort();
11681 + }
11682 + }
11683 + [(set_attr "type" "mulww_w,mulww_w,mulwh")
11684 + (set_attr "length" "2,4,4")
11685 + (set_attr "cc" "none")])
11686 +
11687 +(define_insn "mulsi3"
11688 + [(set (match_operand:SI 0 "register_operand" "=r,r,r")
11689 + (mult:SI (match_operand:SI 1 "register_operand" "%0,r,r")
11690 + (match_operand:SI 2 "avr32_mul_operand" "r,r,Ks08")))]
11691 + ""
11692 + {
11693 + switch (which_alternative){
11694 + case 0:
11695 + return "mul %0, %2";
11696 + case 1:
11697 + return "mul %0, %1, %2";
11698 + case 2:
11699 + return "mul %0, %1, %2";
11700 + default:
11701 + abort();
11702 + }
11703 + }
11704 + [(set_attr "type" "mulww_w,mulww_w,mulwh")
11705 + (set_attr "length" "2,4,4")
11706 + (set_attr "cc" "none")])
11707 +
11708 +
11709 +(define_insn "mulhisi3"
11710 + [(set (match_operand:SI 0 "register_operand" "=r")
11711 + (mult:SI
11712 + (sign_extend:SI (match_operand:HI 1 "register_operand" "%r"))
11713 + (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
11714 + "TARGET_DSP"
11715 + "mulhh.w %0, %1:b, %2:b"
11716 + [(set_attr "type" "mulhh")
11717 + (set_attr "length" "4")
11718 + (set_attr "cc" "none")])
11719 +
11720 +(define_peephole2
11721 + [(match_scratch:DI 6 "r")
11722 + (set (match_operand:SI 0 "register_operand" "")
11723 + (mult:SI
11724 + (sign_extend:SI (match_operand:HI 1 "register_operand" ""))
11725 + (sign_extend:SI (match_operand:HI 2 "register_operand" ""))))
11726 + (set (match_operand:SI 3 "register_operand" "")
11727 + (ashiftrt:SI (match_dup 0)
11728 + (const_int 16)))]
11729 + "TARGET_DSP
11730 + && (peep2_reg_dead_p(1, operands[0]) || (REGNO(operands[0]) == REGNO(operands[3])))"
11731 + [(set (match_dup 4) (sign_extend:SI (match_dup 1)))
11732 + (set (match_dup 6)
11733 + (ashift:DI (mult:DI (sign_extend:DI (match_dup 4))
11734 + (sign_extend:DI (match_dup 2)))
11735 + (const_int 16)))
11736 + (set (match_dup 3) (match_dup 5))]
11737 +
11738 + "{
11739 + operands[4] = gen_rtx_REG(SImode, REGNO(operands[1]));
11740 + operands[5] = gen_highpart (SImode, operands[4]);
11741 + }"
11742 + )
11743 +
11744 +(define_insn "mulnhisi3"
11745 + [(set (match_operand:SI 0 "register_operand" "=r")
11746 + (mult:SI
11747 + (sign_extend:SI (neg:HI (match_operand:HI 1 "register_operand" "r")))
11748 + (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
11749 + "TARGET_DSP"
11750 + "mulnhh.w %0, %1:b, %2:b"
11751 + [(set_attr "type" "mulhh")
11752 + (set_attr "length" "4")
11753 + (set_attr "cc" "none")])
11754 +
11755 +(define_insn "machisi3"
11756 + [(set (match_operand:SI 0 "register_operand" "+r")
11757 + (plus:SI (mult:SI
11758 + (sign_extend:SI (match_operand:HI 1 "register_operand" "%r"))
11759 + (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))
11760 + (match_dup 0)))]
11761 + "TARGET_DSP"
11762 + "machh.w %0, %1:b, %2:b"
11763 + [(set_attr "type" "machh_w")
11764 + (set_attr "length" "4")
11765 + (set_attr "cc" "none")])
11766 +
11767 +
11768 +
11769 +(define_insn "mulsidi3"
11770 + [(set (match_operand:DI 0 "register_operand" "=r")
11771 + (mult:DI
11772 + (sign_extend:DI (match_operand:SI 1 "register_operand" "%r"))
11773 + (sign_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
11774 + ""
11775 + "muls.d %0, %1, %2"
11776 + [(set_attr "type" "mulww_d")
11777 + (set_attr "length" "4")
11778 + (set_attr "cc" "none")])
11779 +
11780 +(define_insn "umulsidi3"
11781 + [(set (match_operand:DI 0 "register_operand" "=r")
11782 + (mult:DI
11783 + (zero_extend:DI (match_operand:SI 1 "register_operand" "%r"))
11784 + (zero_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
11785 + ""
11786 + "mulu.d %0, %1, %2"
11787 + [(set_attr "type" "mulww_d")
11788 + (set_attr "length" "4")
11789 + (set_attr "cc" "none")])
11790 +
11791 +(define_insn "*mulaccsi3"
11792 + [(set (match_operand:SI 0 "register_operand" "+r")
11793 + (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "%r")
11794 + (match_operand:SI 2 "register_operand" "r"))
11795 + (match_dup 0)))]
11796 + ""
11797 + "mac %0, %1, %2"
11798 + [(set_attr "type" "macww_w")
11799 + (set_attr "length" "4")
11800 + (set_attr "cc" "none")])
11801 +
11802 +(define_insn "mulaccsidi3"
11803 + [(set (match_operand:DI 0 "register_operand" "+r")
11804 + (plus:DI (mult:DI
11805 + (sign_extend:DI (match_operand:SI 1 "register_operand" "%r"))
11806 + (sign_extend:DI (match_operand:SI 2 "register_operand" "r")))
11807 + (match_dup 0)))]
11808 + ""
11809 + "macs.d %0, %1, %2"
11810 + [(set_attr "type" "macww_d")
11811 + (set_attr "length" "4")
11812 + (set_attr "cc" "none")])
11813 +
11814 +(define_insn "umulaccsidi3"
11815 + [(set (match_operand:DI 0 "register_operand" "+r")
11816 + (plus:DI (mult:DI
11817 + (zero_extend:DI (match_operand:SI 1 "register_operand" "%r"))
11818 + (zero_extend:DI (match_operand:SI 2 "register_operand" "r")))
11819 + (match_dup 0)))]
11820 + ""
11821 + "macu.d %0, %1, %2"
11822 + [(set_attr "type" "macww_d")
11823 + (set_attr "length" "4")
11824 + (set_attr "cc" "none")])
11825 +
11826 +
11827 +
11828 +;; Try to avoid Write-After-Write hazards for mul operations
11829 +;; if it can be done
11830 +(define_peephole2
11831 + [(set (match_operand:SI 0 "register_operand" "")
11832 + (mult:SI
11833 + (sign_extend:SI (match_operand 1 "general_operand" ""))
11834 + (sign_extend:SI (match_operand 2 "general_operand" ""))))
11835 + (set (match_dup 0)
11836 + (match_operator:SI 3 "alu_operator" [(match_dup 0)
11837 + (match_operand 4 "general_operand" "")]))]
11838 + "peep2_reg_dead_p(1, operands[2])"
11839 + [(set (match_dup 5)
11840 + (mult:SI
11841 + (sign_extend:SI (match_dup 1))
11842 + (sign_extend:SI (match_dup 2))))
11843 + (set (match_dup 0)
11844 + (match_op_dup 3 [(match_dup 5)
11845 + (match_dup 4)]))]
11846 + "{operands[5] = gen_rtx_REG(SImode, REGNO(operands[2]));}"
11847 + )
11848 +
11849 +
11850 +
11851 +;;=============================================================================
11852 +;; DSP instructions
11853 +;;=============================================================================
11854 +(define_insn "mulsathh_h"
11855 + [(set (match_operand:HI 0 "register_operand" "=r")
11856 + (ss_truncate:HI (ashiftrt:SI (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%r"))
11857 + (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))
11858 + (const_int 15))))]
11859 + "TARGET_DSP"
11860 + "mulsathh.h\t%0, %1:b, %2:b"
11861 + [(set_attr "length" "4")
11862 + (set_attr "cc" "none")
11863 + (set_attr "type" "mulhh")])
11864 +
11865 +(define_insn "mulsatrndhh_h"
11866 + [(set (match_operand:HI 0 "register_operand" "=r")
11867 + (ss_truncate:HI (ashiftrt:SI
11868 + (plus:SI (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%r"))
11869 + (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))
11870 + (const_int 1073741824))
11871 + (const_int 15))))]
11872 + "TARGET_DSP"
11873 + "mulsatrndhh.h\t%0, %1:b, %2:b"
11874 + [(set_attr "length" "4")
11875 + (set_attr "cc" "none")
11876 + (set_attr "type" "mulhh")])
11877 +
11878 +(define_insn "mulsathh_w"
11879 + [(set (match_operand:SI 0 "register_operand" "=r")
11880 + (ss_truncate:SI (ashift:DI (mult:DI (sign_extend:DI (match_operand:HI 1 "register_operand" "%r"))
11881 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
11882 + (const_int 1))))]
11883 + "TARGET_DSP"
11884 + "mulsathh.w\t%0, %1:b, %2:b"
11885 + [(set_attr "length" "4")
11886 + (set_attr "cc" "none")
11887 + (set_attr "type" "mulhh")])
11888 +
11889 +(define_insn "mulsatwh_w"
11890 + [(set (match_operand:SI 0 "register_operand" "=r")
11891 + (ss_truncate:SI (ashiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
11892 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
11893 + (const_int 15))))]
11894 + "TARGET_DSP"
11895 + "mulsatwh.w\t%0, %1, %2:b"
11896 + [(set_attr "length" "4")
11897 + (set_attr "cc" "none")
11898 + (set_attr "type" "mulwh")])
11899 +
11900 +(define_insn "mulsatrndwh_w"
11901 + [(set (match_operand:SI 0 "register_operand" "=r")
11902 + (ss_truncate:SI (ashiftrt:DI (plus:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
11903 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
11904 + (const_int 1073741824))
11905 + (const_int 15))))]
11906 + "TARGET_DSP"
11907 + "mulsatrndwh.w\t%0, %1, %2:b"
11908 + [(set_attr "length" "4")
11909 + (set_attr "cc" "none")
11910 + (set_attr "type" "mulwh")])
11911 +
11912 +(define_insn "macsathh_w"
11913 + [(set (match_operand:SI 0 "register_operand" "+r")
11914 + (plus:SI (match_dup 0)
11915 + (ss_truncate:SI (ashift:DI (mult:DI (sign_extend:DI (match_operand:HI 1 "register_operand" "%r"))
11916 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
11917 + (const_int 1)))))]
11918 + "TARGET_DSP"
11919 + "macsathh.w\t%0, %1:b, %2:b"
11920 + [(set_attr "length" "4")
11921 + (set_attr "cc" "none")
11922 + (set_attr "type" "mulhh")])
11923 +
11924 +
11925 +(define_insn "mulwh_d"
11926 + [(set (match_operand:DI 0 "register_operand" "=r")
11927 + (ashift:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
11928 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
11929 + (const_int 16)))]
11930 + "TARGET_DSP"
11931 + "mulwh.d\t%0, %1, %2:b"
11932 + [(set_attr "length" "4")
11933 + (set_attr "cc" "none")
11934 + (set_attr "type" "mulwh")])
11935 +
11936 +
11937 +(define_insn "mulnwh_d"
11938 + [(set (match_operand:DI 0 "register_operand" "=r")
11939 + (ashift:DI (mult:DI (not:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))
11940 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
11941 + (const_int 16)))]
11942 + "TARGET_DSP"
11943 + "mulnwh.d\t%0, %1, %2:b"
11944 + [(set_attr "length" "4")
11945 + (set_attr "cc" "none")
11946 + (set_attr "type" "mulwh")])
11947 +
11948 +(define_insn "macwh_d"
11949 + [(set (match_operand:DI 0 "register_operand" "+r")
11950 + (plus:DI (match_dup 0)
11951 + (ashift:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "%r"))
11952 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))
11953 + (const_int 16))))]
11954 + "TARGET_DSP"
11955 + "macwh.d\t%0, %1, %2:b"
11956 + [(set_attr "length" "4")
11957 + (set_attr "cc" "none")
11958 + (set_attr "type" "mulwh")])
11959 +
11960 +(define_insn "machh_d"
11961 + [(set (match_operand:DI 0 "register_operand" "+r")
11962 + (plus:DI (match_dup 0)
11963 + (mult:DI (sign_extend:DI (match_operand:HI 1 "register_operand" "%r"))
11964 + (sign_extend:DI (match_operand:HI 2 "register_operand" "r")))))]
11965 + "TARGET_DSP"
11966 + "machh.d\t%0, %1:b, %2:b"
11967 + [(set_attr "length" "4")
11968 + (set_attr "cc" "none")
11969 + (set_attr "type" "mulwh")])
11970 +
11971 +(define_insn "satadd_w"
11972 + [(set (match_operand:SI 0 "register_operand" "=r")
11973 + (ss_plus:SI (match_operand:SI 1 "register_operand" "r")
11974 + (match_operand:SI 2 "register_operand" "r")))]
11975 + "TARGET_DSP"
11976 + "satadd.w\t%0, %1, %2"
11977 + [(set_attr "length" "4")
11978 + (set_attr "cc" "none")
11979 + (set_attr "type" "alu_sat")])
11980 +
11981 +(define_insn "satsub_w"
11982 + [(set (match_operand:SI 0 "register_operand" "=r")
11983 + (ss_minus:SI (match_operand:SI 1 "register_operand" "r")
11984 + (match_operand:SI 2 "register_operand" "r")))]
11985 + "TARGET_DSP"
11986 + "satsub.w\t%0, %1, %2"
11987 + [(set_attr "length" "4")
11988 + (set_attr "cc" "none")
11989 + (set_attr "type" "alu_sat")])
11990 +
11991 +(define_insn "satadd_h"
11992 + [(set (match_operand:HI 0 "register_operand" "=r")
11993 + (ss_plus:HI (match_operand:HI 1 "register_operand" "r")
11994 + (match_operand:HI 2 "register_operand" "r")))]
11995 + "TARGET_DSP"
11996 + "satadd.h\t%0, %1, %2"
11997 + [(set_attr "length" "4")
11998 + (set_attr "cc" "none")
11999 + (set_attr "type" "alu_sat")])
12000 +
12001 +(define_insn "satsub_h"
12002 + [(set (match_operand:HI 0 "register_operand" "=r")
12003 + (ss_minus:HI (match_operand:HI 1 "register_operand" "r")
12004 + (match_operand:HI 2 "register_operand" "r")))]
12005 + "TARGET_DSP"
12006 + "satsub.h\t%0, %1, %2"
12007 + [(set_attr "length" "4")
12008 + (set_attr "cc" "none")
12009 + (set_attr "type" "alu_sat")])
12010 +
12011 +
12012 +;;=============================================================================
12013 +;; smin
12014 +;;-----------------------------------------------------------------------------
12015 +;; Set reg0 to the smallest value of reg1 and reg2. It is used for signed
12016 +;; values in the registers.
12017 +;;=============================================================================
12018 +(define_insn "sminsi3"
12019 + [(set (match_operand:SI 0 "register_operand" "=r")
12020 + (smin:SI (match_operand:SI 1 "register_operand" "r")
12021 + (match_operand:SI 2 "register_operand" "r")))]
12022 + ""
12023 + "min %0, %1, %2"
12024 + [(set_attr "length" "4")
12025 + (set_attr "cc" "none")])
12026 +
12027 +;;=============================================================================
12028 +;; smax
12029 +;;-----------------------------------------------------------------------------
12030 +;; Set reg0 to the largest value of reg1 and reg2. It is used for signed
12031 +;; values in the registers.
12032 +;;=============================================================================
12033 +(define_insn "smaxsi3"
12034 + [(set (match_operand:SI 0 "register_operand" "=r")
12035 + (smax:SI (match_operand:SI 1 "register_operand" "r")
12036 + (match_operand:SI 2 "register_operand" "r")))]
12037 + ""
12038 + "max %0, %1, %2"
12039 + [(set_attr "length" "4")
12040 + (set_attr "cc" "none")])
12041 +
12042 +
12043 +;;=============================================================================
12044 +;; Logical operations
12045 +;;-----------------------------------------------------------------------------
12046 +
12047 +;; Split up simple DImode logical operations. Simply perform the logical
12048 +;; operation on the upper and lower halves of the registers.
12049 +(define_split
12050 + [(set (match_operand:DI 0 "register_operand" "")
12051 + (match_operator:DI 6 "logical_binary_operator"
12052 + [(match_operand:DI 1 "register_operand" "")
12053 + (match_operand:DI 2 "register_operand" "")]))]
12054 + "reload_completed"
12055 + [(set (match_dup 0) (match_op_dup:SI 6 [(match_dup 1) (match_dup 2)]))
12056 + (set (match_dup 3) (match_op_dup:SI 6 [(match_dup 4) (match_dup 5)]))]
12057 + "
12058 + {
12059 + operands[3] = gen_highpart (SImode, operands[0]);
12060 + operands[0] = gen_lowpart (SImode, operands[0]);
12061 + operands[4] = gen_highpart (SImode, operands[1]);
12062 + operands[1] = gen_lowpart (SImode, operands[1]);
12063 + operands[5] = gen_highpart (SImode, operands[2]);
12064 + operands[2] = gen_lowpart (SImode, operands[2]);
12065 + }"
12066 +)
12067 +
12068 +;;=============================================================================
12069 +;; Logical operations with shifted operand
12070 +;;=============================================================================
12071 +(define_insn "<code>si_lshift"
12072 + [(set (match_operand:SI 0 "register_operand" "=r")
12073 + (logical:SI (match_operator:SI 4 "logical_shift_operator"
12074 + [(match_operand:SI 2 "register_operand" "r")
12075 + (match_operand:SI 3 "immediate_operand" "Ku05")])
12076 + (match_operand:SI 1 "register_operand" "r")))]
12077 + ""
12078 + {
12079 + if ( GET_CODE(operands[4]) == ASHIFT )
12080 + return "<logical_insn>\t%0, %1, %2 << %3";
12081 + else
12082 + return "<logical_insn>\t%0, %1, %2 >> %3";
12083 + }
12084 +
12085 + [(set_attr "cc" "set_z")]
12086 +)
12087 +
12088 +
12089 +;;************************************************
12090 +;; Peepholes for detecting logical operantions
12091 +;; with shifted operands
12092 +;;************************************************
12093 +
12094 +(define_peephole
12095 + [(set (match_operand:SI 3 "register_operand" "")
12096 + (match_operator:SI 5 "logical_shift_operator"
12097 + [(match_operand:SI 1 "register_operand" "")
12098 + (match_operand:SI 2 "immediate_operand" "")]))
12099 + (set (match_operand:SI 0 "register_operand" "")
12100 + (logical:SI (match_operand:SI 4 "register_operand" "")
12101 + (match_dup 3)))]
12102 + "(dead_or_set_p(insn, operands[3])) || (REGNO(operands[3]) == REGNO(operands[0]))"
12103 + {
12104 + if ( GET_CODE(operands[5]) == ASHIFT )
12105 + return "<logical_insn>\t%0, %4, %1 << %2";
12106 + else
12107 + return "<logical_insn>\t%0, %4, %1 >> %2";
12108 + }
12109 + [(set_attr "cc" "set_z")]
12110 + )
12111 +
12112 +(define_peephole
12113 + [(set (match_operand:SI 3 "register_operand" "")
12114 + (match_operator:SI 5 "logical_shift_operator"
12115 + [(match_operand:SI 1 "register_operand" "")
12116 + (match_operand:SI 2 "immediate_operand" "")]))
12117 + (set (match_operand:SI 0 "register_operand" "")
12118 + (logical:SI (match_dup 3)
12119 + (match_operand:SI 4 "register_operand" "")))]
12120 + "(dead_or_set_p(insn, operands[3])) || (REGNO(operands[3]) == REGNO(operands[0]))"
12121 + {
12122 + if ( GET_CODE(operands[5]) == ASHIFT )
12123 + return "<logical_insn>\t%0, %4, %1 << %2";
12124 + else
12125 + return "<logical_insn>\t%0, %4, %1 >> %2";
12126 + }
12127 + [(set_attr "cc" "set_z")]
12128 + )
12129 +
12130 +
12131 +(define_peephole2
12132 + [(set (match_operand:SI 0 "register_operand" "")
12133 + (match_operator:SI 5 "logical_shift_operator"
12134 + [(match_operand:SI 1 "register_operand" "")
12135 + (match_operand:SI 2 "immediate_operand" "")]))
12136 + (set (match_operand:SI 3 "register_operand" "")
12137 + (logical:SI (match_operand:SI 4 "register_operand" "")
12138 + (match_dup 0)))]
12139 + "(peep2_reg_dead_p(2, operands[0])) || (REGNO(operands[3]) == REGNO(operands[0]))"
12140 +
12141 + [(set (match_dup 3)
12142 + (logical:SI (match_op_dup:SI 5 [(match_dup 1) (match_dup 2)])
12143 + (match_dup 4)))]
12144 +
12145 + ""
12146 +)
12147 +
12148 +(define_peephole2
12149 + [(set (match_operand:SI 0 "register_operand" "")
12150 + (match_operator:SI 5 "logical_shift_operator"
12151 + [(match_operand:SI 1 "register_operand" "")
12152 + (match_operand:SI 2 "immediate_operand" "")]))
12153 + (set (match_operand:SI 3 "register_operand" "")
12154 + (logical:SI (match_dup 0)
12155 + (match_operand:SI 4 "register_operand" "")))]
12156 + "(peep2_reg_dead_p(2, operands[0])) || (REGNO(operands[3]) == REGNO(operands[0]))"
12157 +
12158 + [(set (match_dup 3)
12159 + (logical:SI (match_op_dup:SI 5 [(match_dup 1) (match_dup 2)])
12160 + (match_dup 4)))]
12161 +
12162 + ""
12163 +)
12164 +
12165 +
12166 +;;=============================================================================
12167 +;; and
12168 +;;-----------------------------------------------------------------------------
12169 +;; Store the result after a bitwise logical-and between reg0 and reg2 in reg0.
12170 +;;=============================================================================
12171 +
12172 +(define_insn "andnsi"
12173 + [(set (match_operand:SI 0 "register_operand" "=r")
12174 + (and:SI (match_operand:SI 1 "register_operand" "0")
12175 + (not:SI (match_operand:SI 2 "register_operand" "r"))))]
12176 + ""
12177 + "andn %0, %2"
12178 + [(set_attr "cc" "set_z")
12179 + (set_attr "length" "2")]
12180 +)
12181 +
12182 +
12183 +
12184 +
12185 +(define_insn "andsi3"
12186 + [(set (match_operand:SI 0 "register_operand" "=r, r, r, r")
12187 + (and:SI (match_operand:SI 1 "register_operand" "%0, r, 0, r")
12188 + (match_operand:SI 2 "nonmemory_operand" "r, M, i, r")))]
12189 + ""
12190 + {
12191 + switch (which_alternative){
12192 + case 0:
12193 + return "and\t%0, %2";
12194 + case 1:
12195 + {
12196 + int i, first_set = -1;
12197 + /* Search for first bit set in mask */
12198 + for ( i = 31; i >= 0; --i )
12199 + if ( INTVAL(operands[2]) & (1 << i) ){
12200 + first_set = i;
12201 + break;
12202 + }
12203 + operands[2] = gen_rtx_CONST_INT(SImode, first_set + 1);
12204 + return "bfextu\t%0, %1, 0, %2";
12205 + }
12206 + case 2:
12207 + if ( one_bit_cleared_operand(operands[2], VOIDmode) ){
12208 + int bitpos;
12209 + for ( bitpos = 0; bitpos < 32; bitpos++ )
12210 + if ( !(INTVAL(operands[2]) & (1 << bitpos)) )
12211 + break;
12212 + operands[2] = gen_rtx_CONST_INT(SImode, bitpos);
12213 + return "cbr\t%0, %2";
12214 + } else if ( (INTVAL(operands[2]) >= 0) &&
12215 + (INTVAL(operands[2]) <= 65535) )
12216 + return "andl\t%0, %2, COH";
12217 + else if ( (INTVAL(operands[2]) < 0) &&
12218 + (INTVAL(operands[2]) >= -65536 ) )
12219 + return "andl\t%0, lo(%2)";
12220 + else if ( ((INTVAL(operands[2]) & 0xffff) == 0xffff) )
12221 + return "andh\t%0, hi(%2)";
12222 + else if ( ((INTVAL(operands[2]) & 0xffff) == 0x0) )
12223 + return "andh\t%0, hi(%2), COH";
12224 + else
12225 + return "andh\t%0, hi(%2)\;andl\t%0, lo(%2)";
12226 + case 3:
12227 + return "and\t%0, %1, %2";
12228 + default:
12229 + abort();
12230 + }
12231 + }
12232 +
12233 + [(set_attr "length" "2,4,8,4")
12234 + (set_attr "cc" "set_z")])
12235 +
12236 +
12237 +(define_insn "anddi3"
12238 + [(set (match_operand:DI 0 "register_operand" "=&r,&r")
12239 + (and:DI (match_operand:DI 1 "register_operand" "%0,r")
12240 + (match_operand:DI 2 "register_operand" "r,r")))]
12241 + ""
12242 + "#"
12243 + [(set_attr "length" "8")
12244 + (set_attr "cc" "clobber")]
12245 +)
12246 +
12247 +;;=============================================================================
12248 +;; or
12249 +;;-----------------------------------------------------------------------------
12250 +;; Store the result after a bitwise inclusive-or between reg0 and reg2 in reg0.
12251 +;;=============================================================================
12252 +
12253 +(define_insn "iorsi3"
12254 + [(set (match_operand:SI 0 "register_operand" "=r,r,r")
12255 + (ior:SI (match_operand:SI 1 "register_operand" "%0,0,r" )
12256 + (match_operand:SI 2 "nonmemory_operand" "r ,i,r")))]
12257 + ""
12258 + {
12259 + switch (which_alternative){
12260 + case 0:
12261 + return "or\t%0, %2";
12262 + case 1:
12263 + if ( one_bit_set_operand(operands[2], VOIDmode) ){
12264 + int bitpos;
12265 + for (bitpos = 0; bitpos < 32; bitpos++)
12266 + if (INTVAL(operands[2]) & (1 << bitpos))
12267 + break;
12268 + operands[2] = gen_rtx_CONST_INT( SImode, bitpos);
12269 + return "sbr\t%0, %2";
12270 + } else if ( (INTVAL(operands[2]) >= 0) &&
12271 + (INTVAL(operands[2]) <= 65535) )
12272 + return "orl\t%0, %2";
12273 + else if ( ((INTVAL(operands[2]) & 0xffff) == 0x0) )
12274 + return "orh\t%0, hi(%2)";
12275 + else
12276 + return "orh\t%0, hi(%2)\;orl\t%0, lo(%2)";
12277 + case 2:
12278 + return "or\t%0, %1, %2";
12279 + default:
12280 + abort();
12281 + }
12282 + }
12283 + [(set_attr "length" "2,8,4")
12284 + (set_attr "cc" "set_z")])
12285 +
12286 +
12287 +;(define_insn "iorsi3"
12288 +; [(set (match_operand:SI 0 "register_operand" "=r, r, r")
12289 +; (ior:SI (match_operand:SI 1 "avr32_logical_insn_operand" "r, r, rA" )
12290 +; (match_operand:SI 2 "register_operand" "0, i, r")))]
12291 +; ""
12292 +; {
12293 +; switch (which_alternative){
12294 +; case 0:
12295 +; return "or %0, %2";
12296 +; case 1:
12297 +; if ( one_bit_set_operand(operands[2], VOIDmode) ){
12298 +; int i, bitpos;
12299 +; for ( i = 0; i < 32; i++ )
12300 +; if ( INTVAL(operands[2]) & (1 << i) ){
12301 +; bitpos = i;
12302 +; break;
12303 +; }
12304 +; operands[2] = gen_rtx_CONST_INT( SImode, bitpos);
12305 +; return "sbr %0, %2";
12306 +; } else if ( (INTVAL(operands[2]) >= 0) &&
12307 +; (INTVAL(operands[2]) <= 65535) )
12308 +; return "orl %0, %2";
12309 +; else if ( ((INTVAL(operands[2]) & 0xffff) == 0x0) )
12310 +; return "orh %0, hi(%2)";
12311 +; else
12312 +; return "orh %0, hi(%2)\;orl %0, lo(%2)";
12313 +; case 2:
12314 +; return "or %0, %2, %1";
12315 +; }
12316 +; }
12317 +; [(set_attr "length" "2,8,4")
12318 +; (set_attr "cc" "set_z")])
12319 +
12320 +(define_insn "iordi3"
12321 + [(set (match_operand:DI 0 "register_operand" "=&r,&r")
12322 + (ior:DI (match_operand:DI 1 "register_operand" "%0,r")
12323 + (match_operand:DI 2 "register_operand" "r,r")))]
12324 + ""
12325 + "#"
12326 + [(set_attr "length" "8")
12327 + (set_attr "cc" "clobber")]
12328 +)
12329 +
12330 +;;=============================================================================
12331 +;; xor bytes
12332 +;;-----------------------------------------------------------------------------
12333 +;; Store the result after a bitwise exclusive-or between reg0 and reg2 in reg0.
12334 +;;=============================================================================
12335 +
12336 +(define_insn "xorsi3"
12337 + [(set (match_operand:SI 0 "register_operand" "=r,r,r")
12338 + (xor:SI (match_operand:SI 1 "register_operand" "0,0,r")
12339 + (match_operand:SI 2 "nonmemory_operand" "r,i,r")))]
12340 + ""
12341 + {
12342 + switch (which_alternative){
12343 + case 0:
12344 + return "eor %0, %2";
12345 + case 1:
12346 + if ( (INTVAL(operands[2]) >= 0) &&
12347 + (INTVAL(operands[2]) <= 65535) )
12348 + return "eorl %0, %2";
12349 + else if ( ((INTVAL(operands[2]) & 0xffff) == 0x0) )
12350 + return "eorh %0, hi(%2)";
12351 + else
12352 + return "eorh %0, hi(%2)\;eorl %0, lo(%2)";
12353 + case 2:
12354 + return "eor %0, %1, %2";
12355 + default:
12356 + abort();
12357 + }
12358 + }
12359 +
12360 + [(set_attr "length" "2,8,4")
12361 + (set_attr "cc" "set_z")])
12362 +
12363 +(define_insn "xordi3"
12364 + [(set (match_operand:DI 0 "register_operand" "=&r,&r")
12365 + (xor:DI (match_operand:DI 1 "register_operand" "%0,r")
12366 + (match_operand:DI 2 "register_operand" "r,r")))]
12367 + ""
12368 + "#"
12369 + [(set_attr "length" "8")
12370 + (set_attr "cc" "clobber")]
12371 +)
12372 +
12373 +;;=============================================================================
12374 +;; divmod
12375 +;;-----------------------------------------------------------------------------
12376 +;; Signed division that produces both a quotient and a remainder.
12377 +;;=============================================================================
12378 +(define_expand "divmodsi4"
12379 + [(parallel [
12380 + (parallel [
12381 + (set (match_operand:SI 0 "register_operand" "=r")
12382 + (div:SI (match_operand:SI 1 "register_operand" "r")
12383 + (match_operand:SI 2 "register_operand" "r")))
12384 + (set (match_operand:SI 3 "register_operand" "=r")
12385 + (mod:SI (match_dup 1)
12386 + (match_dup 2)))])
12387 + (use (match_dup 4))])]
12388 + ""
12389 + {
12390 + if (! no_new_pseudos) {
12391 + operands[4] = gen_reg_rtx (DImode);
12392 +
12393 + emit_insn(gen_divmodsi4_internal(operands[4],operands[1],operands[2]));
12394 + emit_move_insn(operands[0], gen_rtx_SUBREG( SImode, operands[4], 4));
12395 + emit_move_insn(operands[3], gen_rtx_SUBREG( SImode, operands[4], 0));
12396 +
12397 + DONE;
12398 + } else {
12399 + FAIL;
12400 + }
12401 +
12402 + })
12403 +
12404 +
12405 +(define_insn "divmodsi4_internal"
12406 + [(set (match_operand:DI 0 "register_operand" "=r")
12407 + (unspec:DI [(match_operand:SI 1 "register_operand" "r")
12408 + (match_operand:SI 2 "register_operand" "r")]
12409 + UNSPEC_DIVMODSI4_INTERNAL))]
12410 + ""
12411 + "divs %0, %1, %2"
12412 + [(set_attr "type" "div")
12413 + (set_attr "cc" "none")])
12414 +
12415 +
12416 +;;=============================================================================
12417 +;; udivmod
12418 +;;-----------------------------------------------------------------------------
12419 +;; Unsigned division that produces both a quotient and a remainder.
12420 +;;=============================================================================
12421 +(define_expand "udivmodsi4"
12422 + [(parallel [
12423 + (parallel [
12424 + (set (match_operand:SI 0 "register_operand" "=r")
12425 + (udiv:SI (match_operand:SI 1 "register_operand" "r")
12426 + (match_operand:SI 2 "register_operand" "r")))
12427 + (set (match_operand:SI 3 "register_operand" "=r")
12428 + (umod:SI (match_dup 1)
12429 + (match_dup 2)))])
12430 + (use (match_dup 4))])]
12431 + ""
12432 + {
12433 + if (! no_new_pseudos) {
12434 + operands[4] = gen_reg_rtx (DImode);
12435 +
12436 + emit_insn(gen_udivmodsi4_internal(operands[4],operands[1],operands[2]));
12437 + emit_move_insn(operands[0], gen_rtx_SUBREG( SImode, operands[4], 4));
12438 + emit_move_insn(operands[3], gen_rtx_SUBREG( SImode, operands[4], 0));
12439 +
12440 + DONE;
12441 + } else {
12442 + FAIL;
12443 + }
12444 + })
12445 +
12446 +(define_insn "udivmodsi4_internal"
12447 + [(set (match_operand:DI 0 "register_operand" "=r")
12448 + (unspec:DI [(match_operand:SI 1 "register_operand" "r")
12449 + (match_operand:SI 2 "register_operand" "r")]
12450 + UNSPEC_UDIVMODSI4_INTERNAL))]
12451 + ""
12452 + "divu %0, %1, %2"
12453 + [(set_attr "type" "div")
12454 + (set_attr "cc" "none")])
12455 +
12456 +
12457 +;;=============================================================================
12458 +;; Arithmetic-shift left
12459 +;;-----------------------------------------------------------------------------
12460 +;; Arithmetic-shift reg0 left by reg2 or immediate value.
12461 +;;=============================================================================
12462 +
12463 +(define_insn "ashlsi3"
12464 + [(set (match_operand:SI 0 "register_operand" "=r,r,r")
12465 + (ashift:SI (match_operand:SI 1 "register_operand" "r,0,r")
12466 + (match_operand:SI 2 "nonmemory_operand" "r,Ku05,Ku05")))]
12467 + ""
12468 + "@
12469 + lsl %0, %1, %2
12470 + lsl %0, %2
12471 + lsl %0, %1, %2"
12472 + [(set_attr "length" "4,2,4")
12473 + (set_attr "cc" "set_ncz")])
12474 +
12475 +;;=============================================================================
12476 +;; Arithmetic-shift right
12477 +;;-----------------------------------------------------------------------------
12478 +;; Arithmetic-shift reg0 right by an immediate value.
12479 +;;=============================================================================
12480 +
12481 +(define_insn "ashrsi3"
12482 + [(set (match_operand:SI 0 "register_operand" "=r,r,r")
12483 + (ashiftrt:SI (match_operand:SI 1 "register_operand" "r,0,r")
12484 + (match_operand:SI 2 "nonmemory_operand" "r,Ku05,Ku05")))]
12485 + ""
12486 + "@
12487 + asr %0, %1, %2
12488 + asr %0, %2
12489 + asr %0, %1, %2"
12490 + [(set_attr "length" "4,2,4")
12491 + (set_attr "cc" "set_ncz")])
12492 +
12493 +;;=============================================================================
12494 +;; Logical shift right
12495 +;;-----------------------------------------------------------------------------
12496 +;; Logical shift reg0 right by an immediate value.
12497 +;;=============================================================================
12498 +
12499 +(define_insn "lshrsi3"
12500 + [(set (match_operand:SI 0 "register_operand" "=r,r,r")
12501 + (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,0,r")
12502 + (match_operand:SI 2 "nonmemory_operand" "r,Ku05,Ku05")))]
12503 + ""
12504 + "@
12505 + lsr %0, %1, %2
12506 + lsr %0, %2
12507 + lsr %0, %1, %2"
12508 + [(set_attr "length" "4,2,4")
12509 + (set_attr "cc" "set_ncz")])
12510 +
12511 +
12512 +;;=============================================================================
12513 +;; neg
12514 +;;-----------------------------------------------------------------------------
12515 +;; Negate operand 1 and store the result in operand 0.
12516 +;;=============================================================================
12517 +(define_insn "negsi2"
12518 + [(set (match_operand:SI 0 "register_operand" "=r")
12519 + (neg:SI (match_operand:SI 1 "register_operand" "0")))]
12520 + ""
12521 + "neg %0"
12522 + [(set_attr "length" "2")
12523 + (set_attr "cc" "set_vncz")])
12524 +
12525 +;;=============================================================================
12526 +;; abs
12527 +;;-----------------------------------------------------------------------------
12528 +;; Store the absolute value of operand 1 into operand 0.
12529 +;;=============================================================================
12530 +(define_insn "abssi2"
12531 + [(set (match_operand:SI 0 "register_operand" "=r")
12532 + (abs:SI (match_operand:SI 1 "register_operand" "0")))]
12533 + ""
12534 + "abs %0"
12535 + [(set_attr "length" "2")
12536 + (set_attr "cc" "set_z")])
12537 +
12538 +
12539 +;;=============================================================================
12540 +;; one_cmpl
12541 +;;-----------------------------------------------------------------------------
12542 +;; Store the bitwise-complement of operand 1 into operand 0.
12543 +;;=============================================================================
12544 +
12545 +(define_insn "one_cmplsi2"
12546 + [(set (match_operand:SI 0 "register_operand" "=r,r")
12547 + (not:SI (match_operand:SI 1 "register_operand" "r,0")))]
12548 + ""
12549 + "@
12550 + rsub %0, %1, -1
12551 + com %0"
12552 + [(set_attr "length" "4,2")
12553 + (set_attr "cc" "set_z")])
12554 +
12555 +
12556 +;;=============================================================================
12557 +;; Bit load
12558 +;;-----------------------------------------------------------------------------
12559 +;; Load a bit into Z and C flags
12560 +;;=============================================================================
12561 +(define_insn "bldsi"
12562 + [(set (cc0)
12563 + (and:SI (match_operand:SI 0 "register_operand" "r")
12564 + (match_operand:SI 1 "one_bit_set_operand" "i")))]
12565 + ""
12566 + "bld\t%0, %p1"
12567 + [(set_attr "length" "4")
12568 + (set_attr "cc" "bld")]
12569 + )
12570 +
12571 +
12572 +;;=============================================================================
12573 +;; Compare
12574 +;;-----------------------------------------------------------------------------
12575 +;; Compare reg0 with reg1 or an immediate value.
12576 +;;=============================================================================
12577 +
12578 +(define_expand "cmpqi"
12579 + [(set (cc0)
12580 + (compare:QI
12581 + (match_operand:QI 0 "general_operand" "")
12582 + (match_operand:QI 1 "general_operand" "")))]
12583 + ""
12584 + "{
12585 +
12586 + if ( GET_CODE(operands[0]) != REG
12587 + && GET_CODE(operands[0]) != SUBREG)
12588 + operands[0] = force_reg(QImode, operands[0]);
12589 +
12590 +
12591 + if ( GET_CODE(operands[1]) != REG
12592 + && GET_CODE(operands[1]) != SUBREG )
12593 + operands[1] = force_reg(QImode, operands[1]);
12594 +
12595 + avr32_compare_op0 = operands[0];
12596 + avr32_compare_op1 = operands[1];
12597 + emit_insn(gen_cmpqi_internal(operands[0], operands[1]));
12598 + DONE;
12599 + }"
12600 +)
12601 +
12602 +
12603 +(define_insn "cmpqi_internal"
12604 + [(set (cc0)
12605 + (compare:QI
12606 + (match_operand:QI 0 "register_operand" "r")
12607 + (match_operand:QI 1 "register_operand" "r")))]
12608 + ""
12609 + {
12610 + set_next_insn_cond(insn,
12611 + avr32_output_cmp(get_next_insn_cond(insn), QImode, operands[0], operands[1]));
12612 + return "";
12613 + }
12614 + [(set_attr "length" "4")
12615 + (set_attr "cc" "compare")])
12616 +
12617 +(define_expand "cmphi"
12618 + [(set (cc0)
12619 + (compare:HI
12620 + (match_operand:HI 0 "register_operand" "")
12621 + (match_operand:HI 1 "register_operand" "")))]
12622 + ""
12623 + "{
12624 +
12625 + //if ( (GET_CODE(operands[0]) == REG
12626 + // || GET_CODE(operands[0]) == SUBREG)
12627 + // && (GET_CODE(operands[1]) == CONST_INT
12628 + // && avr32_const_ok_for_constraint_p (INTVAL(operands[1]), 'K', \"Ks21\")) ){
12629 + // operands[0] = convert_to_mode(SImode, operands[0], 0);
12630 + // avr32_compare_op0 = operands[0];
12631 + // avr32_compare_op1 = operands[1];
12632 + // emit_insn(gen_cmpsi_internal(operands[0], operands[1]));
12633 + // DONE;
12634 + //}
12635 +
12636 + if ( GET_CODE(operands[0]) != REG
12637 + && GET_CODE(operands[0]) != SUBREG )
12638 + operands[0] = force_reg(HImode, operands[0]);
12639 +
12640 +
12641 + if ( GET_CODE(operands[1]) != REG
12642 + && GET_CODE(operands[1]) != SUBREG)
12643 + operands[1] = force_reg(HImode, operands[1]);
12644 +
12645 + avr32_compare_op0 = operands[0];
12646 + avr32_compare_op1 = operands[1];
12647 + }"
12648 +)
12649 +
12650 +
12651 +(define_insn "cmphi_internal"
12652 + [(set (cc0)
12653 + (compare:HI
12654 + (match_operand:HI 0 "register_operand" "r")
12655 + (match_operand:HI 1 "register_operand" "r")))]
12656 + ""
12657 + {
12658 + set_next_insn_cond(insn,
12659 + avr32_output_cmp(get_next_insn_cond(insn), HImode, operands[0], operands[1]));
12660 + return "";
12661 + }
12662 + [(set_attr "length" "4")
12663 + (set_attr "cc" "compare")])
12664 +
12665 +
12666 +(define_expand "cmpsi"
12667 + [(set (cc0)
12668 + (compare:SI
12669 + (match_operand:SI 0 "register_operand" "")
12670 + (match_operand:SI 1 "register_immediate_operand" "")))]
12671 + ""
12672 + "{
12673 + if ( GET_CODE(operands[0]) != REG
12674 + && GET_CODE(operands[0]) != SUBREG )
12675 + operands[0] = force_reg(SImode, operands[0]);
12676 +
12677 + if ( GET_CODE(operands[1]) != REG
12678 + && GET_CODE(operands[1]) != SUBREG
12679 + && GET_CODE(operands[1]) != CONST_INT )
12680 + operands[1] = force_reg(SImode, operands[1]);
12681 +
12682 + avr32_compare_op0 = operands[0];
12683 + avr32_compare_op1 = operands[1];
12684 +
12685 + }"
12686 +)
12687 +
12688 +
12689 +(define_insn "cmpsi_internal"
12690 + [(set (cc0)
12691 + (compare:SI
12692 + (match_operand:SI 0 "register_operand" "r, r, r")
12693 + (match_operand:SI 1 "register_immediate_operand" "r, Ks06, Ks21")))]
12694 + ""
12695 + {
12696 + set_next_insn_cond(insn,
12697 + avr32_output_cmp(get_next_insn_cond(insn), SImode, operands[0], operands[1]));
12698 + return "";
12699 + }
12700 +
12701 + [(set_attr "length" "2,2,4")
12702 + (set_attr "cc" "compare")])
12703 +
12704 +
12705 +(define_expand "cmpdi"
12706 + [(set (cc0)
12707 + (compare:DI
12708 + (match_operand:DI 0 "register_operand" "")
12709 + (match_operand:DI 1 "register_immediate_operand" "")))]
12710 + ""
12711 + {
12712 + avr32_compare_op0 = operands[0];
12713 + avr32_compare_op1 = operands[1];
12714 + }
12715 +)
12716 +
12717 +(define_insn "cmpdi_internal"
12718 + [(set (cc0)
12719 + (compare:DI
12720 + (match_operand:DI 0 "register_operand" "r")
12721 + (match_operand:DI 1 "register_immediate_operand" "rKu20")))]
12722 + ""
12723 + {
12724 + set_next_insn_cond(insn,
12725 + avr32_output_cmp(get_next_insn_cond(insn), DImode, operands[0], operands[1]));
12726 + return "";
12727 + }
12728 +
12729 + [(set_attr "length" "6")
12730 + (set_attr "type" "alu2")
12731 + (set_attr "cc" "compare")])
12732 +
12733 +
12734 +
12735 +;;=============================================================================
12736 +;; Test if zero
12737 +;;-----------------------------------------------------------------------------
12738 +;; Compare reg against zero and set the condition codes.
12739 +;;=============================================================================
12740 +
12741 +
12742 +(define_expand "tstsi"
12743 + [(set (cc0)
12744 + (match_operand:SI 0 "register_operand" ""))]
12745 + ""
12746 + {
12747 + avr32_compare_op0 = operands[0];
12748 + avr32_compare_op1 = const0_rtx;
12749 + }
12750 +)
12751 +
12752 +(define_insn "tstsi_internal"
12753 + [(set (cc0)
12754 + (match_operand:SI 0 "register_operand" "r"))]
12755 + ""
12756 + {
12757 + set_next_insn_cond(insn,
12758 + avr32_output_cmp(get_next_insn_cond(insn), SImode, operands[0], const0_rtx));
12759 +
12760 + return "";
12761 + }
12762 + [(set_attr "length" "2")
12763 + (set_attr "cc" "compare")])
12764 +
12765 +
12766 +(define_expand "tstdi"
12767 + [(set (cc0)
12768 + (match_operand:DI 0 "register_operand" ""))]
12769 + ""
12770 + {
12771 + avr32_compare_op0 = operands[0];
12772 + avr32_compare_op1 = const0_rtx;
12773 + }
12774 +)
12775 +
12776 +(define_insn "tstdi_internal"
12777 + [(set (cc0)
12778 + (match_operand:DI 0 "register_operand" "r"))]
12779 + ""
12780 + {
12781 + set_next_insn_cond(insn,
12782 + avr32_output_cmp(get_next_insn_cond(insn), DImode, operands[0], const0_rtx));
12783 + return "";
12784 + }
12785 + [(set_attr "length" "4")
12786 + (set_attr "type" "alu2")
12787 + (set_attr "cc" "compare")])
12788 +
12789 +
12790 +
12791 +;;=============================================================================
12792 +;; Convert operands
12793 +;;-----------------------------------------------------------------------------
12794 +;;
12795 +;;=============================================================================
12796 +(define_insn "truncdisi2"
12797 + [(set (match_operand:SI 0 "general_operand" "")
12798 + (truncate:SI (match_operand:DI 1 "general_operand" "")))]
12799 + ""
12800 + "truncdisi2")
12801 +
12802 +;;=============================================================================
12803 +;; Extend
12804 +;;-----------------------------------------------------------------------------
12805 +;;
12806 +;;=============================================================================
12807 +
12808 +
12809 +(define_insn "extendhisi2"
12810 + [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
12811 + (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "0,r,<RKu00>,m")))]
12812 + ""
12813 + {
12814 + switch ( which_alternative ){
12815 + case 0:
12816 + return "casts.h\t%0";
12817 + case 1:
12818 + return "bfexts\t%0, %1, 0, 16";
12819 + case 2:
12820 + case 3:
12821 + return "ld.sh\t%0, %1";
12822 + default:
12823 + abort();
12824 + }
12825 + }
12826 + [(set_attr "length" "2,4,2,4")
12827 + (set_attr "cc" "set_ncz,set_ncz,none,none")
12828 + (set_attr "type" "alu,alu,load_rm,load_rm")])
12829 +
12830 +(define_insn "extendqisi2"
12831 + [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
12832 + (sign_extend:SI (match_operand:QI 1 "extendqi_operand" "0,r,RKu00,m")))]
12833 + ""
12834 + {
12835 + switch ( which_alternative ){
12836 + case 0:
12837 + return "casts.b\t%0";
12838 + case 1:
12839 + return "bfexts\t%0, %1, 0, 8";
12840 + case 2:
12841 + case 3:
12842 + return "ld.sb\t%0, %1";
12843 + default:
12844 + abort();
12845 + }
12846 + }
12847 + [(set_attr "length" "2,4,2,4")
12848 + (set_attr "cc" "set_ncz,set_ncz,none,none")
12849 + (set_attr "type" "alu,alu,load_rm,load_rm")])
12850 +
12851 +(define_insn "extendqihi2"
12852 + [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
12853 + (sign_extend:HI (match_operand:QI 1 "extendqi_operand" "0,r,RKu00,m")))]
12854 + ""
12855 + {
12856 + switch ( which_alternative ){
12857 + case 0:
12858 + return "casts.b\t%0";
12859 + case 1:
12860 + return "bfexts\t%0, %1, 0, 8";
12861 + case 2:
12862 + case 3:
12863 + return "ld.sb\t%0, %1";
12864 + default:
12865 + abort();
12866 + }
12867 + }
12868 + [(set_attr "length" "2,4,2,4")
12869 + (set_attr "cc" "set_ncz,set_ncz,none,none")
12870 + (set_attr "type" "alu,alu,load_rm,load_rm")])
12871 +
12872 +
12873 +;;=============================================================================
12874 +;; Zero-extend
12875 +;;-----------------------------------------------------------------------------
12876 +;;
12877 +;;=============================================================================
12878 +
12879 +(define_insn "zero_extendhisi2"
12880 + [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
12881 + (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "0,r,<RKu00>,m")))]
12882 + ""
12883 + {
12884 + switch ( which_alternative ){
12885 + case 0:
12886 + return "castu.h\t%0";
12887 + case 1:
12888 + return "bfextu\t%0, %1, 0, 16";
12889 + case 2:
12890 + case 3:
12891 + return "ld.uh\t%0, %1";
12892 + default:
12893 + abort();
12894 + }
12895 + }
12896 +
12897 + [(set_attr "length" "2,4,2,4")
12898 + (set_attr "cc" "set_ncz,set_ncz,none,none")
12899 + (set_attr "type" "alu,alu,load_rm,load_rm")])
12900 +
12901 +(define_insn "zero_extendqisi2"
12902 + [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
12903 + (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,r,<RKu00>,m")))]
12904 + ""
12905 + {
12906 + switch ( which_alternative ){
12907 + case 0:
12908 + return "castu.b\t%0";
12909 + case 1:
12910 + return "bfextu\t%0, %1, 0, 8";
12911 + case 2:
12912 + case 3:
12913 + return "ld.ub\t%0, %1";
12914 + default:
12915 + abort();
12916 + }
12917 + }
12918 + [(set_attr "length" "2,4,2,4")
12919 + (set_attr "cc" "set_ncz, set_ncz, none, none")
12920 + (set_attr "type" "alu, alu, load_rm, load_rm")])
12921 +
12922 +(define_insn "zero_extendqihi2"
12923 + [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
12924 + (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,r,<RKu00>,m")))]
12925 + ""
12926 + {
12927 + switch ( which_alternative ){
12928 + case 0:
12929 + return "castu.b\t%0";
12930 + case 1:
12931 + return "bfextu\t%0, %1, 0, 8";
12932 + case 2:
12933 + case 3:
12934 + return "ld.ub\t%0, %1";
12935 + default:
12936 + abort();
12937 + }
12938 + }
12939 + [(set_attr "length" "2,4,2,4")
12940 + (set_attr "cc" "set_ncz, set_ncz, none, none")
12941 + (set_attr "type" "alu, alu, load_rm, load_rm")])
12942 +
12943 +
12944 +
12945 +;;=============================================================================
12946 +;; Conditional set register
12947 +;; sr{cond4} rd
12948 +;;-----------------------------------------------------------------------------
12949 +
12950 +;;Because of the same issue as with conditional moves and adds we must
12951 +;;not separate the compare instrcution from the scc instruction as
12952 +;;they might be sheduled "badly".
12953 +
12954 +(define_insn "s<code>"
12955 + [(set (match_operand:SI 0 "register_operand" "=r")
12956 + (any_cond:SI (cc0)
12957 + (const_int 0)))]
12958 + ""
12959 + "sr<cond>\t%0"
12960 + [(set_attr "length" "2")
12961 + (set_attr "cc" "none")])
12962 +
12963 +(define_insn "smi"
12964 + [(set (match_operand:SI 0 "register_operand" "=r")
12965 + (unspec:SI [(cc0)
12966 + (const_int 0)] UNSPEC_COND_MI))]
12967 + ""
12968 + "srmi\t%0"
12969 + [(set_attr "length" "2")
12970 + (set_attr "cc" "none")])
12971 +
12972 +(define_insn "spl"
12973 + [(set (match_operand:SI 0 "register_operand" "=r")
12974 + (unspec:SI [(cc0)
12975 + (const_int 0)] UNSPEC_COND_PL))]
12976 + ""
12977 + "srpl\t%0"
12978 + [(set_attr "length" "2")
12979 + (set_attr "cc" "none")])
12980 +
12981 +
12982 +;;=============================================================================
12983 +;; Conditional branch
12984 +;;-----------------------------------------------------------------------------
12985 +;; Branch to label if the specified condition codes are set.
12986 +;;=============================================================================
12987 +; branch if negative
12988 +(define_insn "bmi"
12989 + [(set (pc)
12990 + (if_then_else (unspec:CC [(cc0) (const_int 0)] UNSPEC_COND_MI)
12991 + (label_ref (match_operand 0 "" ""))
12992 + (pc)))]
12993 + ""
12994 + "brmi %0"
12995 + [(set_attr "type" "branch")
12996 + (set (attr "length")
12997 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
12998 + (le (minus (pc) (match_dup 0)) (const_int 256)))
12999 + (const_int 2)] ; use compact branch
13000 + (const_int 4))) ; use extended branch
13001 + (set_attr "cc" "none")])
13002 +
13003 +(define_insn "*bmi-reverse"
13004 + [(set (pc)
13005 + (if_then_else (unspec:CC [(cc0) (const_int 0)] UNSPEC_COND_MI)
13006 + (pc)
13007 + (label_ref (match_operand 0 "" ""))))]
13008 + ""
13009 + "brpl %0"
13010 + [(set_attr "type" "branch")
13011 + (set (attr "length")
13012 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
13013 + (le (minus (pc) (match_dup 0)) (const_int 256)))
13014 + (const_int 2)] ; use compact branch
13015 + (const_int 4))) ; use extended branch
13016 + (set_attr "cc" "none")])
13017 +
13018 +; branch if positive
13019 +(define_insn "bpl"
13020 + [(set (pc)
13021 + (if_then_else (unspec:CC [(cc0) (const_int 0)] UNSPEC_COND_PL)
13022 + (label_ref (match_operand 0 "" ""))
13023 + (pc)))]
13024 + ""
13025 + "brpl %0"
13026 + [(set_attr "type" "branch")
13027 + (set (attr "length")
13028 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
13029 + (le (minus (pc) (match_dup 0)) (const_int 256)))
13030 + (const_int 2)] ; use compact branch
13031 + (const_int 4))) ; use extended branch
13032 + (set_attr "cc" "none")])
13033 +
13034 +(define_insn "*bpl-reverse"
13035 + [(set (pc)
13036 + (if_then_else (unspec:CC [(cc0) (const_int 0)] UNSPEC_COND_PL)
13037 + (pc)
13038 + (label_ref (match_operand 0 "" ""))))]
13039 + ""
13040 + "brmi %0"
13041 + [(set_attr "type" "branch")
13042 + (set (attr "length")
13043 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
13044 + (le (minus (pc) (match_dup 0)) (const_int 256)))
13045 + (const_int 2)] ; use compact branch
13046 + (const_int 4))) ; use extended branch
13047 + (set_attr "cc" "none")])
13048 +
13049 +; branch if equal
13050 +(define_insn "b<code>"
13051 + [(set (pc)
13052 + (if_then_else (any_cond:CC (cc0)
13053 + (const_int 0))
13054 + (label_ref (match_operand 0 "" ""))
13055 + (pc)))]
13056 + ""
13057 + "br<cond> %0 "
13058 + [(set_attr "type" "branch")
13059 + (set (attr "length")
13060 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
13061 + (le (minus (pc) (match_dup 0)) (const_int 256)))
13062 + (const_int 2)] ; use compact branch
13063 + (const_int 4))) ; use extended branch
13064 + (set_attr "cc" "none")])
13065 +
13066 +
13067 +(define_insn "*b<code>-reverse"
13068 + [(set (pc)
13069 + (if_then_else (any_cond:CC (cc0)
13070 + (const_int 0))
13071 + (pc)
13072 + (label_ref (match_operand 0 "" ""))))]
13073 + ""
13074 + "br<invcond> %0 "
13075 + [(set_attr "type" "branch")
13076 + (set (attr "length")
13077 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
13078 + (le (minus (pc) (match_dup 0)) (const_int 256)))
13079 + (const_int 2)] ; use compact branch
13080 + (const_int 4))) ; use extended branch
13081 + (set_attr "cc" "none")])
13082 +
13083 +
13084 +
13085 +;=============================================================================
13086 +; Conditional Add/Subtract
13087 +;-----------------------------------------------------------------------------
13088 +; sub{cond4} Rd, imm
13089 +;=============================================================================
13090 +
13091 +
13092 +(define_expand "add<mode>cc"
13093 + [(set (match_operand:ADDCC 0 "register_operand" "")
13094 + (if_then_else:ADDCC (match_operator 1 "avr32_comparison_operator"
13095 + [(match_dup 4)
13096 + (match_dup 5)])
13097 + (match_operand:ADDCC 2 "register_operand" "")
13098 + (plus:ADDCC
13099 + (match_dup 2)
13100 + (match_operand:ADDCC 3 "avr32_cond_immediate_operand" ""))))]
13101 + ""
13102 + {
13103 + /* Delete compare instruction as it is merged into this instruction */
13104 + remove_insn (get_last_insn_anywhere ());
13105 +
13106 + operands[4] = avr32_compare_op0;
13107 + operands[5] = avr32_compare_op1;
13108 + }
13109 + )
13110 +
13111 +
13112 +(define_insn "add<ADDCC:mode>cc_cmp<CMP:mode>"
13113 + [(set (match_operand:ADDCC 0 "register_operand" "=r")
13114 + (if_then_else:ADDCC (match_operator 1 "avr32_comparison_operator"
13115 + [(match_operand:CMP 4 "register_operand" "r")
13116 + (match_operand:CMP 5 "<CMP:cmp_predicate>" "<CMP:cmp_constraint>")])
13117 + (match_operand:ADDCC 2 "register_operand" "0")
13118 + (plus:ADDCC
13119 + (match_dup 2)
13120 + (match_operand:ADDCC 3 "avr32_cond_immediate_operand" "Is08"))))]
13121 + ""
13122 + {
13123 + operands[1] = avr32_output_cmp(operands[1], GET_MODE(operands[4]), operands[4], operands[5]);
13124 +
13125 + return "sub%i1\t%0, -%3";
13126 + }
13127 + [(set_attr "length" "8")
13128 + (set_attr "cc" "cmp_cond_insn")])
13129 +
13130 +;=============================================================================
13131 +; Conditional Move
13132 +;-----------------------------------------------------------------------------
13133 +; mov{cond4} Rd, (Rs/imm)
13134 +;=============================================================================
13135 +(define_expand "mov<mode>cc"
13136 + [(set (match_operand:MOVCC 0 "register_operand" "")
13137 + (if_then_else:MOVCC (match_operator 1 "avr32_comparison_operator"
13138 + [(match_dup 4)
13139 + (match_dup 5)])
13140 + (match_operand:MOVCC 2 "avr32_cond_register_immediate_operand" "")
13141 + (match_operand:MOVCC 3 "avr32_cond_register_immediate_operand" "")))]
13142 + ""
13143 + {
13144 + /* Delete compare instruction as it is merged into this instruction */
13145 + remove_insn (get_last_insn_anywhere ());
13146 +
13147 + operands[4] = avr32_compare_op0;
13148 + operands[5] = avr32_compare_op1;
13149 + }
13150 + )
13151 +
13152 +
13153 +(define_insn "mov<MOVCC:mode>cc_cmp<CMP:mode>"
13154 + [(set (match_operand:MOVCC 0 "register_operand" "=r,r,r")
13155 + (if_then_else:MOVCC (match_operator 1 "avr32_comparison_operator"
13156 + [(match_operand:CMP 4 "register_operand" "r,r,r")
13157 + (match_operand:CMP 5 "<CMP:cmp_predicate>" "<CMP:cmp_constraint>,<CMP:cmp_constraint>,<CMP:cmp_constraint>")])
13158 + (match_operand:MOVCC 2 "avr32_cond_register_immediate_operand" "0, rKs08,rKs08")
13159 + (match_operand:MOVCC 3 "avr32_cond_register_immediate_operand" "rKs08,0,rKs08")))]
13160 + ""
13161 + {
13162 + operands[1] = avr32_output_cmp(operands[1], GET_MODE(operands[4]), operands[4], operands[5]);
13163 +
13164 + switch( which_alternative ){
13165 + case 0:
13166 + return "mov%i1 %0, %3";
13167 + case 1:
13168 + return "mov%1 %0, %2";
13169 + case 2:
13170 + return "mov%1 %0, %2\;mov%i1 %0, %3";
13171 + default:
13172 + abort();
13173 + }
13174 +
13175 +
13176 + }
13177 + [(set_attr "length" "8,8,12")
13178 + (set_attr "cc" "cmp_cond_insn")])
13179 +
13180 +
13181 +;;=============================================================================
13182 +;; jump
13183 +;;-----------------------------------------------------------------------------
13184 +;; Jump inside a function; an unconditional branch to a label.
13185 +;;=============================================================================
13186 +(define_insn "jump"
13187 + [(set (pc)
13188 + (label_ref (match_operand 0 "" "")))]
13189 + ""
13190 + {
13191 + if (get_attr_length(insn) > 4)
13192 + return "Can't jump this far";
13193 + return (get_attr_length(insn) == 2 ?
13194 + "rjmp %0" : "bral %0");
13195 + }
13196 + [(set_attr "type" "branch")
13197 + (set (attr "length")
13198 + (cond [(and (le (minus (match_dup 0) (pc)) (const_int 1022))
13199 + (le (minus (pc) (match_dup 0)) (const_int 1024)))
13200 + (const_int 2) ; use rjmp
13201 + (le (match_dup 0) (const_int 1048575))
13202 + (const_int 4)] ; use bral
13203 + (const_int 8))) ; do something else
13204 + (set_attr "cc" "none")])
13205 +
13206 +;;=============================================================================
13207 +;; call
13208 +;;-----------------------------------------------------------------------------
13209 +;; Subroutine call instruction returning no value.
13210 +;;=============================================================================
13211 +(define_insn "call_internal"
13212 + [(parallel [(call (mem:SI (match_operand:SI 0 "avr32_call_operand" "r,U,T,W"))
13213 + (match_operand 1 "" ""))
13214 + (clobber (reg:SI LR_REGNUM))])]
13215 + ""
13216 + {
13217 + switch (which_alternative){
13218 + case 0:
13219 + return "icall\t%0";
13220 + case 1:
13221 + return "rcall\t%0";
13222 + case 2:
13223 + return "mcall\t%0";
13224 + case 3:
13225 + if ( TARGET_HAS_ASM_ADDR_PSEUDOS )
13226 + return "call\t%0";
13227 + else
13228 + return "mcall\tr6[%0@got]";
13229 + default:
13230 + abort();
13231 + }
13232 + }
13233 + [(set_attr "type" "call")
13234 + (set_attr "length" "2,4,4,10")
13235 + (set_attr "cc" "clobber")])
13236 +
13237 +
13238 +(define_expand "call"
13239 + [(parallel [(call (match_operand:SI 0 "" "")
13240 + (match_operand 1 "" ""))
13241 + (clobber (reg:SI LR_REGNUM))])]
13242 + ""
13243 + {
13244 + rtx call_address;
13245 + if ( GET_CODE(operands[0]) != MEM )
13246 + FAIL;
13247 +
13248 + call_address = XEXP(operands[0], 0);
13249 +
13250 + /* If assembler supports call pseudo insn and the call
13251 + address is a symbol then nothing special needs to be done. */
13252 + if ( TARGET_HAS_ASM_ADDR_PSEUDOS
13253 + && (GET_CODE(call_address) == SYMBOL_REF) ){
13254 + /* We must however mark the function as using the GOT if
13255 + flag_pic is set, since the call insn might turn into
13256 + a mcall using the GOT ptr register. */
13257 + if ( flag_pic ){
13258 + current_function_uses_pic_offset_table = 1;
13259 + emit_call_insn(gen_call_internal(call_address, operands[1]));
13260 + DONE;
13261 + }
13262 + } else {
13263 + if ( flag_pic &&
13264 + GET_CODE(call_address) == SYMBOL_REF ){
13265 + current_function_uses_pic_offset_table = 1;
13266 + emit_call_insn(gen_call_internal(call_address, operands[1]));
13267 + DONE;
13268 + }
13269 +
13270 + if ( !SYMBOL_REF_RCALL_FUNCTION_P(operands[0]) ){
13271 + if ( optimize_size &&
13272 + GET_CODE(call_address) == SYMBOL_REF ){
13273 + call_address = force_const_mem(SImode, call_address);
13274 + } else {
13275 + call_address = force_reg(SImode, call_address);
13276 + }
13277 + }
13278 + }
13279 + emit_call_insn(gen_call_internal(call_address, operands[1]));
13280 + DONE;
13281 + }
13282 +)
13283 +
13284 +;;=============================================================================
13285 +;; call_value
13286 +;;-----------------------------------------------------------------------------
13287 +;; Subrutine call instruction returning a value.
13288 +;;=============================================================================
13289 +(define_expand "call_value"
13290 + [(parallel [(set (match_operand:SI 0 "" "")
13291 + (call (match_operand:SI 1 "" "")
13292 + (match_operand 2 "" "")))
13293 + (clobber (reg:SI LR_REGNUM))])]
13294 + ""
13295 + {
13296 + rtx call_address;
13297 + if ( GET_CODE(operands[1]) != MEM )
13298 + FAIL;
13299 +
13300 + call_address = XEXP(operands[1], 0);
13301 +
13302 + /* If assembler supports call pseudo insn and the call
13303 + address is a symbol then nothing special needs to be done. */
13304 + if ( TARGET_HAS_ASM_ADDR_PSEUDOS
13305 + && (GET_CODE(call_address) == SYMBOL_REF) ){
13306 + /* We must however mark the function as using the GOT if
13307 + flag_pic is set, since the call insn might turn into
13308 + a mcall using the GOT ptr register. */
13309 + if ( flag_pic ) {
13310 + current_function_uses_pic_offset_table = 1;
13311 + emit_call_insn(gen_call_value_internal(operands[0], call_address, operands[2]));
13312 + DONE;
13313 + }
13314 + } else {
13315 + if ( flag_pic &&
13316 + GET_CODE(call_address) == SYMBOL_REF ){
13317 + current_function_uses_pic_offset_table = 1;
13318 + emit_call_insn(gen_call_value_internal(operands[0], call_address, operands[2]));
13319 + DONE;
13320 + }
13321 +
13322 + if ( !SYMBOL_REF_RCALL_FUNCTION_P(operands[1]) ){
13323 + if ( optimize_size &&
13324 + GET_CODE(call_address) == SYMBOL_REF){
13325 + call_address = force_const_mem(SImode, call_address);
13326 + } else {
13327 + call_address = force_reg(SImode, call_address);
13328 + }
13329 + }
13330 + }
13331 + emit_call_insn(gen_call_value_internal(operands[0], call_address,
13332 + operands[2]));
13333 + DONE;
13334 +
13335 + })
13336 +
13337 +(define_insn "call_value_internal"
13338 + [(parallel [(set (match_operand 0 "register_operand" "=r,r,r,r")
13339 + (call (mem:SI (match_operand:SI 1 "avr32_call_operand" "r,U,T,W"))
13340 + (match_operand 2 "" "")))
13341 + (clobber (reg:SI LR_REGNUM))])]
13342 + ;; Operand 2 not used on the AVR32.
13343 + ""
13344 + {
13345 + switch (which_alternative){
13346 + case 0:
13347 + return "icall\t%1";
13348 + case 1:
13349 + return "rcall\t%1";
13350 + case 2:
13351 + return "mcall\t%1";
13352 + case 3:
13353 + if ( TARGET_HAS_ASM_ADDR_PSEUDOS )
13354 + return "call\t%1";
13355 + else
13356 + return "mcall\tr6[%1@got]";
13357 + default:
13358 + abort();
13359 + }
13360 + }
13361 + [(set_attr "type" "call")
13362 + (set_attr "length" "2,4,4,10")
13363 + (set_attr "cc" "call_set")])
13364 +
13365 +
13366 +;;=============================================================================
13367 +;; untyped_call
13368 +;;-----------------------------------------------------------------------------
13369 +;; Subrutine call instruction returning a value of any type.
13370 +;; The code is copied from m68k.md (except gen_blockage is removed)
13371 +;; Fixme!
13372 +;;=============================================================================
13373 +(define_expand "untyped_call"
13374 + [(parallel [(call (match_operand 0 "avr32_call_operand" "")
13375 + (const_int 0))
13376 + (match_operand 1 "" "")
13377 + (match_operand 2 "" "")])]
13378 + ""
13379 + {
13380 + int i;
13381 +
13382 + emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
13383 +
13384 + for (i = 0; i < XVECLEN (operands[2], 0); i++) {
13385 + rtx set = XVECEXP (operands[2], 0, i);
13386 + emit_move_insn (SET_DEST (set), SET_SRC (set));
13387 + }
13388 +
13389 + /* The optimizer does not know that the call sets the function value
13390 + registers we stored in the result block. We avoid problems by
13391 + claiming that all hard registers are used and clobbered at this
13392 + point. */
13393 + emit_insn (gen_blockage ());
13394 +
13395 + DONE;
13396 + })
13397 +
13398 +
13399 +;;=============================================================================
13400 +;; return
13401 +;;=============================================================================
13402 +
13403 +(define_insn "return"
13404 + [(return)]
13405 + "USE_RETURN_INSN (FALSE)"
13406 + {
13407 + avr32_output_return_instruction(TRUE, FALSE, NULL, NULL);
13408 + return "";
13409 + }
13410 + [(set_attr "length" "4")
13411 + (set_attr "type" "call")]
13412 + )
13413 +
13414 +(define_insn "return_cond"
13415 + [(set (pc)
13416 + (if_then_else (match_operand 0 "avr32_comparison_operand" "")
13417 + (return)
13418 + (pc)))]
13419 + "USE_RETURN_INSN (TRUE)"
13420 + "ret%0\tr12";
13421 + [(set_attr "type" "call")])
13422 +
13423 +
13424 +(define_insn "return_imm"
13425 + [(parallel [(set (reg RETVAL_REGNUM) (match_operand 0 "immediate_operand" "i"))
13426 + (use (reg RETVAL_REGNUM))
13427 + (return)])]
13428 + "USE_RETURN_INSN (FALSE) &&
13429 + ((INTVAL(operands[0]) == -1) || (INTVAL(operands[0]) == 0) || (INTVAL(operands[0]) == 1))"
13430 + {
13431 + avr32_output_return_instruction(TRUE, FALSE, NULL, operands[0]);
13432 + return "";
13433 + }
13434 + [(set_attr "length" "4")
13435 + (set_attr "type" "call")]
13436 + )
13437 +
13438 +(define_insn "return_imm_cond"
13439 + [(parallel [(set (reg RETVAL_REGNUM) (match_operand 0 "immediate_operand" "i"))
13440 + (use (reg RETVAL_REGNUM))
13441 + (set (pc)
13442 + (if_then_else (match_operand 1 "avr32_comparison_operand" "")
13443 + (return)
13444 + (pc)))])]
13445 + "USE_RETURN_INSN (TRUE) &&
13446 + ((INTVAL(operands[0]) == -1) || (INTVAL(operands[0]) == 0) || (INTVAL(operands[0]) == 1))"
13447 + "ret%1\t%0";
13448 + [(set_attr "type" "call")]
13449 + )
13450 +
13451 +(define_insn "return_<mode>reg"
13452 + [(set (reg RETVAL_REGNUM) (match_operand:MOVM 0 "register_operand" "r"))
13453 + (use (reg RETVAL_REGNUM))
13454 + (return)]
13455 + "USE_RETURN_INSN (TRUE)"
13456 + "retal %0";
13457 + [(set_attr "type" "call")]
13458 + )
13459 +
13460 +(define_insn "return_<mode>reg_cond"
13461 + [(set (reg RETVAL_REGNUM) (match_operand:MOVM 0 "register_operand" "r"))
13462 + (use (reg RETVAL_REGNUM))
13463 + (set (pc)
13464 + (if_then_else (match_operator 1 "avr32_comparison_operator"
13465 + [(cc0) (const_int 0)])
13466 + (return)
13467 + (pc)))]
13468 + "USE_RETURN_INSN (TRUE)"
13469 + "ret%1\t%0";
13470 + [(set_attr "type" "call")])
13471 +
13472 +;;=============================================================================
13473 +;; nop
13474 +;;-----------------------------------------------------------------------------
13475 +;; No-op instruction.
13476 +;;=============================================================================
13477 +(define_insn "nop"
13478 + [(const_int 0)]
13479 + ""
13480 + "nop"
13481 + [(set_attr "length" "2")
13482 + (set_attr "type" "alu")
13483 + (set_attr "cc" "none")])
13484 +
13485 +;;=============================================================================
13486 +;; nonlocal_goto_receiver
13487 +;;-----------------------------------------------------------------------------
13488 +;; For targets with a return stack we must make sure to flush the return stack
13489 +;; since it will be corrupt after a nonlocal goto.
13490 +;;=============================================================================
13491 +(define_expand "nonlocal_goto_receiver"
13492 + [(const_int 0)]
13493 + "TARGET_RETURN_STACK"
13494 + "
13495 + {
13496 + emit_insn ( gen_frs() );
13497 + DONE;
13498 + }
13499 + "
13500 + )
13501 +
13502 +
13503 +;;=============================================================================
13504 +;; builtin_setjmp_receiver
13505 +;;-----------------------------------------------------------------------------
13506 +;; For pic code we need to reload the pic register.
13507 +;; For targets with a return stack we must make sure to flush the return stack
13508 +;; since it will probably be corrupted.
13509 +;;=============================================================================
13510 +(define_expand "builtin_setjmp_receiver"
13511 + [(label_ref (match_operand 0 "" ""))]
13512 + "flag_pic"
13513 + "
13514 + {
13515 + if ( TARGET_RETURN_STACK )
13516 + emit_insn ( gen_frs() );
13517 + avr32_load_pic_register ();
13518 + DONE;
13519 + }
13520 + "
13521 +)
13522 +
13523 +
13524 +;;=============================================================================
13525 +;; indirect_jump
13526 +;;-----------------------------------------------------------------------------
13527 +;; Jump to an address in reg or memory.
13528 +;;=============================================================================
13529 +(define_expand "indirect_jump"
13530 + [(set (pc)
13531 + (match_operand:SI 0 "general_operand" ""))]
13532 + ""
13533 + {
13534 + /* One of the ops has to be in a register. */
13535 + if ( (flag_pic || TARGET_HAS_ASM_ADDR_PSEUDOS )
13536 + && !avr32_legitimate_pic_operand_p(operands[0]) )
13537 + operands[0] = legitimize_pic_address (operands[0], SImode, 0);
13538 + else if ( flag_pic && avr32_address_operand(operands[0], GET_MODE(operands[0])) )
13539 + /* If we have an address operand then this function uses the pic register. */
13540 + current_function_uses_pic_offset_table = 1;
13541 + })
13542 +
13543 +
13544 +(define_insn "indirect_jump_internal"
13545 + [(set (pc)
13546 + (match_operand:SI 0 "general_operand" "r,m,W"))]
13547 + ""
13548 + {
13549 + switch( which_alternative ){
13550 + case 0:
13551 + return "mov\tpc, %0";
13552 + case 1:
13553 + if ( avr32_const_pool_ref_operand(operands[0], GET_MODE(operands[0])) )
13554 + return "lddpc\tpc, %0";
13555 + else
13556 + return "ld.w\tpc, %0";
13557 + case 2:
13558 + if ( flag_pic )
13559 + return "ld.w\tpc, r6[%0@got]";
13560 + else
13561 + return "lda.w\tpc, %0";
13562 + default:
13563 + abort();
13564 + }
13565 + }
13566 + [(set_attr "length" "2,4,8")
13567 + (set_attr "type" "call,call,call")
13568 + (set_attr "cc" "none,none,clobber")])
13569 +
13570 +
13571 +;;=============================================================================
13572 +;; casesi and tablejump
13573 +;;=============================================================================
13574 +(define_insn "tablejump_add"
13575 + [(set (pc)
13576 + (plus:SI (match_operand:SI 0 "register_operand" "r")
13577 + (mult:SI (match_operand:SI 1 "register_operand" "r")
13578 + (match_operand:SI 2 "immediate_operand" "Ku04" ))))
13579 + (use (label_ref (match_operand 3 "" "")))]
13580 + "flag_pic &&
13581 + ((INTVAL(operands[2]) == 0) || (INTVAL(operands[2]) == 2) ||
13582 + (INTVAL(operands[2]) == 4) || (INTVAL(operands[2]) == 8))"
13583 + "add\tpc, %0, %1 << %p2"
13584 + [(set_attr "length" "4")
13585 + (set_attr "cc" "clobber")])
13586 +
13587 +(define_insn "tablejump_insn"
13588 + [(set (pc) (match_operand:SI 0 "memory_operand" "m"))
13589 + (use (label_ref (match_operand 1 "" "")))]
13590 + "!flag_pic"
13591 + "ld.w\tpc, %0"
13592 + [(set_attr "length" "4")
13593 + (set_attr "type" "call")
13594 + (set_attr "cc" "none")])
13595 +
13596 +(define_expand "casesi"
13597 + [(match_operand:SI 0 "register_operand" "") ; index to jump on
13598 + (match_operand:SI 1 "const_int_operand" "") ; lower bound
13599 + (match_operand:SI 2 "const_int_operand" "") ; total range
13600 + (match_operand:SI 3 "" "") ; table label
13601 + (match_operand:SI 4 "" "")] ; Out of range label
13602 + ""
13603 + "
13604 + {
13605 + rtx reg;
13606 + rtx index = operands[0];
13607 + rtx low_bound = operands[1];
13608 + rtx range = operands[2];
13609 + rtx table_label = operands[3];
13610 + rtx oor_label = operands[4];
13611 +
13612 + if (low_bound != const0_rtx)
13613 + {
13614 + if (!avr32_const_ok_for_constraint_p(INTVAL (low_bound), 'I', \"Is21\")){
13615 + reg = force_reg(SImode, GEN_INT (INTVAL (low_bound)));
13616 + emit_insn (gen_subsi3 (reg, index,
13617 + reg));
13618 + } else {
13619 + reg = gen_reg_rtx (SImode);
13620 + emit_insn (gen_addsi3 (reg, index,
13621 + GEN_INT (-INTVAL (low_bound))));
13622 + }
13623 + index = reg;
13624 + }
13625 +
13626 + if (!avr32_const_ok_for_constraint_p (INTVAL (range), 'K', \"Ks21\"))
13627 + range = force_reg (SImode, range);
13628 +
13629 + emit_cmp_and_jump_insns ( index, range, GTU, NULL_RTX, SImode, 1, oor_label );
13630 + reg = gen_reg_rtx (SImode);
13631 + emit_move_insn ( reg, gen_rtx_LABEL_REF (VOIDmode, table_label));
13632 +
13633 + if ( flag_pic )
13634 + emit_jump_insn ( gen_tablejump_add ( reg, index, GEN_INT(4), table_label));
13635 + else
13636 + emit_jump_insn (
13637 + gen_tablejump_insn ( gen_rtx_MEM ( SImode,
13638 + gen_rtx_PLUS ( SImode,
13639 + reg,
13640 + gen_rtx_MULT ( SImode,
13641 + index,
13642 + GEN_INT(4)))),
13643 + table_label));
13644 + DONE;
13645 + }"
13646 +)
13647 +
13648 +
13649 +
13650 +(define_insn "prefetch"
13651 + [(prefetch (match_operand:SI 0 "register_operand" "r")
13652 + (match_operand 1 "const_int_operand" "")
13653 + (match_operand 2 "const_int_operand" ""))]
13654 + ""
13655 + {
13656 + return "pref\t%0[0]";
13657 + }
13658 +
13659 + [(set_attr "length" "4")
13660 + (set_attr "type" "load")
13661 + (set_attr "cc" "none")])
13662 +
13663 +
13664 +
13665 +;;=============================================================================
13666 +;; prologue
13667 +;;-----------------------------------------------------------------------------
13668 +;; This pattern, if defined, emits RTL for entry to a function. The function
13669 +;; entry i responsible for setting up the stack frame, initializing the frame
13670 +;; pointer register, saving callee saved registers, etc.
13671 +;;=============================================================================
13672 +(define_expand "prologue"
13673 + [(clobber (const_int 0))]
13674 + ""
13675 + "
13676 + avr32_expand_prologue();
13677 + DONE;
13678 + "
13679 + )
13680 +
13681 +;;=============================================================================
13682 +;; eh_return
13683 +;;-----------------------------------------------------------------------------
13684 +;; This pattern, if defined, affects the way __builtin_eh_return, and
13685 +;; thence the call frame exception handling library routines, are
13686 +;; built. It is intended to handle non-trivial actions needed along
13687 +;; the abnormal return path.
13688 +;;
13689 +;; The address of the exception handler to which the function should
13690 +;; return is passed as operand to this pattern. It will normally need
13691 +;; to copied by the pattern to some special register or memory
13692 +;; location. If the pattern needs to determine the location of the
13693 +;; target call frame in order to do so, it may use
13694 +;; EH_RETURN_STACKADJ_RTX, if defined; it will have already been
13695 +;; assigned.
13696 +;;
13697 +;; If this pattern is not defined, the default action will be to
13698 +;; simply copy the return address to EH_RETURN_HANDLER_RTX. Either
13699 +;; that macro or this pattern needs to be defined if call frame
13700 +;; exception handling is to be used.
13701 +
13702 +;; We can't expand this before we know where the link register is stored.
13703 +(define_insn_and_split "eh_return"
13704 + [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")]
13705 + VUNSPEC_EH_RETURN)
13706 + (clobber (match_scratch:SI 1 "=&r"))]
13707 + ""
13708 + "#"
13709 + "reload_completed"
13710 + [(const_int 0)]
13711 + "
13712 + {
13713 + avr32_set_return_address (operands[0], operands[1]);
13714 + DONE;
13715 + }"
13716 + )
13717 +
13718 +;;=============================================================================
13719 +;; ffssi2
13720 +;;-----------------------------------------------------------------------------
13721 +(define_insn "ffssi2"
13722 + [ (set (match_operand:SI 0 "register_operand" "=r")
13723 + (ffs:SI (match_operand:SI 1 "register_operand" "r"))) ]
13724 + ""
13725 + "mov %0, %1
13726 + brev %0
13727 + clz %0, %0
13728 + sub %0, -1
13729 + cp %0, 33
13730 + moveq %0, 0"
13731 + [(set_attr "length" "18")
13732 + (set_attr "cc" "clobber")]
13733 + )
13734 +
13735 +
13736 +
13737 +;;=============================================================================
13738 +;; swap_h
13739 +;;-----------------------------------------------------------------------------
13740 +(define_insn "*swap_h"
13741 + [ (set (match_operand:SI 0 "register_operand" "=r")
13742 + (ior:SI (ashift:SI (match_dup 0) (const_int 16))
13743 + (lshiftrt:SI (match_dup 0) (const_int 16))))]
13744 + ""
13745 + "swap.h %0"
13746 + [(set_attr "length" "2")]
13747 + )
13748 +
13749 +(define_insn_and_split "bswap_16"
13750 + [ (set (match_operand:HI 0 "avr32_bswap_operand" "=r,RKs13,r")
13751 + (ior:HI (and:HI (lshiftrt:HI (match_operand:HI 1 "avr32_bswap_operand" "r,r,RKs13")
13752 + (const_int 8))
13753 + (const_int 255))
13754 + (ashift:HI (and:HI (match_dup 1)
13755 + (const_int 255))
13756 + (const_int 8))))]
13757 + ""
13758 + {
13759 + switch ( which_alternative ){
13760 + case 0:
13761 + if ( REGNO(operands[0]) == REGNO(operands[1]))
13762 + return "swap.bh\t%0";
13763 + else
13764 + return "mov\t%0, %1\;swap.bh\t%0";
13765 + case 1:
13766 + return "stswp.h\t%0, %1";
13767 + case 2:
13768 + return "ldswp.sh\t%0, %1";
13769 + default:
13770 + abort();
13771 + }
13772 + }
13773 +
13774 + "(reload_completed &&
13775 + REG_P(operands[0]) && REG_P(operands[1])
13776 + && (REGNO(operands[0]) != REGNO(operands[1])))"
13777 + [(set (match_dup 0) (match_dup 1))
13778 + (set (match_dup 0)
13779 + (ior:HI (and:HI (lshiftrt:HI (match_dup 0)
13780 + (const_int 8))
13781 + (const_int 255))
13782 + (ashift:HI (and:HI (match_dup 0)
13783 + (const_int 255))
13784 + (const_int 8))))]
13785 + ""
13786 +
13787 + [(set_attr "length" "4,4,4")
13788 + (set_attr "type" "alu,store,load_rm")]
13789 + )
13790 +
13791 +(define_insn_and_split "bswap_32"
13792 + [ (set (match_operand:SI 0 "avr32_bswap_operand" "=r,RKs14,r")
13793 + (ior:SI (ior:SI (lshiftrt:SI (and:SI (match_operand:SI 1 "avr32_bswap_operand" "=r,r,RKs14")
13794 + (const_int 4278190080))
13795 + (const_int 24))
13796 + (lshiftrt:SI (and:SI (match_dup 1)
13797 + (const_int 16711680))
13798 + (const_int 8)))
13799 + (ior:SI (ashift:SI (and:SI (match_dup 1)
13800 + (const_int 65280))
13801 + (const_int 8))
13802 + (ashift:SI (and:SI (match_dup 1)
13803 + (const_int 255))
13804 + (const_int 24)))))]
13805 + ""
13806 + {
13807 + switch ( which_alternative ){
13808 + case 0:
13809 + if ( REGNO(operands[0]) == REGNO(operands[1]))
13810 + return "swap.b\t%0";
13811 + else
13812 + return "mov\t%0, %1\;swap.b\t%0";
13813 + case 1:
13814 + return "stswp.w\t%0, %1";
13815 + case 2:
13816 + return "ldswp.w\t%0, %1";
13817 + default:
13818 + abort();
13819 + }
13820 + }
13821 + "(reload_completed &&
13822 + REG_P(operands[0]) && REG_P(operands[1])
13823 + && (REGNO(operands[0]) != REGNO(operands[1])))"
13824 + [(set (match_dup 0) (match_dup 1))
13825 + (set (match_dup 0)
13826 + (ior:SI (ior:SI (lshiftrt:SI (and:SI (match_dup 0)
13827 + (const_int 4278190080))
13828 + (const_int 24))
13829 + (lshiftrt:SI (and:SI (match_dup 0)
13830 + (const_int 16711680))
13831 + (const_int 8)))
13832 + (ior:SI (ashift:SI (and:SI (match_dup 0)
13833 + (const_int 65280))
13834 + (const_int 8))
13835 + (ashift:SI (and:SI (match_dup 0)
13836 + (const_int 255))
13837 + (const_int 24)))))]
13838 + ""
13839 +
13840 + [(set_attr "length" "4,4,4")
13841 + (set_attr "type" "alu,store,load_rm")]
13842 + )
13843 +
13844 +
13845 +;;=============================================================================
13846 +;; blockage
13847 +;;-----------------------------------------------------------------------------
13848 +;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
13849 +;; all of memory. This blocks insns from being moved across this point.
13850 +
13851 +(define_insn "blockage"
13852 + [(unspec_volatile [(const_int 0)] VUNSPEC_BLOCKAGE)]
13853 + ""
13854 + ""
13855 + [(set_attr "length" "0")]
13856 +)
13857 +
13858 +;;=============================================================================
13859 +;; clzsi2
13860 +;;-----------------------------------------------------------------------------
13861 +(define_insn "clzsi2"
13862 + [ (set (match_operand:SI 0 "register_operand" "=r")
13863 + (clz:SI (match_operand:SI 1 "register_operand" "r"))) ]
13864 + ""
13865 + "clz %0, %1"
13866 + [(set_attr "length" "4")
13867 + (set_attr "cc" "set_z")]
13868 + )
13869 +
13870 +;;=============================================================================
13871 +;; ctzsi2
13872 +;;-----------------------------------------------------------------------------
13873 +(define_insn "ctzsi2"
13874 + [ (set (match_operand:SI 0 "register_operand" "=r,r")
13875 + (ctz:SI (match_operand:SI 1 "register_operand" "0,r"))) ]
13876 + ""
13877 + "@
13878 + brev\t%0\;clz\t%0, %0
13879 + mov\t%0, %1\;brev\t%0\;clz\t%0, %0"
13880 + [(set_attr "length" "8")
13881 + (set_attr "cc" "set_z")]
13882 + )
13883 +
13884 +;;=============================================================================
13885 +;; cache instructions
13886 +;;-----------------------------------------------------------------------------
13887 +(define_insn "cache"
13888 + [ (unspec_volatile [(match_operand:SI 0 "register_operand" "r")
13889 + (match_operand:SI 1 "immediate_operand" "Ku05")] VUNSPEC_CACHE)]
13890 + ""
13891 + "cache %0[0], %1"
13892 + [(set_attr "length" "4")]
13893 + )
13894 +
13895 +(define_insn "sync"
13896 + [ (unspec_volatile [(match_operand:SI 0 "immediate_operand" "Ku08")] VUNSPEC_SYNC)]
13897 + ""
13898 + "sync %0"
13899 + [(set_attr "length" "4")]
13900 + )
13901 +
13902 +;;=============================================================================
13903 +;; TLB instructions
13904 +;;-----------------------------------------------------------------------------
13905 +(define_insn "tlbr"
13906 + [ (unspec_volatile [(const_int 0)] VUNSPEC_TLBR)]
13907 + ""
13908 + "tlbr"
13909 + [(set_attr "length" "2")]
13910 + )
13911 +
13912 +(define_insn "tlbw"
13913 + [ (unspec_volatile [(const_int 0)] VUNSPEC_TLBW)]
13914 + ""
13915 + "tlbw"
13916 + [(set_attr "length" "2")]
13917 + )
13918 +
13919 +(define_insn "tlbs"
13920 + [ (unspec_volatile [(const_int 0)] VUNSPEC_TLBS)]
13921 + ""
13922 + "tlbs"
13923 + [(set_attr "length" "2")]
13924 + )
13925 +
13926 +;;=============================================================================
13927 +;; Breakpoint instruction
13928 +;;-----------------------------------------------------------------------------
13929 +(define_insn "breakpoint"
13930 + [ (unspec_volatile [(const_int 0)] VUNSPEC_BREAKPOINT)]
13931 + ""
13932 + "breakpoint"
13933 + [(set_attr "length" "2")]
13934 + )
13935 +
13936 +
13937 +;;=============================================================================
13938 +;; mtsr/mfsr instruction
13939 +;;-----------------------------------------------------------------------------
13940 +(define_insn "mtsr"
13941 + [ (unspec_volatile [(match_operand 0 "immediate_operand" "i")
13942 + (match_operand:SI 1 "register_operand" "r")] VUNSPEC_MTSR)]
13943 + ""
13944 + "mtsr\t%0, %1"
13945 + [(set_attr "length" "4")]
13946 + )
13947 +
13948 +(define_insn "mfsr"
13949 + [ (set (match_operand:SI 0 "register_operand" "=r")
13950 + (unspec_volatile:SI [(match_operand 1 "immediate_operand" "i")] VUNSPEC_MFSR)) ]
13951 + ""
13952 + "mfsr\t%0, %1"
13953 + [(set_attr "length" "4")]
13954 + )
13955 +
13956 +;;=============================================================================
13957 +;; mtdr/mfdr instruction
13958 +;;-----------------------------------------------------------------------------
13959 +(define_insn "mtdr"
13960 + [ (unspec_volatile [(match_operand 0 "immediate_operand" "i")
13961 + (match_operand:SI 1 "register_operand" "r")] VUNSPEC_MTDR)]
13962 + ""
13963 + "mtdr\t%0, %1"
13964 + [(set_attr "length" "4")]
13965 + )
13966 +
13967 +(define_insn "mfdr"
13968 + [ (set (match_operand:SI 0 "register_operand" "=r")
13969 + (unspec_volatile:SI [(match_operand 1 "immediate_operand" "i")] VUNSPEC_MFDR)) ]
13970 + ""
13971 + "mfdr\t%0, %1"
13972 + [(set_attr "length" "4")]
13973 + )
13974 +
13975 +;;=============================================================================
13976 +;; musfr
13977 +;;-----------------------------------------------------------------------------
13978 +(define_insn "musfr"
13979 + [ (unspec_volatile [(match_operand:SI 0 "register_operand" "r")] VUNSPEC_MUSFR)]
13980 + ""
13981 + "musfr\t%0"
13982 + [(set_attr "length" "2")
13983 + (set_attr "cc" "clobber")]
13984 + )
13985 +
13986 +(define_insn "mustr"
13987 + [ (set (match_operand:SI 0 "register_operand" "=r")
13988 + (unspec_volatile:SI [(const_int 0)] VUNSPEC_MUSTR)) ]
13989 + ""
13990 + "mustr\t%0"
13991 + [(set_attr "length" "2")]
13992 + )
13993 +
13994 +;;=============================================================================
13995 +;; Flush Return Stack instruction
13996 +;;-----------------------------------------------------------------------------
13997 +(define_insn "frs"
13998 + [ (unspec_volatile [(const_int 0)] VUNSPEC_FRS)]
13999 + ""
14000 + "frs"
14001 + [(set_attr "length" "2")
14002 + (set_attr "cc" "none")]
14003 + )
14004 +
14005 +
14006 +;;=============================================================================
14007 +;; Saturation Round Scale instruction
14008 +;;-----------------------------------------------------------------------------
14009 +(define_insn "sats"
14010 + [ (set (match_operand:SI 0 "register_operand" "+r")
14011 + (unspec:SI [(match_dup 0)
14012 + (match_operand 1 "immediate_operand" "Ku05")
14013 + (match_operand 2 "immediate_operand" "Ku05")]
14014 + UNSPEC_SATS)) ]
14015 + "TARGET_DSP"
14016 + "sats\t%0 >> %1, %2"
14017 + [(set_attr "type" "alu_sat")
14018 + (set_attr "length" "4")]
14019 + )
14020 +
14021 +(define_insn "satu"
14022 + [ (set (match_operand:SI 0 "register_operand" "+r")
14023 + (unspec:SI [(match_dup 0)
14024 + (match_operand 1 "immediate_operand" "Ku05")
14025 + (match_operand 2 "immediate_operand" "Ku05")]
14026 + UNSPEC_SATU)) ]
14027 + "TARGET_DSP"
14028 + "satu\t%0 >> %1, %2"
14029 + [(set_attr "type" "alu_sat")
14030 + (set_attr "length" "4")]
14031 + )
14032 +
14033 +(define_insn "satrnds"
14034 + [ (set (match_operand:SI 0 "register_operand" "+r")
14035 + (unspec:SI [(match_dup 0)
14036 + (match_operand 1 "immediate_operand" "Ku05")
14037 + (match_operand 2 "immediate_operand" "Ku05")]
14038 + UNSPEC_SATRNDS)) ]
14039 + "TARGET_DSP"
14040 + "satrnds\t%0 >> %1, %2"
14041 + [(set_attr "type" "alu_sat")
14042 + (set_attr "length" "4")]
14043 + )
14044 +
14045 +(define_insn "satrndu"
14046 + [ (set (match_operand:SI 0 "register_operand" "+r")
14047 + (unspec:SI [(match_dup 0)
14048 + (match_operand 1 "immediate_operand" "Ku05")
14049 + (match_operand 2 "immediate_operand" "Ku05")]
14050 + UNSPEC_SATRNDU)) ]
14051 + "TARGET_DSP"
14052 + "sats\t%0 >> %1, %2"
14053 + [(set_attr "type" "alu_sat")
14054 + (set_attr "length" "4")]
14055 + )
14056 +
14057 +;; Special patterns for dealing with the constant pool
14058 +
14059 +(define_insn "align_4"
14060 + [(unspec_volatile [(const_int 0)] VUNSPEC_ALIGN)]
14061 + ""
14062 + {
14063 + assemble_align (32);
14064 + return "";
14065 + }
14066 + [(set_attr "length" "2")]
14067 +)
14068 +
14069 +(define_insn "consttable_start"
14070 + [(unspec_volatile [(const_int 0)] VUNSPEC_POOL_START)]
14071 + ""
14072 + {
14073 + return ".cpool";
14074 + }
14075 + [(set_attr "length" "0")]
14076 + )
14077 +
14078 +(define_insn "consttable_end"
14079 + [(unspec_volatile [(const_int 0)] VUNSPEC_POOL_END)]
14080 + ""
14081 + {
14082 + making_const_table = FALSE;
14083 + return "";
14084 + }
14085 + [(set_attr "length" "0")]
14086 +)
14087 +
14088 +
14089 +(define_insn "consttable_4"
14090 + [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_4)]
14091 + ""
14092 + {
14093 + making_const_table = TRUE;
14094 + switch (GET_MODE_CLASS (GET_MODE (operands[0])))
14095 + {
14096 + case MODE_FLOAT:
14097 + {
14098 + REAL_VALUE_TYPE r;
14099 + char real_string[1024];
14100 + REAL_VALUE_FROM_CONST_DOUBLE (r, operands[0]);
14101 + real_to_decimal(real_string, &r, 1024, 0, 1);
14102 + asm_fprintf (asm_out_file, "\t.float\t%s\n", real_string);
14103 + break;
14104 + }
14105 + default:
14106 + assemble_integer (operands[0], 4, 0, 1);
14107 + break;
14108 + }
14109 + return "";
14110 + }
14111 + [(set_attr "length" "4")]
14112 +)
14113 +
14114 +(define_insn "consttable_8"
14115 + [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_8)]
14116 + ""
14117 + {
14118 + making_const_table = TRUE;
14119 + switch (GET_MODE_CLASS (GET_MODE (operands[0])))
14120 + {
14121 + case MODE_FLOAT:
14122 + {
14123 + REAL_VALUE_TYPE r;
14124 + char real_string[1024];
14125 + REAL_VALUE_FROM_CONST_DOUBLE (r, operands[0]);
14126 + real_to_decimal(real_string, &r, 1024, 0, 1);
14127 + asm_fprintf (asm_out_file, "\t.double\t%s\n", real_string);
14128 + break;
14129 + }
14130 + default:
14131 + assemble_integer(operands[0], 8, 0, 1);
14132 + break;
14133 + }
14134 + return "";
14135 + }
14136 + [(set_attr "length" "8")]
14137 +)
14138 +
14139 +(define_insn "consttable_16"
14140 + [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_16)]
14141 + ""
14142 + {
14143 + making_const_table = TRUE;
14144 + assemble_integer(operands[0], 16, 0, 1);
14145 + return "";
14146 + }
14147 + [(set_attr "length" "16")]
14148 +)
14149 +
14150 +;;=============================================================================
14151 +;; coprocessor instructions
14152 +;;-----------------------------------------------------------------------------
14153 +(define_insn "cop"
14154 + [ (unspec_volatile [(match_operand 0 "immediate_operand" "Ku03")
14155 + (match_operand 1 "immediate_operand" "Ku04")
14156 + (match_operand 2 "immediate_operand" "Ku04")
14157 + (match_operand 3 "immediate_operand" "Ku04")
14158 + (match_operand 4 "immediate_operand" "Ku07")] VUNSPEC_COP)]
14159 + ""
14160 + "cop\tcp%0, cr%1, cr%2, cr%3, %4"
14161 + [(set_attr "length" "4")]
14162 + )
14163 +
14164 +(define_insn "mvcrsi"
14165 + [ (set (match_operand:SI 0 "avr32_cop_move_operand" "=r,<,Z")
14166 + (unspec_volatile:SI [(match_operand 1 "immediate_operand" "Ku03,Ku03,Ku03")
14167 + (match_operand 2 "immediate_operand" "Ku04,Ku04,Ku04")]
14168 + VUNSPEC_MVCR)) ]
14169 + ""
14170 + "@
14171 + mvcr.w\tcp%1, %0, cr%2
14172 + stcm.w\tcp%1, %0, cr%2
14173 + stc.w\tcp%1, %0, cr%2"
14174 + [(set_attr "length" "4")]
14175 + )
14176 +
14177 +(define_insn "mvcrdi"
14178 + [ (set (match_operand:DI 0 "avr32_cop_move_operand" "=r,<,Z")
14179 + (unspec_volatile:DI [(match_operand 1 "immediate_operand" "Ku03,Ku03,Ku03")
14180 + (match_operand 2 "immediate_operand" "Ku04,Ku04,Ku04")]
14181 + VUNSPEC_MVCR)) ]
14182 + ""
14183 + "@
14184 + mvcr.d\tcp%1, %0, cr%2
14185 + stcm.d\tcp%1, %0, cr%2-cr%i2
14186 + stc.d\tcp%1, %0, cr%2"
14187 + [(set_attr "length" "4")]
14188 + )
14189 +
14190 +(define_insn "mvrcsi"
14191 + [ (unspec_volatile:SI [(match_operand 0 "immediate_operand" "Ku03,Ku03,Ku03")
14192 + (match_operand 1 "immediate_operand" "Ku04,Ku04,Ku04")
14193 + (match_operand:SI 2 "avr32_cop_move_operand" "r,>,Z")]
14194 + VUNSPEC_MVRC)]
14195 + ""
14196 + {
14197 + switch (which_alternative){
14198 + case 0:
14199 + return "mvrc.w\tcp%0, cr%1, %2";
14200 + case 1:
14201 + return "ldcm.w\tcp%0, %2, cr%1";
14202 + case 2:
14203 + return "ldc.w\tcp%0, cr%1, %2";
14204 + default:
14205 + abort();
14206 + }
14207 + }
14208 + [(set_attr "length" "4")]
14209 + )
14210 +
14211 +(define_insn "mvrcdi"
14212 + [ (unspec_volatile:DI [(match_operand 0 "immediate_operand" "Ku03,Ku03,Ku03")
14213 + (match_operand 1 "immediate_operand" "Ku04,Ku04,Ku04")
14214 + (match_operand:DI 2 "avr32_cop_move_operand" "r,>,Z")]
14215 + VUNSPEC_MVRC)]
14216 + ""
14217 + {
14218 + switch (which_alternative){
14219 + case 0:
14220 + return "mvrc.d\tcp%0, cr%1, %2";
14221 + case 1:
14222 + return "ldcm.d\tcp%0, %2, cr%1-cr%i1";
14223 + case 2:
14224 + return "ldc.d\tcp%0, cr%1, %2";
14225 + default:
14226 + abort();
14227 + }
14228 + }
14229 + [(set_attr "length" "4")]
14230 + )
14231 +
14232 +;;=============================================================================
14233 +;; epilogue
14234 +;;-----------------------------------------------------------------------------
14235 +;; This pattern emits RTL for exit from a function. The function exit is
14236 +;; responsible for deallocating the stack frame, restoring callee saved
14237 +;; registers and emitting the return instruction.
14238 +;; ToDo: using TARGET_ASM_FUNCTION_PROLOGUE instead.
14239 +;;=============================================================================
14240 +(define_expand "epilogue"
14241 + [(unspec_volatile [(return)] VUNSPEC_EPILOGUE)]
14242 + ""
14243 + "
14244 + if (USE_RETURN_INSN (FALSE)){
14245 + emit_jump_insn (gen_return ());
14246 + DONE;
14247 + }
14248 + emit_jump_insn (gen_rtx_UNSPEC_VOLATILE (VOIDmode,
14249 + gen_rtvec (1,
14250 + gen_rtx_RETURN (VOIDmode)),
14251 + VUNSPEC_EPILOGUE));
14252 + DONE;
14253 + "
14254 + )
14255 +
14256 +(define_insn "*epilogue_insns"
14257 + [(unspec_volatile [(return)] VUNSPEC_EPILOGUE)]
14258 + ""
14259 + {
14260 + avr32_output_return_instruction (FALSE, FALSE, NULL, NULL);
14261 + return "";
14262 + }
14263 + ; Length is absolute worst case
14264 + [(set_attr "type" "branch")
14265 + (set_attr "length" "12")]
14266 + )
14267 +
14268 +(define_insn "*epilogue_insns_ret_imm"
14269 + [(parallel [(set (reg RETVAL_REGNUM) (match_operand 0 "immediate_operand" "i"))
14270 + (use (reg RETVAL_REGNUM))
14271 + (unspec_volatile [(return)] VUNSPEC_EPILOGUE)])]
14272 + "((INTVAL(operands[0]) == -1) || (INTVAL(operands[0]) == 0) || (INTVAL(operands[0]) == 1))"
14273 + {
14274 + avr32_output_return_instruction (FALSE, FALSE, NULL, operands[0]);
14275 + return "";
14276 + }
14277 + ; Length is absolute worst case
14278 + [(set_attr "type" "branch")
14279 + (set_attr "length" "12")]
14280 + )
14281 +
14282 +(define_insn "sibcall_epilogue"
14283 + [(unspec_volatile [(const_int 0)] VUNSPEC_EPILOGUE)]
14284 + ""
14285 + {
14286 + avr32_output_return_instruction (FALSE, FALSE, NULL, NULL);
14287 + return "";
14288 + }
14289 +;; Length is absolute worst case
14290 + [(set_attr "type" "branch")
14291 + (set_attr "length" "12")]
14292 + )
14293 +
14294 +(define_insn "*sibcall_epilogue_insns_ret_imm"
14295 + [(parallel [(set (reg RETVAL_REGNUM) (match_operand 0 "immediate_operand" "i"))
14296 + (use (reg RETVAL_REGNUM))
14297 + (unspec_volatile [(const_int 0)] VUNSPEC_EPILOGUE)])]
14298 + "((INTVAL(operands[0]) == -1) || (INTVAL(operands[0]) == 0) || (INTVAL(operands[0]) == 1))"
14299 + {
14300 + avr32_output_return_instruction (FALSE, FALSE, NULL, operands[0]);
14301 + return "";
14302 + }
14303 + ; Length is absolute worst case
14304 + [(set_attr "type" "branch")
14305 + (set_attr "length" "12")]
14306 + )
14307 +
14308 +(define_insn "ldxi"
14309 + [(set (match_operand:SI 0 "register_operand" "=r")
14310 + (mem:SI (plus:SI
14311 + (match_operand:SI 1 "register_operand" "r")
14312 + (mult:SI (zero_extract:SI (match_operand:SI 2 "register_operand" "r")
14313 + (const_int 8)
14314 + (match_operand:SI 3 "immediate_operand" "Ku05"))
14315 + (const_int 4)))))]
14316 + "(INTVAL(operands[3]) == 24 || INTVAL(operands[3]) == 16 || INTVAL(operands[3]) == 8
14317 + || INTVAL(operands[3]) == 0)"
14318 + {
14319 + switch ( INTVAL(operands[3]) ){
14320 + case 0:
14321 + return "ld.w %0, %1[%2:b << 2]";
14322 + case 8:
14323 + return "ld.w %0, %1[%2:l << 2]";
14324 + case 16:
14325 + return "ld.w %0, %1[%2:u << 2]";
14326 + case 24:
14327 + return "ld.w %0, %1[%2:t << 2]";
14328 + default:
14329 + internal_error("illegal operand for ldxi");
14330 + }
14331 + }
14332 + [(set_attr "type" "load")
14333 + (set_attr "length" "4")
14334 + (set_attr "cc" "none")])
14335 +
14336 +
14337 +
14338 +
14339 +
14340 +
14341 +;;=============================================================================
14342 +;; Peephole optimizing
14343 +;;-----------------------------------------------------------------------------
14344 +;; Changing
14345 +;; sub r8, r7, 8
14346 +;; st.w r8[0x0], r12
14347 +;; to
14348 +;; sub r8, r7, 8
14349 +;; st.w r7[-0x8], r12
14350 +;;=============================================================================
14351 +; (set (reg:SI 9 r8)
14352 +; (plus:SI (reg/f:SI 6 r7)
14353 +; (const_int ...)))
14354 +; (set (mem:SI (reg:SI 9 r8))
14355 +; (reg:SI 12 r12))
14356 +(define_peephole2
14357 + [(set (match_operand:SI 0 "register_operand" "")
14358 + (plus:SI (match_operand:SI 1 "register_operand" "")
14359 + (match_operand:SI 2 "immediate_operand" "")))
14360 + (set (mem:SI (match_dup 0))
14361 + (match_operand:SI 3 "register_operand" ""))]
14362 + "REGNO(operands[0]) != REGNO(operands[1]) && avr32_const_ok_for_constraint_p(INTVAL(operands[2]), 'K', \"Ks16\")"
14363 + [(set (match_dup 0)
14364 + (plus:SI (match_dup 1)
14365 + (match_dup 2)))
14366 + (set (mem:SI (plus:SI (match_dup 1)
14367 + (match_dup 2)))
14368 + (match_dup 3))]
14369 + "")
14370 +
14371 +;;=============================================================================
14372 +;; Peephole optimizing
14373 +;;-----------------------------------------------------------------------------
14374 +;; Changing
14375 +;; sub r6, r7, 4
14376 +;; ld.w r6, r6[0x0]
14377 +;; to
14378 +;; sub r6, r7, 4
14379 +;; ld.w r6, r7[-0x4]
14380 +;;=============================================================================
14381 +; (set (reg:SI 7 r6)
14382 +; (plus:SI (reg/f:SI 6 r7)
14383 +; (const_int -4 [0xfffffffc])))
14384 +; (set (reg:SI 7 r6)
14385 +; (mem:SI (reg:SI 7 r6)))
14386 +(define_peephole2
14387 + [(set (match_operand:SI 0 "register_operand" "")
14388 + (plus:SI (match_operand:SI 1 "register_operand" "")
14389 + (match_operand:SI 2 "immediate_operand" "")))
14390 + (set (match_operand:SI 3 "register_operand" "")
14391 + (mem:SI (match_dup 0)))]
14392 + "REGNO(operands[0]) != REGNO(operands[1]) && avr32_const_ok_for_constraint_p(INTVAL(operands[2]), 'K', \"Ks16\")"
14393 + [(set (match_dup 0)
14394 + (plus:SI (match_dup 1)
14395 + (match_dup 2)))
14396 + (set (match_dup 3)
14397 + (mem:SI (plus:SI (match_dup 1)
14398 + (match_dup 2))))]
14399 + "")
14400 +
14401 +;;=============================================================================
14402 +;; Peephole optimizing
14403 +;;-----------------------------------------------------------------------------
14404 +;; Changing
14405 +;; ld.sb r0, r7[-0x6]
14406 +;; cashs.b r0
14407 +;; to
14408 +;; ld.sb r0, r7[-0x6]
14409 +;;=============================================================================
14410 +(define_peephole2
14411 + [(set (match_operand:QI 0 "register_operand" "")
14412 + (match_operand:QI 1 "load_sb_memory_operand" ""))
14413 + (set (match_operand:SI 2 "register_operand" "")
14414 + (sign_extend:SI (match_dup 0)))]
14415 + "(REGNO(operands[0]) == REGNO(operands[2]) || peep2_reg_dead_p(2, operands[0]))"
14416 + [(set (match_dup 2)
14417 + (sign_extend:SI (match_dup 1)))]
14418 + "")
14419 +
14420 +;;=============================================================================
14421 +;; Peephole optimizing
14422 +;;-----------------------------------------------------------------------------
14423 +;; Changing
14424 +;; ld.ub r0, r7[-0x6]
14425 +;; cashu.b r0
14426 +;; to
14427 +;; ld.ub r0, r7[-0x6]
14428 +;;=============================================================================
14429 +(define_peephole2
14430 + [(set (match_operand:QI 0 "register_operand" "")
14431 + (match_operand:QI 1 "memory_operand" ""))
14432 + (set (match_operand:SI 2 "register_operand" "")
14433 + (zero_extend:SI (match_dup 0)))]
14434 + "(REGNO(operands[0]) == REGNO(operands[2])) || peep2_reg_dead_p(2, operands[0])"
14435 + [(set (match_dup 2)
14436 + (zero_extend:SI (match_dup 1)))]
14437 + "")
14438 +
14439 +;;=============================================================================
14440 +;; Peephole optimizing
14441 +;;-----------------------------------------------------------------------------
14442 +;; Changing
14443 +;; ld.sh r0, r7[-0x6]
14444 +;; casts.h r0
14445 +;; to
14446 +;; ld.sh r0, r7[-0x6]
14447 +;;=============================================================================
14448 +(define_peephole2
14449 + [(set (match_operand:HI 0 "register_operand" "")
14450 + (match_operand:HI 1 "memory_operand" ""))
14451 + (set (match_operand:SI 2 "register_operand" "")
14452 + (sign_extend:SI (match_dup 0)))]
14453 + "(REGNO(operands[0]) == REGNO(operands[2])) || peep2_reg_dead_p(2, operands[0])"
14454 + [(set (match_dup 2)
14455 + (sign_extend:SI (match_dup 1)))]
14456 + "")
14457 +
14458 +;;=============================================================================
14459 +;; Peephole optimizing
14460 +;;-----------------------------------------------------------------------------
14461 +;; Changing
14462 +;; ld.uh r0, r7[-0x6]
14463 +;; castu.h r0
14464 +;; to
14465 +;; ld.uh r0, r7[-0x6]
14466 +;;=============================================================================
14467 +(define_peephole2
14468 + [(set (match_operand:HI 0 "register_operand" "")
14469 + (match_operand:HI 1 "memory_operand" ""))
14470 + (set (match_operand:SI 2 "register_operand" "")
14471 + (zero_extend:SI (match_dup 0)))]
14472 + "(REGNO(operands[0]) == REGNO(operands[2])) || peep2_reg_dead_p(2, operands[0])"
14473 + [(set (match_dup 2)
14474 + (zero_extend:SI (match_dup 1)))]
14475 + "")
14476 +
14477 +;;=============================================================================
14478 +;; Peephole optimizing
14479 +;;-----------------------------------------------------------------------------
14480 +;; Changing
14481 +;; mul rd, rx, ry
14482 +;; add rd2, rd
14483 +;; to
14484 +;; mac rd2, rx, ry
14485 +;;=============================================================================
14486 +(define_peephole2
14487 + [(set (match_operand:SI 0 "register_operand" "")
14488 + (mult:SI (match_operand:SI 1 "register_operand" "")
14489 + (match_operand:SI 2 "register_operand" "")))
14490 + (set (match_operand:SI 3 "register_operand" "")
14491 + (plus:SI (match_dup 3)
14492 + (match_dup 0)))]
14493 + "peep2_reg_dead_p(2, operands[0])"
14494 + [(set (match_dup 3)
14495 + (plus:SI (mult:SI (match_dup 1)
14496 + (match_dup 2))
14497 + (match_dup 3)))]
14498 + "")
14499 +
14500 +
14501 +
14502 +;;=============================================================================
14503 +;; Peephole optimizing
14504 +;;-----------------------------------------------------------------------------
14505 +;; Changing
14506 +;; bfextu rd, rs, k5, 1 or and(h/l) rd, one_bit_set_mask
14507 +;; to
14508 +;; bld rs, k5
14509 +;;
14510 +;; If rd is dead after the operation.
14511 +;;=============================================================================
14512 +(define_peephole2
14513 + [ (set (match_operand:SI 0 "register_operand" "")
14514 + (zero_extract:SI (match_operand:SI 1 "register_operand" "")
14515 + (const_int 1)
14516 + (match_operand:SI 2 "immediate_operand" "")))
14517 + (set (cc0)
14518 + (match_dup 0))]
14519 + "peep2_reg_dead_p(2, operands[0])"
14520 + [(set (cc0)
14521 + (and:SI (match_dup 1)
14522 + (match_dup 2)))]
14523 + "operands[2] = GEN_INT(1 << INTVAL(operands[2]));")
14524 +
14525 +(define_peephole2
14526 + [ (set (match_operand:SI 0 "register_operand" "")
14527 + (and:SI (match_operand:SI 1 "register_operand" "")
14528 + (match_operand:SI 2 "one_bit_set_operand" "")))
14529 + (set (cc0)
14530 + (match_dup 0))]
14531 + "peep2_reg_dead_p(2, operands[0])"
14532 + [(set (cc0)
14533 + (and:SI (match_dup 1)
14534 + (match_dup 2)))]
14535 + "")
14536 +
14537 +;;=============================================================================
14538 +;; Peephole optimizing
14539 +;;-----------------------------------------------------------------------------
14540 +;; Load with extracted index: ld.w Rd, Rb[Ri:{t/u/b/l} << 2]
14541 +;;
14542 +;;=============================================================================
14543 +
14544 +
14545 +(define_peephole
14546 + [(set (match_operand:SI 0 "register_operand" "")
14547 + (zero_extract:SI (match_operand:SI 1 "register_operand" "")
14548 + (const_int 8)
14549 + (match_operand:SI 2 "avr32_extract_shift_operand" "")))
14550 + (set (match_operand:SI 3 "register_operand" "")
14551 + (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
14552 + (match_operand:SI 4 "register_operand" ""))))]
14553 +
14554 + "(dead_or_set_p(insn, operands[0]))"
14555 + {
14556 + switch ( INTVAL(operands[2]) ){
14557 + case 0:
14558 + return "ld.w %3, %4[%1:b << 2]";
14559 + case 8:
14560 + return "ld.w %3, %4[%1:l << 2]";
14561 + case 16:
14562 + return "ld.w %3, %4[%1:u << 2]";
14563 + case 24:
14564 + return "ld.w %3, %4[%1:t << 2]";
14565 + default:
14566 + internal_error("illegal operand for ldxi");
14567 + }
14568 + }
14569 + [(set_attr "type" "load")
14570 + (set_attr "length" "4")
14571 + (set_attr "cc" "clobber")]
14572 + )
14573 +
14574 +
14575 +
14576 +(define_peephole
14577 + [(set (match_operand:SI 0 "register_operand" "")
14578 + (and:SI (match_operand:SI 1 "register_operand" "") (const_int 255)))
14579 + (set (match_operand:SI 2 "register_operand" "")
14580 + (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
14581 + (match_operand:SI 3 "register_operand" ""))))]
14582 +
14583 + "(dead_or_set_p(insn, operands[0]))"
14584 +
14585 + "ld.w %2, %3[%1:b << 2]"
14586 + [(set_attr "type" "load")
14587 + (set_attr "length" "4")
14588 + (set_attr "cc" "clobber")]
14589 + )
14590 +
14591 +
14592 +(define_peephole2
14593 + [(set (match_operand:SI 0 "register_operand" "")
14594 + (zero_extract:SI (match_operand:SI 1 "register_operand" "")
14595 + (const_int 8)
14596 + (match_operand:SI 2 "avr32_extract_shift_operand" "")))
14597 + (set (match_operand:SI 3 "register_operand" "")
14598 + (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
14599 + (match_operand:SI 4 "register_operand" ""))))]
14600 +
14601 + "(peep2_reg_dead_p(2, operands[0]))
14602 + || (REGNO(operands[0]) == REGNO(operands[3]))"
14603 + [(set (match_dup 3)
14604 + (mem:SI (plus:SI
14605 + (match_dup 4)
14606 + (mult:SI (zero_extract:SI (match_dup 1)
14607 + (const_int 8)
14608 + (match_dup 2))
14609 + (const_int 4)))))]
14610 + )
14611 +
14612 +(define_peephole2
14613 + [(set (match_operand:SI 0 "register_operand" "")
14614 + (zero_extend:SI (match_operand:QI 1 "register_operand" "")))
14615 + (set (match_operand:SI 2 "register_operand" "")
14616 + (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
14617 + (match_operand:SI 3 "register_operand" ""))))]
14618 +
14619 + "(peep2_reg_dead_p(2, operands[0]))
14620 + || (REGNO(operands[0]) == REGNO(operands[2]))"
14621 + [(set (match_dup 2)
14622 + (mem:SI (plus:SI
14623 + (match_dup 3)
14624 + (mult:SI (zero_extract:SI (match_dup 1)
14625 + (const_int 8)
14626 + (const_int 0))
14627 + (const_int 4)))))]
14628 + "operands[1] = gen_rtx_REG(SImode, REGNO(operands[1]));"
14629 + )
14630 +
14631 +
14632 +(define_peephole2
14633 + [(set (match_operand:SI 0 "register_operand" "")
14634 + (and:SI (match_operand:SI 1 "register_operand" "")
14635 + (const_int 255)))
14636 + (set (match_operand:SI 2 "register_operand" "")
14637 + (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
14638 + (match_operand:SI 3 "register_operand" ""))))]
14639 +
14640 + "(peep2_reg_dead_p(2, operands[0]))
14641 + || (REGNO(operands[0]) == REGNO(operands[2]))"
14642 + [(set (match_dup 2)
14643 + (mem:SI (plus:SI
14644 + (match_dup 3)
14645 + (mult:SI (zero_extract:SI (match_dup 1)
14646 + (const_int 8)
14647 + (const_int 0))
14648 + (const_int 4)))))]
14649 + ""
14650 + )
14651 +
14652 +
14653 +
14654 +(define_peephole2
14655 + [(set (match_operand:SI 0 "register_operand" "")
14656 + (lshiftrt:SI (match_operand:SI 1 "register_operand" "")
14657 + (const_int 24)))
14658 + (set (match_operand:SI 2 "register_operand" "")
14659 + (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
14660 + (match_operand:SI 3 "register_operand" ""))))]
14661 +
14662 + "(peep2_reg_dead_p(2, operands[0]))
14663 + || (REGNO(operands[0]) == REGNO(operands[2]))"
14664 + [(set (match_dup 2)
14665 + (mem:SI (plus:SI
14666 + (match_dup 3)
14667 + (mult:SI (zero_extract:SI (match_dup 1)
14668 + (const_int 8)
14669 + (const_int 24))
14670 + (const_int 4)))))]
14671 + ""
14672 + )
14673 +
14674 +
14675 +;;************************************************
14676 +;; ANDN
14677 +;;
14678 +;;************************************************
14679 +
14680 +
14681 +(define_peephole2
14682 + [(set (match_operand:SI 0 "register_operand" "")
14683 + (not:SI (match_operand:SI 1 "register_operand" "")))
14684 + (set (match_operand:SI 2 "register_operand" "")
14685 + (and:SI (match_dup 2)
14686 + (match_dup 0)))]
14687 + "peep2_reg_dead_p(2, operands[0])"
14688 +
14689 + [(set (match_dup 2)
14690 + (and:SI (match_dup 2)
14691 + (not:SI (match_dup 1))
14692 + ))]
14693 + ""
14694 +)
14695 +
14696 +(define_peephole2
14697 + [(set (match_operand:SI 0 "register_operand" "")
14698 + (not:SI (match_operand:SI 1 "register_operand" "")))
14699 + (set (match_operand:SI 2 "register_operand" "")
14700 + (and:SI (match_dup 0)
14701 + (match_dup 2)
14702 + ))]
14703 + "peep2_reg_dead_p(2, operands[0])"
14704 +
14705 + [(set (match_dup 2)
14706 + (and:SI (match_dup 2)
14707 + (not:SI (match_dup 1))
14708 + ))]
14709 +
14710 + ""
14711 +)
14712 +
14713 +
14714 +;;=================================================================
14715 +;; Addabs peephole
14716 +;;=================================================================
14717 +
14718 +(define_peephole
14719 + [(set (match_operand:SI 2 "register_operand" "=r")
14720 + (abs:SI (match_operand:SI 1 "register_operand" "r")))
14721 + (set (match_operand:SI 0 "register_operand" "=r")
14722 + (plus:SI (match_operand:SI 3 "register_operand" "r")
14723 + (match_dup 2)))]
14724 + "dead_or_set_p(insn, operands[2])"
14725 + "addabs %0, %3, %1"
14726 + [(set_attr "length" "4")
14727 + (set_attr "cc" "set_z")])
14728 +
14729 +(define_peephole
14730 + [(set (match_operand:SI 2 "register_operand" "=r")
14731 + (abs:SI (match_operand:SI 1 "register_operand" "r")))
14732 + (set (match_operand:SI 0 "register_operand" "=r")
14733 + (plus:SI (match_dup 2)
14734 + (match_operand:SI 3 "register_operand" "r")))]
14735 + "dead_or_set_p(insn, operands[2])"
14736 + "addabs %0, %3, %1"
14737 + [(set_attr "length" "4")
14738 + (set_attr "cc" "set_z")])
14739 +
14740 +
14741 +;;=================================================================
14742 +;; Detect roundings
14743 +;;=================================================================
14744 +
14745 +(define_insn "*round"
14746 + [(set (match_operand:SI 0 "register_operand" "=r")
14747 + (ashiftrt:SI (plus:SI (match_operand:SI 1 "register_operand" "0")
14748 + (match_operand:SI 2 "immediate_operand" "i"))
14749 + (match_operand:SI 3 "immediate_operand" "i")))]
14750 + "avr32_rnd_operands(operands[2], operands[3])"
14751 +
14752 + "satrnds %0 >> %3, 31"
14753 +
14754 + [(set_attr "type" "alu_sat")
14755 + (set_attr "length" "4")]
14756 +
14757 + )
14758 +
14759 +
14760 +(define_peephole2
14761 + [(set (match_operand:SI 0 "register_operand" "")
14762 + (plus:SI (match_dup 0)
14763 + (match_operand:SI 1 "immediate_operand" "")))
14764 + (set (match_dup 0)
14765 + (ashiftrt:SI (match_dup 0)
14766 + (match_operand:SI 2 "immediate_operand" "")))]
14767 + "avr32_rnd_operands(operands[1], operands[2])"
14768 +
14769 + [(set (match_dup 0)
14770 + (ashiftrt:SI (plus:SI (match_dup 0)
14771 + (match_dup 1))
14772 + (match_dup 2)))]
14773 + )
14774 +
14775 +(define_peephole
14776 + [(set (match_operand:SI 0 "register_operand" "r")
14777 + (plus:SI (match_dup 0)
14778 + (match_operand:SI 1 "immediate_operand" "i")))
14779 + (set (match_dup 0)
14780 + (ashiftrt:SI (match_dup 0)
14781 + (match_operand:SI 2 "immediate_operand" "i")))]
14782 + "avr32_rnd_operands(operands[1], operands[2])"
14783 +
14784 + "satrnds %0 >> %2, 31"
14785 +
14786 + [(set_attr "type" "alu_sat")
14787 + (set_attr "length" "4")
14788 + (set_attr "cc" "clobber")]
14789 +
14790 + )
14791 +
14792 +
14793 +;;=================================================================
14794 +;; mcall
14795 +;;=================================================================
14796 +(define_peephole
14797 + [(set (match_operand:SI 0 "register_operand" "")
14798 + (match_operand 1 "avr32_const_pool_ref_operand" ""))
14799 + (parallel [(call (mem:SI (match_dup 0))
14800 + (match_operand 2 "" ""))
14801 + (clobber (reg:SI LR_REGNUM))])]
14802 + "dead_or_set_p(insn, operands[0])"
14803 + "mcall %1"
14804 + [(set_attr "type" "call")
14805 + (set_attr "length" "4")
14806 + (set_attr "cc" "clobber")]
14807 +)
14808 +
14809 +(define_peephole
14810 + [(set (match_operand:SI 2 "register_operand" "")
14811 + (match_operand 1 "avr32_const_pool_ref_operand" ""))
14812 + (parallel [(set (match_operand 0 "register_operand" "")
14813 + (call (mem:SI (match_dup 2))
14814 + (match_operand 3 "" "")))
14815 + (clobber (reg:SI LR_REGNUM))])]
14816 + "dead_or_set_p(insn, operands[2])"
14817 + "mcall %1"
14818 + [(set_attr "type" "call")
14819 + (set_attr "length" "4")
14820 + (set_attr "cc" "call_set")]
14821 +)
14822 +
14823 +
14824 +(define_peephole2
14825 + [(set (match_operand:SI 0 "register_operand" "")
14826 + (match_operand 1 "avr32_const_pool_ref_operand" ""))
14827 + (parallel [(call (mem:SI (match_dup 0))
14828 + (match_operand 2 "" ""))
14829 + (clobber (reg:SI LR_REGNUM))])]
14830 + "peep2_reg_dead_p(2, operands[0])"
14831 + [(parallel [(call (mem:SI (match_dup 1))
14832 + (match_dup 2))
14833 + (clobber (reg:SI LR_REGNUM))])]
14834 + ""
14835 +)
14836 +
14837 +(define_peephole2
14838 + [(set (match_operand:SI 0 "register_operand" "")
14839 + (match_operand 1 "avr32_const_pool_ref_operand" ""))
14840 + (parallel [(set (match_operand 2 "register_operand" "")
14841 + (call (mem:SI (match_dup 0))
14842 + (match_operand 3 "" "")))
14843 + (clobber (reg:SI LR_REGNUM))])]
14844 + "(peep2_reg_dead_p(2, operands[0]) || (REGNO(operands[2]) == REGNO(operands[0])))"
14845 + [(parallel [(set (match_dup 2)
14846 + (call (mem:SI (match_dup 1))
14847 + (match_dup 3)))
14848 + (clobber (reg:SI LR_REGNUM))])]
14849 + ""
14850 +)
14851 +
14852 +;;=================================================================
14853 +;; Returning a value
14854 +;;=================================================================
14855 +
14856 +
14857 +(define_peephole
14858 + [(set (match_operand 0 "register_operand" "")
14859 + (match_operand 1 "register_operand" ""))
14860 + (return)]
14861 + "USE_RETURN_INSN (TRUE) && (REGNO(operands[0]) == RETVAL_REGNUM)
14862 + && (REGNO(operands[1]) != LR_REGNUM)
14863 + && (REGNO_REG_CLASS(REGNO(operands[1])) == GENERAL_REGS)"
14864 + "retal %1"
14865 + [(set_attr "type" "call")
14866 + (set_attr "length" "2")]
14867 + )
14868 +
14869 +
14870 +(define_peephole
14871 + [(set (match_operand 0 "register_operand" "r")
14872 + (match_operand 1 "immediate_operand" "i"))
14873 + (return)]
14874 + "(USE_RETURN_INSN (FALSE) && (REGNO(operands[0]) == RETVAL_REGNUM) &&
14875 + ((INTVAL(operands[1]) == -1) || (INTVAL(operands[1]) == 0) || (INTVAL(operands[1]) == 1)))"
14876 + {
14877 + avr32_output_return_instruction (TRUE, FALSE, NULL, operands[1]);
14878 + return "";
14879 + }
14880 + [(set_attr "type" "call")
14881 + (set_attr "length" "4")]
14882 + )
14883 +
14884 +(define_peephole
14885 + [(set (match_operand 0 "register_operand" "r")
14886 + (match_operand 1 "immediate_operand" "i"))
14887 + (unspec_volatile [(return)] VUNSPEC_EPILOGUE)]
14888 + "(REGNO(operands[0]) == RETVAL_REGNUM) &&
14889 + ((INTVAL(operands[1]) == -1) || (INTVAL(operands[1]) == 0) || (INTVAL(operands[1]) == 1))"
14890 + {
14891 + avr32_output_return_instruction (FALSE, FALSE, NULL, operands[1]);
14892 + return "";
14893 + }
14894 + ; Length is absolute worst case
14895 + [(set_attr "type" "branch")
14896 + (set_attr "length" "12")]
14897 + )
14898 +
14899 +(define_peephole
14900 + [(set (match_operand 0 "register_operand" "=r")
14901 + (if_then_else (match_operator 1 "avr32_comparison_operator"
14902 + [(match_operand 4 "register_operand" "r")
14903 + (match_operand 5 "register_immediate_operand" "rKs21")])
14904 + (match_operand 2 "avr32_cond_register_immediate_operand" "rKs08")
14905 + (match_operand 3 "avr32_cond_register_immediate_operand" "rKs08")))
14906 + (return)]
14907 + "USE_RETURN_INSN (TRUE) && (REGNO(operands[0]) == RETVAL_REGNUM)"
14908 + {
14909 + operands[1] = avr32_output_cmp(operands[1], GET_MODE(operands[4]), operands[4], operands[5]);
14910 +
14911 + if ( GET_CODE(operands[2]) == REG
14912 + && GET_CODE(operands[3]) == REG
14913 + && REGNO(operands[2]) != LR_REGNUM
14914 + && REGNO(operands[3]) != LR_REGNUM ){
14915 + return "ret%1 %2\;ret%i1 %3";
14916 + } else if ( GET_CODE(operands[2]) == REG
14917 + && GET_CODE(operands[3]) == CONST_INT ){
14918 + if ( INTVAL(operands[3]) == -1
14919 + || INTVAL(operands[3]) == 0
14920 + || INTVAL(operands[3]) == 1 ){
14921 + return "ret%1 %2\;ret%i1 %d3";
14922 + } else {
14923 + return "mov%1 r12, %2\;mov%i1 r12, %3\;retal r12";
14924 + }
14925 + } else if ( GET_CODE(operands[2]) == CONST_INT
14926 + && GET_CODE(operands[3]) == REG ){
14927 + if ( INTVAL(operands[2]) == -1
14928 + || INTVAL(operands[2]) == 0
14929 + || INTVAL(operands[2]) == 1 ){
14930 + return "ret%1 %d2\;ret%i1 %3";
14931 + } else {
14932 + return "mov%1 r12, %2\;mov%i1 r12, %3\;retal r12";
14933 + }
14934 + } else {
14935 + if ( (INTVAL(operands[2]) == -1
14936 + || INTVAL(operands[2]) == 0
14937 + || INTVAL(operands[2]) == 1 )
14938 + && (INTVAL(operands[3]) == -1
14939 + || INTVAL(operands[3]) == 0
14940 + || INTVAL(operands[3]) == 1 )){
14941 + return "ret%1 %d2\;ret%i1 %d3";
14942 + } else {
14943 + return "mov%1 r12, %2\;mov%i1 r12, %3\;retal r12";
14944 + }
14945 + }
14946 + }
14947 +
14948 + [(set_attr "length" "10")
14949 + (set_attr "cc" "none")
14950 + (set_attr "type" "call")])
14951 +
14952 +
14953 +;;=================================================================
14954 +;; mulnhh.w
14955 +;;=================================================================
14956 +
14957 +(define_peephole2
14958 + [(set (match_operand:HI 0 "register_operand" "")
14959 + (neg:HI (match_operand:HI 1 "register_operand" "")))
14960 + (set (match_operand:SI 2 "register_operand" "")
14961 + (mult:SI
14962 + (sign_extend:SI (match_dup 0))
14963 + (sign_extend:SI (match_operand:HI 3 "register_operand" ""))))]
14964 + "(peep2_reg_dead_p(2, operands[0])) || (REGNO(operands[2]) == REGNO(operands[0]))"
14965 + [ (set (match_dup 2)
14966 + (mult:SI
14967 + (sign_extend:SI (neg:HI (match_dup 1)))
14968 + (sign_extend:SI (match_dup 3))))]
14969 + ""
14970 + )
14971 +
14972 +(define_peephole2
14973 + [(set (match_operand:HI 0 "register_operand" "")
14974 + (neg:HI (match_operand:HI 1 "register_operand" "")))
14975 + (set (match_operand:SI 2 "register_operand" "")
14976 + (mult:SI
14977 + (sign_extend:SI (match_operand:HI 3 "register_operand" ""))
14978 + (sign_extend:SI (match_dup 0))))]
14979 + "(peep2_reg_dead_p(2, operands[0])) || (REGNO(operands[2]) == REGNO(operands[0]))"
14980 + [ (set (match_dup 2)
14981 + (mult:SI
14982 + (sign_extend:SI (neg:HI (match_dup 1)))
14983 + (sign_extend:SI (match_dup 3))))]
14984 + ""
14985 + )
14986 +
14987 +
14988 +
14989 +;;=================================================================
14990 +;; Vector set and extract operations
14991 +;;=================================================================
14992 +(define_insn "vec_setv2hi_hi"
14993 + [(set (match_operand:V2HI 0 "register_operand" "=r")
14994 + (vec_merge:V2HI
14995 + (match_dup 0)
14996 + (vec_duplicate:V2HI
14997 + (match_operand:HI 1 "register_operand" "r"))
14998 + (const_int 1)))]
14999 + ""
15000 + "bfins\t%0, %1, 16, 16"
15001 + [(set_attr "type" "alu")
15002 + (set_attr "length" "4")
15003 + (set_attr "cc" "clobber")])
15004 +
15005 +(define_insn "vec_setv2hi_lo"
15006 + [(set (match_operand:V2HI 0 "register_operand" "+r")
15007 + (vec_merge:V2HI
15008 + (match_dup 0)
15009 + (vec_duplicate:V2HI
15010 + (match_operand:HI 1 "register_operand" "r"))
15011 + (const_int 2)))]
15012 + ""
15013 + "bfins\t%0, %1, 0, 16"
15014 + [(set_attr "type" "alu")
15015 + (set_attr "length" "4")
15016 + (set_attr "cc" "clobber")])
15017 +
15018 +(define_expand "vec_setv2hi"
15019 + [(set (match_operand:V2HI 0 "register_operand" "")
15020 + (vec_merge:V2HI
15021 + (match_dup 0)
15022 + (vec_duplicate:V2HI
15023 + (match_operand:HI 1 "register_operand" ""))
15024 + (match_operand 2 "immediate_operand" "")))]
15025 + ""
15026 + { operands[2] = GEN_INT(INTVAL(operands[2]) + 1); }
15027 + )
15028 +
15029 +(define_insn "vec_extractv2hi"
15030 + [(set (match_operand:HI 0 "register_operand" "=r")
15031 + (vec_select:HI
15032 + (match_operand:V2HI 1 "register_operand" "r")
15033 + (parallel [(match_operand:SI 2 "immediate_operand" "i")])))]
15034 + ""
15035 + {
15036 + if ( INTVAL(operands[2]) == 0 )
15037 + return "bfextu\t%0, %1, 16, 16";
15038 + else
15039 + return "bfextu\t%0, %1, 0, 16";
15040 + }
15041 + [(set_attr "type" "alu")
15042 + (set_attr "length" "4")
15043 + (set_attr "cc" "clobber")])
15044 +
15045 +(define_insn "vec_extractv4qi"
15046 + [(set (match_operand:QI 0 "register_operand" "=r")
15047 + (vec_select:QI
15048 + (match_operand:V4QI 1 "register_operand" "r")
15049 + (parallel [(match_operand:SI 2 "immediate_operand" "i")])))]
15050 + ""
15051 + {
15052 + switch ( INTVAL(operands[2]) ){
15053 + case 0:
15054 + return "bfextu\t%0, %1, 24, 8";
15055 + case 1:
15056 + return "bfextu\t%0, %1, 16, 8";
15057 + case 2:
15058 + return "bfextu\t%0, %1, 8, 8";
15059 + case 3:
15060 + return "bfextu\t%0, %1, 0, 8";
15061 + default:
15062 + abort();
15063 + }
15064 + }
15065 + [(set_attr "type" "alu")
15066 + (set_attr "length" "4")
15067 + (set_attr "cc" "clobber")])
15068 +
15069 +
15070 +(define_insn "concatv2hi"
15071 + [(set (match_operand:V2HI 0 "register_operand" "=r, r, r")
15072 + (vec_concat:V2HI
15073 + (match_operand:HI 1 "register_operand" "r, r, 0")
15074 + (match_operand:HI 2 "register_operand" "r, 0, r")))]
15075 + ""
15076 + "@
15077 + mov\t%0, %1\;bfins\t%0, %2, 0, 16
15078 + bfins\t%0, %2, 0, 16
15079 + bfins\t%0, %1, 16, 16"
15080 + [(set_attr "length" "6, 4, 4")
15081 + (set_attr "type" "alu")])
15082 +
15083 +
15084 +;; Load the atomic operation description
15085 +(include "sync.md")
15086 +
15087 +;; Load the SIMD description
15088 +(include "simd.md")
15089 +
15090 +;; Load the FP coprocessor patterns
15091 +(include "fpcp.md")
15092 Index: gcc-4.2.3/gcc/config/avr32/avr32-modes.def
15093 ===================================================================
15094 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
15095 +++ gcc-4.2.3/gcc/config/avr32/avr32-modes.def 2008-05-21 13:45:54.165287871 +0200
15096 @@ -0,0 +1 @@
15097 +VECTOR_MODES (INT, 4); /* V4QI V2HI */
15098 Index: gcc-4.2.3/gcc/config/avr32/avr32.opt
15099 ===================================================================
15100 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
15101 +++ gcc-4.2.3/gcc/config/avr32/avr32.opt 2008-05-21 13:45:54.165287871 +0200
15102 @@ -0,0 +1,73 @@
15103 +; Options for the ATMEL AVR32 port of the compiler.
15104 +
15105 +; Copyright 2007 Atmel Corporation.
15106 +;
15107 +; This file is part of GCC.
15108 +;
15109 +; GCC is free software; you can redistribute it and/or modify it under
15110 +; the terms of the GNU General Public License as published by the Free
15111 +; Software Foundation; either version 2, or (at your option) any later
15112 +; version.
15113 +;
15114 +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15115 +; WARRANTY; without even the implied warranty of MERCHANTABILITY or
15116 +; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15117 +; for more details.
15118 +;
15119 +; You should have received a copy of the GNU General Public License
15120 +; along with GCC; see the file COPYING. If not, write to the Free
15121 +; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
15122 +; 02110-1301, USA.
15123 +
15124 +muse-rodata-section
15125 +Target Report Mask(USE_RODATA_SECTION)
15126 +Do not put readonly-data in .text section, but in .rodata.
15127 +
15128 +mhard-float
15129 +Target Report Undocumented Mask(HARD_FLOAT)
15130 +Use floating point coprocessor instructions.
15131 +
15132 +msoft-float
15133 +Target Report Undocumented InverseMask(HARD_FLOAT, SOFT_FLOAT)
15134 +Use software floating-point library for floating-point operations.
15135 +
15136 +force-double-align
15137 +Target Report RejectNegative Mask(FORCE_DOUBLE_ALIGN)
15138 +Force double-word alignment for double-word memory accesses.
15139 +
15140 +mno-init-got
15141 +Target Report RejectNegative Mask(NO_INIT_GOT)
15142 +Do not initialize GOT register before using it when compiling PIC code.
15143 +
15144 +mrelax
15145 +Target Report Mask(RELAX)
15146 +Let invoked assembler and linker do relaxing (Enabled by default when optimization level is >1).
15147 +
15148 +mmd-reorg-opt
15149 +Target Report Undocumented Mask(MD_REORG_OPTIMIZATION)
15150 +Perform machine dependent optimizations in reorg stage.
15151 +
15152 +masm-addr-pseudos
15153 +Target Report Mask(HAS_ASM_ADDR_PSEUDOS)
15154 +Use assembler pseudo-instructions lda.w and call for handling direct addresses. (Enabled by default)
15155 +
15156 +mpart=
15157 +Target Report RejectNegative Joined Var(avr32_part_name)
15158 +Specify the AVR32 part name
15159 +
15160 +mcpu=
15161 +Target Report RejectNegative Joined Undocumented Var(avr32_part_name)
15162 +Specify the AVR32 part name (deprecated)
15163 +
15164 +march=
15165 +Target Report RejectNegative Joined Var(avr32_arch_name)
15166 +Specify the AVR32 architecture name
15167 +
15168 +mfast-float
15169 +Target Report Mask(FAST_FLOAT)
15170 +Enable fast floating-point library. Enabled by default if the -funsafe-math-optimizations switch is specified.
15171 +
15172 +mimm-in-const-pool
15173 +Target Report Var(avr32_imm_in_const_pool) Init(-1)
15174 +Put large immediates in constant pool. This is enabled by default for archs with insn-cache.
15175 +
15176 Index: gcc-4.2.3/gcc/config/avr32/avr32-protos.h
15177 ===================================================================
15178 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
15179 +++ gcc-4.2.3/gcc/config/avr32/avr32-protos.h 2008-05-21 13:45:54.165287871 +0200
15180 @@ -0,0 +1,185 @@
15181 +/*
15182 + Prototypes for exported functions defined in avr32.c
15183 + Copyright 2003-2006 Atmel Corporation.
15184 +
15185 + Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
15186 + Initial porting by Anders �dland.
15187 +
15188 + This file is part of GCC.
15189 +
15190 + This program is free software; you can redistribute it and/or modify
15191 + it under the terms of the GNU General Public License as published by
15192 + the Free Software Foundation; either version 2 of the License, or
15193 + (at your option) any later version.
15194 +
15195 + This program is distributed in the hope that it will be useful,
15196 + but WITHOUT ANY WARRANTY; without even the implied warranty of
15197 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15198 + GNU General Public License for more details.
15199 +
15200 + You should have received a copy of the GNU General Public License
15201 + along with this program; if not, write to the Free Software
15202 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
15203 +
15204 +
15205 +#ifndef AVR32_PROTOS_H
15206 +#define AVR32_PROTOS_H
15207 +
15208 +extern const int swap_reg[];
15209 +
15210 +extern int avr32_valid_macmac_bypass (rtx, rtx);
15211 +extern int avr32_valid_mulmac_bypass (rtx, rtx);
15212 +
15213 +extern int avr32_decode_lcomm_symbol_offset (rtx, int *);
15214 +extern void avr32_encode_lcomm_symbol_offset (tree, char *, int);
15215 +
15216 +extern const char *avr32_strip_name_encoding (const char *);
15217 +
15218 +extern rtx avr32_get_note_reg_equiv (rtx insn);
15219 +
15220 +extern int avr32_use_return_insn (int iscond);
15221 +
15222 +extern void avr32_make_reglist16 (int reglist16_vect, char *reglist16_string);
15223 +
15224 +extern void avr32_make_reglist8 (int reglist8_vect, char *reglist8_string);
15225 +extern void avr32_make_fp_reglist_w (int reglist_mask, char *reglist_string);
15226 +extern void avr32_make_fp_reglist_d (int reglist_mask, char *reglist_string);
15227 +
15228 +extern void avr32_output_return_instruction (int single_ret_inst,
15229 + int iscond, rtx cond,
15230 + rtx r12_imm);
15231 +extern void avr32_expand_prologue (void);
15232 +extern void avr32_set_return_address (rtx source, rtx scratch);
15233 +
15234 +extern int avr32_hard_regno_mode_ok (int regno, enum machine_mode mode);
15235 +extern int avr32_extra_constraint_s (rtx value, const int strict);
15236 +extern int avr32_eh_return_data_regno (const int n);
15237 +extern int avr32_initial_elimination_offset (const int from, const int to);
15238 +extern rtx avr32_function_arg (CUMULATIVE_ARGS * cum, enum machine_mode mode,
15239 + tree type, int named);
15240 +extern void avr32_init_cumulative_args (CUMULATIVE_ARGS * cum, tree fntype,
15241 + rtx libname, tree fndecl);
15242 +extern void avr32_function_arg_advance (CUMULATIVE_ARGS * cum,
15243 + enum machine_mode mode,
15244 + tree type, int named);
15245 +#ifdef ARGS_SIZE_RTX
15246 +/* expr.h defines ARGS_SIZE_RTX and `enum direction'. */
15247 +extern enum direction avr32_function_arg_padding (enum machine_mode mode,
15248 + tree type);
15249 +#endif /* ARGS_SIZE_RTX */
15250 +extern rtx avr32_function_value (tree valtype, tree func, bool outgoing);
15251 +extern rtx avr32_libcall_value (enum machine_mode mode);
15252 +extern int avr32_sched_use_dfa_pipeline_interface (void);
15253 +extern bool avr32_return_in_memory (tree type, tree fntype);
15254 +extern void avr32_regs_to_save (char *operand);
15255 +extern void avr32_target_asm_function_prologue (FILE * file,
15256 + HOST_WIDE_INT size);
15257 +extern void avr32_target_asm_function_epilogue (FILE * file,
15258 + HOST_WIDE_INT size);
15259 +extern void avr32_trampoline_template (FILE * file);
15260 +extern void avr32_initialize_trampoline (rtx addr, rtx fnaddr,
15261 + rtx static_chain);
15262 +extern int avr32_legitimate_address (enum machine_mode mode, rtx x,
15263 + int strict);
15264 +extern int avr32_legitimate_constant_p (rtx x);
15265 +
15266 +extern int avr32_legitimate_pic_operand_p (rtx x);
15267 +
15268 +extern rtx avr32_find_symbol (rtx x);
15269 +extern void avr32_select_section (rtx exp, int reloc, int align);
15270 +extern void avr32_encode_section_info (tree decl, rtx rtl, int first);
15271 +extern void avr32_asm_file_end (FILE * stream);
15272 +extern void avr32_asm_output_ascii (FILE * stream, char *ptr, int len);
15273 +extern void avr32_asm_output_common (FILE * stream, const char *name,
15274 + int size, int rounded);
15275 +extern void avr32_asm_output_label (FILE * stream, const char *name);
15276 +extern void avr32_asm_declare_object_name (FILE * stream, char *name,
15277 + tree decl);
15278 +extern void avr32_asm_globalize_label (FILE * stream, const char *name);
15279 +extern void avr32_asm_weaken_label (FILE * stream, const char *name);
15280 +extern void avr32_asm_output_external (FILE * stream, tree decl,
15281 + const char *name);
15282 +extern void avr32_asm_output_external_libcall (FILE * stream, rtx symref);
15283 +extern void avr32_asm_output_labelref (FILE * stream, const char *name);
15284 +extern void avr32_notice_update_cc (rtx exp, rtx insn);
15285 +extern void avr32_print_operand (FILE * stream, rtx x, int code);
15286 +extern void avr32_print_operand_address (FILE * stream, rtx x);
15287 +
15288 +extern int avr32_symbol (rtx x);
15289 +
15290 +extern void avr32_select_rtx_section (enum machine_mode mode, rtx x,
15291 + unsigned HOST_WIDE_INT align);
15292 +
15293 +extern int avr32_load_multiple_operation (rtx op, enum machine_mode mode);
15294 +extern int avr32_store_multiple_operation (rtx op, enum machine_mode mode);
15295 +
15296 +extern int avr32_const_ok_for_constraint_p (HOST_WIDE_INT value, char c,
15297 + const char *str);
15298 +
15299 +extern bool avr32_cannot_force_const_mem (rtx x);
15300 +
15301 +extern void avr32_init_builtins (void);
15302 +
15303 +extern rtx avr32_expand_builtin (tree exp, rtx target, rtx subtarget,
15304 + enum machine_mode mode, int ignore);
15305 +
15306 +extern bool avr32_must_pass_in_stack (enum machine_mode mode, tree type);
15307 +
15308 +extern bool avr32_strict_argument_naming (CUMULATIVE_ARGS * ca);
15309 +
15310 +extern bool avr32_pass_by_reference (CUMULATIVE_ARGS * cum,
15311 + enum machine_mode mode,
15312 + tree type, bool named);
15313 +
15314 +extern rtx avr32_gen_load_multiple (rtx * regs, int count, rtx from,
15315 + int write_back, int in_struct_p,
15316 + int scalar_p);
15317 +extern rtx avr32_gen_store_multiple (rtx * regs, int count, rtx to,
15318 + int in_struct_p, int scalar_p);
15319 +extern int avr32_gen_movmemsi (rtx * operands);
15320 +
15321 +extern int avr32_rnd_operands (rtx add, rtx shift);
15322 +extern int avr32_adjust_insn_length (rtx insn, int length);
15323 +
15324 +extern int symbol_mentioned_p (rtx x);
15325 +extern int label_mentioned_p (rtx x);
15326 +extern rtx legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg);
15327 +extern int avr32_address_register_rtx_p (rtx x, int strict_p);
15328 +extern int avr32_legitimate_index_p (enum machine_mode mode, rtx index,
15329 + int strict_p);
15330 +
15331 +extern int avr32_const_double_immediate (rtx value);
15332 +extern void avr32_init_expanders (void);
15333 +extern rtx avr32_return_addr (int count, rtx frame);
15334 +extern bool avr32_got_mentioned_p (rtx addr);
15335 +
15336 +extern void avr32_final_prescan_insn (rtx insn, rtx * opvec, int noperands);
15337 +
15338 +extern int avr32_expand_movcc (enum machine_mode mode, rtx operands[]);
15339 +extern int avr32_expand_addcc (enum machine_mode mode, rtx operands[]);
15340 +#ifdef RTX_CODE
15341 +extern int avr32_expand_scc (RTX_CODE cond, rtx * operands);
15342 +#endif
15343 +
15344 +extern int avr32_store_bypass (rtx insn_out, rtx insn_in);
15345 +extern int avr32_mul_waw_bypass (rtx insn_out, rtx insn_in);
15346 +extern int avr32_valid_load_double_bypass (rtx insn_out, rtx insn_in);
15347 +extern int avr32_valid_load_quad_bypass (rtx insn_out, rtx insn_in);
15348 +extern rtx avr32_output_cmp (rtx cond, enum machine_mode mode,
15349 + rtx op0, rtx op1);
15350 +
15351 +rtx get_next_insn_cond (rtx cur_insn);
15352 +int set_next_insn_cond (rtx cur_insn, rtx cond);
15353 +void avr32_override_options (void);
15354 +void avr32_load_pic_register (void);
15355 +void avr32_optimization_options (int level, int size);
15356 +void avr32_split_const_expr (enum machine_mode mode,
15357 + enum machine_mode new_mode,
15358 + rtx expr,
15359 + rtx *split_expr);
15360 +void avr32_get_intval (enum machine_mode mode,
15361 + rtx const_expr,
15362 + HOST_WIDE_INT *val);
15363 +
15364 +
15365 +#endif /* AVR32_PROTOS_H */
15366 Index: gcc-4.2.3/gcc/config/avr32/crti.asm
15367 ===================================================================
15368 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
15369 +++ gcc-4.2.3/gcc/config/avr32/crti.asm 2008-05-21 13:45:54.165287871 +0200
15370 @@ -0,0 +1,64 @@
15371 +/*
15372 + Init/fini stuff for AVR32.
15373 + Copyright 2003-2006 Atmel Corporation.
15374 +
15375 + Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
15376 +
15377 + This file is part of GCC.
15378 +
15379 + This program is free software; you can redistribute it and/or modify
15380 + it under the terms of the GNU General Public License as published by
15381 + the Free Software Foundation; either version 2 of the License, or
15382 + (at your option) any later version.
15383 +
15384 + This program is distributed in the hope that it will be useful,
15385 + but WITHOUT ANY WARRANTY; without even the implied warranty of
15386 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15387 + GNU General Public License for more details.
15388 +
15389 + You should have received a copy of the GNU General Public License
15390 + along with this program; if not, write to the Free Software
15391 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
15392 +
15393 +
15394 +/* The code in sections .init and .fini is supposed to be a single
15395 + regular function. The function in .init is called directly from
15396 + start in crt1.asm. The function in .fini is atexit()ed in crt1.asm
15397 + too.
15398 +
15399 + crti.asm contributes the prologue of a function to these sections,
15400 + and crtn.asm comes up the epilogue. STARTFILE_SPEC should list
15401 + crti.o before any other object files that might add code to .init
15402 + or .fini sections, and ENDFILE_SPEC should list crtn.o after any
15403 + such object files. */
15404 +
15405 + .file "crti.asm"
15406 +
15407 + .section ".init"
15408 +/* Just load the GOT */
15409 + .align 2
15410 + .global _init
15411 +_init:
15412 + stm --sp, r6, lr
15413 + lddpc r6, 1f
15414 +0:
15415 + rsub r6, pc
15416 + rjmp 2f
15417 + .align 2
15418 +1: .long 0b - _GLOBAL_OFFSET_TABLE_
15419 +2:
15420 +
15421 + .section ".fini"
15422 +/* Just load the GOT */
15423 + .align 2
15424 + .global _fini
15425 +_fini:
15426 + stm --sp, r6, lr
15427 + lddpc r6, 1f
15428 +0:
15429 + rsub r6, pc
15430 + rjmp 2f
15431 + .align 2
15432 +1: .long 0b - _GLOBAL_OFFSET_TABLE_
15433 +2:
15434 +
15435 Index: gcc-4.2.3/gcc/config/avr32/crtn.asm
15436 ===================================================================
15437 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
15438 +++ gcc-4.2.3/gcc/config/avr32/crtn.asm 2008-05-21 13:45:54.165287871 +0200
15439 @@ -0,0 +1,44 @@
15440 +/* Copyright (C) 2001 Free Software Foundation, Inc.
15441 + Written By Nick Clifton
15442 +
15443 + This file is free software; you can redistribute it and/or modify it
15444 + under the terms of the GNU General Public License as published by the
15445 + Free Software Foundation; either version 2, or (at your option) any
15446 + later version.
15447 +
15448 + In addition to the permissions in the GNU General Public License, the
15449 + Free Software Foundation gives you unlimited permission to link the
15450 + compiled version of this file with other programs, and to distribute
15451 + those programs without any restriction coming from the use of this
15452 + file. (The General Public License restrictions do apply in other
15453 + respects; for example, they cover modification of the file, and
15454 + distribution when not linked into another program.)
15455 +
15456 + This file is distributed in the hope that it will be useful, but
15457 + WITHOUT ANY WARRANTY; without even the implied warranty of
15458 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15459 + General Public License for more details.
15460 +
15461 + You should have received a copy of the GNU General Public License
15462 + along with this program; see the file COPYING. If not, write to
15463 + the Free Software Foundation, 59 Temple Place - Suite 330,
15464 + Boston, MA 02111-1307, USA.
15465 +
15466 + As a special exception, if you link this library with files
15467 + compiled with GCC to produce an executable, this does not cause
15468 + the resulting executable to be covered by the GNU General Public License.
15469 + This exception does not however invalidate any other reasons why
15470 + the executable file might be covered by the GNU General Public License.
15471 +*/
15472 +
15473 +
15474 +
15475 +
15476 + .file "crtn.asm"
15477 +
15478 + .section ".init"
15479 + ldm sp++, r6, pc
15480 +
15481 + .section ".fini"
15482 + ldm sp++, r6, pc
15483 +
15484 Index: gcc-4.2.3/gcc/config/avr32/fpcp.md
15485 ===================================================================
15486 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
15487 +++ gcc-4.2.3/gcc/config/avr32/fpcp.md 2008-05-21 13:45:54.169287542 +0200
15488 @@ -0,0 +1,551 @@
15489 +;; AVR32 machine description file for Floating-Point instructions.
15490 +;; Copyright 2003-2006 Atmel Corporation.
15491 +;;
15492 +;; Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
15493 +;;
15494 +;; This file is part of GCC.
15495 +;;
15496 +;; This program is free software; you can redistribute it and/or modify
15497 +;; it under the terms of the GNU General Public License as published by
15498 +;; the Free Software Foundation; either version 2 of the License, or
15499 +;; (at your option) any later version.
15500 +;;
15501 +;; This program is distributed in the hope that it will be useful,
15502 +;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15503 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15504 +;; GNU General Public License for more details.
15505 +;;
15506 +;; You should have received a copy of the GNU General Public License
15507 +;; along with this program; if not, write to the Free Software
15508 +;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15509 +
15510 +;; -*- Mode: Scheme -*-
15511 +
15512 +;;******************************************************************************
15513 +;; Automaton pipeline description for floating-point coprocessor insns
15514 +;;******************************************************************************
15515 +(define_cpu_unit "fid,fm1,fm2,fm3,fm4,fwb,fcmp,fcast" "avr32_ap")
15516 +
15517 +(define_insn_reservation "fmv_op" 1
15518 + (and (eq_attr "pipeline" "ap")
15519 + (eq_attr "type" "fmv"))
15520 + "is,da,d,fid,fwb")
15521 +
15522 +(define_insn_reservation "fmul_op" 5
15523 + (and (eq_attr "pipeline" "ap")
15524 + (eq_attr "type" "fmul"))
15525 + "is,da,d,fid,fm1,fm2,fm3,fm4,fwb")
15526 +
15527 +(define_insn_reservation "fcmps_op" 1
15528 + (and (eq_attr "pipeline" "ap")
15529 + (eq_attr "type" "fcmps"))
15530 + "is,da,d,fid,fcmp")
15531 +
15532 +(define_insn_reservation "fcmpd_op" 2
15533 + (and (eq_attr "pipeline" "ap")
15534 + (eq_attr "type" "fcmpd"))
15535 + "is,da,d,fid*2,fcmp")
15536 +
15537 +(define_insn_reservation "fcast_op" 3
15538 + (and (eq_attr "pipeline" "ap")
15539 + (eq_attr "type" "fcast"))
15540 + "is,da,d,fid,fcmp,fcast,fwb")
15541 +
15542 +(define_insn_reservation "fmvcpu_op" 2
15543 + (and (eq_attr "pipeline" "ap")
15544 + (eq_attr "type" "fmvcpu"))
15545 + "is,da,d")
15546 +
15547 +(define_insn_reservation "fldd_op" 1
15548 + (and (eq_attr "pipeline" "ap")
15549 + (eq_attr "type" "fldd"))
15550 + "is,da,d,fwb")
15551 +
15552 +(define_insn_reservation "flds_op" 1
15553 + (and (eq_attr "pipeline" "ap")
15554 + (eq_attr "type" "flds"))
15555 + "is,da,d,fwb")
15556 +
15557 +(define_insn_reservation "fsts_op" 0
15558 + (and (eq_attr "pipeline" "ap")
15559 + (eq_attr "type" "fsts"))
15560 + "is,da*2,d")
15561 +
15562 +(define_insn_reservation "fstd_op" 0
15563 + (and (eq_attr "pipeline" "ap")
15564 + (eq_attr "type" "fstd"))
15565 + "is,da*2,d")
15566 +
15567 +
15568 +(define_insn "*movsf_fpcp"
15569 + [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,r,f,m,r,r,r,m")
15570 + (match_operand:SF 1 "general_operand" " f,r,f,m,f,r,G,m,r"))]
15571 + "TARGET_HARD_FLOAT"
15572 + "@
15573 + fmov.s\t%0, %1
15574 + fmov.s\t%0, %1
15575 + fmov.s\t%0, %1
15576 + fld.s\t%0, %1
15577 + fst.s\t%0, %1
15578 + mov\t%0, %1
15579 + mov\t%0, %1
15580 + ld.w\t%0, %1
15581 + st.w\t%0, %1"
15582 + [(set_attr "length" "4,4,4,4,4,2,4,4,4")
15583 + (set_attr "type" "fmv,flds,fmvcpu,flds,fsts,alu,alu,load,store")])
15584 +
15585 +(define_insn_and_split "*movdf_fpcp"
15586 + [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,r,f,m,r,r,m")
15587 + (match_operand:DF 1 "general_operand" " f,r,f,m,f,r,m,r"))]
15588 + "TARGET_HARD_FLOAT"
15589 + "@
15590 + fmov.d\t%0, %1
15591 + fmov.d\t%0, %1
15592 + fmov.d\t%0, %1
15593 + fld.d\t%0, %1
15594 + fst.d\t%0, %1
15595 + mov\t%0, %1\;mov\t%m0, %m1
15596 + ld.d\t%0, %1
15597 + st.d\t%0, %1"
15598 +
15599 + "TARGET_HARD_FLOAT
15600 + && reload_completed
15601 + && (REG_P(operands[0]) && (REGNO_REG_CLASS(REGNO(operands[0])) == GENERAL_REGS))
15602 + && (REG_P(operands[1]) && (REGNO_REG_CLASS(REGNO(operands[1])) == GENERAL_REGS))"
15603 + [(set (match_dup 0) (match_dup 1))
15604 + (set (match_dup 2) (match_dup 3))]
15605 + "
15606 + {
15607 + operands[2] = gen_highpart (SImode, operands[0]);
15608 + operands[0] = gen_lowpart (SImode, operands[0]);
15609 + operands[3] = gen_highpart(SImode, operands[1]);
15610 + operands[1] = gen_lowpart(SImode, operands[1]);
15611 + }
15612 + "
15613 +
15614 + [(set_attr "length" "4,4,4,4,4,4,4,4")
15615 + (set_attr "type" "fmv,fldd,fmvcpu,fldd,fstd,alu2,load2,store2")])
15616 +
15617 +
15618 +(define_insn "mulsf3"
15619 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "=f")
15620 + (mult:SF (match_operand:SF 1 "avr32_fp_register_operand" "f")
15621 + (match_operand:SF 2 "avr32_fp_register_operand" "f")))]
15622 + "TARGET_HARD_FLOAT"
15623 + "fmul.s\t%0, %1, %2"
15624 + [(set_attr "length" "4")
15625 + (set_attr "type" "fmul")])
15626 +
15627 +(define_insn "nmulsf3"
15628 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "=f")
15629 + (neg:SF (mult:SF (match_operand:SF 1 "avr32_fp_register_operand" "f")
15630 + (match_operand:SF 2 "avr32_fp_register_operand" "f"))))]
15631 + "TARGET_HARD_FLOAT"
15632 + "fnmul.s\t%0, %1, %2"
15633 + [(set_attr "length" "4")
15634 + (set_attr "type" "fmul")])
15635 +
15636 +(define_peephole2
15637 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "")
15638 + (mult:SF (match_operand:SF 1 "avr32_fp_register_operand" "")
15639 + (match_operand:SF 2 "avr32_fp_register_operand" "")))
15640 + (set (match_operand:SF 3 "avr32_fp_register_operand" "")
15641 + (neg:SF (match_dup 0)))]
15642 + "TARGET_HARD_FLOAT &&
15643 + (peep2_reg_dead_p(2, operands[0]) || (REGNO(operands[3]) == REGNO(operands[0])))"
15644 + [(set (match_dup 3)
15645 + (neg:SF (mult:SF (match_dup 1)
15646 + (match_dup 2))))]
15647 +)
15648 +
15649 +
15650 +(define_insn "macsf3"
15651 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "=f")
15652 + (plus:SF (mult:SF (match_operand:SF 1 "avr32_fp_register_operand" "f")
15653 + (match_operand:SF 2 "avr32_fp_register_operand" "f"))
15654 + (match_operand:SF 3 "avr32_fp_register_operand" "0")))]
15655 + "TARGET_HARD_FLOAT"
15656 + "fmac.s\t%0, %1, %2"
15657 + [(set_attr "length" "4")
15658 + (set_attr "type" "fmul")])
15659 +
15660 +(define_insn "nmacsf3"
15661 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "=f")
15662 + (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "avr32_fp_register_operand" "f")
15663 + (match_operand:SF 2 "avr32_fp_register_operand" "f")))
15664 + (match_operand:SF 3 "avr32_fp_register_operand" "0")))]
15665 + "TARGET_HARD_FLOAT"
15666 + "fnmac.s\t%0, %1, %2"
15667 + [(set_attr "length" "4")
15668 + (set_attr "type" "fmul")])
15669 +
15670 +(define_peephole2
15671 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "")
15672 + (mult:SF (match_operand:SF 1 "avr32_fp_register_operand" "")
15673 + (match_operand:SF 2 "avr32_fp_register_operand" "")))
15674 + (set (match_operand:SF 3 "avr32_fp_register_operand" "")
15675 + (minus:SF
15676 + (match_dup 3)
15677 + (match_dup 0)))]
15678 + "TARGET_HARD_FLOAT && peep2_reg_dead_p(2, operands[0])"
15679 + [(set (match_dup 3)
15680 + (plus:SF (neg:SF (mult:SF (match_dup 1)
15681 + (match_dup 2)))
15682 + (match_dup 3)))]
15683 +)
15684 +
15685 +
15686 +(define_insn "msubacsf3"
15687 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "=f")
15688 + (minus:SF (mult:SF (match_operand:SF 1 "avr32_fp_register_operand" "f")
15689 + (match_operand:SF 2 "avr32_fp_register_operand" "f"))
15690 + (match_operand:SF 3 "avr32_fp_register_operand" "0")))]
15691 + "TARGET_HARD_FLOAT"
15692 + "fmsc.s\t%0, %1, %2"
15693 + [(set_attr "length" "4")
15694 + (set_attr "type" "fmul")])
15695 +
15696 +(define_peephole2
15697 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "")
15698 + (mult:SF (match_operand:SF 1 "avr32_fp_register_operand" "")
15699 + (match_operand:SF 2 "avr32_fp_register_operand" "")))
15700 + (set (match_operand:SF 3 "avr32_fp_register_operand" "")
15701 + (minus:SF
15702 + (match_dup 0)
15703 + (match_dup 3)))]
15704 + "TARGET_HARD_FLOAT && peep2_reg_dead_p(2, operands[0])"
15705 + [(set (match_dup 3)
15706 + (minus:SF (mult:SF (match_dup 1)
15707 + (match_dup 2))
15708 + (match_dup 3)))]
15709 +)
15710 +
15711 +(define_insn "nmsubacsf3"
15712 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "=f")
15713 + (minus:SF (neg:SF (mult:SF (match_operand:SF 1 "avr32_fp_register_operand" "f")
15714 + (match_operand:SF 2 "avr32_fp_register_operand" "f")))
15715 + (match_operand:SF 3 "avr32_fp_register_operand" "0")))]
15716 + "TARGET_HARD_FLOAT"
15717 + "fnmsc.s\t%0, %1, %2"
15718 + [(set_attr "length" "4")
15719 + (set_attr "type" "fmul")])
15720 +
15721 +
15722 +
15723 +(define_insn "addsf3"
15724 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "=f")
15725 + (plus:SF (match_operand:SF 1 "avr32_fp_register_operand" "f")
15726 + (match_operand:SF 2 "avr32_fp_register_operand" "f")))]
15727 + "TARGET_HARD_FLOAT"
15728 + "fadd.s\t%0, %1, %2"
15729 + [(set_attr "length" "4")
15730 + (set_attr "type" "fmul")])
15731 +
15732 +(define_insn "subsf3"
15733 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "=f")
15734 + (minus:SF (match_operand:SF 1 "avr32_fp_register_operand" "f")
15735 + (match_operand:SF 2 "avr32_fp_register_operand" "f")))]
15736 + "TARGET_HARD_FLOAT"
15737 + "fsub.s\t%0, %1, %2"
15738 + [(set_attr "length" "4")
15739 + (set_attr "type" "fmul")])
15740 +
15741 +
15742 +(define_insn "negsf2"
15743 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "=f")
15744 + (neg:SF (match_operand:SF 1 "avr32_fp_register_operand" "f")))]
15745 + "TARGET_HARD_FLOAT"
15746 + "fneg.s\t%0, %1"
15747 + [(set_attr "length" "4")
15748 + (set_attr "type" "fmv")])
15749 +
15750 +(define_insn "abssf2"
15751 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "=f")
15752 + (abs:SF (match_operand:SF 1 "avr32_fp_register_operand" "f")))]
15753 + "TARGET_HARD_FLOAT"
15754 + "fabs.s\t%0, %1"
15755 + [(set_attr "length" "4")
15756 + (set_attr "type" "fmv")])
15757 +
15758 +(define_insn "truncdfsf2"
15759 + [(set (match_operand:SF 0 "avr32_fp_register_operand" "=f")
15760 + (float_truncate:SF
15761 + (match_operand:DF 1 "avr32_fp_register_operand" "f")))]
15762 + "TARGET_HARD_FLOAT"
15763 + "fcastd.s\t%0, %1"
15764 + [(set_attr "length" "4")
15765 + (set_attr "type" "fcast")])
15766 +
15767 +(define_insn "extendsfdf2"
15768 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "=f")
15769 + (float_extend:DF
15770 + (match_operand:SF 1 "avr32_fp_register_operand" "f")))]
15771 + "TARGET_HARD_FLOAT"
15772 + "fcasts.d\t%0, %1"
15773 + [(set_attr "length" "4")
15774 + (set_attr "type" "fcast")])
15775 +
15776 +(define_insn "muldf3"
15777 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "=f")
15778 + (mult:DF (match_operand:DF 1 "avr32_fp_register_operand" "f")
15779 + (match_operand:DF 2 "avr32_fp_register_operand" "f")))]
15780 + "TARGET_HARD_FLOAT"
15781 + "fmul.d\t%0, %1, %2"
15782 + [(set_attr "length" "4")
15783 + (set_attr "type" "fmul")])
15784 +
15785 +(define_insn "nmuldf3"
15786 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "=f")
15787 + (neg:DF (mult:DF (match_operand:DF 1 "avr32_fp_register_operand" "f")
15788 + (match_operand:DF 2 "avr32_fp_register_operand" "f"))))]
15789 + "TARGET_HARD_FLOAT"
15790 + "fnmul.d\t%0, %1, %2"
15791 + [(set_attr "length" "4")
15792 + (set_attr "type" "fmul")])
15793 +
15794 +(define_peephole2
15795 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "")
15796 + (mult:DF (match_operand:DF 1 "avr32_fp_register_operand" "")
15797 + (match_operand:DF 2 "avr32_fp_register_operand" "")))
15798 + (set (match_operand:DF 3 "avr32_fp_register_operand" "")
15799 + (neg:DF (match_dup 0)))]
15800 + "TARGET_HARD_FLOAT &&
15801 + (peep2_reg_dead_p(2, operands[0]) || (REGNO(operands[3]) == REGNO(operands[0])))"
15802 + [(set (match_dup 3)
15803 + (neg:DF (mult:DF (match_dup 1)
15804 + (match_dup 2))))]
15805 +)
15806 +
15807 +(define_insn "macdf3"
15808 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "=f")
15809 + (plus:DF (mult:DF (match_operand:DF 1 "avr32_fp_register_operand" "f")
15810 + (match_operand:DF 2 "avr32_fp_register_operand" "f"))
15811 + (match_operand:DF 3 "avr32_fp_register_operand" "0")))]
15812 + "TARGET_HARD_FLOAT"
15813 + "fmac.d\t%0, %1, %2"
15814 + [(set_attr "length" "4")
15815 + (set_attr "type" "fmul")])
15816 +
15817 +(define_insn "msubacdf3"
15818 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "=f")
15819 + (minus:DF (mult:DF (match_operand:DF 1 "avr32_fp_register_operand" "f")
15820 + (match_operand:DF 2 "avr32_fp_register_operand" "f"))
15821 + (match_operand:DF 3 "avr32_fp_register_operand" "0")))]
15822 + "TARGET_HARD_FLOAT"
15823 + "fmsc.d\t%0, %1, %2"
15824 + [(set_attr "length" "4")
15825 + (set_attr "type" "fmul")])
15826 +
15827 +(define_peephole2
15828 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "")
15829 + (mult:DF (match_operand:DF 1 "avr32_fp_register_operand" "")
15830 + (match_operand:DF 2 "avr32_fp_register_operand" "")))
15831 + (set (match_operand:DF 3 "avr32_fp_register_operand" "")
15832 + (minus:DF
15833 + (match_dup 0)
15834 + (match_dup 3)))]
15835 + "TARGET_HARD_FLOAT && peep2_reg_dead_p(2, operands[0])"
15836 + [(set (match_dup 3)
15837 + (minus:DF (mult:DF (match_dup 1)
15838 + (match_dup 2))
15839 + (match_dup 3)))]
15840 + )
15841 +
15842 +(define_insn "nmsubacdf3"
15843 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "=f")
15844 + (minus:DF (neg:DF (mult:DF (match_operand:DF 1 "avr32_fp_register_operand" "f")
15845 + (match_operand:DF 2 "avr32_fp_register_operand" "f")))
15846 + (match_operand:DF 3 "avr32_fp_register_operand" "0")))]
15847 + "TARGET_HARD_FLOAT"
15848 + "fnmsc.d\t%0, %1, %2"
15849 + [(set_attr "length" "4")
15850 + (set_attr "type" "fmul")])
15851 +
15852 +(define_insn "nmacdf3"
15853 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "=f")
15854 + (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "avr32_fp_register_operand" "f")
15855 + (match_operand:DF 2 "avr32_fp_register_operand" "f")))
15856 + (match_operand:DF 3 "avr32_fp_register_operand" "0")))]
15857 + "TARGET_HARD_FLOAT"
15858 + "fnmac.d\t%0, %1, %2"
15859 + [(set_attr "length" "4")
15860 + (set_attr "type" "fmul")])
15861 +
15862 +(define_peephole2
15863 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "")
15864 + (mult:DF (match_operand:DF 1 "avr32_fp_register_operand" "")
15865 + (match_operand:DF 2 "avr32_fp_register_operand" "")))
15866 + (set (match_operand:DF 3 "avr32_fp_register_operand" "")
15867 + (minus:DF
15868 + (match_dup 3)
15869 + (match_dup 0)))]
15870 + "TARGET_HARD_FLOAT && peep2_reg_dead_p(2, operands[0])"
15871 + [(set (match_dup 3)
15872 + (plus:DF (neg:DF (mult:DF (match_dup 1)
15873 + (match_dup 2)))
15874 + (match_dup 3)))]
15875 +)
15876 +
15877 +(define_insn "adddf3"
15878 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "=f")
15879 + (plus:DF (match_operand:DF 1 "avr32_fp_register_operand" "f")
15880 + (match_operand:DF 2 "avr32_fp_register_operand" "f")))]
15881 + "TARGET_HARD_FLOAT"
15882 + "fadd.d\t%0, %1, %2"
15883 + [(set_attr "length" "4")
15884 + (set_attr "type" "fmul")])
15885 +
15886 +(define_insn "subdf3"
15887 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "=f")
15888 + (minus:DF (match_operand:DF 1 "avr32_fp_register_operand" "f")
15889 + (match_operand:DF 2 "avr32_fp_register_operand" "f")))]
15890 + "TARGET_HARD_FLOAT"
15891 + "fsub.d\t%0, %1, %2"
15892 + [(set_attr "length" "4")
15893 + (set_attr "type" "fmul")])
15894 +
15895 +(define_insn "negdf2"
15896 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "=f")
15897 + (neg:DF (match_operand:DF 1 "avr32_fp_register_operand" "f")))]
15898 + "TARGET_HARD_FLOAT"
15899 + "fneg.d\t%0, %1"
15900 + [(set_attr "length" "4")
15901 + (set_attr "type" "fmv")])
15902 +
15903 +(define_insn "absdf2"
15904 + [(set (match_operand:DF 0 "avr32_fp_register_operand" "=f")
15905 + (abs:DF (match_operand:DF 1 "avr32_fp_register_operand" "f")))]
15906 + "TARGET_HARD_FLOAT"
15907 + "fabs.d\t%0, %1"
15908 + [(set_attr "length" "4")
15909 + (set_attr "type" "fmv")])
15910 +
15911 +
15912 +(define_expand "cmpdf"
15913 + [(set (cc0)
15914 + (compare:DF
15915 + (match_operand:DF 0 "general_operand" "")
15916 + (match_operand:DF 1 "general_operand" "")))]
15917 + "TARGET_HARD_FLOAT"
15918 + "{
15919 + rtx tmpreg;
15920 + if ( !REG_P(operands[0]) )
15921 + operands[0] = force_reg(DFmode, operands[0]);
15922 +
15923 + if ( !REG_P(operands[1]) )
15924 + operands[1] = force_reg(DFmode, operands[1]);
15925 +
15926 + avr32_compare_op0 = operands[0];
15927 + avr32_compare_op1 = operands[1];
15928 +
15929 + emit_insn(gen_cmpdf_internal(operands[0], operands[1]));
15930 +
15931 + tmpreg = gen_reg_rtx(SImode);
15932 + emit_insn(gen_fpcc_to_reg(tmpreg));
15933 + emit_insn(gen_reg_to_cc(tmpreg));
15934 +
15935 + DONE;
15936 + }"
15937 +)
15938 +
15939 +(define_insn "cmpdf_internal"
15940 + [(set (reg:CC FPCC_REGNUM)
15941 + (compare:CC
15942 + (match_operand:DF 0 "avr32_fp_register_operand" "f")
15943 + (match_operand:DF 1 "avr32_fp_register_operand" "f")))]
15944 + "TARGET_HARD_FLOAT"
15945 + {
15946 + if (!rtx_equal_p(cc_prev_status.mdep.fpvalue, SET_SRC(PATTERN (insn))) )
15947 + return "fcmp.d\t%0, %1";
15948 + return "";
15949 + }
15950 + [(set_attr "length" "4")
15951 + (set_attr "type" "fcmpd")
15952 + (set_attr "cc" "fpcompare")])
15953 +
15954 +(define_expand "cmpsf"
15955 + [(set (cc0)
15956 + (compare:SF
15957 + (match_operand:SF 0 "general_operand" "")
15958 + (match_operand:SF 1 "general_operand" "")))]
15959 + "TARGET_HARD_FLOAT"
15960 + "{
15961 + rtx tmpreg;
15962 + if ( !REG_P(operands[0]) )
15963 + operands[0] = force_reg(SFmode, operands[0]);
15964 +
15965 + if ( !REG_P(operands[1]) )
15966 + operands[1] = force_reg(SFmode, operands[1]);
15967 +
15968 + avr32_compare_op0 = operands[0];
15969 + avr32_compare_op1 = operands[1];
15970 +
15971 + emit_insn(gen_cmpsf_internal(operands[0], operands[1]));
15972 +
15973 + tmpreg = gen_reg_rtx(SImode);
15974 + emit_insn(gen_fpcc_to_reg(tmpreg));
15975 + emit_insn(gen_reg_to_cc(tmpreg));
15976 +
15977 + DONE;
15978 + }"
15979 +)
15980 +
15981 +(define_insn "cmpsf_internal"
15982 + [(set (reg:CC FPCC_REGNUM)
15983 + (compare:CC
15984 + (match_operand:SF 0 "avr32_fp_register_operand" "f")
15985 + (match_operand:SF 1 "avr32_fp_register_operand" "f")))]
15986 + "TARGET_HARD_FLOAT"
15987 + {
15988 + if (!rtx_equal_p(cc_prev_status.mdep.fpvalue, SET_SRC(PATTERN (insn))) )
15989 + return "fcmp.s\t%0, %1";
15990 + return "";
15991 + }
15992 + [(set_attr "length" "4")
15993 + (set_attr "type" "fcmps")
15994 + (set_attr "cc" "fpcompare")])
15995 +
15996 +(define_insn "fpcc_to_reg"
15997 + [(set (match_operand:SI 0 "register_operand" "=r")
15998 + (unspec:SI [(reg:CC FPCC_REGNUM)]
15999 + UNSPEC_FPCC_TO_REG))]
16000 + "TARGET_HARD_FLOAT"
16001 + "fmov.s\t%0, fsr"
16002 + [(set_attr "length" "4")
16003 + (set_attr "type" "fmvcpu")])
16004 +
16005 +(define_insn "reg_to_cc"
16006 + [(set (cc0)
16007 + (unspec:SI [(match_operand:SI 0 "register_operand" "r")]
16008 + UNSPEC_REG_TO_CC))]
16009 + "TARGET_HARD_FLOAT"
16010 + "musfr\t%0"
16011 + [(set_attr "length" "2")
16012 + (set_attr "type" "alu")
16013 + (set_attr "cc" "from_fpcc")])
16014 +
16015 +(define_insn "stm_fp"
16016 + [(unspec [(match_operand 0 "register_operand" "r")
16017 + (match_operand 1 "const_int_operand" "")
16018 + (match_operand 2 "const_int_operand" "")]
16019 + UNSPEC_STMFP)]
16020 + "TARGET_HARD_FLOAT"
16021 + {
16022 + int cop_reglist = INTVAL(operands[1]);
16023 +
16024 + if (INTVAL(operands[2]) != 0)
16025 + return "stcm.w\tcp0, --%0, %C1";
16026 + else
16027 + return "stcm.w\tcp0, %0, %C1";
16028 +
16029 + if ( cop_reglist & ~0xff ){
16030 + operands[1] = GEN_INT(cop_reglist & ~0xff);
16031 + if (INTVAL(operands[2]) != 0)
16032 + return "stcm.d\tcp0, --%0, %D1";
16033 + else
16034 + return "stcm.d\tcp0, %0, %D1";
16035 + }
16036 + }
16037 + [(set_attr "type" "fstm")
16038 + (set_attr "length" "4")
16039 + (set_attr "cc" "none")])
16040 Index: gcc-4.2.3/gcc/config/avr32/lib1funcs.S
16041 ===================================================================
16042 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
16043 +++ gcc-4.2.3/gcc/config/avr32/lib1funcs.S 2008-05-21 13:45:54.173288052 +0200
16044 @@ -0,0 +1,2589 @@
16045 +
16046 +/* Adjust the unpacked double number if it is a subnormal number.
16047 + The exponent and mantissa pair are stored
16048 + in [mant_hi,mant_lo] and [exp]. A register with the correct sign bit in
16049 + the MSB is passed in [sign]. Needs two scratch
16050 + registers [scratch1] and [scratch2]. An adjusted and packed double float
16051 + is present in [mant_hi,mant_lo] after macro has executed */
16052 +.macro adjust_subnormal_df exp, mant_lo, mant_hi, sign, scratch1, scratch2
16053 + /* We have an exponent which is <=0 indicating a subnormal number
16054 + As it should be stored as if the exponent was 1 (although the
16055 + exponent field is all zeros to indicate a subnormal number)
16056 + we have to shift down the mantissa to its correct position. */
16057 + neg \exp
16058 + sub \exp,-1 /* amount to shift down */
16059 + cp.w \exp,54
16060 + brlo 50f /* if more than 53 shift steps, the
16061 + entire mantissa will disappear
16062 + without any rounding to occur */
16063 + mov \mant_hi, 0
16064 + mov \mant_lo, 0
16065 + rjmp 52f
16066 +50:
16067 + sub \exp,-10 /* do the shift to position the
16068 + mantissa at the same time
16069 + note! this does not include the
16070 + final 1 step shift to add the sign */
16071 +
16072 + /* when shifting, save all shifted out bits in [scratch2]. we may need to
16073 + look at them to make correct rounding. */
16074 +
16075 + rsub \scratch1,\exp,32 /* get inverted shift count */
16076 + cp.w \exp,32 /* handle shifts >= 32 separately */
16077 + brhs 51f
16078 +
16079 + /* small (<32) shift amount, both words are part of the shift */
16080 + lsl \scratch2,\mant_lo,\scratch1 /* save bits to shift out from lsw*/
16081 + lsl \scratch1,\mant_hi,\scratch1 /* get bits from msw destined for lsw*/
16082 + lsr \mant_lo,\mant_lo,\exp /* shift down lsw */
16083 + lsr \mant_hi,\mant_hi,\exp /* shift down msw */
16084 + or \mant_hi,\scratch1 /* add bits from msw with prepared lsw */
16085 + rjmp 50f
16086 +
16087 + /* large (>=32) shift amount, only lsw will have bits left after shift.
16088 + note that shift operations will use ((shift count) mod 32) so
16089 + we do not need to subtract 32 from shift count. */
16090 +51:
16091 + lsl \scratch2,\mant_hi,\scratch1 /* save bits to shift out from msw */
16092 + or \scratch2,\mant_lo /* also save all bits from lsw */
16093 + mov \mant_lo,\mant_hi /* msw -> lsw (i.e. "shift 32 first") */
16094 + mov \mant_hi,0 /* clear msw */
16095 + lsr \mant_lo,\mant_lo,\exp /* make rest of shift inside lsw */
16096 +
16097 +50:
16098 + /* result is almost ready to return, except that least significant bit
16099 + and the part we already shifted out may cause the result to be
16100 + rounded */
16101 + bld \mant_lo,0 /* get bit to be shifted out */
16102 + brcc 51f /* if bit was 0, no rounding */
16103 +
16104 + /* msb of part to remove is 1, so rounding depends on rest of bits */
16105 + tst \scratch2,\scratch2 /* get shifted out tail */
16106 + brne 50f /* if rest > 0, do round */
16107 + bld \mant_lo,1 /* we have to look at lsb in result */
16108 + brcc 51f /* if lsb is 0, don't round */
16109 +
16110 +50:
16111 + /* subnormal result requires rounding
16112 + rounding may cause subnormal to become smallest normal number
16113 + luckily, smallest normal number has exactly the representation
16114 + we got by rippling a one bit up from mantissa into exponent field. */
16115 + sub \mant_lo,-1
16116 + subcc \mant_hi,-1
16117 +
16118 +51:
16119 + /* shift and return packed double with correct sign */
16120 + rol \sign
16121 + ror \mant_hi
16122 + ror \mant_lo
16123 +52:
16124 +.endm
16125 +
16126 +
16127 +/* Adjust subnormal single float number with exponent [exp]
16128 + and mantissa [mant] and round. */
16129 +.macro adjust_subnormal_sf sf, exp, mant, sign, scratch
16130 + /* subnormal number */
16131 + rsub \exp,\exp, 1 /* shift amount */
16132 + cp.w \exp, 25
16133 + movhs \mant, 0
16134 + brhs 90f /* Return zero */
16135 + rsub \scratch, \exp, 32
16136 + lsl \scratch, \mant,\scratch/* Check if there are any bits set
16137 + in the bits discarded in the mantissa */
16138 + srne \scratch /* If so set the lsb of the shifted mantissa */
16139 + lsr \mant,\mant,\exp /* Shift the mantissa */
16140 + or \mant, \scratch /* Round lsb if any bits were shifted out */
16141 + /* Rounding : For explaination, see round_sf. */
16142 + mov \scratch, 0x7f /* Set rounding constant */
16143 + bld \mant, 8
16144 + subeq \scratch, -1 /* For odd numbers use rounding constant 0x80 */
16145 + add \mant, \scratch /* Add rounding constant to mantissa */
16146 + /* We can't overflow because mantissa is at least shifted one position
16147 + to the right so the implicit bit is zero. We can however get the implicit
16148 + bit set after rounding which means that we have the lowest normal number
16149 + but this is ok since this bit has the same position as the LSB of the
16150 + exponent */
16151 + lsr \sf, \mant, 7
16152 + /* Rotate in sign */
16153 + lsl \sign, 1
16154 + ror \sf
16155 +90:
16156 +.endm
16157 +
16158 +
16159 +/* Round the unpacked df number with exponent [exp] and
16160 + mantissa [mant_hi, mant_lo]. Uses scratch register
16161 + [scratch] */
16162 +.macro round_df exp, mant_lo, mant_hi, scratch
16163 + mov \scratch, 0x3ff /* Rounding constant */
16164 + bld \mant_lo,11 /* Check if lsb in the final result is
16165 + set */
16166 + subeq \scratch, -1 /* Adjust rounding constant to 0x400
16167 + if rounding 0.5 upwards */
16168 + add \mant_lo, \scratch /* Round */
16169 + acr \mant_hi /* If overflowing we know that
16170 + we have all zeros in the bits not
16171 + scaled out so we can leave them
16172 + but we must increase the exponent with
16173 + two since we had an implicit bit
16174 + which is lost + the extra overflow bit */
16175 + subcs \exp, -2 /* Update exponent */
16176 +.endm
16177 +
16178 +/* Round single float number stored in [mant] and [exp] */
16179 +.macro round_sf exp, mant, scratch
16180 + /* Round:
16181 + For 0.5 we round to nearest even integer
16182 + for all other cases we round to nearest integer.
16183 + This means that if the digit left of the "point" (.)
16184 + is 1 we can add 0x80 to the mantissa since the
16185 + corner case 0x180 will round up to 0x200. If the
16186 + digit left of the "point" is 0 we will have to
16187 + add 0x7f since this will give 0xff and hence a
16188 + truncation/rounding downwards for the corner
16189 + case when the 9 lowest bits are 0x080 */
16190 + mov \scratch, 0x7f /* Set rounding constant */
16191 + /* Check if the mantissa is even or odd */
16192 + bld \mant, 8
16193 + subeq \scratch, -1 /* Rounding constant should be 0x80 */
16194 + add \mant, \scratch
16195 + subcs \exp, -2 /* Adjust exponent if we overflowed */
16196 +.endm
16197 +
16198 +/* Scale mantissa [mant_hi, mant_lo] with amount [shift_count].
16199 + Uses scratch registers [scratch1] and [scratch2] */
16200 +.macro scale_df shift_count, mant_lo, mant_hi, scratch1, scratch2
16201 + /* Scale [mant_hi, mant_lo] with shift_amount.
16202 + Must not forget the sticky bits we intend to shift out. */
16203 +
16204 + rsub \scratch1,\shift_count,32/* get (32 - shift count)
16205 + (if shift count > 32 we get a
16206 + negative value, but that will
16207 + work as well in the code below.) */
16208 +
16209 + cp.w \shift_count,32 /* handle shifts >= 32 separately */
16210 + brhs 70f
16211 +
16212 + /* small (<32) shift amount, both words are part of the shift
16213 + first remember whether part that is lost contains any 1 bits ... */
16214 + lsl \scratch2,\mant_lo,\scratch1 /*shift away bits that are part of
16215 + final mantissa. only part that goes
16216 + to scratch2 are bits that will be lost */
16217 +
16218 + /* ... and now to the actual shift */
16219 + lsl \scratch1,\mant_hi,\scratch1 /* get bits from msw destined for lsw*/
16220 + lsr \mant_lo,\mant_lo,\shift_count /* shift down lsw of mantissa */
16221 + lsr \mant_hi,\mant_hi,\shift_count /* shift down msw of mantissa */
16222 + or \mant_lo,\scratch1 /* combine these bits with prepared lsw*/
16223 + rjmp 71f
16224 +
16225 + /* large (>=32) shift amount, only lsw will have bits left after shift.
16226 + note that shift operations will use ((shift count) mod 32) so
16227 + we do not need to subtract 32 from shift count. */
16228 +70:
16229 + /* first remember whether part that is lost contains any 1 bits ... */
16230 + lsl \scratch2,\mant_hi,\scratch1 /* save all lost bits from msw */
16231 + or \scratch2,\mant_lo /* also save lost bits (all) from lsw
16232 + now scratch2<>0 if we lose any bits */
16233 +
16234 + /* ... and now to the actual shift */
16235 + mov \mant_lo,\mant_hi /* msw -> lsw (i.e. "shift 32 first")*/
16236 + mov \mant_hi,0 /* clear msw */
16237 + lsr \mant_lo,\mant_lo,\shift_count /* make rest of shift inside lsw*/
16238 +
16239 +71:
16240 + cp.w \scratch2,0 /* if any '1' bit in part we lost ...*/
16241 + breq 70f
16242 +
16243 + sbr \mant_lo,0 /* ... we need to set sticky bit*/
16244 +70:
16245 +.endm
16246 +
16247 +/* Unpack exponent and mantissa from the double number
16248 + stored in [df_hi,df_lo]. The exponent is stored in [exp]
16249 + while the mantissa is stored in [df_hi,df_lo]. */
16250 +
16251 +.macro unpack_df exp, df_lo, df_hi
16252 + lsr \exp, \df_hi,21 /* Extract exponent */
16253 + lsl \df_hi,10 /* Get mantissa */
16254 + or \df_hi,\df_hi,\df_lo>>21
16255 + lsl \df_lo,11
16256 +
16257 + neg \exp /* Fix implicit bit */
16258 + bst \df_hi,31
16259 + subeq \exp,1
16260 + neg \exp /* negate back exponent */
16261 + .endm
16262 +
16263 +/* Unpack exponent and mantissa from the single float number
16264 + stored in [sf]. The exponent is stored in [exp]
16265 + while the mantissa is stored in [sf]. */
16266 +.macro unpack_sf exp, sf
16267 + lsr \exp, \sf, 24
16268 + brne 80f
16269 + /* Fix subnormal number */
16270 + lsl \sf,7
16271 + clz \exp,\sf
16272 + lsl \sf,\sf,\exp
16273 + rsub \exp,\exp,1
16274 + rjmp 81f
16275 +80:
16276 + lsl \sf,7
16277 + sbr \sf, 31 /*Implicit bit*/
16278 +81:
16279 +.endm
16280 +
16281 +
16282 +
16283 +/* Pack a single float number stored in [mant] and [exp]
16284 + into a single float number in [sf] */
16285 +.macro pack_sf sf, exp, mant
16286 + bld \mant,31 /* implicit bit to z */
16287 + subne \exp,1 /* if subnormal (implicit bit 0)
16288 + adjust exponent to storage format */
16289 +
16290 + lsr \sf, \mant, 7
16291 + bfins \sf, \exp, 24, 8
16292 +.endm
16293 +
16294 +/* Pack exponent [exp] and mantissa [mant_hi, mant_lo]
16295 + into [df_hi, df_lo]. [df_hi] is shifted
16296 + one bit up so the sign bit can be shifted into it */
16297 +
16298 +.macro pack_df exp, mant_lo, mant_hi, df_lo, df_hi
16299 + bld \mant_hi,31 /* implicit bit to z */
16300 + subne \exp,1 /* if subnormal (implicit bit 0)
16301 + adjust exponent to storage format */
16302 +
16303 + lsr \mant_lo,11 /* shift back lsw */
16304 + or \df_lo,\mant_lo,\mant_hi<<21 /* combine with low bits from msw */
16305 + lsl \mant_hi,1 /* get rid of implicit bit */
16306 + lsr \mant_hi,11 /* shift back msw except for one step*/
16307 + or \df_hi,\mant_hi,\exp<<21 /* combine msw with exponent */
16308 +.endm
16309 +
16310 +/* Normalize single float number stored in [mant] and [exp]
16311 + using scratch register [scratch] */
16312 +.macro normalize_sf exp, mant, scratch
16313 + /* Adjust exponent and mantissa */
16314 + clz \scratch, \mant
16315 + sub \exp, \scratch
16316 + lsl \mant, \mant, \scratch
16317 +.endm
16318 +
16319 +/* Normalize the exponent and mantissa pair stored
16320 + in [mant_hi,mant_lo] and [exp]. Needs two scratch
16321 + registers [scratch1] and [scratch2]. */
16322 +.macro normalize_df exp, mant_lo, mant_hi, scratch1, scratch2
16323 + clz \scratch1,\mant_hi /* Check if we have zeros in high bits */
16324 + breq 80f /* No need for scaling if no zeros in high bits */
16325 + brcs 81f /* Check for all zeros */
16326 +
16327 + /* shift amount is smaller than 32, and involves both msw and lsw*/
16328 + rsub \scratch2,\scratch1,32 /* shift mantissa */
16329 + lsl \mant_hi,\mant_hi,\scratch1
16330 + lsr \scratch2,\mant_lo,\scratch2
16331 + or \mant_hi,\scratch2
16332 + lsl \mant_lo,\mant_lo,\scratch1
16333 + sub \exp,\scratch1 /* adjust exponent */
16334 + rjmp 80f /* Finished */
16335 +81:
16336 + /* shift amount is greater than 32 */
16337 + clz \scratch1,\mant_lo /* shift mantissa */
16338 + movcs \scratch1, 0
16339 + subcc \scratch1,-32
16340 + mov \mant_hi,\mant_lo
16341 + lsl \mant_hi,\mant_hi,\scratch1
16342 + mov \mant_lo,0
16343 + sub \exp,\scratch1 /* adjust exponent */
16344 +80:
16345 +.endm
16346 +
16347 +
16348 +/* Fast but approximate multiply of two 64-bit numbers to give a 64 bit result.
16349 + The multiplication of [al]x[bl] is discarded.
16350 + Operands in [ah], [al], [bh], [bl].
16351 + Scratch registers in [sh], [sl].
16352 + Returns results in registers [rh], [rl].*/
16353 +.macro mul_approx_df ah, al, bh, bl, rh, rl, sh, sl
16354 + mulu.d \sl, \ah, \bl
16355 + macu.d \sl, \al, \bh
16356 + mulu.d \rl, \ah, \bh
16357 + add \rl, \sh
16358 + acr \rh
16359 +.endm
16360 +
16361 +
16362 +
16363 +
16364 +#ifdef L_avr32_f64_mul
16365 + .align 2
16366 + .global __avr32_f64_mul
16367 + .type __avr32_f64_mul,@function
16368 +
16369 +
16370 +__avr32_f64_mul:
16371 + or r12, r10, r11 << 1
16372 + breq __avr32_f64_mul_op1_zero
16373 +
16374 + stm --sp, r5,r6,r7,lr
16375 + /* op1 in {r11,r10}*/
16376 + /* op2 in {r9,r8}*/
16377 + eor lr, r11, r9 /* MSB(lr) = Sign(op1) ^ Sign(op2) */
16378 +
16379 + /* Unpack op1 */
16380 + /* exp: r7 */
16381 + /* sf: r11, r10 */
16382 + lsr r7, r11, 20 /* Extract exponent */
16383 +
16384 + lsl r11, 11 /* Extract mantissa, leave room for implicit bit */
16385 + or r11, r11, r10>>21
16386 + lsl r10, 11
16387 + sbr r11, 31 /* Insert implicit bit */
16388 +
16389 + cbr r7, 11 /* Clear sign bit */
16390 + /* Check if normalization is needed */
16391 + breq __avr32_f64_mul_op1_subnormal /*If number is subnormal, normalize it */
16392 +
16393 +22:
16394 + /* Unpack op2 */
16395 + /* exp: r6 */
16396 + /* sf: r9, r8 */
16397 + lsr r6, r9, 20 /* Extract exponent */
16398 +
16399 + lsl r9, 11 /* Extract mantissa, leave room for implicit bit */
16400 + or r9, r9, r8>>21
16401 + lsl r8, 11
16402 + sbr r9, 31 /* Insert implicit bit */
16403 +
16404 + cbr r6, 11 /* Clear sign bit */
16405 + /* Check if normalization is needed */
16406 + breq __avr32_f64_mul_op2_subnormal /*If number is subnormal, normalize it */
16407 +23:
16408 +
16409 + /* Check if any operands are NaN or INF */
16410 + cp r7, 0x7ff
16411 + breq __avr32_f64_mul_op_nan_or_inf /* Check op1 for NaN or Inf */
16412 + cp r6, 0x7ff
16413 + breq __avr32_f64_mul_op_nan_or_inf /* Check op2 for NaN or Inf */
16414 +
16415 +
16416 + /* Calculate new exponent in r12*/
16417 + add r12, r7, r6
16418 + sub r12, (1023-1)
16419 +
16420 + /* Do the multiplication using approximate calculation.
16421 + Place result in r11, r10. Use r7, r6 as scratch registers */
16422 + mul_approx_df r11 /*ah*/, r10 /*al*/, r9 /*bh*/, r8 /*bl*/, r11 /*rh*/, r10 /*rl*/, r7 /*sh*/, r6 /*sl*/
16423 +
16424 + /* Check if result is zero */
16425 + breq __avr32_f64_mul_res_subnormal
16426 +
16427 + /* Adjust exponent and mantissa */
16428 + /* [r12]:exp, [r11, r10]:mant, [r9,r8,r7]:scratch*/
16429 + /* Mantissa may be of the format 0.xxxx or 1.xxxx. */
16430 + /* In the first case, shift one pos to left.*/
16431 + sub r9, r12, 1
16432 + mov r8, r11
16433 + lsl r7, r10, 1
16434 + rol r8
16435 + bld r11, 31
16436 + movne r12, r9
16437 + movne r11, r8
16438 + movne r10, r7
16439 + cp r12, 0
16440 + breq __avr32_f64_mul_res_subnormal /*Result was subnormal. Flush-to-zero and return zero*/
16441 +
16442 + /* Check for Inf. */
16443 + cp.w r12, 0x7ff
16444 + brge __avr32_f64_mul_res_inf
16445 +
16446 + /* Result was not subnormal. Perform rounding. */
16447 + /* Because of performance optimization, we have no sticky bit, */
16448 + /* so round-to-even won't work as specified in the IEEE standard.*/
16449 + /* [r12]:exp, [r11, r10]:mant */
16450 + /* Mantissa is in 0.64 format. Round by adding 1<<(64-(52+2))=1<<10*/
16451 + /* That is, 1 in the MSB of the part that will be discarded in final packing.*/
16452 + mov r9, (1<<10)
16453 + add r10, r9
16454 + acr r11
16455 + /* Adjust exponent if we overflowed.*/
16456 + subcs r12, -1
16457 +
16458 +
16459 + /* Pack final result*/
16460 + /* Input: [r12]:exp, [r11, r10]:mant */
16461 + /* Result in [r11,r10] */
16462 + /* Insert mantissa */
16463 + cbr r11, 31 /*Clear implicit bit*/
16464 + lsr r10, 11
16465 + or r10, r10, r11<<21
16466 + lsr r11, 11
16467 + /* Insert exponent and sign bit*/
16468 + or r11, r11, r12<<20
16469 + bld lr, 31
16470 + bst r11, 31
16471 +
16472 + /* Return result in [r11,r10] */
16473 + ldm sp++, r5, r6, r7,pc
16474 +
16475 +
16476 +__avr32_f64_mul_op1_subnormal:
16477 + cbr r11, 31 /* Clear implicit bit. */
16478 + normalize_df r7 /*exp*/, r10, r11 /*Mantissa*/, r5, r12 /*scratch*/
16479 + rjmp 22b
16480 +
16481 +__avr32_f64_mul_op2_subnormal:
16482 + cbr r9, 31 /* Clear implicit bit. */
16483 + normalize_df r6 /*exp*/, r8, r9 /*Mantissa*/, r5, r12 /*scratch*/
16484 + rjmp 23b
16485 +
16486 +
16487 +__avr32_f64_mul_op_nan_or_inf:
16488 + /* Same code for OP1 and OP2*/
16489 + /* Since we are here, at least one of the OPs were NaN or INF*/
16490 + /* Shift out implicit bit of both operands' mantissa */
16491 + lsl r11, 1
16492 + lsl r9, 1
16493 + /* Merge the regs in each operand to check for zero*/
16494 + or r11, r10 /* op1 */
16495 + or r9, r8 /* op2 */
16496 + /* Check if op1 is NaN or INF */
16497 + cp r7, 0x7ff
16498 + brne __avr32_f64_mul_op1_not_naninf
16499 + /* op1 was NaN or INF.*/
16500 + cp r11, 0
16501 + brne __avr32_f64_mul_res_nan /* op1 was NaN. Result will be NaN*/
16502 + /*op1 was INF. check if op2 is NaN or INF*/
16503 + cp r6, 0x7ff
16504 + brne __avr32_f64_mul_res_inf /*op1 was INF, op2 was neither NaN nor INF*/
16505 + /* op1 is INF, op2 is either NaN or INF*/
16506 + cp r9, 0
16507 + breq __avr32_f64_mul_res_inf /*op2 was also INF*/
16508 + rjmp __avr32_f64_mul_res_nan /*op2 was NaN*/
16509 +
16510 +__avr32_f64_mul_op1_not_naninf:
16511 + /* op1 was not NaN nor INF. Then op2 must be NaN or INF*/
16512 + cp r9, 0
16513 + breq __avr32_f64_mul_res_inf /*op2 was INF, return INF*/
16514 + rjmp __avr32_f64_mul_res_nan /*else return NaN*/
16515 +
16516 +__avr32_f64_mul_res_subnormal:/* Multiply result was subnormal. Return zero. */
16517 + mov r11, lr /*Get correct sign*/
16518 + andh r11, 0x8000, COH
16519 + mov r10, 0
16520 + ldm sp++, r5, r6, r7,pc
16521 +
16522 +__avr32_f64_mul_res_nan: /* Return NaN. */
16523 + mov r11, -1
16524 + mov r10, -1
16525 + ldm sp++, r5, r6, r7,pc
16526 +
16527 +__avr32_f64_mul_res_inf: /* Return INF. */
16528 + mov r11, 0
16529 + orh r11, 0x7ff0
16530 + bld lr, 31
16531 + bst r11, 31
16532 + mov r10, 0
16533 + ldm sp++, r5, r6, r7,pc
16534 +
16535 +__avr32_f64_mul_op1_zero:
16536 + /* Get sign */
16537 + eor r11, r11, r9
16538 + andh r11, 0x8000, COH
16539 + /* Check if op2 is Inf or NaN. */
16540 + bfextu r12, r9, 20, 11
16541 + cp.w r12, 0x7ff
16542 + retne r12 /* Return 0.0 */
16543 + /* Return NaN */
16544 + mov r10, -1
16545 + mov r11, -1
16546 + ret r12
16547 +
16548 +
16549 +
16550 +#endif
16551 +
16552 +
16553 +#if defined(L_avr32_f64_addsub) || defined(L_avr32_f64_addsub_fast)
16554 + .align 2
16555 +
16556 +__avr32_f64_sub_from_add:
16557 + /* Switch sign on op2 */
16558 + eorh r9, 0x8000
16559 +
16560 +#if defined(L_avr32_f64_addsub_fast)
16561 + .global __avr32_f64_sub_fast
16562 + .type __avr32_f64_sub_fast,@function
16563 +__avr32_f64_sub_fast:
16564 +#else
16565 + .global __avr32_f64_sub
16566 + .type __avr32_f64_sub,@function
16567 +__avr32_f64_sub:
16568 +#endif
16569 +
16570 + /* op1 in {r11,r10}*/
16571 + /* op2 in {r9,r8}*/
16572 +
16573 +#if defined(L_avr32_f64_addsub_fast)
16574 + /* If op2 is zero just return op1 */
16575 + or r12, r8, r9 << 1
16576 + reteq r12
16577 +#endif
16578 +
16579 + /* Check signs */
16580 + eor r12, r11, r9
16581 + /* Different signs, use addition. */
16582 + brmi __avr32_f64_add_from_sub
16583 +
16584 + stm --sp, r5, r6, r7, lr
16585 +
16586 + /* Get sign of op1 into r12 */
16587 + mov r12, r11
16588 + andh r12, 0x8000, COH
16589 +
16590 + /* Remove sign from operands */
16591 + cbr r11, 31
16592 + cbr r9, 31
16593 +
16594 + /* Put the number with the largest exponent in [r11, r10]
16595 + and the number with the smallest exponent in [r9, r8] */
16596 + cp r11, r9
16597 + brhs 1f /* Skip swap if operands already correctly ordered*/
16598 + /* Operands were not correctly ordered, swap them*/
16599 + mov r7, r11
16600 + mov r11, r9
16601 + mov r9, r7
16602 + mov r7, r10
16603 + mov r10, r8
16604 + mov r8, r7
16605 + eorh r12, 0x8000 /* Invert sign in r12*/
16606 +1:
16607 + /* Unpack largest operand - opH */
16608 + /* exp: r7 */
16609 + /* sf: r11, r10 */
16610 + lsr r7, r11, 20 /* Extract exponent */
16611 + cbr r7, 11 /* Clear sign bit */
16612 + lsl r11, 11 /* Extract mantissa, leave room for implicit bit */
16613 + or r11, r11, r10>>21
16614 + lsl r10, 11
16615 + sbr r11, 31 /* Insert implicit bit */
16616 +
16617 +
16618 + /* Unpack smallest operand - opL */
16619 + /* exp: r6 */
16620 + /* sf: r9, r8 */
16621 + lsr r6, r9, 20 /* Extract exponent */
16622 + cbr r6, 11 /* Clear sign bit */
16623 + breq __avr32_f64_sub_opL_subnormal /* If either zero or subnormal */
16624 + lsl r9, 11 /* Extract mantissa, leave room for implicit bit */
16625 + or r9, r9, r8>>21
16626 + lsl r8, 11
16627 + sbr r9, 31 /* Insert implicit bit */
16628 +
16629 +
16630 +__avr32_f64_sub_opL_subnormal_done:
16631 + /* opH is NaN or Inf. */
16632 + cp.w r7, 0x7ff
16633 + breq __avr32_f64_sub_opH_nan_or_inf
16634 +
16635 + /* Get shift amount to scale mantissa of op2. */
16636 + rsub r6, r7
16637 + breq __avr32_f64_sub_shift_done /* No need to shift, exponents are equal*/
16638 +
16639 + /* Scale mantissa [r9, r8] with amount [r6].
16640 + Uses scratch registers [r5] and [lr].
16641 + In IEEE mode:Must not forget the sticky bits we intend to shift out. */
16642 +
16643 + rsub r5,r6,32 /* get (32 - shift count)
16644 + (if shift count > 32 we get a
16645 + negative value, but that will
16646 + work as well in the code below.) */
16647 +
16648 + cp.w r6,32 /* handle shifts >= 32 separately */
16649 + brhs __avr32_f64_sub_longshift
16650 +
16651 + /* small (<32) shift amount, both words are part of the shift
16652 + first remember whether part that is lost contains any 1 bits ... */
16653 + lsl lr,r8,r5 /* shift away bits that are part of
16654 + final mantissa. only part that goes
16655 + to lr are bits that will be lost */
16656 +
16657 + /* ... and now to the actual shift */
16658 + lsl r5,r9,r5 /* get bits from msw destined for lsw*/
16659 + lsr r8,r8,r6 /* shift down lsw of mantissa */
16660 + lsr r9,r9,r6 /* shift down msw of mantissa */
16661 + or r8,r5 /* combine these bits with prepared lsw*/
16662 +#if defined(L_avr32_f64_addsub)
16663 + cp.w lr,0 /* if any '1' bit in part we lost ...*/
16664 + srne lr
16665 + or r8, lr /* ... we need to set sticky bit*/
16666 +#endif
16667 +
16668 +__avr32_f64_sub_shift_done:
16669 + /* Now subtract the mantissas. */
16670 + sub r10, r8
16671 + sbc r11, r11, r9
16672 +
16673 + /* Normalize the exponent and mantissa pair stored in
16674 + [r11,r10] and exponent in [r7]. Needs two scratch registers [r6] and [lr]. */
16675 + clz r6,r11 /* Check if we have zeros in high bits */
16676 + breq __avr32_f64_sub_longnormalize_done /* No need for scaling if no zeros in high bits */
16677 + brcs __avr32_f64_sub_longnormalize
16678 +
16679 + /* shift amount is smaller than 32, and involves both msw and lsw*/
16680 + rsub lr,r6,32 /* shift mantissa */
16681 + lsl r11,r11,r6
16682 + lsr lr,r10,lr
16683 + or r11,lr
16684 + lsl r10,r10,r6
16685 + sub r7,r6 /* adjust exponent */
16686 + brle __avr32_f64_sub_subnormal_result
16687 +
16688 +__avr32_f64_sub_longnormalize_done:
16689 +
16690 +#if defined(L_avr32_f64_addsub)
16691 + /* Insert the bits we will remove from the mantissa r9[31:21] */
16692 + lsl r9, r10, (32 - 11)
16693 +#else
16694 + /* Keep the last bit shifted out. */
16695 + bfextu r9, r10, 10, 1
16696 +#endif
16697 +
16698 + /* Pack final result*/
16699 + /* Input: [r7]:exp, [r11, r10]:mant, [r12]:sign in MSB */
16700 + /* Result in [r11,r10] */
16701 + /* Insert mantissa */
16702 + cbr r11, 31 /*Clear implicit bit*/
16703 + lsr r10, 11
16704 + or r10, r10, r11<<21
16705 + lsr r11, 11
16706 + /* Insert exponent and sign bit*/
16707 + or r11, r11, r7<<20
16708 + bld r12, 31
16709 + bst r11, 31
16710 +
16711 + /* Round */
16712 +__avr32_f64_sub_round:
16713 +#if defined(L_avr32_f64_addsub)
16714 + mov r7, 0
16715 + sbr r7, 31
16716 + bld r10, 0
16717 + subne r7, -1
16718 +
16719 + cp.w r9, r7
16720 + srhs r9
16721 +#endif
16722 + add r10, r9
16723 + acr r11
16724 +
16725 + /* Return result in [r11,r10] */
16726 + ldm sp++, r5, r6, r7,pc
16727 +
16728 +
16729 +
16730 +__avr32_f64_sub_opL_subnormal:
16731 + /* Extract the of mantissa */
16732 + lsl r9, 11 /* Extract mantissa, leave room for implicit bit */
16733 + or r9, r9, r8>>21
16734 + lsl r8, 11
16735 +
16736 + /* Set exponent to 1 if we do not have a zero. */
16737 + or lr, r9, r8
16738 + movne r6,1
16739 +
16740 + /* Check if opH is also subnormal. If so, clear implicit bit in r11*/
16741 + rsub lr, r7, 0
16742 + moveq r7,1
16743 + bst r11, 31
16744 +
16745 + /* Check if op1 is zero, if so set exponent to 0. */
16746 + or lr, r11, r10
16747 + moveq r7,0
16748 +
16749 + rjmp __avr32_f64_sub_opL_subnormal_done
16750 +
16751 +__avr32_f64_sub_opH_nan_or_inf:
16752 + /* Check if opH is NaN, if so return NaN */
16753 + cbr r11, 31
16754 + or lr, r11, r10
16755 + brne __avr32_f64_sub_return_nan
16756 +
16757 + /* opH is Inf. */
16758 + /* Check if opL is Inf. or NaN */
16759 + cp.w r6, 0x7ff
16760 + breq __avr32_f64_sub_opL_nan_or_inf
16761 + ldm sp++, r5, r6, r7, pc/* opL not Inf or NaN, return opH */
16762 +__avr32_f64_sub_opL_nan_or_inf:
16763 + cbr r9, 31
16764 + or lr, r9, r8
16765 + brne __avr32_f64_sub_return_nan
16766 + mov r10, 0 /* Generate Inf in r11, r10 */
16767 + mov r11, 0
16768 + orh r11, 0x7ff0
16769 + ldm sp++, r5, r6, r7, pc/* opL Inf, return Inf */
16770 +__avr32_f64_sub_return_nan:
16771 + mov r10, -1 /* Generate NaN in r11, r10 */
16772 + mov r11, -1
16773 + ldm sp++, r5, r6, r7, pc/* opL Inf or NaN, return NaN */
16774 +
16775 +
16776 +__avr32_f64_sub_subnormal_result:
16777 + /* Just flush subnormals to zero. */
16778 + mov r10, 0
16779 + mov r11, 0
16780 + ldm sp++, r5, r6, r7, pc
16781 +
16782 +
16783 +__avr32_f64_sub_longshift:
16784 + /* large (>=32) shift amount, only lsw will have bits left after shift.
16785 + note that shift operations will use ((shift count=r6) mod 32) so
16786 + we do not need to subtract 32 from shift count. */
16787 + /* Saturate the shift amount to 63. If the amount
16788 + is any larger op2 is insignificant. */
16789 + satu r6 >> 0, 6
16790 +#if defined(L_avr32_f64_addsub)
16791 + /* first remember whether part that is lost contains any 1 bits ... */
16792 + lsl lr,r9,r5 /* save all lost bits from msw */
16793 + or lr,r8 /* also save lost bits (all) from lsw
16794 + now lr != 0 if we lose any bits */
16795 +#endif
16796 + /* ... and now to the actual shift */
16797 + mov r8,r9 /* msw -> lsw (i.e. "shift 32 first")*/
16798 + mov r9,0 /* clear msw */
16799 + lsr r8,r8,r6 /* make rest of shift inside lsw*/
16800 +#if defined(L_avr32_f64_addsub)
16801 + cp.w lr,0 /* if any '1' bit in part we lost ...*/
16802 + sreq lr
16803 + or r8, lr /* ... we need to set sticky bit*/
16804 +#endif
16805 + rjmp __avr32_f64_sub_shift_done
16806 +
16807 +__avr32_f64_sub_longnormalize:
16808 + /* shift amount is greater than 32 */
16809 + clz r6,r10 /* shift mantissa */
16810 + /* If the resulting mantissa is zero the result is
16811 + zero so force exponent to zero. */
16812 + movcs r7, 0
16813 + movcs r6, 0
16814 + subcc r6,-32
16815 + mov r11,r10
16816 + lsl r11,r11,r6
16817 + mov r10,0
16818 + sub r7,r6 /* adjust exponent */
16819 + brle __avr32_f64_sub_subnormal_result
16820 + rjmp __avr32_f64_sub_longnormalize_done
16821 +
16822 +
16823 +
16824 + .align 2
16825 +__avr32_f64_add_from_sub:
16826 + /* Switch sign on op2 */
16827 + eorh r9, 0x8000
16828 +
16829 +#if defined(L_avr32_f64_addsub_fast)
16830 + .global __avr32_f64_add_fast
16831 + .type __avr32_f64_add_fast,@function
16832 +__avr32_f64_add_fast:
16833 +#else
16834 + .global __avr32_f64_add
16835 + .type __avr32_f64_add,@function
16836 +__avr32_f64_add:
16837 +#endif
16838 +
16839 + /* op1 in {r11,r10}*/
16840 + /* op2 in {r9,r8}*/
16841 +
16842 +#if defined(L_avr32_f64_addsub_fast)
16843 + /* If op2 is zero just return op1 */
16844 + or r12, r8, r9 << 1
16845 + reteq r12
16846 +#endif
16847 +
16848 + /* Check signs */
16849 + eor r12, r11, r9
16850 + /* Different signs, use subtraction. */
16851 + brmi __avr32_f64_sub_from_add
16852 +
16853 + stm --sp, r5, r6, r7, lr
16854 +
16855 + /* Get sign of op1 into r12 */
16856 + mov r12, r11
16857 + andh r12, 0x8000, COH
16858 +
16859 + /* Remove sign from operands */
16860 + cbr r11, 31
16861 + cbr r9, 31
16862 +
16863 + /* Put the number with the largest exponent in [r11, r10]
16864 + and the number with the smallest exponent in [r9, r8] */
16865 + cp r11, r9
16866 + brhs 1f /* Skip swap if operands already correctly ordered*/
16867 + /* Operands were not correctly ordered, swap them*/
16868 + mov r7, r11
16869 + mov r11, r9
16870 + mov r9, r7
16871 + mov r7, r10
16872 + mov r10, r8
16873 + mov r8, r7
16874 +1:
16875 + /* Unpack largest operand - opH */
16876 + /* exp: r7 */
16877 + /* sf: r11, r10 */
16878 + lsr r7, r11, 20 /* Extract exponent */
16879 + cbr r7, 11 /* Clear sign bit */
16880 + lsl r11, 11 /* Extract mantissa, leave room for implicit bit */
16881 + or r11, r11, r10>>21
16882 + lsl r10, 11
16883 + sbr r11, 31 /* Insert implicit bit */
16884 +
16885 +
16886 + /* Unpack smallest operand - opL */
16887 + /* exp: r6 */
16888 + /* sf: r9, r8 */
16889 + lsr r6, r9, 20 /* Extract exponent */
16890 + cbr r6, 11 /* Clear sign bit */
16891 + breq __avr32_f64_add_opL_subnormal /* If either zero or subnormal */
16892 + lsl r9, 11 /* Extract mantissa, leave room for implicit bit */
16893 + or r9, r9, r8>>21
16894 + lsl r8, 11
16895 + sbr r9, 31 /* Insert implicit bit */
16896 +
16897 +
16898 +__avr32_f64_add_opL_subnormal_done:
16899 + /* opH is NaN or Inf. */
16900 + cp.w r7, 0x7ff
16901 + breq __avr32_f64_add_opH_nan_or_inf
16902 +
16903 + /* Get shift amount to scale mantissa of op2. */
16904 + rsub r6, r7
16905 + breq __avr32_f64_add_shift_done /* No need to shift, exponents are equal*/
16906 +
16907 + /* Scale mantissa [r9, r8] with amount [r6].
16908 + Uses scratch registers [r5] and [lr].
16909 + In IEEE mode:Must not forget the sticky bits we intend to shift out. */
16910 + rsub r5,r6,32 /* get (32 - shift count)
16911 + (if shift count > 32 we get a
16912 + negative value, but that will
16913 + work as well in the code below.) */
16914 +
16915 + cp.w r6,32 /* handle shifts >= 32 separately */
16916 + brhs __avr32_f64_add_longshift
16917 +
16918 + /* small (<32) shift amount, both words are part of the shift
16919 + first remember whether part that is lost contains any 1 bits ... */
16920 + lsl lr,r8,r5 /* shift away bits that are part of
16921 + final mantissa. only part that goes
16922 + to lr are bits that will be lost */
16923 +
16924 + /* ... and now to the actual shift */
16925 + lsl r5,r9,r5 /* get bits from msw destined for lsw*/
16926 + lsr r8,r8,r6 /* shift down lsw of mantissa */
16927 + lsr r9,r9,r6 /* shift down msw of mantissa */
16928 + or r8,r5 /* combine these bits with prepared lsw*/
16929 +#if defined(L_avr32_f64_addsub)
16930 + cp.w lr,0 /* if any '1' bit in part we lost ...*/
16931 + srne lr
16932 + or r8, lr /* ... we need to set sticky bit*/
16933 +#endif
16934 +
16935 +__avr32_f64_add_shift_done:
16936 + /* Now add the mantissas. */
16937 + add r10, r8
16938 + adc r11, r11, r9
16939 +
16940 + /* Check if we overflowed. */
16941 + brcs __avr32_f64_add_res_of
16942 +
16943 +__avr32_f64_add_res_of_done:
16944 +
16945 +#if defined(L_avr32_f64_addsub)
16946 + /* Insert the bits we will remove from the mantissa r9[31:21] */
16947 + lsl r9, r10, (32 - 11)
16948 +#else
16949 + /* Keep the last bit shifted out. */
16950 + bfextu r9, r10, 10, 1
16951 +#endif
16952 +
16953 + /* Pack final result*/
16954 + /* Input: [r7]:exp, [r11, r10]:mant, [r12]:sign in MSB */
16955 + /* Result in [r11,r10] */
16956 + /* Insert mantissa */
16957 + cbr r11, 31 /*Clear implicit bit*/
16958 + lsr r10, 11
16959 + or r10, r10, r11<<21
16960 + lsr r11, 11
16961 + /* Insert exponent and sign bit*/
16962 + or r11, r11, r7<<20
16963 + bld r12, 31
16964 + bst r11, 31
16965 +
16966 + /* Round */
16967 +__avr32_f64_add_round:
16968 +#if defined(L_avr32_f64_addsub)
16969 + mov r7, 0
16970 + sbr r7, 31
16971 + bld r10, 0
16972 + subne r7, -1
16973 +
16974 + cp.w r9, r7
16975 + srhs r9
16976 +#endif
16977 + add r10, r9
16978 + acr r11
16979 +
16980 + /* Return result in [r11,r10] */
16981 + ldm sp++, r5, r6, r7,pc
16982 +
16983 +
16984 +
16985 +__avr32_f64_add_opL_subnormal:
16986 + /* Extract the of mantissa */
16987 + lsl r9, 11 /* Extract mantissa, leave room for implicit bit */
16988 + or r9, r9, r8>>21
16989 + lsl r8, 11
16990 +
16991 + /* Set exponent to 1 if we do not have a zero. */
16992 + or lr, r9, r8
16993 + movne r6,1
16994 +
16995 + /* Check if opH is also subnormal. If so, clear implicit bit in r11*/
16996 + rsub lr, r7, 0
16997 + moveq r7,1
16998 + bst r11, 31
16999 +
17000 + /* Check if op1 is zero, if so set exponent to 0. */
17001 + or lr, r11, r10
17002 + moveq r7,0
17003 +
17004 + rjmp __avr32_f64_add_opL_subnormal_done
17005 +
17006 +__avr32_f64_add_opH_nan_or_inf:
17007 + /* Check if opH is NaN, if so return NaN */
17008 + cbr r11, 31
17009 + or lr, r11, r10
17010 + brne __avr32_f64_add_return_nan
17011 +
17012 + /* opH is Inf. */
17013 + /* Check if opL is Inf. or NaN */
17014 + cp.w r6, 0x7ff
17015 + breq __avr32_f64_add_opL_nan_or_inf
17016 + ldm sp++, r5, r6, r7, pc/* opL not Inf or NaN, return opH */
17017 +__avr32_f64_add_opL_nan_or_inf:
17018 + cbr r9, 31
17019 + or lr, r9, r8
17020 + brne __avr32_f64_add_return_nan
17021 + mov r10, 0 /* Generate Inf in r11, r10 */
17022 + mov r11, 0
17023 + orh r11, 0x7ff0
17024 + ldm sp++, r5, r6, r7, pc/* opL Inf, return Inf */
17025 +__avr32_f64_add_return_nan:
17026 + mov r10, -1 /* Generate NaN in r11, r10 */
17027 + mov r11, -1
17028 + ldm sp++, r5, r6, r7, pc/* opL Inf or NaN, return NaN */
17029 +
17030 +
17031 +__avr32_f64_add_longshift:
17032 + /* large (>=32) shift amount, only lsw will have bits left after shift.
17033 + note that shift operations will use ((shift count=r6) mod 32) so
17034 + we do not need to subtract 32 from shift count. */
17035 + /* Saturate the shift amount to 63. If the amount
17036 + is any larger op2 is insignificant. */
17037 + satu r6 >> 0, 6
17038 +#if defined(L_avr32_f64_addsub)
17039 + /* first remember whether part that is lost contains any 1 bits ... */
17040 + lsl lr,r9,r5 /* save all lost bits from msw */
17041 + or lr,r8 /* also save lost bits (all) from lsw
17042 + now lr != 0 if we lose any bits */
17043 +#endif
17044 + /* ... and now to the actual shift */
17045 + mov r8,r9 /* msw -> lsw (i.e. "shift 32 first")*/
17046 + mov r9,0 /* clear msw */
17047 + lsr r8,r8,r6 /* make rest of shift inside lsw*/
17048 +#if defined(L_avr32_f64_addsub)
17049 + cp.w lr,0 /* if any '1' bit in part we lost ...*/
17050 + sreq lr
17051 + or r8, lr /* ... we need to set sticky bit*/
17052 +#endif
17053 + rjmp __avr32_f64_add_shift_done
17054 +
17055 +__avr32_f64_add_res_of:
17056 + /* We overflowed. Increase exponent and shift mantissa.*/
17057 + /* [r7]:exp, [r11, r10]:mant */
17058 + ror r11
17059 + lsr r10, 1
17060 + sub r7, -1
17061 +
17062 + /* Clear mantissa to set result to Inf if the exponent is 255. */
17063 + cp.w r7, 0x7ff
17064 + moveq r10, 0
17065 + moveq r11, 0
17066 + rjmp __avr32_f64_add_res_of_done
17067 +
17068 +
17069 +#endif
17070 +
17071 +#ifdef L_avr32_f64_to_u32
17072 + /* This goes into L_fixdfsi */
17073 +#endif
17074 +
17075 +
17076 +#ifdef L_avr32_f64_to_s32
17077 + .global __avr32_f64_to_u32
17078 + .type __avr32_f64_to_u32,@function
17079 +__avr32_f64_to_u32:
17080 + cp.w r11, 0
17081 + retmi 0 /* Negative returns 0 */
17082 +
17083 + /* Fallthrough to df to signed si conversion */
17084 + .global __avr32_f64_to_s32
17085 + .type __avr32_f64_to_s32,@function
17086 +__avr32_f64_to_s32:
17087 + lsl r12,r11,1
17088 + lsr r12,21 /* extract exponent*/
17089 + sub r12,1023 /* convert to unbiased exponent.*/
17090 + retlo 0 /* too small exponent implies zero. */
17091 +
17092 +1:
17093 + rsub r12,r12,31 /* shift count = 31 - exponent */
17094 + mov r9,r11 /* save sign for later...*/
17095 + lsl r11,11 /* remove exponent and sign*/
17096 + sbr r11,31 /* add implicit bit*/
17097 + or r11,r11,r10>>21 /* get rest of bits from lsw of double */
17098 + lsr r11,r11,r12 /* shift down mantissa to final place */
17099 + lsl r9,1 /* sign -> carry */
17100 + retcc r11 /* if positive, we are done */
17101 + neg r11 /* if negative float, negate result */
17102 + ret r11
17103 +
17104 +#endif /* L_fixdfsi*/
17105 +
17106 +#ifdef L_avr32_f64_to_u64
17107 + /* Actual function is in L_fixdfdi */
17108 +#endif
17109 +
17110 +#ifdef L_avr32_f64_to_s64
17111 + .global __avr32_f64_to_u64
17112 + .type __avr32_f64_to_u64,@function
17113 +__avr32_f64_to_u64:
17114 + cp.w r11,0
17115 + /* Negative numbers return zero */
17116 + movmi r10, 0
17117 + movmi r11, 0
17118 + retmi r11
17119 +
17120 +
17121 +
17122 + /* Fallthrough */
17123 + .global __avr32_f64_to_s64
17124 + .type __avr32_f64_to_s64,@function
17125 +__avr32_f64_to_s64:
17126 + lsl r9,r11,1
17127 + lsr r9,21 /* get exponent*/
17128 + sub r9,1023 /* convert to correct range*/
17129 + /* Return zero if exponent to small */
17130 + movlo r10, 0
17131 + movlo r11, 0
17132 + retlo r11
17133 +
17134 + mov r8,r11 /* save sign for later...*/
17135 +1:
17136 + lsl r11,11 /* remove exponent */
17137 + sbr r11,31 /* add implicit bit*/
17138 + or r11,r11,r10>>21 /* get rest of bits from lsw of double*/
17139 + lsl r10,11 /* align lsw correctly as well */
17140 + rsub r9,r9,63 /* shift count = 63 - exponent */
17141 + breq 1f
17142 +
17143 + cp.w r9,32 /* is shift count more than one reg? */
17144 + brhs 0f
17145 +
17146 + mov r12,r11 /* save msw */
17147 + lsr r10,r10,r9 /* small shift count, shift down lsw */
17148 + lsr r11,r11,r9 /* small shift count, shift down msw */
17149 + rsub r9,r9,32 /* get 32-size of shifted out tail */
17150 + lsl r12,r12,r9 /* align part to move from msw to lsw */
17151 + or r10,r12 /* combine to get new lsw */
17152 + rjmp 1f
17153 +
17154 +0:
17155 + lsr r10,r11,r9 /* large shift count,only lsw get bits
17156 + note that shift count is modulo 32*/
17157 + mov r11,0 /* msw will be 0 */
17158 +
17159 +1:
17160 + lsl r8,1 /* sign -> carry */
17161 + retcc r11 /* if positive, we are done */
17162 +
17163 + neg r11 /* if negative float, negate result */
17164 + neg r10
17165 + scr r11
17166 + ret r11
17167 +
17168 +#endif
17169 +
17170 +#ifdef L_avr32_u32_to_f64
17171 + /* Code located in L_floatsidf */
17172 +#endif
17173 +
17174 +#ifdef L_avr32_s32_to_f64
17175 + .global __avr32_u32_to_f64
17176 + .type __avr32_u32_to_f64,@function
17177 +__avr32_u32_to_f64:
17178 + sub r11, r12, 0 /* Move to r11 and force Z flag to be updated */
17179 + mov r12, 0 /* always positive */
17180 + rjmp 0f /* Jump to common code for floatsidf */
17181 +
17182 + .global __avr32_s32_to_f64
17183 + .type __avr32_s32_to_f64,@function
17184 +__avr32_s32_to_f64:
17185 + mov r11, r12 /* Keep original value in r12 for sign */
17186 + abs r11 /* Absolute value if r12 */
17187 +0:
17188 + mov r10,0 /* let remaining bits be zero */
17189 + reteq r11 /* zero long will return zero float */
17190 +
17191 + pushm lr
17192 + mov r9,31+1023 /* set exponent */
17193 +
17194 + normalize_df r9 /*exp*/, r10, r11 /* mantissa */, r8, lr /* scratch */
17195 +
17196 + /* Check if a subnormal result was created */
17197 + cp.w r9, 0
17198 + brgt 0f
17199 +
17200 + adjust_subnormal_df r9 /* exp */, r10, r11 /* Mantissa */, r12 /*sign*/, r8, lr /* scratch */
17201 + popm pc
17202 +0:
17203 +
17204 + /* Round result */
17205 + round_df r9 /*exp*/, r10, r11 /* Mantissa */, r8 /*scratch*/
17206 + cp.w r9,0x7ff
17207 + brlt 0f
17208 + /*Return infinity */
17209 + mov r10, 0
17210 + mov r11, 0
17211 + orh r11, 0xffe0
17212 + rjmp __floatsidf_return_op1
17213 +
17214 +0:
17215 +
17216 + /* Pack */
17217 + pack_df r9 /*exp*/, r10, r11 /* mantissa */, r10, r11 /* Output df number*/
17218 +__floatsidf_return_op1:
17219 + lsl r12,1 /* shift in sign bit */
17220 + ror r11
17221 +
17222 + popm pc
17223 +#endif
17224 +
17225 +
17226 +#ifdef L_avr32_f32_cmp_eq
17227 + .global __avr32_f32_cmp_eq
17228 + .type __avr32_f32_cmp_eq,@function
17229 +__avr32_f32_cmp_eq:
17230 + cp.w r12, r11
17231 + breq 0f
17232 + /* If not equal check for +/-0 */
17233 + /* Or together the two values and shift out the sign bit.
17234 + If the result is zero, then the two values are both zero. */
17235 + or r12, r11
17236 + lsl r12, 1
17237 + sreq r12
17238 + ret r12
17239 +0:
17240 + /* Numbers were equal. Check for NaN or Inf */
17241 + mov r11, 0
17242 + orh r11, 0xff00
17243 + lsl r12, 1
17244 + cp.w r12, r11
17245 + srls r12 /* 0 if NaN, 1 otherwise */
17246 + ret r12
17247 +#endif
17248 +
17249 +#if defined(L_avr32_f32_cmp_ge) || defined(L_avr32_f32_cmp_lt)
17250 +#ifdef L_avr32_f32_cmp_ge
17251 + .global __avr32_f32_cmp_ge
17252 + .type __avr32_f32_cmp_ge,@function
17253 +__avr32_f32_cmp_ge:
17254 +#endif
17255 +#ifdef L_avr32_f32_cmp_lt
17256 + .global __avr32_f32_cmp_lt
17257 + .type __avr32_f32_cmp_lt,@function
17258 +__avr32_f32_cmp_lt:
17259 +#endif
17260 + lsl r10, r12, 1 /* Remove sign bits */
17261 + lsl r9, r11, 1
17262 + mov r8, 0
17263 + orh r8, 0xff00
17264 + cp.w r10, r8
17265 + rethi 0 /* Op0 is NaN */
17266 + cp.w r9, r8
17267 + rethi 0 /* Op1 is Nan */
17268 +
17269 + eor r8, r11, r12
17270 + bld r12, 31
17271 +#ifdef L_avr32_f32_cmp_ge
17272 + srcc r8 /* Set result to true if op0 is positive*/
17273 +#endif
17274 +#ifdef L_avr32_f32_cmp_lt
17275 + srcs r8 /* Set result to true if op0 is negative*/
17276 +#endif
17277 + retmi r8 /* Return if signs are different */
17278 + brcs 0f /* Both signs negative? */
17279 +
17280 + /* Both signs positive */
17281 + cp.w r12, r11
17282 +#ifdef L_avr32_f32_cmp_ge
17283 + srhs r12
17284 +#endif
17285 +#ifdef L_avr32_f32_cmp_lt
17286 + srlo r12
17287 +#endif
17288 + retal r12
17289 +0:
17290 + /* Both signs negative */
17291 + cp.w r11, r12
17292 +#ifdef L_avr32_f32_cmp_ge
17293 + srhs r12
17294 +#endif
17295 +#ifdef L_avr32_f32_cmp_lt
17296 + srlo r12
17297 +#endif
17298 + retal r12
17299 +#endif
17300 +
17301 +
17302 +#ifdef L_avr32_f64_cmp_eq
17303 + .global __avr32_f64_cmp_eq
17304 + .type __avr32_f64_cmp_eq,@function
17305 +__avr32_f64_cmp_eq:
17306 + cp.w r10,r8
17307 + cpc r11,r9
17308 + breq 0f
17309 +
17310 + /* Args were not equal*/
17311 + /* Both args could be zero with different sign bits */
17312 + lsl r11,1 /* get rid of sign bits */
17313 + lsl r9,1
17314 + or r11,r10 /* Check if all bits are zero */
17315 + or r11,r9
17316 + or r11,r8
17317 + sreq r12 /* If all zeros the arguments are equal
17318 + so return 1 else return 0 */
17319 + ret r12
17320 +0:
17321 + /* check for NaN */
17322 + lsl r11,1
17323 + mov r12, 0
17324 + orh r12, 0xffe0
17325 + cp.w r10,0
17326 + cpc r11,r12 /* check if nan or inf */
17327 + srls r12 /* If Arg is NaN return 0 else 1*/
17328 + ret r12 /* Return */
17329 +
17330 +#endif
17331 +
17332 +
17333 +#if defined(L_avr32_f64_cmp_ge) || defined(L_avr32_f64_cmp_lt)
17334 +
17335 +#ifdef L_avr32_f64_cmp_ge
17336 + .global __avr32_f64_cmp_ge
17337 + .type __avr32_f64_cmp_ge,@function
17338 +__avr32_f64_cmp_ge:
17339 +#endif
17340 +#ifdef L_avr32_f64_cmp_lt
17341 + .global __avr32_f64_cmp_lt
17342 + .type __avr32_f64_cmp_lt,@function
17343 +__avr32_f64_cmp_lt:
17344 +#endif
17345 +
17346 + /* compare magnitude of op1 and op2 */
17347 + pushm lr
17348 +
17349 + lsl r11,1 /* Remove sign bit of op1 */
17350 + srcs lr /* Sign op1 to lsb of lr*/
17351 + lsl r9,1 /* Remove sign bit of op2 */
17352 + rol lr /* Sign op2 to lsb of lr, sign bit op1 bit 1 of lr*/
17353 +
17354 + /* Check for Nan */
17355 + mov r12, 0
17356 + orh r12, 0xffe0
17357 + cp.w r10,0
17358 + cpc r11,r12
17359 + movhi r12, 0 /* Return false for NaN */
17360 + brhi 0f /* We have NaN */
17361 + cp.w r8,0
17362 + cpc r9,r12
17363 + movhi r12, 0 /* Return false for NaN */
17364 + brhi 0f /* We have NaN */
17365 +
17366 + cp.w lr,3 /* both operands negative ?*/
17367 + breq 1f
17368 +
17369 + cp.w lr,1 /* both operands positive? */
17370 + brlo 2f
17371 +
17372 + /* Different signs. If sign of op1 is negative the difference
17373 + between op1 and op2 will always be negative, and if op1 is
17374 + positive the difference will always be positive */
17375 +#ifdef L_avr32_f64_cmp_ge
17376 + sreq r12
17377 +#endif
17378 +#ifdef L_avr32_f64_cmp_lt
17379 + srne r12
17380 +#endif
17381 + popm pc
17382 +
17383 +
17384 +2:
17385 + /* Both operands positive. Just compute the difference */
17386 + cp.w r10,r8
17387 + cpc r11,r9
17388 +#ifdef L_avr32_f64_cmp_ge
17389 + srhs r12
17390 +#endif
17391 +#ifdef L_avr32_f64_cmp_lt
17392 + srlo r12
17393 +#endif
17394 + popm pc
17395 +
17396 +1:
17397 + /* Both operands negative. Compute the difference with operands switched */
17398 + cp r8,r10
17399 + cpc r9,r11
17400 +#ifdef L_avr32_f64_cmp_ge
17401 + srhs r12
17402 +#endif
17403 +#ifdef L_avr32_f64_cmp_lt
17404 + srlo r12
17405 +#endif
17406 +0:
17407 + popm pc
17408 +#endif
17409 +
17410 +
17411 +
17412 +#ifdef L_avr32_f64_div
17413 + .align 2
17414 + .global __avr32_f64_div
17415 + .type __avr32_f64_div,@function
17416 +
17417 +__avr32_f64_div:
17418 + stm --sp, r0, r1, r2, r3, r4, r5, r6, r7,lr
17419 + /* op1 in {r11,r10}*/
17420 + /* op2 in {r9,r8}*/
17421 + eor lr, r11, r9 /* MSB(lr) = Sign(op1) ^ Sign(op2) */
17422 +
17423 +
17424 + /* Unpack op1 to 2.62 format*/
17425 + /* exp: r7 */
17426 + /* sf: r11, r10 */
17427 + lsr r7, r11, 20 /* Extract exponent */
17428 +
17429 + lsl r11, 9 /* Extract mantissa, leave room for implicit bit */
17430 + or r11, r11, r10>>23
17431 + lsl r10, 9
17432 + sbr r11, 29 /* Insert implicit bit */
17433 + andh r11, 0x3fff /*Mask last part of exponent since we use 2.62 format*/
17434 +
17435 + cbr r7, 11 /* Clear sign bit */
17436 + /* Check if normalization is needed */
17437 + breq 11f /*If number is subnormal, normalize it */
17438 +22:
17439 + cp r7, 0x7ff
17440 + brhs 2f /* Check op1 for NaN or Inf */
17441 +
17442 + /* Unpack op2 to 2.62 format*/
17443 + /* exp: r6 */
17444 + /* sf: r9, r8 */
17445 + lsr r6, r9, 20 /* Extract exponent */
17446 +
17447 + lsl r9, 9 /* Extract mantissa, leave room for implicit bit */
17448 + or r9, r9, r8>>23
17449 + lsl r8, 9
17450 + sbr r9, 29 /* Insert implicit bit */
17451 + andh r9, 0x3fff /*Mask last part of exponent since we use 2.62 format*/
17452 +
17453 + cbr r6, 11 /* Clear sign bit */
17454 + /* Check if normalization is needed */
17455 + breq 13f /*If number is subnormal, normalize it */
17456 +23:
17457 + cp r6, 0x7ff
17458 + brhs 3f /* Check op2 for NaN or Inf */
17459 +
17460 + /* Calculate new exponent */
17461 + sub r7, r6
17462 + sub r7,-1023
17463 +
17464 + /* Divide */
17465 + /* Approximating 1/d with the following recurrence: */
17466 + /* R[j+1] = R[j]*(2-R[j]*d) */
17467 + /* Using 2.62 format */
17468 + /* TWO: r12 */
17469 + /* d = op2 = divisor (2.62 format): r9,r8 */
17470 + /* Multiply result : r5, r4 */
17471 + /* Initial guess : r3, r2 */
17472 + /* New approximations : r3, r2 */
17473 + /* op1 = Dividend (2.62 format) : r11, r10 */
17474 +
17475 + mov r12, 1 /* Load TWO */
17476 + brev r12
17477 +
17478 + /* Load initial guess, using look-up table */
17479 + /* Initial guess is of format 01.XY, where XY is constructed as follows: */
17480 + /* Let d be of following format: 00.1xy....., then XY=~xy */
17481 + /* For d=00.100 = 0,5 -> initial guess=01.11 = 1,75 */
17482 + /* For d=00.101 = 0,625 -> initial guess=01.11 = 1,5 */
17483 + /* For d=00.110 = 0,75 -> initial guess=01.11 = 1,25 */
17484 + /* For d=00.111 = 0,875 -> initial guess=01.11 = 1,0 */
17485 + /* r2 is also part of the reg pair forming initial guess, but it*/
17486 + /* is kept uninitialized to save one cycle since it has so low significance*/
17487 +
17488 + lsr r3, r12, 1
17489 + bfextu r4, r9, 27, 2
17490 + com r4
17491 + bfins r3, r4, 28, 2
17492 +
17493 + /* First approximation */
17494 + /* Approximating to 32 bits */
17495 + /* r5 = R[j]*d */
17496 + mulu.d r4, r3, r9
17497 + /* r5 = 2-R[j]*d */
17498 + sub r5, r12, r5<<2
17499 + /* r3 = R[j]*(2-R[j]*d) */
17500 + mulu.d r4, r3, r5
17501 + lsl r3, r5, 2
17502 +
17503 + /* Second approximation */
17504 + /* Approximating to 32 bits */
17505 + /* r5 = R[j]*d */
17506 + mulu.d r4, r3, r9
17507 + /* r5 = 2-R[j]*d */
17508 + sub r5, r12, r5<<2
17509 + /* r3 = R[j]*(2-R[j]*d) */
17510 + mulu.d r4, r3, r5
17511 + lsl r3, r5, 2
17512 +
17513 + /* Third approximation */
17514 + /* Approximating to 32 bits */
17515 + /* r5 = R[j]*d */
17516 + mulu.d r4, r3, r9
17517 + /* r5 = 2-R[j]*d */
17518 + sub r5, r12, r5<<2
17519 + /* r3 = R[j]*(2-R[j]*d) */
17520 + mulu.d r4, r3, r5
17521 + lsl r3, r5, 2
17522 +
17523 + /* Fourth approximation */
17524 + /* Approximating to 64 bits */
17525 + /* r5,r4 = R[j]*d */
17526 + mul_approx_df r3 /*ah*/, r2 /*al*/, r9 /*bh*/, r8 /*bl*/, r5 /*rh*/, r4 /*rl*/, r1 /*sh*/, r0 /*sl*/
17527 + lsl r5, 2
17528 + or r5, r5, r4>>30
17529 + lsl r4, 2
17530 + /* r5,r4 = 2-R[j]*d */
17531 + neg r4
17532 + sbc r5, r12, r5
17533 + /* r3,r2 = R[j]*(2-R[j]*d) */
17534 + mul_approx_df r3 /*ah*/, r2 /*al*/, r5 /*bh*/, r4 /*bl*/, r5 /*rh*/, r4 /*rl*/, r1 /*sh*/, r0 /*sl*/
17535 + lsl r3, r5, 2
17536 + or r3, r3, r4>>30
17537 + lsl r2, r4, 2
17538 +
17539 +
17540 + /* Fifth approximation */
17541 + /* Approximating to 64 bits */
17542 + /* r5,r4 = R[j]*d */
17543 + mul_approx_df r3 /*ah*/, r2 /*al*/, r9 /*bh*/, r8 /*bl*/, r5 /*rh*/, r4 /*rl*/, r1 /*sh*/, r0 /*sl*/
17544 + lsl r5, 2
17545 + or r5, r5, r4>>30
17546 + lsl r4, 2
17547 + /* r5,r4 = 2-R[j]*d */
17548 + neg r4
17549 + sbc r5, r12, r5
17550 + /* r3,r2 = R[j]*(2-R[j]*d) */
17551 + mul_approx_df r3 /*ah*/, r2 /*al*/, r5 /*bh*/, r4 /*bl*/, r5 /*rh*/, r4 /*rl*/, r1 /*sh*/, r0 /*sl*/
17552 + lsl r3, r5, 2
17553 + or r3, r3, r4>>30
17554 + lsl r2, r4, 2
17555 +
17556 +
17557 + /* Multiply with dividend to get quotient */
17558 + mul_approx_df r3 /*ah*/, r2 /*al*/, r11 /*bh*/, r10 /*bl*/, r3 /*rh*/, r2 /*rl*/, r1 /*sh*/, r0 /*sl*/
17559 +
17560 + /* Shift by 3 to get result in 1.63 format, as required by the exponent. */
17561 + /* Note that 1.63 format is already used by the exponent in r7, since */
17562 + /* a bias of 1023 was added to the result exponent, even though the implicit */
17563 + /* bit was inserted. This gives the exponent an additional bias of 1, which */
17564 + /* supports 1.63 format. */
17565 + lsl r3, r3, 3
17566 + or r3, r3, r2>>29
17567 + lsl r2, r2, 3
17568 +
17569 + /* To increase speed, this result is not corrected before final rounding.*/
17570 + /* This may give a difference to IEEE compliant code of 1 ULP.*/
17571 +
17572 + /* Adjust exponent and mantissa */
17573 + /* r7:exp, [r3, r2]:mant, [r12,r11,r10]:scratch*/
17574 + /* Mantissa may be of the format 0.xxxx or 1.xxxx. */
17575 + /* In the first case, shift one pos to left.*/
17576 + sub r10, r7, 1
17577 + mov r12, r3
17578 + lsl r11, r2, 1
17579 + rol r12
17580 + bld r3, 31
17581 + movne r7, r10
17582 + movne r3, r12
17583 + movne r2, r11
17584 + cp r7, 0
17585 + breq 15f /*Result was subnormal. Flush-to-zero and return zero*/
17586 +
17587 + /* Result was not subnormal. Perform rounding. */
17588 + /* Note that the tie case (for round-to-even) can not occur in division. */
17589 + /* [r7]:exp, [r3, r2]:mant */
17590 + /* Mantissa is in 0.64 format. Round by adding 1<<(64-(52+2))=1<<10*/
17591 + mov r12, (1<<10)
17592 + add r2, r12
17593 + acr r3
17594 + /* Adjust exponent if we overflowed.*/
17595 + subcs r7, -1
17596 +
17597 +
17598 +
17599 + /* Pack final result*/
17600 + /* Input: [r7]:exp, [r3, r2]:mant */
17601 + /* Result in [r11,r10] */
17602 + /* Insert exponent and sign bit*/
17603 + lsl r11, r7, 20
17604 + bld lr, 31
17605 + bst r11, 31
17606 + /* Insert mantissa */
17607 + cbr r3, 31 /*Clear implicit bit*/
17608 + or r11, r11, r3>>11
17609 + lsr r10, r2, 11
17610 + or r10, r10, r3<<21
17611 + /* Return result in [r11,r10] */
17612 + ldm sp++, r0, r1, r2, r3, r4, r5, r6, r7,pc
17613 +
17614 +
17615 +2:
17616 + /* Op1 is NaN or inf */
17617 + andh r11, 0x000f /* Extract mantissa */
17618 + or r11, r10
17619 + brne 16f /* Return NaN if op1 is NaN */
17620 + /* Op1 is inf check op2 */
17621 + lsr r6, r9, 20 /* Extract exponent */
17622 + cbr r6, 8 /* Clear sign bit */
17623 + cp r6, 0x7ff
17624 + brne 17f /* Inf/number gives inf, return inf */
17625 + rjmp 16f /* The rest gives NaN*/
17626 +
17627 +3:
17628 + /* Op1 is a valid number. Op 2 is NaN or inf */
17629 + andh r9, 0x000f /* Extract mantissa */
17630 + or r9, r8
17631 + brne 16f /* Return NaN if op2 is NaN */
17632 + rjmp 15f /* Op2 was inf, return zero*/
17633 +
17634 +11: /* Op1 was denormal. Fix it. */
17635 + lsl r11, 2
17636 + or r11, r11, r10 >> 30
17637 + lsl r10, 2
17638 + cbr r11, 31
17639 + /* Check if op1 is zero. */
17640 + or r4, r10, r11
17641 + breq __avr32_f64_div_op1_zero
17642 + normalize_df r7 /*exp*/, r10, r11 /*Mantissa*/, r4, r5 /*scratch*/
17643 + lsr r10, 2
17644 + or r10, r10, r11 << 30
17645 + lsr r11, 2
17646 + rjmp 22b
17647 +
17648 +
17649 +13: /* Op2 was denormal. Fix it */
17650 + lsl r9, 2
17651 + or r9, r9, r8 >> 30
17652 + lsl r8, 2
17653 + cbr r9, 31
17654 + /* Check if op2 is zero. */
17655 + or r4, r9, r8
17656 + breq 17f /* Divisor is zero -> return Inf */
17657 + normalize_df r6 /*exp*/, r8, r9 /*Mantissa*/, r4, r5 /*scratch*/
17658 + lsr r8, 2
17659 + or r8, r8, r9 << 30
17660 + lsr r9, 2
17661 + rjmp 23b
17662 +
17663 +
17664 +15: /* Divide result was subnormal. Return zero. */
17665 + mov r11, lr /*Get correct sign*/
17666 + andh r11, 0x8000, COH
17667 + mov r10, 0
17668 + ldm sp++, r0, r1, r2, r3, r4, r5, r6, r7,pc
17669 +
17670 +16: /* Return NaN. */
17671 + mov r11, -1
17672 + mov r10, -1
17673 + ldm sp++, r0, r1, r2, r3, r4, r5, r6, r7,pc
17674 +
17675 +17: /* Return INF. */
17676 + mov r11, lr /*Get correct sign*/
17677 + andh r11, 0x8000, COH
17678 + orh r11, 0x7ff0
17679 + mov r10, 0
17680 + ldm sp++, r0, r1, r2, r3, r4, r5, r6, r7,pc
17681 +
17682 +__avr32_f64_div_op1_zero:
17683 + or r5, r8, r9 << 1
17684 + breq 16b /* 0.0/0.0 -> NaN */
17685 + bfextu r4, r9, 20, 11
17686 + cp r4, 0x7ff
17687 + brne 15b /* Return zero */
17688 + /* Check if divisor is Inf or NaN */
17689 + or r5, r8, r9 << 12
17690 + breq 15b /* Divisor is inf -> return zero */
17691 + rjmp 16b /* Return NaN */
17692 +
17693 +
17694 +
17695 +
17696 +#endif
17697 +
17698 +#if defined(L_avr32_f32_addsub) || defined(L_avr32_f32_addsub_fast)
17699 +
17700 + .align 2
17701 +__avr32_f32_sub_from_add:
17702 + /* Switch sign on op2 */
17703 + eorh r11, 0x8000
17704 +
17705 +#if defined(L_avr32_f32_addsub_fast)
17706 + .global __avr32_f32_sub_fast
17707 + .type __avr32_f32_sub_fast,@function
17708 +__avr32_f32_sub_fast:
17709 +#else
17710 + .global __avr32_f32_sub
17711 + .type __avr32_f32_sub,@function
17712 +__avr32_f32_sub:
17713 +#endif
17714 +
17715 + /* Check signs */
17716 + eor r8, r11, r12
17717 + /* Different signs, use subtraction. */
17718 + brmi __avr32_f32_add_from_sub
17719 +
17720 + /* Get sign of op1 */
17721 + mov r8, r12
17722 + andh r12, 0x8000, COH
17723 +
17724 + /* Remove sign from operands */
17725 + cbr r11, 31
17726 +#if defined(L_avr32_f32_addsub_fast)
17727 + reteq r8 /* If op2 is zero return op1 */
17728 +#endif
17729 + cbr r8, 31
17730 +
17731 + /* Put the number with the largest exponent in r10
17732 + and the number with the smallest exponent in r9 */
17733 + max r10, r8, r11
17734 + min r9, r8, r11
17735 + cp r10, r8 /*If largest operand (in R10) is not equal to op1*/
17736 + subne r12, 1 /* Subtract 1 from sign, which will invert MSB of r12*/
17737 + andh r12, 0x8000, COH /*Mask all but MSB*/
17738 +
17739 + /* Unpack exponent and mantissa of op1 */
17740 + lsl r8, r10, 8
17741 + sbr r8, 31 /* Set implicit bit. */
17742 + lsr r10, 23
17743 +
17744 + /* op1 is NaN or Inf. */
17745 + cp.w r10, 0xff
17746 + breq __avr32_f32_sub_op1_nan_or_inf
17747 +
17748 + /* Unpack exponent and mantissa of op2 */
17749 + lsl r11, r9, 8
17750 + sbr r11, 31 /* Set implicit bit. */
17751 + lsr r9, 23
17752 +
17753 +#if defined(L_avr32_f32_addsub)
17754 + /* Keep sticky bit for correct IEEE rounding */
17755 + st.w --sp, r12
17756 +
17757 + /* op2 is either zero or subnormal. */
17758 + breq __avr32_f32_sub_op2_subnormal
17759 +0:
17760 + /* Get shift amount to scale mantissa of op2. */
17761 + rsub r9, r10
17762 +
17763 + /* Saturate the shift amount to 31. If the amount
17764 + is any larger op2 is insignificant. */
17765 + satu r9 >> 0, 5
17766 +
17767 + /* Shift mantissa of op2 to same decimal point as the mantissa
17768 + of op1. */
17769 + lsr r12, r11, r9
17770 +
17771 + /* Put the remainding bits into r11[23:..].*/
17772 + rsub r9, r9, (32-8)
17773 + lsl r11, r11, r9
17774 +
17775 + /* Now subtract the mantissas. */
17776 + sub r8, r12
17777 +
17778 + ld.w r12, sp++
17779 +
17780 + /* Normalize resulting mantissa. */
17781 + clz r9, r8
17782 + lsl r8, r8, r9
17783 + sub r10, r9
17784 + brle __avr32_f32_sub_subnormal_result
17785 +
17786 + /* Insert the bits we will remove from the mantissa into r11[31:24] */
17787 + bfins r11, r8, 24, 8
17788 +#else
17789 + /* Ignore sticky bit to simplify and speed up rounding */
17790 + /* op2 is either zero or subnormal. */
17791 + breq __avr32_f32_sub_op2_subnormal
17792 +0:
17793 + /* Get shift amount to scale mantissa of op2. */
17794 + rsub r9, r10
17795 +
17796 + /* Saturate the shift amount to 31. If the amount
17797 + is any larger op2 is insignificant. */
17798 + satu r9 >> 0, 5
17799 +
17800 + /* Shift mantissa of op2 to same decimal point as the mantissa
17801 + of op1. */
17802 + lsr r11, r11, r9
17803 +
17804 + /* Now subtract the mantissas. */
17805 + sub r8, r11
17806 +
17807 + /* Normalize resulting mantissa. */
17808 + clz r9, r8
17809 + lsl r8, r8, r9
17810 + sub r10, r9
17811 + brle __avr32_f32_sub_subnormal_result
17812 +#endif
17813 +
17814 + /* Pack result. */
17815 + or r12, r12, r8 >> 8
17816 + bfins r12, r10, 23, 8
17817 +
17818 + /* Round */
17819 +__avr32_f32_sub_round:
17820 +#if defined(L_avr32_f32_addsub)
17821 + mov r10, 0
17822 + sbr r10, 31
17823 + bld r12, 0
17824 + subne r10, -1
17825 + cp.w r11, r10
17826 + subhs r12, -1
17827 +#else
17828 + bld r8, 7
17829 + acr r12
17830 +#endif
17831 +
17832 + ret r12
17833 +
17834 +
17835 +__avr32_f32_sub_op2_subnormal:
17836 + /* Fix implicit bit and adjust exponent of subnormals. */
17837 + cbr r11, 31
17838 + /* Set exponent to 1 if we do not have a zero. */
17839 + movne r9,1
17840 +
17841 + /* Check if op1 is also subnormal. */
17842 + cp.w r10, 0
17843 + brne 0b
17844 +
17845 + cbr r8, 31
17846 + /* If op1 is not zero set exponent to 1. */
17847 + movne r10,1
17848 +
17849 + rjmp 0b
17850 +
17851 +__avr32_f32_sub_op1_nan_or_inf:
17852 + /* Check if op1 is NaN, if so return NaN */
17853 + lsl r11, r8, 1
17854 + retne -1
17855 +
17856 + /* op1 is Inf. */
17857 + bfins r12, r10, 23, 8 /* Generate Inf in r12 */
17858 +
17859 + /* Check if op2 is Inf. or NaN */
17860 + lsr r11, r9, 23
17861 + cp.w r11, 0xff
17862 + retne r12 /* op2 not Inf or NaN, return op1 */
17863 +
17864 + ret -1 /* op2 Inf or NaN, return NaN */
17865 +
17866 +__avr32_f32_sub_subnormal_result:
17867 + /* Check if the number is so small that
17868 + it will be represented with zero. */
17869 + rsub r10, r10, 9
17870 + rsub r9, r10, 32
17871 + retcs 0
17872 +
17873 + /* Shift the mantissa into the correct position.*/
17874 + lsr r10, r8, r10
17875 + /* Add sign bit. */
17876 + or r10, r12
17877 +
17878 + /* Put the shifted out bits in the most significant part
17879 + of r8. */
17880 + lsl r8, r8, r9
17881 +
17882 +#if defined(L_avr32_f32_addsub)
17883 + /* Add all the remainder bits used for rounding into r11 */
17884 + andh r11, 0x00FF
17885 + or r11, r8
17886 +#else
17887 + lsr r8, 24
17888 +#endif
17889 + rjmp __avr32_f32_sub_round
17890 +
17891 +
17892 + .align 2
17893 +
17894 +__avr32_f32_add_from_sub:
17895 + /* Switch sign on op2 */
17896 + eorh r11, 0x8000
17897 +
17898 +#if defined(L_avr32_f32_addsub_fast)
17899 + .global __avr32_f32_add_fast
17900 + .type __avr32_f32_add_fast,@function
17901 +__avr32_f32_add_fast:
17902 +#else
17903 + .global __avr32_f32_add
17904 + .type __avr32_f32_add,@function
17905 +__avr32_f32_add:
17906 +#endif
17907 +
17908 + /* Check signs */
17909 + eor r8, r11, r12
17910 + /* Different signs, use subtraction. */
17911 + brmi __avr32_f32_sub_from_add
17912 +
17913 + /* Get sign of op1 */
17914 + mov r8, r12
17915 + andh r12, 0x8000, COH
17916 +
17917 + /* Remove sign from operands */
17918 + cbr r11, 31
17919 +#if defined(L_avr32_f32_addsub_fast)
17920 + reteq r8 /* If op2 is zero return op1 */
17921 +#endif
17922 + cbr r8, 31
17923 +
17924 + /* Put the number with the largest exponent in r10
17925 + and the number with the smallest exponent in r9 */
17926 + max r10, r8, r11
17927 + min r9, r8, r11
17928 +
17929 + /* Unpack exponent and mantissa of op1 */
17930 + lsl r8, r10, 8
17931 + sbr r8, 31 /* Set implicit bit. */
17932 + lsr r10, 23
17933 +
17934 + /* op1 is NaN or Inf. */
17935 + cp.w r10, 0xff
17936 + breq __avr32_f32_add_op1_nan_or_inf
17937 +
17938 + /* Unpack exponent and mantissa of op2 */
17939 + lsl r11, r9, 8
17940 + sbr r11, 31 /* Set implicit bit. */
17941 + lsr r9, 23
17942 +
17943 +#if defined(L_avr32_f32_addsub)
17944 + /* Keep sticky bit for correct IEEE rounding */
17945 + st.w --sp, r12
17946 +
17947 + /* op2 is either zero or subnormal. */
17948 + breq __avr32_f32_add_op2_subnormal
17949 +0:
17950 + /* Get shift amount to scale mantissa of op2. */
17951 + rsub r9, r10
17952 +
17953 + /* Saturate the shift amount to 31. If the amount
17954 + is any larger op2 is insignificant. */
17955 + satu r9 >> 0, 5
17956 +
17957 + /* Shift mantissa of op2 to same decimal point as the mantissa
17958 + of op1. */
17959 + lsr r12, r11, r9
17960 +
17961 + /* Put the remainding bits into r11[23:..].*/
17962 + rsub r9, r9, (32-8)
17963 + lsl r11, r11, r9
17964 + /* Insert the bits we will remove from the mantissa into r11[31:24] */
17965 + bfins r11, r12, 24, 8
17966 +
17967 + /* Now add the mantissas. */
17968 + add r8, r12
17969 +
17970 + ld.w r12, sp++
17971 +#else
17972 + /* Ignore sticky bit to simplify and speed up rounding */
17973 + /* op2 is either zero or subnormal. */
17974 + breq __avr32_f32_add_op2_subnormal
17975 +0:
17976 + /* Get shift amount to scale mantissa of op2. */
17977 + rsub r9, r10
17978 +
17979 + /* Saturate the shift amount to 31. If the amount
17980 + is any larger op2 is insignificant. */
17981 + satu r9 >> 0, 5
17982 +
17983 + /* Shift mantissa of op2 to same decimal point as the mantissa
17984 + of op1. */
17985 + lsr r11, r11, r9
17986 +
17987 + /* Now add the mantissas. */
17988 + add r8, r11
17989 +
17990 +#endif
17991 + /* Check if we overflowed. */
17992 + brcs __avr32_f32_add_res_of
17993 +1:
17994 + /* Pack result. */
17995 + or r12, r12, r8 >> 8
17996 + bfins r12, r10, 23, 8
17997 +
17998 + /* Round */
17999 +#if defined(L_avr32_f32_addsub)
18000 + mov r10, 0
18001 + sbr r10, 31
18002 + bld r12, 0
18003 + subne r10, -1
18004 + cp.w r11, r10
18005 + subhs r12, -1
18006 +#else
18007 + bld r8, 7
18008 + acr r12
18009 +#endif
18010 +
18011 + ret r12
18012 +
18013 +__avr32_f32_add_op2_subnormal:
18014 + /* Fix implicit bit and adjust exponent of subnormals. */
18015 + cbr r11, 31
18016 + /* Set exponent to 1 if we do not have a zero. */
18017 + movne r9,1
18018 +
18019 + /* Check if op1 is also subnormal. */
18020 + cp.w r10, 0
18021 + brne 0b
18022 +
18023 + cbr r8, 31
18024 + /* If op1 is not zero set exponent to 1. */
18025 + movne r10,1
18026 +
18027 + rjmp 0b
18028 +
18029 +__avr32_f32_add_op1_nan_or_inf:
18030 + /* Check if op1 is NaN, if so return NaN */
18031 + lsl r11, r8, 1
18032 + retne -1
18033 +
18034 + /* op1 is Inf. */
18035 + bfins r12, r10, 23, 8 /* Generate Inf in r12 */
18036 +
18037 + /* Check if op2 is Inf. or NaN */
18038 + lsr r11, r9, 23
18039 + cp.w r11, 0xff
18040 + retne r12 /* op2 not Inf or NaN, return op1 */
18041 +
18042 + lsl r9, 9
18043 + reteq r12 /* op2 Inf return op1 */
18044 + ret -1 /* op2 is NaN, return NaN */
18045 +
18046 +__avr32_f32_add_res_of:
18047 + /* We overflowed. Increase exponent and shift mantissa.*/
18048 + lsr r8, 1
18049 + sub r10, -1
18050 +
18051 + /* Clear mantissa to set result to Inf if the exponent is 255. */
18052 + cp.w r10, 255
18053 + moveq r8, 0
18054 + moveq r11, 0
18055 + rjmp 1b
18056 +
18057 +
18058 +#endif
18059 +
18060 +
18061 +#if defined(L_avr32_f32_div) || defined(L_avr32_f32_div_fast)
18062 + .align 2
18063 +
18064 +#if defined(L_avr32_f32_div_fast)
18065 + .global __avr32_f32_div_fast
18066 + .type __avr32_f32_div_fast,@function
18067 +__avr32_f32_div_fast:
18068 +#else
18069 + .global __avr32_f32_div
18070 + .type __avr32_f32_div,@function
18071 +__avr32_f32_div:
18072 +#endif
18073 +
18074 + eor r8, r11, r12 /* MSB(r8) = Sign(op1) ^ Sign(op2) */
18075 +
18076 + /* Unpack */
18077 + lsl r12,1
18078 + reteq 0 /* Return zero if op1 is zero */
18079 + lsl r11,1
18080 + breq 4f /* Check op2 for zero */
18081 +
18082 + /* Unpack op1*/
18083 + /* exp: r9 */
18084 + /* sf: r12 */
18085 + lsr r9, r12, 24
18086 + breq 11f /*If number is subnormal*/
18087 + cp r9, 0xff
18088 + brhs 2f /* Check op1 for NaN or Inf */
18089 + lsl r12, 7
18090 + sbr r12, 31 /*Implicit bit*/
18091 +12:
18092 +
18093 + /* Unpack op2*/
18094 + /* exp: r10 */
18095 + /* sf: r11 */
18096 + lsr r10, r11, 24
18097 + breq 13f /*If number is subnormal*/
18098 + cp r10, 0xff
18099 + brhs 3f /* Check op2 for NaN or Inf */
18100 +
18101 + lsl r11,7
18102 + sbr r11, 31 /*Implicit bit*/
18103 +14:
18104 +
18105 + /* For UC3, store with predecrement is faster than stm */
18106 + st.w --sp, r5
18107 + st.d --sp, r6
18108 +
18109 + /* Calculate new exponent */
18110 + sub r9, r10
18111 + sub r9,-127
18112 +
18113 + /* Divide */
18114 + /* Approximating 1/d with the following recurrence: */
18115 + /* R[j+1] = R[j]*(2-R[j]*d) */
18116 + /* Using 2.30 format */
18117 + /* TWO: r10 */
18118 + /* d: r5 */
18119 + /* Multiply result : r6, r7 */
18120 + /* Initial guess : r11 */
18121 + /* New approximations : r11 */
18122 + /* Dividend : r12 */
18123 +
18124 + mov r10, 1 /* Load TWO */
18125 + brev r10
18126 +
18127 + lsr r12, 2 /* Get significand of Op1 in 2.30 format */
18128 + lsr r5, r11, 2 /* Get significand of Op2 (=d) in 2.30 format */
18129 +
18130 + /* Load initial guess, using look-up table */
18131 + /* Initial guess is of format 01.XY, where XY is constructed as follows: */
18132 + /* Let d be of following format: 00.1xy....., then XY=~xy */
18133 + /* For d=00.100 = 0,5 -> initial guess=01.11 = 1,75 */
18134 + /* For d=00.101 = 0,625 -> initial guess=01.11 = 1,5 */
18135 + /* For d=00.110 = 0,75 -> initial guess=01.11 = 1,25 */
18136 + /* For d=00.111 = 0,875 -> initial guess=01.11 = 1,0 */
18137 +
18138 + lsr r11, r10, 1
18139 + bfextu r6, r5, 27, 2
18140 + com r6
18141 + bfins r11, r6, 28, 2
18142 +
18143 + /* First approximation */
18144 + /* r7 = R[j]*d */
18145 + mulu.d r6, r11, r5
18146 + /* r7 = 2-R[j]*d */
18147 + sub r7, r10, r7<<2
18148 + /* r11 = R[j]*(2-R[j]*d) */
18149 + mulu.d r6, r11, r7
18150 + lsl r11, r7, 2
18151 +
18152 + /* Second approximation */
18153 + /* r7 = R[j]*d */
18154 + mulu.d r6, r11, r5
18155 + /* r7 = 2-R[j]*d */
18156 + sub r7, r10, r7<<2
18157 + /* r11 = R[j]*(2-R[j]*d) */
18158 + mulu.d r6, r11, r7
18159 + lsl r11, r7, 2
18160 +
18161 + /* Third approximation */
18162 + /* r7 = R[j]*d */
18163 + mulu.d r6, r11, r5
18164 + /* r7 = 2-R[j]*d */
18165 + sub r7, r10, r7<<2
18166 + /* r11 = R[j]*(2-R[j]*d) */
18167 + mulu.d r6, r11, r7
18168 + lsl r11, r7, 2
18169 +
18170 + /* Fourth approximation */
18171 + /* r7 = R[j]*d */
18172 + mulu.d r6, r11, r5
18173 + /* r7 = 2-R[j]*d */
18174 + sub r7, r10, r7<<2
18175 + /* r11 = R[j]*(2-R[j]*d) */
18176 + mulu.d r6, r11, r7
18177 + lsl r11, r7, 2
18178 +
18179 +
18180 + /* Multiply with dividend to get quotient, r7 = sf(op1)/sf(op2) */
18181 + mulu.d r6, r11, r12
18182 +
18183 + /* Shift by 3 to get result in 1.31 format, as required by the exponent. */
18184 + /* Note that 1.31 format is already used by the exponent in r9, since */
18185 + /* a bias of 127 was added to the result exponent, even though the implicit */
18186 + /* bit was inserted. This gives the exponent an additional bias of 1, which */
18187 + /* supports 1.31 format. */
18188 + lsl r10, r7, 3
18189 +
18190 +#if defined(L_avr32_f32_div)
18191 + /* To perform correct rounding, check for nonzero remainder, */
18192 + /* and set LSB in quot if remainder != 0 */
18193 + /* Remainder = dividend(r12) - divisor(r5)*quotient(r10) */
18194 +
18195 + lsl r5, 1 /* Transform divisor from 2.30 to 1.31 format */
18196 + /* Mask all bits lower than guard in quotient. */
18197 + /* These bits are inexact due to approximative algorithm */
18198 + andl r10, 0xffc0
18199 + /* Add 1 in least significant bit pos to make sure approximation is from above */
18200 + sub r10, -64
18201 + mulu.d r6, r5, r10
18202 + /* If remainder < 0, truncated quotient is too large, so the */
18203 + /* delta added must be subtracted to get the correct truncated quotient. */
18204 + sub r12, r7 /* Calculate remainder and implicitly set flags */
18205 + sublt r10, 64
18206 +#endif
18207 +
18208 + /* For UC3, load with postincrement is faster than ldm */
18209 + ld.d r6, sp++
18210 + ld.w r5, sp++
18211 +
18212 + /* Adjust exponent and mantissa */
18213 + /* r9:exp, r10:mant, r11:scratch*/
18214 + clz r11, r10
18215 + sub r9, r11
18216 + breq 16f /*Result was subnormal*/
18217 + lsl r10, r10, r11
18218 +
18219 + /* Result was not subnormal. Perform rounding. */
18220 + /* Note that the tie case (for round-to-even) can not occur in division. */
18221 + /* r9:exp, r10:mant*/
18222 + sub r10, -1*(0x80)
18223 + /* Adjust exponent if we overflowed. Note that we must use {cc}
18224 + since we perform the add using a sub insn. */
18225 + subcc r9, -1
18226 +
18227 + /* Pack final result*/
18228 + lsr r12, r10, 7
18229 + bfins r12, r9, 24, 8
18230 +__divsf_return_op1:
18231 + lsl r8, 1
18232 + ror r12
18233 + ret r12
18234 +
18235 +
18236 +2:
18237 + /* Op1 is NaN or inf */
18238 + retne -1 /* Return NaN if op1 is NaN */
18239 + /* Op1 is inf check op2 */
18240 + mov r9, 0xff
18241 + brev r9
18242 + cp r11, r9
18243 + brlo __divsf_return_op1 /* inf/number gives inf */
18244 + ret -1 /* The rest gives NaN*/
18245 +3:
18246 + /* Op1 is NaN or inf */
18247 + reteq 0 /* Return zero if number/inf*/
18248 + ret -1 /* Return NaN*/
18249 +4:
18250 + /* Op2 is zero ? */
18251 + tst r12,r12
18252 + reteq -1 /* 0.0/0.0 is NaN */
18253 + /* Nonzero/0.0 is Inf. Sign bit will be shifted in before returning*/
18254 + mov r12, 0x7ff
18255 + brev r12
18256 + rjmp __divsf_return_op1
18257 +
18258 +11: /* Op1 was denormal. Fix it. */
18259 + lsl r12,7
18260 + clz r9,r12
18261 + lsl r12,r12,r9
18262 + rsub r9,r9,1
18263 + rjmp 12b
18264 +
18265 +13: /* Op2 was denormal. Fix it. */
18266 + lsl r11,7
18267 + clz r10,r11
18268 + lsl r11,r11,r10
18269 + rsub r10,r10,1
18270 + rjmp 14b
18271 +
18272 +
18273 +16: /* Divide result was subnormal. Fix it and return. */
18274 +#if defined(L_avr32_f32_div)
18275 + lsl r10, r10, r11 /*Perform shift required by adjustment of exponent and mantissa*/
18276 + adjust_subnormal_sf r12 /*sf*/, r9 /*exp*/, r10 /*mant*/, r8 /*sign*/,r11 /*scratch*/
18277 +#else
18278 + /*Flush to zero*/
18279 + mov r12, 0
18280 +#endif
18281 + ret r12
18282 +
18283 +#endif
18284 +
18285 +#ifdef L_avr32_f32_mul
18286 + .global __avr32_f32_mul
18287 + .type __avr32_f32_mul,@function
18288 +
18289 +
18290 +__avr32_f32_mul:
18291 + mov r8, r12
18292 + eor r12, r11 /* MSB(r8) = Sign(op1) ^ Sign(op2) */
18293 + andh r12, 0x8000, COH
18294 +
18295 + /* arrange operands so that that op1 >= op2 */
18296 + cbr r8, 31
18297 + breq __avr32_f32_mul_op1_zero
18298 + cbr r11, 31
18299 +
18300 + /* Put the number with the largest exponent in r10
18301 + and the number with the smallest exponent in r9 */
18302 + max r10, r8, r11
18303 + min r9, r8, r11
18304 +
18305 + /* Unpack exponent and mantissa of op1 */
18306 + lsl r8, r10, 8
18307 + sbr r8, 31 /* Set implicit bit. */
18308 + lsr r10, 23
18309 +
18310 + /* op1 is NaN or Inf. */
18311 + cp.w r10, 0xff
18312 + breq __avr32_f32_mul_op1_nan_or_inf
18313 +
18314 + /* Unpack exponent and mantissa of op2 */
18315 + lsl r11, r9, 8
18316 + sbr r11, 31 /* Set implicit bit. */
18317 + lsr r9, 23
18318 +
18319 + /* op2 is either zero or subnormal. */
18320 + breq __avr32_f32_mul_op2_subnormal
18321 +0:
18322 + /* Calculate new exponent */
18323 + add r9,r10
18324 +
18325 + /* Do the multiplication */
18326 + mulu.d r10,r8,r11
18327 +
18328 + /* We might need to scale up by two if the MSB of the result is
18329 + zero. */
18330 + lsl r8, r11, 1
18331 + movcc r11, r8
18332 + subcc r9, 1
18333 +
18334 + /* Put the shifted out bits of the mantissa into r10 */
18335 + lsr r10, 8
18336 + bfins r10, r11, 24, 8
18337 +
18338 + sub r9,(127-1) /* remove extra exponent bias */
18339 + brle __avr32_f32_mul_res_subnormal
18340 +
18341 + /* Check for Inf. */
18342 + cp.w r9, 0xff
18343 + brge 1f
18344 +
18345 + /* Pack result. */
18346 + or r12, r12, r11 >> 8
18347 + bfins r12, r9, 23, 8
18348 +
18349 + /* Round */
18350 +__avr32_f32_mul_round:
18351 + mov r8, 0
18352 + sbr r8, 31
18353 + bld r12, 0
18354 + subne r8, -1
18355 +
18356 + cp.w r10, r8
18357 + subhs r12, -1
18358 +
18359 + ret r12
18360 +
18361 +1:
18362 + /* Return Inf */
18363 + orh r12, 0x7f80
18364 + ret r12
18365 +
18366 +__avr32_f32_mul_op2_subnormal:
18367 + cbr r11, 31
18368 + clz r9, r11
18369 + retcs 0 /* op2 is zero. Return 0 */
18370 + lsl r11, r11, r9
18371 + rsub r9, r9, 1
18372 +
18373 + /* Check if op2 is subnormal. */
18374 + tst r10, r10
18375 + brne 0b
18376 +
18377 + /* op2 is subnormal */
18378 + cbr r8, 31
18379 + clz r10, r11
18380 + retcs 0 /* op1 is zero. Return 0 */
18381 + lsl r8, r8, r10
18382 + rsub r10, r10, 1
18383 +
18384 + rjmp 0b
18385 +
18386 +
18387 +__avr32_f32_mul_op1_nan_or_inf:
18388 + /* Check if op1 is NaN, if so return NaN */
18389 + lsl r11, r8, 1
18390 + retne -1
18391 +
18392 + /* op1 is Inf. */
18393 + tst r9, r9
18394 + reteq -1 /* Inf * 0 -> NaN */
18395 +
18396 + bfins r12, r10, 23, 8 /* Generate Inf in r12 */
18397 +
18398 + /* Check if op2 is Inf. or NaN */
18399 + lsr r11, r9, 23
18400 + cp.w r11, 0xff
18401 + retne r12 /* op2 not Inf or NaN, return Info */
18402 +
18403 + lsl r9, 9
18404 + reteq r12 /* op2 Inf return Inf */
18405 + ret -1 /* op2 is NaN, return NaN */
18406 +
18407 +__avr32_f32_mul_res_subnormal:
18408 + /* Check if the number is so small that
18409 + it will be represented with zero. */
18410 + rsub r9, r9, 9
18411 + rsub r8, r9, 32
18412 + retcs 0
18413 +
18414 + /* Shift the mantissa into the correct position.*/
18415 + lsr r9, r11, r9
18416 + /* Add sign bit. */
18417 + or r12, r9
18418 + /* Put the shifted out bits in the most significant part
18419 + of r8. */
18420 + lsl r11, r11, r8
18421 +
18422 + /* Add all the remainder bits used for rounding into r11 */
18423 + andh r10, 0x00FF
18424 + or r10, r11
18425 + rjmp __avr32_f32_mul_round
18426 +
18427 +__avr32_f32_mul_op1_zero:
18428 + bfextu r10, r11, 23, 8
18429 + cp.w r10, 0xff
18430 + retne r12
18431 + reteq -1
18432 +
18433 +#endif
18434 +
18435 +
18436 +#ifdef L_avr32_s32_to_f32
18437 + .global __avr32_s32_to_f32
18438 + .type __avr32_s32_to_f32,@function
18439 +__avr32_s32_to_f32:
18440 + cp r12, 0
18441 + reteq r12 /* If zero then return zero float */
18442 + mov r11, r12 /* Keep the sign */
18443 + abs r12 /* Compute the absolute value */
18444 + mov r10, 31 + 127 /* Set the correct exponent */
18445 +
18446 + /* Normalize */
18447 + normalize_sf r10 /*exp*/, r12 /*mant*/, r9 /*scratch*/
18448 +
18449 + /* Check for subnormal result */
18450 + cp.w r10, 0
18451 + brle __avr32_s32_to_f32_subnormal
18452 +
18453 + round_sf r10 /*exp*/, r12 /*mant*/, r9 /*scratch*/
18454 + pack_sf r12 /*sf*/, r10 /*exp*/, r12 /*mant*/
18455 + lsl r11, 1
18456 + ror r12
18457 + ret r12
18458 +
18459 +__avr32_s32_to_f32_subnormal:
18460 + /* Adjust a subnormal result */
18461 + adjust_subnormal_sf r12/*sf*/, r10 /*exp*/, r12 /*mant*/, r11/*sign*/, r9 /*scratch*/
18462 + ret r12
18463 +
18464 +#endif
18465 +
18466 +#ifdef L_avr32_u32_to_f32
18467 + .global __avr32_u32_to_f32
18468 + .type __avr32_u32_to_f32,@function
18469 +__avr32_u32_to_f32:
18470 + cp r12, 0
18471 + reteq r12 /* If zero then return zero float */
18472 + mov r10, 31 + 127 /* Set the correct exponent */
18473 +
18474 + /* Normalize */
18475 + normalize_sf r10 /*exp*/, r12 /*mant*/, r9 /*scratch*/
18476 +
18477 + /* Check for subnormal result */
18478 + cp.w r10, 0
18479 + brle __avr32_u32_to_f32_subnormal
18480 +
18481 + round_sf r10 /*exp*/, r12 /*mant*/, r9 /*scratch*/
18482 + pack_sf r12 /*sf*/, r10 /*exp*/, r12 /*mant*/
18483 + lsr r12,1 /* Sign bit is 0 for unsigned int */
18484 + ret r12
18485 +
18486 +__avr32_u32_to_f32_subnormal:
18487 + /* Adjust a subnormal result */
18488 + mov r8, 0
18489 + adjust_subnormal_sf r12/*sf*/,r10 /*exp*/, r12 /*mant*/,r8/*sign*/, r9 /*scratch*/
18490 + ret r12
18491 +
18492 +
18493 +#endif
18494 +
18495 +
18496 +#ifdef L_avr32_f32_to_s32
18497 + .global __avr32_f32_to_s32
18498 + .type __avr32_f32_to_s32,@function
18499 +__avr32_f32_to_s32:
18500 + bfextu r11, r12, 23, 8
18501 + sub r11,127 /* Fix bias */
18502 + retlo 0 /* Negative exponent yields zero integer */
18503 +
18504 + /* Shift mantissa into correct position */
18505 + rsub r11,r11,31 /* Shift amount */
18506 + lsl r10,r12,8 /* Get mantissa */
18507 + sbr r10,31 /* Add implicit bit */
18508 + lsr r10,r10,r11 /* Perform shift */
18509 + lsl r12,1 /* Check sign */
18510 + retcc r10 /* if positive, we are done */
18511 + neg r10 /* if negative float, negate result */
18512 + ret r10
18513 +
18514 +#endif
18515 +
18516 +#ifdef L_avr32_f32_to_u32
18517 + .global __avr32_f32_to_u32
18518 + .type __avr32_f32_to_u32,@function
18519 +__avr32_f32_to_u32:
18520 + cp r12,0
18521 + retmi 0 /* Negative numbers gives 0 */
18522 + bfextu r11, r12, 23, 8 /* Extract exponent */
18523 + sub r11,127 /* Fix bias */
18524 + retlo 0 /* Negative exponent yields zero integer */
18525 +
18526 + /* Shift mantissa into correct position */
18527 + rsub r11,r11,31 /* Shift amount */
18528 + lsl r12,8 /* Get mantissa */
18529 + sbr r12,31 /* Add implicit bit */
18530 + lsr r12,r12,r11 /* Perform shift */
18531 + ret r12
18532 +
18533 +#endif
18534 +
18535 +#ifdef L_avr32_f32_to_f64
18536 + .global __avr32_f32_to_f64
18537 + .type __avr32_f32_to_f64,@function
18538 +
18539 +__avr32_f32_to_f64:
18540 + lsl r11,r12,1 /* Remove sign bit, keep original value in r12*/
18541 + moveq r10, 0
18542 + reteq r11 /* Return zero if input is zero */
18543 +
18544 + bfextu r9,r11,24,8 /* Get exponent */
18545 + cp.w r9,0xff /* check for NaN or inf */
18546 + breq 0f
18547 +
18548 + lsl r11,7 /* Convert sf mantissa to df format */
18549 + mov r10,0
18550 +
18551 + /* Check if implicit bit should be set */
18552 + cp.w r9, 0
18553 + subeq r9,-1 /* Adjust exponent if it was 0 */
18554 + srne r8
18555 + or r11, r11, r8 << 31 /* Set implicit bit if needed */
18556 + sub r9,(127-0x3ff) /* Convert exponent to df format exponent */
18557 +
18558 + /*We know that low register of mantissa is 0, and will be unaffected by normalization.*/
18559 + /*We can therefore use the faster normalize_sf function instead of normalize_df.*/
18560 + normalize_sf r9 /*exp*/, r11 /*mantissa*/, r8 /*scratch*/
18561 + pack_df r9 /*exp*/, r10, r11 /*mantissa*/, r10, r11 /*df*/
18562 +
18563 +__extendsfdf_return_op1:
18564 + /* Rotate in sign bit */
18565 + lsl r12, 1
18566 + ror r11
18567 + ret r11
18568 +
18569 +0:
18570 + /* Inf or NaN*/
18571 + mov r10, 0
18572 + orh r10, 0xffe0
18573 + lsl r11,8 /* check mantissa */
18574 + movne r11, -1 /* Return NaN */
18575 + moveq r11, r10 /* Return inf */
18576 + rjmp __extendsfdf_return_op1
18577 +#endif
18578 +
18579 +
18580 +#ifdef L_avr32_f64_to_f32
18581 + .global __avr32_f64_to_f32
18582 + .type __avr32_f64_to_f32,@function
18583 +
18584 +__avr32_f64_to_f32:
18585 + /* Unpack */
18586 + lsl r9,r11,1 /* Unpack exponent */
18587 + lsr r9,21
18588 +
18589 + reteq 0 /* If exponent is 0 the number is so small
18590 + that the conversion to single float gives
18591 + zero */
18592 +
18593 + lsl r8,r11,10 /* Adjust mantissa */
18594 + or r12,r8,r10>>22
18595 +
18596 + lsl r10,10 /* Check if there are any remaining bits
18597 + in the low part of the mantissa.*/
18598 + neg r10
18599 + rol r12 /* If there were remaining bits then set lsb
18600 + of mantissa to 1 */
18601 +
18602 + cp r9,0x7ff
18603 + breq 2f /* Check for NaN or inf */
18604 +
18605 + sub r9,(0x3ff-127) /* Adjust bias of exponent */
18606 + sbr r12,31 /* set the implicit bit.*/
18607 +
18608 + cp.w r9, 0 /* Check for subnormal number */
18609 + brle 3f
18610 +
18611 + round_sf r9 /*exp*/, r12 /*mant*/, r10 /*scratch*/
18612 + pack_sf r12 /*sf*/, r9 /*exp*/, r12 /*mant*/
18613 +__truncdfsf_return_op1:
18614 + /* Rotate in sign bit */
18615 + lsl r11, 1
18616 + ror r12
18617 + ret r12
18618 +
18619 +2:
18620 + /* NaN or inf */
18621 + cbr r12,31 /* clear implicit bit */
18622 + retne -1 /* Return NaN if mantissa not zero */
18623 + mov r12, 0
18624 + orh r12, 0xff00
18625 + ret r12 /* Return inf */
18626 +
18627 +3: /* Result is subnormal. Adjust it.*/
18628 + adjust_subnormal_sf r12/*sf*/,r9 /*exp*/, r12 /*mant*/, r11/*sign*/, r10 /*scratch*/
18629 + ret r12
18630 +
18631 +
18632 +#endif
18633 +
18634 \ No newline at end of file
18635 Index: gcc-4.2.3/gcc/config/avr32/lib2funcs.S
18636 ===================================================================
18637 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
18638 +++ gcc-4.2.3/gcc/config/avr32/lib2funcs.S 2008-05-21 13:45:54.173288052 +0200
18639 @@ -0,0 +1,21 @@
18640 + .align 4
18641 + .global __nonlocal_goto
18642 + .type __nonlocal_goto,@function
18643 +
18644 +/* __nonlocal_goto: This function handles nonlocal_goto's in gcc.
18645 +
18646 + parameter 0 (r12) = New Frame Pointer
18647 + parameter 1 (r11) = Address to goto
18648 + parameter 2 (r10) = New Stack Pointer
18649 +
18650 + This function invalidates the return stack, since it returns from a
18651 + function without using a return instruction.
18652 +*/
18653 +__nonlocal_goto:
18654 + mov r7, r12
18655 + mov sp, r10
18656 + frs # Flush return stack
18657 + mov pc, r11
18658 +
18659 +
18660 +
18661 Index: gcc-4.2.3/gcc/config/avr32/linux-elf.h
18662 ===================================================================
18663 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
18664 +++ gcc-4.2.3/gcc/config/avr32/linux-elf.h 2008-05-21 13:45:54.173288052 +0200
18665 @@ -0,0 +1,156 @@
18666 +/*
18667 + Linux/Elf specific definitions.
18668 + Copyright 2003-2006 Atmel Corporation.
18669 +
18670 + Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
18671 + and H�vard Skinnemoen, Atmel Norway, <hskinnemoen@atmel.com>
18672 +
18673 + This file is part of GCC.
18674 +
18675 + This program is free software; you can redistribute it and/or modify
18676 + it under the terms of the GNU General Public License as published by
18677 + the Free Software Foundation; either version 2 of the License, or
18678 + (at your option) any later version.
18679 +
18680 + This program is distributed in the hope that it will be useful,
18681 + but WITHOUT ANY WARRANTY; without even the implied warranty of
18682 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18683 + GNU General Public License for more details.
18684 +
18685 + You should have received a copy of the GNU General Public License
18686 + along with this program; if not, write to the Free Software
18687 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18688 +
18689 +
18690 +
18691 +/* elfos.h should have already been included. Now just override
18692 + any conflicting definitions and add any extras. */
18693 +
18694 +/* Run-time Target Specification. */
18695 +#undef TARGET_VERSION
18696 +#define TARGET_VERSION fputs (" (AVR32 GNU/Linux with ELF)", stderr);
18697 +
18698 +/* Do not assume anything about header files. */
18699 +#define NO_IMPLICIT_EXTERN_C
18700 +
18701 +/* The GNU C++ standard library requires that these macros be defined. */
18702 +#undef CPLUSPLUS_CPP_SPEC
18703 +#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
18704 +
18705 +/* Now we define the strings used to build the spec file. */
18706 +#undef LIB_SPEC
18707 +#define LIB_SPEC \
18708 + "%{pthread:-lpthread} \
18709 + %{shared:-lc} \
18710 + %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
18711 +
18712 +/* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
18713 + the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
18714 + provides part of the support for getting C++ file-scope static
18715 + object constructed before entering `main'. */
18716 +
18717 +#undef STARTFILE_SPEC
18718 +#define STARTFILE_SPEC \
18719 + "%{!shared: \
18720 + %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
18721 + %{!p:%{profile:gcrt1.o%s} \
18722 + %{!profile:crt1.o%s}}}} \
18723 + crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
18724 +
18725 +/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
18726 + the GNU/Linux magical crtend.o file (see crtstuff.c) which
18727 + provides part of the support for getting C++ file-scope static
18728 + object constructed before entering `main', followed by a normal
18729 + GNU/Linux "finalizer" file, `crtn.o'. */
18730 +
18731 +#undef ENDFILE_SPEC
18732 +#define ENDFILE_SPEC \
18733 + "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
18734 +
18735 +#undef ASM_SPEC
18736 +#define ASM_SPEC "%{!mno-pic:--pic} %{mrelax|O*:%{mno-relax|O0|O1: ;:--linkrelax}} %{mcpu=*:-mcpu=%*}"
18737 +
18738 +#undef LINK_SPEC
18739 +#define LINK_SPEC "%{version:-v} \
18740 + %{static:-Bstatic} \
18741 + %{shared:-shared} \
18742 + %{symbolic:-Bsymbolic} \
18743 + %{rdynamic:-export-dynamic} \
18744 + %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0} \
18745 + %{mrelax|O*:%{mno-relax|O0|O1: ;:--relax}}"
18746 +
18747 +#define TARGET_OS_CPP_BUILTINS() LINUX_TARGET_OS_CPP_BUILTINS()
18748 +
18749 +/* This is how we tell the assembler that two symbols have the same value. */
18750 +#define ASM_OUTPUT_DEF(FILE, NAME1, NAME2) \
18751 + do \
18752 + { \
18753 + assemble_name (FILE, NAME1); \
18754 + fputs (" = ", FILE); \
18755 + assemble_name (FILE, NAME2); \
18756 + fputc ('\n', FILE); \
18757 + } \
18758 + while (0)
18759 +
18760 +
18761 +
18762 +#undef CC1_SPEC
18763 +#define CC1_SPEC "%{profile:-p}"
18764 +
18765 +/* Target CPU builtins. */
18766 +#define TARGET_CPU_CPP_BUILTINS() \
18767 + do \
18768 + { \
18769 + builtin_define ("__avr32__"); \
18770 + builtin_define ("__AVR32__"); \
18771 + builtin_define ("__AVR32_LINUX__"); \
18772 + builtin_define (avr32_part->macro); \
18773 + builtin_define (avr32_arch->macro); \
18774 + if (avr32_arch->uarch_type == UARCH_TYPE_AVR32A) \
18775 + builtin_define ("__AVR32_AVR32A__"); \
18776 + else \
18777 + builtin_define ("__AVR32_AVR32B__"); \
18778 + if (TARGET_UNALIGNED_WORD) \
18779 + builtin_define ("__AVR32_HAS_UNALIGNED_WORD__"); \
18780 + if (TARGET_SIMD) \
18781 + builtin_define ("__AVR32_HAS_SIMD__"); \
18782 + if (TARGET_DSP) \
18783 + builtin_define ("__AVR32_HAS_DSP__"); \
18784 + if (TARGET_RMW) \
18785 + builtin_define ("__AVR32_HAS_RMW__"); \
18786 + if (TARGET_BRANCH_PRED) \
18787 + builtin_define ("__AVR32_HAS_BRANCH_PRED__"); \
18788 + if (TARGET_FAST_FLOAT) \
18789 + builtin_define ("__AVR32_FAST_FLOAT__"); \
18790 + if (flag_pic) \
18791 + { \
18792 + builtin_define ("__PIC__"); \
18793 + builtin_define ("__pic__"); \
18794 + } \
18795 + } \
18796 + while (0)
18797 +
18798 +
18799 +
18800 +/* Call the function profiler with a given profile label. */
18801 +#undef FUNCTION_PROFILER
18802 +#define FUNCTION_PROFILER(STREAM, LABELNO) \
18803 + do \
18804 + { \
18805 + fprintf (STREAM, "\tmov\tlr, lo(mcount)\n\torh\tlr, hi(mcount)\n"); \
18806 + fprintf (STREAM, "\ticall lr\n"); \
18807 + } \
18808 + while (0)
18809 +
18810 +#define NO_PROFILE_COUNTERS 1
18811 +
18812 +/* For dynamic libraries to work */
18813 +/* #define PLT_REG_CALL_CLOBBERED 1 */
18814 +#define AVR32_ALWAYS_PIC 1
18815 +
18816 +/* uclibc does not implement sinf, cosf etc. */
18817 +#undef TARGET_C99_FUNCTIONS
18818 +#define TARGET_C99_FUNCTIONS 0
18819 +
18820 +#define LINK_GCC_C_SEQUENCE_SPEC \
18821 + "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
18822 Index: gcc-4.2.3/gcc/config/avr32/predicates.md
18823 ===================================================================
18824 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
18825 +++ gcc-4.2.3/gcc/config/avr32/predicates.md 2008-05-21 13:45:54.173288052 +0200
18826 @@ -0,0 +1,331 @@
18827 +;; AVR32 predicates file.
18828 +;; Copyright 2003-2006 Atmel Corporation.
18829 +;;
18830 +;; Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
18831 +;;
18832 +;; This file is part of GCC.
18833 +;;
18834 +;; This program is free software; you can redistribute it and/or modify
18835 +;; it under the terms of the GNU General Public License as published by
18836 +;; the Free Software Foundation; either version 2 of the License, or
18837 +;; (at your option) any later version.
18838 +;;
18839 +;; This program is distributed in the hope that it will be useful,
18840 +;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18841 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18842 +;; GNU General Public License for more details.
18843 +;;
18844 +;; You should have received a copy of the GNU General Public License
18845 +;; along with this program; if not, write to the Free Software
18846 +;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18847 +
18848 +
18849 +;; True if the operand is a memory reference which contains an
18850 +;; Address consisting of a single pointer register
18851 +(define_predicate "avr32_indirect_register_operand"
18852 + (and (match_code "mem")
18853 + (match_test "register_operand(XEXP(op, 0), SImode)")))
18854 +
18855 +
18856 +
18857 +;; Address expression with a base pointer offset with
18858 +;; a register displacement
18859 +(define_predicate "avr32_indexed_memory_operand"
18860 + (and (match_code "mem")
18861 + (match_test "GET_CODE(XEXP(op, 0)) == PLUS"))
18862 + {
18863 +
18864 + rtx op0 = XEXP(XEXP(op, 0), 0);
18865 + rtx op1 = XEXP(XEXP(op, 0), 1);
18866 +
18867 + return ((avr32_address_register_rtx_p (op0, 0)
18868 + && avr32_legitimate_index_p (GET_MODE(op), op1, 0))
18869 + || (avr32_address_register_rtx_p (op1, 0)
18870 + && avr32_legitimate_index_p (GET_MODE(op), op0, 0)));
18871 +
18872 + })
18873 +
18874 +;; Operand suitable for the ld.sb instruction
18875 +(define_predicate "load_sb_memory_operand"
18876 + (ior (match_operand 0 "avr32_indirect_register_operand")
18877 + (match_operand 0 "avr32_indexed_memory_operand")))
18878 +
18879 +
18880 +;; Operand suitable as operand to insns sign extending QI values
18881 +(define_predicate "extendqi_operand"
18882 + (ior (match_operand 0 "load_sb_memory_operand")
18883 + (match_operand 0 "register_operand")))
18884 +
18885 +(define_predicate "post_inc_memory_operand"
18886 + (and (match_code "mem")
18887 + (match_test "(GET_CODE(XEXP(op, 0)) == POST_INC)
18888 + && REG_P(XEXP(XEXP(op, 0), 0))")))
18889 +
18890 +(define_predicate "pre_dec_memory_operand"
18891 + (and (match_code "mem")
18892 + (match_test "(GET_CODE(XEXP(op, 0)) == PRE_DEC)
18893 + && REG_P(XEXP(XEXP(op, 0), 0))")))
18894 +
18895 +;; Operand suitable for add instructions
18896 +(define_predicate "avr32_add_operand"
18897 + (ior (match_operand 0 "register_operand")
18898 + (and (match_operand 0 "immediate_operand")
18899 + (match_test "CONST_OK_FOR_CONSTRAINT_P(INTVAL(op), 'I', \"Is21\")"))))
18900 +
18901 +;; Operand is a power of two immediate
18902 +(define_predicate "power_of_two_operand"
18903 + (match_code "const_int")
18904 +{
18905 + HOST_WIDE_INT value = INTVAL (op);
18906 +
18907 + return value != 0 && (value & (value - 1)) == 0;
18908 +})
18909 +
18910 +;; Operand is a multiple of 8 immediate
18911 +(define_predicate "multiple_of_8_operand"
18912 + (match_code "const_int")
18913 +{
18914 + HOST_WIDE_INT value = INTVAL (op);
18915 +
18916 + return (value & 0x7) == 0 ;
18917 +})
18918 +
18919 +;; Operand is a multiple of 16 immediate
18920 +(define_predicate "multiple_of_16_operand"
18921 + (match_code "const_int")
18922 +{
18923 + HOST_WIDE_INT value = INTVAL (op);
18924 +
18925 + return (value & 0xf) == 0 ;
18926 +})
18927 +
18928 +;; Operand is a mask used for masking away upper bits of a reg
18929 +(define_predicate "avr32_mask_upper_bits_operand"
18930 + (match_code "const_int")
18931 +{
18932 + HOST_WIDE_INT value = INTVAL (op) + 1;
18933 +
18934 + return value != 1 && value != 0 && (value & (value - 1)) == 0;
18935 +})
18936 +
18937 +
18938 +;; Operand suitable for mul instructions
18939 +(define_predicate "avr32_mul_operand"
18940 + (ior (match_operand 0 "register_operand")
18941 + (and (match_operand 0 "immediate_operand")
18942 + (match_test "CONST_OK_FOR_CONSTRAINT_P(INTVAL(op), 'K', \"Ks08\")"))))
18943 +
18944 +;; True for logical binary operators.
18945 +(define_predicate "logical_binary_operator"
18946 + (match_code "ior,xor,and"))
18947 +
18948 +;; True for logical shift operators
18949 +(define_predicate "logical_shift_operator"
18950 + (match_code "ashift,lshiftrt"))
18951 +
18952 +;; True for shift operand for logical and, or and eor insns
18953 +(define_predicate "avr32_logical_shift_operand"
18954 + (and (match_code "ashift,lshiftrt")
18955 + (ior (and (match_test "GET_CODE(XEXP(op, 1)) == CONST_INT")
18956 + (match_test "register_operand(XEXP(op, 0), GET_MODE(XEXP(op, 0)))"))
18957 + (and (match_test "GET_CODE(XEXP(op, 0)) == CONST_INT")
18958 + (match_test "register_operand(XEXP(op, 1), GET_MODE(XEXP(op, 1)))"))))
18959 + {
18960 + return 1;
18961 + }
18962 + )
18963 +
18964 +
18965 +;; Predicate for second operand to and, ior and xor insn patterns
18966 +(define_predicate "avr32_logical_insn_operand"
18967 + (ior (match_operand 0 "register_operand")
18968 + (match_operand 0 "avr32_logical_shift_operand"))
18969 + {
18970 + return 1;
18971 + }
18972 +)
18973 +
18974 +
18975 +;; True for avr32 comparison operators
18976 +(define_predicate "avr32_comparison_operator"
18977 + (ior (match_code "eq, ne, gt, ge, lt, le, gtu, geu, ltu, leu")
18978 + (and (match_code "unspec")
18979 + (match_test "(XINT(op, 1) == UNSPEC_COND_MI)
18980 + || (XINT(op, 1) == UNSPEC_COND_PL)"))))
18981 +
18982 +;; True for avr32 comparison operand
18983 +(define_predicate "avr32_comparison_operand"
18984 + (ior (and (match_code "eq, ne, gt, ge, lt, le, gtu, geu, ltu, leu")
18985 + (match_test "(rtx_equal_p (XEXP(op,0), cc0_rtx) && rtx_equal_p (XEXP(op,1), const0_rtx))"))
18986 + (and (match_code "unspec")
18987 + (match_test "(XINT(op, 1) == UNSPEC_COND_MI)
18988 + || (XINT(op, 1) == UNSPEC_COND_PL)"))))
18989 +
18990 +;; True if this is a const_int with one bit set
18991 +(define_predicate "one_bit_set_operand"
18992 + (match_code "const_int")
18993 + {
18994 + int i;
18995 + int value;
18996 + int ones = 0;
18997 +
18998 + value = INTVAL(op);
18999 + for ( i = 0 ; i < 32; i++ ){
19000 + if ( value & ( 1 << i ) ){
19001 + ones++;
19002 + }
19003 + }
19004 +
19005 + return ( ones == 1 );
19006 + })
19007 +
19008 +
19009 +;; True if this is a const_int with one bit cleared
19010 +(define_predicate "one_bit_cleared_operand"
19011 + (match_code "const_int")
19012 + {
19013 + int i;
19014 + int value;
19015 + int zeroes = 0;
19016 +
19017 + value = INTVAL(op);
19018 + for ( i = 0 ; i < 32; i++ ){
19019 + if ( !(value & ( 1 << i )) ){
19020 + zeroes++;
19021 + }
19022 + }
19023 +
19024 + return ( zeroes == 1 );
19025 + })
19026 +
19027 +
19028 +;; True if this is a register or immediate operand
19029 +(define_predicate "register_immediate_operand"
19030 + (ior (match_operand 0 "register_operand")
19031 + (match_operand 0 "immediate_operand")))
19032 +
19033 +
19034 +;; True is this is an operand containing a label_ref
19035 +(define_predicate "avr32_label_ref_operand"
19036 + (and (match_code "mem")
19037 + (match_test "avr32_find_symbol(op)
19038 + && (GET_CODE(avr32_find_symbol(op)) == LABEL_REF)")))
19039 +
19040 +;; True is this is a valid symbol pointing to the constant pool
19041 +(define_predicate "avr32_const_pool_operand"
19042 + (and (match_code "symbol_ref")
19043 + (match_test "CONSTANT_POOL_ADDRESS_P(op)"))
19044 + {
19045 + return (flag_pic ? (!(symbol_mentioned_p (get_pool_constant (op))
19046 + || label_mentioned_p (get_pool_constant (op)))
19047 + || avr32_got_mentioned_p(get_pool_constant (op)))
19048 + : true);
19049 + }
19050 +)
19051 +
19052 +;; True is this is a memory reference to the constant or mini pool
19053 +(define_predicate "avr32_const_pool_ref_operand"
19054 + (ior (match_operand 0 "avr32_label_ref_operand")
19055 + (and (match_code "mem")
19056 + (match_test "avr32_const_pool_operand(XEXP(op,0), GET_MODE(XEXP(op,0)))"))))
19057 +
19058 +
19059 +;; Legal source operand for movti insns
19060 +(define_predicate "avr32_movti_src_operand"
19061 + (ior (match_operand 0 "avr32_const_pool_ref_operand")
19062 + (ior (ior (match_operand 0 "register_immediate_operand")
19063 + (match_operand 0 "avr32_indirect_register_operand"))
19064 + (match_operand 0 "post_inc_memory_operand"))))
19065 +
19066 +;; Legal destination operand for movti insns
19067 +(define_predicate "avr32_movti_dst_operand"
19068 + (ior (ior (match_operand 0 "register_operand")
19069 + (match_operand 0 "avr32_indirect_register_operand"))
19070 + (match_operand 0 "pre_dec_memory_operand")))
19071 +
19072 +
19073 +;; True is this is a k12 offseted memory operand
19074 +(define_predicate "avr32_k12_memory_operand"
19075 + (and (match_code "mem")
19076 + (ior (match_test "REG_P(XEXP(op, 0))")
19077 + (match_test "GET_CODE(XEXP(op, 0)) == PLUS
19078 + && REG_P(XEXP(XEXP(op, 0), 0))
19079 + && (GET_CODE(XEXP(XEXP(op, 0), 1)) == CONST_INT)
19080 + && (CONST_OK_FOR_CONSTRAINT_P(INTVAL(XEXP(XEXP(op, 0), 0)),
19081 + 'K', (mode == SImode) ? \"Ks14\" : ((mode == HImode) ? \"Ks13\" : \"Ks12\")))"))))
19082 +
19083 +;; True is this is a memory operand with an immediate displacement
19084 +(define_predicate "avr32_imm_disp_memory_operand"
19085 + (and (match_code "mem")
19086 + (match_test "GET_CODE(XEXP(op, 0)) == PLUS
19087 + && REG_P(XEXP(XEXP(op, 0), 0))
19088 + && (GET_CODE(XEXP(XEXP(op, 0), 1)) == CONST_INT)")))
19089 +
19090 +;; True is this is a bswap operand
19091 +(define_predicate "avr32_bswap_operand"
19092 + (ior (match_operand 0 "avr32_k12_memory_operand")
19093 + (match_operand 0 "register_operand")))
19094 +
19095 +;; True is this is a valid coprocessor insn memory operand
19096 +(define_predicate "avr32_cop_memory_operand"
19097 + (and (match_operand 0 "memory_operand")
19098 + (not (match_test "GET_CODE(XEXP(op, 0)) == PLUS
19099 + && REG_P(XEXP(XEXP(op, 0), 0))
19100 + && (GET_CODE(XEXP(XEXP(op, 0), 1)) == CONST_INT)
19101 + && !(CONST_OK_FOR_CONSTRAINT_P(INTVAL(XEXP(XEXP(op, 0), 0)), 'K', \"Ku10\"))"))))
19102 +
19103 +;; True is this is a valid source/destination operand
19104 +;; for moving values to/from a coprocessor
19105 +(define_predicate "avr32_cop_move_operand"
19106 + (ior (match_operand 0 "register_operand")
19107 + (match_operand 0 "avr32_cop_memory_operand")))
19108 +
19109 +
19110 +;; True is this is a valid extract byte offset for use in
19111 +;; load extracted index insns
19112 +(define_predicate "avr32_extract_shift_operand"
19113 + (and (match_operand 0 "const_int_operand")
19114 + (match_test "(INTVAL(op) == 0) || (INTVAL(op) == 8)
19115 + || (INTVAL(op) == 16) || (INTVAL(op) == 24)")))
19116 +
19117 +;; True is this is a floating-point register
19118 +(define_predicate "avr32_fp_register_operand"
19119 + (and (match_operand 0 "register_operand")
19120 + (match_test "REGNO_REG_CLASS(REGNO(op)) == FP_REGS")))
19121 +
19122 +;; True is this is valid avr32 symbol operand
19123 +(define_predicate "avr32_symbol_operand"
19124 + (ior (match_code "label_ref, symbol_ref")
19125 + (and (match_code "const")
19126 + (match_test "avr32_find_symbol(op)"))))
19127 +
19128 +;; True is this is valid operand for the lda.w and call pseudo insns
19129 +(define_predicate "avr32_address_operand"
19130 + (and (match_code "label_ref, symbol_ref")
19131 + (ior (match_test "TARGET_HAS_ASM_ADDR_PSEUDOS")
19132 + (match_test "flag_pic")) ))
19133 +
19134 +;; True if this is a avr32 call operand
19135 +(define_predicate "avr32_call_operand"
19136 + (ior (ior (match_operand 0 "register_operand")
19137 + (ior (match_operand 0 "avr32_const_pool_ref_operand")
19138 + (match_operand 0 "avr32_address_operand")))
19139 + (match_test "SYMBOL_REF_RCALL_FUNCTION_P(op)")))
19140 +
19141 +;; Return true for operators performing ALU operations
19142 +
19143 +(define_predicate "alu_operator"
19144 + (match_code "ior, xor, and, plus, minus, ashift, lshiftrt, ashiftrt"))
19145 +
19146 +(define_predicate "avr32_add_shift_immediate_operand"
19147 + (and (match_operand 0 "immediate_operand")
19148 + (match_test "CONST_OK_FOR_CONSTRAINT_P(INTVAL(op), 'K', \"Ku02\")")))
19149 +
19150 +(define_predicate "avr32_cond_register_immediate_operand"
19151 + (ior (match_operand 0 "register_operand")
19152 + (and (match_operand 0 "immediate_operand")
19153 + (match_test "CONST_OK_FOR_CONSTRAINT_P(INTVAL(op), 'K', \"Ks08\")"))))
19154 +
19155 +(define_predicate "avr32_cond_immediate_operand"
19156 + (and (match_operand 0 "immediate_operand")
19157 + (match_test "CONST_OK_FOR_CONSTRAINT_P(INTVAL(op), 'I', \"Is08\")")))
19158 Index: gcc-4.2.3/gcc/config/avr32/simd.md
19159 ===================================================================
19160 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
19161 +++ gcc-4.2.3/gcc/config/avr32/simd.md 2008-05-21 13:45:54.173288052 +0200
19162 @@ -0,0 +1,145 @@
19163 +;; AVR32 machine description file for SIMD instructions.
19164 +;; Copyright 2003-2006 Atmel Corporation.
19165 +;;
19166 +;; Written by Ronny Pedersen, Atmel Norway, <rpedersen@atmel.com>
19167 +;;
19168 +;; This file is part of GCC.
19169 +;;
19170 +;; This program is free software; you can redistribute it and/or modify
19171 +;; it under the terms of the GNU General Public License as published by
19172 +;; the Free Software Foundation; either version 2 of the License, or
19173 +;; (at your option) any later version.
19174 +;;
19175 +;; This program is distributed in the hope that it will be useful,
19176 +;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19177 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19178 +;; GNU General Public License for more details.
19179 +;;
19180 +;; You should have received a copy of the GNU General Public License
19181 +;; along with this program; if not, write to the Free Software
19182 +;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19183 +
19184 +;; -*- Mode: Scheme -*-
19185 +
19186 +
19187 +;; Vector modes
19188 +(define_mode_macro VECM [V2HI V4QI])
19189 +(define_mode_attr size [(V2HI "h") (V4QI "b")])
19190 +
19191 +(define_insn "add<mode>3"
19192 + [(set (match_operand:VECM 0 "register_operand" "=r")
19193 + (plus:VECM (match_operand:VECM 1 "register_operand" "r")
19194 + (match_operand:VECM 2 "register_operand" "r")))]
19195 + "TARGET_SIMD"
19196 + "padd.<size>\t%0, %1, %2"
19197 + [(set_attr "length" "4")
19198 + (set_attr "type" "alu")])
19199 +
19200 +
19201 +(define_insn "sub<mode>3"
19202 + [(set (match_operand:VECM 0 "register_operand" "=r")
19203 + (minus:VECM (match_operand:VECM 1 "register_operand" "r")
19204 + (match_operand:VECM 2 "register_operand" "r")))]
19205 + "TARGET_SIMD"
19206 + "psub.<size>\t%0, %1, %2"
19207 + [(set_attr "length" "4")
19208 + (set_attr "type" "alu")])
19209 +
19210 +
19211 +(define_insn "abs<mode>2"
19212 + [(set (match_operand:VECM 0 "register_operand" "=r")
19213 + (abs:VECM (match_operand:VECM 1 "register_operand" "r")))]
19214 + "TARGET_SIMD"
19215 + "pabs.s<size>\t%0, %1"
19216 + [(set_attr "length" "4")
19217 + (set_attr "type" "alu")])
19218 +
19219 +(define_insn "ashl<mode>3"
19220 + [(set (match_operand:VECM 0 "register_operand" "=r")
19221 + (ashift:VECM (match_operand:VECM 1 "register_operand" "r")
19222 + (match_operand:SI 2 "immediate_operand" "Ku04")))]
19223 + "TARGET_SIMD"
19224 + "plsl.<size>\t%0, %1, %2"
19225 + [(set_attr "length" "4")
19226 + (set_attr "type" "alu")])
19227 +
19228 +(define_insn "ashr<mode>3"
19229 + [(set (match_operand:VECM 0 "register_operand" "=r")
19230 + (ashiftrt:VECM (match_operand:VECM 1 "register_operand" "r")
19231 + (match_operand:SI 2 "immediate_operand" "Ku04")))]
19232 + "TARGET_SIMD"
19233 + "pasr.<size>\t%0, %1, %2"
19234 + [(set_attr "length" "4")
19235 + (set_attr "type" "alu")])
19236 +
19237 +(define_insn "lshr<mode>3"
19238 + [(set (match_operand:VECM 0 "register_operand" "=r")
19239 + (lshiftrt:VECM (match_operand:VECM 1 "register_operand" "r")
19240 + (match_operand:SI 2 "immediate_operand" "Ku04")))]
19241 + "TARGET_SIMD"
19242 + "plsr.<size>\t%0, %1, %2"
19243 + [(set_attr "length" "4")
19244 + (set_attr "type" "alu")])
19245 +
19246 +(define_insn "smaxv2hi3"
19247 + [(set (match_operand:V2HI 0 "register_operand" "=r")
19248 + (smax:V2HI (match_operand:V2HI 1 "register_operand" "r")
19249 + (match_operand:V2HI 2 "register_operand" "r")))]
19250 +
19251 + "TARGET_SIMD"
19252 + "pmax.sh\t%0, %1, %2"
19253 + [(set_attr "length" "4")
19254 + (set_attr "type" "alu")])
19255 +
19256 +(define_insn "sminv2hi3"
19257 + [(set (match_operand:V2HI 0 "register_operand" "=r")
19258 + (smin:V2HI (match_operand:V2HI 1 "register_operand" "r")
19259 + (match_operand:V2HI 2 "register_operand" "r")))]
19260 +
19261 + "TARGET_SIMD"
19262 + "pmin.sh\t%0, %1, %2"
19263 + [(set_attr "length" "4")
19264 + (set_attr "type" "alu")])
19265 +
19266 +(define_insn "umaxv4qi3"
19267 + [(set (match_operand:V4QI 0 "register_operand" "=r")
19268 + (umax:V4QI (match_operand:V4QI 1 "register_operand" "r")
19269 + (match_operand:V4QI 2 "register_operand" "r")))]
19270 +
19271 + "TARGET_SIMD"
19272 + "pmax.ub\t%0, %1, %2"
19273 + [(set_attr "length" "4")
19274 + (set_attr "type" "alu")])
19275 +
19276 +(define_insn "uminv4qi3"
19277 + [(set (match_operand:V4QI 0 "register_operand" "=r")
19278 + (umin:V4QI (match_operand:V4QI 1 "register_operand" "r")
19279 + (match_operand:V4QI 2 "register_operand" "r")))]
19280 +
19281 + "TARGET_SIMD"
19282 + "pmin.ub\t%0, %1, %2"
19283 + [(set_attr "length" "4")
19284 + (set_attr "type" "alu")])
19285 +
19286 +
19287 +(define_insn "addsubv2hi"
19288 + [(set (match_operand:V2HI 0 "register_operand" "=r")
19289 + (vec_concat:V2HI
19290 + (plus:HI (match_operand:HI 1 "register_operand" "r")
19291 + (match_operand:HI 2 "register_operand" "r"))
19292 + (minus:HI (match_dup 1) (match_dup 2))))]
19293 + "TARGET_SIMD"
19294 + "paddsub.h\t%0, %1:b, %2:b"
19295 + [(set_attr "length" "4")
19296 + (set_attr "type" "alu")])
19297 +
19298 +(define_insn "subaddv2hi"
19299 + [(set (match_operand:V2HI 0 "register_operand" "=r")
19300 + (vec_concat:V2HI
19301 + (minus:HI (match_operand:HI 1 "register_operand" "r")
19302 + (match_operand:HI 2 "register_operand" "r"))
19303 + (plus:HI (match_dup 1) (match_dup 2))))]
19304 + "TARGET_SIMD"
19305 + "psubadd.h\t%0, %1:b, %2:b"
19306 + [(set_attr "length" "4")
19307 + (set_attr "type" "alu")])
19308 Index: gcc-4.2.3/gcc/config/avr32/sync.md
19309 ===================================================================
19310 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
19311 +++ gcc-4.2.3/gcc/config/avr32/sync.md 2008-05-21 13:45:54.177287723 +0200
19312 @@ -0,0 +1,175 @@
19313 +;;=================================================================
19314 +;; Atomic operations
19315 +;;=================================================================
19316 +
19317 +
19318 +(define_insn "sync_compare_and_swapsi"
19319 + [(set (match_operand:SI 0 "register_operand" "=&r,&r")
19320 + (match_operand:SI 1 "memory_operand" "+RKs16,+RKs16"))
19321 + (set (match_dup 1)
19322 + (unspec_volatile:SI
19323 + [(match_dup 1)
19324 + (match_operand:SI 2 "register_immediate_operand" "r,Ks21")
19325 + (match_operand:SI 3 "register_operand" "r,r")]
19326 + VUNSPEC_SYNC_CMPXCHG)) ]
19327 + ""
19328 + "0:
19329 + ssrf\t5
19330 + ld.w\t%0,%1
19331 + cp.w\t%0,%2
19332 + brne\t0f
19333 + stcond\t%1, %3
19334 + brne\t0b
19335 + 0:
19336 + "
19337 + [(set_attr "length" "16,18")
19338 + (set_attr "cc" "clobber")]
19339 + )
19340 +
19341 +
19342 +(define_code_macro atomic_op [plus minus and ior xor])
19343 +(define_code_attr atomic_asm_insn [(plus "add") (minus "sub") (and "and") (ior "or") (xor "eor")])
19344 +(define_code_attr atomic_insn [(plus "add") (minus "sub") (and "and") (ior "ior") (xor "xor")])
19345 +
19346 +(define_insn "sync_loadsi"
19347 + [(set (match_operand:SI 0 "register_operand" "=r")
19348 + (unspec_volatile:SI
19349 + [(match_operand:SI 1 "memory_operand" "RKs16")
19350 + (label_ref (match_operand 2 "" ""))]
19351 + VUNSPEC_SYNC_SET_LOCK_AND_LOAD) )]
19352 + ""
19353 + "%2:
19354 + ssrf\t5
19355 + ld.w\t%0,%1"
19356 + [(set_attr "length" "6")
19357 + (set_attr "cc" "clobber")]
19358 + )
19359 +
19360 +(define_insn "sync_store_if_lock"
19361 + [(set (match_operand:SI 0 "memory_operand" "=RKs16")
19362 + (unspec_volatile:SI
19363 + [(match_operand:SI 1 "register_operand" "r")
19364 + (label_ref (match_operand 2 "" ""))]
19365 + VUNSPEC_SYNC_STORE_IF_LOCK) )]
19366 + ""
19367 + "stcond\t%0, %1
19368 + brne\t%2"
19369 + [(set_attr "length" "6")
19370 + (set_attr "cc" "clobber")]
19371 + )
19372 +
19373 +
19374 +(define_expand "sync_<atomic_insn>si"
19375 + [(set (match_dup 2)
19376 + (unspec_volatile:SI
19377 + [(match_operand:SI 0 "memory_operand" "")
19378 + (match_dup 3)]
19379 + VUNSPEC_SYNC_SET_LOCK_AND_LOAD))
19380 + (set (match_dup 2)
19381 + (atomic_op:SI (match_dup 2)
19382 + (match_operand:SI 1 "register_immediate_operand" "")))
19383 + (set (match_dup 0)
19384 + (unspec_volatile:SI
19385 + [(match_dup 2)
19386 + (match_dup 3)]
19387 + VUNSPEC_SYNC_STORE_IF_LOCK) )]
19388 + ""
19389 + {
19390 + operands[2] = gen_reg_rtx (SImode);
19391 + operands[3] = gen_rtx_LABEL_REF(Pmode, gen_label_rtx ());
19392 + }
19393 + )
19394 +
19395 +
19396 +
19397 +(define_expand "sync_old_<atomic_insn>si"
19398 + [(set (match_operand:SI 0 "register_operand" "")
19399 + (unspec_volatile:SI
19400 + [(match_operand:SI 1 "memory_operand" "")
19401 + (match_dup 4)]
19402 + VUNSPEC_SYNC_SET_LOCK_AND_LOAD))
19403 + (set (match_dup 3)
19404 + (atomic_op:SI (match_dup 0)
19405 + (match_operand:SI 2 "register_immediate_operand" "")))
19406 + (set (match_dup 1)
19407 + (unspec_volatile:SI
19408 + [(match_dup 3)
19409 + (match_dup 4)]
19410 + VUNSPEC_SYNC_STORE_IF_LOCK) )]
19411 + ""
19412 + {
19413 + operands[3] = gen_reg_rtx (SImode);
19414 + operands[4] = gen_rtx_LABEL_REF(Pmode, gen_label_rtx ());
19415 + }
19416 + )
19417 +
19418 +(define_expand "sync_new_<atomic_insn>si"
19419 + [(set (match_operand:SI 0 "register_operand" "")
19420 + (unspec_volatile:SI
19421 + [(match_operand:SI 1 "memory_operand" "")
19422 + (match_dup 3)]
19423 + VUNSPEC_SYNC_SET_LOCK_AND_LOAD))
19424 + (set (match_dup 0)
19425 + (atomic_op:SI (match_dup 0)
19426 + (match_operand:SI 2 "register_immediate_operand" "")))
19427 + (set (match_dup 1)
19428 + (unspec_volatile:SI
19429 + [(match_dup 0)
19430 + (match_dup 3)]
19431 + VUNSPEC_SYNC_STORE_IF_LOCK) )]
19432 + ""
19433 + {
19434 + operands[3] = gen_rtx_LABEL_REF(Pmode, gen_label_rtx ());
19435 + }
19436 + )
19437 +
19438 +
19439 +;(define_insn "sync_<atomic_insn>si"
19440 +; [(set (match_operand:SI 0 "memory_operand" "+RKs16")
19441 +; (unspec_volatile:SI
19442 +; [(atomic_op:SI (match_dup 0)
19443 +; (match_operand:SI 1 "register_operand" "r"))]
19444 +; VUNSPEC_SYNC_CMPXCHG))
19445 +; (clobber (match_scratch:SI 2 "=&r"))]
19446 +; ""
19447 +; "0:
19448 +; ssrf\t5
19449 +; ld.w\t%2,%0
19450 +; <atomic_asm_insn>\t%2,%1
19451 +; stcond\t%0, %2
19452 +; brne\t0b
19453 +; "
19454 +; [(set_attr "length" "14")
19455 +; (set_attr "cc" "clobber")]
19456 +; )
19457 +;
19458 +;(define_insn "sync_new_<atomic_insn>si"
19459 +; [(set (match_operand:SI 1 "memory_operand" "+RKs16")
19460 +; (unspec_volatile:SI
19461 +; [(atomic_op:SI (match_dup 1)
19462 +; (match_operand:SI 2 "register_operand" "r"))]
19463 +; VUNSPEC_SYNC_CMPXCHG))
19464 +; (set (match_operand:SI 0 "register_operand" "=&r")
19465 +; (atomic_op:SI (match_dup 1)
19466 +; (match_dup 2)))]
19467 +; ""
19468 +; "0:
19469 +; ssrf\t5
19470 +; ld.w\t%0,%1
19471 +; <atomic_asm_insn>\t%0,%2
19472 +; stcond\t%1, %0
19473 +; brne\t0b
19474 +; "
19475 +; [(set_attr "length" "14")
19476 +; (set_attr "cc" "clobber")]
19477 +; )
19478 +
19479 +(define_insn "sync_lock_test_and_setsi"
19480 + [ (set (match_operand:SI 0 "register_operand" "=&r")
19481 + (match_operand:SI 1 "memory_operand" "+RKu00"))
19482 + (set (match_dup 1)
19483 + (match_operand:SI 2 "register_operand" "r")) ]
19484 + ""
19485 + "xchg\t%0, %p1, %2"
19486 + [(set_attr "length" "4")]
19487 + )
19488 Index: gcc-4.2.3/gcc/config/avr32/t-avr32
19489 ===================================================================
19490 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
19491 +++ gcc-4.2.3/gcc/config/avr32/t-avr32 2008-05-21 13:45:54.177287723 +0200
19492 @@ -0,0 +1,76 @@
19493 +
19494 +MD_INCLUDES= $(srcdir)/config/avr32/avr32.md \
19495 + $(srcdir)/config/avr32/sync.md \
19496 + $(srcdir)/config/avr32/fpcp.md \
19497 + $(srcdir)/config/avr32/simd.md \
19498 + $(srcdir)/config/avr32/predicates.md
19499 +
19500 +s-config s-conditions s-flags s-codes s-constants s-emit s-recog s-preds \
19501 + s-opinit s-extract s-peep s-attr s-attrtab s-output: $(MD_INCLUDES)
19502 +
19503 +# We want fine grained libraries, so use the new code
19504 +# to build the floating point emulation libraries.
19505 +FPBIT = fp-bit.c
19506 +DPBIT = dp-bit.c
19507 +
19508 +LIB1ASMSRC = avr32/lib1funcs.S
19509 +LIB1ASMFUNCS = _avr32_f64_mul _avr32_f64_addsub _avr32_f64_addsub_fast _avr32_f64_to_u32 \
19510 + _avr32_f64_to_s32 _avr32_f64_to_u64 _avr32_f64_to_s64 _avr32_u32_to_f64 \
19511 + _avr32_s32_to_f64 _avr32_f64_cmp_eq _avr32_f64_cmp_ge _avr32_f64_cmp_lt \
19512 + _avr32_f32_cmp_eq _avr32_f32_cmp_ge _avr32_f32_cmp_lt _avr32_f64_div \
19513 + _avr32_f32_div _avr32_f32_div_fast _avr32_f32_addsub _avr32_f32_addsub_fast \
19514 + _avr32_f32_mul _avr32_s32_to_f32 _avr32_u32_to_f32 _avr32_f32_to_s32 \
19515 + _avr32_f32_to_u32 _avr32_f32_to_f64 _avr32_f64_to_f32
19516 +
19517 +#LIB2FUNCS_EXTRA += $(srcdir)/config/avr32/lib2funcs.S
19518 +
19519 +MULTILIB_OPTIONS = march=ap/march=uc
19520 +MULTILIB_DIRNAMES = ap uc
19521 +MULTILIB_EXCEPTIONS =
19522 +MULTILIB_MATCHES = march?ap=mcpu?ap7000
19523 +MULTILIB_MATCHES += march?ap=mcpu?ap7010
19524 +MULTILIB_MATCHES += march?ap=mcpu?ap7020
19525 +MULTILIB_MATCHES += march?uc=mcpu?uc3a0256
19526 +MULTILIB_MATCHES += march?uc=mcpu?uc3a0512
19527 +MULTILIB_MATCHES += march?uc=mcpu?uc3a1128
19528 +MULTILIB_MATCHES += march?uc=mcpu?uc3a1256
19529 +MULTILIB_MATCHES += march?uc=mcpu?uc3a1512
19530 +MULTILIB_MATCHES += march?uc=mcpu?uc3b064
19531 +MULTILIB_MATCHES += march?uc=mcpu?uc3b0128
19532 +MULTILIB_MATCHES += march?uc=mcpu?uc3b0256
19533 +MULTILIB_MATCHES += march?uc=mcpu?uc3b164
19534 +MULTILIB_MATCHES += march?uc=mcpu?uc3b1128
19535 +MULTILIB_MATCHES += march?uc=mcpu?uc3b1256
19536 +MULTILIB_MATCHES += march?ap=mpart?ap7000
19537 +MULTILIB_MATCHES += march?ap=mpart?ap7010
19538 +MULTILIB_MATCHES += march?ap=mpart?ap7020
19539 +MULTILIB_MATCHES += march?uc=mpart?uc3a0256
19540 +MULTILIB_MATCHES += march?uc=mpart?uc3a0512
19541 +MULTILIB_MATCHES += march?uc=mpart?uc3a1128
19542 +MULTILIB_MATCHES += march?uc=mpart?uc3a1256
19543 +MULTILIB_MATCHES += march?uc=mpart?uc3a1512
19544 +MULTILIB_MATCHES += march?uc=mpart?uc3b064
19545 +MULTILIB_MATCHES += march?uc=mpart?uc3b0128
19546 +MULTILIB_MATCHES += march?uc=mpart?uc3b0256
19547 +MULTILIB_MATCHES += march?uc=mpart?uc3b164
19548 +MULTILIB_MATCHES += march?uc=mpart?uc3b1128
19549 +MULTILIB_MATCHES += march?uc=mpart?uc3b1256
19550 +
19551 +EXTRA_MULTILIB_PARTS = crtbegin.o crtbeginS.o crtend.o crtendS.o crti.o crtn.o
19552 +
19553 +CRTSTUFF_T_CFLAGS = -mrelax
19554 +CRTSTUFF_T_CFLAGS_S = -mrelax -fPIC
19555 +TARGET_LIBGCC2_CFLAGS += -mrelax
19556 +
19557 +LIBGCC = stmp-multilib
19558 +INSTALL_LIBGCC = install-multilib
19559 +
19560 +fp-bit.c: $(srcdir)/config/fp-bit.c
19561 + echo '#define FLOAT' > fp-bit.c
19562 + cat $(srcdir)/config/fp-bit.c >> fp-bit.c
19563 +
19564 +dp-bit.c: $(srcdir)/config/fp-bit.c
19565 + cat $(srcdir)/config/fp-bit.c > dp-bit.c
19566 +
19567 +
19568 +
19569 Index: gcc-4.2.3/gcc/config/avr32/t-elf
19570 ===================================================================
19571 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
19572 +++ gcc-4.2.3/gcc/config/avr32/t-elf 2008-05-21 13:45:54.177287723 +0200
19573 @@ -0,0 +1,16 @@
19574 +
19575 +# Assemble startup files.
19576 +$(T)crti.o: $(srcdir)/config/avr32/crti.asm $(GCC_PASSES)
19577 + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) $(INCLUDES) \
19578 + -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/avr32/crti.asm
19579 +
19580 +$(T)crtn.o: $(srcdir)/config/avr32/crtn.asm $(GCC_PASSES)
19581 + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) $(INCLUDES) \
19582 + -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/avr32/crtn.asm
19583 +
19584 +
19585 +# Build the libraries for both hard and soft floating point
19586 +EXTRA_MULTILIB_PARTS = crtbegin.o crtbeginS.o crtend.o crtendS.o crti.o crtn.o
19587 +
19588 +LIBGCC = stmp-multilib
19589 +INSTALL_LIBGCC = install-multilib
19590 Index: gcc-4.2.3/gcc/config/avr32/uclinux-elf.h
19591 ===================================================================
19592 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
19593 +++ gcc-4.2.3/gcc/config/avr32/uclinux-elf.h 2008-05-21 13:45:54.177287723 +0200
19594 @@ -0,0 +1,20 @@
19595 +
19596 +/* Run-time Target Specification. */
19597 +#undef TARGET_VERSION
19598 +#define TARGET_VERSION fputs (" (AVR32 uClinux with ELF)", stderr)
19599 +
19600 +/* We don't want a .jcr section on uClinux. As if this makes a difference... */
19601 +#define TARGET_USE_JCR_SECTION 0
19602 +
19603 +/* Here we go. Drop the crtbegin/crtend stuff completely. */
19604 +#undef STARTFILE_SPEC
19605 +#define STARTFILE_SPEC \
19606 + "%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s}" \
19607 + " %{!p:%{profile:gcrt1.o%s}" \
19608 + " %{!profile:crt1.o%s}}}} crti.o%s"
19609 +
19610 +#undef ENDFILE_SPEC
19611 +#define ENDFILE_SPEC "crtn.o%s"
19612 +
19613 +#undef TARGET_DEFAULT
19614 +#define TARGET_DEFAULT (AVR32_FLAG_NO_INIT_GOT)
19615 Index: gcc-4.2.3/gcc/config/host-linux.c
19616 ===================================================================
19617 --- gcc-4.2.3.orig/gcc/config/host-linux.c 2007-09-01 17:28:30.000000000 +0200
19618 +++ gcc-4.2.3/gcc/config/host-linux.c 2008-05-21 13:45:54.177287723 +0200
19619 @@ -25,6 +25,9 @@
19620 #include "hosthooks.h"
19621 #include "hosthooks-def.h"
19622
19623 +#ifndef SSIZE_MAX
19624 +#define SSIZE_MAX LONG_MAX
19625 +#endif
19626
19627 /* Linux has a feature called exec-shield-randomize that perturbs the
19628 address of non-fixed mapped segments by a (relatively) small amount.
19629 Index: gcc-4.2.3/gcc/config.gcc
19630 ===================================================================
19631 --- gcc-4.2.3.orig/gcc/config.gcc 2008-05-21 13:45:53.353287795 +0200
19632 +++ gcc-4.2.3/gcc/config.gcc 2008-05-21 13:45:54.181287953 +0200
19633 @@ -790,6 +790,24 @@
19634 tm_file="avr/avr.h dbxelf.h"
19635 use_fixproto=yes
19636 ;;
19637 +avr32*-*-linux*)
19638 + tm_file="dbxelf.h elfos.h linux.h avr32/linux-elf.h avr32/avr32.h "
19639 + tmake_file="t-linux avr32/t-avr32 avr32/t-elf"
19640 + extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
19641 + extra_modes=avr32/avr32-modes.def
19642 + gnu_ld=yes
19643 + ;;
19644 +avr32*-*-uclinux*)
19645 + tm_file="dbxelf.h elfos.h linux.h avr32/linux-elf.h avr32/uclinux-elf.h avr32/avr32.h"
19646 + tmake_file="t-linux avr32/t-avr32 avr32/t-elf"
19647 + extra_modes=avr32/avr32-modes.def
19648 + gnu_ld=yes
19649 + ;;
19650 +avr32-*-*)
19651 + tm_file="dbxelf.h elfos.h avr32/avr32.h avr32/avr32-elf.h"
19652 + tmake_file="avr32/t-avr32 avr32/t-elf"
19653 + extra_modes=avr32/avr32-modes.def
19654 + ;;
19655 bfin*-elf*)
19656 tm_file="${tm_file} dbxelf.h elfos.h bfin/elf.h"
19657 tmake_file=bfin/t-bfin-elf
19658 @@ -1690,6 +1708,9 @@
19659 pdp11-*-*)
19660 use_fixproto=yes
19661 ;;
19662 +avr-*-*)
19663 + use_fixproto=yes
19664 + ;;
19665 # port not yet contributed
19666 #powerpc-*-openbsd*)
19667 # tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-fprules-fpbit "
19668 @@ -2726,6 +2747,32 @@
19669 fi
19670 ;;
19671
19672 + avr32*-*-*)
19673 + supported_defaults="part arch"
19674 +
19675 + case "$with_part" in
19676 + "" \
19677 + | "ap7000" | "ap7010" | "ap7020" | "uc3a0256" | "uc3a0512" | "uc3a1128" | "uc3a1256" | "uc3a1512" )
19678 + # OK
19679 + ;;
19680 + *)
19681 + echo "Unknown part used in --with-part=$with_part" 1>&2
19682 + exit 1
19683 + ;;
19684 + esac
19685 +
19686 + case "$with_arch" in
19687 + "" \
19688 + | "ap" | "uc")
19689 + # OK
19690 + ;;
19691 + *)
19692 + echo "Unknown arch used in --with-arch=$with_arch" 1>&2
19693 + exit 1
19694 + ;;
19695 + esac
19696 + ;;
19697 +
19698 fr*-*-*linux*)
19699 supported_defaults=cpu
19700 case "$with_cpu" in
19701 Index: gcc-4.2.3/gcc/doc/extend.texi
19702 ===================================================================
19703 --- gcc-4.2.3.orig/gcc/doc/extend.texi 2008-02-01 02:40:49.000000000 +0100
19704 +++ gcc-4.2.3/gcc/doc/extend.texi 2008-05-21 13:45:54.222289824 +0200
19705 @@ -1981,7 +1981,7 @@
19706
19707 @item interrupt
19708 @cindex interrupt handler functions
19709 -Use this attribute on the ARM, AVR, C4x, CRX, M32C, M32R/D, MS1, and Xstormy16
19710 +Use this attribute on the ARM, AVR, AVR32, C4x, CRX, M32C, M32R/D, MS1, and Xstormy16
19711 ports to indicate that the specified function is an interrupt handler.
19712 The compiler will generate function entry and exit sequences suitable
19713 for use in an interrupt handler when this attribute is present.
19714 @@ -2000,6 +2000,15 @@
19715
19716 Permissible values for this parameter are: IRQ, FIQ, SWI, ABORT and UNDEF@.
19717
19718 +Note, for the AVR32, you can specify which banking scheme is used for
19719 +the interrupt mode this interrupt handler is used in like this:
19720 +
19721 +@smallexample
19722 +void f () __attribute__ ((interrupt ("FULL")));
19723 +@end smallexample
19724 +
19725 +Permissible values for this parameter are: FULL, HALF, NONE and UNDEF.
19726 +
19727 @item interrupt_handler
19728 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
19729 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
19730 @@ -6175,6 +6184,7 @@
19731 @menu
19732 * Alpha Built-in Functions::
19733 * ARM Built-in Functions::
19734 +* AVR32 Built-in Functions::
19735 * Blackfin Built-in Functions::
19736 * FR-V Built-in Functions::
19737 * X86 Built-in Functions::
19738 @@ -6413,6 +6423,54 @@
19739 long long __builtin_arm_wzero ()
19740 @end smallexample
19741
19742 +@node AVR32 Built-in Functions
19743 +@subsection AVR32 Built-in Functions
19744 +
19745 +
19746 +@smallexample
19747 +
19748 +int __builtin_sats (int /*Rd*/,int /*sa*/, int /*bn*/)
19749 +int __builtin_satu (int /*Rd*/,int /*sa*/, int /*bn*/)
19750 +int __builtin_satrnds (int /*Rd*/,int /*sa*/, int /*bn*/)
19751 +int __builtin_satrndu (int /*Rd*/,int /*sa*/, int /*bn*/)
19752 +short __builtin_mulsathh_h (short, short)
19753 +int __builtin_mulsathh_w (short, short)
19754 +short __builtin_mulsatrndhh_h (short, short)
19755 +int __builtin_mulsatrndwh_w (int, short)
19756 +int __builtin_mulsatwh_w (int, short)
19757 +int __builtin_macsathh_w (int, short, short)
19758 +short __builtin_satadd_h (short, short)
19759 +short __builtin_satsub_h (short, short)
19760 +int __builtin_satadd_w (int, int)
19761 +int __builtin_satsub_w (int, int)
19762 +long long __builtin_mulwh_d(int, short)
19763 +long long __builtin_mulnwh_d(int, short)
19764 +long long __builtin_macwh_d(long long, int, short)
19765 +long long __builtin_machh_d(long long, short, short)
19766 +
19767 +void __builtin_musfr(int);
19768 +int __builtin_mustr(void);
19769 +int __builtin_mfsr(int /*Status Register Address*/)
19770 +void __builtin_mtsr(int /*Status Register Address*/, int /*Value*/)
19771 +int __builtin_mfdr(int /*Debug Register Address*/)
19772 +void __builtin_mtdr(int /*Debug Register Address*/, int /*Value*/)
19773 +void __builtin_cache(void * /*Address*/, int /*Cache Operation*/)
19774 +void __builtin_sync(int /*Sync Operation*/)
19775 +void __builtin_tlbr(void)
19776 +void __builtin_tlbs(void)
19777 +void __builtin_tlbw(void)
19778 +void __builtin_breakpoint(void)
19779 +int __builtin_xchg(void * /*Address*/, int /*Value*/ )
19780 +short __builtin_bswap_16(short)
19781 +int __builtin_bswap_32(int)
19782 +void __builtin_cop(int/*cpnr*/, int/*crd*/, int/*crx*/, int/*cry*/, int/*op*/)
19783 +int __builtin_mvcr_w(int/*cpnr*/, int/*crs*/)
19784 +void __builtin_mvrc_w(int/*cpnr*/, int/*crd*/, int/*value*/)
19785 +long long __builtin_mvcr_d(int/*cpnr*/, int/*crs*/)
19786 +void __builtin_mvrc_d(int/*cpnr*/, int/*crd*/, long long/*value*/)
19787 +
19788 +@end smallexample
19789 +
19790 @node Blackfin Built-in Functions
19791 @subsection Blackfin Built-in Functions
19792
19793 Index: gcc-4.2.3/gcc/doc/invoke.texi
19794 ===================================================================
19795 --- gcc-4.2.3.orig/gcc/doc/invoke.texi 2008-01-31 19:40:58.000000000 +0100
19796 +++ gcc-4.2.3/gcc/doc/invoke.texi 2008-05-21 13:45:54.274288067 +0200
19797 @@ -190,7 +190,7 @@
19798 -fno-default-inline -fvisibility-inlines-hidden @gol
19799 -Wabi -Wctor-dtor-privacy @gol
19800 -Wnon-virtual-dtor -Wreorder @gol
19801 --Weffc++ -Wno-deprecated -Wstrict-null-sentinel @gol
19802 +-Weffc++ -Wno-deprecated @gol
19803 -Wno-non-template-friend -Wold-style-cast @gol
19804 -Woverloaded-virtual -Wno-pmf-conversions @gol
19805 -Wsign-promo}
19806 @@ -590,6 +590,12 @@
19807 -mauto-incdec -minmax -mlong-calls -mshort @gol
19808 -msoft-reg-count=@var{count}}
19809
19810 +@emph{AVR32 Options}
19811 +@gccoptlist{-muse-rodata-section -mhard-float -msoft-float -mrelax @gol
19812 +-mforce-double-align -mno-init-got -mpart=@var{part} -mcpu=@var{cpu} @gol
19813 +-march=@var{arch} -mfast-float -masm-addr-pseudos -mno-asm-addr-pseudos -mno-pic
19814 +}
19815 +
19816 @emph{MCore Options}
19817 @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
19818 -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
19819 @@ -1869,14 +1875,6 @@
19820 @opindex Wno-deprecated
19821 Do not warn about usage of deprecated features. @xref{Deprecated Features}.
19822
19823 -@item -Wstrict-null-sentinel @r{(C++ only)}
19824 -@opindex Wstrict-null-sentinel
19825 -Warn also about the use of an uncasted @code{NULL} as sentinel. When
19826 -compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
19827 -to @code{__null}. Although it is a null pointer constant not a null pointer,
19828 -it is guaranteed to of the same size as a pointer. But this use is
19829 -not portable across different compilers.
19830 -
19831 @item -Wno-non-template-friend @r{(C++ only)}
19832 @opindex Wno-non-template-friend
19833 Disable warnings when non-templatized friend functions are declared
19834 @@ -2733,13 +2731,11 @@
19835 If you want to warn about code which uses the uninitialized value of the
19836 variable in its own initializer, use the @option{-Winit-self} option.
19837
19838 -These warnings occur for individual uninitialized or clobbered
19839 -elements of structure, union or array variables as well as for
19840 -variables which are uninitialized or clobbered as a whole. They do
19841 -not occur for variables or elements declared @code{volatile}. Because
19842 -these warnings depend on optimization, the exact variables or elements
19843 -for which there are warnings will depend on the precise optimization
19844 -options and version of GCC used.
19845 +These warnings occur only for variables that are candidates for
19846 +register allocation. Therefore, they do not occur for a variable that
19847 +is declared @code{volatile}, or whose address is taken, or whose size
19848 +is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
19849 +structures, unions or arrays, even when they are in registers.
19850
19851 Note that there may be no warning about a variable that is used only
19852 to compute a value that itself is never used, because such
19853 @@ -6228,10 +6224,6 @@
19854 we always try to remove unnecessary ivs from the set during its
19855 optimization when a new iv is added to the set.
19856
19857 -@item scev-max-expr-size
19858 -Bound on size of expressions used in the scalar evolutions analyzer.
19859 -Large expressions slow the analyzer.
19860 -
19861 @item vect-max-version-checks
19862 The maximum number of runtime checks that can be performed when doing
19863 loop versioning in the vectorizer. See option ftree-vect-loop-version
19864 @@ -7429,7 +7421,7 @@
19865 * ARC Options::
19866 * ARM Options::
19867 * AVR Options::
19868 -* Blackfin Options::
19869 +* AVR32 Options::
19870 * CRIS Options::
19871 * CRX Options::
19872 * Darwin Options::
19873 @@ -7894,81 +7886,68 @@
19874 size.
19875 @end table
19876
19877 -@node Blackfin Options
19878 -@subsection Blackfin Options
19879 -@cindex Blackfin Options
19880 +@node AVR32 Options
19881 +@subsection AVR32 Options
19882 +@cindex AVR32 Options
19883 +
19884 +These options are defined for AVR32 implementations:
19885
19886 @table @gcctabopt
19887 -@item -momit-leaf-frame-pointer
19888 -@opindex momit-leaf-frame-pointer
19889 -Don't keep the frame pointer in a register for leaf functions. This
19890 -avoids the instructions to save, set up and restore frame pointers and
19891 -makes an extra register available in leaf functions. The option
19892 -@option{-fomit-frame-pointer} removes the frame pointer for all functions
19893 -which might make debugging harder.
19894 +@item -muse-rodata-section
19895 +@opindex muse-rodata-section
19896 +Use section @samp{.rodata} for read-only data instead of @samp{.text}.
19897
19898 -@item -mspecld-anomaly
19899 -@opindex mspecld-anomaly
19900 -When enabled, the compiler will ensure that the generated code does not
19901 -contain speculative loads after jump instructions. This option is enabled
19902 -by default.
19903 -
19904 -@item -mno-specld-anomaly
19905 -@opindex mno-specld-anomaly
19906 -Don't generate extra code to prevent speculative loads from occurring.
19907 -
19908 -@item -mcsync-anomaly
19909 -@opindex mcsync-anomaly
19910 -When enabled, the compiler will ensure that the generated code does not
19911 -contain CSYNC or SSYNC instructions too soon after conditional branches.
19912 -This option is enabled by default.
19913 -
19914 -@item -mno-csync-anomaly
19915 -@opindex mno-csync-anomaly
19916 -Don't generate extra code to prevent CSYNC or SSYNC instructions from
19917 -occurring too soon after a conditional branch.
19918 -
19919 -@item -mlow-64k
19920 -@opindex mlow-64k
19921 -When enabled, the compiler is free to take advantage of the knowledge that
19922 -the entire program fits into the low 64k of memory.
19923 -
19924 -@item -mno-low-64k
19925 -@opindex mno-low-64k
19926 -Assume that the program is arbitrarily large. This is the default.
19927 +@item -mrelax
19928 +@opindex mrelax
19929 +Enable relaxing in linker. This means that when the address of symbols
19930 +are known at link time, the linker can optimize @samp{icall} and @samp{mcall}
19931 +instructions into a @samp{rcall} instruction if possible. Loading the address
19932 +of a symbol can also be optimized.
19933 +
19934 +@item -mforce-double-align
19935 +@opindex mforce-double-align
19936 +Force double-word alignment for double-word memory accesses.
19937 +
19938 +@item -mno-init-got
19939 +@opindex mno-init-got
19940 +Do not initialize the GOT register before using it when compiling PIC
19941 +code.
19942
19943 -@item -mid-shared-library
19944 -@opindex mid-shared-library
19945 -Generate code that supports shared libraries via the library ID method.
19946 -This allows for execute in place and shared libraries in an environment
19947 -without virtual memory management. This option implies @option{-fPIC}.
19948 +@item -mno-pic
19949 +@opindex mno-pic
19950 +Do not emit position-independent code (will break dynamic linking.)
19951
19952 -@item -mno-id-shared-library
19953 -@opindex mno-id-shared-library
19954 -Generate code that doesn't assume ID based shared libraries are being used.
19955 -This is the default.
19956 +@item -masm-addr-pseudos
19957 +@opindex masm-addr-pseudos
19958 +Use assembler pseudo-instructions lda.w and call for handling direct
19959 +addresses. (Enabled by default)
19960 +
19961 +@item -mno-asm-addr-pseudos
19962 +@opindex mno-asm-addr-pseudos
19963 +Do not use assembler pseudo-instructions lda.w and call for handling direct addresses.
19964 +
19965 +@item -mpart=@var{part}
19966 +@opindex mpart
19967 +Generate code for the specified part. Permissible parts are: @samp{ap7000},
19968 +@samp{ap7010},@samp{ap7020},@samp{uc3a0256}, @samp{uc3a0512},
19969 +@samp{uc3a1128}, @samp{uc3a1256}, @samp{uc3a1512}.
19970
19971 -@item -mshared-library-id=n
19972 -@opindex mshared-library-id
19973 -Specified the identification number of the ID based shared library being
19974 -compiled. Specifying a value of 0 will generate more compact code, specifying
19975 -other values will force the allocation of that number to the current
19976 -library but is no more space or time efficient than omitting this option.
19977 +@item -mcpu=@var{cpu-type}
19978 +@opindex mcpu
19979 +Same as -mpart. Obsolete.
19980 +
19981 +@item -march=@var{arch}
19982 +@opindex march
19983 +Generate code for the specified architecture. Permissible architectures are:
19984 +@samp{ap} and @samp{uc}.
19985 +
19986 +@item -mfast-float
19987 +@opindex mfast-float
19988 +Enable fast floating-point library that does not conform to ieee but is still good enough
19989 +for most applications. The fast floating-point library does not round to the nearest even
19990 +but away from zero. Enabled by default if the -funsafe-math-optimizations switch is specified.
19991
19992 -@item -mlong-calls
19993 -@itemx -mno-long-calls
19994 -@opindex mlong-calls
19995 -@opindex mno-long-calls
19996 -Tells the compiler to perform function calls by first loading the
19997 -address of the function into a register and then performing a subroutine
19998 -call on this register. This switch is needed if the target function
19999 -will lie outside of the 24 bit addressing range of the offset based
20000 -version of subroutine call instruction.
20001
20002 -This feature is not enabled by default. Specifying
20003 -@option{-mno-long-calls} will restore the default behavior. Note these
20004 -switches have no effect on how the compiler generates code to handle
20005 -function calls via function pointers.
20006 @end table
20007
20008 @node CRIS Options
20009 @@ -11879,6 +11858,7 @@
20010 Application Binary Interface, PowerPC processor supplement. This is the
20011 default unless you configured GCC using @samp{powerpc-*-eabiaix}.
20012
20013 +
20014 @item -mcall-sysv-eabi
20015 @opindex mcall-sysv-eabi
20016 Specify both @option{-mcall-sysv} and @option{-meabi} options.
20017 @@ -14181,4 +14161,4 @@
20018 exist, because otherwise they won't get converted.
20019
20020 @xref{Protoize Caveats}, for more information on how to use
20021 -@code{protoize} successfully.
20022 +@code{protoize} successfully.
20023 \ No newline at end of file
20024 Index: gcc-4.2.3/gcc/doc/md.texi
20025 ===================================================================
20026 --- gcc-4.2.3.orig/gcc/doc/md.texi 2007-04-04 03:24:10.000000000 +0200
20027 +++ gcc-4.2.3/gcc/doc/md.texi 2008-05-21 13:45:54.302287723 +0200
20028 @@ -3,6 +3,7 @@
20029 @c This is part of the GCC manual.
20030 @c For copying conditions, see the file gcc.texi.
20031
20032 +
20033 @ifset INTERNALS
20034 @node Machine Desc
20035 @chapter Machine Descriptions
20036 @@ -1681,6 +1682,58 @@
20037 A memory reference suitable for the ARMv4 ldrsb instruction.
20038 @end table
20039
20040 +@item AVR32 family---@file{avr32.h}
20041 +@table @code
20042 +@item f
20043 +Floating-point registers (f0 to f15)
20044 +
20045 +@item Ku@var{bits}
20046 +Unsigned constant representable with @var{bits} number of bits (Must be
20047 +two digits). I.e: An unsigned 8-bit constant is written as @samp{Ku08}
20048 +
20049 +@item Ks@var{bits}
20050 +Signed constant representable with @var{bits} number of bits (Must be
20051 +two digits). I.e: A signed 12-bit constant is written as @samp{Ks12}
20052 +
20053 +@item Is@var{bits}
20054 +The negated range of a signed constant representable with @var{bits}
20055 +number of bits. The same as @samp{Ks@var{bits}} with a negated range.
20056 +This means that the constant must be in the range @math{-2^{bits-1}-1} to @math{2^{bits-1}}
20057 +
20058 +@item G
20059 +A single/double precision floating-point immediate or 64-bit integer
20060 +immediate where the least and most significant words both can be
20061 +loaded with a move instruction. That is the the integer form of the
20062 +values in the least and most significant words both are in the range
20063 +@math{-2^{20}} to @math{2^{20}-1}.
20064 +
20065 +@item RKs@var{bits}
20066 +A memory reference where the address consists of a base register
20067 +plus a signed immediate displacement with range given by @samp{Ks@var{bits}}
20068 +which has the same format as for the signed immediate integer constraint
20069 +given above.
20070 +
20071 +@item RKu@var{bits}
20072 +A memory reference where the address consists of a base register
20073 +plus an unsigned immediate displacement with range given by @samp{Ku@var{bits}}
20074 +which has the same format as for the unsigned immediate integer constraint
20075 +given above.
20076 +
20077 +@item S
20078 +A memory reference with an immediate or register offset
20079 +
20080 +@item T
20081 +A memory reference to a constant pool entry
20082 +
20083 +@item W
20084 +A valid operand for use in the @samp{lda.w} instruction macro when
20085 +relaxing is enabled
20086 +
20087 +@item Z
20088 +A memory reference valid for coprocessor memory instructions
20089 +
20090 +@end table
20091 +
20092 @item AVR family---@file{config/avr/constraints.md}
20093 @table @code
20094 @item l
20095 Index: gcc-4.2.3/gcc/expmed.c
20096 ===================================================================
20097 --- gcc-4.2.3.orig/gcc/expmed.c 2007-09-01 17:28:30.000000000 +0200
20098 +++ gcc-4.2.3/gcc/expmed.c 2008-05-21 13:45:54.306288512 +0200
20099 @@ -36,6 +36,7 @@
20100 #include "real.h"
20101 #include "recog.h"
20102 #include "langhooks.h"
20103 +#include "target.h"
20104
20105 static void store_fixed_bit_field (rtx, unsigned HOST_WIDE_INT,
20106 unsigned HOST_WIDE_INT,
20107 @@ -454,9 +455,18 @@
20108 ? ((GET_MODE_SIZE (fieldmode) >= UNITS_PER_WORD
20109 || GET_MODE_SIZE (GET_MODE (op0)) == GET_MODE_SIZE (fieldmode))
20110 && byte_offset % GET_MODE_SIZE (fieldmode) == 0)
20111 - : (! SLOW_UNALIGNED_ACCESS (fieldmode, MEM_ALIGN (op0))
20112 - || (offset * BITS_PER_UNIT % bitsize == 0
20113 - && MEM_ALIGN (op0) % GET_MODE_BITSIZE (fieldmode) == 0))))
20114 + : (
20115 +
20116 + /* NB! Added for AVR32, and I think this should be true for
20117 + all targets not using narrow volatile bitfields. If the
20118 + bitfield is volatile then we need to perform an access
20119 + consistent with the container type. */
20120 + !(MEM_VOLATILE_P (op0)
20121 + && GET_MODE_BITSIZE (GET_MODE (op0)) != bitsize
20122 + && !targetm.narrow_volatile_bitfield ())
20123 + && (! SLOW_UNALIGNED_ACCESS (fieldmode, MEM_ALIGN (op0))
20124 + || (offset * BITS_PER_UNIT % bitsize == 0
20125 + && MEM_ALIGN (op0) % GET_MODE_BITSIZE (fieldmode) == 0)))))
20126 {
20127 if (MEM_P (op0))
20128 op0 = adjust_address (op0, fieldmode, offset);
20129 @@ -1256,6 +1266,13 @@
20130 && GET_MODE_SIZE (mode1) != 0
20131 && byte_offset % GET_MODE_SIZE (mode1) == 0)
20132 || (MEM_P (op0)
20133 + /* NB! Added for AVR32, and I think this should be true for
20134 + all targets not using narrow volatile bitfields. If the
20135 + bitfield is volatile then we need to perform an access
20136 + consistent with the container type. */
20137 + && !(MEM_VOLATILE_P (op0)
20138 + && GET_MODE_BITSIZE (GET_MODE (op0)) != bitsize
20139 + && !targetm.narrow_volatile_bitfield ())
20140 && (! SLOW_UNALIGNED_ACCESS (mode, MEM_ALIGN (op0))
20141 || (offset * BITS_PER_UNIT % bitsize == 0
20142 && MEM_ALIGN (op0) % bitsize == 0)))))
20143 Index: gcc-4.2.3/gcc/expr.c
20144 ===================================================================
20145 --- gcc-4.2.3.orig/gcc/expr.c 2008-01-22 20:39:39.000000000 +0100
20146 +++ gcc-4.2.3/gcc/expr.c 2008-05-21 13:45:54.330288217 +0200
20147 @@ -3549,18 +3549,19 @@
20148 }
20149 else
20150 {
20151 + emit_move_insn (stack_pointer_rtx,
20152 + expand_binop (Pmode,
20153 #ifdef STACK_GROWS_DOWNWARD
20154 - /* ??? This seems wrong if STACK_PUSH_CODE == POST_DEC. */
20155 - dest_addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
20156 - GEN_INT (-(HOST_WIDE_INT) rounded_size));
20157 + sub_optab,
20158 #else
20159 - /* ??? This seems wrong if STACK_PUSH_CODE == POST_INC. */
20160 - dest_addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
20161 - GEN_INT (rounded_size));
20162 + add_optab,
20163 #endif
20164 - dest_addr = gen_rtx_PRE_MODIFY (Pmode, stack_pointer_rtx, dest_addr);
20165 + stack_pointer_rtx,
20166 + GEN_INT (rounded_size),
20167 + NULL_RTX, 0, OPTAB_LIB_WIDEN));
20168 + dest_addr = stack_pointer_rtx;
20169 }
20170 -
20171 +
20172 dest = gen_rtx_MEM (mode, dest_addr);
20173
20174 if (type != 0)
20175 @@ -5539,7 +5540,16 @@
20176 is a bit field, we cannot use addressing to access it.
20177 Use bit-field techniques or SUBREG to store in it. */
20178
20179 - if (mode == VOIDmode
20180 + if (
20181 + /* NB! Added for AVR32, and I think this should be true for
20182 + all targets not using narrow volatile bitfields. If the
20183 + bitfield is volatile then we need to perform an access
20184 + consistent with the container type. */
20185 + (MEM_P (target)
20186 + && MEM_VOLATILE_P (target)
20187 + && GET_MODE_BITSIZE (GET_MODE (target)) > bitsize
20188 + && !targetm.narrow_volatile_bitfield ())
20189 + || mode == VOIDmode
20190 || (mode != BLKmode && ! direct_store[(int) mode]
20191 && GET_MODE_CLASS (mode) != MODE_COMPLEX_INT
20192 && GET_MODE_CLASS (mode) != MODE_COMPLEX_FLOAT)
20193 @@ -7590,7 +7600,16 @@
20194 by doing the extract into an object as wide as the field
20195 (which we know to be the width of a basic mode), then
20196 storing into memory, and changing the mode to BLKmode. */
20197 - if (mode1 == VOIDmode
20198 + if (
20199 + /* NB! Added for AVR32, and I think this should be true for
20200 + all targets not using narrow volatile bitfields. If the
20201 + bitfield is volatile then we need to perform an access
20202 + consistent with the container type. */
20203 + (MEM_P (op0)
20204 + && MEM_VOLATILE_P (op0)
20205 + && GET_MODE_BITSIZE (GET_MODE (op0)) > bitsize
20206 + && !targetm.narrow_volatile_bitfield ())
20207 + || mode1 == VOIDmode
20208 || REG_P (op0) || GET_CODE (op0) == SUBREG
20209 || (mode1 != BLKmode && ! direct_load[(int) mode1]
20210 && GET_MODE_CLASS (mode) != MODE_COMPLEX_INT
20211 Index: gcc-4.2.3/gcc/function.c
20212 ===================================================================
20213 --- gcc-4.2.3.orig/gcc/function.c 2007-09-01 17:28:30.000000000 +0200
20214 +++ gcc-4.2.3/gcc/function.c 2008-05-21 13:45:54.334287888 +0200
20215 @@ -2676,8 +2676,12 @@
20216 SET_DECL_RTL (parm, parmreg);
20217
20218 /* Copy the value into the register. */
20219 - if (data->nominal_mode != data->passed_mode
20220 - || promoted_nominal_mode != data->promoted_mode)
20221 + if ( (data->nominal_mode != data->passed_mode
20222 + /* Added for AVR32: If passed_mode is equal
20223 + to promoted nominal mode why should be convert?
20224 + The conversion should make no difference. */
20225 + && data->passed_mode != promoted_nominal_mode)
20226 + || promoted_nominal_mode != data->promoted_mode)
20227 {
20228 int save_tree_used;
20229
20230 Index: gcc-4.2.3/gcc/genemit.c
20231 ===================================================================
20232 --- gcc-4.2.3.orig/gcc/genemit.c 2007-09-01 17:28:30.000000000 +0200
20233 +++ gcc-4.2.3/gcc/genemit.c 2008-05-21 13:45:54.342288908 +0200
20234 @@ -121,6 +121,24 @@
20235 }
20236 \f
20237 static void
20238 +gen_vararg_prologue(int operands)
20239 +{
20240 + int i;
20241 +
20242 + if (operands > 1)
20243 + {
20244 + for (i = 1; i < operands; i++)
20245 + printf(" rtx operand%d ATTRIBUTE_UNUSED;\n", i);
20246 +
20247 + printf(" va_list args;\n\n");
20248 + printf(" va_start(args, operand0);\n");
20249 + for (i = 1; i < operands; i++)
20250 + printf(" operand%d = va_arg(args, rtx);\n", i);
20251 + printf(" va_end(args);\n\n");
20252 + }
20253 +}
20254 +
20255 +static void
20256 print_code (RTX_CODE code)
20257 {
20258 const char *p1;
20259 @@ -405,18 +423,16 @@
20260 fatal ("match_dup operand number has no match_operand");
20261
20262 /* Output the function name and argument declarations. */
20263 - printf ("rtx\ngen_%s (", XSTR (insn, 0));
20264 + printf ("rtx\ngen_%s ", XSTR (insn, 0));
20265 +
20266 if (operands)
20267 - for (i = 0; i < operands; i++)
20268 - if (i)
20269 - printf (",\n\trtx operand%d ATTRIBUTE_UNUSED", i);
20270 - else
20271 - printf ("rtx operand%d ATTRIBUTE_UNUSED", i);
20272 + printf("(rtx operand0 ATTRIBUTE_UNUSED, ...)\n");
20273 else
20274 - printf ("void");
20275 - printf (")\n");
20276 + printf("(void)\n");
20277 printf ("{\n");
20278
20279 + gen_vararg_prologue(operands);
20280 +
20281 /* Output code to construct and return the rtl for the instruction body. */
20282
20283 if (XVECLEN (insn, 1) == 1)
20284 @@ -456,16 +472,12 @@
20285 operands = max_operand_vec (expand, 1);
20286
20287 /* Output the function name and argument declarations. */
20288 - printf ("rtx\ngen_%s (", XSTR (expand, 0));
20289 + printf ("rtx\ngen_%s ", XSTR (expand, 0));
20290 if (operands)
20291 - for (i = 0; i < operands; i++)
20292 - if (i)
20293 - printf (",\n\trtx operand%d", i);
20294 - else
20295 - printf ("rtx operand%d", i);
20296 + printf("(rtx operand0 ATTRIBUTE_UNUSED, ...)\n");
20297 else
20298 - printf ("void");
20299 - printf (")\n");
20300 + printf("(void)\n");
20301 +
20302 printf ("{\n");
20303
20304 /* If we don't have any C code to write, only one insn is being written,
20305 @@ -475,6 +487,8 @@
20306 && operands > max_dup_opno
20307 && XVECLEN (expand, 1) == 1)
20308 {
20309 + gen_vararg_prologue(operands);
20310 +
20311 printf (" return ");
20312 gen_exp (XVECEXP (expand, 1, 0), DEFINE_EXPAND, NULL);
20313 printf (";\n}\n\n");
20314 @@ -488,6 +502,7 @@
20315 for (; i <= max_scratch_opno; i++)
20316 printf (" rtx operand%d ATTRIBUTE_UNUSED;\n", i);
20317 printf (" rtx _val = 0;\n");
20318 + gen_vararg_prologue(operands);
20319 printf (" start_sequence ();\n");
20320
20321 /* The fourth operand of DEFINE_EXPAND is some code to be executed
20322 Index: gcc-4.2.3/gcc/genflags.c
20323 ===================================================================
20324 --- gcc-4.2.3.orig/gcc/genflags.c 2007-09-01 17:28:30.000000000 +0200
20325 +++ gcc-4.2.3/gcc/genflags.c 2008-05-21 13:45:54.346288020 +0200
20326 @@ -127,7 +127,6 @@
20327 gen_proto (rtx insn)
20328 {
20329 int num = num_operands (insn);
20330 - int i;
20331 const char *name = XSTR (insn, 0);
20332 int truth = maybe_eval_c_test (XSTR (insn, 2));
20333
20334 @@ -158,12 +157,7 @@
20335 if (num == 0)
20336 fputs ("void", stdout);
20337 else
20338 - {
20339 - for (i = 1; i < num; i++)
20340 - fputs ("rtx, ", stdout);
20341 -
20342 - fputs ("rtx", stdout);
20343 - }
20344 + fputs("rtx, ...", stdout);
20345
20346 puts (");");
20347
20348 @@ -173,12 +167,7 @@
20349 {
20350 printf ("static inline rtx\ngen_%s", name);
20351 if (num > 0)
20352 - {
20353 - putchar ('(');
20354 - for (i = 0; i < num-1; i++)
20355 - printf ("rtx ARG_UNUSED (%c), ", 'a' + i);
20356 - printf ("rtx ARG_UNUSED (%c))\n", 'a' + i);
20357 - }
20358 + puts("(rtx ARG_UNUSED(a), ...)");
20359 else
20360 puts ("(void)");
20361 puts ("{\n return 0;\n}");
20362 Index: gcc-4.2.3/gcc/genoutput.c
20363 ===================================================================
20364 --- gcc-4.2.3.orig/gcc/genoutput.c 2007-09-01 17:28:30.000000000 +0200
20365 +++ gcc-4.2.3/gcc/genoutput.c 2008-05-21 13:45:54.354290436 +0200
20366 @@ -386,7 +386,7 @@
20367 }
20368
20369 if (d->name && d->name[0] != '*')
20370 - printf (" (insn_gen_fn) gen_%s,\n", d->name);
20371 + printf (" gen_%s,\n", d->name);
20372 else
20373 printf (" 0,\n");
20374
20375 Index: gcc-4.2.3/gcc/ifcvt.c
20376 ===================================================================
20377 --- gcc-4.2.3.orig/gcc/ifcvt.c 2007-10-30 05:32:06.000000000 +0100
20378 +++ gcc-4.2.3/gcc/ifcvt.c 2008-05-21 13:45:54.358287873 +0200
20379 @@ -1050,7 +1050,11 @@
20380 != UNKNOWN))
20381 {
20382 rtx cond = if_info->cond;
20383 - enum rtx_code code = reversed_comparison_code (cond, if_info->jump);
20384 + /* This generates wrong code for AVR32. The cond code need not be reversed
20385 + since the addmodecc patterns add if the condition is NOT met. */
20386 + /* enum rtx_code code = reversed_comparison_code (cond, if_info->jump);*/
20387 + enum rtx_code code = GET_CODE(cond);
20388 +
20389
20390 /* First try to use addcc pattern. */
20391 if (general_operand (XEXP (cond, 0), VOIDmode)
20392 Index: gcc-4.2.3/gcc/longlong.h
20393 ===================================================================
20394 --- gcc-4.2.3.orig/gcc/longlong.h 2007-09-01 17:28:30.000000000 +0200
20395 +++ gcc-4.2.3/gcc/longlong.h 2008-05-21 13:45:54.358287873 +0200
20396 @@ -226,6 +226,39 @@
20397 #define UDIV_TIME 100
20398 #endif /* __arm__ */
20399
20400 +#if defined (__avr32__) && W_TYPE_SIZE == 32
20401 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
20402 + __asm__ ("add\t%1, %4, %5\n\tadc\t%0, %2, %3" \
20403 + : "=r" ((USItype) (sh)), \
20404 + "=&r" ((USItype) (sl)) \
20405 + : "r" ((USItype) (ah)), \
20406 + "r" ((USItype) (bh)), \
20407 + "r" ((USItype) (al)), \
20408 + "r" ((USItype) (bl)) __CLOBBER_CC)
20409 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
20410 + __asm__ ("sub\t%1, %4, %5\n\tsbc\t%0, %2, %3" \
20411 + : "=r" ((USItype) (sh)), \
20412 + "=&r" ((USItype) (sl)) \
20413 + : "r" ((USItype) (ah)), \
20414 + "r" ((USItype) (bh)), \
20415 + "r" ((USItype) (al)), \
20416 + "r" ((USItype) (bl)) __CLOBBER_CC)
20417 +
20418 +#define __umulsidi3(a,b) ((UDItype)(a) * (UDItype)(b))
20419 +
20420 +#define umul_ppmm(w1, w0, u, v) \
20421 +{ \
20422 + DWunion __w; \
20423 + __w.ll = __umulsidi3 (u, v); \
20424 + w1 = __w.s.high; \
20425 + w0 = __w.s.low; \
20426 +}
20427 +
20428 +#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X))
20429 +#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctz (X))
20430 +#define COUNT_LEADING_ZEROS_0 32
20431 +#endif
20432 +
20433 #if defined (__hppa) && W_TYPE_SIZE == 32
20434 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
20435 __asm__ ("add %4,%5,%1\n\taddc %2,%3,%0" \
20436 Index: gcc-4.2.3/gcc/optabs.h
20437 ===================================================================
20438 --- gcc-4.2.3.orig/gcc/optabs.h 2007-09-01 17:28:30.000000000 +0200
20439 +++ gcc-4.2.3/gcc/optabs.h 2008-05-21 13:45:54.358287873 +0200
20440 @@ -431,7 +431,7 @@
20441 extern GTY(()) optab code_to_optab[NUM_RTX_CODE + 1];
20442
20443 \f
20444 -typedef rtx (*rtxfun) (rtx);
20445 +typedef rtx (*rtxfun) (rtx, ...);
20446
20447 /* Indexed by the rtx-code for a conditional (e.g. EQ, LT,...)
20448 gives the gen_function to make a branch to test that condition. */
20449 Index: gcc-4.2.3/gcc/testsuite/gcc.dg/cpp/mac-eol-at-eof.c
20450 ===================================================================
20451 --- gcc-4.2.3.orig/gcc/testsuite/gcc.dg/cpp/mac-eol-at-eof.c 2005-02-19 20:48:02.000000000 +0100
20452 +++ gcc-4.2.3/gcc/testsuite/gcc.dg/cpp/mac-eol-at-eof.c 2008-05-21 13:45:54.358287873 +0200
20453 @@ -1 +1,3 @@
20454 -/* Test no newline at eof warning when Mac line ending is used*/ /* { dg-do compile } */ int main() { return 0; }
20455 \ No newline at end of file
20456 +/* Test no newline at eof warning when Mac line ending is used*/
20457 +/* { dg-do compile } */
20458 +int main() { return 0; }
20459 Index: gcc-4.2.3/gcc/testsuite/gcc.dg/sibcall-3.c
20460 ===================================================================
20461 --- gcc-4.2.3.orig/gcc/testsuite/gcc.dg/sibcall-3.c 2005-07-20 08:39:38.000000000 +0200
20462 +++ gcc-4.2.3/gcc/testsuite/gcc.dg/sibcall-3.c 2008-05-21 13:45:54.358287873 +0200
20463 @@ -5,7 +5,7 @@
20464 Copyright (C) 2002 Free Software Foundation Inc.
20465 Contributed by Hans-Peter Nilsson <hp@bitrange.com> */
20466
20467 -/* { dg-do run { xfail arc-*-* avr-*-* c4x-*-* cris-*-* h8300-*-* hppa*64*-*-* m32r-*-* m68hc1?-*-* m681?-*-* m680*-*-* m68k-*-* mcore-*-* mn10300-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa-*-* } } */
20468 +/* { dg-do run { xfail arc-*-* avr-*-* avr32-*-* c4x-*-* cris-*-* h8300-*-* hppa*64*-*-* m32r-*-* m68hc1?-*-* m681?-*-* m680*-*-* m68k-*-* mcore-*-* mn10300-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa-*-* } } */
20469 /* { dg-options "-O2 -foptimize-sibling-calls" } */
20470
20471 /* The option -foptimize-sibling-calls is the default, but serves as
20472 Index: gcc-4.2.3/gcc/testsuite/gcc.dg/sibcall-4.c
20473 ===================================================================
20474 --- gcc-4.2.3.orig/gcc/testsuite/gcc.dg/sibcall-4.c 2005-07-20 08:39:38.000000000 +0200
20475 +++ gcc-4.2.3/gcc/testsuite/gcc.dg/sibcall-4.c 2008-05-21 13:45:54.362288662 +0200
20476 @@ -5,7 +5,7 @@
20477 Copyright (C) 2002 Free Software Foundation Inc.
20478 Contributed by Hans-Peter Nilsson <hp@bitrange.com> */
20479
20480 -/* { dg-do run { xfail arc-*-* avr-*-* c4x-*-* cris-*-* h8300-*-* hppa*64*-*-* m32r-*-* m68hc1?-*-* m681?-*-* m680*-*-* m68k-*-* mcore-*-* mn10300-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa-*-* } } */
20481 +/* { dg-do run { xfail arc-*-* avr-*-* avr32-*-* c4x-*-* cris-*-* h8300-*-* hppa*64*-*-* m32r-*-* m68hc1?-*-* m681?-*-* m680*-*-* m68k-*-* mcore-*-* mn10300-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa-*-* } } */
20482 /* { dg-options "-O2 -foptimize-sibling-calls" } */
20483
20484 /* The option -foptimize-sibling-calls is the default, but serves as
20485 Index: gcc-4.2.3/gcc/testsuite/gcc.dg/trampoline-1.c
20486 ===================================================================
20487 --- gcc-4.2.3.orig/gcc/testsuite/gcc.dg/trampoline-1.c 2004-08-03 10:22:26.000000000 +0200
20488 +++ gcc-4.2.3/gcc/testsuite/gcc.dg/trampoline-1.c 2008-05-21 13:45:54.362288662 +0200
20489 @@ -46,6 +46,8 @@
20490
20491 int main (void)
20492 {
20493 +#ifndef NO_TRAMPOLINES
20494 foo ();
20495 +#endif
20496 return 0;
20497 }
20498 Index: gcc-4.2.3/gcc/testsuite/gfortran.dg/char_pointer_assign.f90
20499 ===================================================================
20500 --- gcc-4.2.3.orig/gcc/testsuite/gfortran.dg/char_pointer_assign.f90 2005-05-29 18:03:43.000000000 +0200
20501 +++ gcc-4.2.3/gcc/testsuite/gfortran.dg/char_pointer_assign.f90 2008-05-21 13:45:54.362288662 +0200
20502 @@ -1,4 +1,4 @@
20503 -! { dg-do run }
20504 +! { dg-do run }
20505 program char_pointer_assign
20506 ! Test character pointer assignments, required
20507 ! to fix PR18890 and PR21297
20508 @@ -8,7 +8,7 @@
20509 character*4, target :: t2(4) =(/"lmno","lmno","lmno","lmno"/)
20510 character*4 :: const
20511 character*4, pointer :: c1, c3
20512 - character*4, pointer :: c2(:), c4(:)
20513 + character*4, pointer :: c2(:), c4(:)
20514 allocate (c3, c4(4))
20515 ! Scalars first.
20516 c3 = "lmno" ! pointer = constant
20517 @@ -24,13 +24,13 @@
20518
20519 ! Now arrays.
20520 c4 = "lmno" ! pointer = constant
20521 - t2 = c4 ! target = pointer
20522 - c2 => t2 ! pointer =>target
20523 - const = c2(1)
20524 + t2 = c4 ! target = pointer
20525 + c2 => t2 ! pointer =>target
20526 + const = c2(1)
20527 const(2:3) ="nm" ! c2(:)(2:3) = "nm" is still broken
20528 c2 = const
20529 c4 = c2 ! pointer = pointer
20530 - const = c4(1)
20531 + const = c4(1)
20532 const(1:1) ="o" ! c4(:)(1:1) = "o" is still broken
20533 const(4:4) ="l" ! c4(:)(4:4) = "l" is still broken
20534 c4 = const
20535 Index: gcc-4.2.3/gcc/testsuite/g++.old-deja/g++.pt/static11.C
20536 ===================================================================
20537 --- gcc-4.2.3.orig/gcc/testsuite/g++.old-deja/g++.pt/static11.C 2006-02-22 10:05:07.000000000 +0100
20538 +++ gcc-4.2.3/gcc/testsuite/g++.old-deja/g++.pt/static11.C 2008-05-21 13:45:54.362288662 +0200
20539 @@ -2,7 +2,7 @@
20540 // in their dejagnu baseboard description) require that the status is
20541 // final when exit is entered (or main returns), and not "overruled" by a
20542 // destructor calling _exit. It's not really worth it to handle that.
20543 -// { dg-do run { xfail mmix-knuth-mmixware xtensa-*-elf* arm*-*-elf arm*-*-eabi m68k-*-elf } }
20544 +// { dg-do run { xfail mmix-knuth-mmixware xtensa-*-elf* avr32-*-elf arm*-*-elf arm*-*-eabi m68k-*-elf } }
20545
20546 // Bug: g++ was failing to destroy C<int>::a because it was using two
20547 // different sentry variables for construction and destruction.
20548 Index: gcc-4.2.3/libjava/classpath/external/relaxngDatatype/copying.txt
20549 ===================================================================
20550 --- gcc-4.2.3.orig/libjava/classpath/external/relaxngDatatype/copying.txt 2006-03-10 14:25:35.000000000 +0100
20551 +++ gcc-4.2.3/libjava/classpath/external/relaxngDatatype/copying.txt 2008-05-21 13:45:54.362288662 +0200
20552 @@ -1,30 +1,30 @@
20553 -Copyright (c) 2001, Thai Open Source Software Center Ltd, Sun Microsystems.
20554 -All rights reserved.
20555 -
20556 -Redistribution and use in source and binary forms, with or without
20557 -modification, are permitted provided that the following conditions are
20558 -met:
20559 -
20560 - Redistributions of source code must retain the above copyright
20561 - notice, this list of conditions and the following disclaimer.
20562 -
20563 - Redistributions in binary form must reproduce the above copyright
20564 - notice, this list of conditions and the following disclaimer in
20565 - the documentation and/or other materials provided with the
20566 - distribution.
20567 -
20568 - Neither the names of the copyright holders nor the names of its
20569 - contributors may be used to endorse or promote products derived
20570 - from this software without specific prior written permission.
20571 -
20572 -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20573 -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20574 -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20575 -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
20576 -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20577 -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20578 -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20579 -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
20580 -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20581 -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
20582 -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20583 +Copyright (c) 2001, Thai Open Source Software Center Ltd, Sun Microsystems.
20584 +All rights reserved.
20585 +
20586 +Redistribution and use in source and binary forms, with or without
20587 +modification, are permitted provided that the following conditions are
20588 +met:
20589 +
20590 + Redistributions of source code must retain the above copyright
20591 + notice, this list of conditions and the following disclaimer.
20592 +
20593 + Redistributions in binary form must reproduce the above copyright
20594 + notice, this list of conditions and the following disclaimer in
20595 + the documentation and/or other materials provided with the
20596 + distribution.
20597 +
20598 + Neither the names of the copyright holders nor the names of its
20599 + contributors may be used to endorse or promote products derived
20600 + from this software without specific prior written permission.
20601 +
20602 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20603 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20604 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20605 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
20606 +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20607 +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20608 +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20609 +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
20610 +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20611 +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
20612 +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20613 Index: gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeBuilder.java
20614 ===================================================================
20615 --- gcc-4.2.3.orig/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeBuilder.java 2006-03-10 14:25:35.000000000 +0100
20616 +++ gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeBuilder.java 2008-05-21 13:45:54.362288662 +0200
20617 @@ -1,45 +1,45 @@
20618 -package org.relaxng.datatype;
20619 -
20620 -/**
20621 - * Creates a user-defined type by adding parameters to
20622 - * the pre-defined type.
20623 - *
20624 - * @author <a href="mailto:jjc@jclark.com">James Clark</a>
20625 - * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
20626 - */
20627 -public interface DatatypeBuilder {
20628 -
20629 - /**
20630 - * Adds a new parameter.
20631 - *
20632 - * @param name
20633 - * The name of the parameter to be added.
20634 - * @param strValue
20635 - * The raw value of the parameter. Caller may not normalize
20636 - * this value because any white space is potentially significant.
20637 - * @param context
20638 - * The context information which can be used by the callee to
20639 - * acquire additional information. This context object is
20640 - * valid only during this method call. The callee may not
20641 - * keep a reference to this object.
20642 - * @exception DatatypeException
20643 - * When the given parameter is inappropriate for some reason.
20644 - * The callee is responsible to recover from this error.
20645 - * That is, the object should behave as if no such error
20646 - * was occured.
20647 - */
20648 - void addParameter( String name, String strValue, ValidationContext context )
20649 - throws DatatypeException;
20650 -
20651 - /**
20652 - * Derives a new Datatype from a Datatype by parameters that
20653 - * were already set through the addParameter method.
20654 - *
20655 - * @exception DatatypeException
20656 - * DatatypeException must be thrown if the derivation is
20657 - * somehow invalid. For example, a required parameter is missing,
20658 - * etc. The exception should contain a diagnosis message
20659 - * if possible.
20660 - */
20661 - Datatype createDatatype() throws DatatypeException;
20662 -}
20663 +package org.relaxng.datatype;
20664 +
20665 +/**
20666 + * Creates a user-defined type by adding parameters to
20667 + * the pre-defined type.
20668 + *
20669 + * @author <a href="mailto:jjc@jclark.com">James Clark</a>
20670 + * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
20671 + */
20672 +public interface DatatypeBuilder {
20673 +
20674 + /**
20675 + * Adds a new parameter.
20676 + *
20677 + * @param name
20678 + * The name of the parameter to be added.
20679 + * @param strValue
20680 + * The raw value of the parameter. Caller may not normalize
20681 + * this value because any white space is potentially significant.
20682 + * @param context
20683 + * The context information which can be used by the callee to
20684 + * acquire additional information. This context object is
20685 + * valid only during this method call. The callee may not
20686 + * keep a reference to this object.
20687 + * @exception DatatypeException
20688 + * When the given parameter is inappropriate for some reason.
20689 + * The callee is responsible to recover from this error.
20690 + * That is, the object should behave as if no such error
20691 + * was occured.
20692 + */
20693 + void addParameter( String name, String strValue, ValidationContext context )
20694 + throws DatatypeException;
20695 +
20696 + /**
20697 + * Derives a new Datatype from a Datatype by parameters that
20698 + * were already set through the addParameter method.
20699 + *
20700 + * @exception DatatypeException
20701 + * DatatypeException must be thrown if the derivation is
20702 + * somehow invalid. For example, a required parameter is missing,
20703 + * etc. The exception should contain a diagnosis message
20704 + * if possible.
20705 + */
20706 + Datatype createDatatype() throws DatatypeException;
20707 +}
20708 Index: gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeException.java
20709 ===================================================================
20710 --- gcc-4.2.3.orig/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeException.java 2006-03-10 14:25:35.000000000 +0100
20711 +++ gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeException.java 2008-05-21 13:45:54.366287774 +0200
20712 @@ -1,39 +1,39 @@
20713 -package org.relaxng.datatype;
20714 -
20715 -/**
20716 - * Signals Datatype related exceptions.
20717 - *
20718 - * @author <a href="mailto:jjc@jclark.com">James Clark</a>
20719 - * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
20720 - */
20721 -public class DatatypeException extends Exception {
20722 -
20723 - public DatatypeException( int index, String msg ) {
20724 - super(msg);
20725 - this.index = index;
20726 - }
20727 - public DatatypeException( String msg ) {
20728 - this(UNKNOWN,msg);
20729 - }
20730 - /**
20731 - * A constructor for those datatype libraries which don't support any
20732 - * diagnostic information at all.
20733 - */
20734 - public DatatypeException() {
20735 - this(UNKNOWN,null);
20736 - }
20737 -
20738 -
20739 - private final int index;
20740 -
20741 - public static final int UNKNOWN = -1;
20742 -
20743 - /**
20744 - * Gets the index of the content where the error occured.
20745 - * UNKNOWN can be returned to indicate that no index information
20746 - * is available.
20747 - */
20748 - public int getIndex() {
20749 - return index;
20750 - }
20751 -}
20752 +package org.relaxng.datatype;
20753 +
20754 +/**
20755 + * Signals Datatype related exceptions.
20756 + *
20757 + * @author <a href="mailto:jjc@jclark.com">James Clark</a>
20758 + * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
20759 + */
20760 +public class DatatypeException extends Exception {
20761 +
20762 + public DatatypeException( int index, String msg ) {
20763 + super(msg);
20764 + this.index = index;
20765 + }
20766 + public DatatypeException( String msg ) {
20767 + this(UNKNOWN,msg);
20768 + }
20769 + /**
20770 + * A constructor for those datatype libraries which don't support any
20771 + * diagnostic information at all.
20772 + */
20773 + public DatatypeException() {
20774 + this(UNKNOWN,null);
20775 + }
20776 +
20777 +
20778 + private final int index;
20779 +
20780 + public static final int UNKNOWN = -1;
20781 +
20782 + /**
20783 + * Gets the index of the content where the error occured.
20784 + * UNKNOWN can be returned to indicate that no index information
20785 + * is available.
20786 + */
20787 + public int getIndex() {
20788 + return index;
20789 + }
20790 +}
20791 Index: gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/Datatype.java
20792 ===================================================================
20793 --- gcc-4.2.3.orig/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/Datatype.java 2006-03-10 14:25:35.000000000 +0100
20794 +++ gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/Datatype.java 2008-05-21 13:45:54.366287774 +0200
20795 @@ -1,237 +1,237 @@
20796 -package org.relaxng.datatype;
20797 -
20798 -/**
20799 - * Datatype object.
20800 - *
20801 - * This object has the following functionality:
20802 - *
20803 - * <ol>
20804 - * <li> functionality to identify a class of character sequences. This is
20805 - * done through the isValid method.
20806 - *
20807 - * <li> functionality to produce a "value object" from a character sequence and
20808 - * context information.
20809 - *
20810 - * <li> functionality to test the equality of two value objects.
20811 - * </ol>
20812 - *
20813 - * This interface also defines the createStreamingValidator method,
20814 - * which is intended to efficiently support the validation of
20815 - * large character sequences.
20816 - *
20817 - * @author <a href="mailto:jjc@jclark.com">James Clark</a>
20818 - * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
20819 - */
20820 -public interface Datatype {
20821 -
20822 - /**
20823 - * Checks if the specified 'literal' matches this Datatype
20824 - * with respect to the current context.
20825 - *
20826 - * @param literal
20827 - * the lexical representation to be checked.
20828 - * @param context
20829 - * If this datatype is context-dependent
20830 - * (i.e. the {@link #isContextDependent} method returns true),
20831 - * then the caller must provide a non-null valid context object.
20832 - * Otherwise, the caller can pass null.
20833 - *
20834 - * @return
20835 - * true if the 'literal' is a member of this Datatype;
20836 - * false if it's not a member of this Datatype.
20837 - */
20838 - boolean isValid( String literal, ValidationContext context );
20839 -
20840 - /**
20841 - * Similar to the isValid method but throws an exception with diagnosis
20842 - * in case of errors.
20843 - *
20844 - * <p>
20845 - * If the specified 'literal' is a valid lexical representation for this
20846 - * datatype, then this method must return without throwing any exception.
20847 - * If not, the callee must throw an exception (with diagnosis message,
20848 - * if possible.)
20849 - *
20850 - * <p>
20851 - * The application can use this method to provide detailed error message
20852 - * to users. This method is kept separate from the isValid method to
20853 - * achieve higher performance during normal validation.
20854 - *
20855 - * @exception DatatypeException
20856 - * If the given literal is invalid, then this exception is thrown.
20857 - * If the callee supports error diagnosis, then the exception should
20858 - * contain a diagnosis message.
20859 - */
20860 - void checkValid( String literal, ValidationContext context )
20861 - throws DatatypeException;
20862 -
20863 - /**
20864 - * Creates an instance of a streaming validator for this type.
20865 - *
20866 - * <p>
20867 - * By using streaming validators instead of the isValid method,
20868 - * the caller can avoid keeping the entire string, which is
20869 - * sometimes quite big, in memory.
20870 - *
20871 - * @param context
20872 - * If this datatype is context-dependent
20873 - * (i.e. the {@link #isContextDependent} method returns true),
20874 - * then the caller must provide a non-null valid context object.
20875 - * Otherwise, the caller can pass null.
20876 - * The callee may keep a reference to this context object
20877 - * only while the returned streaming validator is being used.
20878 - */
20879 - DatatypeStreamingValidator createStreamingValidator( ValidationContext context );
20880 -
20881 - /**
20882 - * Converts lexcial value and the current context to the corresponding
20883 - * value object.
20884 - *
20885 - * <p>
20886 - * The caller cannot generally assume that the value object is
20887 - * a meaningful Java object. For example, the caller cannot expect
20888 - * this method to return <code>java.lang.Number</code> type for
20889 - * the "integer" type of XML Schema Part 2.
20890 - *
20891 - * <p>
20892 - * Also, the caller cannot assume that the equals method and
20893 - * the hashCode method of the value object are consistent with
20894 - * the semantics of the datatype. For that purpose, the sameValue
20895 - * method and the valueHashCode method have to be used. Note that
20896 - * this means you cannot use classes like
20897 - * <code>java.util.Hashtable</code> to store the value objects.
20898 - *
20899 - * <p>
20900 - * The returned value object should be used solely for the sameValue
20901 - * and valueHashCode methods.
20902 - *
20903 - * @param context
20904 - * If this datatype is context-dependent
20905 - * (when the {@link #isContextDependent} method returns true),
20906 - * then the caller must provide a non-null valid context object.
20907 - * Otherwise, the caller can pass null.
20908 - *
20909 - * @return null
20910 - * when the given lexical value is not a valid lexical
20911 - * value for this type.
20912 - */
20913 - Object createValue( String literal, ValidationContext context );
20914 -
20915 - /**
20916 - * Tests the equality of two value objects which were originally
20917 - * created by the createValue method of this object.
20918 - *
20919 - * The behavior is undefined if objects not created by this type
20920 - * are passed. It is the caller's responsibility to ensure that
20921 - * value objects belong to this type.
20922 - *
20923 - * @return
20924 - * true if two value objects are considered equal according to
20925 - * the definition of this datatype; false if otherwise.
20926 - */
20927 - boolean sameValue( Object value1, Object value2 );
20928 -
20929 -
20930 - /**
20931 - * Computes the hash code for a value object,
20932 - * which is consistent with the sameValue method.
20933 - *
20934 - * @return
20935 - * hash code for the specified value object.
20936 - */
20937 - int valueHashCode( Object value );
20938 -
20939 -
20940 -
20941 -
20942 - /**
20943 - * Indicates that the datatype doesn't have ID/IDREF semantics.
20944 - *
20945 - * This value is one of the possible return values of the
20946 - * {@link #getIdType} method.
20947 - */
20948 - public static final int ID_TYPE_NULL = 0;
20949 -
20950 - /**
20951 - * Indicates that RELAX NG compatibility processors should
20952 - * treat this datatype as having ID semantics.
20953 - *
20954 - * This value is one of the possible return values of the
20955 - * {@link #getIdType} method.
20956 - */
20957 - public static final int ID_TYPE_ID = 1;
20958 -
20959 - /**
20960 - * Indicates that RELAX NG compatibility processors should
20961 - * treat this datatype as having IDREF semantics.
20962 - *
20963 - * This value is one of the possible return values of the
20964 - * {@link #getIdType} method.
20965 - */
20966 - public static final int ID_TYPE_IDREF = 2;
20967 -
20968 - /**
20969 - * Indicates that RELAX NG compatibility processors should
20970 - * treat this datatype as having IDREFS semantics.
20971 - *
20972 - * This value is one of the possible return values of the
20973 - * {@link #getIdType} method.
20974 - */
20975 - public static final int ID_TYPE_IDREFS = 3;
20976 -
20977 - /**
20978 - * Checks if the ID/IDREF semantics is associated with this
20979 - * datatype.
20980 - *
20981 - * <p>
20982 - * This method is introduced to support the RELAX NG DTD
20983 - * compatibility spec. (Of course it's always free to use
20984 - * this method for other purposes.)
20985 - *
20986 - * <p>
20987 - * If you are implementing a datatype library and have no idea about
20988 - * the "RELAX NG DTD compatibility" thing, just return
20989 - * <code>ID_TYPE_NULL</code> is fine.
20990 - *
20991 - * @return
20992 - * If this datatype doesn't have any ID/IDREF semantics,
20993 - * it returns {@link #ID_TYPE_NULL}. If it has such a semantics
20994 - * (for example, XSD:ID, XSD:IDREF and comp:ID type), then
20995 - * it returns {@link #ID_TYPE_ID}, {@link #ID_TYPE_IDREF} or
20996 - * {@link #ID_TYPE_IDREFS}.
20997 - */
20998 - public int getIdType();
20999 -
21000 -
21001 - /**
21002 - * Checks if this datatype may need a context object for
21003 - * the validation.
21004 - *
21005 - * <p>
21006 - * The callee must return true even when the context
21007 - * is not always necessary. (For example, the "QName" type
21008 - * doesn't need a context object when validating unprefixed
21009 - * string. But nonetheless QName must return true.)
21010 - *
21011 - * <p>
21012 - * XSD's <code>string</code> and <code>short</code> types
21013 - * are examples of context-independent datatypes.
21014 - * Its <code>QName</code> and <code>ENTITY</code> types
21015 - * are examples of context-dependent datatypes.
21016 - *
21017 - * <p>
21018 - * When a datatype is context-independent, then
21019 - * the {@link #isValid} method, the {@link #checkValid} method,
21020 - * the {@link #createStreamingValidator} method and
21021 - * the {@link #createValue} method can be called without
21022 - * providing a context object.
21023 - *
21024 - * @return
21025 - * <b>true</b> if this datatype is context-dependent
21026 - * (it needs a context object sometimes);
21027 - *
21028 - * <b>false</b> if this datatype is context-<b>in</b>dependent
21029 - * (it never needs a context object).
21030 - */
21031 - public boolean isContextDependent();
21032 -}
21033 +package org.relaxng.datatype;
21034 +
21035 +/**
21036 + * Datatype object.
21037 + *
21038 + * This object has the following functionality:
21039 + *
21040 + * <ol>
21041 + * <li> functionality to identify a class of character sequences. This is
21042 + * done through the isValid method.
21043 + *
21044 + * <li> functionality to produce a "value object" from a character sequence and
21045 + * context information.
21046 + *
21047 + * <li> functionality to test the equality of two value objects.
21048 + * </ol>
21049 + *
21050 + * This interface also defines the createStreamingValidator method,
21051 + * which is intended to efficiently support the validation of
21052 + * large character sequences.
21053 + *
21054 + * @author <a href="mailto:jjc@jclark.com">James Clark</a>
21055 + * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
21056 + */
21057 +public interface Datatype {
21058 +
21059 + /**
21060 + * Checks if the specified 'literal' matches this Datatype
21061 + * with respect to the current context.
21062 + *
21063 + * @param literal
21064 + * the lexical representation to be checked.
21065 + * @param context
21066 + * If this datatype is context-dependent
21067 + * (i.e. the {@link #isContextDependent} method returns true),
21068 + * then the caller must provide a non-null valid context object.
21069 + * Otherwise, the caller can pass null.
21070 + *
21071 + * @return
21072 + * true if the 'literal' is a member of this Datatype;
21073 + * false if it's not a member of this Datatype.
21074 + */
21075 + boolean isValid( String literal, ValidationContext context );
21076 +
21077 + /**
21078 + * Similar to the isValid method but throws an exception with diagnosis
21079 + * in case of errors.
21080 + *
21081 + * <p>
21082 + * If the specified 'literal' is a valid lexical representation for this
21083 + * datatype, then this method must return without throwing any exception.
21084 + * If not, the callee must throw an exception (with diagnosis message,
21085 + * if possible.)
21086 + *
21087 + * <p>
21088 + * The application can use this method to provide detailed error message
21089 + * to users. This method is kept separate from the isValid method to
21090 + * achieve higher performance during normal validation.
21091 + *
21092 + * @exception DatatypeException
21093 + * If the given literal is invalid, then this exception is thrown.
21094 + * If the callee supports error diagnosis, then the exception should
21095 + * contain a diagnosis message.
21096 + */
21097 + void checkValid( String literal, ValidationContext context )
21098 + throws DatatypeException;
21099 +
21100 + /**
21101 + * Creates an instance of a streaming validator for this type.
21102 + *
21103 + * <p>
21104 + * By using streaming validators instead of the isValid method,
21105 + * the caller can avoid keeping the entire string, which is
21106 + * sometimes quite big, in memory.
21107 + *
21108 + * @param context
21109 + * If this datatype is context-dependent
21110 + * (i.e. the {@link #isContextDependent} method returns true),
21111 + * then the caller must provide a non-null valid context object.
21112 + * Otherwise, the caller can pass null.
21113 + * The callee may keep a reference to this context object
21114 + * only while the returned streaming validator is being used.
21115 + */
21116 + DatatypeStreamingValidator createStreamingValidator( ValidationContext context );
21117 +
21118 + /**
21119 + * Converts lexcial value and the current context to the corresponding
21120 + * value object.
21121 + *
21122 + * <p>
21123 + * The caller cannot generally assume that the value object is
21124 + * a meaningful Java object. For example, the caller cannot expect
21125 + * this method to return <code>java.lang.Number</code> type for
21126 + * the "integer" type of XML Schema Part 2.
21127 + *
21128 + * <p>
21129 + * Also, the caller cannot assume that the equals method and
21130 + * the hashCode method of the value object are consistent with
21131 + * the semantics of the datatype. For that purpose, the sameValue
21132 + * method and the valueHashCode method have to be used. Note that
21133 + * this means you cannot use classes like
21134 + * <code>java.util.Hashtable</code> to store the value objects.
21135 + *
21136 + * <p>
21137 + * The returned value object should be used solely for the sameValue
21138 + * and valueHashCode methods.
21139 + *
21140 + * @param context
21141 + * If this datatype is context-dependent
21142 + * (when the {@link #isContextDependent} method returns true),
21143 + * then the caller must provide a non-null valid context object.
21144 + * Otherwise, the caller can pass null.
21145 + *
21146 + * @return null
21147 + * when the given lexical value is not a valid lexical
21148 + * value for this type.
21149 + */
21150 + Object createValue( String literal, ValidationContext context );
21151 +
21152 + /**
21153 + * Tests the equality of two value objects which were originally
21154 + * created by the createValue method of this object.
21155 + *
21156 + * The behavior is undefined if objects not created by this type
21157 + * are passed. It is the caller's responsibility to ensure that
21158 + * value objects belong to this type.
21159 + *
21160 + * @return
21161 + * true if two value objects are considered equal according to
21162 + * the definition of this datatype; false if otherwise.
21163 + */
21164 + boolean sameValue( Object value1, Object value2 );
21165 +
21166 +
21167 + /**
21168 + * Computes the hash code for a value object,
21169 + * which is consistent with the sameValue method.
21170 + *
21171 + * @return
21172 + * hash code for the specified value object.
21173 + */
21174 + int valueHashCode( Object value );
21175 +
21176 +
21177 +
21178 +
21179 + /**
21180 + * Indicates that the datatype doesn't have ID/IDREF semantics.
21181 + *
21182 + * This value is one of the possible return values of the
21183 + * {@link #getIdType} method.
21184 + */
21185 + public static final int ID_TYPE_NULL = 0;
21186 +
21187 + /**
21188 + * Indicates that RELAX NG compatibility processors should
21189 + * treat this datatype as having ID semantics.
21190 + *
21191 + * This value is one of the possible return values of the
21192 + * {@link #getIdType} method.
21193 + */
21194 + public static final int ID_TYPE_ID = 1;
21195 +
21196 + /**
21197 + * Indicates that RELAX NG compatibility processors should
21198 + * treat this datatype as having IDREF semantics.
21199 + *
21200 + * This value is one of the possible return values of the
21201 + * {@link #getIdType} method.
21202 + */
21203 + public static final int ID_TYPE_IDREF = 2;
21204 +
21205 + /**
21206 + * Indicates that RELAX NG compatibility processors should
21207 + * treat this datatype as having IDREFS semantics.
21208 + *
21209 + * This value is one of the possible return values of the
21210 + * {@link #getIdType} method.
21211 + */
21212 + public static final int ID_TYPE_IDREFS = 3;
21213 +
21214 + /**
21215 + * Checks if the ID/IDREF semantics is associated with this
21216 + * datatype.
21217 + *
21218 + * <p>
21219 + * This method is introduced to support the RELAX NG DTD
21220 + * compatibility spec. (Of course it's always free to use
21221 + * this method for other purposes.)
21222 + *
21223 + * <p>
21224 + * If you are implementing a datatype library and have no idea about
21225 + * the "RELAX NG DTD compatibility" thing, just return
21226 + * <code>ID_TYPE_NULL</code> is fine.
21227 + *
21228 + * @return
21229 + * If this datatype doesn't have any ID/IDREF semantics,
21230 + * it returns {@link #ID_TYPE_NULL}. If it has such a semantics
21231 + * (for example, XSD:ID, XSD:IDREF and comp:ID type), then
21232 + * it returns {@link #ID_TYPE_ID}, {@link #ID_TYPE_IDREF} or
21233 + * {@link #ID_TYPE_IDREFS}.
21234 + */
21235 + public int getIdType();
21236 +
21237 +
21238 + /**
21239 + * Checks if this datatype may need a context object for
21240 + * the validation.
21241 + *
21242 + * <p>
21243 + * The callee must return true even when the context
21244 + * is not always necessary. (For example, the "QName" type
21245 + * doesn't need a context object when validating unprefixed
21246 + * string. But nonetheless QName must return true.)
21247 + *
21248 + * <p>
21249 + * XSD's <code>string</code> and <code>short</code> types
21250 + * are examples of context-independent datatypes.
21251 + * Its <code>QName</code> and <code>ENTITY</code> types
21252 + * are examples of context-dependent datatypes.
21253 + *
21254 + * <p>
21255 + * When a datatype is context-independent, then
21256 + * the {@link #isValid} method, the {@link #checkValid} method,
21257 + * the {@link #createStreamingValidator} method and
21258 + * the {@link #createValue} method can be called without
21259 + * providing a context object.
21260 + *
21261 + * @return
21262 + * <b>true</b> if this datatype is context-dependent
21263 + * (it needs a context object sometimes);
21264 + *
21265 + * <b>false</b> if this datatype is context-<b>in</b>dependent
21266 + * (it never needs a context object).
21267 + */
21268 + public boolean isContextDependent();
21269 +}
21270 Index: gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeLibraryFactory.java
21271 ===================================================================
21272 --- gcc-4.2.3.orig/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeLibraryFactory.java 2006-03-10 14:25:35.000000000 +0100
21273 +++ gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeLibraryFactory.java 2008-05-21 13:45:54.366287774 +0200
21274 @@ -1,26 +1,26 @@
21275 -package org.relaxng.datatype;
21276 -
21277 -/**
21278 - * Factory class for the DatatypeLibrary class.
21279 - *
21280 - * <p>
21281 - * The datatype library should provide the implementation of
21282 - * this interface if it wants to be found by the schema processors.
21283 - * The implementor also have to place a file in your jar file.
21284 - * See the reference datatype library implementation for detail.
21285 - *
21286 - * @author <a href="mailto:jjc@jclark.com">James Clark</a>
21287 - * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
21288 - */
21289 -public interface DatatypeLibraryFactory
21290 -{
21291 - /**
21292 - * Creates a new instance of a DatatypeLibrary that supports
21293 - * the specified namespace URI.
21294 - *
21295 - * @return
21296 - * <code>null</code> if the specified namespace URI is not
21297 - * supported.
21298 - */
21299 - DatatypeLibrary createDatatypeLibrary( String namespaceURI );
21300 -}
21301 +package org.relaxng.datatype;
21302 +
21303 +/**
21304 + * Factory class for the DatatypeLibrary class.
21305 + *
21306 + * <p>
21307 + * The datatype library should provide the implementation of
21308 + * this interface if it wants to be found by the schema processors.
21309 + * The implementor also have to place a file in your jar file.
21310 + * See the reference datatype library implementation for detail.
21311 + *
21312 + * @author <a href="mailto:jjc@jclark.com">James Clark</a>
21313 + * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
21314 + */
21315 +public interface DatatypeLibraryFactory
21316 +{
21317 + /**
21318 + * Creates a new instance of a DatatypeLibrary that supports
21319 + * the specified namespace URI.
21320 + *
21321 + * @return
21322 + * <code>null</code> if the specified namespace URI is not
21323 + * supported.
21324 + */
21325 + DatatypeLibrary createDatatypeLibrary( String namespaceURI );
21326 +}
21327 Index: gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeLibrary.java
21328 ===================================================================
21329 --- gcc-4.2.3.orig/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeLibrary.java 2006-03-10 14:25:35.000000000 +0100
21330 +++ gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeLibrary.java 2008-05-21 13:45:54.366287774 +0200
21331 @@ -1,37 +1,37 @@
21332 -package org.relaxng.datatype;
21333 -
21334 -/**
21335 - * A Datatype library
21336 - *
21337 - * @author <a href="mailto:jjc@jclark.com">James Clark</a>
21338 - * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
21339 - */
21340 -public interface DatatypeLibrary {
21341 -
21342 - /**
21343 - * Creates a new instance of DatatypeBuilder.
21344 - *
21345 - * The callee should throw a DatatypeException in case of an error.
21346 - *
21347 - * @param baseTypeLocalName
21348 - * The local name of the base type.
21349 - *
21350 - * @return
21351 - * A non-null valid datatype object.
21352 - */
21353 - DatatypeBuilder createDatatypeBuilder( String baseTypeLocalName )
21354 - throws DatatypeException;
21355 -
21356 - /**
21357 - * Gets or creates a pre-defined type.
21358 - *
21359 - * This is just a short-cut of
21360 - * <code>createDatatypeBuilder(typeLocalName).createDatatype();</code>
21361 - *
21362 - * The callee should throw a DatatypeException in case of an error.
21363 - *
21364 - * @return
21365 - * A non-null valid datatype object.
21366 - */
21367 - Datatype createDatatype( String typeLocalName ) throws DatatypeException;
21368 -}
21369 +package org.relaxng.datatype;
21370 +
21371 +/**
21372 + * A Datatype library
21373 + *
21374 + * @author <a href="mailto:jjc@jclark.com">James Clark</a>
21375 + * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
21376 + */
21377 +public interface DatatypeLibrary {
21378 +
21379 + /**
21380 + * Creates a new instance of DatatypeBuilder.
21381 + *
21382 + * The callee should throw a DatatypeException in case of an error.
21383 + *
21384 + * @param baseTypeLocalName
21385 + * The local name of the base type.
21386 + *
21387 + * @return
21388 + * A non-null valid datatype object.
21389 + */
21390 + DatatypeBuilder createDatatypeBuilder( String baseTypeLocalName )
21391 + throws DatatypeException;
21392 +
21393 + /**
21394 + * Gets or creates a pre-defined type.
21395 + *
21396 + * This is just a short-cut of
21397 + * <code>createDatatypeBuilder(typeLocalName).createDatatype();</code>
21398 + *
21399 + * The callee should throw a DatatypeException in case of an error.
21400 + *
21401 + * @return
21402 + * A non-null valid datatype object.
21403 + */
21404 + Datatype createDatatype( String typeLocalName ) throws DatatypeException;
21405 +}
21406 Index: gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeStreamingValidator.java
21407 ===================================================================
21408 --- gcc-4.2.3.orig/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeStreamingValidator.java 2006-03-10 14:25:35.000000000 +0100
21409 +++ gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/DatatypeStreamingValidator.java 2008-05-21 13:45:54.366287774 +0200
21410 @@ -1,46 +1,46 @@
21411 -package org.relaxng.datatype;
21412 -
21413 -/**
21414 - * Datatype streaming validator.
21415 - *
21416 - * <p>
21417 - * The streaming validator is an optional feature that is useful for
21418 - * certain Datatypes. It allows the caller to incrementally provide
21419 - * the literal.
21420 - *
21421 - * @author <a href="mailto:jjc@jclark.com">James Clark</a>
21422 - * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
21423 - */
21424 -public interface DatatypeStreamingValidator {
21425 -
21426 - /**
21427 - * Passes an additional fragment of the literal.
21428 - *
21429 - * <p>
21430 - * The application can call this method several times, then call
21431 - * the isValid method (or the checkValid method) to check the validity
21432 - * of the accumulated characters.
21433 - */
21434 - void addCharacters( char[] buf, int start, int len );
21435 -
21436 - /**
21437 - * Tells if the accumulated literal is valid with respect to
21438 - * the underlying Datatype.
21439 - *
21440 - * @return
21441 - * True if it is valid. False if otherwise.
21442 - */
21443 - boolean isValid();
21444 -
21445 - /**
21446 - * Similar to the isValid method, but this method throws
21447 - * Exception (with possibly diagnostic information), instead of
21448 - * returning false.
21449 - *
21450 - * @exception DatatypeException
21451 - * If the callee supports the diagnosis and the accumulated
21452 - * literal is invalid, then this exception that possibly
21453 - * contains diagnosis information is thrown.
21454 - */
21455 - void checkValid() throws DatatypeException;
21456 -}
21457 +package org.relaxng.datatype;
21458 +
21459 +/**
21460 + * Datatype streaming validator.
21461 + *
21462 + * <p>
21463 + * The streaming validator is an optional feature that is useful for
21464 + * certain Datatypes. It allows the caller to incrementally provide
21465 + * the literal.
21466 + *
21467 + * @author <a href="mailto:jjc@jclark.com">James Clark</a>
21468 + * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
21469 + */
21470 +public interface DatatypeStreamingValidator {
21471 +
21472 + /**
21473 + * Passes an additional fragment of the literal.
21474 + *
21475 + * <p>
21476 + * The application can call this method several times, then call
21477 + * the isValid method (or the checkValid method) to check the validity
21478 + * of the accumulated characters.
21479 + */
21480 + void addCharacters( char[] buf, int start, int len );
21481 +
21482 + /**
21483 + * Tells if the accumulated literal is valid with respect to
21484 + * the underlying Datatype.
21485 + *
21486 + * @return
21487 + * True if it is valid. False if otherwise.
21488 + */
21489 + boolean isValid();
21490 +
21491 + /**
21492 + * Similar to the isValid method, but this method throws
21493 + * Exception (with possibly diagnostic information), instead of
21494 + * returning false.
21495 + *
21496 + * @exception DatatypeException
21497 + * If the callee supports the diagnosis and the accumulated
21498 + * literal is invalid, then this exception that possibly
21499 + * contains diagnosis information is thrown.
21500 + */
21501 + void checkValid() throws DatatypeException;
21502 +}
21503 Index: gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/helpers/DatatypeLibraryLoader.java
21504 ===================================================================
21505 --- gcc-4.2.3.orig/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/helpers/DatatypeLibraryLoader.java 2006-03-10 14:25:35.000000000 +0100
21506 +++ gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/helpers/DatatypeLibraryLoader.java 2008-05-21 13:45:54.370287167 +0200
21507 @@ -1,262 +1,262 @@
21508 -/**
21509 - * Copyright (c) 2001, Thai Open Source Software Center Ltd
21510 - * All rights reserved.
21511 - *
21512 - * Redistribution and use in source and binary forms, with or without
21513 - * modification, are permitted provided that the following conditions are
21514 - * met:
21515 - *
21516 - * Redistributions of source code must retain the above copyright
21517 - * notice, this list of conditions and the following disclaimer.
21518 - *
21519 - * Redistributions in binary form must reproduce the above copyright
21520 - * notice, this list of conditions and the following disclaimer in
21521 - * the documentation and/or other materials provided with the
21522 - * distribution.
21523 - *
21524 - * Neither the name of the Thai Open Source Software Center Ltd nor
21525 - * the names of its contributors may be used to endorse or promote
21526 - * products derived from this software without specific prior written
21527 - * permission.
21528 - *
21529 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21530 - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21531 - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21532 - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
21533 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21534 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21535 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21536 - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21537 - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21538 - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21539 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21540 - */
21541 -package org.relaxng.datatype.helpers;
21542 -
21543 -import org.relaxng.datatype.DatatypeLibraryFactory;
21544 -import org.relaxng.datatype.DatatypeLibrary;
21545 -import java.util.Enumeration;
21546 -import java.util.NoSuchElementException;
21547 -import java.util.Vector;
21548 -import java.io.Reader;
21549 -import java.io.InputStream;
21550 -import java.io.InputStreamReader;
21551 -import java.io.BufferedReader;
21552 -import java.io.IOException;
21553 -import java.io.UnsupportedEncodingException;
21554 -import java.net.URL;
21555 -
21556 -/**
21557 - * Discovers the datatype library implementation from the classpath.
21558 - *
21559 - * <p>
21560 - * The call of the createDatatypeLibrary method finds an implementation
21561 - * from a given datatype library URI at run-time.
21562 - */
21563 -public class DatatypeLibraryLoader implements DatatypeLibraryFactory {
21564 - private final Service service = new Service(DatatypeLibraryFactory.class);
21565 -
21566 - public DatatypeLibrary createDatatypeLibrary(String uri) {
21567 - for (Enumeration e = service.getProviders();
21568 - e.hasMoreElements();) {
21569 - DatatypeLibraryFactory factory
21570 - = (DatatypeLibraryFactory)e.nextElement();
21571 - DatatypeLibrary library = factory.createDatatypeLibrary(uri);
21572 - if (library != null)
21573 - return library;
21574 - }
21575 - return null;
21576 - }
21577 -
21578 - private static class Service {
21579 - private final Class serviceClass;
21580 - private final Enumeration configFiles;
21581 - private Enumeration classNames = null;
21582 - private final Vector providers = new Vector();
21583 - private Loader loader;
21584 -
21585 - private class ProviderEnumeration implements Enumeration {
21586 - private int nextIndex = 0;
21587 -
21588 - public boolean hasMoreElements() {
21589 - return nextIndex < providers.size() || moreProviders();
21590 - }
21591 -
21592 - public Object nextElement() {
21593 - try {
21594 - return providers.elementAt(nextIndex++);
21595 - }
21596 - catch (ArrayIndexOutOfBoundsException e) {
21597 - throw new NoSuchElementException();
21598 - }
21599 - }
21600 - }
21601 -
21602 - private static class Singleton implements Enumeration {
21603 - private Object obj;
21604 - private Singleton(Object obj) {
21605 - this.obj = obj;
21606 - }
21607 -
21608 - public boolean hasMoreElements() {
21609 - return obj != null;
21610 - }
21611 -
21612 - public Object nextElement() {
21613 - if (obj == null)
21614 - throw new NoSuchElementException();
21615 - Object tem = obj;
21616 - obj = null;
21617 - return tem;
21618 - }
21619 - }
21620 -
21621 - // JDK 1.1
21622 - private static class Loader {
21623 - Enumeration getResources(String resName) {
21624 - ClassLoader cl = Loader.class.getClassLoader();
21625 - URL url;
21626 - if (cl == null)
21627 - url = ClassLoader.getSystemResource(resName);
21628 - else
21629 - url = cl.getResource(resName);
21630 - return new Singleton(url);
21631 - }
21632 -
21633 - Class loadClass(String name) throws ClassNotFoundException {
21634 - return Class.forName(name);
21635 - }
21636 - }
21637 -
21638 - // JDK 1.2+
21639 - private static class Loader2 extends Loader {
21640 - private ClassLoader cl;
21641 -
21642 - Loader2() {
21643 - cl = Loader2.class.getClassLoader();
21644 - // If the thread context class loader has the class loader
21645 - // of this class as an ancestor, use the thread context class
21646 - // loader. Otherwise, the thread context class loader
21647 - // probably hasn't been set up properly, so don't use it.
21648 - ClassLoader clt = Thread.currentThread().getContextClassLoader();
21649 - for (ClassLoader tem = clt; tem != null; tem = tem.getParent())
21650 - if (tem == cl) {
21651 - cl = clt;
21652 - break;
21653 - }
21654 - }
21655 -
21656 - Enumeration getResources(String resName) {
21657 - try {
21658 - return cl.getResources(resName);
21659 - }
21660 - catch (IOException e) {
21661 - return new Singleton(null);
21662 - }
21663 - }
21664 -
21665 - Class loadClass(String name) throws ClassNotFoundException {
21666 - return Class.forName(name, true, cl);
21667 - }
21668 - }
21669 -
21670 - public Service(Class cls) {
21671 - try {
21672 - loader = new Loader2();
21673 - }
21674 - catch (NoSuchMethodError e) {
21675 - loader = new Loader();
21676 - }
21677 - serviceClass = cls;
21678 - String resName = "META-INF/services/" + serviceClass.getName();
21679 - configFiles = loader.getResources(resName);
21680 - }
21681 -
21682 - public Enumeration getProviders() {
21683 - return new ProviderEnumeration();
21684 - }
21685 -
21686 - synchronized private boolean moreProviders() {
21687 - for (;;) {
21688 - while (classNames == null) {
21689 - if (!configFiles.hasMoreElements())
21690 - return false;
21691 - classNames = parseConfigFile((URL)configFiles.nextElement());
21692 - }
21693 - while (classNames.hasMoreElements()) {
21694 - String className = (String)classNames.nextElement();
21695 - try {
21696 - Class cls = loader.loadClass(className);
21697 - Object obj = cls.newInstance();
21698 - if (serviceClass.isInstance(obj)) {
21699 - providers.addElement(obj);
21700 - return true;
21701 - }
21702 - }
21703 - catch (ClassNotFoundException e) { }
21704 - catch (InstantiationException e) { }
21705 - catch (IllegalAccessException e) { }
21706 - catch (LinkageError e) { }
21707 - }
21708 - classNames = null;
21709 - }
21710 - }
21711 -
21712 - private static final int START = 0;
21713 - private static final int IN_NAME = 1;
21714 - private static final int IN_COMMENT = 2;
21715 -
21716 - private static Enumeration parseConfigFile(URL url) {
21717 - try {
21718 - InputStream in = url.openStream();
21719 - Reader r;
21720 - try {
21721 - r = new InputStreamReader(in, "UTF-8");
21722 - }
21723 - catch (UnsupportedEncodingException e) {
21724 - r = new InputStreamReader(in, "UTF8");
21725 - }
21726 - r = new BufferedReader(r);
21727 - Vector tokens = new Vector();
21728 - StringBuffer tokenBuf = new StringBuffer();
21729 - int state = START;
21730 - for (;;) {
21731 - int n = r.read();
21732 - if (n < 0)
21733 - break;
21734 - char c = (char)n;
21735 - switch (c) {
21736 - case '\r':
21737 - case '\n':
21738 - state = START;
21739 - break;
21740 - case ' ':
21741 - case '\t':
21742 - break;
21743 - case '#':
21744 - state = IN_COMMENT;
21745 - break;
21746 - default:
21747 - if (state != IN_COMMENT) {
21748 - state = IN_NAME;
21749 - tokenBuf.append(c);
21750 - }
21751 - break;
21752 - }
21753 - if (tokenBuf.length() != 0 && state != IN_NAME) {
21754 - tokens.addElement(tokenBuf.toString());
21755 - tokenBuf.setLength(0);
21756 - }
21757 - }
21758 - if (tokenBuf.length() != 0)
21759 - tokens.addElement(tokenBuf.toString());
21760 - return tokens.elements();
21761 - }
21762 - catch (IOException e) {
21763 - return null;
21764 - }
21765 - }
21766 - }
21767 -
21768 -}
21769 -
21770 +/**
21771 + * Copyright (c) 2001, Thai Open Source Software Center Ltd
21772 + * All rights reserved.
21773 + *
21774 + * Redistribution and use in source and binary forms, with or without
21775 + * modification, are permitted provided that the following conditions are
21776 + * met:
21777 + *
21778 + * Redistributions of source code must retain the above copyright
21779 + * notice, this list of conditions and the following disclaimer.
21780 + *
21781 + * Redistributions in binary form must reproduce the above copyright
21782 + * notice, this list of conditions and the following disclaimer in
21783 + * the documentation and/or other materials provided with the
21784 + * distribution.
21785 + *
21786 + * Neither the name of the Thai Open Source Software Center Ltd nor
21787 + * the names of its contributors may be used to endorse or promote
21788 + * products derived from this software without specific prior written
21789 + * permission.
21790 + *
21791 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21792 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21793 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21794 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
21795 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21796 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21797 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21798 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21799 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21800 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21801 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21802 + */
21803 +package org.relaxng.datatype.helpers;
21804 +
21805 +import org.relaxng.datatype.DatatypeLibraryFactory;
21806 +import org.relaxng.datatype.DatatypeLibrary;
21807 +import java.util.Enumeration;
21808 +import java.util.NoSuchElementException;
21809 +import java.util.Vector;
21810 +import java.io.Reader;
21811 +import java.io.InputStream;
21812 +import java.io.InputStreamReader;
21813 +import java.io.BufferedReader;
21814 +import java.io.IOException;
21815 +import java.io.UnsupportedEncodingException;
21816 +import java.net.URL;
21817 +
21818 +/**
21819 + * Discovers the datatype library implementation from the classpath.
21820 + *
21821 + * <p>
21822 + * The call of the createDatatypeLibrary method finds an implementation
21823 + * from a given datatype library URI at run-time.
21824 + */
21825 +public class DatatypeLibraryLoader implements DatatypeLibraryFactory {
21826 + private final Service service = new Service(DatatypeLibraryFactory.class);
21827 +
21828 + public DatatypeLibrary createDatatypeLibrary(String uri) {
21829 + for (Enumeration e = service.getProviders();
21830 + e.hasMoreElements();) {
21831 + DatatypeLibraryFactory factory
21832 + = (DatatypeLibraryFactory)e.nextElement();
21833 + DatatypeLibrary library = factory.createDatatypeLibrary(uri);
21834 + if (library != null)
21835 + return library;
21836 + }
21837 + return null;
21838 + }
21839 +
21840 + private static class Service {
21841 + private final Class serviceClass;
21842 + private final Enumeration configFiles;
21843 + private Enumeration classNames = null;
21844 + private final Vector providers = new Vector();
21845 + private Loader loader;
21846 +
21847 + private class ProviderEnumeration implements Enumeration {
21848 + private int nextIndex = 0;
21849 +
21850 + public boolean hasMoreElements() {
21851 + return nextIndex < providers.size() || moreProviders();
21852 + }
21853 +
21854 + public Object nextElement() {
21855 + try {
21856 + return providers.elementAt(nextIndex++);
21857 + }
21858 + catch (ArrayIndexOutOfBoundsException e) {
21859 + throw new NoSuchElementException();
21860 + }
21861 + }
21862 + }
21863 +
21864 + private static class Singleton implements Enumeration {
21865 + private Object obj;
21866 + private Singleton(Object obj) {
21867 + this.obj = obj;
21868 + }
21869 +
21870 + public boolean hasMoreElements() {
21871 + return obj != null;
21872 + }
21873 +
21874 + public Object nextElement() {
21875 + if (obj == null)
21876 + throw new NoSuchElementException();
21877 + Object tem = obj;
21878 + obj = null;
21879 + return tem;
21880 + }
21881 + }
21882 +
21883 + // JDK 1.1
21884 + private static class Loader {
21885 + Enumeration getResources(String resName) {
21886 + ClassLoader cl = Loader.class.getClassLoader();
21887 + URL url;
21888 + if (cl == null)
21889 + url = ClassLoader.getSystemResource(resName);
21890 + else
21891 + url = cl.getResource(resName);
21892 + return new Singleton(url);
21893 + }
21894 +
21895 + Class loadClass(String name) throws ClassNotFoundException {
21896 + return Class.forName(name);
21897 + }
21898 + }
21899 +
21900 + // JDK 1.2+
21901 + private static class Loader2 extends Loader {
21902 + private ClassLoader cl;
21903 +
21904 + Loader2() {
21905 + cl = Loader2.class.getClassLoader();
21906 + // If the thread context class loader has the class loader
21907 + // of this class as an ancestor, use the thread context class
21908 + // loader. Otherwise, the thread context class loader
21909 + // probably hasn't been set up properly, so don't use it.
21910 + ClassLoader clt = Thread.currentThread().getContextClassLoader();
21911 + for (ClassLoader tem = clt; tem != null; tem = tem.getParent())
21912 + if (tem == cl) {
21913 + cl = clt;
21914 + break;
21915 + }
21916 + }
21917 +
21918 + Enumeration getResources(String resName) {
21919 + try {
21920 + return cl.getResources(resName);
21921 + }
21922 + catch (IOException e) {
21923 + return new Singleton(null);
21924 + }
21925 + }
21926 +
21927 + Class loadClass(String name) throws ClassNotFoundException {
21928 + return Class.forName(name, true, cl);
21929 + }
21930 + }
21931 +
21932 + public Service(Class cls) {
21933 + try {
21934 + loader = new Loader2();
21935 + }
21936 + catch (NoSuchMethodError e) {
21937 + loader = new Loader();
21938 + }
21939 + serviceClass = cls;
21940 + String resName = "META-INF/services/" + serviceClass.getName();
21941 + configFiles = loader.getResources(resName);
21942 + }
21943 +
21944 + public Enumeration getProviders() {
21945 + return new ProviderEnumeration();
21946 + }
21947 +
21948 + synchronized private boolean moreProviders() {
21949 + for (;;) {
21950 + while (classNames == null) {
21951 + if (!configFiles.hasMoreElements())
21952 + return false;
21953 + classNames = parseConfigFile((URL)configFiles.nextElement());
21954 + }
21955 + while (classNames.hasMoreElements()) {
21956 + String className = (String)classNames.nextElement();
21957 + try {
21958 + Class cls = loader.loadClass(className);
21959 + Object obj = cls.newInstance();
21960 + if (serviceClass.isInstance(obj)) {
21961 + providers.addElement(obj);
21962 + return true;
21963 + }
21964 + }
21965 + catch (ClassNotFoundException e) { }
21966 + catch (InstantiationException e) { }
21967 + catch (IllegalAccessException e) { }
21968 + catch (LinkageError e) { }
21969 + }
21970 + classNames = null;
21971 + }
21972 + }
21973 +
21974 + private static final int START = 0;
21975 + private static final int IN_NAME = 1;
21976 + private static final int IN_COMMENT = 2;
21977 +
21978 + private static Enumeration parseConfigFile(URL url) {
21979 + try {
21980 + InputStream in = url.openStream();
21981 + Reader r;
21982 + try {
21983 + r = new InputStreamReader(in, "UTF-8");
21984 + }
21985 + catch (UnsupportedEncodingException e) {
21986 + r = new InputStreamReader(in, "UTF8");
21987 + }
21988 + r = new BufferedReader(r);
21989 + Vector tokens = new Vector();
21990 + StringBuffer tokenBuf = new StringBuffer();
21991 + int state = START;
21992 + for (;;) {
21993 + int n = r.read();
21994 + if (n < 0)
21995 + break;
21996 + char c = (char)n;
21997 + switch (c) {
21998 + case '\r':
21999 + case '\n':
22000 + state = START;
22001 + break;
22002 + case ' ':
22003 + case '\t':
22004 + break;
22005 + case '#':
22006 + state = IN_COMMENT;
22007 + break;
22008 + default:
22009 + if (state != IN_COMMENT) {
22010 + state = IN_NAME;
22011 + tokenBuf.append(c);
22012 + }
22013 + break;
22014 + }
22015 + if (tokenBuf.length() != 0 && state != IN_NAME) {
22016 + tokens.addElement(tokenBuf.toString());
22017 + tokenBuf.setLength(0);
22018 + }
22019 + }
22020 + if (tokenBuf.length() != 0)
22021 + tokens.addElement(tokenBuf.toString());
22022 + return tokens.elements();
22023 + }
22024 + catch (IOException e) {
22025 + return null;
22026 + }
22027 + }
22028 + }
22029 +
22030 +}
22031 +
22032 Index: gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/helpers/ParameterlessDatatypeBuilder.java
22033 ===================================================================
22034 --- gcc-4.2.3.orig/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/helpers/ParameterlessDatatypeBuilder.java 2006-03-10 14:25:35.000000000 +0100
22035 +++ gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/helpers/ParameterlessDatatypeBuilder.java 2008-05-21 13:45:54.370287167 +0200
22036 @@ -1,42 +1,42 @@
22037 -package org.relaxng.datatype.helpers;
22038 -
22039 -import org.relaxng.datatype.*;
22040 -
22041 -/**
22042 - * Dummy implementation of {@link DatatypeBuilder}.
22043 - *
22044 - * This implementation can be used for Datatypes which have no parameters.
22045 - * Any attempt to add parameters will be rejected.
22046 - *
22047 - * <p>
22048 - * Typical usage would be:
22049 - * <PRE><XMP>
22050 - * class MyDatatypeLibrary implements DatatypeLibrary {
22051 - * ....
22052 - * DatatypeBuilder createDatatypeBuilder( String typeName ) {
22053 - * return new ParameterleessDatatypeBuilder(createDatatype(typeName));
22054 - * }
22055 - * ....
22056 - * }
22057 - * </XMP></PRE>
22058 - *
22059 - * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
22060 - */
22061 -public final class ParameterlessDatatypeBuilder implements DatatypeBuilder {
22062 -
22063 - /** This type object is returned for the derive method. */
22064 - private final Datatype baseType;
22065 -
22066 - public ParameterlessDatatypeBuilder( Datatype baseType ) {
22067 - this.baseType = baseType;
22068 - }
22069 -
22070 - public void addParameter( String name, String strValue, ValidationContext context )
22071 - throws DatatypeException {
22072 - throw new DatatypeException();
22073 - }
22074 -
22075 - public Datatype createDatatype() throws DatatypeException {
22076 - return baseType;
22077 - }
22078 -}
22079 +package org.relaxng.datatype.helpers;
22080 +
22081 +import org.relaxng.datatype.*;
22082 +
22083 +/**
22084 + * Dummy implementation of {@link DatatypeBuilder}.
22085 + *
22086 + * This implementation can be used for Datatypes which have no parameters.
22087 + * Any attempt to add parameters will be rejected.
22088 + *
22089 + * <p>
22090 + * Typical usage would be:
22091 + * <PRE><XMP>
22092 + * class MyDatatypeLibrary implements DatatypeLibrary {
22093 + * ....
22094 + * DatatypeBuilder createDatatypeBuilder( String typeName ) {
22095 + * return new ParameterleessDatatypeBuilder(createDatatype(typeName));
22096 + * }
22097 + * ....
22098 + * }
22099 + * </XMP></PRE>
22100 + *
22101 + * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
22102 + */
22103 +public final class ParameterlessDatatypeBuilder implements DatatypeBuilder {
22104 +
22105 + /** This type object is returned for the derive method. */
22106 + private final Datatype baseType;
22107 +
22108 + public ParameterlessDatatypeBuilder( Datatype baseType ) {
22109 + this.baseType = baseType;
22110 + }
22111 +
22112 + public void addParameter( String name, String strValue, ValidationContext context )
22113 + throws DatatypeException {
22114 + throw new DatatypeException();
22115 + }
22116 +
22117 + public Datatype createDatatype() throws DatatypeException {
22118 + return baseType;
22119 + }
22120 +}
22121 Index: gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/helpers/StreamingValidatorImpl.java
22122 ===================================================================
22123 --- gcc-4.2.3.orig/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/helpers/StreamingValidatorImpl.java 2006-03-10 14:25:35.000000000 +0100
22124 +++ gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/helpers/StreamingValidatorImpl.java 2008-05-21 13:45:54.370287167 +0200
22125 @@ -1,55 +1,55 @@
22126 -package org.relaxng.datatype.helpers;
22127 -
22128 -import org.relaxng.datatype.*;
22129 -
22130 -/**
22131 - * Dummy implementation of {@link DatatypeStreamingValidator}.
22132 - *
22133 - * <p>
22134 - * This implementation can be used as a quick hack when the performance
22135 - * of streaming validation is not important. And this implementation
22136 - * also shows you how to implement the DatatypeStreamingValidator interface.
22137 - *
22138 - * <p>
22139 - * Typical usage would be:
22140 - * <PRE><XMP>
22141 - * class MyDatatype implements Datatype {
22142 - * ....
22143 - * public DatatypeStreamingValidator createStreamingValidator( ValidationContext context ) {
22144 - * return new StreamingValidatorImpl(this,context);
22145 - * }
22146 - * ....
22147 - * }
22148 - * </XMP></PRE>
22149 - *
22150 - * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
22151 - */
22152 -public final class StreamingValidatorImpl implements DatatypeStreamingValidator {
22153 -
22154 - /** This buffer accumulates characters. */
22155 - private final StringBuffer buffer = new StringBuffer();
22156 -
22157 - /** Datatype obejct that creates this streaming validator. */
22158 - private final Datatype baseType;
22159 -
22160 - /** The current context. */
22161 - private final ValidationContext context;
22162 -
22163 - public void addCharacters( char[] buf, int start, int len ) {
22164 - // append characters to the current buffer.
22165 - buffer.append(buf,start,len);
22166 - }
22167 -
22168 - public boolean isValid() {
22169 - return baseType.isValid(buffer.toString(),context);
22170 - }
22171 -
22172 - public void checkValid() throws DatatypeException {
22173 - baseType.checkValid(buffer.toString(),context);
22174 - }
22175 -
22176 - public StreamingValidatorImpl( Datatype baseType, ValidationContext context ) {
22177 - this.baseType = baseType;
22178 - this.context = context;
22179 - }
22180 -}
22181 +package org.relaxng.datatype.helpers;
22182 +
22183 +import org.relaxng.datatype.*;
22184 +
22185 +/**
22186 + * Dummy implementation of {@link DatatypeStreamingValidator}.
22187 + *
22188 + * <p>
22189 + * This implementation can be used as a quick hack when the performance
22190 + * of streaming validation is not important. And this implementation
22191 + * also shows you how to implement the DatatypeStreamingValidator interface.
22192 + *
22193 + * <p>
22194 + * Typical usage would be:
22195 + * <PRE><XMP>
22196 + * class MyDatatype implements Datatype {
22197 + * ....
22198 + * public DatatypeStreamingValidator createStreamingValidator( ValidationContext context ) {
22199 + * return new StreamingValidatorImpl(this,context);
22200 + * }
22201 + * ....
22202 + * }
22203 + * </XMP></PRE>
22204 + *
22205 + * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
22206 + */
22207 +public final class StreamingValidatorImpl implements DatatypeStreamingValidator {
22208 +
22209 + /** This buffer accumulates characters. */
22210 + private final StringBuffer buffer = new StringBuffer();
22211 +
22212 + /** Datatype obejct that creates this streaming validator. */
22213 + private final Datatype baseType;
22214 +
22215 + /** The current context. */
22216 + private final ValidationContext context;
22217 +
22218 + public void addCharacters( char[] buf, int start, int len ) {
22219 + // append characters to the current buffer.
22220 + buffer.append(buf,start,len);
22221 + }
22222 +
22223 + public boolean isValid() {
22224 + return baseType.isValid(buffer.toString(),context);
22225 + }
22226 +
22227 + public void checkValid() throws DatatypeException {
22228 + baseType.checkValid(buffer.toString(),context);
22229 + }
22230 +
22231 + public StreamingValidatorImpl( Datatype baseType, ValidationContext context ) {
22232 + this.baseType = baseType;
22233 + this.context = context;
22234 + }
22235 +}
22236 Index: gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/ValidationContext.java
22237 ===================================================================
22238 --- gcc-4.2.3.orig/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/ValidationContext.java 2006-03-10 14:25:35.000000000 +0100
22239 +++ gcc-4.2.3/libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/ValidationContext.java 2008-05-21 13:45:54.370287167 +0200
22240 @@ -1,66 +1,66 @@
22241 -package org.relaxng.datatype;
22242 -
22243 -/**
22244 - * An interface that must be implemented by caller to
22245 - * provide context information that is necessary to
22246 - * perform validation of some Datatypes.
22247 - *
22248 - * @author <a href="mailto:jjc@jclark.com">James Clark</a>
22249 - * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
22250 - */
22251 -public interface ValidationContext {
22252 -
22253 - /**
22254 - * Resolves a namespace prefix to the corresponding namespace URI.
22255 - *
22256 - * This method is used for validating the QName type, for example.
22257 - *
22258 - * <p>
22259 - * If the prefix is "" (empty string), it indicates
22260 - * an unprefixed value. The callee
22261 - * should resolve it as for an unprefixed
22262 - * element, rather than for an unprefixed attribute.
22263 - *
22264 - * <p>
22265 - * If the prefix is "xml", then the callee must resolve
22266 - * this prefix into "http://www.w3.org/XML/1998/namespace",
22267 - * as defined in the XML Namespaces Recommendation.
22268 - *
22269 - * @return
22270 - * namespace URI of this prefix.
22271 - * If the specified prefix is not declared,
22272 - * the implementation must return null.
22273 - */
22274 - String resolveNamespacePrefix( String prefix );
22275 -
22276 - /**
22277 - * Returns the base URI of the context. The null string may be returned
22278 - * if no base URI is known.
22279 - */
22280 - String getBaseUri();
22281 -
22282 - /**
22283 - * Checks if an unparsed entity is declared with the
22284 - * specified name.
22285 - *
22286 - * @return
22287 - * true
22288 - * if the DTD has an unparsed entity declaration for
22289 - * the specified name.
22290 - * false
22291 - * otherwise.
22292 - */
22293 - boolean isUnparsedEntity( String entityName );
22294 -
22295 - /**
22296 - * Checks if a notation is declared with the
22297 - * specified name.
22298 - *
22299 - * @return
22300 - * true
22301 - * if the DTD has a notation declaration for the specified name.
22302 - * false
22303 - * otherwise.
22304 - */
22305 - boolean isNotation( String notationName );
22306 -}
22307 +package org.relaxng.datatype;
22308 +
22309 +/**
22310 + * An interface that must be implemented by caller to
22311 + * provide context information that is necessary to
22312 + * perform validation of some Datatypes.
22313 + *
22314 + * @author <a href="mailto:jjc@jclark.com">James Clark</a>
22315 + * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
22316 + */
22317 +public interface ValidationContext {
22318 +
22319 + /**
22320 + * Resolves a namespace prefix to the corresponding namespace URI.
22321 + *
22322 + * This method is used for validating the QName type, for example.
22323 + *
22324 + * <p>
22325 + * If the prefix is "" (empty string), it indicates
22326 + * an unprefixed value. The callee
22327 + * should resolve it as for an unprefixed
22328 + * element, rather than for an unprefixed attribute.
22329 + *
22330 + * <p>
22331 + * If the prefix is "xml", then the callee must resolve
22332 + * this prefix into "http://www.w3.org/XML/1998/namespace",
22333 + * as defined in the XML Namespaces Recommendation.
22334 + *
22335 + * @return
22336 + * namespace URI of this prefix.
22337 + * If the specified prefix is not declared,
22338 + * the implementation must return null.
22339 + */
22340 + String resolveNamespacePrefix( String prefix );
22341 +
22342 + /**
22343 + * Returns the base URI of the context. The null string may be returned
22344 + * if no base URI is known.
22345 + */
22346 + String getBaseUri();
22347 +
22348 + /**
22349 + * Checks if an unparsed entity is declared with the
22350 + * specified name.
22351 + *
22352 + * @return
22353 + * true
22354 + * if the DTD has an unparsed entity declaration for
22355 + * the specified name.
22356 + * false
22357 + * otherwise.
22358 + */
22359 + boolean isUnparsedEntity( String entityName );
22360 +
22361 + /**
22362 + * Checks if a notation is declared with the
22363 + * specified name.
22364 + *
22365 + * @return
22366 + * true
22367 + * if the DTD has a notation declaration for the specified name.
22368 + * false
22369 + * otherwise.
22370 + */
22371 + boolean isNotation( String notationName );
22372 +}
22373 Index: gcc-4.2.3/libjava/classpath/external/relaxngDatatype/README.txt
22374 ===================================================================
22375 --- gcc-4.2.3.orig/libjava/classpath/external/relaxngDatatype/README.txt 2006-03-10 14:25:35.000000000 +0100
22376 +++ gcc-4.2.3/libjava/classpath/external/relaxngDatatype/README.txt 2008-05-21 13:45:54.370287167 +0200
22377 @@ -1,54 +1,54 @@
22378 -======================================================================
22379 - README FILE FOR DATATYPE INTERFACES FOR RELAX NG
22380 -======================================================================
22381 -
22382 -
22383 -
22384 -RELAX NG supports multiple datatype vocabularies. To achive this, an
22385 -interface between datatype vocabularies and schema processors is
22386 -necessary. This interface is intended to be a standard Java interface
22387 -for this purpose.
22388 -
22389 -
22390 -----------------------------------------------------------------------
22391 -LICENSE
22392 -----------------------------------------------------------------------
22393 -
22394 -See copying.txt.
22395 -
22396 -Note: this license is the BSD license.
22397 -
22398 -
22399 -
22400 -----------------------------------------------------------------------
22401 -FOR DEVELOPER
22402 -----------------------------------------------------------------------
22403 -
22404 -If you are planning to implement a datatype library, A sample datatype
22405 -library implementation by James Clark is available at [1], which
22406 -comes with documentation and source code.
22407 -
22408 -If you are planning to implement a schema processor, then don't forget
22409 -to check out org.relaxng.datatype.helpers.DatatypeLibraryLoader, as
22410 -this allows you to dynamically locate datatype implementations.
22411 -
22412 -
22413 -----------------------------------------------------------------------
22414 -LINKS
22415 -----------------------------------------------------------------------
22416 -
22417 -* OASIS RELAX NG TC
22418 - http://www.oasis-open.org/committees/relax-ng/
22419 -* RELAX home page
22420 - http://www.xml.gr.jp/relax/
22421 -
22422 -
22423 -----------------------------------------------------------------------
22424 -REFERENCES
22425 -----------------------------------------------------------------------
22426 -[1] Sample datatype library implementation by James Clark
22427 - http://www.thaiopensource.com/relaxng/datatype-sample.zip
22428 -
22429 -Document written by Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
22430 -======================================================================
22431 -END OF README
22432 +======================================================================
22433 + README FILE FOR DATATYPE INTERFACES FOR RELAX NG
22434 +======================================================================
22435 +
22436 +
22437 +
22438 +RELAX NG supports multiple datatype vocabularies. To achive this, an
22439 +interface between datatype vocabularies and schema processors is
22440 +necessary. This interface is intended to be a standard Java interface
22441 +for this purpose.
22442 +
22443 +
22444 +----------------------------------------------------------------------
22445 +LICENSE
22446 +----------------------------------------------------------------------
22447 +
22448 +See copying.txt.
22449 +
22450 +Note: this license is the BSD license.
22451 +
22452 +
22453 +
22454 +----------------------------------------------------------------------
22455 +FOR DEVELOPER
22456 +----------------------------------------------------------------------
22457 +
22458 +If you are planning to implement a datatype library, A sample datatype
22459 +library implementation by James Clark is available at [1], which
22460 +comes with documentation and source code.
22461 +
22462 +If you are planning to implement a schema processor, then don't forget
22463 +to check out org.relaxng.datatype.helpers.DatatypeLibraryLoader, as
22464 +this allows you to dynamically locate datatype implementations.
22465 +
22466 +
22467 +----------------------------------------------------------------------
22468 +LINKS
22469 +----------------------------------------------------------------------
22470 +
22471 +* OASIS RELAX NG TC
22472 + http://www.oasis-open.org/committees/relax-ng/
22473 +* RELAX home page
22474 + http://www.xml.gr.jp/relax/
22475 +
22476 +
22477 +----------------------------------------------------------------------
22478 +REFERENCES
22479 +----------------------------------------------------------------------
22480 +[1] Sample datatype library implementation by James Clark
22481 + http://www.thaiopensource.com/relaxng/datatype-sample.zip
22482 +
22483 +Document written by Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
22484 +======================================================================
22485 +END OF README
22486 Index: gcc-4.2.3/libstdc++-v3/config/os/gnu-linux/ctype_base.h
22487 ===================================================================
22488 --- gcc-4.2.3.orig/libstdc++-v3/config/os/gnu-linux/ctype_base.h 2006-12-01 13:56:23.000000000 +0100
22489 +++ gcc-4.2.3/libstdc++-v3/config/os/gnu-linux/ctype_base.h 2008-05-21 13:45:54.370287167 +0200
22490 @@ -31,6 +31,8 @@
22491 //
22492 // ISO C++ 14882: 22.1 Locales
22493 //
22494 +#include <features.h>
22495 +#include <ctype.h>
22496
22497 /** @file ctype_base.h
22498 * This is an internal header file, included by other library headers.
22499 @@ -45,8 +47,12 @@
22500 struct ctype_base
22501 {
22502 // Non-standard typedefs.
22503 - typedef const int* __to_type;
22504 -
22505 +#ifdef __UCLIBC__
22506 + typedef const __ctype_touplow_t* __to_type;
22507 +#else
22508 + typedef const int* __to_type;
22509 +#endif
22510 +
22511 // NB: Offsets into ctype<char>::_M_table force a particular size
22512 // on the mask type. Because of this, we don't use an enum.
22513 typedef unsigned short mask;
22514 Index: gcc-4.2.3/libstdc++-v3/include/Makefile.in
22515 ===================================================================
22516 --- gcc-4.2.3.orig/libstdc++-v3/include/Makefile.in 2007-07-05 13:46:00.000000000 +0200
22517 +++ gcc-4.2.3/libstdc++-v3/include/Makefile.in 2008-05-21 13:45:54.374287956 +0200
22518 @@ -36,6 +36,7 @@
22519 build_triplet = @build@
22520 host_triplet = @host@
22521 target_triplet = @target@
22522 +LIBOBJDIR =
22523 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
22524 $(top_srcdir)/fragment.am
22525 subdir = include
22526 Index: gcc-4.2.3/libstdc++-v3/libmath/Makefile.in
22527 ===================================================================
22528 --- gcc-4.2.3.orig/libstdc++-v3/libmath/Makefile.in 2006-10-16 21:08:22.000000000 +0200
22529 +++ gcc-4.2.3/libstdc++-v3/libmath/Makefile.in 2008-05-21 13:45:54.374287956 +0200
22530 @@ -37,6 +37,7 @@
22531 build_triplet = @build@
22532 host_triplet = @host@
22533 target_triplet = @target@
22534 +LIBOBJDIR =
22535 subdir = libmath
22536 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
22537 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
22538 Index: gcc-4.2.3/libstdc++-v3/libsupc++/Makefile.in
22539 ===================================================================
22540 --- gcc-4.2.3.orig/libstdc++-v3/libsupc++/Makefile.in 2006-10-16 21:08:22.000000000 +0200
22541 +++ gcc-4.2.3/libstdc++-v3/libsupc++/Makefile.in 2008-05-21 13:45:54.374287956 +0200
22542 @@ -38,6 +38,7 @@
22543 build_triplet = @build@
22544 host_triplet = @host@
22545 target_triplet = @target@
22546 +LIBOBJDIR =
22547 DIST_COMMON = $(glibcxxinstall_HEADERS) $(srcdir)/Makefile.am \
22548 $(srcdir)/Makefile.in $(top_srcdir)/fragment.am
22549 subdir = libsupc++
22550 Index: gcc-4.2.3/libstdc++-v3/Makefile.in
22551 ===================================================================
22552 --- gcc-4.2.3.orig/libstdc++-v3/Makefile.in 2006-10-16 21:08:22.000000000 +0200
22553 +++ gcc-4.2.3/libstdc++-v3/Makefile.in 2008-05-21 13:45:54.374287956 +0200
22554 @@ -36,6 +36,7 @@
22555 build_triplet = @build@
22556 host_triplet = @host@
22557 target_triplet = @target@
22558 +LIBOBJDIR =
22559 DIST_COMMON = README $(am__configure_deps) $(srcdir)/../config.guess \
22560 $(srcdir)/../config.sub $(srcdir)/../install-sh \
22561 $(srcdir)/../ltmain.sh $(srcdir)/../missing \
22562 Index: gcc-4.2.3/libstdc++-v3/po/Makefile.in
22563 ===================================================================
22564 --- gcc-4.2.3.orig/libstdc++-v3/po/Makefile.in 2006-10-16 21:08:22.000000000 +0200
22565 +++ gcc-4.2.3/libstdc++-v3/po/Makefile.in 2008-05-21 13:45:54.378287906 +0200
22566 @@ -36,6 +36,7 @@
22567 build_triplet = @build@
22568 host_triplet = @host@
22569 target_triplet = @target@
22570 +LIBOBJDIR =
22571 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
22572 $(top_srcdir)/fragment.am
22573 subdir = po
22574 Index: gcc-4.2.3/libstdc++-v3/src/Makefile.in
22575 ===================================================================
22576 --- gcc-4.2.3.orig/libstdc++-v3/src/Makefile.in 2008-05-21 13:45:47.465287535 +0200
22577 +++ gcc-4.2.3/libstdc++-v3/src/Makefile.in 2008-05-21 13:45:54.378287906 +0200
22578 @@ -36,6 +36,7 @@
22579 build_triplet = @build@
22580 host_triplet = @host@
22581 target_triplet = @target@
22582 +LIBOBJDIR =
22583 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
22584 $(top_srcdir)/fragment.am
22585 subdir = src
22586 Index: gcc-4.2.3/libstdc++-v3/acinclude.m4
22587 ===================================================================
22588 --- gcc-4.2.3.orig/libstdc++-v3/acinclude.m4 2008-05-21 13:45:43.925289703 +0200
22589 +++ gcc-4.2.3/libstdc++-v3/acinclude.m4 2008-05-21 13:45:54.378287906 +0200
22590 @@ -1392,8 +1392,8 @@
22591 #endif
22592 int main()
22593 {
22594 - const char __one[] = "Äuglein Augmen";
22595 - const char __two[] = "Äuglein";
22596 + const char __one[] = "Äuglein Augmen";
22597 + const char __two[] = "Äuglein";
22598 int i;
22599 int j;
22600 __locale_t loc;