3 @@ -3602,6 +3602,9 @@ case "${target}" in
5 noconfigdirs="$noconfigdirs target-libstdc++-v3 ${libgcj}"
8 + noconfigdirs="$noconfigdirs target-libffi"
10 *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
11 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
14 +++ b/gcc/config/ubicom32/constraints.md
16 +; Constraint definitions for Ubicom32
18 +; Copyright (C) 2009 Free Software Foundation, Inc.
19 +; Contributed by Ubicom, Inc.
21 +; This file is part of GCC.
23 +; GCC is free software; you can redistribute it and/or modify it
24 +; under the terms of the GNU General Public License as published
25 +; by the Free Software Foundation; either version 3, or (at your
26 +; option) any later version.
28 +; GCC is distributed in the hope that it will be useful, but WITHOUT
29 +; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
30 +; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
31 +; License for more details.
33 +; You should have received a copy of the GNU General Public License
34 +; along with GCC; see the file COPYING3. If not see
35 +; <http://www.gnu.org/licenses/>.
37 +(define_register_constraint "a" "ALL_ADDRESS_REGS"
40 +(define_register_constraint "d" "DATA_REGS"
43 +(define_register_constraint "h" "ACC_REGS"
44 + "An accumulator register.")
46 +(define_register_constraint "l" "ACC_LO_REGS"
47 + "An accn_lo register.")
49 +(define_register_constraint "Z" "FDPIC_REG"
50 + "The FD-PIC GOT pointer: A0.")
52 +(define_constraint "I"
53 + "An 8-bit signed constant value."
54 + (and (match_code "const_int")
55 + (match_test "(ival >= -128) && (ival <= 127)")))
57 +(define_constraint "Q"
58 + "An 8-bit signed constant value represented as unsigned."
59 + (and (match_code "const_int")
60 + (match_test "(ival >= 0x00) && (ival <= 0xff)")))
62 +(define_constraint "R"
63 + "An 8-bit signed constant value represented as unsigned."
64 + (and (match_code "const_int")
65 + (match_test "((ival >= 0x0000) && (ival <= 0x007f)) || ((ival >= 0xff80) && (ival <= 0xffff))")))
67 +(define_constraint "J"
68 + "A 7-bit unsigned constant value."
69 + (and (match_code "const_int")
70 + (match_test "(ival >= 0) && (ival <= 127)")))
72 +(define_constraint "K"
73 + "A 7-bit unsigned constant value shifted << 1."
74 + (and (match_code "const_int")
75 + (match_test "(ival >= 0) && (ival <= 254) && ((ival & 1) == 0)")))
77 +(define_constraint "L"
78 + "A 7-bit unsigned constant value shifted << 2."
79 + (and (match_code "const_int")
80 + (match_test "(ival >= 0) && (ival <= 508) && ((ival & 3) == 0)")))
82 +(define_constraint "M"
83 + "A 5-bit unsigned constant value."
84 + (and (match_code "const_int")
85 + (match_test "(ival >= 0) && (ival <= 31)")))
87 +(define_constraint "N"
88 + "A signed 16 bit constant value."
89 + (and (match_code "const_int")
90 + (match_test "(ival >= -32768) && (ival <= 32767)")))
92 +(define_constraint "O"
93 + "An exact bitmask of contiguous 1 bits starting at bit 0."
94 + (and (match_code "const_int")
95 + (match_test "exact_log2 (ival + 1) != -1")))
97 +(define_constraint "P"
98 + "A 7-bit negative constant value shifted << 2."
99 + (and (match_code "const_int")
100 + (match_test "(ival >= -504) && (ival <= 0) && ((ival & 3) == 0)")))
102 +(define_constraint "S"
103 + "A symbolic reference."
104 + (match_code "symbol_ref"))
106 +(define_constraint "Y"
107 + "An FD-PIC symbolic reference."
108 + (and (match_test "TARGET_FDPIC")
109 + (match_test "GET_CODE (op) == UNSPEC")
110 + (ior (match_test "XINT (op, 1) == UNSPEC_FDPIC_GOT")
111 + (match_test "XINT (op, 1) == UNSPEC_FDPIC_GOT_FUNCDESC"))))
113 +(define_memory_constraint "T1"
114 + "A memory operand that can be used for .1 instruction."
115 + (and (match_test "memory_operand (op, GET_MODE(op))")
116 + (match_test "GET_MODE (op) == QImode")))
118 +(define_memory_constraint "T2"
119 + "A memory operand that can be used for .2 instruction."
120 + (and (match_test "memory_operand (op, GET_MODE(op))")
121 + (match_test "GET_MODE (op) == HImode")))
123 +(define_memory_constraint "T4"
124 + "A memory operand that can be used for .4 instruction."
125 + (and (match_test "memory_operand (op, GET_MODE(op))")
126 + (ior (match_test "GET_MODE (op) == SImode")
127 + (match_test "GET_MODE (op) == DImode")
128 + (match_test "GET_MODE (op) == SFmode"))))
130 +(define_memory_constraint "U1"
131 + "An offsettable memory operand that can be used for .1 instruction."
132 + (and (match_test "memory_operand (op, GET_MODE(op))")
133 + (match_test "GET_MODE (op) == QImode")
134 + (match_test "GET_CODE (XEXP (op, 0)) != POST_INC")
135 + (match_test "GET_CODE (XEXP (op, 0)) != PRE_INC")
136 + (match_test "GET_CODE (XEXP (op, 0)) != POST_DEC")
137 + (match_test "GET_CODE (XEXP (op, 0)) != PRE_DEC")
138 + (match_test "GET_CODE (XEXP (op, 0)) != POST_MODIFY")
139 + (match_test "GET_CODE (XEXP (op, 0)) != PRE_MODIFY")))
141 +(define_memory_constraint "U2"
142 + "An offsettable memory operand that can be used for .2 instruction."
143 + (and (match_test "memory_operand (op, GET_MODE(op))")
144 + (match_test "GET_MODE (op) == HImode")
145 + (match_test "GET_CODE (XEXP (op, 0)) != POST_INC")
146 + (match_test "GET_CODE (XEXP (op, 0)) != PRE_INC")
147 + (match_test "GET_CODE (XEXP (op, 0)) != POST_DEC")
148 + (match_test "GET_CODE (XEXP (op, 0)) != PRE_DEC")
149 + (match_test "GET_CODE (XEXP (op, 0)) != POST_MODIFY")
150 + (match_test "GET_CODE (XEXP (op, 0)) != PRE_MODIFY")))
152 +(define_memory_constraint "U4"
153 + "An offsettable memory operand that can be used for .4 instruction."
154 + (and (match_test "memory_operand (op, GET_MODE(op))")
155 + (ior (match_test "GET_MODE (op) == SImode")
156 + (match_test "GET_MODE (op) == DImode")
157 + (match_test "GET_MODE (op) == SFmode"))
158 + (match_test "GET_CODE (XEXP (op, 0)) != POST_INC")
159 + (match_test "GET_CODE (XEXP (op, 0)) != PRE_INC")
160 + (match_test "GET_CODE (XEXP (op, 0)) != POST_DEC")
161 + (match_test "GET_CODE (XEXP (op, 0)) != PRE_DEC")
162 + (match_test "GET_CODE (XEXP (op, 0)) != POST_MODIFY")
163 + (match_test "GET_CODE (XEXP (op, 0)) != PRE_MODIFY")))
166 +++ b/gcc/config/ubicom32/crti.S
168 +/* Specialized code needed to support construction and destruction of
169 + file-scope objects in C++ and Java code, and to support exception handling.
170 + Copyright (C) 1999 Free Software Foundation, Inc.
171 + Contributed by Charles-Antoine Gauthier (charles.gauthier@iit.nrc.ca).
173 +This file is part of GCC.
175 +GCC is free software; you can redistribute it and/or modify
176 +it under the terms of the GNU General Public License as published by
177 +the Free Software Foundation; either version 2, or (at your option)
180 +GCC is distributed in the hope that it will be useful,
181 +but WITHOUT ANY WARRANTY; without even the implied warranty of
182 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
183 +GNU General Public License for more details.
185 +You should have received a copy of the GNU General Public License
186 +along with GCC; see the file COPYING. If not, write to
187 +the Free Software Foundation, 59 Temple Place - Suite 330,
188 +Boston, MA 02111-1307, USA. */
190 +/* As a special exception, if you link this library with files
191 + compiled with GCC to produce an executable, this does not cause
192 + the resulting executable to be covered by the GNU General Public License.
193 + This exception does not however invalidate any other reasons why
194 + the executable file might be covered by the GNU General Public License. */
197 + * This file just supplies function prologues for the .init and .fini
198 + * sections. It is linked in before crtbegin.o.
201 + .ident "GNU C crti.o"
206 + .type _init, @function
208 + move.4 -4(sp)++, a5
209 +#ifdef __UBICOM32_FDPIC__
210 + move.4 -4(sp)++, a0
216 + .type _fini, @function
218 + move.4 -4(sp)++, a5
219 +#ifdef __UBICOM32_FDPIC__
220 + move.4 -4(sp)++, a0
223 +++ b/gcc/config/ubicom32/crtn.S
225 +/* Specialized code needed to support construction and destruction of
226 + file-scope objects in C++ and Java code, and to support exception handling.
227 + Copyright (C) 1999 Free Software Foundation, Inc.
228 + Contributed by Charles-Antoine Gauthier (charles.gauthier@iit.nrc.ca).
230 +This file is part of GCC.
232 +GCC is free software; you can redistribute it and/or modify
233 +it under the terms of the GNU General Public License as published by
234 +the Free Software Foundation; either version 2, or (at your option)
237 +GCC is distributed in the hope that it will be useful,
238 +but WITHOUT ANY WARRANTY; without even the implied warranty of
239 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
240 +GNU General Public License for more details.
242 +You should have received a copy of the GNU General Public License
243 +along with GCC; see the file COPYING. If not, write to
244 +the Free Software Foundation, 59 Temple Place - Suite 330,
245 +Boston, MA 02111-1307, USA. */
247 +/* As a special exception, if you link this library with files
248 + compiled with GCC to produce an executable, this does not cause
249 + the resulting executable to be covered by the GNU General Public License.
250 + This exception does not however invalidate any other reasons why
251 + the executable file might be covered by the GNU General Public License. */
254 + * This file supplies function epilogues for the .init and .fini sections.
255 + * It is linked in after all other files.
259 + .ident "GNU C crtn.o"
262 +#ifdef __UBICOM32_FDPIC__
268 +#ifdef __UBICOM32_FDPIC__
273 +++ b/gcc/config/ubicom32/elf.h
275 +#undef STARTFILE_SPEC
276 +#define STARTFILE_SPEC "\
277 +%{msim:%{!shared:crt0%O%s}} \
278 +crti%O%s crtbegin%O%s"
281 +#define ENDFILE_SPEC "crtend%O%s crtn%O%s"
283 +#ifdef __UBICOM32_FDPIC__
284 +#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
285 + asm (SECTION_OP); \
286 + asm ("move.4 a0, 0(sp);\n\t" \
287 + "call a5," USER_LABEL_PREFIX #FUNC ";"); \
288 + asm (TEXT_SECTION_ASM_OP);
291 +#undef SUBTARGET_DRIVER_SELF_SPECS
292 +#define SUBTARGET_DRIVER_SELF_SPECS \
295 +#define NO_IMPLICIT_EXTERN_C
298 + * We need this to compile crtbegin/crtend. This should really be picked
299 + * up from elfos.h but at the moment including elfos.h causes other more
300 + * serous linker issues.
302 +#define INIT_SECTION_ASM_OP "\t.section\t.init"
303 +#define FINI_SECTION_ASM_OP "\t.section\t.fini"
305 +++ b/gcc/config/ubicom32/linux.h
307 +/* Definitions of target machine for Ubicom32-uclinux
309 + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
310 + 2009 Free Software Foundation, Inc.
311 + Contributed by Ubicom, Inc.
313 + This file is part of GCC.
315 + GCC is free software; you can redistribute it and/or modify it
316 + under the terms of the GNU General Public License as published
317 + by the Free Software Foundation; either version 3, or (at your
318 + option) any later version.
320 + GCC is distributed in the hope that it will be useful, but WITHOUT
321 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
322 + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
323 + License for more details.
325 + You should have received a copy of the GNU General Public License
326 + along with GCC; see the file COPYING3. If not see
327 + <http://www.gnu.org/licenses/>. */
329 +/* Don't assume anything about the header files. */
330 +#define NO_IMPLICIT_EXTERN_C
334 + "%{pthread:-lpthread} " \
337 +#undef LINK_GCC_C_SEQUENCE_SPEC
338 +#define LINK_GCC_C_SEQUENCE_SPEC \
339 + "%{static:--start-group} %G %L %{static:--end-group} " \
342 +#undef STARTFILE_SPEC
343 +#define STARTFILE_SPEC \
344 + "%{!shared: %{pg|p|profile:gcrt1%O%s;pie:Scrt1%O%s;:crt1%O%s}} " \
345 + "crtreloc%O%s crti%O%s %{shared|pie:crtbeginS%O%s;:crtbegin%O%s}"
348 +#define ENDFILE_SPEC \
349 + "%{shared|pie:crtendS%O%s;:crtend%O%s} crtn%O%s"
351 +/* taken from linux.h */
352 +/* The GNU C++ standard library requires that these macros be defined. */
353 +#undef CPLUSPLUS_CPP_SPEC
354 +#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
356 +#define TARGET_OS_CPP_BUILTINS() \
358 + builtin_define_std ("__UBICOM32__"); \
359 + builtin_define_std ("__ubicom32__"); \
360 + builtin_define ("__gnu_linux__"); \
361 + builtin_define_std ("linux"); \
362 + builtin_define_std ("unix"); \
363 + builtin_assert ("system=linux"); \
364 + builtin_assert ("system=unix"); \
365 + builtin_assert ("system=posix"); \
368 +#define OBJECT_FORMAT_ELF
371 +#undef DRIVER_SELF_SPECS
372 +#define DRIVER_SELF_SPECS \
373 + "%{!mno-fdpic:-mfdpic}"
376 +#define LINK_SPEC "%{mfdpic: -m elf32ubicom32fdpic -z text } %{shared} %{pie} \
377 + %{static:-dn -Bstatic} \
378 + %{shared:-G -Bdynamic} \
379 + %{!shared: %{!static: \
380 + %{rdynamic:-export-dynamic} \
381 + %{!dynamic-linker:-dynamic-linker /lib/ld-uClibc.so.0}} \
385 +#define MD_UNWIND_SUPPORT "config/bfin/linux-unwind.h"
388 +++ b/gcc/config/ubicom32/predicates.md
390 +; Predicate definitions for Ubicom32.
392 +; Copyright (C) 2009 Free Software Foundation, Inc.
393 +; Contributed by Ubicom, Inc.
395 +; This file is part of GCC.
397 +; GCC is free software; you can redistribute it and/or modify it
398 +; under the terms of the GNU General Public License as published
399 +; by the Free Software Foundation; either version 3, or (at your
400 +; option) any later version.
402 +; GCC is distributed in the hope that it will be useful, but WITHOUT
403 +; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
404 +; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
405 +; License for more details.
407 +; You should have received a copy of the GNU General Public License
408 +; along with GCC; see the file COPYING3. If not see
409 +; <http://www.gnu.org/licenses/>.
411 +(define_predicate "ubicom32_move_operand"
412 + (match_code "const_int, const_double, const, mem, subreg, reg, lo_sum")
414 + if (CONST_INT_P (op))
417 + if (GET_CODE (op) == CONST_DOUBLE)
420 + if (GET_CODE (op) == CONST)
421 + return memory_address_p (mode, op);
423 + if (GET_MODE (op) != mode)
427 + return memory_address_p (mode, XEXP (op, 0));
429 + if (GET_CODE (op) == SUBREG) {
430 + op = SUBREG_REG (op);
438 + /* Paradoxical SUBREG. */
439 + if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (GET_MODE (op)))
442 + return memory_address_p (GET_MODE (op), XEXP (op, 0));
445 + return register_operand (op, mode);
448 +;; Returns true if OP is either a symbol reference or a sum of a
449 +;; symbol reference and a constant.
451 +(define_predicate "ubicom32_symbolic_address_operand"
452 + (match_code "symbol_ref, label_ref, const")
454 + switch (GET_CODE (op))
462 + return ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
463 + || GET_CODE (XEXP (op, 0)) == LABEL_REF)
464 + && CONST_INT_P (XEXP (op, 1)));
471 +;; Return true if operand is the uClinux FD-PIC register.
473 +(define_predicate "ubicom32_fdpic_operand"
476 + if (! TARGET_FDPIC)
482 + if (GET_MODE (op) != mode && mode != VOIDmode)
485 + if (REGNO (op) != FDPIC_REGNUM && REGNO (op) < FIRST_PSEUDO_REGISTER)
491 +(define_predicate "ubicom32_fdpic_got_offset_operand"
492 + (match_code "unspec")
494 + if (! TARGET_FDPIC)
497 + if (GET_CODE (op) != UNSPEC)
500 + if (XINT (op, 1) != UNSPEC_FDPIC_GOT
501 + && XINT (op, 1) != UNSPEC_FDPIC_GOT_FUNCDESC)
507 +(define_predicate "ubicom32_arith_operand"
508 + (match_code "subreg, reg, const_int, lo_sum, mem")
510 + return (ubicom32_move_operand (op, mode)
511 + && ! ubicom32_symbolic_address_operand (op, mode)
512 + && (! CONST_INT_P (op)
513 + || satisfies_constraint_I (op)));
516 +(define_predicate "ubicom32_arith_operand_dot1"
517 + (match_code "subreg, reg, const_int, lo_sum, mem")
519 + return (ubicom32_move_operand (op, mode)
520 + && ! ubicom32_symbolic_address_operand (op, mode)
521 + && (! CONST_INT_P (op)
522 + || satisfies_constraint_Q (op)));
525 +(define_predicate "ubicom32_arith_operand_dot2"
526 + (match_code "subreg, reg, const_int, lo_sum, mem")
528 + return (ubicom32_move_operand (op, mode)
529 + && ! ubicom32_symbolic_address_operand (op, mode)
530 + && (! CONST_INT_P (op)
531 + || satisfies_constraint_R (op)));
534 +(define_predicate "ubicom32_compare_operand"
535 + (match_code "subreg, reg, const_int, lo_sum, mem")
537 + return (ubicom32_move_operand (op, mode)
538 + && ! ubicom32_symbolic_address_operand (op, mode)
539 + && (! CONST_INT_P (op)
540 + || satisfies_constraint_N (op)));
543 +(define_predicate "ubicom32_compare_operator"
544 + (match_code "compare"))
546 +(define_predicate "ubicom32_and_or_si3_operand"
547 + (match_code "subreg, reg, const_int, lo_sum, mem")
549 + return (ubicom32_arith_operand (op, mode)
550 + || (CONST_INT_P (op)
551 + && ((exact_log2 (INTVAL (op) + 1) != -1
552 + && exact_log2 (INTVAL (op) + 1) <= 31)
553 + || (exact_log2 (INTVAL (op)) != -1
554 + && exact_log2 (INTVAL (op)) <= 31)
555 + || (exact_log2 (~INTVAL (op)) != -1
556 + && exact_log2 (~INTVAL (op)) <= 31))));
559 +(define_predicate "ubicom32_and_or_hi3_operand"
560 + (match_code "subreg, reg, const_int, lo_sum, mem")
562 + return (ubicom32_arith_operand (op, mode)
563 + || (CONST_INT_P (op)
564 + && exact_log2 (INTVAL (op) + 1) != -1
565 + && exact_log2 (INTVAL (op) + 1) <= 15));
568 +(define_predicate "ubicom32_mem_or_address_register_operand"
569 + (match_code "subreg, reg, mem")
571 + unsigned int regno;
574 + && memory_operand (op, mode))
578 + regno = REGNO (op);
579 + else if (GET_CODE (op) == SUBREG && REG_P (SUBREG_REG (op)))
582 + if (REGNO (SUBREG_REG (op)) >= FIRST_PSEUDO_REGISTER)
583 + offset = SUBREG_BYTE (op) / (GET_MODE_SIZE (GET_MODE (op)));
585 + offset = subreg_regno_offset (REGNO (SUBREG_REG (op)),
586 + GET_MODE (SUBREG_REG (op)),
589 + regno = REGNO (SUBREG_REG (op)) + offset;
594 + return (regno >= FIRST_PSEUDO_REGISTER
595 + || REGNO_REG_CLASS (regno) == FDPIC_REG
596 + || REGNO_REG_CLASS (regno) == ADDRESS_REGS);
599 +(define_predicate "ubicom32_data_register_operand"
600 + (match_code "subreg, reg")
602 + unsigned int regno;
605 + regno = REGNO (op);
606 + else if (GET_CODE (op) == SUBREG && REG_P (SUBREG_REG (op)))
609 + if (REGNO (SUBREG_REG (op)) >= FIRST_PSEUDO_REGISTER)
610 + offset = SUBREG_BYTE (op) / (GET_MODE_SIZE (GET_MODE (op)));
612 + offset = subreg_regno_offset (REGNO (SUBREG_REG (op)),
613 + GET_MODE (SUBREG_REG (op)),
616 + regno = REGNO (SUBREG_REG (op)) + offset;
621 + return ((regno >= FIRST_PSEUDO_REGISTER
622 + && regno != REGNO (virtual_stack_vars_rtx))
623 + || REGNO_REG_CLASS (regno) == DATA_REGS);
626 +(define_predicate "ubicom32_address_register_operand"
627 + (match_code "subreg, reg")
629 + unsigned int regno;
632 + regno = REGNO (op);
633 + else if (GET_CODE (op) == SUBREG && REG_P (SUBREG_REG (op)))
636 + if (REGNO (SUBREG_REG (op)) >= FIRST_PSEUDO_REGISTER)
637 + offset = SUBREG_BYTE (op) / (GET_MODE_SIZE (GET_MODE (op)));
639 + offset = subreg_regno_offset (REGNO (SUBREG_REG (op)),
640 + GET_MODE (SUBREG_REG (op)),
643 + regno = REGNO (SUBREG_REG (op)) + offset;
648 + return (regno >= FIRST_PSEUDO_REGISTER
649 + || REGNO_REG_CLASS (regno) == FDPIC_REG
650 + || REGNO_REG_CLASS (regno) == ADDRESS_REGS);
653 +(define_predicate "ubicom32_acc_lo_register_operand"
654 + (match_code "subreg, reg")
656 + unsigned int regno;
659 + regno = REGNO (op);
660 + else if (GET_CODE (op) == SUBREG && REG_P (SUBREG_REG (op)))
663 + if (REGNO (SUBREG_REG (op)) >= FIRST_PSEUDO_REGISTER)
664 + offset = SUBREG_BYTE (op) / (GET_MODE_SIZE (GET_MODE (op)));
666 + offset = subreg_regno_offset (REGNO (SUBREG_REG (op)),
667 + GET_MODE (SUBREG_REG (op)),
670 + regno = REGNO (SUBREG_REG (op)) + offset;
675 + return ((regno >= FIRST_PSEUDO_REGISTER
676 + && regno != REGNO (virtual_stack_vars_rtx))
677 + || REGNO_REG_CLASS (regno) == ACC_LO_REGS);
680 +(define_predicate "ubicom32_acc_hi_register_operand"
681 + (match_code "subreg, reg")
683 + unsigned int regno;
686 + regno = REGNO (op);
687 + else if (GET_CODE (op) == SUBREG && REG_P (SUBREG_REG (op)))
690 + if (REGNO (SUBREG_REG (op)) >= FIRST_PSEUDO_REGISTER)
691 + offset = SUBREG_BYTE (op) / (GET_MODE_SIZE (GET_MODE (op)));
693 + offset = subreg_regno_offset (REGNO (SUBREG_REG (op)),
694 + GET_MODE (SUBREG_REG (op)),
697 + regno = REGNO (SUBREG_REG (op)) + offset;
702 + return ((regno >= FIRST_PSEUDO_REGISTER
703 + && regno != REGNO (virtual_stack_vars_rtx))
704 + || REGNO_REG_CLASS (regno) == ACC_REGS);
707 +(define_predicate "ubicom32_call_address_operand"
708 + (match_code "symbol_ref, subreg, reg")
710 + return (GET_CODE (op) == SYMBOL_REF || REG_P (op));
713 +(define_special_predicate "ubicom32_cc_register_operand"
714 + (and (match_code "reg")
715 + (match_test "REGNO (op) == CC_REGNUM")))
718 +++ b/gcc/config/ubicom32/t-ubicom32
720 +# Name of assembly file containing libgcc1 functions.
721 +# This entry must be present, but it can be empty if the target does
722 +# not need any assembler functions to support its code generation.
725 +# Alternatively if assembler functions *are* needed then define the
727 +# CROSS_LIBGCC1 = libgcc1-asm.a
730 + $(srcdir)/config/udivmodsi4.c \
731 + $(srcdir)/config/divmod.c \
732 + $(srcdir)/config/udivmod.c
734 +# If any special flags are necessary when building libgcc2 put them here.
736 +# TARGET_LIBGCC2_CFLAGS =
738 +# We want fine grained libraries, so use the new code to build the
739 +# floating point emulation libraries.
743 +fp-bit.c: $(srcdir)/config/fp-bit.c
744 + echo '#define FLOAT' > fp-bit.c
745 + cat $(srcdir)/config/fp-bit.c >> fp-bit.c
747 +dp-bit.c: $(srcdir)/config/fp-bit.c
748 + cat $(srcdir)/config/fp-bit.c > dp-bit.c
750 +# Commented out to speed up compiler development!
752 +# MULTILIB_OPTIONS = march=ubicom32v1/march=ubicom32v2/march=ubicom32v3/march=ubicom32v4
753 +# MULTILIB_DIRNAMES = ubicom32v1 ubicom32v2 ubicom32v3 ubicom32v4
755 +MULTILIB_OPTIONS = march=ubicom32v3/march=ubicom32v4
756 +MULTILIB_OPTIONS += mfdpic
757 +MULTILIB_OPTIONS += mno-ipos-abi/mipos-abi
758 +MULTILIB_OPTIONS += fno-leading-underscore/fleading-underscore
760 +# Assemble startup files.
761 +$(T)crti.o: $(srcdir)/config/ubicom32/crti.S $(GCC_PASSES)
762 + $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
763 + -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/ubicom32/crti.S
765 +$(T)crtn.o: $(srcdir)/config/ubicom32/crtn.S $(GCC_PASSES)
766 + $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
767 + -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/ubicom32/crtn.S
769 +# these parts are required because uClibc ldso needs them to link.
770 +# they are not in the specfile so they will not be included automatically.
771 +EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crtbeginS.o crtendS.o crti.o crtn.o
773 +++ b/gcc/config/ubicom32/t-ubicom32-linux
775 +# Name of assembly file containing libgcc1 functions.
776 +# This entry must be present, but it can be empty if the target does
777 +# not need any assembler functions to support its code generation.
780 +# Alternatively if assembler functions *are* needed then define the
782 +# CROSS_LIBGCC1 = libgcc1-asm.a
785 + $(srcdir)/config/udivmodsi4.c \
786 + $(srcdir)/config/divmod.c \
787 + $(srcdir)/config/udivmod.c
789 +# If any special flags are necessary when building libgcc2 put them here.
791 +# TARGET_LIBGCC2_CFLAGS =
793 +# We want fine grained libraries, so use the new code to build the
794 +# floating point emulation libraries.
798 +fp-bit.c: $(srcdir)/config/fp-bit.c
799 + echo '#define FLOAT' > fp-bit.c
800 + cat $(srcdir)/config/fp-bit.c >> fp-bit.c
802 +dp-bit.c: $(srcdir)/config/fp-bit.c
803 + cat $(srcdir)/config/fp-bit.c > dp-bit.c
805 +# We only support v3 and v4 ISAs for uClinux.
807 +MULTILIB_OPTIONS = march=ubicom32v3/march=ubicom32v4
809 +#EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crtbeginS.o crtendS.o
811 +++ b/gcc/config/ubicom32/t-ubicom32-uclinux
813 +# Name of assembly file containing libgcc1 functions.
814 +# This entry must be present, but it can be empty if the target does
815 +# not need any assembler functions to support its code generation.
818 +# Alternatively if assembler functions *are* needed then define the
820 +# CROSS_LIBGCC1 = libgcc1-asm.a
823 + $(srcdir)/config/udivmodsi4.c \
824 + $(srcdir)/config/divmod.c \
825 + $(srcdir)/config/udivmod.c
827 +# If any special flags are necessary when building libgcc2 put them here.
829 +# TARGET_LIBGCC2_CFLAGS =
831 +# We want fine grained libraries, so use the new code to build the
832 +# floating point emulation libraries.
836 +fp-bit.c: $(srcdir)/config/fp-bit.c
837 + echo '#define FLOAT' > fp-bit.c
838 + cat $(srcdir)/config/fp-bit.c >> fp-bit.c
840 +dp-bit.c: $(srcdir)/config/fp-bit.c
841 + cat $(srcdir)/config/fp-bit.c > dp-bit.c
843 +# We only support v3 and v4 ISAs for uClinux.
845 +MULTILIB_OPTIONS = march=ubicom32v3/march=ubicom32v4
847 +EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o # crtbeginS.o crtendS.o
849 +++ b/gcc/config/ubicom32/ubicom32-modes.def
851 +/* Definitions of target machine for GNU compiler, Ubicom32 architecture.
852 + Copyright (C) 2009 Free Software Foundation, Inc.
853 + Contributed by Ubicom, Inc.
855 + This file is part of GCC.
857 + GCC is free software; you can redistribute it and/or modify it
858 + under the terms of the GNU General Public License as published
859 + by the Free Software Foundation; either version 3, or (at your
860 + option) any later version.
862 + GCC is distributed in the hope that it will be useful, but WITHOUT
863 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
864 + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
865 + License for more details.
867 + You should have received a copy of the GNU General Public License
868 + along with GCC; see the file COPYING3. If not see
869 + <http://www.gnu.org/licenses/>. */
871 +/* Some insns set all condition code flags, some only set the Z and N flags, and
872 + some only set the Z flag. */
882 +++ b/gcc/config/ubicom32/ubicom32-protos.h
884 +/* Function prototypes for Ubicom IP3000.
886 + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
887 + 2009 Free Software Foundation, Inc.
888 + Contributed by Ubicom, Inc.
890 + This file is part of GNU CC.
892 + GNU CC is free software; you can redistribute it and/or modify it under
893 + the terms of the GNU General Public License as published by the Free
894 + Software Foundation; either version 2, or (at your option) any later
897 + GNU CC is distributed in the hope that it will be useful, but WITHOUT
898 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
899 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
902 + You should have received a copy of the GNU General Public License along
903 + with GNU CC; see the file COPYING. If not, write to the Free Software
904 + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
909 +extern void ubicom32_va_start (tree, rtx);
910 +#endif /* TREE_CODE */
912 +extern void ubicom32_print_operand (FILE *, rtx, int);
913 +extern void ubicom32_print_operand_address (FILE *, rtx);
915 +extern void ubicom32_conditional_register_usage (void);
916 +extern enum reg_class ubicom32_preferred_reload_class (rtx, enum reg_class);
917 +extern int ubicom32_regno_ok_for_index_p (int, int);
918 +extern void ubicom32_expand_movsi (rtx *);
919 +extern void ubicom32_expand_addsi3 (rtx *);
920 +extern int ubicom32_emit_mult_sequence (rtx *);
921 +extern void ubicom32_emit_move_const_int (rtx, rtx);
922 +extern bool ubicom32_legitimate_constant_p (rtx);
923 +extern bool ubicom32_legitimate_address_p (enum machine_mode, rtx, int);
924 +extern rtx ubicom32_legitimize_address (rtx, rtx, enum machine_mode);
925 +extern rtx ubicom32_legitimize_reload_address (rtx, enum machine_mode, int, int);
926 +extern void ubicom32_canonicalize_comparison (enum rtx_code *code, rtx *op0, rtx *op1);
927 +extern int ubicom32_mode_dependent_address_p (rtx);
928 +extern void ubicom32_output_cond_jump (rtx, rtx, rtx);
929 +extern void ubicom32_expand_eh_return (rtx *);
930 +extern void ubicom32_expand_call_fdpic (rtx *);
931 +extern void ubicom32_expand_call_value_fdpic (rtx *);
932 +extern enum machine_mode ubicom32_select_cc_mode (RTX_CODE, rtx, rtx);
933 +extern rtx ubicom32_gen_compare_reg (RTX_CODE, rtx, rtx);
934 +extern int ubicom32_shiftable_const_int (int);
935 +#endif /* RTX_CODE */
938 +extern void init_cumulative_args (CUMULATIVE_ARGS *cum,
940 + struct rtx_def *libname,
942 +extern struct rtx_def *function_arg (CUMULATIVE_ARGS *,
943 + enum machine_mode, tree, int);
944 +extern struct rtx_def *function_incoming_arg (CUMULATIVE_ARGS *,
947 +extern int function_arg_partial_nregs (CUMULATIVE_ARGS *,
948 + enum machine_mode, tree, int);
949 +extern struct rtx_def *ubicom32_va_arg (tree, tree);
950 +extern int ubicom32_reg_parm_stack_space (tree);
951 +#endif /* TREE_CODE */
953 +extern struct rtx_def * ubicom32_builtin_saveregs (void);
954 +extern void asm_file_start (FILE *);
955 +extern void ubicom32_expand_prologue (void);
956 +extern void ubicom32_expand_epilogue (void);
957 +extern int ubicom32_initial_elimination_offset (int, int);
958 +extern int ubicom32_regno_ok_for_base_p (int, int);
959 +extern bool ubicom32_hard_regno_mode_ok (unsigned int, enum machine_mode);
960 +extern int ubicom32_can_use_return_insn_p (void);
961 +extern rtx ubicom32_return_addr_rtx (int, rtx);
962 +extern void ubicom32_optimization_options (int, int);
963 +extern void ubicom32_override_options (void);
964 +extern bool ubicom32_match_cc_mode (rtx, enum machine_mode);
966 +extern int ubicom32_reorg_completed;
969 +++ b/gcc/config/ubicom32/ubicom32.c
971 +/* Subroutines for insn-output.c for Ubicom32
973 + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
974 + 2009 Free Software Foundation, Inc.
975 + Contributed by Ubicom, Inc.
977 + This file is part of GCC.
979 + GCC is free software; you can redistribute it and/or modify it
980 + under the terms of the GNU General Public License as published
981 + by the Free Software Foundation; either version 3, or (at your
982 + option) any later version.
984 + GCC is distributed in the hope that it will be useful, but WITHOUT
985 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
986 + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
987 + License for more details.
989 + You should have received a copy of the GNU General Public License
990 + along with GCC; see the file COPYING3. If not see
991 + <http://www.gnu.org/licenses/>. */
995 +#include "coretypes.h"
1000 +#include "hard-reg-set.h"
1002 +#include "insn-config.h"
1003 +#include "conditions.h"
1004 +#include "insn-flags.h"
1005 +#include "output.h"
1006 +#include "insn-attr.h"
1007 +#include "insn-codes.h"
1011 +#include "function.h"
1012 +#include "obstack.h"
1013 +#include "toplev.h"
1015 +#include "tm-constrs.h"
1016 +#include "basic-block.h"
1017 +#include "integrate.h"
1018 +#include "target.h"
1019 +#include "target-def.h"
1020 +#include "reload.h"
1022 +#include "langhooks.h"
1023 +#include "optabs.h"
1025 +static tree ubicom32_handle_fndecl_attribute (tree *, tree, tree, int, bool *);
1026 +static void ubicom32_layout_frame (void);
1027 +static void ubicom32_function_prologue (FILE *, HOST_WIDE_INT);
1028 +static void ubicom32_function_epilogue (FILE *, HOST_WIDE_INT);
1029 +static bool ubicom32_rtx_costs (rtx, int, int, int *, bool speed);
1030 +static bool ubicom32_fixed_condition_code_regs (unsigned int *,
1032 +static enum machine_mode ubicom32_cc_modes_compatible (enum machine_mode,
1033 + enum machine_mode);
1034 +static int ubicom32_naked_function_p (void);
1035 +static void ubicom32_machine_dependent_reorg (void);
1036 +static bool ubicom32_assemble_integer (rtx, unsigned int, int);
1037 +static void ubicom32_asm_init_sections (void);
1038 +static int ubicom32_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,tree,
1040 +static bool ubicom32_pass_by_reference (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
1041 + enum machine_mode mode, const_tree type,
1042 + bool named ATTRIBUTE_UNUSED);
1043 +static bool ubicom32_callee_copies (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
1044 + enum machine_mode mode, const_tree type,
1045 + bool named ATTRIBUTE_UNUSED);
1047 +static bool ubicom32_return_in_memory (const_tree type,
1048 + const_tree fntype ATTRIBUTE_UNUSED);
1049 +static bool ubicom32_is_base_reg (rtx, int);
1050 +static void ubicom32_init_builtins (void);
1051 +static rtx ubicom32_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
1052 +static tree ubicom32_fold_builtin (tree, tree, bool);
1053 +static int ubicom32_get_valid_offset_mask (enum machine_mode);
1054 +static bool ubicom32_cannot_force_const_mem (rtx);
1056 +/* Case values threshold */
1057 +int ubicom32_case_values_threshold = 6;
1059 +/* Nonzero if this chip supports the Ubicom32 v3 ISA. */
1060 +int ubicom32_v3 = 1;
1062 +/* Nonzero if this chip supports the Ubicom32 v4 ISA. */
1063 +int ubicom32_v4 = 1;
1065 +/* Valid attributes:
1066 + naked - don't generate function prologue/epilogue and `ret' command. */
1067 +const struct attribute_spec ubicom32_attribute_table[] =
1069 + /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
1070 + { "naked", 0, 0, true, false, false, ubicom32_handle_fndecl_attribute },
1071 + { NULL, 0, 0, false, false, false, NULL }
1074 +#undef TARGET_ASM_FUNCTION_PROLOGUE
1075 +#define TARGET_ASM_FUNCTION_PROLOGUE ubicom32_function_prologue
1077 +#undef TARGET_ASM_FUNCTION_EPILOGUE
1078 +#define TARGET_ASM_FUNCTION_EPILOGUE ubicom32_function_epilogue
1080 +#undef TARGET_ATTRIBUTE_TABLE
1081 +#define TARGET_ATTRIBUTE_TABLE ubicom32_attribute_table
1083 +/* All addresses cost the same amount. */
1084 +#undef TARGET_ADDRESS_COST
1085 +#define TARGET_ADDRESS_COST hook_int_rtx_bool_0
1087 +#undef TARGET_RTX_COSTS
1088 +#define TARGET_RTX_COSTS ubicom32_rtx_costs
1090 +#undef TARGET_FIXED_CONDITION_CODE_REGS
1091 +#define TARGET_FIXED_CONDITION_CODE_REGS ubicom32_fixed_condition_code_regs
1093 +#undef TARGET_CC_MODES_COMPATIBLE
1094 +#define TARGET_CC_MODES_COMPATIBLE ubicom32_cc_modes_compatible
1096 +#undef TARGET_MACHINE_DEPENDENT_REORG
1097 +#define TARGET_MACHINE_DEPENDENT_REORG ubicom32_machine_dependent_reorg
1099 +#undef TARGET_ASM_INTEGER
1100 +#define TARGET_ASM_INTEGER ubicom32_assemble_integer
1102 +#undef TARGET_ASM_INIT_SECTIONS
1103 +#define TARGET_ASM_INIT_SECTIONS ubicom32_asm_init_sections
1105 +#undef TARGET_ARG_PARTIAL_BYTES
1106 +#define TARGET_ARG_PARTIAL_BYTES ubicom32_arg_partial_bytes
1108 +#undef TARGET_PASS_BY_REFERENCE
1109 +#define TARGET_PASS_BY_REFERENCE ubicom32_pass_by_reference
1111 +#undef TARGET_CALLEE_COPIES
1112 +#define TARGET_CALLEE_COPIES ubicom32_callee_copies
1114 +#undef TARGET_RETURN_IN_MEMORY
1115 +#define TARGET_RETURN_IN_MEMORY ubicom32_return_in_memory
1117 +#undef TARGET_INIT_BUILTINS
1118 +#define TARGET_INIT_BUILTINS ubicom32_init_builtins
1120 +#undef TARGET_EXPAND_BUILTIN
1121 +#define TARGET_EXPAND_BUILTIN ubicom32_expand_builtin
1123 +#undef TARGET_FOLD_BUILTIN
1124 +#define TARGET_FOLD_BUILTIN ubicom32_fold_builtin
1126 +#undef TARGET_CANNOT_FORCE_CONST_MEM
1127 +#define TARGET_CANNOT_FORCE_CONST_MEM ubicom32_cannot_force_const_mem
1129 +struct gcc_target targetm = TARGET_INITIALIZER;
1131 +static char save_regs[FIRST_PSEUDO_REGISTER];
1133 +static int frame_size;
1134 +int ubicom32_stack_size = 0; /* size of allocated stack (including frame) */
1135 +int ubicom32_can_use_calli_to_ret;
1137 +#define STACK_UNIT_BOUNDARY (STACK_BOUNDARY / BITS_PER_UNIT)
1138 +#define ROUND_CALL_BLOCK_SIZE(BYTES) \
1139 + (((BYTES) + (STACK_UNIT_BOUNDARY - 1)) & ~(STACK_UNIT_BOUNDARY - 1))
1141 +/* In case of a PRE_INC, POST_INC, PRE_DEC, POST_DEC memory reference, we
1142 + must report the mode of the memory reference from PRINT_OPERAND to
1143 + PRINT_OPERAND_ADDRESS. */
1144 +enum machine_mode output_memory_reference_mode;
1146 +/* Flag for some split insns from the ubicom32.md. */
1147 +int ubicom32_reorg_completed;
1149 +enum reg_class const ubicom32_regclass_map[FIRST_PSEUDO_REGISTER] =
1181 + NO_REGS, /* CC_REG must be NO_REGS */
1192 +rtx ubicom32_compare_op0;
1193 +rtx ubicom32_compare_op1;
1195 +/* Handle command line option overrides. */
1198 +ubicom32_override_options (void)
1202 + if (strcmp (ubicom32_arch_name, "ubicom32v1") == 0) {
1203 + /* If we have a version 1 architecture then we want to avoid using jump
1205 + ubicom32_case_values_threshold = 30000;
1208 + } else if (strcmp (ubicom32_arch_name, "ubicom32v2") == 0) {
1211 + } else if (strcmp (ubicom32_arch_name, "ubicom32v3") == 0) {
1214 + } else if (strcmp (ubicom32_arch_name, "ubicom32v4") == 0) {
1219 + /* There is no single unaligned SI op for PIC code. Sometimes we
1220 + need to use ".4byte" and sometimes we need to use ".picptr".
1221 + See ubicom32_assemble_integer for details. */
1223 + targetm.asm_out.unaligned_op.si = 0;
1227 +ubicom32_conditional_register_usage (void)
1229 + /* If we're using the old ipOS ABI we need to make D10 through D13
1230 + caller-clobbered. */
1231 + if (TARGET_IPOS_ABI)
1233 + call_used_regs[D10_REGNUM] = 1;
1234 + call_used_regs[D11_REGNUM] = 1;
1235 + call_used_regs[D12_REGNUM] = 1;
1236 + call_used_regs[D13_REGNUM] = 1;
1240 +/* We have some number of optimizations that don't really work for the Ubicom32
1241 + architecture so we deal with them here. */
1244 +ubicom32_optimization_options (int level ATTRIBUTE_UNUSED,
1245 + int size ATTRIBUTE_UNUSED)
1247 + /* The tree IVOPTs pass seems to do really bad things for the Ubicom32
1248 + architecture - it tends to turn things that would happily use pre/post
1249 + increment/decrement into operations involving unecessary loop
1253 + /* We have problems where DSE at the RTL level misses partial stores
1254 + to the stack. For now we disable it to avoid this. */
1258 +/* Print operand X using operand code CODE to assembly language output file
1262 +ubicom32_print_operand (FILE *file, rtx x, int code)
1267 + /* Identify the correct accumulator to use. */
1268 + if (REGNO (x) == ACC0_HI_REGNUM || REGNO (x) == ACC0_LO_REGNUM)
1269 + fprintf (file, "acc0");
1270 + else if (REGNO (x) == ACC1_HI_REGNUM || REGNO (x) == ACC1_LO_REGNUM)
1271 + fprintf (file, "acc1");
1279 + enum machine_mode mode;
1281 + mode = GET_MODE (XEXP (x, 0));
1283 + /* These are normal and reversed branches. */
1284 + switch (code == 'b' ? GET_CODE (x) : reverse_condition (GET_CODE (x)))
1287 + fprintf (file, "ne");
1291 + fprintf (file, "eq");
1295 + if (mode == CCSZNmode || mode == CCWZNmode)
1296 + fprintf (file, "pl");
1298 + fprintf (file, "ge");
1302 + fprintf (file, "gt");
1306 + fprintf (file, "le");
1310 + if (mode == CCSZNmode || mode == CCWZNmode)
1311 + fprintf (file, "mi");
1313 + fprintf (file, "lt");
1317 + fprintf (file, "cs");
1321 + fprintf (file, "hi");
1325 + fprintf (file, "ls");
1329 + fprintf (file, "cc");
1339 + /* This is used for the operand to a call instruction;
1340 + if it's a REG, enclose it in parens, else output
1341 + the operand normally. */
1344 + fputc ('(', file);
1345 + ubicom32_print_operand (file, x, 0);
1346 + fputc (')', file);
1349 + ubicom32_print_operand (file, x, 0);
1353 + /* Bit operations we need bit numbers. */
1354 + fprintf (file, "%d", exact_log2 (INTVAL (x)));
1358 + /* Bit operations we need bit numbers. */
1359 + fprintf (file, "%d", exact_log2 (~ INTVAL (x)));
1363 + /* For lea, which we use to add address registers.
1364 + We don't want the '#' on a constant. */
1365 + if (CONST_INT_P (x))
1367 + fprintf (file, "%ld", INTVAL (x));
1370 + /* FALL THROUGH */
1373 + switch (GET_CODE (x))
1376 + output_memory_reference_mode = GET_MODE (x);
1377 + output_address (XEXP (x, 0));
1381 + output_address (x);
1385 + fprintf (file, "%s", reg_names[REGNO (x)]);
1389 + fprintf (file, "%s", reg_names[subreg_regno (x)]);
1392 + /* This will only be single precision.... */
1393 + case CONST_DOUBLE:
1395 + unsigned long val;
1396 + REAL_VALUE_TYPE rv;
1398 + REAL_VALUE_FROM_CONST_DOUBLE (rv, x);
1399 + REAL_VALUE_TO_TARGET_SINGLE (rv, val);
1400 + fprintf (file, "0x%lx", val);
1410 + ubicom32_print_operand_address (file, x);
1414 + fprintf (file, "#%%hi(");
1415 + ubicom32_print_operand_address (file, XEXP (x, 0));
1416 + fprintf (file, ")");
1420 + switch (XINT (x, 1))
1422 + case UNSPEC_FDPIC_GOT:
1423 + fprintf (file, "#%%got_lo(");
1424 + ubicom32_print_operand_address (file, XVECEXP (x, 0, 0));
1425 + fprintf (file, ")");
1428 + case UNSPEC_FDPIC_GOT_FUNCDESC:
1429 + fprintf (file, "#%%got_funcdesc_lo(");
1430 + ubicom32_print_operand_address (file, XVECEXP (x, 0, 0));
1431 + fprintf (file, ")");
1446 +/* Output assembly language output for the address ADDR to FILE. */
1449 +ubicom32_print_operand_address (FILE *file, rtx addr)
1451 + switch (GET_CODE (addr))
1454 + ubicom32_print_operand_address (file, XEXP (addr, 0));
1455 + fprintf (file, "%d++", GET_MODE_SIZE (output_memory_reference_mode));
1459 + fprintf (file, "%d", GET_MODE_SIZE (output_memory_reference_mode));
1460 + ubicom32_print_operand_address (file, XEXP (addr, 0));
1461 + fprintf (file, "++");
1465 + ubicom32_print_operand_address (file, XEXP (addr, 0));
1466 + fprintf (file, "%d++", -GET_MODE_SIZE (output_memory_reference_mode));
1470 + fprintf (file, "%d", -GET_MODE_SIZE (output_memory_reference_mode));
1471 + ubicom32_print_operand_address (file, XEXP (addr, 0));
1472 + fprintf (file, "++");
1476 + ubicom32_print_operand_address (file, XEXP (addr, 0));
1477 + fprintf (file, "%ld++", INTVAL (XEXP (XEXP (addr,1), 1)));
1481 + fprintf (file, "%ld", INTVAL (XEXP (XEXP (addr,1), 1)));
1482 + ubicom32_print_operand_address (file, XEXP (addr, 0));
1483 + fprintf (file, "++");
1487 + fputc ('(', file);
1488 + fprintf (file, "%s", reg_names[REGNO (addr)]);
1489 + fputc (')', file);
1494 + rtx base = XEXP (addr, 0);
1495 + rtx index = XEXP (addr, 1);
1497 + /* Switch around addresses of the form index * scaling + base. */
1498 + if (! ubicom32_is_base_reg (base, 1))
1505 + if (CONST_INT_P (index))
1507 + fprintf (file, "%ld", INTVAL (index));
1508 + fputc ('(', file);
1509 + fputs (reg_names[REGNO (base)], file);
1511 + else if (GET_CODE (index) == MULT
1514 + if (GET_CODE (index) == MULT)
1515 + index = XEXP (index, 0);
1516 + fputc ('(', file);
1517 + fputs (reg_names[REGNO (base)], file);
1518 + fputc (',', file);
1519 + fputs (reg_names[REGNO (index)], file);
1524 + fputc (')', file);
1529 + fprintf (file, "%%lo(");
1530 + ubicom32_print_operand (file, XEXP (addr, 1), 'L');
1531 + fprintf (file, ")(");
1532 + ubicom32_print_operand (file, XEXP (addr, 0), 0);
1533 + fprintf (file, ")");
1537 + fputc ('#', file);
1538 + output_addr_const (file, addr);
1542 + output_addr_const (file, addr);
1547 +/* X and Y are two things to compare using CODE. Emit the compare insn and
1548 + return the rtx for the cc reg in the proper mode. */
1551 +ubicom32_gen_compare_reg (enum rtx_code code, rtx x, rtx y)
1553 + enum machine_mode mode = SELECT_CC_MODE (code, x, y);
1556 + cc_reg = gen_rtx_REG (mode, CC_REGNUM);
1558 + emit_insn (gen_rtx_SET (VOIDmode, cc_reg,
1559 + gen_rtx_COMPARE (mode, x, y)));
1564 +/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
1565 + return the mode to be used for the comparison. */
1568 +ubicom32_select_cc_mode (enum rtx_code op, rtx x, rtx y)
1570 + /* Is this a short compare? */
1571 + if (GET_MODE (x) == QImode
1572 + || GET_MODE (x) == HImode
1573 + || GET_MODE (y) == QImode
1574 + || GET_MODE (y) == HImode)
1584 + if (y == const0_rtx)
1592 + /* We have a word compare. */
1601 + if (y == const0_rtx)
1609 +/* Return TRUE or FALSE depending on whether the first SET in INSN
1610 + has source and destination with matching CC modes, and that the
1611 + CC mode is at least as constrained as REQ_MODE. */
1613 +ubicom32_match_cc_mode (rtx insn, enum machine_mode req_mode)
1616 + enum machine_mode set_mode;
1618 + set = PATTERN (insn);
1619 + if (GET_CODE (set) == PARALLEL)
1620 + set = XVECEXP (set, 0, 0);
1621 + gcc_assert (GET_CODE (set) == SET);
1622 + gcc_assert (GET_CODE (SET_SRC (set)) == COMPARE);
1624 + /* SET_MODE is the mode we have in the instruction. This must either
1625 + be the same or less restrictive that the required mode REQ_MODE. */
1626 + set_mode = GET_MODE (SET_DEST (set));
1631 + if (set_mode != CCSZmode)
1636 + if (set_mode != CCSZmode
1637 + && set_mode != CCSZNmode)
1642 + if (set_mode != CCSmode
1643 + && set_mode != CCSZmode
1644 + && set_mode != CCSZNmode)
1649 + if (set_mode != CCWZmode)
1654 + if (set_mode != CCWZmode
1655 + && set_mode != CCWZNmode)
1660 + if (set_mode != CCWmode
1661 + && set_mode != CCWZmode
1662 + && set_mode != CCWZNmode)
1667 + gcc_unreachable ();
1670 + return (GET_MODE (SET_SRC (set)) == set_mode);
1673 +/* Replace the comparison OP0 CODE OP1 by a semantically equivalent one
1674 + that we can implement more efficiently. */
1677 +ubicom32_canonicalize_comparison (enum rtx_code *code, rtx *op0, rtx *op1)
1679 + /* If we have a REG and a MEM then compare the MEM with the REG and not
1680 + the other way round. */
1681 + if (REG_P (*op0) && MEM_P (*op1))
1686 + *code = swap_condition (*code);
1690 + /* If we have a REG and a CONST_INT then we may want to reverse things
1691 + if the constant can be represented as an "I" constraint. */
1692 + if (REG_P (*op0) && CONST_INT_P (*op1) && satisfies_constraint_I (*op1))
1697 + *code = swap_condition (*code);
1702 +/* Return the fixed registers used for condition codes. */
1705 +ubicom32_fixed_condition_code_regs (unsigned int *p1, unsigned int *p2)
1708 + *p2 = INVALID_REGNUM;
1713 +/* If two condition code modes are compatible, return a condition code
1714 + mode which is compatible with both. Otherwise, return
1717 +static enum machine_mode
1718 +ubicom32_cc_modes_compatible (enum machine_mode m1, enum machine_mode m2)
1723 + if (GET_MODE_CLASS (m1) != MODE_CC || GET_MODE_CLASS (m2) != MODE_CC)
1729 + if (m2 == CCWZNmode || m2 == CCWZmode)
1735 + if (m2 == CCWmode)
1738 + if (m2 == CCWZmode)
1744 + if (m2 == CCWmode || m2 == CCWZNmode)
1750 + if (m2 == CCSZNmode || m2 == CCSZmode)
1756 + if (m2 == CCSmode)
1759 + if (m2 == CCSZmode)
1765 + if (m2 == CCSmode || m2 == CCSZNmode)
1771 + gcc_unreachable ();
1776 +ubicom32_legitimize_fdpic_address_symbol (rtx orig, rtx reg, rtx fdpic_reg)
1780 + rtx got_offs_scaled;
1785 + gcc_assert (reg != 0);
1787 + if (GET_CODE (orig) == SYMBOL_REF
1788 + && SYMBOL_REF_FUNCTION_P (orig))
1789 + unspec = UNSPEC_FDPIC_GOT_FUNCDESC;
1791 + unspec = UNSPEC_FDPIC_GOT;
1793 + got_offs = gen_reg_rtx (SImode);
1794 + tmp = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, orig), unspec);
1795 + emit_move_insn (got_offs, tmp);
1797 + got_offs_scaled = gen_rtx_MULT (SImode, got_offs, GEN_INT (4));
1798 + plus_scaled = gen_rtx_PLUS (Pmode, fdpic_reg, got_offs_scaled);
1799 + new_rtx = gen_const_mem (Pmode, plus_scaled);
1800 + emit_move_insn (reg, new_rtx);
1806 +ubicom32_legitimize_fdpic_address (rtx orig, rtx reg, rtx fdpic_reg)
1809 + rtx new_rtx = orig;
1811 + if (GET_CODE (addr) == CONST || GET_CODE (addr) == PLUS)
1815 + if (GET_CODE (addr) == CONST)
1817 + addr = XEXP (addr, 0);
1818 + gcc_assert (GET_CODE (addr) == PLUS);
1821 + base = ubicom32_legitimize_fdpic_address_symbol (XEXP (addr, 0), reg, fdpic_reg);
1822 + return gen_rtx_PLUS (Pmode, base, XEXP (addr, 1));
1828 +/* Code generation. */
1831 +ubicom32_expand_movsi (rtx *operands)
1833 + if (GET_CODE (operands[1]) == SYMBOL_REF
1834 + || (GET_CODE (operands[1]) == CONST
1835 + && GET_CODE (XEXP (operands[1], 0)) == PLUS
1836 + && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == SYMBOL_REF)
1837 + || CONSTANT_ADDRESS_P (operands[1]))
1844 + gcc_assert (can_create_pseudo_p ());
1845 + tmp = gen_reg_rtx (Pmode);
1846 + fdpic_reg = get_hard_reg_initial_val (SImode, FDPIC_REGNUM);
1847 + if (GET_CODE (operands[1]) == SYMBOL_REF
1848 + || GET_CODE (operands[1]) == LABEL_REF)
1849 + operands[1] = ubicom32_legitimize_fdpic_address_symbol (operands[1], tmp, fdpic_reg);
1851 + operands[1] = ubicom32_legitimize_fdpic_address (operands[1], tmp, fdpic_reg);
1856 + enum machine_mode mode;
1858 + /* We want to avoid reusing operand 0 if we can because it limits
1859 + our ability to optimize later. */
1860 + tmp = ! can_create_pseudo_p () ? operands[0] : gen_reg_rtx (Pmode);
1862 + mode = GET_MODE (operands[0]);
1863 + emit_insn (gen_rtx_SET (VOIDmode, tmp,
1864 + gen_rtx_HIGH (mode, operands[1])));
1865 + operands[1] = gen_rtx_LO_SUM (mode, tmp, operands[1]);
1866 + if (can_create_pseudo_p() && ! REG_P (operands[0]))
1868 + tmp = gen_reg_rtx (mode);
1869 + emit_insn (gen_rtx_SET (VOIDmode, tmp, operands[1]));
1870 + operands[1] = tmp;
1876 +/* Emit code for addsi3. */
1879 +ubicom32_expand_addsi3 (rtx *operands)
1883 + if (can_create_pseudo_p ())
1885 + /* If we have a non-data reg for operand 1 then prefer that over
1886 + a CONST_INT in operand 2. */
1887 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
1888 + && CONST_INT_P (operands[2]))
1889 + operands[2] = copy_to_mode_reg (SImode, operands[2]);
1891 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
1892 + operands[2] = copy_to_mode_reg (SImode, operands[2]);
1895 + /* Emit the instruction. */
1897 + op = gen_rtx_SET (VOIDmode, operands[0],
1898 + gen_rtx_PLUS (SImode, operands[1], operands[2]));
1900 + if (! can_create_pseudo_p ())
1902 + /* Reload doesn't know about the flags register, and doesn't know that
1903 + it doesn't want to clobber it. We can only do this with PLUS. */
1908 + clob = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, CC_REGNUM));
1909 + emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, op, clob)));
1913 +/* Emit code for mulsi3. Return 1 if we have generated all the code
1914 + necessary to do the multiplication. */
1917 +ubicom32_emit_mult_sequence (rtx *operands)
1919 + if (! ubicom32_v4)
1926 + /* Give up if we cannot create new pseudos. */
1927 + if (!can_create_pseudo_p())
1930 + /* Synthesize 32-bit multiplication using 16-bit operations:
1938 + c = (a1 * b1) << 32 + (a1 * b2) << 16 + (a2 * b1) << 16 + a2 * b2
1939 + = 0 + (a1 * b2) << 16 + (a2 * b1) << 16 + a2 * b2
1940 + ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^
1941 + Signed Signed Unsigned */
1943 + if (!ubicom32_data_register_operand (operands[1], GET_MODE (operands[1])))
1947 + op1 = gen_reg_rtx (SImode);
1948 + emit_move_insn (op1, operands[1]);
1949 + operands[1] = op1;
1952 + if (!ubicom32_data_register_operand (operands[2], GET_MODE (operands[2])))
1956 + op2 = gen_reg_rtx (SImode);
1957 + emit_move_insn (op2, operands[2]);
1958 + operands[2] = op2;
1961 + /* a1 = highpart (a) */
1962 + a1 = gen_reg_rtx (HImode);
1963 + a1_1 = gen_reg_rtx (SImode);
1964 + emit_insn (gen_ashrsi3 (a1_1, operands[1], GEN_INT (16)));
1965 + emit_move_insn (a1, gen_lowpart (HImode, a1_1));
1967 + /* a2 = lowpart (a) */
1968 + a2 = gen_reg_rtx (HImode);
1969 + emit_move_insn (a2, gen_lowpart (HImode, operands[1]));
1971 + /* b1 = highpart (b) */
1972 + b1 = gen_reg_rtx (HImode);
1973 + b1_1 = gen_reg_rtx (SImode);
1974 + emit_insn (gen_ashrsi3 (b1_1, operands[2], GEN_INT (16)));
1975 + emit_move_insn (b1, gen_lowpart (HImode, b1_1));
1977 + /* b2 = lowpart (b) */
1978 + b2 = gen_reg_rtx (HImode);
1979 + emit_move_insn (b2, gen_lowpart (HImode, operands[2]));
1981 + /* t1 = (a1 * b2) << 16 */
1982 + t1 = gen_reg_rtx (SImode);
1983 + mac_lo_rtx = gen_rtx_REG (SImode, ACC0_LO_REGNUM);
1984 + emit_insn (gen_mulhisi3 (mac_lo_rtx, a1, b2));
1985 + emit_insn (gen_ashlsi3 (t1, mac_lo_rtx, GEN_INT (16)));
1987 + /* t2 = (a2 * b1) << 16 */
1988 + t2 = gen_reg_rtx (SImode);
1989 + emit_insn (gen_mulhisi3 (mac_lo_rtx, a2, b1));
1990 + emit_insn (gen_ashlsi3 (t2, mac_lo_rtx, GEN_INT (16)));
1992 + /* mac_lo = a2 * b2 */
1993 + emit_insn (gen_umulhisi3 (mac_lo_rtx, a2, b2));
1995 + /* t3 = t1 + t2 */
1996 + t3 = gen_reg_rtx (SImode);
1997 + emit_insn (gen_addsi3 (t3, t1, t2));
1999 + /* c = t3 + mac_lo_rtx */
2000 + emit_insn (gen_addsi3 (operands[0], mac_lo_rtx, t3));
2008 + /* Give up if we cannot create new pseudos. */
2009 + if (!can_create_pseudo_p())
2012 + if (!ubicom32_data_register_operand (operands[1], GET_MODE (operands[1])))
2016 + op1 = gen_reg_rtx (SImode);
2017 + emit_move_insn (op1, operands[1]);
2018 + operands[1] = op1;
2021 + if (!ubicom32_data_register_operand (operands[2], GET_MODE (operands[2])))
2025 + op2 = gen_reg_rtx (SImode);
2026 + emit_move_insn (op2, operands[2]);
2027 + operands[2] = op2;
2030 + acc_rtx = gen_reg_rtx (DImode);
2031 + emit_insn (gen_umulsidi3 (acc_rtx, operands[1], operands[2]));
2032 + emit_move_insn (operands[0], gen_lowpart (SImode, acc_rtx));
2038 +/* Move the integer value VAL into OPERANDS[0]. */
2041 +ubicom32_emit_move_const_int (rtx dest, rtx imm)
2045 + xoperands[0] = dest;
2046 + xoperands[1] = imm;
2048 + /* Treat mem destinations separately. Values must be explicitly sign
2052 + rtx low_hword_mem;
2053 + rtx low_hword_addr;
2055 + /* Emit shorter sequence for signed 7-bit quantities. */
2056 + if (satisfies_constraint_I (imm))
2058 + output_asm_insn ("move.4\t%0, %1", xoperands);
2062 + /* Special case for pushing constants. */
2063 + if (GET_CODE (XEXP (dest, 0)) == PRE_DEC
2064 + && XEXP (XEXP (dest, 0), 0) == stack_pointer_rtx)
2066 + output_asm_insn ("movei\t-4(sp)++, #%%hi(%E1)", xoperands);
2067 + output_asm_insn ("movei\t2(sp), #%%lo(%E1)", xoperands);
2071 + /* See if we can add 2 to the original address. This is only
2072 + possible if the original address is of the form REG or
2074 + low_hword_addr = plus_constant (XEXP (dest, 0), 2);
2075 + if (ubicom32_legitimate_address_p (HImode, low_hword_addr, 1))
2077 + low_hword_mem = gen_rtx_MEM (HImode, low_hword_addr);
2078 + MEM_COPY_ATTRIBUTES (low_hword_mem, dest);
2079 + output_asm_insn ("movei\t%0, #%%hi(%E1)", xoperands);
2080 + xoperands[0] = low_hword_mem;
2081 + output_asm_insn ("movei\t%0, #%%lo(%E1)", xoperands);
2085 + /* The original address is too complex. We need to use a
2086 + scratch memory by (sp) and move that to the original
2088 + if (! reg_mentioned_p (stack_pointer_rtx, dest))
2090 + output_asm_insn ("movei\t-4(sp)++, #%%hi(%E1)", xoperands);
2091 + output_asm_insn ("movei\t2(sp), #%%lo(%E1)", xoperands);
2092 + output_asm_insn ("move.4\t%0, (sp)4++", xoperands);
2096 + /* Our address mentions the stack pointer so we need to
2097 + use our scratch data register here as well as scratch
2099 + output_asm_insn ("movei\t-4(sp)++, #%%hi(%E1)", xoperands);
2100 + output_asm_insn ("movei\t2(sp), #%%lo(%E1)", xoperands);
2101 + output_asm_insn ("move.4\td15, (sp)4++", xoperands);
2102 + output_asm_insn ("move.4\t%0, d15", xoperands);
2106 + /* Move into registers are zero extended by default. */
2107 + if (! REG_P (dest))
2110 + if (satisfies_constraint_N (imm))
2112 + output_asm_insn ("movei\t%0, %1", xoperands);
2116 + if (INTVAL (xoperands[1]) >= 0xff80
2117 + && INTVAL (xoperands[1]) < 0x10000)
2119 + xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 0x10000);
2120 + output_asm_insn ("move.2\t%0, %1", xoperands);
2124 + if ((REGNO_REG_CLASS (REGNO (xoperands[0])) == ADDRESS_REGS
2125 + || REGNO_REG_CLASS (REGNO (xoperands[0])) == FDPIC_REG)
2126 + && ((INTVAL (xoperands[1]) & 0x80000000) == 0))
2128 + output_asm_insn ("moveai\t%0, #%%hi(%E1)", xoperands);
2129 + if ((INTVAL (xoperands[1]) & 0x7f) != 0)
2130 + output_asm_insn ("lea.1\t%0, %%lo(%E1)(%0)", xoperands);
2134 + if ((INTVAL (xoperands[1]) & 0xffff0000) == 0)
2136 + output_asm_insn ("movei\t%0, #%%lo(%E1)", xoperands);
2137 + output_asm_insn ("move.2\t%0, %0", xoperands);
2141 + /* This is very expensive. The constant is so large that we
2142 + need to use the stack to do the load. */
2143 + output_asm_insn ("movei\t-4(sp)++, #%%hi(%E1)", xoperands);
2144 + output_asm_insn ("movei\t2(sp), #%%lo(%E1)", xoperands);
2145 + output_asm_insn ("move.4\t%0, (sp)4++", xoperands);
2148 +/* Stack layout. Prologue/Epilogue. */
2150 +static int save_regs_size;
2153 +ubicom32_layout_frame (void)
2157 + memset ((char *) &save_regs[0], 0, sizeof (save_regs));
2159 + frame_size = get_frame_size ();
2161 + if (frame_pointer_needed || df_regs_ever_live_p (FRAME_POINTER_REGNUM))
2163 + save_regs[FRAME_POINTER_REGNUM] = 1;
2167 + if (current_function_is_leaf && ! df_regs_ever_live_p (LINK_REGNO))
2168 + ubicom32_can_use_calli_to_ret = 1;
2171 + ubicom32_can_use_calli_to_ret = 0;
2172 + save_regs[LINK_REGNO] = 1;
2176 + /* Figure out which register(s) needs to be saved. */
2177 + for (regno = 0; regno <= LAST_ADDRESS_REGNUM; regno++)
2178 + if (df_regs_ever_live_p(regno)
2179 + && ! call_used_regs[regno]
2180 + && ! fixed_regs[regno]
2181 + && ! save_regs[regno])
2183 + save_regs[regno] = 1;
2187 + save_regs_size = 4 * nregs;
2191 +ubicom32_emit_add_movsi (int regno, int adj)
2194 + rtx reg = gen_rtx_REG (SImode, regno);
2199 + x = emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
2201 + RTX_FRAME_RELATED_P (x) = 1;
2202 + x = emit_move_insn (gen_rtx_MEM (SImode, stack_pointer_rtx), reg);
2206 + rtx addr = gen_rtx_PRE_MODIFY (Pmode, stack_pointer_rtx,
2207 + gen_rtx_PLUS (Pmode, stack_pointer_rtx,
2209 + x = emit_move_insn (gen_rtx_MEM (SImode, addr), reg);
2211 + RTX_FRAME_RELATED_P (x) = 1;
2215 +ubicom32_expand_prologue (void)
2219 + int outgoing_args_size = crtl->outgoing_args_size;
2222 + if (ubicom32_naked_function_p ())
2225 + ubicom32_builtin_saveregs ();
2227 + ubicom32_layout_frame ();
2228 + adj = (outgoing_args_size + get_frame_size () + save_regs_size
2229 + + crtl->args.pretend_args_size);
2233 + else if (outgoing_args_size + save_regs_size < 508
2234 + && get_frame_size () + save_regs_size > 508)
2237 + x = gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
2239 + x = emit_insn (x);
2240 + RTX_FRAME_RELATED_P (x) = 1;
2242 + for (regno = LAST_ADDRESS_REGNUM; regno >= 0; --regno)
2243 + if (save_regs[regno] && regno != LINK_REGNO)
2245 + x = gen_rtx_MEM (SImode,
2246 + gen_rtx_PLUS (Pmode,
2247 + stack_pointer_rtx,
2248 + GEN_INT (i * 4 + outgoing_args_size)));
2249 + x = emit_move_insn (x, gen_rtx_REG (SImode, regno));
2250 + RTX_FRAME_RELATED_P (x) = 1;
2253 + if (save_regs[LINK_REGNO])
2255 + x = gen_rtx_MEM (SImode,
2256 + gen_rtx_PLUS (Pmode,
2257 + stack_pointer_rtx,
2258 + GEN_INT (i * 4 + outgoing_args_size)));
2259 + x = emit_move_insn (x, gen_rtx_REG (SImode, LINK_REGNO));
2260 + RTX_FRAME_RELATED_P (x) = 1;
2266 + int adj = get_frame_size () + crtl->args.pretend_args_size;
2269 + if (save_regs[LINK_REGNO])
2271 + ubicom32_emit_add_movsi (LINK_REGNO, adj);
2275 + for (regno = 0; regno <= LAST_ADDRESS_REGNUM; ++regno)
2276 + if (save_regs[regno] && regno != LINK_REGNO)
2280 + rtx mem = gen_rtx_MEM (SImode,
2281 + gen_rtx_PRE_DEC (Pmode,
2282 + stack_pointer_rtx));
2283 + x = emit_move_insn (mem, gen_rtx_REG (SImode, regno));
2284 + RTX_FRAME_RELATED_P (x) = 1;
2287 + ubicom32_emit_add_movsi (regno, adj);
2291 + if (outgoing_args_size || (!i && adj))
2293 + x = gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
2294 + GEN_INT (-outgoing_args_size - (i ? 0 : adj)));
2295 + x = emit_insn (x);
2296 + RTX_FRAME_RELATED_P (x) = 1;
2300 + if (frame_pointer_needed)
2302 + int fp_adj = save_regs_size + outgoing_args_size;
2303 + x = gen_addsi3 (frame_pointer_rtx, stack_pointer_rtx,
2304 + GEN_INT (fp_adj));
2305 + x = emit_insn (x);
2306 + RTX_FRAME_RELATED_P (x) = 1;
2311 +ubicom32_expand_epilogue (void)
2315 + int outgoing_args_size = crtl->outgoing_args_size;
2319 + if (ubicom32_naked_function_p ())
2321 + emit_jump_insn (gen_return_internal (gen_rtx_REG (SImode,
2326 + if (cfun->calls_alloca)
2328 + x = gen_addsi3 (stack_pointer_rtx, frame_pointer_rtx,
2329 + GEN_INT (-save_regs_size));
2331 + outgoing_args_size = 0;
2334 + if (outgoing_args_size)
2336 + x = gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
2337 + GEN_INT (outgoing_args_size));
2342 + for (regno = LAST_ADDRESS_REGNUM; regno >= 0; --regno)
2343 + if (save_regs[regno] && regno != LINK_REGNO)
2345 + x = gen_rtx_MEM (SImode, gen_rtx_POST_INC (Pmode, stack_pointer_rtx));
2346 + emit_move_insn (gen_rtx_REG (SImode, regno), x);
2350 + /* Do we have to adjust the stack after we've finished restoring regs? */
2351 + adj = get_frame_size() + crtl->args.pretend_args_size;
2353 + adj += UBICOM32_FUNCTION_ARG_REGS * UNITS_PER_WORD;
2356 + if (crtl->calls_eh_return && 0)
2358 + if (save_regs[LINK_REGNO])
2360 + x = gen_rtx_MEM (SImode, gen_rtx_POST_INC (Pmode, stack_pointer_rtx));
2361 + emit_move_insn (gen_rtx_REG (SImode, LINK_REGNO), x);
2366 + x = gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
2368 + x = emit_insn (x);
2371 + /* Perform the additional bump for __throw. */
2372 + emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
2373 + EH_RETURN_STACKADJ_RTX));
2374 + emit_jump_insn (gen_eh_return_internal ());
2379 + if (save_regs[LINK_REGNO])
2381 + if (adj >= 4 && adj <= (6 * 4))
2383 + x = GEN_INT (adj + 4);
2384 + emit_jump_insn (gen_return_from_post_modify_sp (x));
2390 + x = gen_rtx_MEM (SImode, gen_rtx_POST_INC (Pmode, stack_pointer_rtx));
2391 + emit_jump_insn (gen_return_internal (x));
2395 + x = gen_rtx_MEM (SImode, gen_rtx_POST_INC (Pmode, stack_pointer_rtx));
2396 + emit_move_insn (gen_rtx_REG (SImode, LINK_REGNO), x);
2401 + x = gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
2403 + x = emit_insn (x);
2407 + /* Given that we've just done all the hard work here we may as well use
2408 + a calli to return. */
2409 + ubicom32_can_use_calli_to_ret = 1;
2410 + emit_jump_insn (gen_return_internal (gen_rtx_REG (SImode, LINK_REGNO)));
2414 +ubicom32_expand_call_fdpic (rtx *operands)
2418 + rtx fdpic_reg = get_hard_reg_initial_val (SImode, FDPIC_REGNUM);
2420 + addr = XEXP (operands[0], 0);
2422 + c = gen_call_fdpic (addr, operands[1], fdpic_reg);
2423 + emit_call_insn (c);
2427 +ubicom32_expand_call_value_fdpic (rtx *operands)
2431 + rtx fdpic_reg = get_hard_reg_initial_val (SImode, FDPIC_REGNUM);
2433 + addr = XEXP (operands[1], 0);
2435 + c = gen_call_value_fdpic (operands[0], addr, operands[2], fdpic_reg);
2436 + emit_call_insn (c);
2440 +ubicom32_expand_eh_return (rtx *operands)
2442 + if (REG_P (operands[0])
2443 + || REGNO (operands[0]) != EH_RETURN_STACKADJ_REGNO)
2445 + rtx sp = EH_RETURN_STACKADJ_RTX;
2446 + emit_move_insn (sp, operands[0]);
2450 + if (REG_P (operands[1])
2451 + || REGNO (operands[1]) != EH_RETURN_HANDLER_REGNO)
2453 + rtx ra = EH_RETURN_HANDLER_RTX;
2454 + emit_move_insn (ra, operands[1]);
2459 +/* Compute the offsets between eliminable registers. */
2462 +ubicom32_initial_elimination_offset (int from, int to)
2464 + ubicom32_layout_frame ();
2465 + if (from == FRAME_POINTER_REGNUM && to == STACK_POINTER_REGNUM)
2466 + return save_regs_size + crtl->outgoing_args_size;
2468 + if (from == ARG_POINTER_REGNUM && to == FRAME_POINTER_REGNUM)
2469 + return get_frame_size ()/* + save_regs_size */;
2471 + if (from == ARG_POINTER_REGNUM && to == STACK_POINTER_REGNUM)
2472 + return get_frame_size ()
2473 + + crtl->outgoing_args_size
2479 +/* Return 1 if it is appropriate to emit `ret' instructions in the
2480 + body of a function. Do this only if the epilogue is simple, needing a
2481 + couple of insns. Prior to reloading, we can't tell how many registers
2482 + must be saved, so return 0 then. Return 0 if there is no frame
2483 + marker to de-allocate.
2485 + If NON_SAVING_SETJMP is defined and true, then it is not possible
2486 + for the epilogue to be simple, so return 0. This is a special case
2487 + since NON_SAVING_SETJMP will not cause regs_ever_live to change
2488 + until final, but jump_optimize may need to know sooner if a
2489 + `return' is OK. */
2492 +ubicom32_can_use_return_insn_p (void)
2494 + if (! reload_completed || frame_pointer_needed)
2500 +/* Attributes and CC handling. */
2502 +/* Handle an attribute requiring a FUNCTION_DECL; arguments as in
2503 + struct attribute_spec.handler. */
2505 +ubicom32_handle_fndecl_attribute (tree *node, tree name,
2506 + tree args ATTRIBUTE_UNUSED,
2507 + int flags ATTRIBUTE_UNUSED,
2508 + bool *no_add_attrs)
2510 + if (TREE_CODE (*node) != FUNCTION_DECL)
2512 + warning ("'%s' attribute only applies to functions",
2513 + IDENTIFIER_POINTER (name));
2514 + *no_add_attrs = true;
2520 +/* A C expression that places additional restrictions on the register class to
2521 + use when it is necessary to copy value X into a register in class CLASS.
2522 + The value is a register class; perhaps CLASS, or perhaps another, smaller
2523 + class. On many machines, the following definition is safe:
2525 + #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
2527 + Sometimes returning a more restrictive class makes better code. For
2528 + example, on the 68000, when X is an integer constant that is in range for a
2529 + `moveq' instruction, the value of this macro is always `DATA_REGS' as long
2530 + as CLASS includes the data registers. Requiring a data register guarantees
2531 + that a `moveq' will be used.
2533 + If X is a `const_double', by returning `NO_REGS' you can force X into a
2534 + memory constant. This is useful on certain machines where immediate
2535 + floating values cannot be loaded into certain kinds of registers. */
2538 +ubicom32_preferred_reload_class (rtx x, enum reg_class class)
2540 + /* If a symbolic constant, HIGH or a PLUS is reloaded,
2541 + it is most likely being used as an address, so
2542 + prefer ADDRESS_REGS. If 'class' is not a superset
2543 + of ADDRESS_REGS, e.g. DATA_REGS, then reject this reload. */
2544 + if (GET_CODE (x) == PLUS
2545 + || GET_CODE (x) == HIGH
2546 + || GET_CODE (x) == LABEL_REF
2547 + || GET_CODE (x) == SYMBOL_REF
2548 + || GET_CODE (x) == CONST)
2550 + if (reg_class_subset_p (ALL_ADDRESS_REGS, class))
2551 + return ALL_ADDRESS_REGS;
2559 +/* Function arguments and varargs. */
2562 +ubicom32_reg_parm_stack_space (tree fndecl)
2567 + && TYPE_ARG_TYPES (TREE_TYPE (fndecl)) != 0
2568 + && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl))))
2569 + != void_type_node))
2570 + return UBICOM32_FUNCTION_ARG_REGS * UNITS_PER_WORD;
2575 +/* Flush the argument registers to the stack for a stdarg function;
2576 + return the new argument pointer. */
2579 +ubicom32_builtin_saveregs (void)
2583 + if (! cfun->stdarg)
2586 + for (regno = UBICOM32_FUNCTION_ARG_REGS - 1; regno >= 0; --regno)
2587 + emit_move_insn (gen_rtx_MEM (SImode,
2588 + gen_rtx_PRE_DEC (SImode,
2589 + stack_pointer_rtx)),
2590 + gen_rtx_REG (SImode, regno));
2592 + return stack_pointer_rtx;
2596 +ubicom32_va_start (tree valist, rtx nextarg)
2598 + std_expand_builtin_va_start (valist, nextarg);
2602 +ubicom32_va_arg (tree valist, tree type)
2604 + HOST_WIDE_INT size, rsize;
2605 + tree addr, incr, tmp;
2609 + /* Round up sizeof(type) to a word. */
2610 + size = int_size_in_bytes (type);
2611 + rsize = (size + UNITS_PER_WORD - 1) & -UNITS_PER_WORD;
2613 + /* Large types are passed by reference. */
2617 + size = rsize = UNITS_PER_WORD;
2621 + addr = incr = save_expr (incr);
2623 + /* FIXME Nat's version - is it correct? */
2624 + tmp = fold_convert (ptr_type_node, size_int (rsize));
2625 + tmp = build2 (PLUS_EXPR, ptr_type_node, incr, tmp);
2626 + incr = fold (tmp);
2628 + /* FIXME Nat's version - is it correct? */
2629 + incr = build2 (MODIFY_EXPR, ptr_type_node, valist, incr);
2631 + TREE_SIDE_EFFECTS (incr) = 1;
2632 + expand_expr (incr, const0_rtx, VOIDmode, EXPAND_NORMAL);
2634 + addr_rtx = expand_expr (addr, NULL, Pmode, EXPAND_NORMAL);
2636 + if (size < UNITS_PER_WORD)
2637 + emit_insn (gen_addsi3 (addr_rtx, addr_rtx,
2638 + GEN_INT (UNITS_PER_WORD - size)));
2642 + addr_rtx = force_reg (Pmode, addr_rtx);
2643 + addr_rtx = gen_rtx_MEM (Pmode, addr_rtx);
2644 + set_mem_alias_set (addr_rtx, get_varargs_alias_set ());
2651 +init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype, rtx libname,
2652 + int indirect ATTRIBUTE_UNUSED)
2658 + cum->stdarg = (TYPE_ARG_TYPES (fntype) != 0
2659 + && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
2660 + != void_type_node));
2664 +/* Return an RTX to represent where a value in mode MODE will be passed
2665 + to a function. If the result is 0, the argument will be pushed. */
2668 +function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
2669 + int named ATTRIBUTE_UNUSED)
2673 + int nregs = UBICOM32_FUNCTION_ARG_REGS;
2675 + /* Figure out the size of the object to be passed. */
2676 + if (mode == BLKmode)
2677 + size = int_size_in_bytes (type);
2679 + size = GET_MODE_SIZE (mode);
2681 + /* Figure out the alignment of the object to be passed. */
2684 + cum->nbytes = (cum->nbytes + 3) & ~3;
2686 + /* Don't pass this arg via a register if all the argument registers
2688 + if (cum->nbytes >= nregs * UNITS_PER_WORD)
2691 + /* Don't pass this arg via a register if it would be split between
2692 + registers and memory. */
2693 + result = gen_rtx_REG (mode, cum->nbytes / UNITS_PER_WORD);
2699 +function_incoming_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
2700 + int named ATTRIBUTE_UNUSED)
2705 + return function_arg (cum, mode, type, named);
2709 +/* Implement hook TARGET_ARG_PARTIAL_BYTES.
2711 + Returns the number of bytes at the beginning of an argument that
2712 + must be put in registers. The value must be zero for arguments
2713 + that are passed entirely in registers or that are entirely pushed
2716 +ubicom32_arg_partial_bytes (CUMULATIVE_ARGS *cum, enum machine_mode mode,
2717 + tree type, bool named ATTRIBUTE_UNUSED)
2721 + int nregs = UBICOM32_FUNCTION_ARG_REGS;
2723 + /* round up to full word */
2724 + cum->nbytes = (cum->nbytes + 3) & ~3;
2726 + if (targetm.calls.pass_by_reference (cum, mode, type, named))
2729 + /* number of bytes left in registers */
2730 + diff = nregs*UNITS_PER_WORD - cum->nbytes;
2732 + /* regs all used up */
2736 + /* Figure out the size of the object to be passed. */
2737 + if (mode == BLKmode)
2738 + size = int_size_in_bytes (type);
2740 + size = GET_MODE_SIZE (mode);
2742 + /* enough space left in regs for size */
2746 + /* put diff bytes in regs and rest on stack */
2752 +ubicom32_pass_by_reference (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
2753 + enum machine_mode mode, const_tree type,
2754 + bool named ATTRIBUTE_UNUSED)
2759 + size = int_size_in_bytes (type);
2761 + size = GET_MODE_SIZE (mode);
2763 + return size <= 0 || size > 8;
2767 +ubicom32_callee_copies (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
2768 + enum machine_mode mode, const_tree type,
2769 + bool named ATTRIBUTE_UNUSED)
2774 + size = int_size_in_bytes (type);
2776 + size = GET_MODE_SIZE (mode);
2778 + return size <= 0 || size > 8;
2782 +ubicom32_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED)
2789 + size = int_size_in_bytes(type);
2793 + mode = TYPE_MODE(type);
2794 + if (mode == BLKmode)
2800 +/* Return true if a given register number REGNO is acceptable for machine
2803 +ubicom32_hard_regno_mode_ok (unsigned int regno, enum machine_mode mode)
2805 + /* If we're not at least a v3 ISA then ACC0_HI is only 16 bits. */
2806 + if (! ubicom32_v3)
2808 + if (regno == ACC0_HI_REGNUM)
2809 + return (mode == QImode || mode == HImode);
2812 + /* Only the flags reg can hold CCmode. */
2813 + if (GET_MODE_CLASS (mode) == MODE_CC)
2814 + return regno == CC_REGNUM;
2816 + /* We restrict the choice of DImode registers to only being address,
2817 + data or accumulator regs. We also restrict them to only start on
2818 + even register numbers so we never have to worry about partial
2819 + overlaps between operands in instructions. */
2820 + if (GET_MODE_SIZE (mode) > 4)
2822 + switch (REGNO_REG_CLASS (regno))
2824 + case ADDRESS_REGS:
2827 + return (regno & 1) == 0;
2837 +/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
2838 + and check its validity for a certain class.
2839 + We have two alternate definitions for each of them.
2840 + The usual definition accepts all pseudo regs; the other rejects
2841 + them unless they have been allocated suitable hard regs.
2842 + The symbol REG_OK_STRICT causes the latter definition to be used.
2844 + Most source files want to accept pseudo regs in the hope that
2845 + they will get allocated to the class that the insn wants them to be in.
2846 + Source files for reload pass need to be strict.
2847 + After reload, it makes no difference, since pseudo regs have
2848 + been eliminated by then.
2850 + These assume that REGNO is a hard or pseudo reg number.
2851 + They give nonzero only if REGNO is a hard reg of the suitable class
2852 + or a pseudo reg currently allocated to a suitable hard reg.
2853 + Since they use reg_renumber, they are safe only once reg_renumber
2854 + has been allocated, which happens in local-alloc.c. */
2857 +ubicom32_regno_ok_for_base_p (int regno, int strict)
2859 + if ((regno >= FIRST_ADDRESS_REGNUM && regno <= STACK_POINTER_REGNUM)
2861 + && (regno >= FIRST_PSEUDO_REGISTER
2862 + || regno == ARG_POINTER_REGNUM))
2863 + || (strict && (reg_renumber
2864 + && reg_renumber[regno] >= FIRST_ADDRESS_REGNUM
2865 + && reg_renumber[regno] <= STACK_POINTER_REGNUM)))
2872 +ubicom32_regno_ok_for_index_p (int regno, int strict)
2874 + if ((regno >= FIRST_DATA_REGNUM && regno <= LAST_DATA_REGNUM)
2875 + || (!strict && regno >= FIRST_PSEUDO_REGISTER)
2876 + || (strict && (reg_renumber
2877 + && reg_renumber[regno] >= FIRST_DATA_REGNUM
2878 + && reg_renumber[regno] <= LAST_DATA_REGNUM)))
2884 +/* Returns 1 if X is a valid index register. STRICT is 1 if only hard
2885 + registers should be accepted. Accept either REG or SUBREG where a
2886 + register is valid. */
2889 +ubicom32_is_index_reg (rtx x, int strict)
2891 + if ((REG_P (x) && ubicom32_regno_ok_for_index_p (REGNO (x), strict))
2892 + || (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x))
2893 + && ubicom32_regno_ok_for_index_p (REGNO (SUBREG_REG (x)), strict)))
2899 +/* Return 1 if X is a valid index for a memory address. */
2902 +ubicom32_is_index_expr (enum machine_mode mode, rtx x, int strict)
2904 + /* Immediate index must be an unsigned 7-bit offset multiple of 1, 2
2905 + or 4 depending on mode. */
2906 + if (CONST_INT_P (x))
2911 + return satisfies_constraint_J (x);
2914 + return satisfies_constraint_K (x);
2918 + return satisfies_constraint_L (x);
2921 + return satisfies_constraint_L (x)
2922 + && satisfies_constraint_L (GEN_INT (INTVAL (x) + 4));
2929 + if (mode != SImode && mode != HImode && mode != QImode)
2932 + /* Register index scaled by mode of operand: REG + REG * modesize.
2933 + Valid scaled index registers are:
2935 + SImode (mult (dreg) 4))
2936 + HImode (mult (dreg) 2))
2937 + QImode (mult (dreg) 1)) */
2938 + if (GET_CODE (x) == MULT
2939 + && ubicom32_is_index_reg (XEXP (x, 0), strict)
2940 + && CONST_INT_P (XEXP (x, 1))
2941 + && INTVAL (XEXP (x, 1)) == (HOST_WIDE_INT)GET_MODE_SIZE (mode))
2944 + /* REG + REG addressing is allowed for QImode. */
2945 + if (ubicom32_is_index_reg (x, strict) && mode == QImode)
2952 +ubicom32_is_valid_offset (enum machine_mode mode, HOST_WIDE_INT offs)
2960 + return offs <= 127;
2963 + return offs <= 254;
2967 + return offs <= 508;
2970 + return offs <= 504;
2978 +ubicom32_get_valid_offset_mask (enum machine_mode mode)
3000 +/* Returns 1 if X is a valid base register. STRICT is 1 if only hard
3001 + registers should be accepted. Accept either REG or SUBREG where a
3002 + register is valid. */
3005 +ubicom32_is_base_reg (rtx x, int strict)
3007 + if ((REG_P (x) && ubicom32_regno_ok_for_base_p (REGNO (x), strict))
3008 + || (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x))
3009 + && ubicom32_regno_ok_for_base_p (REGNO (SUBREG_REG (x)), strict)))
3016 +ubicom32_cannot_force_const_mem (rtx x ATTRIBUTE_UNUSED)
3018 + return TARGET_FDPIC;
3021 +/* Determine if X is a legitimate constant. */
3024 +ubicom32_legitimate_constant_p (rtx x)
3026 + /* Among its other duties, LEGITIMATE_CONSTANT_P decides whether
3027 + a constant can be entered into reg_equiv_constant[]. If we return true,
3028 + reload can create new instances of the constant whenever it likes.
3030 + The idea is therefore to accept as many constants as possible (to give
3031 + reload more freedom) while rejecting constants that can only be created
3032 + at certain times. In particular, anything with a symbolic component will
3033 + require use of the pseudo FDPIC register, which is only available before
3037 + if (GET_CODE (x) == SYMBOL_REF
3038 + || (GET_CODE (x) == CONST
3039 + && GET_CODE (XEXP (x, 0)) == PLUS
3040 + && GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF)
3041 + || CONSTANT_ADDRESS_P (x))
3047 + /* For non-PIC code anything goes! */
3051 +/* Address validation. */
3054 +ubicom32_legitimate_address_p (enum machine_mode mode, rtx x, int strict)
3056 + if (TARGET_DEBUG_ADDRESS)
3058 + fprintf (stderr, "\n==> GO_IF_LEGITIMATE_ADDRESS%s\n",
3059 + (strict) ? " (STRICT)" : "");
3063 + if (CONSTANT_ADDRESS_P (x))
3066 + if (ubicom32_is_base_reg (x, strict))
3069 + if ((GET_CODE (x) == POST_INC
3070 + || GET_CODE (x) == PRE_INC
3071 + || GET_CODE (x) == POST_DEC
3072 + || GET_CODE (x) == PRE_DEC)
3073 + && REG_P (XEXP (x, 0))
3074 + && ubicom32_is_base_reg (XEXP (x, 0), strict)
3075 + && mode != DImode)
3078 + if ((GET_CODE (x) == PRE_MODIFY || GET_CODE (x) == POST_MODIFY)
3079 + && ubicom32_is_base_reg (XEXP (x, 0), strict)
3080 + && GET_CODE (XEXP (x, 1)) == PLUS
3081 + && rtx_equal_p (XEXP (x, 0), XEXP (XEXP (x, 1), 0))
3082 + && CONST_INT_P (XEXP (XEXP (x, 1), 1))
3083 + && mode != DImode)
3085 + HOST_WIDE_INT disp = INTVAL (XEXP (XEXP (x, 1), 1));
3089 + return disp >= -8 && disp <= 7;
3092 + return disp >= -16 && disp <= 14 && ! (disp & 1);
3095 + return disp >= -32 && disp <= 28 && ! (disp & 3);
3102 + /* Accept base + index * scale. */
3103 + if (GET_CODE (x) == PLUS
3104 + && ubicom32_is_base_reg (XEXP (x, 0), strict)
3105 + && ubicom32_is_index_expr (mode, XEXP (x, 1), strict))
3108 + /* Accept index * scale + base. */
3109 + if (GET_CODE (x) == PLUS
3110 + && ubicom32_is_base_reg (XEXP (x, 1), strict)
3111 + && ubicom32_is_index_expr (mode, XEXP (x, 0), strict))
3114 + if (! TARGET_FDPIC)
3116 + /* Accept (lo_sum (reg) (symbol_ref)) that can be used as a mem+7bits
3117 + displacement operand:
3119 + moveai a1, #%hi(SYM)
3120 + move.4 d3, %lo(SYM)(a1) */
3121 + if (GET_CODE (x) == LO_SUM
3122 + && ubicom32_is_base_reg (XEXP (x, 0), strict)
3123 + && (GET_CODE (XEXP (x, 1)) == SYMBOL_REF
3124 + || GET_CODE (XEXP (x, 1)) == LABEL_REF /* FIXME: wrong */)
3125 + && mode != DImode)
3129 + if (TARGET_DEBUG_ADDRESS)
3130 + fprintf (stderr, "\nNot a legitimate address.\n");
3136 +ubicom32_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
3137 + enum machine_mode mode)
3139 + if (mode == BLKmode)
3142 + if (GET_CODE (x) == PLUS
3143 + && REG_P (XEXP (x, 0))
3144 + && ! REGNO_PTR_FRAME_P (REGNO (XEXP (x, 0)))
3145 + && CONST_INT_P (XEXP (x, 1))
3146 + && ! ubicom32_is_valid_offset (mode, INTVAL (XEXP (x, 1))))
3151 + HOST_WIDE_INT val = INTVAL (XEXP (x, 1));
3152 + HOST_WIDE_INT low = val & ubicom32_get_valid_offset_mask (mode);
3153 + HOST_WIDE_INT high = val ^ low;
3161 + /* Reload the high part into a base reg; leave the low part
3162 + in the mem directly. */
3163 + base = XEXP (x, 0);
3164 + if (! ubicom32_is_base_reg (base, 0))
3165 + base = copy_to_mode_reg (Pmode, base);
3167 + plus = expand_simple_binop (Pmode, PLUS,
3168 + gen_int_mode (high, Pmode),
3169 + base, NULL, 0, OPTAB_WIDEN);
3170 + new_rtx = plus_constant (plus, low);
3178 +/* Try a machine-dependent way of reloading an illegitimate address AD
3179 + operand. If we find one, push the reload and and return the new address.
3181 + MODE is the mode of the enclosing MEM. OPNUM is the operand number
3182 + and TYPE is the reload type of the current reload. */
3185 +ubicom32_legitimize_reload_address (rtx ad, enum machine_mode mode,
3186 + int opnum, int type)
3188 + /* Is this an address that we've already fixed up? If it is then
3189 + recognize it and move on. */
3190 + if (GET_CODE (ad) == PLUS
3191 + && GET_CODE (XEXP (ad, 0)) == PLUS
3192 + && REG_P (XEXP (XEXP (ad, 0), 0))
3193 + && CONST_INT_P (XEXP (XEXP (ad, 0), 1))
3194 + && CONST_INT_P (XEXP (ad, 1)))
3196 + push_reload (XEXP (ad, 0), NULL_RTX, &XEXP (ad, 0), NULL,
3197 + BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
3198 + opnum, (enum reload_type) type);
3202 + /* Have we got an address where the offset is simply out of range? If
3203 + yes then reload the range as a high part and smaller offset. */
3204 + if (GET_CODE (ad) == PLUS
3205 + && REG_P (XEXP (ad, 0))
3206 + && REGNO (XEXP (ad, 0)) < FIRST_PSEUDO_REGISTER
3207 + && REGNO_OK_FOR_BASE_P (REGNO (XEXP (ad, 0)))
3208 + && CONST_INT_P (XEXP (ad, 1))
3209 + && ! ubicom32_is_valid_offset (mode, INTVAL (XEXP (ad, 1))))
3214 + HOST_WIDE_INT val = INTVAL (XEXP (ad, 1));
3215 + HOST_WIDE_INT low = val & ubicom32_get_valid_offset_mask (mode);
3216 + HOST_WIDE_INT high = val ^ low;
3218 + /* Reload the high part into a base reg; leave the low part
3219 + in the mem directly. */
3220 + temp = gen_rtx_PLUS (Pmode, XEXP (ad, 0), GEN_INT (high));
3221 + new_rtx = gen_rtx_PLUS (Pmode, temp, GEN_INT (low));
3223 + push_reload (XEXP (new_rtx, 0), NULL_RTX, &XEXP (new_rtx, 0), NULL,
3224 + BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
3225 + opnum, (enum reload_type) type);
3229 + /* If we're presented with an pre/post inc/dec then we must force this
3230 + to be done in an address register. The register allocator should
3231 + work this out for itself but at times ends up trying to use the wrong
3232 + class. If we get the wrong class then reload will end up generating
3233 + at least 3 instructions whereas this way we can hopefully keep it to
3235 + if ((GET_CODE (ad) == POST_INC
3236 + || GET_CODE (ad) == PRE_INC
3237 + || GET_CODE (ad) == POST_DEC
3238 + || GET_CODE (ad) == PRE_DEC)
3239 + && REG_P (XEXP (ad, 0))
3240 + && REGNO (XEXP (ad, 0)) < FIRST_PSEUDO_REGISTER
3241 + && ! REGNO_OK_FOR_BASE_P (REGNO (XEXP (ad, 0))))
3243 + push_reload (XEXP (ad, 0), XEXP (ad, 0), &XEXP (ad, 0), &XEXP (ad, 0),
3244 + BASE_REG_CLASS, GET_MODE (XEXP (ad, 0)), GET_MODE (XEXP (ad, 0)), 0, 0,
3245 + opnum, RELOAD_OTHER);
3252 +/* Compute a (partial) cost for rtx X. Return true if the complete
3253 + cost has been computed, and false if subexpressions should be
3254 + scanned. In either case, *TOTAL contains the cost result. */
3257 +ubicom32_rtx_costs (rtx x, int code, int outer_code, int *total,
3258 + bool speed ATTRIBUTE_UNUSED)
3260 + enum machine_mode mode = GET_MODE (x);
3265 + /* Very short constants often fold into instructions so
3266 + we pretend that they don't cost anything! This is
3267 + really important as regards zero values as otherwise
3268 + the compiler has a nasty habit of wanting to reuse
3269 + zeroes that are in regs but that tends to pessimize
3271 + if (satisfies_constraint_I (x))
3277 + /* Bit clearing costs nothing */
3278 + if (outer_code == AND
3279 + && exact_log2 (~INTVAL (x)) != -1)
3285 + /* Masking the lower set of bits costs nothing. */
3286 + if (outer_code == AND
3287 + && exact_log2 (INTVAL (x) + 1) != -1)
3293 + /* Bit setting costs nothing. */
3294 + if (outer_code == IOR
3295 + && exact_log2 (INTVAL (x)) != -1)
3301 + /* Larger constants that can be loaded via movei aren't too
3302 + bad. If we're just doing a set they cost nothing extra. */
3303 + if (satisfies_constraint_N (x))
3305 + if (mode == DImode)
3306 + *total = COSTS_N_INSNS (2);
3308 + *total = COSTS_N_INSNS (1);
3312 + if (mode == DImode)
3313 + *total = COSTS_N_INSNS (5);
3315 + *total = COSTS_N_INSNS (3);
3318 + case CONST_DOUBLE:
3319 + /* We don't optimize CONST_DOUBLEs well nor do we relax them well,
3320 + so their cost is very high. */
3321 + *total = COSTS_N_INSNS (6);
3330 + case IF_THEN_ELSE:
3331 + *total = COSTS_N_INSNS (1);
3350 + case ZERO_EXTRACT:
3351 + if (outer_code == SET)
3353 + if (mode == DImode)
3354 + *total = COSTS_N_INSNS (2);
3356 + *total = COSTS_N_INSNS (1);
3361 + if (outer_code == SET)
3363 + if (GET_MODE (XEXP (x, 0)) == DImode
3364 + || GET_MODE (XEXP (x, 1)) == DImode)
3365 + *total = COSTS_N_INSNS (2);
3367 + *total = COSTS_N_INSNS (1);
3375 + if (outer_code == SET)
3377 + if (mode == DImode)
3378 + *total = COSTS_N_INSNS (600);
3380 + *total = COSTS_N_INSNS (200);
3385 + if (outer_code == SET)
3387 + if (! ubicom32_v4)
3389 + if (mode == DImode)
3390 + *total = COSTS_N_INSNS (15);
3392 + *total = COSTS_N_INSNS (5);
3396 + if (mode == DImode)
3397 + *total = COSTS_N_INSNS (6);
3399 + *total = COSTS_N_INSNS (2);
3405 + if (XINT (x, 1) == UNSPEC_FDPIC_GOT
3406 + || XINT (x, 1) == UNSPEC_FDPIC_GOT_FUNCDESC)
3415 +/* Return 1 if ADDR can have different meanings depending on the machine
3416 + mode of the memory reference it is used for or if the address is
3417 + valid for some modes but not others.
3419 + Autoincrement and autodecrement addresses typically have
3420 + mode-dependent effects because the amount of the increment or
3421 + decrement is the size of the operand being addressed. Some machines
3422 + have other mode-dependent addresses. Many RISC machines have no
3423 + mode-dependent addresses.
3425 + You may assume that ADDR is a valid address for the machine. */
3428 +ubicom32_mode_dependent_address_p (rtx addr)
3430 + if (GET_CODE (addr) == POST_INC
3431 + || GET_CODE (addr) == PRE_INC
3432 + || GET_CODE (addr) == POST_DEC
3433 + || GET_CODE (addr) == PRE_DEC
3434 + || GET_CODE (addr) == POST_MODIFY
3435 + || GET_CODE (addr) == PRE_MODIFY)
3442 +ubicom32_function_prologue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED)
3444 + fprintf (file, "/* frame/pretend: %ld/%d save_regs: %d out_args: %d %s */\n",
3445 + get_frame_size (), crtl->args.pretend_args_size,
3446 + save_regs_size, crtl->outgoing_args_size,
3447 + current_function_is_leaf ? "leaf" : "nonleaf");
3451 +ubicom32_function_epilogue (FILE *file ATTRIBUTE_UNUSED,
3452 + HOST_WIDE_INT size ATTRIBUTE_UNUSED)
3454 + ubicom32_reorg_completed = 0;
3458 +ubicom32_machine_dependent_reorg (void)
3460 +#if 0 /* Commenting out this optimization until it is fixed */
3463 + compute_bb_for_insn ();
3465 + /* Do a very simple CSE pass over just the hard registers. */
3466 + reload_cse_regs (get_insns ());
3468 + /* Reload_cse_regs can eliminate potentially-trapping MEMs.
3469 + Remove any EH edges associated with them. */
3470 + if (flag_non_call_exceptions)
3471 + purge_all_dead_edges ();
3474 + ubicom32_reorg_completed = 1;
3478 +ubicom32_output_cond_jump (rtx insn, rtx cond, rtx target)
3481 + int mostly_false_jump;
3485 + note = find_reg_note (insn, REG_BR_PROB, 0);
3486 + mostly_false_jump = !note || (INTVAL (XEXP (note, 0))
3487 + <= REG_BR_PROB_BASE / 2);
3489 + xoperands[0] = target;
3490 + xoperands[1] = cond;
3491 + cc_reg = XEXP (cond, 0);
3493 + if (GET_MODE (cc_reg) == CCWmode
3494 + || GET_MODE (cc_reg) == CCWZmode
3495 + || GET_MODE (cc_reg) == CCWZNmode)
3497 + if (mostly_false_jump)
3498 + output_asm_insn ("jmp%b1.w.f\t%0", xoperands);
3500 + output_asm_insn ("jmp%b1.w.t\t%0", xoperands);
3504 + if (GET_MODE (cc_reg) == CCSmode
3505 + || GET_MODE (cc_reg) == CCSZmode
3506 + || GET_MODE (cc_reg) == CCSZNmode)
3508 + if (mostly_false_jump)
3509 + output_asm_insn ("jmp%b1.s.f\t%0", xoperands);
3511 + output_asm_insn ("jmp%b1.s.t\t%0", xoperands);
3518 +/* Return non-zero if FUNC is a naked function. */
3521 +ubicom32_naked_function_p (void)
3523 + return lookup_attribute ("naked", DECL_ATTRIBUTES (current_function_decl)) != NULL_TREE;
3526 +/* Return an RTX indicating where the return address to the
3527 + calling function can be found. */
3529 +ubicom32_return_addr_rtx (int count, rtx frame ATTRIBUTE_UNUSED)
3534 + return get_hard_reg_initial_val (Pmode, LINK_REGNO);
3538 + * ubicom32_readonly_data_section: This routtine handles code
3539 + * at the start of readonly data sections
3542 +ubicom32_readonly_data_section (const void *data ATTRIBUTE_UNUSED)
3544 + static int num = 0;
3545 + if (in_section == readonly_data_section){
3546 + fprintf (asm_out_file, "%s", DATA_SECTION_ASM_OP);
3547 + if (flag_data_sections){
3548 + fprintf (asm_out_file, ".rodata%d", num);
3549 + fprintf (asm_out_file, ",\"a\"");
3551 + fprintf (asm_out_file, "\n");
3557 + * ubicom32_text_section: not in readonly section
3560 +ubicom32_text_section(const void *data ATTRIBUTE_UNUSED)
3562 + fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
3566 + * ubicom32_data_section: not in readonly section
3569 +ubicom32_data_section(const void *data ATTRIBUTE_UNUSED)
3571 + fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
3575 + * ubicom32_asm_init_sections: This routine implements special
3576 + * section handling
3579 +ubicom32_asm_init_sections(void)
3581 + text_section = get_unnamed_section(SECTION_CODE, ubicom32_text_section, NULL);
3583 + data_section = get_unnamed_section(SECTION_WRITE, ubicom32_data_section, NULL);
3585 + readonly_data_section = get_unnamed_section(0, ubicom32_readonly_data_section, NULL);
3589 + * ubicom32_profiler: This routine would call
3590 + * mcount to support prof and gprof if mcount
3591 + * was supported. Currently, do nothing.
3594 +ubicom32_profiler(void)
3598 +/* Initialise the builtin functions. Start by initialising
3599 + descriptions of different types of functions (e.g., void fn(int),
3600 + int fn(void)), and then use these to define the builtins. */
3602 +ubicom32_init_builtins (void)
3605 + tree short_unsigned_endlink;
3606 + tree unsigned_endlink;
3607 + tree short_unsigned_ftype_short_unsigned;
3608 + tree unsigned_ftype_unsigned;
3610 + endlink = void_list_node;
3612 + short_unsigned_endlink
3613 + = tree_cons (NULL_TREE, short_unsigned_type_node, endlink);
3616 + = tree_cons (NULL_TREE, unsigned_type_node, endlink);
3618 + short_unsigned_ftype_short_unsigned
3619 + = build_function_type (short_unsigned_type_node, short_unsigned_endlink);
3621 + unsigned_ftype_unsigned
3622 + = build_function_type (unsigned_type_node, unsigned_endlink);
3624 + /* Initialise the byte swap function. */
3625 + add_builtin_function ("__builtin_ubicom32_swapb_2",
3626 + short_unsigned_ftype_short_unsigned,
3627 + UBICOM32_BUILTIN_UBICOM32_SWAPB_2,
3628 + BUILT_IN_MD, NULL,
3631 + /* Initialise the byte swap function. */
3632 + add_builtin_function ("__builtin_ubicom32_swapb_4",
3633 + unsigned_ftype_unsigned,
3634 + UBICOM32_BUILTIN_UBICOM32_SWAPB_4,
3635 + BUILT_IN_MD, NULL,
3639 +/* Given a builtin function taking 2 operands (i.e., target + source),
3640 + emit the RTL for the underlying instruction. */
3642 +ubicom32_expand_builtin_2op (enum insn_code icode, tree arglist, rtx target)
3646 + enum machine_mode tmode, mode0;
3648 + /* Grab the incoming argument and emit its RTL. */
3649 + arg0 = TREE_VALUE (arglist);
3650 + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
3652 + /* Determine the modes of the instruction operands. */
3653 + tmode = insn_data[icode].operand[0].mode;
3654 + mode0 = insn_data[icode].operand[1].mode;
3656 + /* Ensure that the incoming argument RTL is in a register of the
3658 + if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
3659 + op0 = copy_to_mode_reg (mode0, op0);
3661 + /* If there isn't a suitable target, emit a target register. */
3663 + || GET_MODE (target) != tmode
3664 + || !(*insn_data[icode].operand[0].predicate) (target, tmode))
3665 + target = gen_reg_rtx (tmode);
3667 + /* Emit and return the new instruction. */
3668 + pat = GEN_FCN (icode) (target, op0);
3676 +/* Expand a call to a builtin function. */
3678 +ubicom32_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
3679 + enum machine_mode mode ATTRIBUTE_UNUSED,
3680 + int ignore ATTRIBUTE_UNUSED)
3682 + tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
3683 + tree arglist = CALL_EXPR_ARGS(exp);
3684 + int fcode = DECL_FUNCTION_CODE (fndecl);
3688 + case UBICOM32_BUILTIN_UBICOM32_SWAPB_2:
3689 + return ubicom32_expand_builtin_2op (CODE_FOR_bswaphi, arglist, target);
3691 + case UBICOM32_BUILTIN_UBICOM32_SWAPB_4:
3692 + return ubicom32_expand_builtin_2op (CODE_FOR_bswapsi, arglist, target);
3695 + gcc_unreachable();
3698 + /* Should really do something sensible here. */
3702 +/* Fold any constant argument for a swapb.2 instruction. */
3704 +ubicom32_fold_builtin_ubicom32_swapb_2 (tree fndecl, tree arglist)
3708 + arg0 = TREE_VALUE (arglist);
3710 + /* Optimize constant value. */
3711 + if (TREE_CODE (arg0) == INTEGER_CST)
3714 + HOST_WIDE_INT res;
3716 + v = TREE_INT_CST_LOW (arg0);
3717 + res = ((v >> 8) & 0xff)
3718 + | ((v & 0xff) << 8);
3720 + return build_int_cst (TREE_TYPE (TREE_TYPE (fndecl)), res);
3726 +/* Fold any constant argument for a swapb.4 instruction. */
3728 +ubicom32_fold_builtin_ubicom32_swapb_4 (tree fndecl, tree arglist)
3732 + arg0 = TREE_VALUE (arglist);
3734 + /* Optimize constant value. */
3735 + if (TREE_CODE (arg0) == INTEGER_CST)
3737 + unsigned HOST_WIDE_INT v;
3738 + unsigned HOST_WIDE_INT res;
3740 + v = TREE_INT_CST_LOW (arg0);
3741 + res = ((v >> 24) & 0xff)
3742 + | (((v >> 16) & 0xff) << 8)
3743 + | (((v >> 8) & 0xff) << 16)
3744 + | ((v & 0xff) << 24);
3746 + return build_int_cst_wide (TREE_TYPE (TREE_TYPE (fndecl)), res, 0);
3752 +/* Fold any constant arguments for builtin functions. */
3754 +ubicom32_fold_builtin (tree fndecl, tree arglist, bool ignore ATTRIBUTE_UNUSED)
3756 + switch (DECL_FUNCTION_CODE (fndecl))
3758 + case UBICOM32_BUILTIN_UBICOM32_SWAPB_2:
3759 + return ubicom32_fold_builtin_ubicom32_swapb_2 (fndecl, arglist);
3761 + case UBICOM32_BUILTIN_UBICOM32_SWAPB_4:
3762 + return ubicom32_fold_builtin_ubicom32_swapb_4 (fndecl, arglist);
3769 +/* Implementation of TARGET_ASM_INTEGER. When using FD-PIC, we need to
3770 + tell the assembler to generate pointers to function descriptors in
3773 +ubicom32_assemble_integer (rtx value, unsigned int size, int aligned_p)
3775 + if (TARGET_FDPIC && size == UNITS_PER_WORD)
3777 + if (GET_CODE (value) == SYMBOL_REF
3778 + && SYMBOL_REF_FUNCTION_P (value))
3780 + fputs ("\t.picptr\t%funcdesc(", asm_out_file);
3781 + output_addr_const (asm_out_file, value);
3782 + fputs (")\n", asm_out_file);
3788 + /* We've set the unaligned SI op to NULL, so we always have to
3789 + handle the unaligned case here. */
3790 + assemble_integer_with_op ("\t.4byte\t", value);
3795 + return default_assemble_integer (value, size, aligned_p);
3798 +/* If the constant I can be constructed by shifting a source-1 immediate
3799 + by a constant number of bits then return the bit count. If not
3803 +ubicom32_shiftable_const_int (int i)
3807 + /* Note that any constant that can be represented as an immediate to
3808 + a movei instruction is automatically ignored here in the interests
3809 + of the clarity of the output asm code. */
3810 + if (i >= -32768 && i <= 32767)
3813 + /* Find the number of trailing zeroes. We could use __builtin_ctz
3814 + here but it's not obvious if this is supported on all build
3815 + compilers so we err on the side of caution. */
3816 + if ((i & 0xffff) == 0)
3822 + if ((i & 0xff) == 0)
3828 + if ((i & 0xf) == 0)
3834 + if ((i & 0x3) == 0)
3840 + if ((i & 0x1) == 0)
3846 + if (i >= -128 && i <= 127)
3853 +++ b/gcc/config/ubicom32/ubicom32.h
3855 +/* Definitions of target machine for Ubicom32
3857 + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
3858 + 2009 Free Software Foundation, Inc.
3859 + Contributed by Ubicom, Inc.
3861 + This file is part of GCC.
3863 + GCC is free software; you can redistribute it and/or modify it
3864 + under the terms of the GNU General Public License as published
3865 + by the Free Software Foundation; either version 3, or (at your
3866 + option) any later version.
3868 + GCC is distributed in the hope that it will be useful, but WITHOUT
3869 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
3870 + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
3871 + License for more details.
3873 + You should have received a copy of the GNU General Public License
3874 + along with GCC; see the file COPYING3. If not see
3875 + <http://www.gnu.org/licenses/>. */
3879 +#define OBJECT_FORMAT_ELF
3881 +/* Run-time target specifications. */
3883 +/* Target CPU builtins. */
3884 +#define TARGET_CPU_CPP_BUILTINS() \
3887 + builtin_define_std ("__UBICOM32__"); \
3888 + builtin_define_std ("__ubicom32__"); \
3890 + if (TARGET_FDPIC) \
3892 + builtin_define ("__UBICOM32_FDPIC__"); \
3893 + builtin_define ("__FDPIC__"); \
3898 +#ifndef TARGET_DEFAULT
3899 +#define TARGET_DEFAULT 0
3902 +extern int ubicom32_case_values_threshold;
3904 +/* Nonzero if this chip supports the Ubicom32 v3 ISA. */
3905 +extern int ubicom32_v3;
3907 +/* Nonzero if this chip supports the Ubicom32 v4 ISA. */
3908 +extern int ubicom32_v4;
3910 +extern int ubicom32_stack_size;
3912 +/* Flag for whether we can use calli instead of ret in returns. */
3913 +extern int ubicom32_can_use_calli_to_ret;
3915 +/* This macro is a C statement to print on `stderr' a string describing the
3916 + particular machine description choice. Every machine description should
3917 + define `TARGET_VERSION'. */
3918 +#define TARGET_VERSION fprintf (stderr, " (UBICOM32)");
3920 +/* We don't need a frame pointer to debug things. Doing this means
3921 + that gcc can turn on -fomit-frame-pointer when '-O' is specified. */
3922 +#define CAN_DEBUG_WITHOUT_FP
3924 +/* We need to handle processor-specific options. */
3925 +#define OVERRIDE_OPTIONS ubicom32_override_options ()
3927 +#define OPTIMIZATION_OPTIONS(LEVEL, SIZE) \
3928 + ubicom32_optimization_options (LEVEL, SIZE)
3930 +/* For Ubicom32 the least significant bit has the lowest bit number
3931 + so we define this to be 0. */
3932 +#define BITS_BIG_ENDIAN 0
3934 +/* For Ubicom32 the most significant byte in a word has the lowest
3936 +#define BYTES_BIG_ENDIAN 1
3938 +/* For Ubicom32, in a multiword object, the most signifant word has the
3940 +#define WORDS_BIG_ENDIAN 1
3942 +/* Ubicom32 has 8 bits per byte. */
3943 +#define BITS_PER_UNIT 8
3945 +/* Ubicom32 has 32 bits per word. */
3946 +#define BITS_PER_WORD 32
3948 +/* Width of a word, in units (bytes). */
3949 +#define UNITS_PER_WORD 4
3951 +/* Width of a pointer, in bits. */
3952 +#define POINTER_SIZE 32
3954 +/* Alias for pointers. Ubicom32 is a 32-bit architecture so we use
3956 +#define Pmode SImode
3958 +/* Normal alignment required for function parameters on the stack, in
3960 +#define PARM_BOUNDARY 32
3962 +/* We need to maintain the stack on a 32-bit boundary. */
3963 +#define STACK_BOUNDARY 32
3965 +/* Alignment required for a function entry point, in bits. */
3966 +#define FUNCTION_BOUNDARY 32
3968 +/* Alias for the machine mode used for memory references to functions being
3969 + called, in `call' RTL expressions. We use byte-oriented addresses
3971 +#define FUNCTION_MODE QImode
3973 +/* Biggest alignment that any data type can require on this machine,
3975 +#define BIGGEST_ALIGNMENT 32
3977 +/* this default to BIGGEST_ALIGNMENT unless defined */
3978 +/* ART: What's the correct value here? Default is (((unsigned int)1<<28)*8)*/
3979 +#undef MAX_OFILE_ALIGNMENT
3980 +#define MAX_OFILE_ALIGNMENT (128 * 8)
3982 +/* Alignment in bits to be given to a structure bit field that follows an empty
3983 + field such as `int : 0;'. */
3984 +#define EMPTY_FIELD_BOUNDARY 32
3986 +/* All structures must be a multiple of 32 bits in size. */
3987 +#define STRUCTURE_SIZE_BOUNDARY 32
3989 +/* A bit-field declared as `int' forces `int' alignment for the struct. */
3990 +#define PCC_BITFIELD_TYPE_MATTERS 1
3992 +/* For Ubicom32 we absolutely require that data be aligned with nominal
3994 +#define STRICT_ALIGNMENT 1
3996 +/* Make strcpy of constants fast. */
3997 +#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
3998 + (TREE_CODE (EXP) == STRING_CST \
3999 + && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
4001 +/* Define this macro as an expression for the alignment of a structure
4002 + (given by STRUCT as a tree node) if the alignment computed in the
4003 + usual way is COMPUTED and the alignment explicitly specified was
4005 +#define DATA_ALIGNMENT(TYPE, ALIGN) \
4006 + ((((ALIGN) < BITS_PER_WORD) \
4007 + && (TREE_CODE (TYPE) == ARRAY_TYPE \
4008 + || TREE_CODE (TYPE) == UNION_TYPE \
4009 + || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
4011 +#define LOCAL_ALIGNMENT(TYPE,ALIGN) DATA_ALIGNMENT(TYPE,ALIGN)
4013 +/* For Ubicom32 we default to unsigned chars. */
4014 +#define DEFAULT_SIGNED_CHAR 0
4016 +/* Machine-specific data register numbers. */
4017 +#define FIRST_DATA_REGNUM 0
4018 +#define D10_REGNUM 10
4019 +#define D11_REGNUM 11
4020 +#define D12_REGNUM 12
4021 +#define D13_REGNUM 13
4022 +#define LAST_DATA_REGNUM 15
4024 +/* Machine-specific address register numbers. */
4025 +#define FIRST_ADDRESS_REGNUM 16
4026 +#define LAST_ADDRESS_REGNUM 22
4028 +/* Register numbers used for passing a function's static chain pointer. If
4029 + register windows are used, the register number as seen by the called
4030 + function is `STATIC_CHAIN_INCOMING_REGNUM', while the register number as
4031 + seen by the calling function is `STATIC_CHAIN_REGNUM'. If these registers
4032 + are the same, `STATIC_CHAIN_INCOMING_REGNUM' need not be defined.
4034 + The static chain register need not be a fixed register.
4036 + If the static chain is passed in memory, these macros should not be defined;
4037 + instead, the next two macros should be defined. */
4038 +#define STATIC_CHAIN_REGNUM (FIRST_ADDRESS_REGNUM + 1)
4040 +/* The register number of the frame pointer register, which is used to access
4041 + automatic variables in the stack frame. We generally eliminate this anyway
4042 + for Ubicom32 but we make it A6 by default. */
4043 +#define FRAME_POINTER_REGNUM (LAST_ADDRESS_REGNUM)
4045 +/* The register number of the stack pointer register, which is also be a
4046 + fixed register according to `FIXED_REGISTERS'. For Ubicom32 we don't
4047 + have a hardware requirement about which register this is, but by convention
4049 +#define STACK_POINTER_REGNUM (LAST_ADDRESS_REGNUM + 1)
4051 +/* Machine-specific accumulator register numbers. */
4052 +#define ACC0_HI_REGNUM 24
4053 +#define ACC0_LO_REGNUM 25
4054 +#define ACC1_HI_REGNUM 26
4055 +#define ACC1_LO_REGNUM 27
4057 +/* source3 register number */
4058 +#define SOURCE3_REGNUM 28
4060 +/* The register number of the arg pointer register, which is used to access the
4061 + function's argument list. On some machines, this is the same as the frame
4062 + pointer register. On some machines, the hardware determines which register
4063 + this is. On other machines, you can choose any register you wish for this
4064 + purpose. If this is not the same register as the frame pointer register,
4065 + then you must mark it as a fixed register according to `FIXED_REGISTERS', or
4066 + arrange to be able to eliminate it. */
4067 +#define ARG_POINTER_REGNUM 29
4069 +/* Pseudo-reg for condition code. */
4070 +#define CC_REGNUM 30
4072 +/* Interrupt set/clear registers. */
4073 +#define INT_SET0_REGNUM 31
4074 +#define INT_SET1_REGNUM 32
4075 +#define INT_CLR0_REGNUM 33
4076 +#define INT_CLR1_REGNUM 34
4078 +/* Scratchpad registers. */
4079 +#define SCRATCHPAD0_REGNUM 35
4080 +#define SCRATCHPAD1_REGNUM 36
4081 +#define SCRATCHPAD2_REGNUM 37
4082 +#define SCRATCHPAD3_REGNUM 38
4084 +/* FDPIC register. */
4085 +#define FDPIC_REGNUM 16
4087 +/* Number of hardware registers known to the compiler. They receive numbers 0
4088 + through `FIRST_PSEUDO_REGISTER-1'; thus, the first pseudo register's number
4089 + really is assigned the number `FIRST_PSEUDO_REGISTER'. */
4090 +#define FIRST_PSEUDO_REGISTER 39
4092 +/* An initializer that says which registers are used for fixed purposes all
4093 + throughout the compiled code and are therefore not available for general
4094 + allocation. These would include the stack pointer, the frame pointer
4095 + (except on machines where that can be used as a general register when no
4096 + frame pointer is needed), the program counter on machines where that is
4097 + considered one of the addressable registers, and any other numbered register
4098 + with a standard use.
4100 + This information is expressed as a sequence of numbers, separated by commas
4101 + and surrounded by braces. The Nth number is 1 if register N is fixed, 0
4104 + The table initialized from this macro, and the table initialized by the
4105 + following one, may be overridden at run time either automatically, by the
4106 + actions of the macro `CONDITIONAL_REGISTER_USAGE', or by the user with the
4107 + command options `-ffixed-REG', `-fcall-used-REG' and `-fcall-saved-REG'. */
4108 +#define FIXED_REGISTERS \
4110 + 0, 0, 0, 0, 0, 0, 0, 0, /* d0 - d7 */ \
4111 + 0, 0, 0, 0, 0, 0, 0, 1, /* d8 - d15 */ \
4112 + 0, 0, 0, 0, 0, 0, 0, 1, /* a0 - a7 */ \
4113 + 0, 0, /* acc0 hi/lo */ \
4114 + 0, 0, /* acc1 hi/lo */ \
4115 + 0, /* source3 */ \
4118 + 1, 1, /* int_set[01] */ \
4119 + 1, 1, /* int_clr[01] */ \
4120 + 1, 1, 1, 1 /* scratchpad[0123] */ \
4123 +/* Like `FIXED_REGISTERS' but has 1 for each register that is clobbered (in
4124 + general) by function calls as well as for fixed registers. This macro
4125 + therefore identifies the registers that are not available for general
4126 + allocation of values that must live across function calls.
4128 + If a register has 0 in `CALL_USED_REGISTERS', the compiler automatically
4129 + saves it on function entry and restores it on function exit, if the register
4130 + is used within the function. */
4131 +#define CALL_USED_REGISTERS \
4133 + 1, 1, 1, 1, 1, 1, 1, 1, /* d0 - d7 */ \
4134 + 1, 1, 0, 0, 0, 0, 1, 1, /* d8 - d15 */ \
4135 + 1, 0, 0, 1, 1, 1, 0, 1, /* a0 - a7 */ \
4136 + 1, 1, /* acc0 hi/lo */ \
4137 + 1, 1, /* acc1 hi/lo */ \
4138 + 1, /* source3 */ \
4141 + 1, 1, /* int_set[01] */ \
4142 + 1, 1, /* int_clr[01] */ \
4143 + 1, 1, 1, 1 /* scratchpad[0123] */ \
4146 +/* How to refer to registers in assembler output.
4147 + This sequence is indexed by compiler's hard-register-number (see above). */
4149 +/* A C initializer containing the assembler's names for the machine registers,
4150 + each one as a C string constant. This is what translates register numbers
4151 + in the compiler into assembler language. */
4152 +#define REGISTER_NAMES \
4154 + "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \
4155 + "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15", \
4156 + "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp", \
4157 + "acc0_hi", "acc0_lo", \
4158 + "acc1_hi", "acc1_lo", \
4162 + "int_set0", "int_set1", \
4163 + "int_clr0", "int_clr1", \
4164 + "scratchpad0", "scratchpad1", "scratchpad2", "scratchpad3" \
4167 +#define CONDITIONAL_REGISTER_USAGE \
4168 + ubicom32_conditional_register_usage ();
4170 +/* Order of allocation of registers. */
4172 +/* If defined, an initializer for a vector of integers, containing the numbers
4173 + of hard registers in the order in which GNU CC should prefer to use them
4174 + (from most preferred to least).
4176 + For Ubicom32 we try using caller-clobbered data registers first, then
4177 + callee-saved data registers, then caller-clobbered address registers,
4178 + then callee-saved address registers and finally everything else.
4180 + The caller-clobbered registers are usually slightly cheaper to use because
4181 + there's no need to save/restore. */
4182 +#define REG_ALLOC_ORDER \
4184 + 0, 1, 2, 3, 4, /* d0 - d4 */ \
4185 + 5, 6, 7, 8, 9, /* d5 - d9 */ \
4187 + 10, 11, 12, 13, /* d10 - d13 */ \
4188 + 19, 20, 16, 21, /* a3, a4, a0, a5 */ \
4189 + 17, 18, 22, /* a1, a2, a6 */ \
4190 + 24, 25, /* acc0 hi/lo */ \
4191 + 26, 27, /* acc0 hi/lo */ \
4192 + 28 /* source3 */ \
4195 +/* C expression for the number of consecutive hard registers, starting at
4196 + register number REGNO, required to hold a value of mode MODE. */
4197 +#define HARD_REGNO_NREGS(REGNO, MODE) \
4198 + ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
4200 +/* Most registers can hold QImode, HImode and SImode values but we have to
4201 + be able to indicate any hard registers that cannot hold values with some
4203 +#define HARD_REGNO_MODE_OK(REGNO, MODE) \
4204 + ubicom32_hard_regno_mode_ok(REGNO, MODE)
4206 +/* We can rename most registers aside from the FDPIC register if we're using
4208 +#define HARD_REGNO_RENAME_OK(from, to) (TARGET_FDPIC ? ((to) != FDPIC_REGNUM) : 1)
4210 +/* A C expression that is nonzero if it is desirable to choose register
4211 + allocation so as to avoid move instructions between a value of mode MODE1
4212 + and a value of mode MODE2.
4214 + If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R, MODE2)' are
4215 + ever different for any R, then `MODES_TIEABLE_P (MODE1, MODE2)' must be
4217 +#define MODES_TIEABLE_P(MODE1, MODE2) 1
4219 +/* An enumeral type that must be defined with all the register class names as
4220 + enumeral values. `NO_REGS' must be first. `ALL_REGS' must be the last
4221 + register class, followed by one more enumeral value, `LIM_REG_CLASSES',
4222 + which is not a register class but rather tells how many classes there are.
4224 + Each register class has a number, which is the value of casting the class
4225 + name to type `int'. The number serves as an index in many of the tables
4226 + described below. */
4246 +/* The number of distinct register classes. */
4247 +#define N_REG_CLASSES (int) LIM_REG_CLASSES
4249 +/* An initializer containing the names of the register classes as C string
4250 + constants. These names are used in writing some of the debugging dumps. */
4252 +#define REG_CLASS_NAMES \
4258 + "ALL_ADDRESS_REGS", \
4262 + "DATA_ACC_REGS", \
4270 +/* An initializer containing the contents of the register classes, as integers
4271 + which are bit masks. The Nth integer specifies the contents of class N.
4272 + The way the integer MASK is interpreted is that register R is in the class
4273 + if `MASK & (1 << R)' is 1.
4275 + When the machine has more than 32 registers, an integer does not suffice.
4276 + Then the integers are replaced by sub-initializers, braced groupings
4277 + containing several integers. Each sub-initializer must be suitable as an
4278 + initializer for the type `HARD_REG_SET' which is defined in
4279 + `hard-reg-set.h'. */
4280 +#define REG_CLASS_CONTENTS \
4282 + {0x00000000, 0x00000000}, /* No regs */ \
4283 + {0x0000ffff, 0x00000000}, /* DATA_REGS */ \
4284 + {0x00010000, 0x00000000}, /* FDPIC_REG */ \
4285 + {0x20fe0000, 0x00000000}, /* ADDRESS_REGS */ \
4286 + {0x20ff0000, 0x00000000}, /* ALL_ADDRESS_REGS */ \
4287 + {0x0a000000, 0x00000000}, /* ACC_LO_REGS */ \
4288 + {0x0f000000, 0x00000000}, /* ACC_REGS */ \
4289 + {0x40000000, 0x00000000}, /* CC_REG */ \
4290 + {0x0f00ffff, 0x00000000}, /* DATA_ACC_REGS */ \
4291 + {0x10000000, 0x00000000}, /* SOURGE3_REG */ \
4292 + {0x80000000, 0x0000007f}, /* SPECIAL_REGS */ \
4293 + {0xbfffffff, 0x0000007f}, /* GENERAL_REGS */ \
4294 + {0xbfffffff, 0x0000007f} /* ALL_REGS */ \
4297 +extern enum reg_class const ubicom32_regclass_map[FIRST_PSEUDO_REGISTER];
4299 +/* A C expression whose value is a register class containing hard register
4300 + REGNO. In general there is more than one such class; choose a class which
4301 + is "minimal", meaning that no smaller class also contains the register. */
4302 +#define REGNO_REG_CLASS(REGNO) (ubicom32_regclass_map[REGNO])
4304 +#define IRA_COVER_CLASSES \
4310 +/* Ubicom32 base registers must be address registers since addresses can
4311 + only be reached via address registers. */
4312 +#define BASE_REG_CLASS ALL_ADDRESS_REGS
4314 +/* Ubicom32 index registers must be data registers since we cannot add
4315 + two address registers together to form an address. */
4316 +#define INDEX_REG_CLASS DATA_REGS
4318 +/* A C expression which is nonzero if register number NUM is suitable for use
4319 + as a base register in operand addresses. It may be either a suitable hard
4320 + register or a pseudo register that has been allocated such a hard register. */
4322 +#ifndef REG_OK_STRICT
4323 +#define REGNO_OK_FOR_BASE_P(regno) \
4324 + ubicom32_regno_ok_for_base_p (regno, 0)
4326 +#define REGNO_OK_FOR_BASE_P(regno) \
4327 + ubicom32_regno_ok_for_base_p (regno, 1)
4330 +/* A C expression which is nonzero if register number NUM is suitable for use
4331 + as an index register in operand addresses. It may be either a suitable hard
4332 + register or a pseudo register that has been allocated such a hard register.
4334 + The difference between an index register and a base register is that the
4335 + index register may be scaled. If an address involves the sum of two
4336 + registers, neither one of them scaled, then either one may be labeled the
4337 + "base" and the other the "index"; but whichever labeling is used must fit
4338 + the machine's constraints of which registers may serve in each capacity.
4339 + The compiler will try both labelings, looking for one that is valid, and
4340 + will reload one or both registers only if neither labeling works. */
4341 +#ifndef REG_OK_STRICT
4342 +#define REGNO_OK_FOR_INDEX_P(regno) \
4343 + ubicom32_regno_ok_for_index_p (regno, 0)
4345 +#define REGNO_OK_FOR_INDEX_P(regno) \
4346 + ubicom32_regno_ok_for_index_p (regno, 1)
4349 +/* Attempt to restrict the register class we need to copy value X intoto the
4350 + would-be register class CLASS. Most things are fine for Ubicom32 but we
4351 + have to restrict certain types of address loads. */
4352 +#define PREFERRED_RELOAD_CLASS(X, CLASS) \
4353 + ubicom32_preferred_reload_class (X, CLASS)
4355 +/* A C expression for the maximum number of consecutive registers of
4356 + class CLASS needed to hold a value of mode MODE. For Ubicom32 this
4357 + is pretty much identical to HARD_REGNO_NREGS. */
4358 +#define CLASS_MAX_NREGS(CLASS, MODE) \
4359 + ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
4361 +/* For Ubicom32 the stack grows downwards when we push a word onto the stack
4362 + - i.e. it moves to a smaller address. */
4363 +#define STACK_GROWS_DOWNWARD 1
4365 +/* Offset from the frame pointer to the first local variable slot to
4367 +#define STARTING_FRAME_OFFSET 0
4369 +/* Offset from the argument pointer register to the first argument's
4371 +#define FIRST_PARM_OFFSET(FNDECL) 0
4373 +/* A C expression whose value is RTL representing the value of the return
4374 + address for the frame COUNT steps up from the current frame, after the
4375 + prologue. FRAMEADDR is the frame pointer of the COUNT frame, or the frame
4376 + pointer of the COUNT - 1 frame if `RETURN_ADDR_IN_PREVIOUS_FRAME' is
4379 + The value of the expression must always be the correct address when COUNT is
4380 + zero, but may be `NULL_RTX' if there is not way to determine the return
4381 + address of other frames. */
4382 +#define RETURN_ADDR_RTX(COUNT, FRAME) \
4383 + ubicom32_return_addr_rtx (COUNT, FRAME)
4385 +/* Register That Address the Stack Frame. */
4387 +/* We don't actually require a frame pointer in most functions with the
4388 + Ubicom32 architecture so we allow it to be eliminated. */
4389 +#define FRAME_POINTER_REQUIRED 0
4391 +/* Macro that defines a table of register pairs used to eliminate unecessary
4392 + registers that point into the stack frame.
4394 + For Ubicom32 we don't generally need an arg pointer of a frame pointer
4395 + so we allow the arg pointer to be replaced by either the frame pointer or
4396 + the stack pointer. We also allow the frame pointer to be replaced by
4397 + the stack pointer. */
4398 +#define ELIMINABLE_REGS \
4400 + {ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
4401 + {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
4402 + {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM} \
4405 +/* Let the compiler know that we want to use the ELIMINABLE_REGS macro
4407 +#define CAN_ELIMINATE(FROM, TO) 1
4409 +/* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It specifies the
4410 + initial difference between the specified pair of registers. This macro must
4411 + be defined if `ELIMINABLE_REGS' is defined. */
4412 +#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
4413 + (OFFSET) = ubicom32_initial_elimination_offset (FROM, TO)
4415 +/* If defined, the maximum amount of space required for outgoing arguments will
4416 + be computed and placed into the variable
4417 + `current_function_outgoing_args_size'. No space will be pushed onto the
4418 + stack for each call; instead, the function prologue should increase the
4419 + stack frame size by this amount.
4421 + Defining both `PUSH_ROUNDING' and `ACCUMULATE_OUTGOING_ARGS' is not
4423 +#define ACCUMULATE_OUTGOING_ARGS 1
4425 +/* Define this macro if functions should assume that stack space has been
4426 + allocated for arguments even when their values are passed in registers.
4428 + The value of this macro is the size, in bytes, of the area reserved for
4429 + arguments passed in registers for the function represented by FNDECL.
4431 + This space can be allocated by the caller, or be a part of the
4432 + machine-dependent stack frame: `OUTGOING_REG_PARM_STACK_SPACE' says
4434 +#define REG_PARM_STACK_SPACE(FNDECL) ubicom32_reg_parm_stack_space(FNDECL)
4436 +/* A C expression that should indicate the number of bytes of its own arguments
4437 + that a function pops on returning, or 0 if the function pops no arguments
4438 + and the caller must therefore pop them all after the function returns.
4440 + FUNDECL is a C variable whose value is a tree node that describes the
4441 + function in question. Normally it is a node of type `FUNCTION_DECL' that
4442 + describes the declaration of the function. From this it is possible to
4443 + obtain the DECL_MACHINE_ATTRIBUTES of the function.
4445 + FUNTYPE is a C variable whose value is a tree node that describes the
4446 + function in question. Normally it is a node of type `FUNCTION_TYPE' that
4447 + describes the data type of the function. From this it is possible to obtain
4448 + the data types of the value and arguments (if known).
4450 + When a call to a library function is being considered, FUNTYPE will contain
4451 + an identifier node for the library function. Thus, if you need to
4452 + distinguish among various library functions, you can do so by their names.
4453 + Note that "library function" in this context means a function used to
4454 + perform arithmetic, whose name is known specially in the compiler and was
4455 + not mentioned in the C code being compiled.
4457 + STACK-SIZE is the number of bytes of arguments passed on the stack. If a
4458 + variable number of bytes is passed, it is zero, and argument popping will
4459 + always be the responsibility of the calling function.
4461 + On the Vax, all functions always pop their arguments, so the definition of
4462 + this macro is STACK-SIZE. On the 68000, using the standard calling
4463 + convention, no functions pop their arguments, so the value of the macro is
4464 + always 0 in this case. But an alternative calling convention is available
4465 + in which functions that take a fixed number of arguments pop them but other
4466 + functions (such as `printf') pop nothing (the caller pops all). When this
4467 + convention is in use, FUNTYPE is examined to determine whether a function
4468 + takes a fixed number of arguments. */
4469 +#define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACK_SIZE) 0
4471 +/* A C expression that controls whether a function argument is passed in a
4472 + register, and which register.
4474 + The arguments are CUM, of type CUMULATIVE_ARGS, which summarizes (in a way
4475 + defined by INIT_CUMULATIVE_ARGS and FUNCTION_ARG_ADVANCE) all of the previous
4476 + arguments so far passed in registers; MODE, the machine mode of the argument;
4477 + TYPE, the data type of the argument as a tree node or 0 if that is not known
4478 + (which happens for C support library functions); and NAMED, which is 1 for an
4479 + ordinary argument and 0 for nameless arguments that correspond to `...' in the
4480 + called function's prototype.
4482 + The value of the expression should either be a `reg' RTX for the hard
4483 + register in which to pass the argument, or zero to pass the argument on the
4486 + For machines like the Vax and 68000, where normally all arguments are
4487 + pushed, zero suffices as a definition.
4489 + The usual way to make the ANSI library `stdarg.h' work on a machine where
4490 + some arguments are usually passed in registers, is to cause nameless
4491 + arguments to be passed on the stack instead. This is done by making
4492 + `FUNCTION_ARG' return 0 whenever NAMED is 0.
4494 + You may use the macro `MUST_PASS_IN_STACK (MODE, TYPE)' in the definition of
4495 + this macro to determine if this argument is of a type that must be passed in
4496 + the stack. If `REG_PARM_STACK_SPACE' is not defined and `FUNCTION_ARG'
4497 + returns non-zero for such an argument, the compiler will abort. If
4498 + `REG_PARM_STACK_SPACE' is defined, the argument will be computed in the
4499 + stack and then loaded into a register. */
4500 +#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
4501 + function_arg (&CUM, MODE, TYPE, NAMED)
4503 +#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \
4504 + function_incoming_arg (&CUM, MODE, TYPE, NAMED)
4506 +/* A C expression for the number of words, at the beginning of an argument,
4507 + must be put in registers. The value must be zero for arguments that are
4508 + passed entirely in registers or that are entirely pushed on the stack.
4510 + On some machines, certain arguments must be passed partially in registers
4511 + and partially in memory. On these machines, typically the first N words of
4512 + arguments are passed in registers, and the rest on the stack. If a
4513 + multi-word argument (a `double' or a structure) crosses that boundary, its
4514 + first few words must be passed in registers and the rest must be pushed.
4515 + This macro tells the compiler when this occurs, and how many of the words
4516 + should go in registers.
4518 + `FUNCTION_ARG' for these arguments should return the first register to be
4519 + used by the caller for this argument; likewise `FUNCTION_INCOMING_ARG', for
4520 + the called function. */
4522 +/* A C expression that indicates when an argument must be passed by reference.
4523 + If nonzero for an argument, a copy of that argument is made in memory and a
4524 + pointer to the argument is passed instead of the argument itself. The
4525 + pointer is passed in whatever way is appropriate for passing a pointer to
4528 + On machines where `REG_PARM_STACK_SPACE' is not defined, a suitable
4529 + definition of this macro might be
4530 + #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
4531 + MUST_PASS_IN_STACK (MODE, TYPE) */
4533 +/* If defined, a C expression that indicates when it is the called function's
4534 + responsibility to make a copy of arguments passed by invisible reference.
4535 + Normally, the caller makes a copy and passes the address of the copy to the
4536 + routine being called. When FUNCTION_ARG_CALLEE_COPIES is defined and is
4537 + nonzero, the caller does not make a copy. Instead, it passes a pointer to
4538 + the "live" value. The called function must not modify this value. If it
4539 + can be determined that the value won't be modified, it need not make a copy;
4540 + otherwise a copy must be made. */
4542 +/* A C type for declaring a variable that is used as the first argument of
4543 + `FUNCTION_ARG' and other related values. For some target machines, the type
4544 + `int' suffices and can hold the number of bytes of argument so far.
4546 + There is no need to record in `CUMULATIVE_ARGS' anything about the arguments
4547 + that have been passed on the stack. The compiler has other variables to
4548 + keep track of that. For target machines on which all arguments are passed
4549 + on the stack, there is no need to store anything in `CUMULATIVE_ARGS';
4550 + however, the data structure must exist and should not be empty, so use
4558 +#define CUMULATIVE_ARGS struct cum_arg
4560 +/* A C statement (sans semicolon) for initializing the variable CUM for the
4561 + state at the beginning of the argument list. The variable has type
4562 + `CUMULATIVE_ARGS'. The value of FNTYPE is the tree node for the data type
4563 + of the function which will receive the args, or 0 if the args are to a
4564 + compiler support library function. The value of INDIRECT is nonzero when
4565 + processing an indirect call, for example a call through a function pointer.
4566 + The value of INDIRECT is zero for a call to an explicitly named function, a
4567 + library function call, or when `INIT_CUMULATIVE_ARGS' is used to find
4568 + arguments for the function being compiled.
4570 + When processing a call to a compiler support library function, LIBNAME
4571 + identifies which one. It is a `symbol_ref' rtx which contains the name of
4572 + the function, as a string. LIBNAME is 0 when an ordinary C function call is
4573 + being processed. Thus, each time this macro is called, either LIBNAME or
4574 + FNTYPE is nonzero, but never both of them at once. */
4576 +#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT, NAMED_ARGS) \
4577 + init_cumulative_args (&(CUM), FNTYPE, LIBNAME, INDIRECT);
4579 +/* A C statement (sans semicolon) to update the summarizer variable CUM to
4580 + advance past an argument in the argument list. The values MODE, TYPE and
4581 + NAMED describe that argument. Once this is done, the variable CUM is
4582 + suitable for analyzing the *following* argument with `FUNCTION_ARG', etc.
4584 + This macro need not do anything if the argument in question was passed on
4585 + the stack. The compiler knows how to track the amount of stack space used
4586 + for arguments without any special help. */
4587 +#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
4588 + ((CUM).nbytes += ((MODE) != BLKmode \
4589 + ? (GET_MODE_SIZE (MODE) + 3) & ~3 \
4590 + : (int_size_in_bytes (TYPE) + 3) & ~3))
4592 +/* For the Ubicom32 we define the upper function argument register here. */
4593 +#define UBICOM32_FUNCTION_ARG_REGS 10
4595 +/* A C expression that is nonzero if REGNO is the number of a hard register in
4596 + which function arguments are sometimes passed. This does *not* include
4597 + implicit arguments such as the static chain and the structure-value address.
4598 + On many machines, no registers can be used for this purpose since all
4599 + function arguments are pushed on the stack. */
4600 +#define FUNCTION_ARG_REGNO_P(N) ((N) < UBICOM32_FUNCTION_ARG_REGS)
4603 +/* How Scalar Function Values are Returned. */
4605 +/* The number of the hard register that is used to return a scalar value from a
4607 +#define RETURN_VALUE_REGNUM 0
4609 +/* A C expression to create an RTX representing the place where a function
4610 + returns a value of data type VALTYPE. VALTYPE is a tree node representing a
4611 + data type. Write `TYPE_MODE (VALTYPE)' to get the machine mode used to
4612 + represent that type. On many machines, only the mode is relevant.
4613 + (Actually, on most machines, scalar values are returned in the same place
4614 + regardless of mode).
4616 + If `PROMOTE_FUNCTION_RETURN' is defined, you must apply the same promotion
4617 + rules specified in `PROMOTE_MODE' if VALTYPE is a scalar type.
4619 + If the precise function being called is known, FUNC is a tree node
4620 + (`FUNCTION_DECL') for it; otherwise, FUNC is a null pointer. This makes it
4621 + possible to use a different value-returning convention for specific
4622 + functions when all their calls are known.
4624 + `FUNCTION_VALUE' is not used for return vales with aggregate data types,
4625 + because these are returned in another way. See `STRUCT_VALUE_REGNUM' and
4626 + related macros, below. */
4627 +#define FUNCTION_VALUE(VALTYPE, FUNC) \
4628 + gen_rtx_REG (TYPE_MODE (VALTYPE), FIRST_DATA_REGNUM)
4630 +/* A C expression to create an RTX representing the place where a library
4631 + function returns a value of mode MODE.
4633 + Note that "library function" in this context means a compiler support
4634 + routine, used to perform arithmetic, whose name is known specially by the
4635 + compiler and was not mentioned in the C code being compiled.
4637 + The definition of `LIBRARY_VALUE' need not be concerned aggregate data
4638 + types, because none of the library functions returns such types. */
4639 +#define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, FIRST_DATA_REGNUM)
4641 +/* A C expression that is nonzero if REGNO is the number of a hard register in
4642 + which the values of called function may come back.
4644 + A register whose use for returning values is limited to serving as the
4645 + second of a pair (for a value of type `double', say) need not be recognized
4646 + by this macro. So for most machines, this definition suffices:
4648 + #define FUNCTION_VALUE_REGNO_P(N) ((N) == RETURN)
4650 + If the machine has register windows, so that the caller and the called
4651 + function use different registers for the return value, this macro should
4652 + recognize only the caller's register numbers. */
4653 +#define FUNCTION_VALUE_REGNO_P(N) ((N) == FIRST_DATA_REGNUM)
4656 +/* How Large Values are Returned. */
4658 +/* A C expression which can inhibit the returning of certain function values in
4659 + registers, based on the type of value. A nonzero value says to return the
4660 + function value in memory, just as large structures are always returned.
4661 + Here TYPE will be a C expression of type `tree', representing the data type
4664 + Note that values of mode `BLKmode' must be explicitly handled by this macro.
4665 + Also, the option `-fpcc-struct-return' takes effect regardless of this
4666 + macro. On most systems, it is possible to leave the macro undefined; this
4667 + causes a default definition to be used, whose value is the constant 1 for
4668 + `BLKmode' values, and 0 otherwise.
4670 + Do not use this macro to indicate that structures and unions should always
4671 + be returned in memory. You should instead use `DEFAULT_PCC_STRUCT_RETURN'
4672 + to indicate this. */
4673 +#define RETURN_IN_MEMORY(TYPE) \
4674 + (int_size_in_bytes (TYPE) > 8 || TYPE_MODE (TYPE) == BLKmode)
4676 +/* Define this macro to be 1 if all structure and union return values must be
4677 + in memory. Since this results in slower code, this should be defined only
4678 + if needed for compatibility with other compilers or with an ABI. If you
4679 + define this macro to be 0, then the conventions used for structure and union
4680 + return values are decided by the `RETURN_IN_MEMORY' macro.
4682 + If not defined, this defaults to the value 1. */
4683 +#define DEFAULT_PCC_STRUCT_RETURN 0
4685 +/* If the structure value address is not passed in a register, define
4686 + `STRUCT_VALUE' as an expression returning an RTX for the place
4687 + where the address is passed. If it returns 0, the address is
4688 + passed as an "invisible" first argument. */
4689 +#define STRUCT_VALUE 0
4691 +/* Define this macro as a C expression that is nonzero if the return
4692 + instruction or the function epilogue ignores the value of the stack pointer;
4693 + in other words, if it is safe to delete an instruction to adjust the stack
4694 + pointer before a return from the function.
4696 + Note that this macro's value is relevant only for functions for which frame
4697 + pointers are maintained. It is never safe to delete a final stack
4698 + adjustment in a function that has no frame pointer, and the compiler knows
4699 + this regardless of `EXIT_IGNORE_STACK'. */
4700 +#define EXIT_IGNORE_STACK 1
4702 +/* A C statement or compound statement to output to FILE some assembler code to
4703 + call the profiling subroutine `mcount'. Before calling, the assembler code
4704 + must load the address of a counter variable into a register where `mcount'
4705 + expects to find the address. The name of this variable is `LP' followed by
4706 + the number LABELNO, so you would generate the name using `LP%d' in a
4709 + The details of how the address should be passed to `mcount' are determined
4710 + by your operating system environment, not by GNU CC. To figure them out,
4711 + compile a small program for profiling using the system's installed C
4712 + compiler and look at the assembler code that results.
4714 + This declaration must be present, but it can be an abort if profiling is
4715 + not implemented. */
4717 +#define FUNCTION_PROFILER(file, labelno) ubicom32_profiler(file, labelno)
4719 +/* A C statement to output, on the stream FILE, assembler code for a block of
4720 + data that contains the constant parts of a trampoline. This code should not
4721 + include a label--the label is taken care of automatically. */
4723 +#define TRAMPOLINE_TEMPLATE(FILE) \
4725 + fprintf (FILE, "\tadd -4,sp\n"); \
4726 + fprintf (FILE, "\t.long 0x0004fffa\n"); \
4727 + fprintf (FILE, "\tmov (0,sp),a0\n"); \
4728 + fprintf (FILE, "\tadd 4,sp\n"); \
4729 + fprintf (FILE, "\tmov (13,a0),a1\n"); \
4730 + fprintf (FILE, "\tmov (17,a0),a0\n"); \
4731 + fprintf (FILE, "\tjmp (a0)\n"); \
4732 + fprintf (FILE, "\t.long 0\n"); \
4733 + fprintf (FILE, "\t.long 0\n"); \
4737 +/* A C expression for the size in bytes of the trampoline, as an integer. */
4738 +#define TRAMPOLINE_SIZE 0x1b
4740 +/* Alignment required for trampolines, in bits.
4742 + If you don't define this macro, the value of `BIGGEST_ALIGNMENT' is used for
4743 + aligning trampolines. */
4744 +#define TRAMPOLINE_ALIGNMENT 32
4746 +/* A C statement to initialize the variable parts of a trampoline. ADDR is an
4747 + RTX for the address of the trampoline; FNADDR is an RTX for the address of
4748 + the nested function; STATIC_CHAIN is an RTX for the static chain value that
4749 + should be passed to the function when it is called. */
4750 +#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
4752 + emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 0x14)), \
4754 + emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 0x18)), \
4758 +/* Ubicom32 supports pre and post increment/decrement addressing. */
4759 +#define HAVE_POST_INCREMENT 1
4760 +#define HAVE_PRE_INCREMENT 1
4761 +#define HAVE_POST_DECREMENT 1
4762 +#define HAVE_PRE_DECREMENT 1
4764 +/* Ubicom32 supports pre and post address side-effects with constants
4765 + other than the size of the memory operand. */
4766 +#define HAVE_PRE_MODIFY_DISP 1
4767 +#define HAVE_POST_MODIFY_DISP 1
4769 +/* A C expression that is 1 if the RTX X is a constant which is a valid
4770 + address. On most machines, this can be defined as `CONSTANT_P (X)',
4771 + but a few machines are more restrictive in which constant addresses
4774 + `CONSTANT_P' accepts integer-values expressions whose values are not
4775 + explicitly known, such as `symbol_ref', `label_ref', and `high'
4776 + expressions and `const' arithmetic expressions, in addition to
4777 + `const_int' and `const_double' expressions. */
4778 +#define CONSTANT_ADDRESS_P(X) \
4779 + (GET_CODE (X) == LABEL_REF \
4780 + || (GET_CODE (X) == CONST \
4781 + && GET_CODE (XEXP (X, 0)) == PLUS \
4782 + && GET_CODE (XEXP (XEXP (X, 0), 0)) == LABEL_REF))
4784 +/* Ubicom32 supports a maximum of 2 registers in a valid memory address.
4785 + One is always an address register while a second, optional, one may be a
4787 +#define MAX_REGS_PER_ADDRESS 2
4789 +/* A C compound statement with a conditional `goto LABEL;' executed if X (an
4790 + RTX) is a legitimate memory address on the target machine for a memory
4791 + operand of mode MODE.
4793 + It usually pays to define several simpler macros to serve as subroutines for
4794 + this one. Otherwise it may be too complicated to understand.
4796 + This macro must exist in two variants: a strict variant and a non-strict
4797 + one. The strict variant is used in the reload pass. It must be defined so
4798 + that any pseudo-register that has not been allocated a hard register is
4799 + considered a memory reference. In contexts where some kind of register is
4800 + required, a pseudo-register with no hard register must be rejected.
4802 + The non-strict variant is used in other passes. It must be defined to
4803 + accept all pseudo-registers in every context where some kind of register is
4806 + Compiler source files that want to use the strict variant of this macro
4807 + define the macro `REG_OK_STRICT'. You should use an `#ifdef REG_OK_STRICT'
4808 + conditional to define the strict variant in that case and the non-strict
4809 + variant otherwise.
4811 + Subroutines to check for acceptable registers for various purposes (one for
4812 + base registers, one for index registers, and so on) are typically among the
4813 + subroutines used to define `GO_IF_LEGITIMATE_ADDRESS'. Then only these
4814 + subroutine macros need have two variants; the higher levels of macros may be
4815 + the same whether strict or not.
4817 + Normally, constant addresses which are the sum of a `symbol_ref' and an
4818 + integer are stored inside a `const' RTX to mark them as constant.
4819 + Therefore, there is no need to recognize such sums specifically as
4820 + legitimate addresses. Normally you would simply recognize any `const' as
4823 + Usually `PRINT_OPERAND_ADDRESS' is not prepared to handle constant sums that
4824 + are not marked with `const'. It assumes that a naked `plus' indicates
4825 + indexing. If so, then you *must* reject such naked constant sums as
4826 + illegitimate addresses, so that none of them will be given to
4827 + `PRINT_OPERAND_ADDRESS'.
4829 + On some machines, whether a symbolic address is legitimate depends on the
4830 + section that the address refers to. On these machines, define the macro
4831 + `ENCODE_SECTION_INFO' to store the information into the `symbol_ref', and
4832 + then check for it here. When you see a `const', you will have to look
4833 + inside it to find the `symbol_ref' in order to determine the section.
4835 + The best way to modify the name string is by adding text to the beginning,
4836 + with suitable punctuation to prevent any ambiguity. Allocate the new name
4837 + in `saveable_obstack'. You will have to modify `ASM_OUTPUT_LABELREF' to
4838 + remove and decode the added text and output the name accordingly, and define
4839 + `STRIP_NAME_ENCODING' to access the original name string.
4841 + You can check the information stored here into the `symbol_ref' in the
4842 + definitions of the macros `GO_IF_LEGITIMATE_ADDRESS' and
4843 + `PRINT_OPERAND_ADDRESS'. */
4844 +/* On the ubicom32, the value in the address register must be
4845 + in the same memory space/segment as the effective address.
4847 + This is problematical for reload since it does not understand
4848 + that base+index != index+base in a memory reference. */
4850 +#ifdef REG_OK_STRICT
4851 +#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
4852 + if (ubicom32_legitimate_address_p (MODE, X, 1)) goto ADDR;
4854 +#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
4855 + if (ubicom32_legitimate_address_p (MODE, X, 0)) goto ADDR;
4858 +/* Try machine-dependent ways of modifying an illegitimate address
4859 + to be legitimate. If we find one, return the new, valid address.
4860 + This macro is used in only one place: `memory_address' in explow.c.
4862 + OLDX is the address as it was before break_out_memory_refs was called.
4863 + In some cases it is useful to look at this to decide what needs to be done.
4865 + MODE and WIN are passed so that this macro can use
4866 + GO_IF_LEGITIMATE_ADDRESS.
4868 + It is always safe for this macro to do nothing. It exists to recognize
4869 + opportunities to optimize the output.
4871 + On RS/6000, first check for the sum of a register with a constant
4872 + integer that is out of range. If so, generate code to add the
4873 + constant with the low-order 16 bits masked to the register and force
4874 + this result into another register (this can be done with `cau').
4875 + Then generate an address of REG+(CONST&0xffff), allowing for the
4876 + possibility of bit 16 being a one.
4878 + Then check for the sum of a register and something not constant, try to
4879 + load the other things into a register and return the sum. */
4881 +#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
4883 + rtx result = ubicom32_legitimize_address ((X), (OLDX), (MODE)); \
4884 + if (result != NULL_RTX) \
4891 +/* Try a machine-dependent way of reloading an illegitimate address
4892 + operand. If we find one, push the reload and jump to WIN. This
4893 + macro is used in only one place: `find_reloads_address' in reload.c. */
4894 +#define LEGITIMIZE_RELOAD_ADDRESS(AD, MODE, OPNUM, TYPE, IND, WIN) \
4896 + rtx new_rtx = ubicom32_legitimize_reload_address ((AD), (MODE), (OPNUM), (int)(TYPE)); \
4904 +/* A C statement or compound statement with a conditional `goto LABEL;'
4905 + executed if memory address X (an RTX) can have different meanings depending
4906 + on the machine mode of the memory reference it is used for or if the address
4907 + is valid for some modes but not others.
4909 + Autoincrement and autodecrement addresses typically have mode-dependent
4910 + effects because the amount of the increment or decrement is the size of the
4911 + operand being addressed. Some machines have other mode-dependent addresses.
4912 + Many RISC machines have no mode-dependent addresses.
4914 + You may assume that ADDR is a valid address for the machine. */
4915 +#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \
4916 + if (ubicom32_mode_dependent_address_p (ADDR)) \
4919 +/* A C expression that is nonzero if X is a legitimate constant for an
4920 + immediate operand on the target machine. You can assume that X
4921 + satisfies `CONSTANT_P', so you need not check this. In fact, `1' is
4922 + a suitable definition for this macro on machines where anything
4923 + `CONSTANT_P' is valid. */
4924 +#define LEGITIMATE_CONSTANT_P(X) \
4925 + ubicom32_legitimate_constant_p ((X))
4927 +/* Moves between registers are pretty-much single instructions for
4928 + Ubicom32. We make this the default "2" that gcc likes. */
4929 +#define REGISTER_MOVE_COST(MODE, FROM, TO) 2
4931 +/* This is a little bit of magic from the S390 port that wins 2% on code
4932 + size when building the Linux kernel! Unfortunately while it wins on
4933 + that size the user-space apps built using FD-PIC don't improve and the
4934 + performance is lower because we put more pressure on the caches. We may
4935 + want this back on some future CPU that has higher cache performance. */
4936 +/* #define IRA_HARD_REGNO_ADD_COST_MULTIPLIER(regno) 0.5 */
4938 +/* Moves between registers and memory are more expensive than between
4939 + registers because we have caches and write buffers that slow things
4941 +#define MEMORY_MOVE_COST(MODE, CLASS, IN) 2
4943 +/* A fall-through branch is very low cost but anything that changes the PC
4944 + incurs a major pipeline hazard. We don't make the full extent of this
4945 + hazard visible because we hope that multiple threads will absorb much
4946 + of the cost and so we don't want a jump being replaced with, say, 7
4948 +#define BRANCH_COST(SPEED_P, PREDICTABLE_P) \
4949 + ((PREDICTABLE_P) ? 1 : 3)
4951 +/* Define this macro as a C expression which is nonzero if accessing less than
4952 + a word of memory (i.e. a `char' or a `short') is no faster than accessing a
4953 + word of memory, i.e., if such access require more than one instruction or if
4954 + there is no difference in cost between byte and (aligned) word loads.
4956 + When this macro is not defined, the compiler will access a field by finding
4957 + the smallest containing object; when it is defined, a fullword load will be
4958 + used if alignment permits. Unless bytes accesses are faster than word
4959 + accesses, using word accesses is preferable since it may eliminate
4960 + subsequent memory access if subsequent accesses occur to other fields in the
4961 + same word of the structure, but to different bytes. */
4962 +#define SLOW_BYTE_ACCESS 0
4964 +/* The number of scalar move insns which should be generated instead of a
4965 + string move insn or a library call. Increasing the value will always make
4966 + code faster, but eventually incurs high cost in increased code size.
4968 + If you don't define this, a reasonable default is used. */
4969 +/* According to expr.c, a value of around 6 should minimize code size. */
4970 +#define MOVE_RATIO(SPEED) 6
4972 +/* We're much better off calling a constant function address with the
4973 + Ubicom32 architecture because we have an opcode for doing so. Don't
4974 + let the compiler extract function addresses as common subexpressions
4975 + into an address register. */
4976 +#define NO_FUNCTION_CSE
4978 +#define SELECT_CC_MODE(OP, X, Y) ubicom32_select_cc_mode (OP, X, Y)
4980 +#define REVERSIBLE_CC_MODE(MODE) 1
4982 +/* Canonicalize a comparison from one we don't have to one we do have. */
4983 +#define CANONICALIZE_COMPARISON(CODE, OP0, OP1) \
4984 + ubicom32_canonicalize_comparison (&(CODE), &(OP0), &(OP1))
4986 +/* Dividing the output into sections. */
4988 +/* A C expression whose value is a string containing the assembler operation
4989 + that should precede instructions and read-only data. Normally `".text"' is
4991 +#define TEXT_SECTION_ASM_OP "\t.section .text"
4993 +/* A C expression whose value is a string containing the assembler operation to
4994 + identify the following data as writable initialized data. Normally
4995 + `".data"' is right. */
4996 +#define DATA_SECTION_ASM_OP "\t.section .data"
4999 +/* If defined, a C expression whose value is a string containing the
5000 + assembler operation to identify the following data as
5001 + uninitialized global data. If not defined, and neither
5002 + `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
5003 + uninitialized global data will be output in the data section if
5004 + `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
5006 +#define BSS_SECTION_ASM_OP "\t.section .bss"
5008 +/* This is how we tell the assembler that a symbol is weak. */
5010 +#define ASM_WEAKEN_LABEL(FILE, NAME) \
5013 + fputs ("\t.weak\t", (FILE)); \
5014 + assemble_name ((FILE), (NAME)); \
5015 + fputc ('\n', (FILE)); \
5019 +/* The Overall Framework of an Assembler File. */
5022 +#define SET_ASM_OP "\t.set\t"
5024 +/* A C string constant describing how to begin a comment in the target
5025 + assembler language. The compiler assumes that the comment will end at the
5026 + end of the line. */
5027 +#define ASM_COMMENT_START ";"
5029 +/* A C string constant for text to be output before each `asm' statement or
5030 + group of consecutive ones. Normally this is `"#APP"', which is a comment
5031 + that has no effect on most assemblers but tells the GNU assembler that it
5032 + must check the lines that follow for all valid assembler constructs. */
5033 +#define ASM_APP_ON "#APP\n"
5035 +/* A C string constant for text to be output after each `asm' statement or
5036 + group of consecutive ones. Normally this is `"#NO_APP"', which tells the
5037 + GNU assembler to resume making the time-saving assumptions that are valid
5038 + for ordinary compiler output. */
5039 +#define ASM_APP_OFF "#NO_APP\n"
5041 +/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a separate,
5042 + explicit argument. If you define this macro, it is used in place of
5043 + `ASM_OUTPUT_BSS', and gives you more flexibility in handling the required
5044 + alignment of the variable. The alignment is specified as the number of
5047 + Try to use function `asm_output_aligned_bss' defined in file `varasm.c' when
5048 + defining this macro. */
5049 +#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
5050 + asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
5052 +/* A C expression to assign to OUTVAR (which is a variable of type `char *') a
5053 + newly allocated string made from the string NAME and the number NUMBER, with
5054 + some suitable punctuation added. Use `alloca' to get space for the string.
5056 + The string will be used as an argument to `ASM_OUTPUT_LABELREF' to produce
5057 + an assembler label for an internal static variable whose name is NAME.
5058 + Therefore, the string must be such as to result in valid assembler code.
5059 + The argument NUMBER is different each time this macro is executed; it
5060 + prevents conflicts between similarly-named internal static variables in
5063 + Ideally this string should not be a valid C identifier, to prevent any
5064 + conflict with the user's own symbols. Most assemblers allow periods or
5065 + percent signs in assembler symbols; putting at least one of these between
5066 + the name and the number will suffice. */
5067 +#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
5068 + ((OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
5069 + sprintf ((OUTPUT), "%s___%d", (NAME), (LABELNO)))
5071 +#define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
5072 + sprintf (STRING, "*.%s%ld", PREFIX, (long)(NUM))
5073 +/* A C statement to store into the string STRING a label whose name
5074 + is made from the string PREFIX and the number NUM.
5076 + This string, when output subsequently by `assemble_name', should
5077 + produce the output that `(*targetm.asm_out.internal_label)' would produce
5078 + with the same PREFIX and NUM.
5080 + If the string begins with `*', then `assemble_name' will output
5081 + the rest of the string unchanged. It is often convenient for
5082 + `ASM_GENERATE_INTERNAL_LABEL' to use `*' in this way. If the
5083 + string doesn't start with `*', then `ASM_OUTPUT_LABELREF' gets to
5084 + output the string, and may change it. (Of course,
5085 + `ASM_OUTPUT_LABELREF' is also part of your machine description, so
5086 + you should know what it does on your machine.) */
5088 +/* This says how to output assembler code to declare an
5089 + uninitialized external linkage data object. Under SVR4,
5090 + the linker seems to want the alignment of data objects
5091 + to depend on their types. We do exactly that here. */
5093 +#define COMMON_ASM_OP "\t.comm\t"
5095 +#undef ASM_OUTPUT_COMMON
5096 +#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
5099 + fprintf ((FILE), "%s", COMMON_ASM_OP); \
5100 + assemble_name ((FILE), (NAME)); \
5101 + fprintf ((FILE), ", %u\n", (SIZE)); \
5105 +/* This says how to output assembler code to declare an
5106 + uninitialized internal linkage data object. Under SVR4,
5107 + the linker seems to want the alignment of data objects
5108 + to depend on their types. We do exactly that here. */
5109 +#define LOCAL_ASM_OP "\t.lcomm\t"
5111 +#undef ASM_OUTPUT_LOCAL
5112 +#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
5115 + fprintf ((FILE), "%s", LOCAL_ASM_OP); \
5116 + assemble_name ((FILE), (NAME)); \
5117 + fprintf ((FILE), ", %u\n", (SIZE)); \
5121 +/* Globalizing directive for a label. */
5122 +#define GLOBAL_ASM_OP ".global\t"
5124 +/* Output the operand of an instruction. */
5125 +#define PRINT_OPERAND(FILE, X, CODE) \
5126 + ubicom32_print_operand(FILE, X, CODE)
5128 +/* Output the address of an operand. */
5129 +#define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
5130 + ubicom32_print_operand_address (FILE, ADDR)
5132 +/* A C expression to output to STREAM some assembler code which will push hard
5133 + register number REGNO onto the stack. The code need not be optimal, since
5134 + this macro is used only when profiling. */
5135 +#define ASM_OUTPUT_REG_PUSH(FILE, REGNO)
5137 +/* A C expression to output to STREAM some assembler code which will pop hard
5138 + register number REGNO off of the stack. The code need not be optimal, since
5139 + this macro is used only when profiling. */
5140 +#define ASM_OUTPUT_REG_POP(FILE, REGNO)
5142 +/* This macro should be provided on machines where the addresses in a dispatch
5143 + table are relative to the table's own address.
5145 + The definition should be a C statement to output to the stdio stream STREAM
5146 + an assembler pseudo-instruction to generate a difference between two labels.
5147 + VALUE and REL are the numbers of two internal labels. The definitions of
5148 + these labels are output using `ASM_OUTPUT_INTERNAL_LABEL', and they must be
5149 + printed in the same way here. For example,
5151 + fprintf (STREAM, "\t.word L%d-L%d\n", VALUE, REL) */
5152 +#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
5153 + fprintf (FILE, "\t%s .L%d-.L%d\n", ".long", VALUE, REL)
5155 +/* This macro should be provided on machines where the addresses in a dispatch
5156 + table are absolute.
5158 + The definition should be a C statement to output to the stdio stream STREAM
5159 + an assembler pseudo-instruction to generate a reference to a label. VALUE
5160 + is the number of an internal label whose definition is output using
5161 + `ASM_OUTPUT_INTERNAL_LABEL'. For example,
5163 + fprintf (STREAM, "\t.word L%d\n", VALUE) */
5164 +#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \
5165 + fprintf (STREAM, "\t.word .L%d\n", VALUE)
5167 +/* Switch into a generic section. */
5168 +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
5170 +/* Assembler Commands for Alignment. */
5172 +#define ASM_OUTPUT_SKIP(STREAM, N) fprintf (STREAM, "\t.skip %d,0\n", N)
5173 +/* A C statement to output to the stdio stream STREAM an assembler
5174 + instruction to advance the location counter by NBYTES bytes.
5175 + Those bytes should be zero when loaded. NBYTES will be a C
5176 + expression of type `int'. */
5178 +/* A C statement to output to the stdio stream STREAM an assembler command to
5179 + advance the location counter to a multiple of 2 to the POWER bytes. POWER
5180 + will be a C expression of type `int'. */
5181 +#define ASM_OUTPUT_ALIGN(FILE, LOG) \
5183 + fprintf (FILE, "\t.align %d\n", (LOG))
5185 +/* A C expression that returns the DBX register number for the compiler
5186 + register number REGNO. In simple cases, the value of this expression may be
5187 + REGNO itself. But sometimes there are some registers that the compiler
5188 + knows about and DBX does not, or vice versa. In such cases, some register
5189 + may need to have one number in the compiler and another for DBX.
5191 + If two registers have consecutive numbers inside GNU CC, and they can be
5192 + used as a pair to hold a multiword value, then they *must* have consecutive
5193 + numbers after renumbering with `DBX_REGISTER_NUMBER'. Otherwise, debuggers
5194 + will be unable to access such a pair, because they expect register pairs to
5195 + be consecutive in their own numbering scheme.
5197 + If you find yourself defining `DBX_REGISTER_NUMBER' in way that does not
5198 + preserve register pairs, then what you must do instead is redefine the
5199 + actual register numbering scheme.
5201 + This declaration is required. */
5202 +#define DBX_REGISTER_NUMBER(REGNO) REGNO
5204 +/* A C expression that returns the integer offset value for an automatic
5205 + variable having address X (an RTL expression). The default computation
5206 + assumes that X is based on the frame-pointer and gives the offset from the
5207 + frame-pointer. This is required for targets that produce debugging output
5208 + for DBX or COFF-style debugging output for SDB and allow the frame-pointer
5209 + to be eliminated when the `-g' options is used. */
5210 +#define DEBUGGER_AUTO_OFFSET(X) \
5211 + ((GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0) \
5212 + + (frame_pointer_needed \
5213 + ? 0 : -initial_elimination_offset (FRAME_POINTER_REGNUM, \
5214 + STACK_POINTER_REGNUM)))
5216 +/* A C expression that returns the integer offset value for an argument having
5217 + address X (an RTL expression). The nominal offset is OFFSET. */
5218 +#define DEBUGGER_ARG_OFFSET(OFFSET, X) \
5219 + ((GET_CODE (X) == PLUS ? OFFSET : 0) \
5220 + + (frame_pointer_needed \
5221 + ? 0 : -initial_elimination_offset (ARG_POINTER_REGNUM, \
5222 + STACK_POINTER_REGNUM)))
5224 +/* A C expression that returns the type of debugging output GNU CC produces
5225 + when the user specifies `-g' or `-ggdb'. Define this if you have arranged
5226 + for GNU CC to support more than one format of debugging output. Currently,
5227 + the allowable values are `DBX_DEBUG', `SDB_DEBUG', `DWARF_DEBUG',
5228 + `DWARF2_DEBUG', and `XCOFF_DEBUG'.
5230 + The value of this macro only affects the default debugging output; the user
5231 + can always get a specific type of output by using `-gstabs', `-gcoff',
5232 + `-gdwarf-1', `-gdwarf-2', or `-gxcoff'.
5234 + Defined in svr4.h.
5236 +#undef PREFERRED_DEBUGGING_TYPE
5237 +#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
5239 +/* Define this macro if GNU CC should produce dwarf version 2 format debugging
5240 + output in response to the `-g' option.
5242 + To support optional call frame debugging information, you must also define
5243 + `INCOMING_RETURN_ADDR_RTX' and either set `RTX_FRAME_RELATED_P' on the
5244 + prologue insns if you use RTL for the prologue, or call `dwarf2out_def_cfa'
5245 + and `dwarf2out_reg_save' as appropriate from `FUNCTION_PROLOGUE' if you
5248 + Defined in svr4.h. */
5250 +#define DWARF2_DEBUGGING_INFO 1
5251 +/*#define DWARF2_UNWIND_INFO 1*/
5252 +#define DWARF2_UNWIND_INFO 0
5253 +#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LINK_REGNO)
5254 +#define INCOMING_FRAME_SP_OFFSET 0
5255 +#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LINK_REGNO)
5256 +#define EH_RETURN_FIRST 9
5257 +#define EH_RETURN_DATA_REGNO(N) ((N) < 2 ? (N) + EH_RETURN_FIRST : INVALID_REGNUM)
5259 +/* The EH_RETURN_STACKADJ_RTX macro returns RTL which describes the
5260 + location used to store the amount to ajdust the stack. This is
5261 + usually a registers that is available from end of the function's body
5262 + to the end of the epilogue. Thus, this cannot be a register used as a
5263 + temporary by the epilogue.
5265 + This must be an integer register. */
5266 +#define EH_RETURN_STACKADJ_REGNO 11
5267 +#define EH_RETURN_STACKADJ_RTX \
5268 + gen_rtx_REG (Pmode, EH_RETURN_STACKADJ_REGNO)
5270 +/* The EH_RETURN_HANDLER_RTX macro returns RTL which describes the
5271 + location used to store the address the processor should jump to
5272 + catch exception. This is usually a registers that is available from
5273 + end of the function's body to the end of the epilogue. Thus, this
5274 + cannot be a register used as a temporary by the epilogue.
5276 + This must be an address register. */
5277 +#define EH_RETURN_HANDLER_REGNO 18
5278 +#define EH_RETURN_HANDLER_RTX \
5279 + gen_rtx_REG (Pmode, EH_RETURN_HANDLER_REGNO)
5281 +/* #define DWARF2_DEBUGGING_INFO */
5283 +/* Define this macro if GNU CC should produce dwarf version 2-style
5284 + line numbers. This usually requires extending the assembler to
5285 + support them, and #defining DWARF2_LINE_MIN_INSN_LENGTH in the
5286 + assembler configuration header files. */
5287 +/* #define DWARF2_ASM_LINE_DEBUG_INFO 1 */
5290 +/* An alias for a machine mode name. This is the machine mode that elements
5291 + of a jump-table have. */
5292 +#define CASE_VECTOR_MODE Pmode
5294 +/* Smallest number of different values for which it is best to use a
5295 + jump-table instead of a tree of conditional branches. For most Ubicom32
5296 + targets this is quite small, but for the v1 architecture implementations
5297 + we had very little data memory and so heavily prefer the tree approach
5298 + rather than the jump tables. */
5299 +#define CASE_VALUES_THRESHOLD ubicom32_case_values_threshold
5301 +/* Register operations within the Ubicom32 architecture always operate on
5302 + the whole register word and not just the sub-bits required for the opcode
5304 +#define WORD_REGISTER_OPERATIONS
5306 +/* The maximum number of bytes that a single instruction can move quickly from
5307 + memory to memory. */
5310 +/* A C expression that is nonzero if on this machine the number of bits
5311 + actually used for the count of a shift operation is equal to the number of
5312 + bits needed to represent the size of the object being shifted. When this
5313 + macro is non-zero, the compiler will assume that it is safe to omit a
5314 + sign-extend, zero-extend, and certain bitwise `and' instructions that
5315 + truncates the count of a shift operation. On machines that have
5316 + instructions that act on bitfields at variable positions, which may include
5317 + `bit test' instructions, a nonzero `SHIFT_COUNT_TRUNCATED' also enables
5318 + deletion of truncations of the values that serve as arguments to bitfield
5321 + If both types of instructions truncate the count (for shifts) and position
5322 + (for bitfield operations), or if no variable-position bitfield instructions
5323 + exist, you should define this macro.
5325 + However, on some machines, such as the 80386 and the 680x0, truncation only
5326 + applies to shift operations and not the (real or pretended) bitfield
5327 + operations. Define `SHIFT_COUNT_TRUNCATED' to be zero on such machines.
5328 + Instead, add patterns to the `md' file that include the implied truncation
5329 + of the shift instructions.
5331 + You need not define this macro if it would always have the value of zero. */
5332 +#define SHIFT_COUNT_TRUNCATED 1
5334 +/* A C expression which is nonzero if on this machine it is safe to "convert"
5335 + an integer of INPREC bits to one of OUTPREC bits (where OUTPREC is smaller
5336 + than INPREC) by merely operating on it as if it had only OUTPREC bits.
5338 + On many machines, this expression can be 1.
5340 + When `TRULY_NOOP_TRUNCATION' returns 1 for a pair of sizes for modes for
5341 + which `MODES_TIEABLE_P' is 0, suboptimal code can result. If this is the
5342 + case, making `TRULY_NOOP_TRUNCATION' return 0 in such cases may improve
5344 +#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
5346 +/* A C string constant that tells the GNU CC driver program options to pass
5347 + to the assembler. It can also specify how to translate options you give
5348 + to GNU CC into options for GNU CC to pass to the assembler. See the
5349 + file `sun3.h' for an example of this.
5351 + Defined in svr4.h. */
5354 + "%{march=*:-m%*} %{!march=*:-mubicom32v4} %{mfdpic:-mfdpic}"
5356 +#define LINK_SPEC "\
5359 +%{mfdpic:-melf32ubicom32fdpic -z text} \
5360 +%{static:-dn -Bstatic} \
5361 +%{shared:-G -Bdynamic} \
5362 +%{symbolic:-Bsymbolic} \
5367 +#undef STARTFILE_SPEC
5368 +#undef ENDFILE_SPEC
5370 +/* The svr4.h LIB_SPEC with -leval and --*group tacked on */
5373 +#define LIB_SPEC "%{!shared:%{!symbolic:--start-group -lc -leval -lgcc --end-group}}"
5375 +#undef HAVE_GAS_SHF_MERGE
5376 +#define HAVE_GAS_SHF_MERGE 0
5378 +#define HANDLE_SYSV_PRAGMA 1
5379 +#undef HANDLE_PRAGMA_PACK
5381 +typedef void (*ubicom32_func_ptr) (void);
5383 +/* Define builtins for selected special-purpose instructions. */
5384 +enum ubicom32_builtins
5386 + UBICOM32_BUILTIN_UBICOM32_SWAPB_2,
5387 + UBICOM32_BUILTIN_UBICOM32_SWAPB_4
5390 +extern rtx ubicom32_compare_op0;
5391 +extern rtx ubicom32_compare_op1;
5393 +#define TYPE_ASM_OP "\t.type\t"
5394 +#define TYPE_OPERAND_FMT "@%s"
5396 +#ifndef ASM_DECLARE_RESULT
5397 +#define ASM_DECLARE_RESULT(FILE, RESULT)
5400 +/* These macros generate the special .type and .size directives which
5401 + are used to set the corresponding fields of the linker symbol table
5402 + entries in an ELF object file under SVR4. These macros also output
5403 + the starting labels for the relevant functions/objects. */
5405 +/* Write the extra assembler code needed to declare a function properly.
5406 + Some svr4 assemblers need to also have something extra said about the
5407 + function's return value. We allow for that here. */
5409 +#ifndef ASM_DECLARE_FUNCTION_NAME
5410 +#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
5413 + ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
5414 + ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
5415 + ASM_OUTPUT_LABEL (FILE, NAME); \
5420 +++ b/gcc/config/ubicom32/ubicom32.md
5422 +; GCC machine description for Ubicom32
5424 +; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software
5426 +; Contributed by Ubicom, Inc.
5428 +; This file is part of GCC.
5430 +; GCC is free software; you can redistribute it and/or modify
5431 +; it under the terms of the GNU General Public License as published by
5432 +; the Free Software Foundation; either version 3, or (at your option)
5433 +; any later version.
5435 +; GCC is distributed in the hope that it will be useful,
5436 +; but WITHOUT ANY WARRANTY; without even the implied warranty of
5437 +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5438 +; GNU General Public License for more details.
5440 +; You should have received a copy of the GNU General Public License
5441 +; along with GCC; see the file COPYING3. If not see
5442 +; <http://www.gnu.org/licenses/>.
5445 + [(AUX_DATA_REGNO 15)
5448 + (ACC0_HI_REGNO 24)
5449 + (ACC1_HI_REGNO 26)
5453 + [(UNSPEC_FDPIC_GOT 0)
5454 + (UNSPEC_FDPIC_GOT_FUNCDESC 1)])
5457 + [(UNSPEC_VOLATILE_LOAD_FDPIC_FUNCDESC 0)])
5459 +;; Types of instructions (for scheduling purposes).
5461 +(define_attr "type" "mul,addr,other"
5462 + (const_string "other"))
5464 +; Define instruction scheduling characteristics. We can only issue
5465 +; one instruction per clock so we don't need to define CPU units.
5467 +(define_automaton "ubicom32")
5469 +(define_cpu_unit "i_pipeline" "ubicom32");
5471 +; We have a 4 cycle hazard associated with address calculations which
5472 +; seems rather tricky to avoid so we go with a defensive assumption
5473 +; that almost anything can be used to generate addresses.
5475 +;(define_insn_reservation "ubicom32_other" 4
5476 +; (eq_attr "type" "other")
5479 +; Some moves don't generate hazards.
5481 +;(define_insn_reservation "ubicom32_addr" 1
5482 +; (eq_attr "type" "addr")
5485 +; We need 3 cycles between a multiply instruction and any use of the
5486 +; matching accumulator register(s).
5488 +(define_insn_reservation "ubicom32_mul" 4
5489 + (eq_attr "type" "mul")
5492 +(define_attr "length" ""
5495 +(include "predicates.md")
5496 +(include "constraints.md")
5498 +; 8-bit move with no change to the flags reg.
5500 +(define_insn "movqi"
5501 + [(set (match_operand:QI 0 "nonimmediate_operand" "=rm")
5502 + (match_operand:QI 1 "ubicom32_move_operand" "g"))]
5504 + "move.1\\t%0, %1")
5506 +; Combiner-generated 8-bit move with the zero flag set accordingly.
5508 +(define_insn "movqi_ccszn"
5509 + [(set (reg CC_REGNO)
5510 + (compare (match_operand:QI 0 "nonimmediate_operand" "rm")
5512 + (set (match_operand:QI 1 "nonimmediate_operand" "=rm")
5514 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
5517 +; Combine isn't very good at merging some types of operations so we
5518 +; have to make do with a peephole. It's not as effective but it's better
5519 +; than doing nothing.
5522 + [(set (match_operand:QI 0 "nonimmediate_operand" "")
5523 + (match_operand:QI 1 "nonimmediate_operand" ""))
5524 + (set (match_operand 2 "ubicom32_cc_register_operand" "")
5525 + (match_operator 3 "ubicom32_compare_operator"
5528 + "(GET_MODE (operands[2]) == CCSZNmode
5529 + || GET_MODE (operands[2]) == CCSZmode)"
5531 + [(set (match_dup 2)
5535 + (set (match_dup 0)
5539 +; Combine isn't very good at merging some types of operations so we
5540 +; have to make do with a peephole. It's not as effective but it's better
5541 +; than doing nothing.
5544 + [(set (match_operand:QI 0 "nonimmediate_operand" "")
5545 + (match_operand:QI 1 "nonimmediate_operand" ""))
5546 + (set (match_operand 2 "ubicom32_cc_register_operand" "")
5547 + (match_operator 3 "ubicom32_compare_operator"
5550 + "(GET_MODE (operands[2]) == CCSZNmode
5551 + || GET_MODE (operands[2]) == CCSZmode)"
5553 + [(set (match_dup 2)
5557 + (set (match_dup 0)
5561 +; 16-bit move with no change to the flags reg.
5563 +(define_insn "movhi"
5564 + [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
5565 + (match_operand:HI 1 "ubicom32_move_operand" "g"))]
5569 + if (CONST_INT_P (operands[1]))
5570 + return \"movei\\t%0, %1\";
5572 + return \"move.2\\t%0, %1\";
5575 +; Combiner-generated 16-bit move with the zero flag set accordingly.
5577 +(define_insn "movhi_ccszn"
5578 + [(set (reg CC_REGNO)
5579 + (compare (match_operand:HI 0 "nonimmediate_operand" "rm")
5581 + (set (match_operand:HI 1 "nonimmediate_operand" "=rm")
5583 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
5586 +; Combine isn't very good at merging some types of operations so we
5587 +; have to make do with a peephole. It's not as effective but it's better
5588 +; than doing nothing.
5591 + [(set (match_operand:HI 0 "nonimmediate_operand" "")
5592 + (match_operand:HI 1 "nonimmediate_operand" ""))
5593 + (set (match_operand 2 "ubicom32_cc_register_operand" "")
5594 + (match_operator 3 "ubicom32_compare_operator"
5597 + "(GET_MODE (operands[2]) == CCSZNmode
5598 + || GET_MODE (operands[2]) == CCSZmode)"
5600 + [(set (match_dup 2)
5604 + (set (match_dup 0)
5608 +; Combine isn't very good at merging some types of operations so we
5609 +; have to make do with a peephole. It's not as effective but it's better
5610 +; than doing nothing.
5613 + [(set (match_operand:HI 0 "nonimmediate_operand" "")
5614 + (match_operand:HI 1 "nonimmediate_operand" ""))
5615 + (set (match_operand 2 "ubicom32_cc_register_operand" "")
5616 + (match_operator 3 "ubicom32_compare_operator"
5619 + "(GET_MODE (operands[2]) == CCSZNmode
5620 + || GET_MODE (operands[2]) == CCSZmode)"
5622 + [(set (match_dup 2)
5626 + (set (match_dup 0)
5630 +; 32-bit move with no change to the flags reg.
5632 +(define_expand "movsi"
5633 + [(set (match_operand:SI 0 "nonimmediate_operand" "")
5634 + (match_operand:SI 1 "general_operand" ""))]
5637 + /* Convert any complexities in operand 1 into something that can just
5638 + fall into the default expander code. */
5639 + ubicom32_expand_movsi (operands);
5642 +(define_insn "movsi_high"
5643 + [(set (match_operand:SI 0 "ubicom32_address_register_operand" "=a")
5644 + (high:SI (match_operand:SI 1 "ubicom32_symbolic_address_operand" "s")))]
5646 + "moveai\\t%0, #%%hi(%E1)")
5648 +(define_insn "movsi_lo_sum"
5649 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5650 + (lo_sum:SI (match_operand:SI 1 "ubicom32_address_register_operand" "a")
5651 + (match_operand:SI 2 "immediate_operand" "s")))]
5653 + "lea.1\\t%0, %%lo(%E2)(%1)")
5655 +(define_insn "movsi_internal"
5656 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5657 + (match_operand:SI 1 "ubicom32_move_operand" "rmnY"))]
5661 + if (CONST_INT_P (operands[1]))
5663 + ubicom32_emit_move_const_int (operands[0], operands[1]);
5667 + if (GET_CODE (operands[1]) == CONST_DOUBLE)
5669 + HOST_WIDE_INT i = CONST_DOUBLE_LOW (operands[1]);
5671 + ubicom32_emit_move_const_int (operands[0], GEN_INT (i));
5675 + if (ubicom32_address_register_operand (operands[0], VOIDmode)
5676 + && register_operand (operands[1], VOIDmode))
5678 + if (ubicom32_address_register_operand (operands[1], VOIDmode))
5679 + return \"lea.1\\t%0, 0(%1)\";
5681 + /* Use movea here to utilize the hazard bypass in the >= v4 ISA. */
5683 + return \"movea\\t%0, %1\";
5685 + return \"move.4\\t%0, %1\";
5688 + return \"move.4\\t%0, %1\";
5691 +; If we're not dependent on the state of the condition codes we can construct
5692 +; constants of value 2^n by using a bset.
5695 + [(set (match_operand:SI 0 "nonimmediate_operand" "")
5696 + (match_operand:SI 1 "const_int_operand" ""))]
5697 + "(exact_log2 (INTVAL (operands[1])) > 14
5698 + && peep2_regno_dead_p (0, CC_REGNO))"
5700 + [(set (match_dup 0)
5701 + (ior:SI (const_int 0)
5703 + (clobber (reg:CC CC_REGNO))])]
5706 +; If we're not dependent on the state of the condition codes we can construct
5707 +; constants of value ~(2^n) by using a bclr.
5710 + [(set (match_operand:SI 0 "nonimmediate_operand" "")
5711 + (match_operand:SI 1 "const_int_operand" ""))]
5712 + "(exact_log2 (~INTVAL (operands[1])) > 14
5713 + && peep2_regno_dead_p (0, CC_REGNO))"
5715 + [(set (match_dup 0)
5716 + (and:SI (const_int -1)
5718 + (clobber (reg:CC CC_REGNO))])]
5721 +; For 32-bit constants that have bits 0 through 24 and bit 31 set the same
5722 +; we can use swapb.4!
5725 + [(set (match_operand:SI 0 "nonimmediate_operand" "")
5726 + (match_operand:SI 1 "const_int_operand" ""))]
5728 + && (INTVAL (operands[1]) & 0xffffffff) != 0xffffffff
5729 + && (INTVAL (operands[1]) & 0xffffffff) != 0
5730 + && ((INTVAL (operands[1]) & 0x80ffffff) == 0
5731 + || (INTVAL (operands[1]) & 0x80ffffff) == 0x80ffffff))"
5732 + [(set (match_dup 0)
5733 + (bswap:SI (match_dup 2)))]
5735 + operands[2] = GEN_INT (INTVAL (operands[1]) >> 24);
5738 +; If this is a write of a constant to memory look to see if we can usefully
5739 +; transform this into 2 smaller writes.
5742 + [(set (match_operand:SI 0 "memory_operand" "")
5743 + (match_operand:SI 1 "const_int_operand" ""))]
5744 + "! satisfies_constraint_I (operands[1])
5745 + && ubicom32_legitimate_address_p (HImode, plus_constant (XEXP (operands[0], 0), 2), 1)"
5746 + [(set (match_dup 4) (match_dup 2))
5747 + (set (match_dup 5) (match_dup 3))]
5749 + rtx low_hword_addr;
5751 + operands[2] = gen_highpart_mode (HImode, SImode, operands[1]);
5752 + operands[3] = gen_lowpart (HImode, operands[1]);
5754 + operands[4] = gen_rtx_MEM (HImode, XEXP (operands[0], 0));
5755 + MEM_COPY_ATTRIBUTES (operands[4], operands[0]);
5757 + low_hword_addr = plus_constant (XEXP (operands[0], 0), 2);
5758 + operands[5] = gen_rtx_MEM (HImode, low_hword_addr);
5759 + MEM_COPY_ATTRIBUTES (operands[5], operands[0]);
5762 +; If we're writing memory and we've not found a better way to do this then
5763 +; try loading into a D register and then copying to memory. This will
5764 +; perform the fewest possible memory read/writes.
5767 + [(match_scratch:SI 2 "d")
5768 + (set (match_operand:SI 0 "memory_operand" "")
5769 + (match_operand:SI 1 "const_int_operand" ""))]
5770 + "! satisfies_constraint_I (operands[1])"
5771 + [(set (match_dup 2) (match_dup 1))
5772 + (set (match_dup 0) (match_dup 2))]
5775 +; If we're not dependent on the state of the condition codes we can construct
5776 +; constants of value (2^n - 1) by using an lsr.4.
5779 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "")
5780 + (match_operand:SI 1 "const_int_operand" ""))]
5781 + "(exact_log2 (INTVAL (operands[1]) + 1) > 14
5782 + && peep2_regno_dead_p (0, CC_REGNO))"
5784 + [(set (match_dup 0)
5785 + (lshiftrt:SI (const_int -1)
5787 + (clobber (reg:CC CC_REGNO))])]
5789 + operands[2] = GEN_INT (32 - exact_log2 (INTVAL (operands[1]) + 1));
5792 +; If we're not dependent on the state of the condition codes we can construct
5793 +; constants of value (2^n - 1) by using an lsr.4.
5796 + [(match_scratch:SI 2 "d")
5797 + (set (match_operand:SI 0 "nonimmediate_operand" "")
5798 + (match_operand:SI 1 "const_int_operand" ""))]
5799 + "(exact_log2 (INTVAL (operands[1]) + 1) > 14
5800 + && peep2_regno_dead_p (0, CC_REGNO))"
5802 + [(set (match_dup 2)
5803 + (lshiftrt:SI (const_int -1)
5805 + (clobber (reg:CC CC_REGNO))])
5806 + (set (match_dup 0)
5809 + operands[3] = GEN_INT (32 - exact_log2 (INTVAL (operands[1]) + 1));
5812 +; If we're not dependent on the state of the condition codes we can construct
5813 +; some other constants by using an lsl.4 to shift 7 bits left by some
5817 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "")
5818 + (match_operand:SI 1 "const_int_operand" ""))]
5819 + "(ubicom32_shiftable_const_int (INTVAL (operands[1]))
5820 + && peep2_regno_dead_p (0, CC_REGNO))"
5822 + [(set (match_dup 0)
5823 + (ashift:SI (match_dup 2)
5825 + (clobber (reg:CC CC_REGNO))])]
5827 + int shift = ubicom32_shiftable_const_int (INTVAL (operands[1]));
5828 + operands[2] = GEN_INT (INTVAL (operands[1]) >> shift);
5829 + operands[3] = GEN_INT (shift);
5832 +; If we're not dependent on the state of the condition codes we can construct
5833 +; some other constants by using an lsl.4 to shift 7 bits left by some
5837 + [(match_scratch:SI 2 "d")
5838 + (set (match_operand:SI 0 "nonimmediate_operand" "")
5839 + (match_operand:SI 1 "const_int_operand" ""))]
5840 + "(ubicom32_shiftable_const_int (INTVAL (operands[1]))
5841 + && peep2_regno_dead_p (0, CC_REGNO))"
5843 + [(set (match_dup 2)
5844 + (ashift:SI (match_dup 3)
5846 + (clobber (reg:CC CC_REGNO))])
5847 + (set (match_dup 0)
5850 + int shift = ubicom32_shiftable_const_int (INTVAL (operands[1]));
5851 + operands[3] = GEN_INT (INTVAL (operands[1]) >> shift);
5852 + operands[4] = GEN_INT (shift);
5855 +; For some 16-bit unsigned constants that have bit 15 set we can use
5858 +; Note that the movsi code emits the same sequence but by using a peephole2
5859 +; we split the pattern early enough to allow instruction scheduling to
5863 + [(set (match_operand:SI 0 "register_operand" "")
5864 + (match_operand:SI 1 "const_int_operand" ""))]
5866 + && (INTVAL (operands[1]) & 0xffff80ff) == 0x80ff)"
5867 + [(set (match_dup 0)
5868 + (zero_extend:SI (bswap:HI (match_dup 2))))]
5870 + HOST_WIDE_INT i = INTVAL (operands[1]) >> 8;
5873 + operands[2] = GEN_INT (i);
5876 +; In general for a 16-bit unsigned constant that has bit 15 set
5877 +; then we need a movei/move.2 pair unless we can represent it
5878 +; via just a move.2.
5881 + [(set (match_operand:SI 0 "register_operand" "")
5882 + (match_operand:SI 1 "const_int_operand" ""))]
5883 + "(INTVAL (operands[1]) & 0xffff8000) == 0x8000
5884 + && (INTVAL (operands[1]) & 0xffff) < 0xff80"
5885 + [(set (match_dup 2)
5887 + (set (match_dup 0)
5888 + (zero_extend:SI (match_dup 2)))]
5890 + operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));
5893 +; If we're not dependent on the state of the condition codes we can construct
5894 +; 32-bit constants that have bits 16 through 31 set to arbitrary values
5895 +; and have bits 0 through 15 set to something representable as a default
5896 +; source-1 immediate - we use movei/shmrg.2
5899 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "")
5900 + (match_operand:SI 1 "const_int_operand" ""))]
5901 + "(((INTVAL (operands[1]) >= 0x8000
5902 + && INTVAL (operands[1]) < 0xff80)
5903 + || INTVAL (operands[1]) >= 0x10000
5904 + || INTVAL (operands[1]) < -0x8000)
5905 + && ((INTVAL (operands[1]) & 0xffff) >= 0xff80
5906 + || (INTVAL (operands[1]) & 0xffff) < 0x80)
5907 + && peep2_regno_dead_p (0, CC_REGNO))"
5908 + [(set (match_dup 0)
5911 + [(set (match_dup 0)
5913 + (ashift:SI (match_dup 0)
5917 + (clobber (reg:CC CC_REGNO))])]
5919 + operands[2] = gen_highpart_mode (HImode, SImode, operands[1]);
5920 + operands[3] = gen_lowpart (HImode, operands[1]);
5923 +; Exactly the same as the peephole2 preceding except that this targets a
5924 +; general register instead of D register. Hopefully the later optimization
5925 +; passes will notice that the value ended up in a D register first here
5926 +; and eliminate away the other register!
5929 + [(match_scratch:SI 2 "d")
5930 + (set (match_operand:SI 0 "register_operand" "")
5931 + (match_operand:SI 1 "const_int_operand" ""))]
5932 + "(((INTVAL (operands[1]) >= 0x8000
5933 + && INTVAL (operands[1]) < 0xff80)
5934 + || INTVAL (operands[1]) >= 0x10000
5935 + || INTVAL (operands[1]) < -0x8000)
5936 + && ((INTVAL (operands[1]) & 0xffff) >= 0xff80
5937 + || (INTVAL (operands[1]) & 0xffff) < 0x80)
5938 + && peep2_regno_dead_p (0, CC_REGNO))"
5939 + [(set (match_dup 2)
5942 + [(set (match_dup 2)
5944 + (ashift:SI (match_dup 2)
5948 + (clobber (reg:CC CC_REGNO))])
5949 + (set (match_dup 0)
5952 + operands[3] = gen_highpart_mode (HImode, SImode, operands[1]);
5953 + operands[4] = gen_lowpart (HImode, operands[1]);
5956 +; If we have a load of a large integer constant which does not have bit 31
5957 +; set and we have a spare A reg then construct it with a moveai/lea.1 pair
5958 +; instead. This avoids constructing it in 3 instructions on the stack.
5960 +; Note that we have to be careful not to match anything that matches
5961 +; something we can do in a single instruction! There aren't many such
5962 +; constants but there are some.
5965 + [(match_scratch:SI 2 "a")
5966 + (set (match_operand:SI 0 "register_operand" "")
5967 + (match_operand:SI 1 "const_int_operand" ""))]
5968 + "(! (INTVAL (operands[1]) & 0x80000000)
5969 + && ((INTVAL (operands[1]) >= 0x8000
5970 + && INTVAL (operands[1]) < 0xff80)
5971 + || INTVAL (operands[1]) >= 0x10000))"
5972 + [(set (match_dup 2)
5974 + (set (match_dup 0)
5975 + (plus:SI (match_dup 2)
5978 + HOST_WIDE_INT i = INTVAL (operands[1]);
5979 + operands[3] = GEN_INT (i & 0xffffff80);
5980 + operands[4] = GEN_INT (i & 0x7f);
5983 +; If we're not dependent on the state of the condition codes we can construct
5984 +; a 32-bit constant with a movei/movei/shmrg.2 sequence if possible.
5987 + [(match_scratch:HI 2 "d")
5988 + (set (match_operand:SI 0 "ubicom32_data_register_operand" "")
5989 + (match_operand:SI 1 "const_int_operand" ""))
5991 + "(INTVAL (operands[1]) & 0x80000000
5992 + && INTVAL (operands[1]) < -0x8000
5993 + && peep2_regno_dead_p (0, CC_REGNO))"
5994 + [(set (match_dup 0)
5996 + (set (match_dup 2)
5999 + [(set (match_dup 0)
6001 + (ashift:SI (match_dup 0)
6005 + (clobber (reg:CC CC_REGNO))])]
6007 + operands[3] = gen_highpart_mode (HImode, SImode, operands[1]);
6008 + operands[4] = gen_lowpart (HImode, operands[1]);
6011 +; Exactly the same as the peephole2 preceding except that this targets a
6012 +; general register instead of D register. Hopefully the later optimization
6013 +; passes will notice that the value ended up in a D register first here
6014 +; and eliminate away the other register!
6017 + [(match_scratch:SI 2 "d")
6018 + (match_scratch:HI 3 "d")
6019 + (set (match_operand:SI 0 "register_operand" "")
6020 + (match_operand:SI 1 "const_int_operand" ""))
6022 + "(INTVAL (operands[1]) & 0x80000000
6023 + && INTVAL (operands[1]) < -0x8000
6024 + && peep2_regno_dead_p (0, CC_REGNO))"
6025 + [(set (match_dup 2)
6027 + (set (match_dup 3)
6030 + [(set (match_dup 2)
6032 + (ashift:SI (match_dup 2)
6036 + (clobber (reg:CC CC_REGNO))])
6037 + (set (match_dup 0)
6040 + operands[4] = gen_highpart_mode (HImode, SImode, operands[1]);
6041 + operands[5] = gen_lowpart (HImode, operands[1]);
6044 +(define_insn "movsi_fdpic_got_offset"
6045 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
6046 + (match_operand:SI 1 "ubicom32_fdpic_got_offset_operand" "Y"))]
6050 +; The explicit MEM inside the UNSPEC prevents the compiler from moving
6051 +; the load before a branch after a NULL test, or before a store that
6052 +; initializes a function descriptor.
6054 +(define_insn_and_split "load_fdpic_funcdesc"
6055 + [(set (match_operand:SI 0 "ubicom32_address_register_operand" "=a")
6056 + (unspec_volatile:SI [(mem:SI (match_operand:SI 1 "address_operand" "p"))]
6057 + UNSPEC_VOLATILE_LOAD_FDPIC_FUNCDESC))]
6060 + "reload_completed"
6061 + [(set (match_dup 0)
6062 + (mem:SI (match_dup 1)))])
6064 +; Combiner-generated 32-bit move with the zero flag set accordingly.
6066 +(define_insn "movsi_ccwzn"
6067 + [(set (reg CC_REGNO)
6068 + (compare (match_operand:SI 0 "nonimmediate_operand" "rm, d")
6070 + (set (match_operand:SI 1 "nonimmediate_operand" "=d,rm")
6072 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
6074 + lsl.4\\t%1, %0, #0
6075 + add.4\\t%1, #0, %0")
6077 +; Combiner-generated 32-bit move with all flags set accordingly.
6079 +(define_insn "movsi_ccw"
6080 + [(set (reg CC_REGNO)
6081 + (compare (match_operand:SI 0 "ubicom32_data_register_operand" "d")
6083 + (set (match_operand:SI 1 "nonimmediate_operand" "=rm")
6085 + "ubicom32_match_cc_mode(insn, CCWmode)"
6086 + "add.4\\t%1, #0, %0")
6088 +; Combine isn't very good at merging some types of operations so we
6089 +; have to make do with a peephole. It's not as effective but it's better
6090 +; than doing nothing.
6093 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "")
6094 + (match_operand:SI 1 "nonimmediate_operand" ""))
6096 + [(set (match_operand 2 "ubicom32_cc_register_operand" "")
6097 + (match_operator 3 "ubicom32_compare_operator"
6100 + (clobber (match_operand:SI 4 "ubicom32_data_register_operand" ""))])]
6101 + "(GET_MODE (operands[2]) == CCWZNmode
6102 + || GET_MODE (operands[2]) == CCWZmode)"
6104 + [(set (match_dup 2)
6108 + (set (match_dup 0)
6112 +; Combine isn't very good at merging some types of operations so we
6113 +; have to make do with a peephole. It's not as effective but it's better
6114 +; than doing nothing.
6117 + [(set (match_operand:SI 0 "nonimmediate_operand" "")
6118 + (match_operand:SI 1 "ubicom32_data_register_operand" ""))
6120 + [(set (match_operand 2 "ubicom32_cc_register_operand" "")
6121 + (match_operator 3 "ubicom32_compare_operator"
6124 + (clobber (match_operand:SI 4 "ubicom32_data_register_operand" ""))])]
6125 + "(GET_MODE (operands[2]) == CCWZNmode
6126 + || GET_MODE (operands[2]) == CCWZmode)"
6128 + [(set (match_dup 2)
6132 + (set (match_dup 0)
6136 +; Combine isn't very good at merging some types of operations so we
6137 +; have to make do with a peephole. It's not as effective but it's better
6138 +; than doing nothing.
6141 + [(set (match_operand:SI 0 "register_operand" "")
6142 + (match_operand:SI 1 "nonimmediate_operand" ""))
6144 + [(set (match_operand 2 "ubicom32_cc_register_operand" "")
6145 + (match_operator 3 "ubicom32_compare_operator"
6148 + (set (match_operand:SI 4 "ubicom32_data_register_operand" "")
6150 + "(peep2_reg_dead_p (2, operands[0])
6151 + && (GET_MODE (operands[2]) == CCWZNmode
6152 + || GET_MODE (operands[2]) == CCWZmode))"
6154 + [(set (match_dup 2)
6158 + (set (match_dup 4)
6162 +; Register renaming may make a general reg into a D reg in which case
6163 +; we may be able to simplify a compare.
6166 + [(set (match_operand:SI 0 "register_operand" "")
6167 + (match_operand:SI 1 "nonimmediate_operand" ""))
6169 + [(set (match_operand 2 "ubicom32_cc_register_operand" "")
6170 + (match_operator 3 "ubicom32_compare_operator"
6173 + (clobber (match_operand:SI 4 "ubicom32_data_register_operand" ""))])]
6174 + "(peep2_reg_dead_p (2, operands[0])
6175 + && (GET_MODE (operands[2]) == CCWZNmode
6176 + || GET_MODE (operands[2]) == CCWZmode))"
6178 + [(set (match_dup 2)
6182 + (clobber (match_dup 4))])]
6185 +(define_insn_and_split "movdi"
6186 + [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
6187 + (match_operand:DI 1 "general_operand" "rmi,ri"))]
6190 + "reload_completed"
6191 + [(set (match_dup 2) (match_dup 3))
6192 + (set (match_dup 4) (match_dup 5))]
6197 + dest_low = gen_lowpart (SImode, operands[0]);
6198 + src_low = gen_lowpart (SImode, operands[1]);
6200 + if (REG_P (operands[0])
6201 + && REG_P (operands[1])
6202 + && REGNO (operands[0]) < REGNO (operands[1]))
6204 + operands[2] = gen_highpart (SImode, operands[0]);
6205 + operands[3] = gen_highpart_mode (SImode, DImode, operands[1]);
6206 + operands[4] = dest_low;
6207 + operands[5] = src_low;
6209 + else if (reg_mentioned_p (dest_low, src_low))
6211 + operands[2] = gen_highpart (SImode, operands[0]);
6212 + operands[3] = gen_highpart_mode (SImode, DImode, operands[1]);
6213 + operands[4] = dest_low;
6214 + operands[5] = src_low;
6218 + operands[2] = dest_low;
6219 + operands[3] = src_low;
6220 + operands[4] = gen_highpart (SImode, operands[0]);
6221 + operands[5] = gen_highpart_mode (SImode, DImode, operands[1]);
6224 + [(set_attr "length" "8")])
6226 +; Combiner-generated 64-bit move with all flags set accordingly.
6228 +(define_insn "movdi_ccwzn"
6229 + [(set (reg CC_REGNO)
6230 + (compare (match_operand:DI 0 "nonimmediate_operand" "d, m, r")
6232 + (set (match_operand:DI 1 "nonimmediate_operand" "=&rm,rm,!&rm")
6234 + (clobber (match_scratch:SI 2 "=X, d, d"))]
6235 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
6238 + operands[3] = gen_lowpart (SImode, operands[0]);
6239 + operands[4] = gen_lowpart (SImode, operands[1]);
6240 + operands[5] = gen_highpart (SImode, operands[0]);
6241 + operands[6] = gen_highpart (SImode, operands[1]);
6243 + if (ubicom32_data_register_operand (operands[0], VOIDmode))
6244 + return \"add.4\\t%4, #0, %3\;addc\\t%6, #0, %5\";
6246 + return \"movei\\t%2, #0\;add.4\\t%4, %3, %2\;addc\\t%6, %5, %2\";
6248 + [(set_attr "length" "8")])
6250 +(define_insn "movdi_ccw"
6251 + [(set (reg CC_REGNO)
6252 + (compare (match_operand:DI 0 "nonimmediate_operand" "d, m, r")
6254 + (set (match_operand:DI 1 "nonimmediate_operand" "=&rm,rm,!&rm")
6256 + (clobber (match_scratch:SI 2 "=X, d, d"))]
6257 + "ubicom32_match_cc_mode(insn, CCWmode)"
6260 + operands[3] = gen_lowpart (SImode, operands[0]);
6261 + operands[4] = gen_lowpart (SImode, operands[1]);
6262 + operands[5] = gen_highpart (SImode, operands[0]);
6263 + operands[6] = gen_highpart (SImode, operands[1]);
6265 + if (ubicom32_data_register_operand (operands[0], VOIDmode))
6266 + return \"add.4\\t%4, #0, %3\;addc\\t%6, #0, %5\";
6268 + return \"movei\\t%2, #0\;add.4\\t%4, %3, %2\;addc\\t%6, %5, %2\";
6270 + [(set_attr "length" "8")])
6272 +(define_insn "movsf"
6273 + [(set (match_operand:SF 0 "nonimmediate_operand" "=!d,*rm")
6274 + (match_operand:SF 1 "ubicom32_move_operand" "rmF,rmF"))]
6278 + if (GET_CODE (operands[1]) == CONST_DOUBLE)
6280 + HOST_WIDE_INT val;
6281 + REAL_VALUE_TYPE rv;
6283 + REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
6284 + REAL_VALUE_TO_TARGET_SINGLE (rv, val);
6286 + ubicom32_emit_move_const_int (operands[0], GEN_INT (val));
6290 + return \"move.4\\t%0, %1\";
6293 +(define_insn "zero_extendqihi2"
6294 + [(set (match_operand:HI 0 "register_operand" "=r")
6295 + (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "rm")))]
6297 + "move.1\\t%0, %1")
6299 +(define_insn "zero_extendqisi2"
6300 + [(set (match_operand:SI 0 "register_operand" "=r")
6301 + (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rm")))]
6303 + "move.1\\t%0, %1")
6305 +(define_insn "zero_extendqisi2_ccwz_1"
6306 + [(set (reg CC_REGNO)
6308 + (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rm"))
6310 + (set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
6311 + (zero_extend:SI (match_dup 1)))]
6312 + "ubicom32_match_cc_mode(insn, CCWZmode)"
6313 + "shmrg.1\\t%0, %1, #0")
6315 +(define_insn "zero_extendhisi2"
6316 + [(set (match_operand:SI 0 "register_operand" "=r")
6317 + (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
6319 + "move.2\\t%0, %1")
6321 +(define_insn "zero_extendhisi2_ccwz_1"
6322 + [(set (reg CC_REGNO)
6324 + (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm"))
6326 + (set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
6327 + (zero_extend:SI (match_dup 1)))]
6328 + "ubicom32_match_cc_mode(insn, CCWZmode)"
6329 + "shmrg.2\\t%0, %1, #0")
6331 +(define_insn_and_split "zero_extendqidi2"
6332 + [(set (match_operand:DI 0 "register_operand" "=r")
6333 + (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "rm")))]
6336 + "reload_completed"
6337 + [(set (match_dup 2)
6338 + (zero_extend:SI (match_dup 1)))
6339 + (set (match_dup 3)
6342 + operands[2] = gen_lowpart (SImode, operands[0]);
6343 + operands[3] = gen_highpart (SImode, operands[0]);
6345 + [(set_attr "length" "8")])
6347 +(define_insn_and_split "zero_extendhidi2"
6348 + [(set (match_operand:DI 0 "register_operand" "=r")
6349 + (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
6352 + "reload_completed"
6353 + [(set (match_dup 2)
6354 + (zero_extend:SI (match_dup 1)))
6355 + (set (match_dup 3)
6358 + operands[2] = gen_lowpart (SImode, operands[0]);
6359 + operands[3] = gen_highpart (SImode, operands[0]);
6361 + [(set_attr "length" "8")])
6363 +(define_insn_and_split "zero_extendsidi2"
6364 + [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
6365 + (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm")))]
6368 + "reload_completed"
6369 + [(set (match_dup 2)
6371 + (set (match_dup 3)
6374 + operands[2] = gen_lowpart (SImode, operands[0]);
6375 + operands[3] = gen_highpart (SImode, operands[0]);
6377 + [(set_attr "length" "8")])
6379 +(define_insn "extendqihi2"
6380 + [(set (match_operand:HI 0 "register_operand" "=r")
6381 + (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "rm")))
6382 + (clobber (reg:CC CC_REGNO))]
6386 +(define_insn "extendqisi2"
6387 + [(set (match_operand:SI 0 "register_operand" "=r")
6388 + (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rm")))
6389 + (clobber (reg:CC CC_REGNO))]
6393 +(define_insn "extendhisi2"
6394 + [(set (match_operand:SI 0 "register_operand" "=r")
6395 + (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))
6396 + (clobber (reg:CC CC_REGNO))]
6400 +(define_insn_and_split "extendsidi2"
6401 + [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
6402 + (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm")))
6403 + (clobber (reg:CC CC_REGNO))]
6406 + "reload_completed"
6407 + [(set (match_dup 2)
6410 + [(set (match_dup 3)
6411 + (ashiftrt:SI (match_dup 2)
6413 + (clobber (reg:CC CC_REGNO))])]
6415 + operands[2] = gen_lowpart (SImode, operands[0]);
6416 + operands[3] = gen_highpart (SImode, operands[0]);
6418 + [(set_attr "length" "8")])
6420 +(define_insn "bswaphi"
6421 + [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
6422 + (bswap:HI (match_operand:HI 1 "ubicom32_arith_operand" "rmI")))]
6424 + "swapb.2\\t%0, %1");
6426 +(define_insn "bswaphisi"
6427 + [(set (match_operand:SI 0 "register_operand" "=r")
6429 + (bswap:HI (match_operand:HI 1 "ubicom32_arith_operand" "rmI"))))]
6431 + "swapb.2\\t%0, %1");
6433 +(define_insn "bswapsi"
6434 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
6435 + (bswap:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")))]
6437 + "swapb.4\\t%0, %1");
6439 +(define_insn "tstqi_ext1"
6440 + [(set (reg CC_REGNO)
6441 + (compare (match_operand:QI 0 "nonimmediate_operand" "rm")
6443 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
6446 +(define_expand "cmpqi"
6447 + [(set (reg CC_REGNO)
6448 + (compare (match_operand:QI 0 "ubicom32_arith_operand" "")
6449 + (match_operand:QI 1 "ubicom32_data_register_operand" "")))]
6452 + ubicom32_compare_op0 = operands[0];
6453 + ubicom32_compare_op1 = operands[1];
6457 +(define_insn "sub1_ccs"
6458 + [(set (reg CC_REGNO)
6459 + (compare (match_operand:QI 0 "ubicom32_arith_operand" "rmI")
6460 + (match_operand:QI 1 "ubicom32_data_register_operand" "d")))]
6462 + "sub.1\\t#0, %0, %1")
6464 +; If we're testing for equality we don't have to worry about reversing conditions.
6466 +(define_insn "sub1_ccsz_1"
6467 + [(set (reg:CCSZ CC_REGNO)
6468 + (compare:CCSZ (match_operand:QI 0 "nonimmediate_operand" "rm")
6469 + (match_operand:QI 1 "ubicom32_data_register_operand" "d")))]
6471 + "sub.1\\t#0, %0, %1")
6473 +(define_insn "sub1_ccsz_2"
6474 + [(set (reg:CCSZ CC_REGNO)
6475 + (compare:CCSZ (match_operand:QI 0 "ubicom32_data_register_operand" "d")
6476 + (match_operand:QI 1 "ubicom32_arith_operand" "rmI")))]
6478 + "sub.1\\t#0, %1, %0")
6480 +; When the combiner runs it doesn't have any insight into whether or not an argument
6481 +; to a compare is spilled to the stack and therefore can't swap the comparison in
6482 +; an attempt to use sub.1 more effectively. We peephole this case here.
6485 + [(set (match_operand:QI 0 "register_operand" "")
6486 + (match_operand:QI 1 "ubicom32_arith_operand" ""))
6487 + (set (match_operand 2 "ubicom32_cc_register_operand" "")
6488 + (compare (match_operand:QI 3 "ubicom32_data_register_operand" "")
6491 + (if_then_else (match_operator 4 "comparison_operator"
6494 + (label_ref (match_operand 5 "" ""))
6496 + "(peep2_reg_dead_p (2, operands[0])
6497 + && peep2_regno_dead_p (3, CC_REGNO))"
6498 + [(set (match_dup 2)
6499 + (compare (match_dup 1)
6502 + (if_then_else (match_op_dup 6
6505 + (label_ref (match_dup 5))
6510 + cc_reg = gen_rtx_REG (GET_MODE (operands[2]), CC_REGNO);
6511 + operands[6] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[4])),
6512 + GET_MODE (operands[4]),
6517 +(define_insn "tsthi_ext2"
6518 + [(set (reg CC_REGNO)
6519 + (compare (match_operand:HI 0 "nonimmediate_operand" "rm")
6521 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
6524 +(define_expand "cmphi"
6525 + [(set (reg CC_REGNO)
6526 + (compare (match_operand:HI 0 "ubicom32_arith_operand" "")
6527 + (match_operand:HI 1 "ubicom32_compare_operand" "")))]
6532 + /* Is this a cmpi? */
6533 + if (CONST_INT_P (operands[1]))
6536 + /* Must be a sub.2 - if necessary copy an operand into a reg. */
6537 + if (! ubicom32_data_register_operand (operands[1], HImode))
6538 + operands[1] = copy_to_mode_reg (HImode, operands[1]);
6542 + ubicom32_compare_op0 = operands[0];
6543 + ubicom32_compare_op1 = operands[1];
6547 +(define_insn "cmpi"
6548 + [(set (reg CC_REGNO)
6549 + (compare (match_operand:HI 0 "nonimmediate_operand" "rm")
6550 + (match_operand 1 "const_int_operand" "N")))]
6554 +(define_insn "sub2_ccs"
6555 + [(set (reg CC_REGNO)
6556 + (compare (match_operand:HI 0 "ubicom32_arith_operand" "rmI")
6557 + (match_operand:HI 1 "ubicom32_data_register_operand" "d")))]
6559 + "sub.2\\t#0, %0, %1")
6561 +; If we're testing for equality we don't have to worry about reversing conditions.
6563 +(define_insn "sub2_ccsz_1"
6564 + [(set (reg:CCSZ CC_REGNO)
6565 + (compare:CCSZ (match_operand:HI 0 "nonimmediate_operand" "rm")
6566 + (match_operand:HI 1 "ubicom32_data_register_operand" "d")))]
6568 + "sub.2\\t#0, %0, %1")
6570 +(define_insn "sub2_ccsz_2"
6571 + [(set (reg:CCSZ CC_REGNO)
6572 + (compare:CCSZ (match_operand:HI 0 "ubicom32_data_register_operand" "d")
6573 + (match_operand:HI 1 "ubicom32_arith_operand" "rmI")))]
6575 + "sub.2\\t#0, %1, %0")
6577 +; When the combiner runs it doesn't have any insight into whether or not an argument
6578 +; to a compare is spilled to the stack and therefore can't swap the comparison in
6579 +; an attempt to use sub.2 more effectively. We peephole this case here.
6582 + [(set (match_operand:HI 0 "register_operand" "")
6583 + (match_operand:HI 1 "ubicom32_arith_operand" ""))
6584 + (set (match_operand 2 "ubicom32_cc_register_operand" "")
6585 + (compare (match_operand:HI 3 "ubicom32_data_register_operand" "")
6588 + (if_then_else (match_operator 4 "comparison_operator"
6591 + (label_ref (match_operand 5 "" ""))
6593 + "(peep2_reg_dead_p (2, operands[0])
6594 + && peep2_regno_dead_p (3, CC_REGNO))"
6595 + [(set (match_dup 2)
6596 + (compare (match_dup 1)
6599 + (if_then_else (match_op_dup 6
6602 + (label_ref (match_dup 5))
6607 + cc_reg = gen_rtx_REG (GET_MODE (operands[2]), CC_REGNO);
6608 + operands[6] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[4])),
6609 + GET_MODE (operands[4]),
6614 +(define_insn_and_split "tstsi_lsl4"
6615 + [(set (match_operand 0 "ubicom32_cc_register_operand" "=r")
6616 + (match_operator 1 "ubicom32_compare_operator"
6617 + [(match_operand:SI 2 "nonimmediate_operand" "rm")
6619 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
6621 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
6623 + [(set (match_dup 0)
6627 + (clobber (match_dup 3))])]
6629 + operands[3] = gen_reg_rtx (SImode);
6632 +(define_insn "tstsi_lsl4_d"
6633 + [(set (reg CC_REGNO)
6634 + (compare (match_operand:SI 0 "nonimmediate_operand" "rm")
6636 + (clobber (match_operand:SI 1 "ubicom32_data_register_operand" "=d"))]
6637 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
6638 + "lsl.4\\t%1, %0, #0")
6640 +; Comparison for equality with -1.
6642 +(define_insn "cmpsi_not4_ccwz"
6643 + [(set (reg CC_REGNO)
6644 + (compare (match_operand:SI 0 "nonimmediate_operand" "rm")
6646 + "ubicom32_match_cc_mode(insn, CCWZmode)"
6649 +(define_expand "cmpsi"
6650 + [(set (reg CC_REGNO)
6651 + (compare (match_operand:SI 0 "ubicom32_arith_operand" "")
6652 + (match_operand:SI 1 "ubicom32_compare_operand" "")))]
6657 + /* Is this a cmpi? We can't take a memory address as cmpi takes
6658 + 16-bit operands. */
6659 + if (register_operand (operands[0], SImode)
6660 + && CONST_INT_P (operands[1])
6661 + && satisfies_constraint_N (operands[1]))
6664 + /* Must be a sub.4 - if necessary copy an operand into a reg. */
6665 + if (! ubicom32_data_register_operand (operands[1], SImode))
6666 + operands[1] = copy_to_mode_reg (SImode, operands[1]);
6670 + ubicom32_compare_op0 = operands[0];
6671 + ubicom32_compare_op1 = operands[1];
6675 +(define_insn "cmpsi_cmpi"
6676 + [(set (reg CC_REGNO)
6677 + (compare (match_operand:SI 0 "register_operand" "r")
6678 + (match_operand 1 "const_int_operand" "N")))]
6679 + "(satisfies_constraint_N (operands[1]))"
6682 +(define_insn "cmpsi_sub4"
6683 + [(set (reg CC_REGNO)
6684 + (compare (match_operand:SI 0 "ubicom32_arith_operand" "rmI")
6685 + (match_operand:SI 1 "ubicom32_data_register_operand" "d")))]
6687 + "sub.4\\t#0, %0, %1")
6689 +; If we're testing for equality we don't have to worry about reversing conditions.
6691 +(define_insn "cmpsi_sub4_ccwz_1"
6692 + [(set (reg CC_REGNO)
6693 + (compare (match_operand:SI 0 "nonimmediate_operand" "rm")
6694 + (match_operand:SI 1 "ubicom32_data_register_operand" "d")))]
6695 + "ubicom32_match_cc_mode(insn, CCWZmode)"
6696 + "sub.4\\t#0, %0, %1")
6698 +(define_insn "cmpsi_sub4_ccwz_2"
6699 + [(set (reg CC_REGNO)
6700 + (compare (match_operand:SI 0 "ubicom32_data_register_operand" "d")
6701 + (match_operand:SI 1 "nonimmediate_operand" "rm")))]
6702 + "ubicom32_match_cc_mode(insn, CCWZmode)"
6703 + "sub.4\\t#0, %1, %0")
6705 +; When the combiner runs it doesn't have any insight into whether or not an argument
6706 +; to a compare is spilled to the stack and therefore can't swap the comparison in
6707 +; an attempt to use sub.4 more effectively. We peephole this case here.
6710 + [(set (match_operand:SI 0 "register_operand" "")
6711 + (match_operand:SI 1 "ubicom32_arith_operand" ""))
6712 + (set (match_operand 2 "ubicom32_cc_register_operand" "")
6713 + (compare (match_operand:SI 3 "ubicom32_data_register_operand" "")
6716 + (if_then_else (match_operator 4 "comparison_operator"
6719 + (label_ref (match_operand 5 "" ""))
6721 + "(peep2_reg_dead_p (2, operands[0])
6722 + && peep2_regno_dead_p (3, CC_REGNO))"
6723 + [(set (match_dup 2)
6724 + (compare (match_dup 1)
6727 + (if_then_else (match_op_dup 6
6730 + (label_ref (match_dup 5))
6735 + cc_reg = gen_rtx_REG (GET_MODE (operands[2]), CC_REGNO);
6736 + operands[6] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[4])),
6737 + GET_MODE (operands[4]),
6742 +(define_insn_and_split "tstdi_or4"
6743 + [(set (reg:CCWZ CC_REGNO)
6744 + (compare:CCWZ (match_operand:DI 0 "nonimmediate_operand" "rm")
6750 + [(set (reg:CCWZ CC_REGNO)
6751 + (compare:CCWZ (match_dup 0)
6753 + (clobber (match_dup 1))])]
6755 + operands[1] = gen_reg_rtx (SImode);
6758 +(define_insn "tstdi_or4_d"
6759 + [(set (reg:CCWZ CC_REGNO)
6760 + (compare:CCWZ (match_operand:DI 0 "nonimmediate_operand" "rm")
6762 + (clobber (match_operand:SI 1 "ubicom32_data_register_operand" "=d"))]
6766 + operands[2] = gen_lowpart (SImode, operands[0]);
6767 + operands[3] = gen_highpart_mode (SImode, DImode, operands[0]);
6769 + if (ubicom32_data_register_operand (operands[0], GET_MODE (operands[0])))
6770 + return \"or.4\\t#0, %2, %3\";
6772 + return \"move.4\\t%1, %2\;or.4\\t%1, %3, %1\";
6774 + [(set_attr "length" "8")])
6776 +(define_expand "cmpdi"
6777 + [(set (reg CC_REGNO)
6778 + (compare (match_operand:DI 0 "ubicom32_arith_operand" "")
6779 + (match_operand:DI 1 "ubicom32_data_register_operand" "")))]
6782 + ubicom32_compare_op0 = operands[0];
6783 + ubicom32_compare_op1 = operands[1];
6787 +(define_insn "cmpdi_sub4subc"
6788 + [(set (reg CC_REGNO)
6789 + (compare (match_operand:DI 0 "ubicom32_arith_operand" "rmI")
6790 + (match_operand:DI 1 "ubicom32_data_register_operand" "d")))]
6794 + operands[2] = gen_lowpart (SImode, operands[0]);
6795 + operands[3] = gen_lowpart (SImode, operands[1]);
6796 + operands[4] = gen_highpart_mode (SImode, DImode, operands[0]);
6797 + operands[5] = gen_highpart_mode (SImode, DImode, operands[1]);
6799 + return \"sub.4\\t#0, %2, %3\;subc\\t#0, %4, %5\";
6801 + [(set_attr "length" "8")])
6803 +; When the combiner runs it doesn't have any insight into whether or not an argument
6804 +; to a compare is spilled to the stack and therefore can't swap the comparison in
6805 +; an attempt to use sub.4/subc more effectively. We peephole this case here.
6808 + [(set (match_operand:DI 0 "register_operand" "")
6809 + (match_operand:DI 1 "ubicom32_arith_operand" ""))
6810 + (set (match_operand 2 "ubicom32_cc_register_operand" "")
6811 + (compare (match_operand:DI 3 "ubicom32_data_register_operand" "")
6814 + (if_then_else (match_operator 4 "comparison_operator"
6817 + (label_ref (match_operand 5 "" ""))
6819 + "(peep2_reg_dead_p (2, operands[0])
6820 + && peep2_regno_dead_p (3, CC_REGNO))"
6821 + [(set (match_dup 2)
6822 + (compare (match_dup 1)
6825 + (if_then_else (match_op_dup 6
6828 + (label_ref (match_dup 5))
6833 + cc_reg = gen_rtx_REG (GET_MODE (operands[2]), CC_REGNO);
6834 + operands[6] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[4])),
6835 + GET_MODE (operands[4]),
6840 +(define_insn "btst"
6841 + [(set (reg:CCWZ CC_REGNO)
6844 + (match_operand:SI 0 "nonimmediate_operand" "rm")
6846 + (match_operand:SI 1 "ubicom32_arith_operand" "dM"))
6851 +(define_insn "bfextu_ccwz_null"
6852 + [(set (reg:CCWZ CC_REGNO)
6855 + (match_operand:SI 0 "nonimmediate_operand" "rm")
6856 + (match_operand 1 "const_int_operand" "M")
6859 + (clobber (match_scratch:SI 2 "=d"))]
6861 + "bfextu\\t%2, %0, %1")
6863 +(define_expand "addqi3"
6865 + [(set (match_operand:QI 0 "memory_operand" "")
6866 + (plus:QI (match_operand:QI 1 "nonimmediate_operand" "")
6867 + (match_operand:QI 2 "ubicom32_arith_operand" "")))
6868 + (clobber (reg:CC CC_REGNO))])]
6871 + if (!memory_operand (operands[0], QImode))
6874 + /* If we have a non-data reg for operand 1 then prefer that over
6875 + a CONST_INT in operand 2. */
6876 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
6877 + && CONST_INT_P (operands[2]))
6878 + operands[2] = copy_to_mode_reg (QImode, operands[2]);
6880 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
6881 + operands[2] = copy_to_mode_reg (QImode, operands[2]);
6884 +(define_insn "addqi3_add1"
6885 + [(set (match_operand:QI 0 "memory_operand" "=m, m")
6886 + (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%d,rm")
6887 + (match_operand:QI 2 "ubicom32_arith_operand" "rmI, d")))
6888 + (clobber (reg:CC CC_REGNO))]
6891 + add.1\\t%0, %2, %1
6892 + add.1\\t%0, %1, %2")
6894 +(define_insn "addqi3_add1_ccszn_null"
6895 + [(set (reg CC_REGNO)
6897 + (neg:QI (match_operand:QI 0 "nonimmediate_operand" "%d,rm"))
6898 + (match_operand:QI 1 "ubicom32_arith_operand" "rmI, d")))]
6900 + && ubicom32_match_cc_mode(insn, CCSZNmode))"
6902 + add.1\\t#0, %1, %0
6903 + add.1\\t#0, %0, %1")
6905 +(define_expand "addhi3"
6907 + [(set (match_operand:HI 0 "memory_operand" "")
6908 + (plus:HI (match_operand:HI 1 "nonimmediate_operand" "")
6909 + (match_operand:HI 2 "ubicom32_arith_operand" "")))
6910 + (clobber (reg:CC CC_REGNO))])]
6913 + if (!memory_operand (operands[0], HImode))
6916 + /* If we have a non-data reg for operand 1 then prefer that over
6917 + a CONST_INT in operand 2. */
6918 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
6919 + && CONST_INT_P (operands[2]))
6920 + operands[2] = copy_to_mode_reg (HImode, operands[2]);
6922 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
6923 + operands[2] = copy_to_mode_reg (HImode, operands[2]);
6926 +(define_insn "addhi3_add2"
6927 + [(set (match_operand:HI 0 "memory_operand" "=m, m")
6928 + (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%d,rm")
6929 + (match_operand:HI 2 "ubicom32_arith_operand" "rmI, d")))
6930 + (clobber (reg:CC CC_REGNO))]
6933 + add.2\\t%0, %2, %1
6934 + add.2\\t%0, %1, %2")
6936 +(define_insn "addhi3_add2_ccszn_null"
6937 + [(set (reg CC_REGNO)
6939 + (neg:HI (match_operand:HI 0 "nonimmediate_operand" "%d,rm"))
6940 + (match_operand:HI 1 "ubicom32_arith_operand" "rmI, d")))]
6941 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
6943 + add.2\\t#0, %1, %0
6944 + add.2\\t#0, %0, %1")
6946 +(define_expand "addsi3"
6947 + [(set (match_operand:SI 0 "nonimmediate_operand" "")
6948 + (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
6949 + (match_operand:SI 2 "ubicom32_move_operand" "")))]
6952 + ubicom32_expand_addsi3 (operands);
6956 +; We start with an instruction pattern that can do all sorts of interesting
6957 +; things but we split out any uses of lea or pdec instructions because
6958 +; those instructions don't clobber the condition codes.
6960 +(define_insn_and_split "addsi3_1"
6961 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm,rm,rm,rm, rm,rm")
6962 + (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%a, a, a, a, a, d,rm")
6963 + (match_operand:SI 2 "ubicom32_move_operand" "L, K, J, P, d,rmI, d")))
6964 + (clobber (reg:CC CC_REGNO))]
6972 + add.4\\t%0, %2, %1
6973 + add.4\\t%0, %1, %2"
6974 + "(reload_completed
6975 + && ubicom32_address_register_operand (operands[1], GET_MODE (operands[1])))"
6976 + [(set (match_dup 0)
6977 + (plus:SI (match_dup 1)
6982 +(define_insn "addsi3_1_ccwzn"
6983 + [(set (reg CC_REGNO)
6985 + (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%d,rm")
6986 + (match_operand:SI 2 "ubicom32_arith_operand" "rmI, d"))
6988 + (set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
6989 + (plus:SI (match_dup 1)
6991 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
6993 + add.4\\t%0, %2, %1
6994 + add.4\\t%0, %1, %2")
6996 +(define_insn "addsi3_1_ccwzn_null"
6997 + [(set (reg CC_REGNO)
6999 + (neg:SI (match_operand:SI 0 "nonimmediate_operand" "%d,rm"))
7000 + (match_operand:SI 1 "ubicom32_arith_operand" "rmI, d")))]
7001 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
7003 + add.4\\t#0, %1, %0
7004 + add.4\\t#0, %0, %1")
7006 +(define_insn_and_split "addsi3_2"
7007 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm,rm,rm,rm,rm")
7008 + (plus:SI (match_operand:SI 1 "ubicom32_address_register_operand" "%a, a, a, a, a, a")
7009 + (match_operand:SI 2 "ubicom32_move_operand" "L, K, J, P, d, n")))]
7012 + lea.4\\t%0, %E2(%1)
7013 + lea.2\\t%0, %E2(%1)
7014 + lea.1\\t%0, %E2(%1)
7015 + pdec\\t%0, %n2(%1)
7016 + lea.1\\t%0, (%1,%2)
7018 + "(reload_completed
7019 + && ! satisfies_constraint_L (operands[2])
7020 + && ! satisfies_constraint_K (operands[2])
7021 + && ! satisfies_constraint_J (operands[2])
7022 + && ! satisfies_constraint_P (operands[2])
7023 + && ! ubicom32_data_register_operand (operands[2], GET_MODE (operands[2])))"
7024 + [(set (reg:SI AUX_DATA_REGNO)
7026 + (set (match_dup 0)
7027 + (plus:SI (match_dup 1)
7028 + (reg:SI AUX_DATA_REGNO)))]
7032 +(define_insn "lea_2"
7033 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
7034 + (plus:SI (mult:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")
7036 + (match_operand:SI 2 "ubicom32_address_register_operand" "a")))]
7038 + "lea.2\\t%0, (%2,%1)")
7040 +(define_insn "lea_4"
7041 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
7042 + (plus:SI (mult:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")
7044 + (match_operand:SI 2 "ubicom32_address_register_operand" "a")))]
7046 + "lea.4\\t%0, (%2,%1)")
7048 +(define_expand "adddi3"
7050 + [(set (match_operand:DI 0 "nonimmediate_operand" "")
7051 + (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
7052 + (match_operand:DI 2 "ubicom32_arith_operand" "")))
7053 + (clobber (reg:CC CC_REGNO))])]
7056 + /* If we have a non-data reg for operand 1 then prefer that over
7057 + a CONST_INT in operand 2. */
7058 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
7059 + && CONST_INT_P (operands[2]))
7060 + operands[2] = copy_to_mode_reg (DImode, operands[2]);
7062 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
7063 + operands[2] = copy_to_mode_reg (DImode, operands[2]);
7066 +; We construct a 64-bit add from 32-bit operations. Note that we use the
7067 +; & constraint to prevent overlapping registers being allocated. We do
7068 +; allow identical registers though as that won't break anything.
7070 +(define_insn "adddi3_add4addc"
7071 + [(set (match_operand:DI 0 "nonimmediate_operand" "=&r,&r,rm, d, m, m")
7072 + (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%d,rm, 0, 0, d,rm")
7073 + (match_operand:DI 2 "ubicom32_arith_operand" "rmI, d, d,rmI,rmI, d")))
7074 + (clobber (reg:CC CC_REGNO))]
7078 + operands[3] = gen_lowpart (SImode, operands[0]);
7079 + operands[4] = gen_lowpart (SImode, operands[1]);
7080 + operands[5] = gen_lowpart (SImode, operands[2]);
7081 + operands[6] = gen_highpart (SImode, operands[0]);
7082 + operands[7] = gen_highpart (SImode, operands[1]);
7083 + operands[8] = gen_highpart_mode (SImode, DImode, operands[2]);
7085 + if (ubicom32_data_register_operand (operands[2], GET_MODE (operands[2])))
7086 + return \"add.4\\t%3, %4, %5\;addc\\t%6, %7, %8\";
7088 + return \"add.4\\t%3, %5, %4\;addc\\t%6, %8, %7\";
7090 + [(set_attr "length" "8")])
7092 +(define_insn "adddi3_ccwz"
7093 + [(set (reg CC_REGNO)
7095 + (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%d,rm, 0, 0, d,rm")
7096 + (match_operand:DI 2 "ubicom32_arith_operand" "rmI, d, d,rmI,rmI, d"))
7098 + (set (match_operand:DI 0 "nonimmediate_operand" "=&r,&r,rm, d, m, m")
7099 + (plus:DI (match_dup 1)
7101 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
7104 + operands[3] = gen_lowpart (SImode, operands[0]);
7105 + operands[6] = gen_highpart (SImode, operands[0]);
7107 + if (ubicom32_data_register_operand (operands[1], GET_MODE (operands[1])))
7109 + operands[4] = gen_lowpart (SImode, operands[1]);
7110 + operands[5] = gen_lowpart (SImode, operands[2]);
7111 + operands[7] = gen_highpart (SImode, operands[1]);
7112 + operands[8] = gen_highpart_mode (SImode, DImode, operands[2]);
7116 + operands[4] = gen_lowpart (SImode, operands[2]);
7117 + operands[5] = gen_lowpart (SImode, operands[1]);
7118 + operands[7] = gen_highpart (SImode, operands[2]);
7119 + operands[8] = gen_highpart (SImode, operands[1]);
7122 + return \"add.4\\t%3, %5, %4\;addc\\t%6, %8, %7\";
7124 + [(set_attr "length" "8")])
7126 +(define_insn "adddi3_ccwz_null"
7127 + [(set (reg CC_REGNO)
7129 + (neg:DI (match_operand:DI 0 "nonimmediate_operand" "%d,rm"))
7130 + (match_operand:DI 1 "ubicom32_arith_operand" "rmI, d")))]
7131 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
7134 + if (ubicom32_data_register_operand (operands[0], GET_MODE (operands[0])))
7136 + operands[2] = gen_lowpart (SImode, operands[0]);
7137 + operands[3] = gen_lowpart (SImode, operands[1]);
7138 + operands[4] = gen_highpart (SImode, operands[0]);
7139 + operands[5] = gen_highpart_mode (SImode, DImode, operands[1]);
7143 + operands[2] = gen_lowpart (SImode, operands[1]);
7144 + operands[3] = gen_lowpart (SImode, operands[0]);
7145 + operands[4] = gen_highpart (SImode, operands[1]);
7146 + operands[5] = gen_highpart (SImode, operands[0]);
7149 + return \"add.4\\t#0, %3, %2\;addc\\t#0, %5, %4\";
7151 + [(set_attr "length" "8")])
7153 +(define_expand "subqi3"
7155 + [(set (match_operand:QI 0 "memory_operand" "")
7156 + (minus:QI (match_operand:QI 1 "ubicom32_arith_operand" "")
7157 + (match_operand:QI 2 "ubicom32_data_register_operand" "")))
7158 + (clobber (reg:CC CC_REGNO))])]
7161 + if (!memory_operand (operands[0], QImode))
7165 +(define_insn "subqi3_sub1"
7166 + [(set (match_operand:QI 0 "memory_operand" "=m")
7167 + (minus:QI (match_operand:QI 1 "ubicom32_arith_operand" "rmI")
7168 + (match_operand:QI 2 "ubicom32_data_register_operand" "d")))
7169 + (clobber (reg:CC CC_REGNO))]
7171 + "sub.1\\t%0, %1, %2")
7173 +(define_expand "subhi3"
7175 + [(set (match_operand:HI 0 "memory_operand" "")
7176 + (minus:HI (match_operand:HI 1 "ubicom32_arith_operand" "")
7177 + (match_operand:HI 2 "ubicom32_data_register_operand" "")))
7178 + (clobber (reg:CC CC_REGNO))])]
7181 + if (!memory_operand (operands[0], HImode))
7185 +(define_insn "subhi3_sub2"
7186 + [(set (match_operand:HI 0 "memory_operand" "=m")
7187 + (minus:HI (match_operand:HI 1 "ubicom32_arith_operand" "rmI")
7188 + (match_operand:HI 2 "ubicom32_data_register_operand" "d")))
7189 + (clobber (reg:CC CC_REGNO))]
7191 + "sub.2\\t%0, %1, %2")
7193 +(define_insn "subsi3"
7194 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
7195 + (minus:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")
7196 + (match_operand:SI 2 "ubicom32_data_register_operand" "d")))
7197 + (clobber (reg:CC CC_REGNO))]
7199 + "sub.4\\t%0, %1, %2")
7201 +(define_insn "subsi3_ccwz"
7202 + [(set (reg CC_REGNO)
7204 + (minus:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")
7205 + (match_operand:SI 2 "ubicom32_data_register_operand" "d"))
7207 + (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
7208 + (minus:SI (match_dup 1)
7210 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
7211 + "sub.4\\t%0, %1, %2")
7213 +; We construct a 64-bit add from 32-bit operations. Note that we use the
7214 +; & constraint to prevent overlapping registers being allocated. We do
7215 +; allow identical registers though as that won't break anything.
7217 +(define_insn "subdi3"
7218 + [(set (match_operand:DI 0 "nonimmediate_operand" "=&r,r, d, m")
7219 + (minus:DI (match_operand:DI 1 "ubicom32_arith_operand" "rmI,0,rmI,rmI")
7220 + (match_operand:DI 2 "ubicom32_data_register_operand" "d,d, 0, d")))
7221 + (clobber (reg:CC CC_REGNO))]
7225 + operands[3] = gen_lowpart (SImode, operands[0]);
7226 + operands[4] = gen_lowpart (SImode, operands[1]);
7227 + operands[5] = gen_lowpart (SImode, operands[2]);
7228 + operands[6] = gen_highpart (SImode, operands[0]);
7229 + operands[7] = gen_highpart_mode (SImode, DImode, operands[1]);
7230 + operands[8] = gen_highpart (SImode, operands[2]);
7232 + return \"sub.4\\t%3, %4, %5\;subc\\t%6, %7, %8\";
7234 + [(set_attr "length" "8")])
7236 +(define_insn "subdi3_ccwz"
7237 + [(set (reg CC_REGNO)
7239 + (minus:DI (match_operand:DI 1 "ubicom32_arith_operand" "rmI,rmI")
7240 + (match_operand:DI 2 "ubicom32_data_register_operand" "d, d"))
7242 + (set (match_operand:DI 0 "nonimmediate_operand" "=&r, m")
7243 + (minus:DI (match_dup 1)
7245 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
7248 + operands[3] = gen_lowpart (SImode, operands[0]);
7249 + operands[4] = gen_lowpart (SImode, operands[1]);
7250 + operands[5] = gen_lowpart (SImode, operands[2]);
7251 + operands[6] = gen_highpart (SImode, operands[0]);
7252 + operands[7] = gen_highpart_mode (SImode, DImode, operands[1]);
7253 + operands[8] = gen_highpart (SImode, operands[2]);
7255 + return \"sub.4\\t%3, %4, %5\;subc\\t%6, %7, %8\";
7257 + [(set_attr "length" "8")])
7259 +;(define_insn "negqi2"
7260 +; [(set (match_operand:QI 0 "nonimmediate_operand" "=rm")
7261 +; (neg:QI (match_operand:QI 1 "ubicom32_data_register_operand" "d")))
7262 +; (clobber (reg:CC CC_REGNO))]
7264 +; "sub.1\\t%0, #0, %1")
7266 +;(define_insn "neghi2"
7267 +; [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
7268 +; (neg:HI (match_operand:HI 1 "ubicom32_data_register_operand" "d")))
7269 +; (clobber (reg:CC CC_REGNO))]
7271 +; "sub.2\\t%0, #0, %1")
7273 +(define_insn "negsi2"
7274 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
7275 + (neg:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")))
7276 + (clobber (reg:CC CC_REGNO))]
7278 + "sub.4\\t%0, #0, %1")
7280 +(define_insn_and_split "negdi2"
7281 + [(set (match_operand:DI 0 "nonimmediate_operand" "=&rm")
7282 + (neg:DI (match_operand:DI 1 "ubicom32_data_register_operand" "d")))
7283 + (clobber (reg:CC CC_REGNO))]
7286 + "reload_completed"
7287 + [(parallel [(set (match_dup 0)
7288 + (minus:DI (const_int 0)
7290 + (clobber (reg:CC CC_REGNO))])]
7292 + [(set_attr "length" "8")])
7294 +(define_insn "umulhisi3"
7295 + [(set (match_operand:SI 0 "ubicom32_acc_lo_register_operand" "=l, l")
7297 + (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "%d,rm"))
7298 + (zero_extend:SI (match_operand:HI 2 "nonimmediate_operand" "rm, d"))))
7299 + (clobber (reg:HI ACC0_HI_REGNO))
7300 + (clobber (reg:HI ACC1_HI_REGNO))]
7303 + mulu\\t%A0, %2, %1
7304 + mulu\\t%A0, %1, %2"
7305 + [(set_attr "type" "mul,mul")])
7307 +(define_insn "mulhisi3"
7308 + [(set (match_operand:SI 0 "ubicom32_acc_lo_register_operand" "=l, l")
7310 + (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "%d,rm"))
7311 + (sign_extend:SI (match_operand:HI 2 "nonimmediate_operand" "rm, d"))))
7312 + (clobber (reg:HI ACC0_HI_REGNO))
7313 + (clobber (reg:HI ACC1_HI_REGNO))]
7316 + muls\\t%A0, %2, %1
7317 + muls\\t%A0, %1, %2"
7318 + [(set_attr "type" "mul,mul")])
7320 +(define_expand "mulsi3"
7321 + [(set (match_operand:SI 0 "ubicom32_acc_hi_register_operand" "")
7322 + (mult:SI (match_operand:SI 1 "ubicom32_arith_operand" "")
7323 + (match_operand:SI 2 "ubicom32_arith_operand" "")))]
7326 + if (ubicom32_emit_mult_sequence (operands))
7330 +(define_insn "umulsidi3"
7331 + [(set (match_operand:DI 0 "ubicom32_acc_hi_register_operand" "=h, h")
7333 + (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "%d,rm"))
7334 + (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm, d"))))]
7337 + mulu.4\\t%A0, %2, %1
7338 + mulu.4\\t%A0, %1, %2"
7339 + [(set_attr "type" "mul,mul")])
7342 + [(set (match_operand:SI 0 "register_operand" "")
7343 + (match_operand:SI 1 "nonimmediate_operand" ""))
7344 + (set (match_operand:DI 2 "ubicom32_acc_hi_register_operand" "")
7346 + (zero_extend:DI (match_dup 0))
7347 + (zero_extend:DI (match_operand:SI 3 "ubicom32_data_register_operand" ""))))]
7348 + "(peep2_reg_dead_p (2, operands[0])
7349 + || REGNO (operands[0]) == REGNO (operands[2])
7350 + || REGNO (operands[0]) == REGNO (operands[2]) + 1)
7351 + && ! rtx_equal_p (operands[0], operands[3])"
7352 + [(set (match_dup 2)
7354 + (zero_extend:DI (match_dup 1))
7355 + (zero_extend:DI (match_dup 3))))]
7359 + [(set (match_operand:SI 0 "register_operand" "")
7360 + (match_operand:SI 1 "nonimmediate_operand" ""))
7361 + (set (match_operand:DI 2 "ubicom32_acc_hi_register_operand" "")
7363 + (zero_extend:DI (match_operand:SI 3 "ubicom32_data_register_operand" ""))
7364 + (zero_extend:DI (match_dup 0))))]
7365 + "(peep2_reg_dead_p (2, operands[0])
7366 + || REGNO (operands[0]) == REGNO (operands[2])
7367 + || REGNO (operands[0]) == REGNO (operands[2]) + 1)
7368 + && ! rtx_equal_p (operands[0], operands[3])"
7369 + [(set (match_dup 2)
7371 + (zero_extend:DI (match_dup 1))
7372 + (zero_extend:DI (match_dup 3))))]
7375 +(define_insn "umulsidi3_const"
7376 + [(set (match_operand:DI 0 "ubicom32_acc_hi_register_operand" "=h")
7378 + (zero_extend:DI (match_operand:SI 1 "ubicom32_data_register_operand" "%d"))
7379 + (match_operand 2 "const_int_operand" "I")))]
7380 + "(ubicom32_v4 && satisfies_constraint_I (operands[2]))"
7381 + "mulu.4\\t%A0, %2, %1"
7382 + [(set_attr "type" "mul")])
7384 +(define_insn "mulsidi3"
7385 + [(set (match_operand:DI 0 "ubicom32_acc_hi_register_operand" "=h, h")
7387 + (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "%d,rm"))
7388 + (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm, d"))))]
7391 + muls.4\\t%A0, %2, %1
7392 + muls.4\\t%A0, %1, %2"
7393 + [(set_attr "type" "mul,mul")])
7396 + [(set (match_operand:SI 0 "register_operand" "")
7397 + (match_operand:SI 1 "nonimmediate_operand" ""))
7398 + (set (match_operand:DI 2 "ubicom32_acc_hi_register_operand" "")
7400 + (sign_extend:DI (match_dup 0))
7401 + (sign_extend:DI (match_operand:SI 3 "ubicom32_data_register_operand" ""))))]
7402 + "(peep2_reg_dead_p (2, operands[0])
7403 + || REGNO (operands[0]) == REGNO (operands[2])
7404 + || REGNO (operands[0]) == REGNO (operands[2]) + 1)
7405 + && ! rtx_equal_p (operands[0], operands[3])"
7406 + [(set (match_dup 2)
7408 + (sign_extend:DI (match_dup 1))
7409 + (sign_extend:DI (match_dup 3))))]
7413 + [(set (match_operand:SI 0 "register_operand" "")
7414 + (match_operand:SI 1 "nonimmediate_operand" ""))
7415 + (set (match_operand:DI 2 "ubicom32_acc_hi_register_operand" "")
7417 + (sign_extend:DI (match_operand:SI 3 "ubicom32_data_register_operand" ""))
7418 + (sign_extend:DI (match_dup 0))))]
7419 + "(peep2_reg_dead_p (2, operands[0])
7420 + || REGNO (operands[0]) == REGNO (operands[2])
7421 + || REGNO (operands[0]) == REGNO (operands[2]) + 1)
7422 + && ! rtx_equal_p (operands[0], operands[3])"
7423 + [(set (match_dup 2)
7425 + (sign_extend:DI (match_dup 1))
7426 + (sign_extend:DI (match_dup 3))))]
7429 +(define_insn "mulsidi3_const"
7430 + [(set (match_operand:DI 0 "ubicom32_acc_hi_register_operand" "=h")
7432 + (sign_extend:DI (match_operand:SI 1 "ubicom32_data_register_operand" "%d"))
7433 + (match_operand 2 "const_int_operand" "I")))]
7434 + "(ubicom32_v4 && satisfies_constraint_I (operands[2]))"
7435 + "muls.4\\t%A0, %2, %1"
7436 + [(set_attr "type" "mul")])
7438 +(define_expand "andqi3"
7440 + [(set (match_operand:QI 0 "memory_operand" "")
7441 + (and:QI (match_operand:QI 1 "nonimmediate_operand" "")
7442 + (match_operand:QI 2 "ubicom32_arith_operand" "")))
7443 + (clobber (reg:CC CC_REGNO))])]
7446 + if (!memory_operand (operands[0], QImode))
7449 + /* If we have a non-data reg for operand 1 then prefer that over
7450 + a CONST_INT in operand 2. */
7451 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
7452 + && CONST_INT_P (operands[2]))
7453 + operands[2] = copy_to_mode_reg (QImode, operands[2]);
7455 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
7456 + operands[2] = copy_to_mode_reg (QImode, operands[2]);
7459 +(define_insn "andqi3_and1"
7460 + [(set (match_operand:QI 0 "memory_operand" "=m, m")
7461 + (and:QI (match_operand:QI 1 "nonimmediate_operand" "%d,rm")
7462 + (match_operand:QI 2 "ubicom32_arith_operand" "rmI, d")))
7463 + (clobber (reg:CC CC_REGNO))]
7466 + and.1\\t%0, %2, %1
7467 + and.1\\t%0, %1, %2")
7469 +(define_insn "andqi3_and1_ccszn"
7470 + [(set (reg CC_REGNO)
7472 + (and:QI (match_operand:QI 1 "nonimmediate_operand" "%d,rm")
7473 + (match_operand:QI 2 "ubicom32_arith_operand" "rmI, d"))
7475 + (set (match_operand:QI 0 "memory_operand" "=m, m")
7476 + (and:QI (match_dup 1)
7479 + && ubicom32_match_cc_mode(insn, CCSZNmode))"
7481 + and.1\\t%0, %2, %1
7482 + and.1\\t%0, %1, %2")
7484 +(define_insn "andqi3_and1_ccszn_null"
7485 + [(set (reg CC_REGNO)
7487 + (and:QI (match_operand:QI 0 "nonimmediate_operand" "%d,rm")
7488 + (match_operand:QI 1 "ubicom32_arith_operand" "rmI, d"))
7491 + && ubicom32_match_cc_mode(insn, CCSZNmode))"
7493 + and.1\\t#0, %1, %0
7494 + and.1\\t#0, %0, %1")
7496 +(define_insn "and1_ccszn_null_1"
7497 + [(set (reg CC_REGNO)
7500 + (and:SI (match_operand:SI 0 "ubicom32_data_register_operand" "%d")
7501 + (match_operand:SI 1 "ubicom32_arith_operand" "rI"))
7505 + && ubicom32_match_cc_mode(insn, CCSZNmode))"
7506 + "and.1\\t#0, %1, %0")
7508 +(define_insn "and1_ccszn_null_2"
7509 + [(set (reg CC_REGNO)
7512 + (and:SI (match_operand:SI 0 "ubicom32_data_register_operand" "d")
7514 + (match_operand:QI 1 "memory_operand" "m")
7519 + && ubicom32_match_cc_mode(insn, CCSZNmode))"
7520 + "and.1\\t#0, %1, %0")
7522 +(define_insn "and1_ccszn_null_3"
7523 + [(set (reg CC_REGNO)
7526 + (and:SI (subreg:SI
7527 + (match_operand:QI 0 "memory_operand" "m")
7529 + (match_operand:SI 1 "ubicom32_data_register_operand" "d"))
7533 + && ubicom32_match_cc_mode(insn, CCSZNmode))"
7534 + "and.1\\t#0, %0, %1")
7536 +(define_expand "andhi3"
7538 + [(set (match_operand:HI 0 "memory_operand" "")
7539 + (and:HI (match_operand:HI 1 "nonimmediate_operand" "")
7540 + (match_operand:HI 2 "ubicom32_arith_operand" "")))
7541 + (clobber (reg:CC CC_REGNO))])]
7544 + if (!memory_operand (operands[0], HImode))
7547 + /* If we have a non-data reg for operand 1 then prefer that over
7548 + a CONST_INT in operand 2. */
7549 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
7550 + && CONST_INT_P (operands[2]))
7551 + operands[2] = copy_to_mode_reg (HImode, operands[2]);
7553 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
7554 + operands[2] = copy_to_mode_reg (HImode, operands[2]);
7557 +(define_insn "andhi3_and2"
7558 + [(set (match_operand:HI 0 "memory_operand" "=m, m")
7559 + (and:HI (match_operand:HI 1 "nonimmediate_operand" "%d,rm")
7560 + (match_operand:HI 2 "ubicom32_arith_operand" "rmI, d")))
7561 + (clobber (reg:CC CC_REGNO))]
7564 + and.2\\t%0, %2, %1
7565 + and.2\\t%0, %1, %2")
7567 +(define_insn "andhi3_and2_ccszn"
7568 + [(set (reg CC_REGNO)
7570 + (and:HI (match_operand:HI 1 "nonimmediate_operand" "%d,rm")
7571 + (match_operand:HI 2 "ubicom32_arith_operand" "rmI, d"))
7573 + (set (match_operand:HI 0 "memory_operand" "=m, m")
7574 + (and:HI (match_dup 1)
7576 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
7578 + and.2\\t%0, %2, %1
7579 + and.2\\t%0, %1, %2")
7581 +(define_insn "andhi3_and2_ccszn_null"
7582 + [(set (reg CC_REGNO)
7584 + (and:HI (match_operand:HI 0 "nonimmediate_operand" "%d,rm")
7585 + (match_operand:HI 1 "ubicom32_arith_operand" "rmI, d"))
7587 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
7589 + and.2\\t#0, %1, %0
7590 + and.2\\t#0, %0, %1")
7592 +(define_insn "and2_ccszn_null_1"
7593 + [(set (reg CC_REGNO)
7596 + (and:SI (match_operand:SI 0 "ubicom32_data_register_operand" "%d")
7597 + (match_operand:SI 1 "ubicom32_arith_operand" "rI"))
7600 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
7601 + "and.2\\t#0, %1, %0")
7603 +(define_insn "and2_ccszn_null_2"
7604 + [(set (reg CC_REGNO)
7607 + (and:SI (match_operand:SI 0 "ubicom32_data_register_operand" "d")
7609 + (match_operand:HI 1 "memory_operand" "m")
7613 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
7614 + "and.2\\t#0, %1, %0")
7616 +(define_insn "and2_ccszn_null_3"
7617 + [(set (reg CC_REGNO)
7620 + (and:SI (subreg:SI
7621 + (match_operand:HI 0 "memory_operand" "m")
7623 + (match_operand:SI 1 "ubicom32_data_register_operand" "d"))
7626 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
7627 + "and.2\\t#0, %0, %1")
7629 +(define_expand "andsi3"
7631 + [(set (match_operand:SI 0 "nonimmediate_operand" "")
7632 + (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
7633 + (match_operand:SI 2 "ubicom32_and_or_si3_operand" "")))
7634 + (clobber (reg:CC CC_REGNO))])]
7639 + /* Is this a bfextu? */
7640 + if (ubicom32_data_register_operand (operands[0], SImode)
7641 + && CONST_INT_P (operands[2])
7642 + && exact_log2 (INTVAL (operands[2]) + 1) != -1)
7645 + /* Is this a bclr? */
7646 + if (CONST_INT_P (operands[2])
7647 + && exact_log2 (~INTVAL (operands[2])) != -1)
7650 + /* Must be an and.4 */
7651 + if (!ubicom32_data_register_operand (operands[1], SImode))
7652 + operands[1] = copy_to_mode_reg (SImode, operands[1]);
7654 + if (!ubicom32_arith_operand (operands[2], SImode))
7655 + operands[2] = copy_to_mode_reg (SImode, operands[2]);
7660 +(define_insn "andsi3_bfextu"
7661 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
7662 + (and:SI (match_operand:SI 1 "nonimmediate_operand" "%rm")
7663 + (match_operand:SI 2 "const_int_operand" "O")))
7664 + (clobber (reg:CC CC_REGNO))]
7665 + "(satisfies_constraint_O (operands[2]))"
7668 + operands[3] = GEN_INT (exact_log2 (INTVAL (operands[2]) + 1));
7670 + return \"bfextu\\t%0, %1, %3\";
7673 +(define_insn "andsi3_bfextu_ccwz"
7674 + [(set (reg CC_REGNO)
7676 + (and:SI (match_operand:SI 1 "nonimmediate_operand" "%rm")
7677 + (match_operand:SI 2 "const_int_operand" "O"))
7679 + (set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
7680 + (and:SI (match_dup 1)
7682 + "(satisfies_constraint_O (operands[2])
7683 + && ubicom32_match_cc_mode(insn, CCWZmode))"
7686 + operands[3] = GEN_INT (exact_log2 (INTVAL (operands[2]) + 1));
7688 + return \"bfextu\\t%0, %1, %3\";
7691 +(define_insn "andsi3_bfextu_ccwz_null"
7692 + [(set (reg CC_REGNO)
7694 + (and:SI (match_operand:SI 0 "nonimmediate_operand" "%rm")
7695 + (match_operand:SI 1 "const_int_operand" "O"))
7697 + (clobber (match_scratch:SI 2 "=d"))]
7698 + "(satisfies_constraint_O (operands[1])
7699 + && ubicom32_match_cc_mode(insn, CCWZmode))"
7702 + operands[3] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
7704 + return \"bfextu\\t%2, %0, %3\";
7707 +(define_insn "andsi3_bclr"
7708 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
7709 + (and:SI (match_operand:SI 1 "ubicom32_arith_operand" "%rmI")
7710 + (match_operand:SI 2 "const_int_operand" "n")))
7711 + (clobber (reg:CC CC_REGNO))]
7712 + "(exact_log2 (~INTVAL (operands[2])) != -1)"
7713 + "bclr\\t%0, %1, #%D2")
7715 +(define_insn "andsi3_and4"
7716 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
7717 + (and:SI (match_operand:SI 1 "nonimmediate_operand" "%d,rm")
7718 + (match_operand:SI 2 "ubicom32_arith_operand" "rmI, d")))
7719 + (clobber (reg:CC CC_REGNO))]
7722 + and.4\\t%0, %2, %1
7723 + and.4\\t%0, %1, %2")
7725 +(define_insn "andsi3_and4_ccwzn"
7726 + [(set (reg CC_REGNO)
7728 + (and:SI (match_operand:SI 1 "nonimmediate_operand" "%d,rm")
7729 + (match_operand:SI 2 "ubicom32_arith_operand" "rmI, d"))
7731 + (set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
7732 + (and:SI (match_dup 1)
7734 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
7736 + and.4\\t%0, %2, %1
7737 + and.4\\t%0, %1, %2")
7739 +(define_insn "andsi3_and4_ccwzn_null"
7740 + [(set (reg CC_REGNO)
7742 + (and:SI (match_operand:SI 0 "nonimmediate_operand" "%d,rm")
7743 + (match_operand:SI 1 "ubicom32_arith_operand" "rmI, d"))
7745 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
7747 + and.4\\t#0, %1, %0
7748 + and.4\\t#0, %0, %1")
7750 +(define_insn "andsi3_lsr4_ccwz_null"
7751 + [(set (reg CC_REGNO)
7753 + (and:SI (match_operand:SI 0 "nonimmediate_operand" "%rm")
7754 + (match_operand:SI 1 "const_int_operand" "n"))
7756 + (clobber (match_scratch:SI 2 "=d"))]
7757 + "(exact_log2 ((~(INTVAL (operands[1]))) + 1) != -1
7758 + && ubicom32_match_cc_mode(insn, CCWZmode))"
7761 + operands[3] = GEN_INT (exact_log2 ((~(INTVAL (operands[1]))) + 1));
7763 + return \"lsr.4\\t%2, %0, %3\";
7766 +; We really would like the combiner to recognize this scenario and deal with
7767 +; it but unfortunately it tries to canonicalize zero_extract ops on MEMs
7768 +; into QImode operations and we can't match them in any useful way.
7771 + [(set (match_operand:SI 0 "register_operand" "")
7772 + (match_operand:SI 1 "const_int_operand" ""))
7773 + (set (reg:CCWZ CC_REGNO)
7775 + (and:SI (match_operand:SI 2 "nonimmediate_operand" "")
7778 + "(exact_log2 (INTVAL (operands[1])) != -1
7779 + && peep2_reg_dead_p (2, operands[0]))"
7780 + [(set (reg:CCWZ CC_REGNO)
7788 + operands[3] = GEN_INT (exact_log2 (INTVAL (operands[1])));
7791 +(define_expand "anddi3"
7793 + [(set (match_operand:DI 0 "nonimmediate_operand" "")
7794 + (and:DI (match_operand:DI 1 "nonimmediate_operand" "")
7795 + (match_operand:DI 2 "ubicom32_arith_operand" "")))
7796 + (clobber (reg:CC CC_REGNO))])]
7799 + /* If we have a non-data reg for operand 1 then prefer that over
7800 + a CONST_INT in operand 2. */
7801 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
7802 + && CONST_INT_P (operands[2]))
7803 + operands[2] = copy_to_mode_reg (DImode, operands[2]);
7805 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
7806 + operands[2] = copy_to_mode_reg (DImode, operands[2]);
7809 +(define_insn_and_split "anddi3_and4"
7810 + [(set (match_operand:DI 0 "nonimmediate_operand" "=&r,&r, d,rm, m, m")
7811 + (and:DI (match_operand:DI 1 "nonimmediate_operand" "%d,rm, 0, 0, d,rm")
7812 + (match_operand:DI 2 "ubicom32_arith_operand" "rmI, d,rmI, d,rmI, d")))
7813 + (clobber (reg:CC CC_REGNO))]
7816 + "reload_completed"
7817 + [(parallel [(set (match_dup 3)
7818 + (and:SI (match_dup 4)
7820 + (clobber (reg:CC CC_REGNO))])
7821 + (parallel [(set (match_dup 6)
7822 + (and:SI (match_dup 7)
7824 + (clobber (reg:CC CC_REGNO))])]
7826 + operands[3] = gen_lowpart (SImode, operands[0]);
7827 + operands[4] = gen_lowpart (SImode, operands[1]);
7828 + operands[5] = gen_lowpart (SImode, operands[2]);
7829 + operands[6] = gen_highpart (SImode, operands[0]);
7830 + operands[7] = gen_highpart (SImode, operands[1]);
7831 + operands[8] = gen_highpart_mode (SImode, DImode, operands[2]);
7833 + [(set_attr "length" "8")])
7835 +(define_expand "iorqi3"
7837 + [(set (match_operand:QI 0 "memory_operand" "")
7838 + (ior:QI (match_operand:QI 1 "nonimmediate_operand" "")
7839 + (match_operand:QI 2 "ubicom32_arith_operand" "")))
7840 + (clobber (reg:CC CC_REGNO))])]
7843 + if (!memory_operand (operands[0], QImode))
7846 + /* If we have a non-data reg for operand 1 then prefer that over
7847 + a CONST_INT in operand 2. */
7848 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
7849 + && CONST_INT_P (operands[2]))
7850 + operands[2] = copy_to_mode_reg (QImode, operands[2]);
7852 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
7853 + operands[2] = copy_to_mode_reg (QImode, operands[2]);
7856 +(define_insn "iorqi3_or1"
7857 + [(set (match_operand:QI 0 "memory_operand" "=m, m")
7858 + (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%d,rm")
7859 + (match_operand:QI 2 "ubicom32_arith_operand" "rmI, d")))
7860 + (clobber (reg:CC CC_REGNO))]
7864 + or.1\\t%0, %1, %2")
7866 +(define_expand "iorhi3"
7868 + [(set (match_operand:HI 0 "memory_operand" "")
7869 + (ior:HI (match_operand:HI 1 "nonimmediate_operand" "")
7870 + (match_operand:HI 2 "ubicom32_arith_operand" "")))
7871 + (clobber (reg:CC CC_REGNO))])]
7874 + if (!memory_operand (operands[0], HImode))
7877 + /* If we have a non-data reg for operand 1 then prefer that over
7878 + a CONST_INT in operand 2. */
7879 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
7880 + && CONST_INT_P (operands[2]))
7881 + operands[2] = copy_to_mode_reg (HImode, operands[2]);
7883 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
7884 + operands[2] = copy_to_mode_reg (HImode, operands[2]);
7887 +(define_insn "iorhi3_or2"
7888 + [(set (match_operand:HI 0 "memory_operand" "=m, m")
7889 + (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%d,rm")
7890 + (match_operand:HI 2 "ubicom32_arith_operand" "rmI, d")))
7891 + (clobber (reg:CC CC_REGNO))]
7895 + or.2\\t%0, %1, %2")
7897 +(define_expand "iorsi3"
7899 + [(set (match_operand:SI 0 "nonimmediate_operand" "")
7900 + (ior:SI (match_operand:SI 1 "nonimmediate_operand" "")
7901 + (match_operand:SI 2 "ubicom32_and_or_si3_operand" "")))
7902 + (clobber (reg:CC CC_REGNO))])]
7907 + /* Is this a bset? */
7908 + if (CONST_INT_P (operands[2])
7909 + && exact_log2 (INTVAL (operands[2])) != -1)
7912 + /* Must be an or.4 */
7913 + if (!ubicom32_data_register_operand (operands[1], SImode))
7914 + operands[1] = copy_to_mode_reg (SImode, operands[1]);
7916 + if (!ubicom32_arith_operand (operands[2], SImode))
7917 + operands[2] = copy_to_mode_reg (SImode, operands[2]);
7922 +(define_insn "iorsi3_bset"
7923 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
7924 + (ior:SI (match_operand:SI 1 "ubicom32_arith_operand" "%rmI")
7925 + (match_operand 2 "const_int_operand" "n")))
7926 + (clobber (reg:CC CC_REGNO))]
7927 + "(exact_log2 (INTVAL (operands[2])) != -1)"
7928 + "bset\\t%0, %1, #%d2")
7930 +(define_insn "iorsi3_or4"
7931 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
7932 + (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%d,rm")
7933 + (match_operand:SI 2 "ubicom32_arith_operand" "rmI, d")))
7934 + (clobber (reg:CC CC_REGNO))]
7938 + or.4\\t%0, %1, %2")
7940 +(define_insn "iorsi3_ccwzn"
7941 + [(set (reg CC_REGNO)
7943 + (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%d,rm")
7944 + (match_operand:SI 2 "ubicom32_arith_operand" "rmI, d"))
7946 + (set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
7947 + (ior:SI (match_dup 1)
7949 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
7952 + or.4\\t%0, %1, %2")
7954 +(define_insn "iorsi3_ccwzn_null"
7955 + [(set (reg CC_REGNO)
7957 + (ior:SI (match_operand:SI 0 "nonimmediate_operand" "%d,rm")
7958 + (match_operand:SI 1 "ubicom32_arith_operand" "rmI, d"))
7960 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
7963 + or.4\\t#0, %0, %1")
7965 +(define_expand "iordi3"
7967 + [(set (match_operand:DI 0 "nonimmediate_operand" "")
7968 + (ior:DI (match_operand:DI 1 "nonimmediate_operand" "")
7969 + (match_operand:DI 2 "ubicom32_arith_operand" "")))
7970 + (clobber (reg:CC CC_REGNO))])]
7973 + /* If we have a non-data reg for operand 1 then prefer that over
7974 + a CONST_INT in operand 2. */
7975 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
7976 + && CONST_INT_P (operands[2]))
7977 + operands[2] = copy_to_mode_reg (DImode, operands[2]);
7979 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
7980 + operands[2] = copy_to_mode_reg (DImode, operands[2]);
7983 +(define_insn_and_split "iordi3_or4"
7984 + [(set (match_operand:DI 0 "nonimmediate_operand" "=&r,&r, d,rm, m, m")
7985 + (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%d,rm, 0, 0, d,rm")
7986 + (match_operand:DI 2 "ubicom32_arith_operand" "rmI, d,rmI, d,rmI, d")))
7987 + (clobber (reg:CC CC_REGNO))]
7990 + "reload_completed"
7991 + [(parallel [(set (match_dup 3)
7992 + (ior:SI (match_dup 4)
7994 + (clobber (reg:CC CC_REGNO))])
7995 + (parallel [(set (match_dup 6)
7996 + (ior:SI (match_dup 7)
7998 + (clobber (reg:CC CC_REGNO))])]
8000 + operands[3] = gen_lowpart (SImode, operands[0]);
8001 + operands[4] = gen_lowpart (SImode, operands[1]);
8002 + operands[5] = gen_lowpart (SImode, operands[2]);
8003 + operands[6] = gen_highpart (SImode, operands[0]);
8004 + operands[7] = gen_highpart (SImode, operands[1]);
8005 + operands[8] = gen_highpart_mode (SImode, DImode, operands[2]);
8007 + [(set_attr "length" "8")])
8009 +(define_expand "xorqi3"
8011 + [(set (match_operand:QI 0 "memory_operand" "")
8012 + (xor:QI (match_operand:QI 1 "nonimmediate_operand" "")
8013 + (match_operand:QI 2 "ubicom32_arith_operand" "")))
8014 + (clobber (reg:CC CC_REGNO))])]
8017 + if (!memory_operand (operands[0], QImode))
8020 + /* If we have a non-data reg for operand 1 then prefer that over
8021 + a CONST_INT in operand 2. */
8022 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
8023 + && CONST_INT_P (operands[2]))
8024 + operands[2] = copy_to_mode_reg (QImode, operands[2]);
8026 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
8027 + operands[2] = copy_to_mode_reg (QImode, operands[2]);
8030 +(define_insn "xorqi3_xor1"
8031 + [(set (match_operand:QI 0 "memory_operand" "=m, m")
8032 + (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%d,rm")
8033 + (match_operand:QI 2 "ubicom32_arith_operand" "rmI, d")))
8034 + (clobber (reg:CC CC_REGNO))]
8037 + xor.1\\t%0, %2, %1
8038 + xor.1\\t%0, %1, %2")
8040 +(define_insn "xorqi3_xor1_ccszn"
8041 + [(set (reg CC_REGNO)
8043 + (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%d,rm")
8044 + (match_operand:QI 2 "ubicom32_arith_operand" "rmI, d"))
8046 + (set (match_operand:QI 0 "memory_operand" "=m, m")
8047 + (xor:QI (match_dup 1)
8050 + && ubicom32_match_cc_mode(insn, CCSZNmode))"
8052 + xor.1\\t%0, %2, %1
8053 + xor.1\\t%0, %1, %2")
8055 +(define_insn "xorqi3_xor1_ccszn_null"
8056 + [(set (reg CC_REGNO)
8058 + (xor:QI (match_operand:QI 0 "nonimmediate_operand" "%d,rm")
8059 + (match_operand:QI 1 "ubicom32_arith_operand" "rmI, d"))
8062 + && ubicom32_match_cc_mode(insn, CCSZNmode))"
8064 + xor.1\\t#0, %1, %0
8065 + xor.1\\t#0, %0, %1")
8067 +(define_insn "xor1_ccszn_null_1"
8068 + [(set (reg CC_REGNO)
8071 + (xor:SI (match_operand:SI 0 "ubicom32_data_register_operand" "%d")
8072 + (match_operand:SI 1 "ubicom32_arith_operand" "rI"))
8076 + && ubicom32_match_cc_mode(insn, CCSZNmode))"
8077 + "xor.1\\t#0, %1, %0")
8079 +(define_insn "xor1_ccszn_null_2"
8080 + [(set (reg CC_REGNO)
8083 + (xor:SI (match_operand:SI 0 "ubicom32_data_register_operand" "d")
8085 + (match_operand:QI 1 "memory_operand" "m")
8090 + && ubicom32_match_cc_mode(insn, CCSZNmode))"
8091 + "xor.1\\t#0, %1, %0")
8093 +(define_insn "xor1_ccwzn_null_3"
8094 + [(set (reg CC_REGNO)
8097 + (xor:SI (subreg:SI
8098 + (match_operand:QI 0 "memory_operand" "m")
8100 + (match_operand:SI 1 "ubicom32_data_register_operand" "d"))
8104 + && ubicom32_match_cc_mode(insn, CCSZNmode))"
8105 + "xor.1\\t#0, %0, %1")
8107 +(define_expand "xorhi3"
8109 + [(set (match_operand:HI 0 "memory_operand" "")
8110 + (xor:HI (match_operand:HI 1 "nonimmediate_operand" "")
8111 + (match_operand:HI 2 "ubicom32_arith_operand" "")))
8112 + (clobber (reg:CC CC_REGNO))])]
8115 + if (!memory_operand (operands[0], HImode))
8118 + /* If we have a non-data reg for operand 1 then prefer that over
8119 + a CONST_INT in operand 2. */
8120 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
8121 + && CONST_INT_P (operands[2]))
8122 + operands[2] = copy_to_mode_reg (HImode, operands[2]);
8124 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
8125 + operands[2] = copy_to_mode_reg (HImode, operands[2]);
8128 +(define_insn "xorhi3_xor2"
8129 + [(set (match_operand:HI 0 "memory_operand" "=m, m")
8130 + (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%d,rm")
8131 + (match_operand:HI 2 "ubicom32_arith_operand" "rmI, d")))
8132 + (clobber (reg:CC CC_REGNO))]
8135 + xor.2\\t%0, %2, %1
8136 + xor.2\\t%0, %1, %2")
8138 +(define_insn "xorhi3_xor2_ccszn"
8139 + [(set (reg CC_REGNO)
8141 + (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%d,rm")
8142 + (match_operand:HI 2 "ubicom32_arith_operand" "rmI, d"))
8144 + (set (match_operand:HI 0 "memory_operand" "=m, m")
8145 + (xor:HI (match_dup 1)
8147 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
8149 + xor.2\\t%0, %2, %1
8150 + xor.2\\t%0, %1, %2")
8152 +(define_insn "xorhi3_xor2_ccszn_null"
8153 + [(set (reg CC_REGNO)
8155 + (xor:HI (match_operand:HI 0 "nonimmediate_operand" "%d,rm")
8156 + (match_operand:HI 1 "ubicom32_arith_operand" "rmI, d"))
8158 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
8160 + xor.2\\t#0, %1, %0
8161 + xor.2\\t#0, %0, %1")
8163 +(define_insn "xor2_ccszn_null_1"
8164 + [(set (reg CC_REGNO)
8167 + (xor:SI (match_operand:SI 0 "ubicom32_data_register_operand" "%d")
8168 + (match_operand:SI 1 "ubicom32_arith_operand" "rI"))
8171 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
8172 + "xor.2\\t#0, %1, %0")
8174 +(define_insn "xor2_ccszn_null_2"
8175 + [(set (reg CC_REGNO)
8178 + (xor:SI (match_operand:SI 0 "ubicom32_data_register_operand" "d")
8180 + (match_operand:HI 1 "memory_operand" "m")
8184 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
8185 + "xor.2\\t#0, %1, %0")
8187 +(define_insn "xor2_ccszn_null_3"
8188 + [(set (reg CC_REGNO)
8191 + (xor:SI (subreg:SI
8192 + (match_operand:HI 0 "memory_operand" "m")
8194 + (match_operand:SI 1 "ubicom32_data_register_operand" "d"))
8197 + "ubicom32_match_cc_mode(insn, CCSZNmode)"
8198 + "xor.2\\t#0, %0, %1")
8200 +(define_insn "xorsi3"
8201 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
8202 + (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%d,rm")
8203 + (match_operand:SI 2 "ubicom32_arith_operand" "rmI, d")))
8204 + (clobber (reg:CC CC_REGNO))]
8207 + xor.4\\t%0, %2, %1
8208 + xor.4\\t%0, %1, %2")
8210 +(define_insn "xorsi3_ccwzn"
8211 + [(set (reg CC_REGNO)
8213 + (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%d,rm")
8214 + (match_operand:SI 2 "ubicom32_arith_operand" "rmI, d"))
8216 + (set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
8217 + (xor:SI (match_dup 1)
8219 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
8221 + xor.4\\t%0, %2, %1
8222 + xor.4\\t%0, %1, %2")
8224 +(define_insn "xorsi3_ccwzn_null"
8225 + [(set (reg CC_REGNO)
8227 + (xor:SI (match_operand:SI 0 "nonimmediate_operand" "%d,rm")
8228 + (match_operand:SI 1 "ubicom32_arith_operand" "rmI, d"))
8230 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
8232 + xor.4\\t#0, %1, %0
8233 + xor.4\\t#0, %0, %1")
8235 +(define_expand "xordi3"
8237 + [(set (match_operand:DI 0 "nonimmediate_operand" "")
8238 + (xor:DI (match_operand:DI 1 "nonimmediate_operand" "")
8239 + (match_operand:DI 2 "ubicom32_arith_operand" "")))
8240 + (clobber (reg:CC CC_REGNO))])]
8243 + /* If we have a non-data reg for operand 1 then prefer that over
8244 + a CONST_INT in operand 2. */
8245 + if (! ubicom32_data_register_operand (operands[1], GET_MODE (operands[1]))
8246 + && CONST_INT_P (operands[2]))
8247 + operands[2] = copy_to_mode_reg (DImode, operands[2]);
8249 + if (CONST_INT_P (operands[2]) && ! satisfies_constraint_I (operands[2]))
8250 + operands[2] = copy_to_mode_reg (DImode, operands[2]);
8253 +(define_insn_and_split "xordi3_xor4"
8254 + [(set (match_operand:DI 0 "nonimmediate_operand" "=&r,&r, d,rm, m, m")
8255 + (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%d,rm, 0, 0, d,rm")
8256 + (match_operand:DI 2 "ubicom32_arith_operand" "rmI, d,rmI, d,rmI, d")))
8257 + (clobber (reg:CC CC_REGNO))]
8260 + "reload_completed"
8261 + [(parallel [(set (match_dup 3)
8262 + (xor:SI (match_dup 4)
8264 + (clobber (reg:CC CC_REGNO))])
8265 + (parallel [(set (match_dup 6)
8266 + (xor:SI (match_dup 7)
8268 + (clobber (reg:CC CC_REGNO))])]
8270 + operands[3] = gen_lowpart (SImode, operands[0]);
8271 + operands[4] = gen_lowpart (SImode, operands[1]);
8272 + operands[5] = gen_lowpart (SImode, operands[2]);
8273 + operands[6] = gen_highpart (SImode, operands[0]);
8274 + operands[7] = gen_highpart (SImode, operands[1]);
8275 + operands[8] = gen_highpart_mode (SImode, DImode, operands[2]);
8277 + [(set_attr "length" "8")])
8279 +(define_insn "not2_2"
8280 + [(set (match_operand:HI 0 "memory_operand" "=m")
8282 + (not:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI"))
8284 + (clobber (reg:CC CC_REGNO))]
8288 +(define_insn "one_cmplsi2"
8289 + [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
8290 + (not:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")))
8291 + (clobber (reg:CC CC_REGNO))]
8295 +(define_insn "one_cmplsi2_ccwzn"
8296 + [(set (reg CC_REGNO)
8298 + (not:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI"))
8300 + (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
8301 + (not:SI (match_dup 1)))]
8302 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
8305 +(define_insn "one_cmplsi2_ccwzn_null"
8306 + [(set (reg CC_REGNO)
8308 + (not:SI (match_operand:SI 0 "ubicom32_arith_operand" "rmI"))
8310 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
8313 +(define_insn_and_split "one_cmpldi2"
8314 + [(set (match_operand:DI 0 "nonimmediate_operand" "=&rm")
8315 + (not:DI (match_operand:DI 1 "nonimmediate_operand" "rmI0")))
8316 + (clobber (reg:CC CC_REGNO))]
8320 + [(parallel [(set (match_dup 2)
8321 + (not:SI (match_dup 3)))
8322 + (clobber (reg:CC CC_REGNO))])
8323 + (parallel [(set (match_dup 4)
8324 + (not:SI (match_dup 5)))
8325 + (clobber (reg:CC CC_REGNO))])]
8327 + operands[2] = gen_lowpart (SImode, operands[0]);
8328 + operands[3] = gen_lowpart (SImode, operands[1]);
8329 + operands[4] = gen_highpart (SImode, operands[0]);
8330 + operands[5] = gen_highpart (SImode, operands[1]);
8332 + [(set_attr "length" "8")])
8334 +; Conditional jump instructions
8336 +(define_expand "beq"
8338 + (if_then_else (eq (match_dup 1)
8340 + (label_ref (match_operand 0 "" ""))
8344 + operands[1] = ubicom32_gen_compare_reg (EQ, ubicom32_compare_op0,
8345 + ubicom32_compare_op1);
8348 +(define_expand "bne"
8350 + (if_then_else (ne (match_dup 1)
8352 + (label_ref (match_operand 0 "" ""))
8356 + operands[1] = ubicom32_gen_compare_reg (NE, ubicom32_compare_op0,
8357 + ubicom32_compare_op1);
8360 +(define_expand "bgt"
8362 + (if_then_else (gt (match_dup 1)
8364 + (label_ref (match_operand 0 "" ""))
8368 + operands[1] = ubicom32_gen_compare_reg (GT, ubicom32_compare_op0,
8369 + ubicom32_compare_op1);
8372 +(define_expand "ble"
8374 + (if_then_else (le (match_dup 1)
8376 + (label_ref (match_operand 0 "" ""))
8380 + operands[1] = ubicom32_gen_compare_reg (LE, ubicom32_compare_op0,
8381 + ubicom32_compare_op1);
8384 +(define_expand "bge"
8386 + (if_then_else (ge (match_dup 1)
8388 + (label_ref (match_operand 0 "" ""))
8392 + operands[1] = ubicom32_gen_compare_reg (GE, ubicom32_compare_op0,
8393 + ubicom32_compare_op1);
8396 +(define_expand "blt"
8398 + (if_then_else (lt (match_dup 1)
8400 + (label_ref (match_operand 0 "" ""))
8404 + operands[1] = ubicom32_gen_compare_reg (LT, ubicom32_compare_op0,
8405 + ubicom32_compare_op1);
8408 +(define_expand "bgtu"
8410 + (if_then_else (gtu (match_dup 1)
8412 + (label_ref (match_operand 0 "" ""))
8416 + operands[1] = ubicom32_gen_compare_reg (GTU, ubicom32_compare_op0,
8417 + ubicom32_compare_op1);
8420 +(define_expand "bleu"
8422 + (if_then_else (leu (match_dup 1)
8424 + (label_ref (match_operand 0 "" ""))
8428 + operands[1] = ubicom32_gen_compare_reg (LEU, ubicom32_compare_op0,
8429 + ubicom32_compare_op1);
8432 +(define_expand "bgeu"
8434 + (if_then_else (geu (match_dup 1)
8436 + (label_ref (match_operand 0 "" ""))
8440 + operands[1] = ubicom32_gen_compare_reg (GEU, ubicom32_compare_op0,
8441 + ubicom32_compare_op1);
8444 +(define_expand "bltu"
8446 + (if_then_else (ltu (match_dup 1)
8448 + (label_ref (match_operand 0 "" ""))
8452 + operands[1] = ubicom32_gen_compare_reg (LTU, ubicom32_compare_op0,
8453 + ubicom32_compare_op1);
8458 + (if_then_else (match_operator 1 "comparison_operator"
8459 + [(match_operand 2 "ubicom32_cc_register_operand" "")
8461 + (label_ref (match_operand 0 "" ""))
8466 + ubicom32_output_cond_jump (insn, operands[1], operands[0]);
8470 +; Reverse branch - reverse our comparison condition so that we can
8471 +; branch in the opposite sense.
8473 +(define_insn_and_split "jcc_reverse"
8475 + (if_then_else (match_operator 1 "comparison_operator"
8476 + [(match_operand 2 "ubicom32_cc_register_operand" "")
8479 + (label_ref (match_operand 0 "" ""))))]
8482 + "reload_completed"
8484 + (if_then_else (match_dup 3)
8485 + (label_ref (match_dup 0))
8490 + cc_reg = gen_rtx_REG (GET_MODE (operands[2]), CC_REGNO);
8491 + operands[3] = gen_rtx_fmt_ee (reverse_condition (GET_CODE (operands[1])),
8492 + GET_MODE (operands[1]),
8497 +(define_insn "jump"
8499 + (label_ref (match_operand 0 "" "")))]
8503 +(define_expand "indirect_jump"
8504 + [(parallel [(set (pc)
8505 + (match_operand:SI 0 "register_operand" ""))
8506 + (clobber (match_dup 0))])]
8510 +(define_insn "indirect_jump_internal"
8512 + (match_operand:SI 0 "register_operand" "a"))
8513 + (clobber (match_dup 0))]
8515 + "calli\\t%0,0(%0)")
8517 +; Program Space: The table contains instructions, typically jumps.
8518 +; CALL An,TABLE_SIZE(PC) ;An = Jump Table Base Address.
8519 +; <Jump Table is Here> ;An -> Here.
8520 +; LEA Ak, (An,Dn) ;Ak -> Table Entry
8523 +(define_expand "tablejump"
8524 + [(parallel [(set (pc)
8525 + (match_operand:SI 0 "nonimmediate_operand" ""))
8526 + (use (label_ref (match_operand 1 "" "")))])]
8530 +(define_insn "tablejump_internal"
8532 + (match_operand:SI 0 "nonimmediate_operand" "rm"))
8533 + (use (label_ref (match_operand 1 "" "")))]
8537 +; Call subroutine with no return value.
8539 +(define_expand "call"
8540 + [(call (match_operand:QI 0 "general_operand" "")
8541 + (match_operand:SI 1 "general_operand" ""))]
8546 + ubicom32_expand_call_fdpic (operands);
8550 + if (! ubicom32_call_address_operand (XEXP (operands[0], 0), VOIDmode))
8551 + XEXP (operands[0], 0) = force_reg (SImode, XEXP (operands[0], 0));
8554 +; We expand to a simple form that doesn't clobber the link register and
8555 +; then split to a form that does. This allows the RTL optimizers that
8556 +; run before the splitter to have the opportunity to eliminate the call
8557 +; without marking A5 as being clobbered and this in turn avoids saves
8558 +; and returns in a number of cases.
8560 +(define_insn_and_split "call_1"
8561 + [(call (mem:QI (match_operand:SI 0 "ubicom32_call_address_operand" "a,S"))
8562 + (match_operand:SI 1 "general_operand" "g,g"))]
8567 + [(call (mem:QI (match_dup 0))
8569 + (clobber (reg:SI LINK_REGNO))])]
8572 +(define_insn "call_slow"
8573 + [(call (mem:QI (match_operand:SI 0 "ubicom32_call_address_operand" "a,S"))
8574 + (match_operand:SI 1 "general_operand" "g,g"))
8575 + (clobber (reg:SI LINK_REGNO))]
8576 + "(! TARGET_FDPIC && ! TARGET_FASTCALL)"
8579 + moveai\\ta5, #%%hi(%C0)\;calli\\ta5, %%lo(%C0)(a5)")
8581 +(define_insn "call_fast"
8582 + [(call (mem:QI (match_operand:SI 0 "ubicom32_call_address_operand" "a,S"))
8583 + (match_operand:SI 1 "general_operand" "g,g"))
8584 + (clobber (reg:SI LINK_REGNO))]
8585 + "(! TARGET_FDPIC && TARGET_FASTCALL)"
8590 +; We expand to a simple form that doesn't clobber the link register and
8591 +; then split to a form that does. This allows the RTL optimizers that
8592 +; run before the splitter to have the opportunity to eliminate the call
8593 +; without marking A5 as being clobbered and this in turn avoids saves
8594 +; and returns in a number of cases.
8596 +(define_insn_and_split "call_fdpic"
8597 + [(call (mem:QI (match_operand:SI 0 "ubicom32_call_address_operand" "a,S"))
8598 + (match_operand:SI 1 "general_operand" "g,g"))
8599 + (use (match_operand:SI 2 "ubicom32_fdpic_operand" "Z,Z"))]
8604 + [(call (mem:QI (match_dup 0))
8606 + (use (match_dup 2))
8607 + (clobber (reg:SI LINK_REGNO))])]
8610 +(define_insn "call_fdpic_clobber"
8611 + [(call (mem:QI (match_operand:SI 0 "ubicom32_call_address_operand" "a,S"))
8612 + (match_operand:SI 1 "general_operand" "g,g"))
8613 + (use (match_operand:SI 2 "ubicom32_fdpic_operand" "Z,Z"))
8614 + (clobber (reg:SI LINK_REGNO))]
8617 + move.4\\ta5, 0(%0)\;move.4\\t%2, 4(%0)\;calli\\ta5, 0(a5)
8620 +; Call subroutine, returning value in operand 0
8621 +; (which must be a hard register).
8623 +(define_expand "call_value"
8624 + [(set (match_operand 0 "" "")
8625 + (call (match_operand:QI 1 "general_operand" "")
8626 + (match_operand:SI 2 "general_operand" "")))]
8631 + ubicom32_expand_call_value_fdpic (operands);
8635 + if (! ubicom32_call_address_operand (XEXP (operands[1], 0), VOIDmode))
8636 + XEXP (operands[1], 0) = force_reg (SImode, XEXP (operands[1], 0));
8639 +; We expand to a simple form that doesn't clobber the link register and
8640 +; then split to a form that does. This allows the RTL optimizers that
8641 +; run before the splitter to have the opportunity to eliminate the call
8642 +; without marking A5 as being clobbered and this in turn avoids saves
8643 +; and returns in a number of cases.
8645 +(define_insn_and_split "call_value_1"
8646 + [(set (match_operand 0 "register_operand" "=r,r")
8647 + (call (mem:QI (match_operand:SI 1 "ubicom32_call_address_operand" "a,S"))
8648 + (match_operand:SI 2 "general_operand" "g,g")))]
8653 + [(set (match_dup 0)
8654 + (call (mem:QI (match_dup 1))
8656 + (clobber (reg:SI LINK_REGNO))])]
8659 +(define_insn "call_value_slow"
8660 + [(set (match_operand 0 "register_operand" "=r,r")
8661 + (call (mem:QI (match_operand:SI 1 "ubicom32_call_address_operand" "a,S"))
8662 + (match_operand:SI 2 "general_operand" "g,g")))
8663 + (clobber (reg:SI LINK_REGNO))]
8664 + "(! TARGET_FDPIC && ! TARGET_FASTCALL)"
8667 + moveai\\ta5, #%%hi(%C1)\;calli\\ta5, %%lo(%C1)(a5)")
8669 +(define_insn "call_value_fast"
8670 + [(set (match_operand 0 "register_operand" "=r,r")
8671 + (call (mem:QI (match_operand:SI 1 "ubicom32_call_address_operand" "a,S"))
8672 + (match_operand:SI 2 "general_operand" "g,g")))
8673 + (clobber (reg:SI LINK_REGNO))]
8674 + "(! TARGET_FDPIC && TARGET_FASTCALL)"
8679 +; We expand to a simple form that doesn't clobber the link register and
8680 +; then split to a form that does. This allows the RTL optimizers that
8681 +; run before the splitter to have the opportunity to eliminate the call
8682 +; without marking A5 as being clobbered and this in turn avoids saves
8683 +; and returns in a number of cases.
8685 +(define_insn_and_split "call_value_fdpic"
8686 + [(set (match_operand 0 "register_operand" "=r,r")
8687 + (call (mem:QI (match_operand:SI 1 "ubicom32_call_address_operand" "a,S"))
8688 + (match_operand:SI 2 "general_operand" "g,g")))
8689 + (use (match_operand:SI 3 "ubicom32_fdpic_operand" "Z,Z"))]
8694 + [(set (match_dup 0)
8695 + (call (mem:QI (match_dup 1))
8697 + (use (match_dup 3))
8698 + (clobber (reg:SI LINK_REGNO))])]
8701 +(define_insn "call_value_fdpic_clobber"
8702 + [(set (match_operand 0 "register_operand" "=r,r")
8703 + (call (mem:QI (match_operand:SI 1 "ubicom32_call_address_operand" "a,S"))
8704 + (match_operand:SI 2 "general_operand" "g,g")))
8705 + (use (match_operand:SI 3 "ubicom32_fdpic_operand" "Z,Z"))
8706 + (clobber (reg:SI LINK_REGNO))]
8709 + move.4\\ta5, 0(%1)\;move.4\\t%3, 4(%1)\;calli\\ta5, 0(a5)
8712 +(define_expand "untyped_call"
8713 + [(parallel [(call (match_operand 0 "" "")
8715 + (match_operand 1 "" "")
8716 + (match_operand 2 "" "")])]
8721 + emit_call_insn (gen_call (operands[0], const0_rtx));
8723 + for (i = 0; i < XVECLEN (operands[2], 0); i++)
8725 + rtx set = XVECEXP (operands[2], 0, i);
8726 + emit_move_insn (SET_DEST (set), SET_SRC (set));
8731 +(define_insn "lsl1_1"
8732 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8733 + (ashift:SI (subreg:SI
8734 + (match_operand:QI 1 "memory_operand" "m")
8736 + (match_operand:SI 2 "ubicom32_arith_operand" "dM")))
8737 + (clobber (reg:CC CC_REGNO))]
8739 + "lsl.1\\t%0, %1, %2")
8741 +; The combiner gets rather creative about left shifts of sub-word memory
8742 +; operands because it's uncertain about whether the memory is sign or
8743 +; zero extended. It only wants zero-extended behaviour and so throws
8744 +; in an extra and operation.
8746 +(define_insn "lsl1_2"
8747 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8749 + (ashift:SI (subreg:SI
8750 + (match_operand:QI 1 "memory_operand" "m")
8752 + (match_operand:SI 2 "const_int_operand" "M"))
8753 + (match_operand:SI 3 "const_int_operand" "n")))
8754 + (clobber (reg:CC CC_REGNO))]
8756 + && INTVAL (operands[3]) == (0xff << INTVAL (operands[2])))"
8757 + "lsl.1\\t%0, %1, %2")
8759 +(define_insn "lsl2_1"
8760 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8761 + (ashift:SI (subreg:SI
8762 + (match_operand:HI 1 "memory_operand" "m")
8764 + (match_operand:SI 2 "ubicom32_arith_operand" "dM")))
8765 + (clobber (reg:CC CC_REGNO))]
8767 + "lsl.2\\t%0, %1, %2")
8769 +; The combiner gets rather creative about left shifts of sub-word memory
8770 +; operands because it's uncertain about whether the memory is sign or
8771 +; zero extended. It only wants zero-extended behaviour and so throws
8772 +; in an extra and operation.
8774 +(define_insn "lsl2_2"
8775 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8777 + (ashift:SI (subreg:SI
8778 + (match_operand:HI 1 "memory_operand" "m")
8780 + (match_operand:SI 2 "const_int_operand" "M"))
8781 + (match_operand:SI 3 "const_int_operand" "n")))
8782 + (clobber (reg:CC CC_REGNO))]
8784 + && INTVAL (operands[3]) == (0xffff << INTVAL (operands[2])))"
8785 + "lsl.2\\t%0, %1, %2")
8787 +(define_insn "ashlsi3"
8788 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8789 + (ashift:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")
8790 + (match_operand:SI 2 "ubicom32_arith_operand" "dM")))
8791 + (clobber (reg:CC CC_REGNO))]
8793 + "lsl.4\\t%0, %1, %2")
8795 +(define_insn "lshlsi3_ccwz"
8796 + [(set (reg CC_REGNO)
8798 + (ashift:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")
8799 + (match_operand:SI 2 "ubicom32_arith_operand" "dM"))
8801 + (set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8802 + (ashift:SI (match_dup 1)
8804 + "ubicom32_match_cc_mode(insn, CCWZmode)"
8805 + "lsl.4\\t%0, %1, %2")
8807 +(define_insn "lshlsi3_ccwz_null"
8808 + [(set (reg CC_REGNO)
8810 + (ashift:SI (match_operand:SI 0 "ubicom32_arith_operand" "rmI")
8811 + (match_operand:SI 1 "ubicom32_arith_operand" "dM"))
8813 + (clobber (match_scratch:SI 2 "=d"))]
8814 + "ubicom32_match_cc_mode(insn, CCWZmode)"
8815 + "lsl.4\\t%2, %0, %1")
8817 +; The combiner finds this canonical form for what is in essence a right
8820 +(define_insn "asr1_2"
8821 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8822 + (sign_extract:SI (match_operand:QI 1 "memory_operand" "m")
8823 + (match_operand:SI 2 "const_int_operand" "M")
8824 + (match_operand:SI 3 "const_int_operand" "M")))
8825 + (clobber (reg:CC CC_REGNO))]
8827 + && (INTVAL (operands[2]) + INTVAL (operands[3]) == 8))"
8828 + "asr.1\\t%0, %1, %3")
8830 +; The combiner finds this canonical form for what is in essence a right
8833 +(define_insn "asr2_2"
8834 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8835 + (sign_extract:SI (match_operand:HI 1 "memory_operand" "m")
8836 + (match_operand:SI 2 "const_int_operand" "M")
8837 + (match_operand:SI 3 "const_int_operand" "M")))
8838 + (clobber (reg:CC CC_REGNO))]
8840 + && (INTVAL (operands[2]) + INTVAL (operands[3]) == 16))"
8841 + "asr.2\\t%0, %1, %3")
8843 +(define_insn "ashrsi3"
8844 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8845 + (ashiftrt:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmJ")
8846 + (match_operand:SI 2 "ubicom32_arith_operand" "dM")))
8847 + (clobber (reg:CC CC_REGNO))]
8849 + "asr.4\\t%0, %1, %2")
8851 +(define_insn "ashrsi3_ccwzn"
8852 + [(set (reg CC_REGNO)
8854 + (ashiftrt:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmJ")
8855 + (match_operand:SI 2 "ubicom32_arith_operand" "dM"))
8857 + (set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8858 + (ashiftrt:SI (match_dup 1)
8860 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
8861 + "asr.4\\t%0, %1, %2")
8863 +(define_insn "ashrsi3_ccwzn_null"
8864 + [(set (reg CC_REGNO)
8866 + (ashiftrt:SI (match_operand:SI 0 "ubicom32_arith_operand" "rmJ")
8867 + (match_operand:SI 1 "ubicom32_arith_operand" "dM"))
8869 + (clobber (match_scratch:SI 2 "=d"))]
8870 + "ubicom32_match_cc_mode(insn, CCWZNmode)"
8871 + "asr.4\\t%2, %0, %1")
8873 +(define_insn "lsr1_1"
8874 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8875 + (lshiftrt:SI (subreg:SI
8876 + (match_operand:QI 1 "memory_operand" "m")
8878 + (match_operand:SI 2 "ubicom32_arith_operand" "dM")))
8879 + (clobber (reg:CC CC_REGNO))]
8881 + "lsr.1\\t%0, %1, %2")
8883 +; The combiner finds this canonical form for what is in essence a right
8886 +(define_insn "lsr1_2"
8887 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8888 + (zero_extract:SI (match_operand:QI 1 "memory_operand" "m")
8889 + (match_operand:SI 2 "const_int_operand" "M")
8890 + (match_operand:SI 3 "const_int_operand" "M")))
8891 + (clobber (reg:CC CC_REGNO))]
8893 + && (INTVAL (operands[2]) + INTVAL (operands[3]) == 8))"
8894 + "lsr.1\\t%0, %1, %3")
8896 +(define_insn "lsr2_1"
8897 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8898 + (lshiftrt:SI (subreg:SI
8899 + (match_operand:HI 1 "memory_operand" "m")
8901 + (match_operand:SI 2 "ubicom32_arith_operand" "dM")))
8902 + (clobber (reg:CC CC_REGNO))]
8904 + "lsr.2\\t%0, %1, %2")
8906 +; The combiner finds this canonical form for what is in essence a right
8909 +(define_insn "lsr2_2"
8910 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8911 + (zero_extract:SI (match_operand:HI 1 "memory_operand" "m")
8912 + (match_operand:SI 2 "const_int_operand" "M")
8913 + (match_operand:SI 3 "const_int_operand" "M")))
8914 + (clobber (reg:CC CC_REGNO))]
8916 + && (INTVAL (operands[2]) + INTVAL (operands[3]) == 16))"
8917 + "lsr.2\\t%0, %1, %3")
8919 +(define_insn "lshrsi3"
8920 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8921 + (lshiftrt:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")
8922 + (match_operand:SI 2 "ubicom32_arith_operand" "dM")))
8923 + (clobber (reg:CC CC_REGNO))]
8925 + "lsr.4\\t%0, %1, %2")
8927 +(define_insn "lshrsi3_ccwz"
8928 + [(set (reg CC_REGNO)
8930 + (lshiftrt:SI (match_operand:SI 1 "ubicom32_arith_operand" "rmI")
8931 + (match_operand:SI 2 "ubicom32_arith_operand" "dM"))
8933 + (set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
8934 + (lshiftrt:SI (match_dup 1)
8936 + "ubicom32_match_cc_mode(insn, CCWZmode)"
8937 + "lsr.4\\t%0, %1, %2")
8939 +(define_insn "lshrsi3_ccwz_null"
8940 + [(set (reg CC_REGNO)
8942 + (lshiftrt:SI (match_operand:SI 0 "ubicom32_arith_operand" "rmI")
8943 + (match_operand:SI 1 "ubicom32_arith_operand" "dM"))
8945 + (clobber (match_scratch:SI 2 "=d"))]
8946 + "ubicom32_match_cc_mode(insn, CCWZmode)"
8947 + "lsr.4\\t%2, %0, %1")
8949 +(define_expand "prologue"
8953 + ubicom32_expand_prologue ();
8957 +(define_expand "epilogue"
8961 + ubicom32_expand_epilogue ();
8965 +(define_expand "return"
8969 + ubicom32_expand_epilogue ();
8973 +(define_expand "_eh_return"
8974 + [(use (match_operand:SI 0 "register_operand" "r"))
8975 + (use (match_operand:SI 1 "register_operand" "r"))]
8978 + ubicom32_expand_eh_return (operands);
8982 +; XXX - it looks almost certain that we could make return_internal use a Dn
8983 +; register too. In that instance we'd have to use a ret instruction
8984 +; rather than a calli but it might save cycles.
8986 +(define_insn "return_internal"
8989 + (use (match_operand:SI 0 "ubicom32_mem_or_address_register_operand" "rm"))]
8993 + if (REG_P (operands[0]) && REGNO (operands[0]) == LINK_REGNO
8994 + && ubicom32_can_use_calli_to_ret)
8995 + return \"calli\\t%0, 0(%0)\";
8997 + return \"ret\\t%0\";
9000 +(define_insn "return_from_post_modify_sp"
9004 + (use (mem:SI (post_modify:SI
9006 + (plus:SI (reg:SI SP_REGNO)
9007 + (match_operand:SI 0 "const_int_operand" "n")))))])]
9008 + "INTVAL (operands[0]) >= 4 && INTVAL (operands[0]) <= 7 * 4"
9009 + "ret\\t(sp)%E0++")
9011 +;(define_insn "eh_return_internal"
9014 +; (use (reg:SI 34))]
9018 +; No operation, needed in case the user uses -g but not -O.
9019 +(define_expand "nop"
9024 +(define_insn "nop_internal"
9029 +; The combiner will generate this pattern given shift and add operations.
9030 +; The canonical form that the combiner wants to use appears to be multiplies
9031 +; instead of shifts even if the compiled sources use shifts.
9033 +(define_insn "shmrg1_add"
9034 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
9036 + (mult:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")
9039 + (match_operand:QI 2 "ubicom32_arith_operand" "rmI"))))
9040 + (clobber (reg:CC CC_REGNO))]
9042 + "shmrg.1\\t%0, %2, %1")
9044 +; The combiner will generate this pattern given shift and or operations.
9046 +(define_insn "shmrg1_ior"
9047 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
9049 + (ashift:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")
9052 + (match_operand:QI 2 "ubicom32_arith_operand" "rmI"))))
9053 + (clobber (reg:CC CC_REGNO))]
9055 + "shmrg.1\\t%0, %2, %1")
9057 +; The combiner will generate this pattern given shift and add operations.
9058 +; The canonical form that the combiner wants to use appears to be multiplies
9059 +; instead of shifts even if the compiled sources use shifts.
9061 +(define_insn "shmrg2_add"
9062 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
9064 + (mult:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")
9065 + (const_int 65536))
9067 + (match_operand:HI 2 "ubicom32_arith_operand" "rmI"))))
9068 + (clobber (reg:CC CC_REGNO))]
9070 + "shmrg.2\\t%0, %2, %1")
9072 +; The combiner will generate this pattern given shift and or operations.
9074 +(define_insn "shmrg2_ior"
9075 + [(set (match_operand:SI 0 "ubicom32_data_register_operand" "=d")
9077 + (ashift:SI (match_operand:SI 1 "ubicom32_data_register_operand" "d")
9080 + (match_operand:HI 2 "ubicom32_arith_operand" "rmI"))))
9081 + (clobber (reg:CC CC_REGNO))]
9083 + "shmrg.2\\t%0, %2, %1")
9085 +; Match the case where we load a word from the stack but then discard the
9086 +; upper 16 bits. We turn this into a zero-extended load of that useful
9087 +; 16 bits direct from the stack where possible.
9090 +; XXX - do these peephole2 ops actually work after the CCmode conversion?
9092 + [(set (match_operand:SI 0 "register_operand" "")
9093 + (mem:SI (plus:SI (reg:SI SP_REGNO)
9094 + (match_operand:SI 1 "const_int_operand" ""))))
9095 + (set (match_operand:SI 2 "nonimmediate_operand" "")
9096 + (zero_extend:SI (match_operand:HI 3 "register_operand" "")))]
9097 + "(INTVAL (operands[1]) <= 252
9098 + && REGNO (operands[3]) == REGNO (operands[0])
9099 + && ((peep2_reg_dead_p (2, operands[0])
9100 + && ! reg_mentioned_p (operands[0], operands[2]))
9101 + || rtx_equal_p (operands[0], operands[2])))"
9102 + [(set (match_dup 2)
9103 + (zero_extend:SI (mem:HI (plus:SI (reg:SI SP_REGNO)
9104 + (match_dup 4)))))]
9106 + operands[4] = GEN_INT (INTVAL (operands[1]) + 2);
9109 +; Match the case where we load a word from the stack but then discard the
9110 +; upper 16 bits. We turn this into a 16-bit load of that useful
9111 +; 16 bits direct from the stack where possible.
9114 + [(set (match_operand:SI 0 "register_operand" "")
9115 + (mem:SI (plus:SI (reg:SI SP_REGNO)
9116 + (match_operand:SI 1 "const_int_operand" ""))))
9117 + (set (match_operand:HI 2 "nonimmediate_operand" "")
9118 + (match_operand:HI 3 "register_operand" ""))]
9119 + "(INTVAL (operands[1]) <= 252
9120 + && REGNO (operands[3]) == REGNO (operands[0])
9121 + && ((peep2_reg_dead_p (2, operands[0])
9122 + && ! reg_mentioned_p (operands[0], operands[2]))
9123 + || rtx_equal_p (operands[0], operands[2])))"
9124 + [(set (match_dup 2)
9125 + (mem:HI (plus:SI (reg:SI SP_REGNO)
9128 + operands[4] = GEN_INT (INTVAL (operands[1]) + 2);
9131 +; Match the case where we load a word from the stack but then discard the
9132 +; upper 24 bits. We turn this into a zero-extended load of that useful
9133 +; 8 bits direct from the stack where possible.
9136 + [(set (match_operand:SI 0 "register_operand" "")
9137 + (mem:SI (plus:SI (reg:SI SP_REGNO)
9138 + (match_operand:SI 1 "const_int_operand" ""))))
9139 + (set (match_operand:SI 2 "nonimmediate_operand" "")
9140 + (zero_extend:SI (match_operand:QI 3 "register_operand" "")))]
9141 + "(INTVAL (operands[1]) <= 124
9142 + && REGNO (operands[3]) == REGNO (operands[0])
9143 + && ((peep2_reg_dead_p (2, operands[0])
9144 + && ! reg_mentioned_p (operands[0], operands[2]))
9145 + || rtx_equal_p (operands[0], operands[2])))"
9146 + [(set (match_dup 2)
9147 + (zero_extend:SI (mem:QI (plus:SI (reg:SI SP_REGNO)
9148 + (match_dup 4)))))]
9150 + operands[4] = GEN_INT (INTVAL (operands[1]) + 3);
9153 +; Match the case where we load a word from the stack but then discard the
9154 +; upper 24 bits. We turn this into an 8-bit load of that useful
9155 +; 8 bits direct from the stack where possible.
9158 + [(set (match_operand:SI 0 "register_operand" "")
9159 + (mem:SI (plus:SI (reg:SI SP_REGNO)
9160 + (match_operand:SI 1 "const_int_operand" ""))))
9161 + (set (match_operand:QI 2 "nonimmediate_operand" "")
9162 + (match_operand:QI 3 "register_operand" ""))]
9163 + "(INTVAL (operands[1]) <= 124
9164 + && REGNO (operands[3]) == REGNO (operands[0])
9165 + && ((peep2_reg_dead_p (2, operands[0])
9166 + && ! reg_mentioned_p (operands[0], operands[2]))
9167 + || rtx_equal_p (operands[0], operands[2])))"
9168 + [(set (match_dup 2)
9169 + (mem:QI (plus:SI (reg:SI SP_REGNO)
9172 + operands[4] = GEN_INT (INTVAL (operands[1]) + 3);
9176 +++ b/gcc/config/ubicom32/ubicom32.opt
9179 +Target RejectNegative Report Undocumented Mask(DEBUG_ADDRESS)
9183 +Target RejectNegative Report Undocumented Mask(DEBUG_CONTEXT)
9187 +Target Report Var(ubicom32_arch_name) Init("ubicom32v4") Joined
9188 +Specify the name of the target architecture
9191 +Target Report Mask(FDPIC)
9192 +Enable Function Descriptor PIC mode
9195 +Target Report Mask(INLINE_PLT)
9196 +Enable inlining of PLT in function calls
9199 +Target Report Mask(FASTCALL)
9200 +Enable default fast (call) calling sequence for smaller applications
9203 +Target Report Mask(IPOS_ABI)
9204 +Enable the ipOS ABI in which D10-D13 are caller-clobbered
9206 +++ b/gcc/config/ubicom32/uclinux.h
9208 +/* Definitions of target machine for Ubicom32-uclinux
9210 + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
9211 + 2009 Free Software Foundation, Inc.
9212 + Contributed by Ubicom, Inc.
9214 + This file is part of GCC.
9216 + GCC is free software; you can redistribute it and/or modify it
9217 + under the terms of the GNU General Public License as published
9218 + by the Free Software Foundation; either version 3, or (at your
9219 + option) any later version.
9221 + GCC is distributed in the hope that it will be useful, but WITHOUT
9222 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9223 + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
9224 + License for more details.
9226 + You should have received a copy of the GNU General Public License
9227 + along with GCC; see the file COPYING3. If not see
9228 + <http://www.gnu.org/licenses/>. */
9230 +/* Don't assume anything about the header files. */
9231 +#define NO_IMPLICIT_EXTERN_C
9235 + "%{pthread:-lpthread} " \
9236 + "%{!shared:%{!symbolic: -lc}} "
9239 +#undef LINK_GCC_C_SEQUENCE_SPEC
9240 +#define LINK_GCC_C_SEQUENCE_SPEC \
9241 + "%{!shared:--start-group} %G %L %{!shared:--end-group}%{shared:%G} "
9243 +#undef STARTFILE_SPEC
9244 +#define STARTFILE_SPEC \
9245 + "%{!shared: crt1%O%s}" \
9246 + " crti%O%s crtbegin%O%s"
9248 +#undef ENDFILE_SPEC
9249 +#define ENDFILE_SPEC "crtend%O%s crtn%O%s"
9251 +/* This macro applies on top of OBJECT_FORMAT_ELF and indicates that
9252 + we want to support both flat and ELF output. */
9253 +#define OBJECT_FORMAT_FLAT
9255 +#undef DRIVER_SELF_SPECS
9256 +#define DRIVER_SELF_SPECS \
9257 + "%{!mno-fastcall:-mfastcall}"
9259 +/* taken from linux.h */
9260 +/* The GNU C++ standard library requires that these macros be defined. */
9261 +#undef CPLUSPLUS_CPP_SPEC
9262 +#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
9264 +#define TARGET_OS_CPP_BUILTINS() \
9266 + builtin_define_std ("__UBICOM32__"); \
9267 + builtin_define_std ("__ubicom32__"); \
9268 + builtin_define ("__gnu_linux__"); \
9269 + builtin_define_std ("linux"); \
9270 + builtin_define_std ("unix"); \
9271 + builtin_assert ("system=linux"); \
9272 + builtin_assert ("system=unix"); \
9273 + builtin_assert ("system=posix"); \
9276 +++ b/gcc/config/ubicom32/xm-ubicom32.h
9278 +/* Configuration for Ubicom's Ubicom32 architecture.
9279 + Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software
9281 + Contributed by Ubicom Inc.
9283 +This file is part of GNU CC.
9285 +GNU CC is free software; you can redistribute it and/or modify
9286 +it under the terms of the GNU General Public License as published by
9287 +the Free Software Foundation; either version 2, or (at your option)
9290 +GNU CC is distributed in the hope that it will be useful,
9291 +but WITHOUT ANY WARRANTY; without even the implied warranty of
9292 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9293 +GNU General Public License for more details.
9295 +You should have received a copy of the GNU General Public License
9296 +along with GNU CC; see the file COPYING. If not, write to
9297 +the Free Software Foundation, 59 Temple Place - Suite 330,
9298 +Boston, MA 02111-1307, USA. */
9300 +/* #defines that need visibility everywhere. */
9304 +/* This describes the machine the compiler is hosted on. */
9305 +#define HOST_BITS_PER_CHAR 8
9306 +#define HOST_BITS_PER_SHORT 16
9307 +#define HOST_BITS_PER_INT 32
9308 +#define HOST_BITS_PER_LONG 32
9309 +#define HOST_BITS_PER_LONGLONG 64
9311 +/* Arguments to use with `exit'. */
9312 +#define SUCCESS_EXIT_CODE 0
9313 +#define FATAL_EXIT_CODE 33
9314 --- a/gcc/config.gcc
9315 +++ b/gcc/config.gcc
9316 @@ -2675,6 +2675,34 @@ spu-*-elf*)
9317 c_target_objs="${c_target_objs} spu-c.o"
9318 cxx_target_objs="${cxx_target_objs} spu-c.o"
9321 + xm_file=ubicom32/xm-ubicom32.h
9322 + tm_file="${tm_file} ubicom32/elf.h" # still need dbxelf.h elfos.h
9323 + tmake_file=ubicom32/t-ubicom32
9325 +ubicom32-*-uclinux*)
9326 + xm_file=ubicom32/xm-ubicom32.h
9327 + tm_file="${tm_file} ubicom32/elf.h ubicom32/uclinux.h" # still need dbxelf.h elfos.h linux.h
9328 + tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
9329 + extra_options="${extra_options} linux.opt"
9330 + tmake_file=ubicom32/t-ubicom32-uclinux
9333 +ubicom32-*-linux-uclibc)
9334 + xm_file=ubicom32/xm-ubicom32.h
9335 + tm_file="${tm_file} ubicom32/elf.h linux.h ubicom32/linux.h" # still need dbxelf.h elfos.h
9336 + tmake_file="t-slibgcc-elf-ver ubicom32/t-ubicom32-linux"
9337 + extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
9341 + xm_file=ubicom32/xm-ubicom32.h
9342 + tm_file="${tm_file} ubicom32/elf.h linux.h ubicom32/linux.h" # still need dbxelf.h elfos.h
9343 + tmake_file="t-slibgcc-elf-ver ubicom32/t-ubicom32-linux"
9344 + tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
9345 + extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
9349 target_cpu_default="TARGET_CPU_v850e1"
9350 tm_file="dbxelf.h elfos.h newlib-stdint.h v850/v850.h"
9351 --- a/libgcc/config.host
9352 +++ b/libgcc/config.host
9353 @@ -563,6 +563,15 @@ sparc64-*-netbsd*)
9359 +ubicom32*-*-uclinux*)
9361 +ubicom32*-*-linux*)
9362 + # No need to build crtbeginT.o on uClibc systems. Should probably
9363 + # be moved to the OS specific section above.
9364 + extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"