1 /* Target Code for OpenRISC
2 Copyright (C) 2018-2023 Free Software Foundation, Inc.
3 Contributed by Stafford Horne based on other ports.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 3, or (at your
10 option) any later version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #define IN_TARGET_CODE 1
25 #include "coretypes.h"
30 #include "stringpool.h"
36 #include "diagnostic-core.h"
38 #include "stor-layout.h"
47 #include "targhooks.h"
48 #include "case-cfn-macros.h"
50 /* These 4 are needed to allow using satisfies_constraint_J. */
51 #include "insn-config.h"
54 #include "tm-constrs.h"
56 /* This file should be included last. */
57 #include "target-def.h"
59 /* Per-function machine data. */
60 struct GTY(()) machine_function
62 /* Number of bytes saved on the stack for callee saved registers. */
63 HOST_WIDE_INT callee_saved_reg_size
;
65 /* Number of bytes saved on the stack for local variables. */
66 HOST_WIDE_INT local_vars_size
;
68 /* Number of bytes saved on the stack for outgoing/sub-function args. */
69 HOST_WIDE_INT args_size
;
71 /* The sum of sizes: locals vars, called saved regs, stack pointer
72 and an optional frame pointer.
73 Used in expand_prologue () and expand_epilogue (). */
74 HOST_WIDE_INT total_size
;
76 /* Remember where the set_got_placeholder is located. */
77 rtx_insn
*set_got_insn
;
79 /* Remember where mcount args are stored so we can insert set_got_insn
81 rtx_insn
*set_mcount_arg_insn
;
84 /* Zero initialization is OK for all current fields. */
86 static struct machine_function
*
87 or1k_init_machine_status (void)
89 return ggc_cleared_alloc
<machine_function
> ();
93 /* Worker for TARGET_OPTION_OVERRIDE.
94 We currently only use this to setup init_machine_status. */
97 or1k_option_override (void)
99 /* Set the per-function-data initializer. */
100 init_machine_status
= or1k_init_machine_status
;
103 /* Returns true if REGNO must be saved for the current function. */
106 callee_saved_regno_p (int regno
)
108 /* Check call-saved registers. */
109 if (!call_used_or_fixed_reg_p (regno
) && df_regs_ever_live_p (regno
))
114 case HARD_FRAME_POINTER_REGNUM
:
115 return frame_pointer_needed
;
118 /* Always save LR if we are saving HFP, producing a walkable
119 stack chain with -fno-omit-frame-pointer. */
120 return (frame_pointer_needed
122 || crtl
->uses_pic_offset_table
123 || df_regs_ever_live_p (regno
));
125 case HW_TO_GCC_REGNO (25):
126 case HW_TO_GCC_REGNO (27):
127 case HW_TO_GCC_REGNO (29):
128 case HW_TO_GCC_REGNO (31):
129 /* See EH_RETURN_DATA_REGNO. */
130 return crtl
->calls_eh_return
;
137 /* Worker for TARGET_COMPUTE_FRAME_LAYOUT.
138 Compute and populate machine specific function attributes which are globally
139 accessible via cfun->machine. These include the sizes needed for
140 stack stored local variables, callee saved registers and space for stack
141 arguments which may be passed to a next function. The values are used for
142 the epilogue, prologue and eliminations.
144 OpenRISC stack grows downwards and contains:
146 ---- previous frame --------
148 current func arg[0] <-- r2 [HFP,AP]
149 ---- current stack frame --- ^ ---\
150 return address r9 | |
151 old frame pointer r2 (+) |-- machine->total_size
152 callee saved regs | | > machine->callee_saved_reg_size
153 local variables | | > machine->local_vars_size <-FP
154 next function args <-- r1 [SP]---/ > machine->args_size
155 ---------------------------- |
160 All of these contents are optional. */
163 or1k_compute_frame_layout (void)
165 HOST_WIDE_INT local_vars_size
, args_size
, save_reg_size
;
167 local_vars_size
= get_frame_size ();
168 local_vars_size
= ROUND_UP (local_vars_size
, UNITS_PER_WORD
);
170 args_size
= crtl
->outgoing_args_size
;
171 args_size
= ROUND_UP (args_size
, UNITS_PER_WORD
);
174 for (int regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
175 if (callee_saved_regno_p (regno
))
176 save_reg_size
+= UNITS_PER_WORD
;
178 cfun
->machine
->local_vars_size
= local_vars_size
;
179 cfun
->machine
->args_size
= args_size
;
180 cfun
->machine
->callee_saved_reg_size
= save_reg_size
;
181 cfun
->machine
->total_size
= save_reg_size
+ local_vars_size
+ args_size
;
184 /* Emit rtl to save register REGNO contents to stack memory at the given OFFSET
185 from the current stack pointer. */
188 or1k_save_reg (int regno
, HOST_WIDE_INT offset
)
190 rtx reg
= gen_rtx_REG (Pmode
, regno
);
191 rtx mem
= gen_frame_mem (SImode
, plus_constant (Pmode
, stack_pointer_rtx
,
193 rtx insn
= emit_move_insn (mem
, reg
);
194 RTX_FRAME_RELATED_P (insn
) = 1;
197 /* Emit rtl to restore register REGNO contents from stack memory at the given
198 OFFSET from the current stack pointer. */
201 or1k_restore_reg (int regno
, HOST_WIDE_INT offset
, rtx cfa_restores
)
203 rtx reg
= gen_rtx_REG (Pmode
, regno
);
204 rtx mem
= gen_frame_mem (SImode
, plus_constant (Pmode
, stack_pointer_rtx
,
206 emit_move_insn (reg
, mem
);
207 return alloc_reg_note (REG_CFA_RESTORE
, reg
, cfa_restores
);
210 /* Expand the "prologue" pattern. */
213 or1k_expand_prologue (void)
215 HOST_WIDE_INT sp_offset
= -cfun
->machine
->total_size
;
216 HOST_WIDE_INT reg_offset
, this_offset
;
219 if (flag_stack_usage_info
)
220 current_function_static_stack_size
= -sp_offset
;
222 /* Early exit for frameless functions. */
226 /* Adjust the stack pointer. For large stack offsets we will
227 do this in multiple parts, before and after saving registers. */
228 reg_offset
= (sp_offset
+ cfun
->machine
->local_vars_size
229 + cfun
->machine
->args_size
);
230 this_offset
= MAX (sp_offset
, -32764);
231 reg_offset
-= this_offset
;
232 sp_offset
-= this_offset
;
234 insn
= emit_insn (gen_frame_addsi3 (stack_pointer_rtx
, stack_pointer_rtx
,
235 GEN_INT (this_offset
)));
236 RTX_FRAME_RELATED_P (insn
) = 1;
238 /* Save callee-saved registers. */
239 for (int regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
240 if (regno
!= HARD_FRAME_POINTER_REGNUM
241 && regno
!= LR_REGNUM
242 && callee_saved_regno_p (regno
))
244 or1k_save_reg (regno
, reg_offset
);
245 reg_offset
+= UNITS_PER_WORD
;
248 /* Save and update frame pointer. */
249 if (callee_saved_regno_p (HARD_FRAME_POINTER_REGNUM
))
251 or1k_save_reg (HARD_FRAME_POINTER_REGNUM
, reg_offset
);
252 if (frame_pointer_needed
)
254 insn
= emit_insn (gen_addsi3 (hard_frame_pointer_rtx
,
256 GEN_INT (-this_offset
)));
257 RTX_FRAME_RELATED_P (insn
) = 1;
259 reg_offset
+= UNITS_PER_WORD
;
262 /* Save the link register. */
263 if (callee_saved_regno_p (LR_REGNUM
))
265 or1k_save_reg (LR_REGNUM
, reg_offset
);
266 reg_offset
+= UNITS_PER_WORD
;
268 gcc_assert (reg_offset
+ this_offset
== 0);
270 /* Allocate the rest of the stack frame, if any. */
273 if (sp_offset
< 2 * -32768)
275 /* For very large offsets, we need a temporary register. */
276 rtx tmp
= gen_rtx_REG (Pmode
, PE_TMP_REGNUM
);
277 emit_move_insn (tmp
, GEN_INT (sp_offset
));
278 insn
= emit_insn (gen_frame_addsi3 (stack_pointer_rtx
,
279 stack_pointer_rtx
, tmp
));
280 if (!frame_pointer_needed
)
282 RTX_FRAME_RELATED_P (insn
) = 1;
283 add_reg_note (insn
, REG_CFA_ADJUST_CFA
,
284 gen_rtx_SET (stack_pointer_rtx
,
285 plus_constant (Pmode
,
292 /* Otherwise, emit one or two sequential subtracts. */
295 this_offset
= MAX (sp_offset
, -32768);
296 sp_offset
-= this_offset
;
298 insn
= emit_insn (gen_frame_addsi3 (stack_pointer_rtx
,
300 GEN_INT (this_offset
)));
301 if (!frame_pointer_needed
)
302 RTX_FRAME_RELATED_P (insn
) = 1;
304 while (sp_offset
!= 0);
309 /* Fix up, or remove, the insn that initialized the pic register. */
310 rtx_insn
*set_got_insn
= cfun
->machine
->set_got_insn
;
311 if (crtl
->uses_pic_offset_table
)
313 rtx reg
= SET_DEST (PATTERN (set_got_insn
));
314 rtx_insn
*insn
= emit_insn_before (gen_set_got (reg
), set_got_insn
);
315 RTX_FRAME_RELATED_P (insn
) = 1;
316 add_reg_note (insn
, REG_CFA_FLUSH_QUEUE
, NULL_RTX
);
318 delete_insn (set_got_insn
);
321 /* Expand the "epilogue" pattern. */
324 or1k_expand_epilogue (void)
326 HOST_WIDE_INT reg_offset
, sp_offset
;
327 rtx insn
, cfa_restores
= NULL
;
329 sp_offset
= cfun
->machine
->total_size
;
333 reg_offset
= cfun
->machine
->local_vars_size
+ cfun
->machine
->args_size
;
335 if (sp_offset
>= 32768 || cfun
->calls_alloca
)
337 /* The saved registers are out of range of the stack pointer.
338 We need to partially deallocate the stack frame now. */
339 if (frame_pointer_needed
)
341 /* Reset the stack pointer to the bottom of the saved regs. */
342 sp_offset
-= reg_offset
;
344 insn
= emit_insn (gen_frame_addsi3 (stack_pointer_rtx
,
345 hard_frame_pointer_rtx
,
346 GEN_INT (-sp_offset
)));
347 RTX_FRAME_RELATED_P (insn
) = 1;
348 add_reg_note (insn
, REG_CFA_DEF_CFA
,
349 plus_constant (Pmode
, stack_pointer_rtx
, sp_offset
));
351 else if (sp_offset
>= 3 * 32768)
353 /* For very large offsets, we need a temporary register. */
354 rtx tmp
= gen_rtx_REG (Pmode
, PE_TMP_REGNUM
);
355 emit_move_insn (tmp
, GEN_INT (reg_offset
));
356 insn
= emit_insn (gen_frame_addsi3 (stack_pointer_rtx
,
357 stack_pointer_rtx
, tmp
));
358 sp_offset
-= reg_offset
;
360 RTX_FRAME_RELATED_P (insn
) = 1;
361 add_reg_note (insn
, REG_CFA_DEF_CFA
,
362 plus_constant (Pmode
, stack_pointer_rtx
, sp_offset
));
366 /* Otherwise, emit one or two sequential additions. */
369 HOST_WIDE_INT this_offset
= MIN (reg_offset
, 32764);
370 reg_offset
-= this_offset
;
371 sp_offset
-= this_offset
;
373 insn
= emit_insn (gen_frame_addsi3 (stack_pointer_rtx
,
375 GEN_INT (this_offset
)));
376 RTX_FRAME_RELATED_P (insn
) = 1;
377 add_reg_note (insn
, REG_CFA_DEF_CFA
,
378 plus_constant (Pmode
, stack_pointer_rtx
,
381 while (sp_offset
>= 32768);
385 /* Restore callee-saved registers. */
386 for (int regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
387 if (regno
!= HARD_FRAME_POINTER_REGNUM
388 && regno
!= LR_REGNUM
389 && callee_saved_regno_p (regno
))
391 cfa_restores
= or1k_restore_reg (regno
, reg_offset
, cfa_restores
);
392 reg_offset
+= UNITS_PER_WORD
;
395 /* Restore frame pointer. */
396 if (callee_saved_regno_p (HARD_FRAME_POINTER_REGNUM
))
398 cfa_restores
= or1k_restore_reg (HARD_FRAME_POINTER_REGNUM
,
399 reg_offset
, cfa_restores
);
400 reg_offset
+= UNITS_PER_WORD
;
403 /* Restore link register. */
404 if (callee_saved_regno_p (LR_REGNUM
))
406 cfa_restores
= or1k_restore_reg (LR_REGNUM
, reg_offset
, cfa_restores
);
407 reg_offset
+= UNITS_PER_WORD
;
409 gcc_assert (reg_offset
== sp_offset
);
411 /* Restore stack pointer. */
412 insn
= emit_insn (gen_frame_addsi3 (stack_pointer_rtx
, stack_pointer_rtx
,
413 GEN_INT (sp_offset
)));
414 RTX_FRAME_RELATED_P (insn
) = 1;
415 REG_NOTES (insn
) = cfa_restores
;
416 add_reg_note (insn
, REG_CFA_DEF_CFA
, stack_pointer_rtx
);
418 /* Move up to the stack frame of an exception handler. */
419 if (crtl
->calls_eh_return
)
420 emit_insn (gen_addsi3 (stack_pointer_rtx
, stack_pointer_rtx
,
421 EH_RETURN_STACKADJ_RTX
));
424 /* Worker for PROFILE_HOOK.
425 The OpenRISC profile hook uses the link register which will get clobbered by
426 the GOT setup RTX. This sets up a placeholder to allow injecting of the GOT
427 setup RTX to avoid clobbering. */
430 or1k_profile_hook (void)
432 rtx a1
= gen_rtx_REG (Pmode
, 3);
433 rtx ra
= get_hard_reg_initial_val (Pmode
, LR_REGNUM
);
434 rtx fun
= gen_rtx_SYMBOL_REF (Pmode
, "_mcount");
436 /* Keep track of where we setup the _mcount argument so we can insert the
437 GOT setup RTX after it. */
438 cfun
->machine
->set_mcount_arg_insn
= emit_move_insn (a1
, ra
);
440 emit_library_call (fun
, LCT_NORMAL
, VOIDmode
, a1
, Pmode
);
443 /* Worker for TARGET_INIT_PIC_REG.
444 Initialize the cfun->machine->set_got_insn rtx and insert it at the entry
445 of the current function. The rtx is just a temporary placeholder for
446 the GOT and will be replaced or removed during or1k_expand_prologue. */
449 or1k_init_pic_reg (void)
453 cfun
->machine
->set_got_insn
=
454 emit_insn_after (gen_set_got_tmp (pic_offset_table_rtx
),
455 cfun
->machine
->set_mcount_arg_insn
);
460 cfun
->machine
->set_got_insn
=
461 emit_insn (gen_set_got_tmp (pic_offset_table_rtx
));
463 rtx_insn
*seq
= get_insns ();
466 edge entry_edge
= single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun
));
467 insert_insn_on_edge (seq
, entry_edge
);
468 commit_one_edge_insertion (entry_edge
);
472 #undef TARGET_INIT_PIC_REG
473 #define TARGET_INIT_PIC_REG or1k_init_pic_reg
474 #undef TARGET_USE_PSEUDO_PIC_REG
475 #define TARGET_USE_PSEUDO_PIC_REG hook_bool_void_true
477 /* Worker for INITIAL_FRAME_ADDRESS_RTX.
478 Returns the RTX representing the address of the initial stack frame. */
481 or1k_initial_frame_addr ()
483 /* Use this to force a stack frame for the current function. */
484 crtl
->accesses_prior_frames
= 1;
485 return arg_pointer_rtx
;
488 /* Worker for DYNAMIC_CHAIN_ADDRESS.
489 Returns the RTX representing the address of where the caller's frame pointer
490 may be stored on the stack. */
493 or1k_dynamic_chain_addr (rtx frame
)
495 return plus_constant (Pmode
, frame
, -2 * UNITS_PER_WORD
);
498 /* Worker for RETURN_ADDR_RTX.
499 Returns the RTX representing the address of where the link register may be
500 stored on the stack. */
503 or1k_return_addr (int, rtx frame
)
505 return gen_frame_mem (Pmode
, plus_constant (Pmode
, frame
, -UNITS_PER_WORD
));
508 /* Worker for TARGET_FRAME_POINTER_REQUIRED.
509 Returns true if the current function must use a frame pointer. */
512 or1k_frame_pointer_required ()
514 /* ??? While IRA checks accesses_prior_frames, reload does not.
515 We do want the frame pointer for this case. */
516 return (crtl
->accesses_prior_frames
);
519 /* Expand the "eh_return" pattern.
520 Used for defining __builtin_eh_return, this will emit RTX to override the
521 current function's return address stored on the stack. The emitted RTX is
522 inserted before the epilogue so we can't just update the link register.
523 This is used when handling exceptions to jump into the exception handler
524 catch block upon return from _Unwind_RaiseException. */
527 or1k_expand_eh_return (rtx eh_addr
)
531 lraddr
= gen_frame_mem (Pmode
, plus_constant (Pmode
,
534 /* Set address to volatile to ensure the store doesn't get optimized out. */
535 MEM_VOLATILE_P (lraddr
) = true;
536 emit_move_insn (lraddr
, eh_addr
);
539 /* Helper for defining INITIAL_ELIMINATION_OFFSET.
540 We allow the following eliminiations:
544 HARD_FP and AP are the same which is handled below. */
547 or1k_initial_elimination_offset (int from
, int to
)
549 HOST_WIDE_INT offset
;
551 /* Set OFFSET to the offset from the stack pointer. */
554 /* Incoming args are all the way up at the previous frame. */
555 case ARG_POINTER_REGNUM
:
556 offset
= cfun
->machine
->total_size
;
559 /* Local args grow downward from the saved registers. */
560 case FRAME_POINTER_REGNUM
:
561 offset
= cfun
->machine
->args_size
+ cfun
->machine
->local_vars_size
;
568 if (to
== HARD_FRAME_POINTER_REGNUM
)
569 offset
-= cfun
->machine
->total_size
;
574 /* Worker for TARGET_LEGITIMATE_ADDRESS_P.
575 Returns true if X is a legitimate address RTX on OpenRISC. */
578 or1k_legitimate_address_p (machine_mode
, rtx x
, bool strict_p
,
579 code_helper
= ERROR_MARK
)
583 switch (GET_CODE (x
))
591 addend
= XEXP (x
, 1);
594 /* Register elimination is going to adjust all of these offsets.
595 We might as well keep them as a unit until then. */
596 if (!strict_p
&& virtual_frame_reg_operand (base
, VOIDmode
))
597 return CONST_INT_P (addend
);
598 if (!satisfies_constraint_I (addend
))
607 switch (GET_CODE (x
))
612 /* Assume legitimize_address properly categorized
613 the symbol. Continue to check the base. */
622 case UNSPEC_GOTTPOFF
:
623 /* Assume legitimize_address properly categorized
624 the symbol. Continue to check the base. */
640 unsigned regno
= REGNO (base
);
641 if (regno
>= FIRST_PSEUDO_REGISTER
)
644 regno
= reg_renumber
[regno
];
651 return REGNO_OK_FOR_BASE_P (regno
);
654 /* Return the TLS type for TLS symbols, 0 otherwise. */
657 or1k_tls_symbolic_operand (rtx op
)
660 split_const (op
, &sym
, &addend
);
661 if (SYMBOL_REF_P (sym
))
662 return SYMBOL_REF_TLS_MODEL (sym
);
663 return TLS_MODEL_NONE
;
666 /* Get a reference to the '__tls_get_addr' symbol. */
668 static GTY(()) rtx gen_tls_tga
;
671 gen_tls_get_addr (void)
674 gen_tls_tga
= init_one_libfunc ("__tls_get_addr");
678 /* Emit a call to '__tls_get_addr'. */
681 or1k_tls_call (rtx dest
, rtx arg
)
683 emit_library_call_value (gen_tls_get_addr (), dest
, LCT_CONST
,
687 /* Helper for or1k_legitimize_address_1. Wrap X in an unspec. */
690 gen_sym_unspec (rtx x
, int kind
)
692 return gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, x
), kind
);
695 /* Worker for TARGET_LEGITIMIZE_ADDRESS_DISPLACEMENT.
696 Split an out-of-range address displacement into hi and lo parts.
697 The hi part will have to be loaded into a register separately,
698 but the low part will be folded into the memory operand. */
701 or1k_legitimize_address_displacement (rtx
*off1
, rtx
*off2
,
702 poly_int64 poly_offset
, machine_mode
)
704 HOST_WIDE_INT orig_offset
= poly_offset
;
705 HOST_WIDE_INT lo
, hi
;
707 /* If the displacement is within range of 2 addi insns, prefer that.
708 Otherwise split as per normal, at which point the register allocator
709 will see that OFF1 is not a valid add3 operand and load it into
710 a register, as desired. */
711 if (orig_offset
>= 0 && orig_offset
< 2 * 32767)
714 lo
= orig_offset
- hi
;
716 else if (orig_offset
< 0 && orig_offset
>= 2 * -32768)
719 lo
= orig_offset
- hi
;
723 lo
= sext_hwi (orig_offset
, 16);
724 hi
= orig_offset
- lo
;
727 *off1
= GEN_INT (hi
);
728 *off2
= GEN_INT (lo
);
732 #undef TARGET_LEGITIMIZE_ADDRESS_DISPLACEMENT
733 #define TARGET_LEGITIMIZE_ADDRESS_DISPLACEMENT \
734 or1k_legitimize_address_displacement
736 /* Helper function to implement both TARGET_LEGITIMIZE_ADDRESS and expand the
737 patterns "movqi", "movqi" and "movsi". Returns an valid OpenRISC RTX that
738 represents the argument X which is an invalid address RTX. The argument
739 SCRATCH may be used as a temporary when building addresses. */
742 or1k_legitimize_address_1 (rtx x
, rtx scratch
)
744 rtx base
, addend
, t1
, t2
;
745 tls_model tls_kind
= TLS_MODEL_NONE
;
746 bool is_local
= true;
748 split_const (x
, &base
, &addend
);
749 switch (GET_CODE (base
))
752 gcc_assert (can_create_pseudo_p ());
753 base
= force_reg (Pmode
, base
);
761 tls_kind
= SYMBOL_REF_TLS_MODEL (base
);
762 is_local
= SYMBOL_REF_LOCAL_P (base
);
769 t1
= can_create_pseudo_p () ? gen_reg_rtx (Pmode
) : scratch
;
772 emit_insn (gen_rtx_SET (t1
, gen_rtx_HIGH (Pmode
, x
)));
773 return gen_rtx_LO_SUM (Pmode
, t1
, x
);
777 crtl
->uses_pic_offset_table
= 1;
778 t2
= gen_sym_unspec (x
, UNSPEC_GOTOFF
);
779 emit_insn (gen_rtx_SET (t1
, gen_rtx_HIGH (Pmode
, t2
)));
780 emit_insn (gen_add3_insn (t1
, t1
, pic_offset_table_rtx
));
781 return gen_rtx_LO_SUM (Pmode
, t1
, copy_rtx (t2
));
785 base
= gen_sym_unspec (base
, UNSPEC_GOT
);
786 crtl
->uses_pic_offset_table
= 1;
787 if (TARGET_CMODEL_LARGE
)
789 emit_insn (gen_rtx_SET (t1
, gen_rtx_HIGH (Pmode
, base
)));
790 emit_insn (gen_add3_insn (t1
, t1
, pic_offset_table_rtx
));
791 t2
= gen_rtx_LO_SUM (Pmode
, t1
, base
);
794 t2
= gen_rtx_LO_SUM (Pmode
, pic_offset_table_rtx
, base
);
795 t2
= gen_const_mem (Pmode
, t2
);
796 emit_insn (gen_rtx_SET (t1
, t2
));
801 case TLS_MODEL_GLOBAL_DYNAMIC
:
802 case TLS_MODEL_LOCAL_DYNAMIC
:
803 /* TODO: For now, treat LD as GD. */
804 t1
= gen_reg_rtx (Pmode
);
805 base
= gen_sym_unspec (base
, UNSPEC_TLSGD
);
806 emit_insn (gen_rtx_SET (t1
, gen_rtx_HIGH (Pmode
, base
)));
807 emit_insn (gen_rtx_SET (t1
, gen_rtx_LO_SUM (Pmode
, t1
, base
)));
808 crtl
->uses_pic_offset_table
= 1;
809 emit_insn (gen_add3_insn (t1
, t1
, pic_offset_table_rtx
));
810 base
= gen_reg_rtx (Pmode
);
811 or1k_tls_call (base
, t1
);
814 case TLS_MODEL_INITIAL_EXEC
:
815 t1
= gen_reg_rtx (Pmode
);
816 t2
= gen_reg_rtx (Pmode
);
817 base
= gen_sym_unspec (base
, UNSPEC_GOTTPOFF
);
818 emit_insn (gen_rtx_SET (t1
, gen_rtx_HIGH (Pmode
, base
)));
819 crtl
->uses_pic_offset_table
= 1;
820 emit_insn (gen_add3_insn (t1
, t1
, pic_offset_table_rtx
));
821 t1
= gen_rtx_LO_SUM (Pmode
, t1
, base
);
822 emit_move_insn (t2
, gen_const_mem (Pmode
, t1
));
823 t1
= gen_rtx_REG (Pmode
, TLS_REGNUM
);
824 emit_insn (gen_add3_insn (t2
, t2
, t1
));
828 case TLS_MODEL_LOCAL_EXEC
:
829 x
= gen_sym_unspec (x
, UNSPEC_TPOFF
);
830 t1
= gen_reg_rtx (Pmode
);
831 emit_insn (gen_rtx_SET (t1
, gen_rtx_HIGH (Pmode
, x
)));
832 t2
= gen_rtx_REG (Pmode
, TLS_REGNUM
);
833 emit_insn (gen_add3_insn (t1
, t1
, t2
));
834 return gen_rtx_LO_SUM (Pmode
, t1
, x
);
841 /* Accept what we may have already emitted. */
848 /* If we get here, we still have addend outstanding. */
849 gcc_checking_assert (register_operand (base
, Pmode
));
850 if (addend
== const0_rtx
)
852 if (satisfies_constraint_I (addend
)
853 || virtual_frame_reg_operand (base
, VOIDmode
))
854 return gen_rtx_PLUS (Pmode
, base
, addend
);
858 bool ok
= (or1k_legitimize_address_displacement
859 (&hi
, &lo
, INTVAL (addend
), SImode
));
862 t2
= can_create_pseudo_p () ? gen_reg_rtx (Pmode
) : scratch
;
863 if (satisfies_constraint_I (hi
))
864 emit_insn (gen_addsi3 (t2
, base
, hi
));
867 t1
= can_create_pseudo_p () ? gen_reg_rtx (Pmode
) : scratch
;
868 emit_move_insn (t1
, hi
);
869 emit_insn (gen_add3_insn (t2
, base
, t1
));
871 if (lo
== const0_rtx
)
874 return gen_rtx_PLUS (Pmode
, t2
, lo
);
878 /* Worker for TARGET_LEGITIMIZE_ADDRESS.
879 This delegates implementation to or1k_legitimize_address_1. */
882 or1k_legitimize_address (rtx x
, rtx
/* oldx */, machine_mode
)
884 return or1k_legitimize_address_1 (x
, NULL_RTX
);
887 #undef TARGET_LEGITIMIZE_ADDRESS
888 #define TARGET_LEGITIMIZE_ADDRESS or1k_legitimize_address
890 /* Worker for TARGET_DELEGITIMIZE_ADDRESS.
891 In the name of slightly smaller debug output, and to cater to
892 general assembler lossage, recognize PIC+GOTOFF and turn it back
893 into a direct symbol reference. */
896 or1k_delegitimize_address (rtx x
)
898 if (GET_CODE (x
) == UNSPEC
)
900 /* The LO_SUM to which X was attached has been stripped.
901 Since the only legitimate address we could have been computing
902 is that of the symbol, assume that's what we've done. */
903 if (XINT (x
, 1) == UNSPEC_GOTOFF
)
904 return XVECEXP (x
, 0, 0);
908 rtx addr
= XEXP (x
, 0);
909 if (GET_CODE (addr
) == LO_SUM
910 && XEXP (addr
, 0) == pic_offset_table_rtx
)
912 rtx inner
= XEXP (addr
, 1);
913 if (GET_CODE (inner
) == UNSPEC
914 && XINT (inner
, 1) == UNSPEC_GOT
)
915 return XVECEXP (inner
, 0, 0);
918 return delegitimize_mem_from_attrs (x
);
921 #undef TARGET_DELEGITIMIZE_ADDRESS
922 #define TARGET_DELEGITIMIZE_ADDRESS or1k_delegitimize_address
924 /* Worker for TARGET_CANNOT_FORCE_CONST_MEM.
925 Primarily this is required for TLS symbols, but given that our move
926 patterns *ought* to be able to handle any symbol at any time, we
927 should never be spilling symbolic operands to the constant pool, ever. */
930 or1k_cannot_force_const_mem (machine_mode
, rtx x
)
932 rtx_code code
= GET_CODE (x
);
933 return (code
== SYMBOL_REF
939 #undef TARGET_CANNOT_FORCE_CONST_MEM
940 #define TARGET_CANNOT_FORCE_CONST_MEM or1k_cannot_force_const_mem
942 /* Worker for TARGET_LEGITIMATE_CONSTANT_P.
943 Returns true is the RTX X represents a constant that can be used as an
944 immediate operand in OpenRISC. */
947 or1k_legitimate_constant_p (machine_mode
, rtx x
)
949 switch (GET_CODE (x
))
954 /* We construct these, rather than spilling to memory. */
960 /* These may need to be split and not reconstructed. */
961 return or1k_tls_symbolic_operand (x
) == TLS_MODEL_NONE
;
968 #undef TARGET_LEGITIMATE_CONSTANT_P
969 #define TARGET_LEGITIMATE_CONSTANT_P or1k_legitimate_constant_p
971 /* Worker for TARGET_PASS_BY_REFERENCE.
972 Returns true if an argument ARG should be passed by reference as
973 required by the OpenRISC ABI. On OpenRISC structures, unions and
974 arguments larger than 64-bits are passed by reference. */
977 or1k_pass_by_reference (cumulative_args_t
, const function_arg_info
&arg
)
979 if (arg
.aggregate_type_p ())
981 HOST_WIDE_INT size
= arg
.type_size_in_bytes ();
982 return size
< 0 || size
> 8;
985 /* Worker for TARGET_FUNCTION_VALUE.
986 Returns an RTX representing the location where function return values will
987 be stored. On OpenRISC this is the register r11. 64-bit return value's
988 upper 32-bits are returned in r12, this is automatically done by GCC. */
991 or1k_function_value (const_tree valtype
,
992 const_tree
/* fn_decl_or_type */,
995 return gen_rtx_REG (TYPE_MODE (valtype
), RV_REGNUM
);
998 /* Worker for TARGET_LIBCALL_VALUE.
999 Returns an RTX representing the location where function return values to
1000 external libraries will be stored. On OpenRISC this the same as local
1004 or1k_libcall_value (machine_mode mode
,
1005 const_rtx
/* fun */)
1007 return gen_rtx_REG (mode
, RV_REGNUM
);
1011 /* Worker for TARGET_FUNCTION_VALUE_REGNO_P.
1012 Returns true if REGNO is a valid register for storing a function return
1016 or1k_function_value_regno_p (const unsigned int regno
)
1018 return (regno
== RV_REGNUM
);
1021 /* Worker for TARGET_STRICT_ARGUMENT_NAMING.
1022 Return true always as on OpenRISC the last argument in a variatic function
1026 or1k_strict_argument_naming (cumulative_args_t
/* ca */)
1031 #undef TARGET_STRICT_ARGUMENT_NAMING
1032 #define TARGET_STRICT_ARGUMENT_NAMING or1k_strict_argument_naming
1034 /* Worker for TARGET_FUNCTION_ARG.
1035 Return the next register to be used to hold a function argument or NULL_RTX
1036 if there's no more space. Arugment CUM_V represents the current argument
1037 offset, zero for the first function argument. OpenRISC function arguments
1038 maybe be passed in registers r3 to r8. */
1041 or1k_function_arg (cumulative_args_t cum_v
, const function_arg_info
&arg
)
1043 /* Handle the special marker for the end of the arguments. */
1044 if (arg
.end_marker_p ())
1047 CUMULATIVE_ARGS
*cum
= get_cumulative_args (cum_v
);
1048 int nreg
= CEIL (GET_MODE_SIZE (arg
.mode
), UNITS_PER_WORD
);
1050 /* Note that all large arguments are passed by reference. */
1051 gcc_assert (nreg
<= 2);
1052 if (arg
.named
&& *cum
+ nreg
<= 6)
1053 return gen_rtx_REG (arg
.mode
, *cum
+ 3);
1058 /* Worker for TARGET_FUNCTION_ARG_ADVANCE.
1059 Update the cumulative args descriptor CUM_V to advance past the next function
1060 argument. Note, this is not called for arguments passed on the stack. */
1063 or1k_function_arg_advance (cumulative_args_t cum_v
,
1064 const function_arg_info
&arg
)
1066 CUMULATIVE_ARGS
*cum
= get_cumulative_args (cum_v
);
1067 int nreg
= CEIL (GET_MODE_SIZE (arg
.mode
), UNITS_PER_WORD
);
1069 /* Note that all large arguments are passed by reference. */
1070 gcc_assert (nreg
<= 2);
1075 /* worker function for TARGET_RETURN_IN_MEMORY.
1076 Returns true if the argument of TYPE should be returned in memory. On
1077 OpenRISC this is any value larger than 64-bits. */
1080 or1k_return_in_memory (const_tree type
, const_tree
/* fntype */)
1082 const HOST_WIDE_INT size
= int_size_in_bytes (type
);
1083 return (size
== -1 || size
> (2 * UNITS_PER_WORD
));
1086 /* Print reloc (x + add). */
1089 output_addr_reloc (FILE *stream
, rtx x
, HOST_WIDE_INT add
, const char *reloc
)
1093 fputs (reloc
, stream
);
1094 fputc ('(', stream
);
1096 output_addr_const (stream
, x
);
1100 fputc ('+', stream
);
1101 fprintf (stream
, HOST_WIDE_INT_PRINT_DEC
, add
);
1104 fputc (')', stream
);
1126 print_reloc (FILE *stream
, rtx x
, HOST_WIDE_INT add
, reloc_kind kind
)
1128 /* All data relocations. A NULL in this table indicates a form that
1129 we expect to never generate, while "" indicates a form that requires
1130 no special markup. */
1131 static const char * const relocs
[RKIND_MAX
][RTYPE_MAX
] = {
1132 { "lo", "got", "gotofflo", "tpofflo", "gottpofflo", "tlsgdlo" },
1133 { "ha", "gotha", "gotoffha", "tpoffha", "gottpoffha", "tlsgdhi" },
1135 reloc_type type
= RTYPE_DIRECT
;
1137 if (GET_CODE (x
) == UNSPEC
)
1139 switch (XINT (x
, 1))
1145 type
= RTYPE_GOTOFF
;
1150 case UNSPEC_GOTTPOFF
:
1151 type
= RTYPE_GOTTPOFF
;
1157 output_operand_lossage ("invalid relocation");
1160 x
= XVECEXP (x
, 0, 0);
1163 const char *reloc
= relocs
[kind
][type
];
1165 output_operand_lossage ("invalid relocation");
1167 output_addr_reloc (stream
, x
, add
, reloc
);
1170 /* Worker for TARGET_PRINT_OPERAND_ADDRESS.
1171 Prints the argument ADDR, an address RTX, to the file FILE. The output is
1172 formed as expected by the OpenRISC assembler. Examples:
1176 (plus:SI (reg:SI 3) (const_int 4)) 0x4(r3)
1177 (lo_sum:SI (reg:SI 3) (symbol_ref:SI ("x")))) lo(x)(r3) */
1180 or1k_print_operand_address (FILE *file
, machine_mode
, rtx addr
)
1184 switch (GET_CODE (addr
))
1191 offset
= XEXP (addr
, 1);
1192 addr
= XEXP (addr
, 0);
1193 gcc_assert (CONST_INT_P (offset
));
1194 if (GET_CODE (addr
) == LO_SUM
)
1196 print_reloc (file
, XEXP (addr
, 1), INTVAL (offset
), RKIND_LO
);
1197 addr
= XEXP (addr
, 0);
1200 output_addr_const (file
, offset
);
1204 offset
= XEXP (addr
, 1);
1205 addr
= XEXP (addr
, 0);
1206 print_reloc (file
, offset
, 0, RKIND_LO
);
1210 output_addr_const (file
, addr
);
1214 fprintf (file
, "(%s)", reg_names
[REGNO (addr
)]);
1217 /* Worker for TARGET_PRINT_OPERAND.
1218 Print operand X, an RTX, to the file FILE. The output is formed as expected
1219 by the OpenRISC assember. CODE is the letter following a '%' in an
1220 instrunction template used to control the RTX output. Example(s):
1222 CODE RTX OUTPUT COMMENT
1223 0 (reg:SI 3) r3 output an operand
1224 r (reg:SI 3) r3 output a register or const zero
1225 H (reg:SI 3) r4 output the high pair register
1226 h (symbol_ref:SI ("x")) ha(x) output a signed high relocation
1227 L (symbol_ref:SI ("x")) lo(x) output a low relocation
1229 Note, '#' is a special code used to fill the branch delay slot with an l.nop
1230 instruction. The l.nop (no-op) instruction is only outputted when the delay
1231 slot has not been filled. */
1234 or1k_print_operand (FILE *file
, rtx x
, int code
)
1241 /* Conditionally add a nop in unfilled delay slot. */
1242 if (final_sequence
== NULL
)
1243 fputs ("\n\t l.nop\n", file
);
1248 fprintf (file
, "%s", reg_names
[REGNO (operand
)]);
1249 else if (x
== CONST0_RTX (GET_MODE (x
)))
1250 fprintf (file
, "r0");
1252 output_operand_lossage ("invalid %%r value");
1257 fprintf (file
, "%s", reg_names
[REGNO (operand
) + 1]);
1259 output_operand_lossage ("invalid %%H value");
1265 if (GET_MODE (x
) == DFmode
|| GET_MODE (x
) == DImode
)
1266 fprintf (file
, "%s,%s", reg_names
[REGNO (operand
)],
1267 reg_names
[REGNO (operand
) + 1]);
1269 fprintf (file
, "%s", reg_names
[REGNO (operand
)]);
1272 output_operand_lossage ("invalid %%d value");
1276 print_reloc (file
, x
, 0, RKIND_HI
);
1279 print_reloc (file
, x
, 0, RKIND_LO
);
1282 if (!flag_pic
|| SYMBOL_REF_LOCAL_P (x
))
1283 output_addr_const (file
, x
);
1285 output_addr_reloc (file
, x
, 0, "plt");
1289 /* Print an operand as without a modifier letter. */
1290 switch (GET_CODE (operand
))
1293 if (REGNO (operand
) > 31)
1294 internal_error ("internal error: bad register: %d",
1296 fprintf (file
, "%s", reg_names
[REGNO (operand
)]);
1300 output_address (GET_MODE (XEXP (operand
, 0)), XEXP (operand
, 0));
1305 output_asm_label (operand
);
1309 /* No need to handle all strange variants, let output_addr_const
1311 if (CONSTANT_P (operand
))
1312 output_addr_const (file
, operand
);
1314 internal_error ("unexpected operand: %d", GET_CODE (operand
));
1320 output_operand_lossage ("unknown operand letter: '%c'", code
);
1325 /* Worker for TARGET_TRAMPOLINE_INIT.
1326 This is called to initialize a trampoline. The argument M_TRAMP is an RTX
1327 for the memory block to be initialized with trampoline code. The argument
1328 FNDECL contains the definition of the nested function to be called, we use
1329 this to get the function's address. The argument CHAIN is an RTX for the
1330 static chain value to be passed to the nested function. */
1333 or1k_trampoline_init (rtx m_tramp
, tree fndecl
, rtx chain
)
1335 const unsigned movhi_r13
= (0x06u
<< 26) | (13 << 21);
1336 const unsigned movhi_r11
= (0x06u
<< 26) | (11 << 21);
1337 const unsigned ori_r13_r13
= (0x2a << 26) | (13 << 21) | (13 << 16);
1338 const unsigned ori_r11_r11
= (0x2a << 26) | (11 << 21) | (11 << 16);
1339 const unsigned jr_r13
= (0x11 << 26) | (13 << 11);
1340 rtx tramp
[5], fnaddr
, f_hi
, f_lo
, c_hi
, c_lo
;
1342 fnaddr
= force_operand (XEXP (DECL_RTL (fndecl
), 0), NULL
);
1343 f_hi
= expand_binop (SImode
, lshr_optab
, fnaddr
, GEN_INT (16),
1344 NULL
, true, OPTAB_DIRECT
);
1345 f_lo
= expand_binop (SImode
, and_optab
, fnaddr
, GEN_INT (0xffff),
1346 NULL
, true, OPTAB_DIRECT
);
1348 chain
= force_operand (chain
, NULL
);
1349 c_hi
= expand_binop (SImode
, lshr_optab
, chain
, GEN_INT (16),
1350 NULL
, true, OPTAB_DIRECT
);
1351 c_lo
= expand_binop (SImode
, and_optab
, chain
, GEN_INT (0xffff),
1352 NULL
, true, OPTAB_DIRECT
);
1354 /* We want to generate
1356 l.movhi r13,hi(nested_func)
1357 l.movhi r11,hi(static_chain)
1358 l.ori r13,r13,lo(nested_func)
1360 l.ori r11,r11,lo(static_chain)
1362 tramp
[0] = expand_binop (SImode
, ior_optab
, f_hi
,
1363 gen_int_mode (movhi_r13
, SImode
),
1364 f_hi
, true, OPTAB_DIRECT
);
1365 tramp
[1] = expand_binop (SImode
, ior_optab
, c_hi
,
1366 gen_int_mode (movhi_r11
, SImode
),
1367 c_hi
, true, OPTAB_DIRECT
);
1368 tramp
[2] = expand_binop (SImode
, ior_optab
, f_lo
,
1369 gen_int_mode (ori_r13_r13
, SImode
),
1370 f_lo
, true, OPTAB_DIRECT
);
1371 tramp
[4] = expand_binop (SImode
, ior_optab
, c_lo
,
1372 gen_int_mode (ori_r11_r11
, SImode
),
1373 c_lo
, true, OPTAB_DIRECT
);
1374 tramp
[3] = gen_int_mode (jr_r13
, SImode
);
1376 for (int i
= 0; i
< 5; ++i
)
1378 rtx mem
= adjust_address (m_tramp
, SImode
, i
* 4);
1379 emit_move_insn (mem
, tramp
[i
]);
1382 /* Flushing the trampoline from the instruction cache needs
1386 /* Worker for TARGET_HARD_REGNO_MODE_OK.
1387 Returns true if the hard register REGNO is ok for storing values of mode
1391 or1k_hard_regno_mode_ok (unsigned int regno
, machine_mode mode
)
1393 /* For OpenRISC, GENERAL_REGS can hold anything, while
1394 FLAG_REGS are really single bits within SP[SR]. */
1395 if (REGNO_REG_CLASS (regno
) == FLAG_REGS
)
1396 return mode
== BImode
;
1400 #undef TARGET_HARD_REGNO_MODE_OK
1401 #define TARGET_HARD_REGNO_MODE_OK or1k_hard_regno_mode_ok
1403 /* Worker for TARGET_CAN_CHANGE_MODE_CLASS.
1404 Returns true if its ok to change a register in class RCLASS from mode FROM to
1405 mode TO. In general OpenRISC registers, other than special flags, handle all
1406 supported classes. */
1409 or1k_can_change_mode_class (machine_mode from
, machine_mode to
,
1412 if (rclass
== FLAG_REGS
)
1417 #undef TARGET_CAN_CHANGE_MODE_CLASS
1418 #define TARGET_CAN_CHANGE_MODE_CLASS or1k_can_change_mode_class
1420 /* Expand the patterns "movqi", "movqi" and "movsi". The argument OP0 is the
1421 destination and OP1 is the source. This expands to set OP0 to OP1. OpenRISC
1422 cannot do memory to memory assignments so for those cases we force one
1423 argument to a register. Constants that can't fit into a 16-bit immediate are
1424 split. Symbols are legitimized using split relocations. */
1427 or1k_expand_move (machine_mode mode
, rtx op0
, rtx op1
)
1431 if (!const0_operand (op1
, mode
))
1432 op1
= force_reg (mode
, op1
);
1434 else if (mode
== QImode
|| mode
== HImode
)
1436 /* ??? Maybe promote MEMs and CONST_INT to SImode,
1437 and then squish back with gen_lowpart. */
1441 switch (GET_CODE (op1
))
1444 if (!input_operand (op1
, mode
))
1446 HOST_WIDE_INT i
= INTVAL (op1
);
1447 HOST_WIDE_INT lo
= i
& 0xffff;
1448 HOST_WIDE_INT hi
= i
^ lo
;
1449 rtx subtarget
= op0
;
1451 if (!cse_not_expected
&& can_create_pseudo_p ())
1452 subtarget
= gen_reg_rtx (SImode
);
1453 emit_insn (gen_rtx_SET (subtarget
, GEN_INT (hi
)));
1454 emit_insn (gen_iorsi3 (op0
, subtarget
, GEN_INT (lo
)));
1462 op1
= or1k_legitimize_address_1 (op1
, op0
);
1469 emit_insn (gen_rtx_SET (op0
, op1
));
1472 /* Used to expand patterns "movsicc", "movqicc", "movhicc", "cstoresi4" and
1474 Expands a comparison where OPERANDS is an array of RTX describing the
1475 comparison. The first argument OPERANDS[0] is the operator and OPERANDS[1]
1476 and OPERANDS[2] are the operands. Split out the compare into SR[F] and
1477 return a new operation in OPERANDS[0]. The inputs OPERANDS[1] and
1478 OPERANDS[2] are not directly used, only overridden. */
1481 or1k_expand_compare (rtx
*operands
)
1483 rtx sr_f
= gen_rtx_REG (BImode
, SR_F_REGNUM
);
1484 rtx righthand_op
= XEXP (operands
[0], 1);
1485 rtx_code cmp_code
= GET_CODE (operands
[0]);
1486 bool flag_check_ne
= true;
1488 /* Integer RTL may receive an immediate in argument 1 of the compare, this is
1489 not supported unless we have l.sf*i instructions, force them into
1491 if (!TARGET_SFIMM
&& CONST_INT_P (righthand_op
))
1492 XEXP (operands
[0], 1) = force_reg (SImode
, righthand_op
);
1494 /* Normalize comparison operators to ones OpenRISC support. */
1499 flag_check_ne
= false;
1503 cmp_code
= UNORDERED
;
1504 flag_check_ne
= false;
1511 /* Emit the given comparison into the Flag bit. */
1512 PUT_MODE (operands
[0], BImode
);
1513 PUT_CODE (operands
[0], cmp_code
);
1514 emit_insn (gen_rtx_SET (sr_f
, operands
[0]));
1516 /* Adjust the operands for use in the caller. */
1517 operands
[0] = flag_check_ne
? gen_rtx_NE (VOIDmode
, sr_f
, const0_rtx
)
1518 : gen_rtx_EQ (VOIDmode
, sr_f
, const0_rtx
);
1520 operands
[2] = const0_rtx
;
1523 /* Expand the patterns "call", "sibcall", "call_value" and "sibcall_value".
1524 Expands a function call where argument RETVAL is an optional RTX providing
1525 return value storage, the argument FNADDR is and RTX describing the function
1526 to call, the argument CALLARG1 is the number or registers used as operands
1527 and the argument SIBCALL should be true if this is a nested function call.
1528 If FNADDR is a non local symbol and FLAG_PIC is enabled this will generate
1532 or1k_expand_call (rtx retval
, rtx fnaddr
, rtx callarg1
, bool sibcall
)
1534 rtx call
, use
= NULL
;
1536 /* Calls via the PLT require the PIC register. */
1538 && GET_CODE (XEXP (fnaddr
, 0)) == SYMBOL_REF
1539 && !SYMBOL_REF_LOCAL_P (XEXP (fnaddr
, 0)))
1541 crtl
->uses_pic_offset_table
= 1;
1542 rtx hard_pic
= gen_rtx_REG (Pmode
, REAL_PIC_OFFSET_TABLE_REGNUM
);
1543 emit_move_insn (hard_pic
, pic_offset_table_rtx
);
1544 use_reg (&use
, hard_pic
);
1547 if (!call_insn_operand (XEXP (fnaddr
, 0), Pmode
))
1549 fnaddr
= copy_to_mode_reg (Pmode
, XEXP (fnaddr
, 0));
1550 fnaddr
= gen_rtx_MEM (SImode
, fnaddr
);
1553 call
= gen_rtx_CALL (VOIDmode
, fnaddr
, callarg1
);
1555 call
= gen_rtx_SET (retval
, call
);
1557 /* Normal calls clobber LR. This is required in order to
1558 prevent e.g. a prologue store of LR being placed into
1559 the delay slot of the call, after it has been updated. */
1562 rtx clob
= gen_rtx_CLOBBER (VOIDmode
, gen_rtx_REG (Pmode
, LR_REGNUM
));
1563 call
= gen_rtx_PARALLEL (VOIDmode
, gen_rtvec (2, call
, clob
));
1565 call
= emit_call_insn (call
);
1567 CALL_INSN_FUNCTION_USAGE (call
) = use
;
1570 /* Worker for TARGET_FUNCTION_OK_FOR_SIBCALL.
1571 Returns true if the function declared by DECL is ok for calling as a nested
1575 or1k_function_ok_for_sibcall (tree decl
, tree
/* exp */)
1577 /* We can sibcall to any function if not PIC. */
1581 /* We can sibcall any indirect function. */
1585 /* If the call may go through the PLT, we need r16 live. */
1586 return targetm
.binds_local_p (decl
);
1589 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
1590 #define TARGET_FUNCTION_OK_FOR_SIBCALL or1k_function_ok_for_sibcall
1592 /* Worker for TARGET_RTX_COSTS. */
1595 or1k_rtx_costs (rtx x
, machine_mode mode
, int outer_code
, int /* opno */,
1596 int *total
, bool /* speed */)
1598 switch (GET_CODE (x
))
1601 if (x
== const0_rtx
)
1603 else if ((outer_code
== PLUS
|| outer_code
== XOR
|| outer_code
== MULT
)
1604 && satisfies_constraint_I (x
))
1606 else if ((outer_code
== AND
|| outer_code
== IOR
)
1607 && satisfies_constraint_K (x
))
1609 else if (satisfies_constraint_I (x
)
1610 || satisfies_constraint_K (x
)
1611 || satisfies_constraint_M (x
))
1614 *total
= COSTS_N_INSNS (2);
1618 *total
= (x
== CONST0_RTX (mode
) ? 0 : COSTS_N_INSNS (2));
1622 /* This is effectively an 'M' constraint. */
1627 /* This is effectively an 'I' constraint. */
1628 *total
= (outer_code
== MEM
? 0 : 2);
1634 if (outer_code
== LO_SUM
|| outer_code
== HIGH
)
1638 /* ??? Extra cost for GOT or TLS symbols. */
1639 *total
= COSTS_N_INSNS (1 + (outer_code
!= MEM
));
1644 if (outer_code
== MEM
)
1654 #undef TARGET_RTX_COSTS
1655 #define TARGET_RTX_COSTS or1k_rtx_costs
1658 /* A subroutine of the atomic operation splitters. Jump to LABEL if
1659 COND is true. Mark the jump as unlikely to be taken. */
1662 emit_unlikely_jump (rtx_code code
, rtx label
)
1666 x
= gen_rtx_REG (BImode
, SR_F_REGNUM
);
1667 x
= gen_rtx_fmt_ee (code
, VOIDmode
, x
, const0_rtx
);
1668 x
= gen_rtx_IF_THEN_ELSE (VOIDmode
, x
, label
, pc_rtx
);
1669 emit_jump_insn (gen_rtx_SET (pc_rtx
, x
));
1671 // Disable this for now -- producing verify_cfg failures on probabilities.
1672 // int very_unlikely = REG_BR_PROB_BASE / 100 - 1;
1673 // add_int_reg_note (insn, REG_BR_PROB, very_unlikely);
1676 /* A subroutine of the atomic operation splitters.
1677 Emit a raw comparison for A CODE B. */
1680 emit_compare (rtx_code code
, rtx a
, rtx b
)
1682 emit_insn (gen_rtx_SET (gen_rtx_REG (BImode
, SR_F_REGNUM
),
1683 gen_rtx_fmt_ee (code
, BImode
, a
, b
)));
1686 /* A subroutine of the atomic operation splitters.
1687 Emit a load-locked instruction in MODE. */
1690 emit_load_locked (machine_mode mode
, rtx reg
, rtx mem
)
1692 gcc_assert (mode
== SImode
);
1693 emit_insn (gen_load_locked_si (reg
, mem
));
1696 /* A subroutine of the atomic operation splitters.
1697 Emit a store-conditional instruction in MODE. */
1700 emit_store_conditional (machine_mode mode
, rtx mem
, rtx val
)
1702 gcc_assert (mode
== SImode
);
1703 emit_insn (gen_store_conditional_si (mem
, val
));
1706 /* A subroutine of the various atomic expanders. For sub-word operations,
1707 we must adjust things to operate on SImode. Given the original MEM,
1708 return a new aligned memory. Also build and return the quantities by
1709 which to shift and mask. */
1712 or1k_adjust_atomic_subword (rtx orig_mem
, rtx
*pshift
, rtx
*pmask
)
1714 rtx addr
, align
, shift
, mask
, mem
;
1715 machine_mode mode
= GET_MODE (orig_mem
);
1717 addr
= XEXP (orig_mem
, 0);
1718 addr
= force_reg (Pmode
, addr
);
1720 /* Aligned memory containing subword. Generate a new memory. We
1721 do not want any of the existing MEM_ATTR data, as we're now
1722 accessing memory outside the original object. */
1723 align
= expand_binop (Pmode
, and_optab
, addr
, GEN_INT (-4),
1724 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
1725 mem
= gen_rtx_MEM (SImode
, align
);
1726 MEM_VOLATILE_P (mem
) = MEM_VOLATILE_P (orig_mem
);
1727 if (MEM_ALIAS_SET (orig_mem
) == ALIAS_SET_MEMORY_BARRIER
)
1728 set_mem_alias_set (mem
, ALIAS_SET_MEMORY_BARRIER
);
1730 /* Shift amount for subword relative to aligned word. */
1731 rtx mode_mask
= GEN_INT (mode
== QImode
? 3 : 2);
1732 shift
= expand_binop (SImode
, and_optab
, gen_lowpart (SImode
, addr
),
1733 mode_mask
, NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
1734 if (BYTES_BIG_ENDIAN
)
1735 shift
= expand_binop (SImode
, xor_optab
, shift
, mode_mask
,
1736 shift
, 1, OPTAB_LIB_WIDEN
);
1737 shift
= expand_binop (SImode
, ashl_optab
, shift
, GEN_INT (3),
1738 shift
, 1, OPTAB_LIB_WIDEN
);
1741 /* Mask for insertion. */
1742 mask
= expand_binop (SImode
, ashl_optab
, GEN_INT (GET_MODE_MASK (mode
)),
1743 shift
, NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
1749 /* A subroutine of the various atomic expanders. For sub-word operations,
1750 complete the operation by shifting result to the lsb of the SImode
1751 temporary and then extracting the result in MODE with a SUBREG. */
1754 or1k_finish_atomic_subword (machine_mode mode
, rtx o
, rtx n
, rtx shift
)
1756 n
= expand_binop (SImode
, lshr_optab
, n
, shift
,
1757 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
1758 emit_move_insn (o
, gen_lowpart (mode
, n
));
1761 /* Expand an atomic compare and swap operation.
1762 Emits the RTX to perform a compare and swap operation. This function takes
1763 8 RTX arguments in the OPERANDS array. The compare and swap operation
1764 loads a value from memory (OPERANDS[2]) and compares it with an expected
1765 value (OPERANDS[3]), if the values are equal it stores a new value
1766 (OPERANDS[4]) to memory. The argument OPERANDS[0] represents a boolean
1767 result which will be set to true if the operation succeeds. A return value
1768 (OPERANDS[1]) will be set to what was loaded from memory. The argument
1769 OPERAND[5] is used to indicate if the compare and swap is to be treated as
1770 weak. OpenRISC does not use OPERANDS[5] or OPERANDS[6] which provide memory
1772 For OpenRISC this emits RTX which will translate to assembly using the
1773 'l.lwa' (load word atomic) and 'l.swa' (store word atomic) instructions. */
1776 or1k_expand_atomic_compare_and_swap (rtx operands
[])
1778 rtx boolval
, retval
, mem
, oldval
, newval
;
1783 boolval
= operands
[0];
1784 retval
= operands
[1];
1786 oldval
= operands
[3];
1787 newval
= operands
[4];
1788 is_weak
= (INTVAL (operands
[5]) != 0);
1789 mode
= GET_MODE (mem
);
1791 if (reg_overlap_mentioned_p (retval
, oldval
))
1792 oldval
= copy_to_reg (oldval
);
1795 /* If strong, create a label to try again. */
1798 label1
= gen_rtx_LABEL_REF (VOIDmode
, gen_label_rtx ());
1799 emit_label (XEXP (label1
, 0));
1801 label2
= gen_rtx_LABEL_REF (VOIDmode
, gen_label_rtx ());
1803 emit_load_locked (mode
, retval
, mem
);
1804 emit_compare (EQ
, retval
, oldval
);
1805 emit_unlikely_jump (EQ
, label2
);
1806 emit_store_conditional (mode
, mem
, newval
);
1808 /* If strong, jump back to try again on fails. */
1810 emit_unlikely_jump (EQ
, label1
);
1811 emit_label (XEXP (label2
, 0));
1813 /* In all cases, SR_F contains 1 on success, and 0 on failure. */
1814 emit_insn (gen_sne_sr_f (boolval
));
1818 or1k_expand_atomic_compare_and_swap_qihi (rtx operands
[])
1820 rtx boolval
, orig_retval
, retval
, scratch
, mem
, oldval
, newval
;
1821 rtx label1
, label2
, mask
, shift
;
1825 boolval
= operands
[0];
1826 orig_retval
= operands
[1];
1828 oldval
= operands
[3];
1829 newval
= operands
[4];
1830 is_weak
= (INTVAL (operands
[5]) != 0);
1831 mode
= GET_MODE (mem
);
1833 mem
= or1k_adjust_atomic_subword (mem
, &shift
, &mask
);
1835 /* Shift and mask OLDVAL and NEWVAL into position with the word. */
1836 if (oldval
!= const0_rtx
)
1838 oldval
= convert_modes (SImode
, mode
, oldval
, 1);
1839 oldval
= expand_binop (SImode
, ashl_optab
, oldval
, shift
,
1840 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
1842 if (newval
!= const0_rtx
)
1844 newval
= convert_modes (SImode
, mode
, newval
, 1);
1845 newval
= expand_binop (SImode
, ashl_optab
, newval
, shift
,
1846 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
1852 label1
= gen_rtx_LABEL_REF (VOIDmode
, gen_label_rtx ());
1853 emit_label (XEXP (label1
, 0));
1855 label2
= gen_rtx_LABEL_REF (VOIDmode
, gen_label_rtx ());
1857 scratch
= gen_reg_rtx (SImode
);
1858 emit_load_locked (SImode
, scratch
, mem
);
1860 retval
= expand_binop (SImode
, and_optab
, scratch
, mask
,
1861 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
1862 scratch
= expand_binop (SImode
, xor_optab
, scratch
, retval
,
1863 scratch
, 1, OPTAB_LIB_WIDEN
);
1865 emit_compare (EQ
, retval
, oldval
);
1866 emit_unlikely_jump (EQ
, label2
);
1868 if (newval
!= const0_rtx
)
1869 scratch
= expand_binop (SImode
, ior_optab
, scratch
, newval
,
1870 scratch
, 1, OPTAB_LIB_WIDEN
);
1872 emit_store_conditional (SImode
, mem
, scratch
);
1875 emit_unlikely_jump (EQ
, label1
);
1876 emit_label (XEXP (label2
, 0));
1878 or1k_finish_atomic_subword (mode
, orig_retval
, retval
, shift
);
1880 /* In all cases, SR_F contains 1 on success, and 0 on failure. */
1881 emit_insn (gen_sne_sr_f (boolval
));
1884 /* Expand an atomic exchange operation.
1885 Emits the RTX to perform an exchange operation. This function takes 4 RTX
1886 arguments in the OPERANDS array. The exchange operation atomically loads a
1887 value from memory (OPERANDS[1]) to a return value (OPERANDS[0]) and stores a
1888 new value (OPERANDS[2]) back to the memory location.
1889 Another argument (OPERANDS[3]) is used to indicate the memory model and
1890 is not used by OpenRISC.
1891 For OpenRISC this emits RTX which will translate to assembly using the
1892 'l.lwa' (load word atomic) and 'l.swa' (store word atomic) instructions. */
1895 or1k_expand_atomic_exchange (rtx operands
[])
1897 rtx retval
, mem
, val
, label
;
1900 retval
= operands
[0];
1903 mode
= GET_MODE (mem
);
1905 if (reg_overlap_mentioned_p (retval
, val
))
1906 val
= copy_to_reg (val
);
1908 label
= gen_rtx_LABEL_REF (VOIDmode
, gen_label_rtx ());
1909 emit_label (XEXP (label
, 0));
1911 emit_load_locked (mode
, retval
, mem
);
1912 emit_store_conditional (mode
, mem
, val
);
1913 emit_unlikely_jump (EQ
, label
);
1917 or1k_expand_atomic_exchange_qihi (rtx operands
[])
1919 rtx orig_retval
, retval
, mem
, val
, scratch
;
1920 rtx label
, mask
, shift
;
1923 orig_retval
= operands
[0];
1926 mode
= GET_MODE (mem
);
1928 mem
= or1k_adjust_atomic_subword (mem
, &shift
, &mask
);
1930 /* Shift and mask VAL into position with the word. */
1931 if (val
!= const0_rtx
)
1933 val
= convert_modes (SImode
, mode
, val
, 1);
1934 val
= expand_binop (SImode
, ashl_optab
, val
, shift
,
1935 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
1938 label
= gen_rtx_LABEL_REF (VOIDmode
, gen_label_rtx ());
1939 emit_label (XEXP (label
, 0));
1941 scratch
= gen_reg_rtx (SImode
);
1942 emit_load_locked (SImode
, scratch
, mem
);
1944 retval
= expand_binop (SImode
, and_optab
, scratch
, mask
,
1945 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
1946 scratch
= expand_binop (SImode
, xor_optab
, scratch
, retval
,
1947 scratch
, 1, OPTAB_LIB_WIDEN
);
1948 if (val
!= const0_rtx
)
1949 scratch
= expand_binop (SImode
, ior_optab
, scratch
, val
,
1950 scratch
, 1, OPTAB_LIB_WIDEN
);
1952 emit_store_conditional (SImode
, mem
, scratch
);
1953 emit_unlikely_jump (EQ
, label
);
1955 or1k_finish_atomic_subword (mode
, orig_retval
, retval
, shift
);
1958 /* Expand an atomic fetch-and-operate pattern. CODE is the binary operation
1959 to perform (with MULT as a stand-in for NAND). MEM is the memory on which
1960 to operate. VAL is the second operand of the binary operator. BEFORE and
1961 AFTER are optional locations to return the value of MEM either before of
1962 after the operation. */
1965 or1k_expand_atomic_op (rtx_code code
, rtx mem
, rtx val
,
1966 rtx orig_before
, rtx orig_after
)
1968 machine_mode mode
= GET_MODE (mem
);
1969 rtx before
= orig_before
, after
= orig_after
;
1972 label
= gen_rtx_LABEL_REF (VOIDmode
, gen_label_rtx ());
1973 emit_label (XEXP (label
, 0));
1975 if (before
== NULL_RTX
)
1976 before
= gen_reg_rtx (mode
);
1978 emit_load_locked (mode
, before
, mem
);
1982 after
= expand_binop (mode
, and_optab
, before
, val
,
1983 after
, 1, OPTAB_LIB_WIDEN
);
1984 after
= expand_unop (mode
, one_cmpl_optab
, after
, after
, 1);
1987 after
= expand_simple_binop (mode
, code
, before
, val
,
1988 after
, 1, OPTAB_LIB_WIDEN
);
1990 emit_store_conditional (mode
, mem
, after
);
1991 emit_unlikely_jump (EQ
, label
);
1994 emit_move_insn (orig_before
, before
);
1996 emit_move_insn (orig_after
, after
);
2000 or1k_expand_atomic_op_qihi (rtx_code code
, rtx mem
, rtx val
,
2001 rtx orig_before
, rtx orig_after
)
2003 machine_mode mode
= GET_MODE (mem
);
2004 rtx label
, mask
, shift
, x
;
2005 rtx before
, after
, scratch
;
2007 mem
= or1k_adjust_atomic_subword (mem
, &shift
, &mask
);
2009 /* Shift and mask VAL into position with the word. */
2010 val
= convert_modes (SImode
, mode
, val
, 1);
2011 val
= expand_binop (SImode
, ashl_optab
, val
, shift
,
2012 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
2018 /* We've already zero-extended VAL. That is sufficient to
2019 make certain that it does not affect other bits. */
2023 case MULT
: /* NAND */
2024 /* If we make certain that all of the other bits in VAL are
2025 set, that will be sufficient to not affect other bits. */
2026 x
= expand_unop (SImode
, one_cmpl_optab
, mask
, NULL_RTX
, 1);
2027 val
= expand_binop (SImode
, ior_optab
, val
, x
,
2028 val
, 1, OPTAB_LIB_WIDEN
);
2033 /* These will all affect bits outside the field and need
2034 adjustment via MASK within the loop. */
2041 label
= gen_rtx_LABEL_REF (VOIDmode
, gen_label_rtx ());
2042 emit_label (XEXP (label
, 0));
2044 before
= scratch
= gen_reg_rtx (SImode
);
2045 emit_load_locked (SImode
, before
, mem
);
2052 after
= expand_simple_binop (SImode
, code
, before
, val
,
2053 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
2059 before
= expand_binop (SImode
, and_optab
, scratch
, mask
,
2060 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
2061 scratch
= expand_binop (SImode
, xor_optab
, scratch
, before
,
2062 scratch
, 1, OPTAB_LIB_WIDEN
);
2063 after
= expand_simple_binop (SImode
, code
, before
, val
,
2064 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
2065 after
= expand_binop (SImode
, and_optab
, after
, mask
,
2066 after
, 1, OPTAB_LIB_WIDEN
);
2067 scratch
= expand_binop (SImode
, ior_optab
, scratch
, after
,
2068 scratch
, 1, OPTAB_LIB_WIDEN
);
2071 case MULT
: /* NAND */
2072 after
= expand_binop (SImode
, and_optab
, before
, val
,
2073 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
2074 after
= expand_binop (SImode
, xor_optab
, after
, mask
,
2075 after
, 1, OPTAB_LIB_WIDEN
);
2083 emit_store_conditional (SImode
, mem
, scratch
);
2084 emit_unlikely_jump (EQ
, label
);
2087 or1k_finish_atomic_subword (mode
, orig_before
, before
, shift
);
2089 or1k_finish_atomic_subword (mode
, orig_after
, after
, shift
);
2092 /* Worker for TARGET_ASM_OUTPUT_MI_THUNK.
2093 Output the assembler code for a thunk function. THUNK_DECL is the
2094 declaration for the thunk function itself, FUNCTION is the decl for
2095 the target function. DELTA is an immediate constant offset to be
2096 added to THIS. If VCALL_OFFSET is nonzero, the word at address
2097 (*THIS + VCALL_OFFSET) should be additionally added to THIS. */
2100 or1k_output_mi_thunk (FILE *file
, tree thunk_fndecl
,
2101 HOST_WIDE_INT delta
, HOST_WIDE_INT vcall_offset
,
2104 const char *fnname
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (thunk_fndecl
));
2105 rtx this_rtx
, funexp
;
2108 reload_completed
= 1;
2109 epilogue_completed
= 1;
2111 emit_note (NOTE_INSN_PROLOGUE_END
);
2113 /* Find the "this" pointer. Normally in r3, but if the function
2114 returns a structure, the structure return pointer is in r3 and
2115 the "this" pointer is in r4 instead. */
2116 if (aggregate_value_p (TREE_TYPE (TREE_TYPE (function
)), function
))
2117 this_rtx
= gen_rtx_REG (Pmode
, 4);
2119 this_rtx
= gen_rtx_REG (Pmode
, 3);
2121 /* Add DELTA. When possible use a plain add, otherwise load it
2122 into a register first. */
2125 rtx delta_rtx
= GEN_INT (delta
);
2127 if (!satisfies_constraint_I (delta_rtx
))
2129 rtx scratch
= gen_rtx_REG (Pmode
, PE_TMP_REGNUM
);
2130 emit_move_insn (scratch
, delta_rtx
);
2131 delta_rtx
= scratch
;
2134 /* THIS_RTX += DELTA. */
2135 emit_insn (gen_add2_insn (this_rtx
, delta_rtx
));
2138 /* Add the word at address (*THIS_RTX + VCALL_OFFSET). */
2141 rtx scratch
= gen_rtx_REG (Pmode
, PE_TMP_REGNUM
);
2142 HOST_WIDE_INT lo
= sext_hwi (vcall_offset
, 16);
2143 HOST_WIDE_INT hi
= vcall_offset
- lo
;
2146 /* SCRATCH = *THIS_RTX. */
2147 tmp
= gen_rtx_MEM (Pmode
, this_rtx
);
2148 emit_move_insn (scratch
, tmp
);
2152 rtx scratch2
= gen_rtx_REG (Pmode
, RV_REGNUM
);
2153 emit_move_insn (scratch2
, GEN_INT (hi
));
2154 emit_insn (gen_add2_insn (scratch
, scratch2
));
2157 /* SCRATCH = *(*THIS_RTX + VCALL_OFFSET). */
2158 tmp
= plus_constant (Pmode
, scratch
, lo
);
2159 tmp
= gen_rtx_MEM (Pmode
, tmp
);
2160 emit_move_insn (scratch
, tmp
);
2162 /* THIS_RTX += *(*THIS_RTX + VCALL_OFFSET). */
2163 emit_insn (gen_add2_insn (this_rtx
, scratch
));
2166 /* Generate a tail call to the target function. */
2167 if (!TREE_USED (function
))
2169 assemble_external (function
);
2170 TREE_USED (function
) = 1;
2172 funexp
= XEXP (DECL_RTL (function
), 0);
2174 /* The symbol will be a local alias and therefore always binds local. */
2175 gcc_assert (SYMBOL_REF_LOCAL_P (funexp
));
2177 funexp
= gen_rtx_MEM (FUNCTION_MODE
, funexp
);
2178 insn
= emit_call_insn (gen_sibcall (funexp
, const0_rtx
));
2179 SIBLING_CALL_P (insn
) = 1;
2182 /* Run just enough of rest_of_compilation to get the insns emitted.
2183 There's not really enough bulk here to make other passes such as
2184 instruction scheduling worth while. */
2185 insn
= get_insns ();
2186 shorten_branches (insn
);
2187 assemble_start_function (thunk_fndecl
, fnname
);
2188 final_start_function (insn
, file
, 1);
2189 final (insn
, file
, 1);
2190 final_end_function ();
2191 assemble_end_function (thunk_fndecl
, fnname
);
2193 reload_completed
= 0;
2194 epilogue_completed
= 0;
2198 or1k_libm_function_max_error (unsigned cfn
, machine_mode mode
,
2202 bool glibc_p
= OPTION_GLIBC
;
2204 bool glibc_p
= false;
2212 if (!boundary_p
&& mode
== DFmode
&& flag_rounding_math
)
2218 return glibc_linux_libm_function_max_error (cfn
, mode
, boundary_p
);
2220 return default_libm_function_max_error (cfn
, mode
, boundary_p
);
2223 #undef TARGET_ASM_OUTPUT_MI_THUNK
2224 #define TARGET_ASM_OUTPUT_MI_THUNK or1k_output_mi_thunk
2225 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
2226 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK \
2227 hook_bool_const_tree_hwi_hwi_const_tree_true
2229 #undef TARGET_OPTION_OVERRIDE
2230 #define TARGET_OPTION_OVERRIDE or1k_option_override
2232 #undef TARGET_COMPUTE_FRAME_LAYOUT
2233 #define TARGET_COMPUTE_FRAME_LAYOUT or1k_compute_frame_layout
2235 #undef TARGET_LEGITIMATE_ADDRESS_P
2236 #define TARGET_LEGITIMATE_ADDRESS_P or1k_legitimate_address_p
2239 #undef TARGET_HAVE_TLS
2240 #define TARGET_HAVE_TLS true
2243 #undef TARGET_HAVE_SPECULATION_SAFE_VALUE
2244 #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed
2246 #undef TARGET_LIBM_FUNCTION_MAX_ERROR
2247 #define TARGET_LIBM_FUNCTION_MAX_ERROR or1k_libm_function_max_error
2249 /* Calling Conventions. */
2250 #undef TARGET_FUNCTION_VALUE
2251 #define TARGET_FUNCTION_VALUE or1k_function_value
2252 #undef TARGET_LIBCALL_VALUE
2253 #define TARGET_LIBCALL_VALUE or1k_libcall_value
2254 #undef TARGET_FUNCTION_VALUE_REGNO_P
2255 #define TARGET_FUNCTION_VALUE_REGNO_P or1k_function_value_regno_p
2256 #undef TARGET_FUNCTION_ARG
2257 #define TARGET_FUNCTION_ARG or1k_function_arg
2258 #undef TARGET_FUNCTION_ARG_ADVANCE
2259 #define TARGET_FUNCTION_ARG_ADVANCE or1k_function_arg_advance
2260 #undef TARGET_RETURN_IN_MEMORY
2261 #define TARGET_RETURN_IN_MEMORY or1k_return_in_memory
2262 #undef TARGET_PASS_BY_REFERENCE
2263 #define TARGET_PASS_BY_REFERENCE or1k_pass_by_reference
2264 #undef TARGET_TRAMPOLINE_INIT
2265 #define TARGET_TRAMPOLINE_INIT or1k_trampoline_init
2266 #undef TARGET_FRAME_POINTER_REQUIRED
2267 #define TARGET_FRAME_POINTER_REQUIRED or1k_frame_pointer_required
2268 #undef TARGET_CUSTOM_FUNCTION_DESCRIPTORS
2269 #define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 1
2271 /* Assembly generation. */
2272 #undef TARGET_PRINT_OPERAND
2273 #define TARGET_PRINT_OPERAND or1k_print_operand
2274 #undef TARGET_PRINT_OPERAND_ADDRESS
2275 #define TARGET_PRINT_OPERAND_ADDRESS or1k_print_operand_address
2277 /* Section anchor support. */
2278 #undef TARGET_MIN_ANCHOR_OFFSET
2279 #define TARGET_MIN_ANCHOR_OFFSET -32768
2280 #undef TARGET_MAX_ANCHOR_OFFSET
2281 #define TARGET_MAX_ANCHOR_OFFSET 32767
2283 struct gcc_target targetm
= TARGET_INITIALIZER
;
2285 #include "gt-or1k.h"