1 /* Definitions of target machine for GNU compiler,
2 for 64 bit PowerPC linux.
3 Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
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 2, 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 COPYING. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston,
20 MA 02111-1307, USA. */
22 #ifndef RS6000_BI_ARCH
25 #define DEFAULT_ABI ABI_AIX
28 #define TARGET_64BIT 1
30 #define DEFAULT_ARCH64_P 1
31 #define RS6000_BI_ARCH_P 0
35 #define DEFAULT_ARCH64_P (TARGET_DEFAULT & MASK_64BIT)
36 #define RS6000_BI_ARCH_P 1
43 #define TARGET_64BIT 1
45 #define TARGET_64BIT 0
50 #define TARGET_AIX TARGET_64BIT
52 #undef PROCESSOR_DEFAULT64
53 #define PROCESSOR_DEFAULT64 PROCESSOR_PPC630
55 #undef TARGET_RELOCATABLE
56 #define TARGET_RELOCATABLE (!TARGET_64BIT && (target_flags & MASK_RELOCATABLE))
58 #undef RS6000_ABI_NAME
59 #define RS6000_ABI_NAME (TARGET_64BIT ? "aixdesc" : "sysv")
61 #define INVALID_64BIT "-m%s not supported in this configuration"
62 #define INVALID_32BIT INVALID_64BIT
64 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
65 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
70 if (DEFAULT_ABI != ABI_AIX) \
72 DEFAULT_ABI = ABI_AIX; \
73 error (INVALID_64BIT, "call"); \
75 if (TARGET_RELOCATABLE) \
77 target_flags &= ~MASK_RELOCATABLE; \
78 error (INVALID_64BIT, "relocatable"); \
82 target_flags &= ~MASK_EABI; \
83 error (INVALID_64BIT, "eabi"); \
85 if (TARGET_PROTOTYPE) \
87 target_flags &= ~MASK_PROTOTYPE; \
88 error (INVALID_64BIT, "prototype"); \
93 if (!RS6000_BI_ARCH_P) \
94 error (INVALID_32BIT, "32"); \
101 #undef OVERRIDE_OPTIONS
102 #define OVERRIDE_OPTIONS \
103 rs6000_override_options (((TARGET_DEFAULT ^ target_flags) & MASK_64BIT) \
104 ? (char *) 0 : TARGET_CPU_DEFAULT)
108 #undef ASM_DEFAULT_SPEC
110 #undef LINK_OS_LINUX_SPEC
112 #ifndef RS6000_BI_ARCH
113 #define ASM_DEFAULT_SPEC "-mppc64"
114 #define ASM_SPEC "%(asm_spec64) %(asm_spec_common)"
115 #define LINK_OS_LINUX_SPEC "%(link_os_linux_spec64)"
118 #define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
119 #define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
120 #define LINK_OS_LINUX_SPEC "%{m32:%(link_os_linux_spec32)}%{!m32:%(link_os_linux_spec64)}"
122 #define ASM_DEFAULT_SPEC "-mppc%{m64:64}"
123 #define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
124 #define LINK_OS_LINUX_SPEC "%{!m64:%(link_os_linux_spec32)}%{m64:%(link_os_linux_spec64)}"
128 #define ASM_SPEC32 "-a32 %{n} %{T} %{Ym,*} %{Yd,*} \
129 %{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \
130 %{memb} %{!memb: %{msdata: -memb} %{msdata=eabi: -memb}} \
131 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
132 %{mcall-freebsd: -mbig} \
133 %{mcall-i960-old: -mlittle} \
134 %{mcall-linux: -mbig} \
135 %{mcall-gnu: -mbig} \
136 %{mcall-netbsd: -mbig} \
139 #define ASM_SPEC64 "-a64"
141 #define ASM_SPEC_COMMON "%(asm_cpu) \
142 %{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \
143 %{v:-V} %{Qy:} %{!Qn:-Qy} %{Wa,*:%*} \
144 %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian}"
146 #undef SUBSUBTARGET_EXTRA_SPECS
147 #define SUBSUBTARGET_EXTRA_SPECS \
148 { "asm_spec_common", ASM_SPEC_COMMON }, \
149 { "asm_spec32", ASM_SPEC32 }, \
150 { "asm_spec64", ASM_SPEC64 }, \
151 { "link_os_linux_spec32", LINK_OS_LINUX_SPEC32 }, \
152 { "link_os_linux_spec64", LINK_OS_LINUX_SPEC64 },
154 #undef MULTILIB_DEFAULTS
156 #define MULTILIB_DEFAULTS { "m64" }
158 #define MULTILIB_DEFAULTS { "m32" }
161 #ifndef RS6000_BI_ARCH
163 /* 64-bit PowerPC Linux is always big-endian. */
164 #undef TARGET_LITTLE_ENDIAN
165 #define TARGET_LITTLE_ENDIAN 0
167 /* 64-bit PowerPC Linux always has a TOC. */
171 /* Some things from sysv4.h we don't do when 64 bit. */
172 #undef TARGET_RELOCATABLE
173 #define TARGET_RELOCATABLE 0
175 #define TARGET_EABI 0
176 #undef TARGET_PROTOTYPE
177 #define TARGET_PROTOTYPE 0
181 #define MASK_PROFILE_KERNEL 0x00080000
183 /* Non-standard profiling for kernels, which just saves LR then calls
184 _mcount without worrying about arg saves. The idea is to change
185 the function prologue as little as possible as it isn't easy to
186 account for arg save/restore code added just for _mcount. */
187 #define TARGET_PROFILE_KERNEL (target_flags & MASK_PROFILE_KERNEL)
189 /* Override sysv4.h. */
190 #undef EXTRA_SUBTARGET_SWITCHES
191 #define EXTRA_SUBTARGET_SWITCHES \
192 {"profile-kernel", MASK_PROFILE_KERNEL, \
193 N_("Call mcount for profiling before a function prologue") }, \
194 {"no-profile-kernel", -MASK_PROFILE_KERNEL, \
195 N_("Call mcount for profiling after a function prologue") },
197 /* We use glibc _mcount for profiling. */
198 #define NO_PROFILE_COUNTERS TARGET_64BIT
199 #define PROFILE_HOOK(LABEL) \
200 do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
202 /* We don't need to generate entries in .fixup. */
203 #undef RELOCATABLE_NEEDS_FIXUP
205 /* This now supports a natural alignment mode. */
206 /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */
207 #undef ADJUST_FIELD_ALIGN
208 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
209 ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE) \
212 && TARGET_ALIGN_NATURAL == 0 \
213 && TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
214 ? get_inner_array_type (FIELD) \
215 : TREE_TYPE (FIELD)) == DFmode) \
216 ? MIN ((COMPUTED), 32) \
219 /* AIX increases natural record alignment to doubleword if the first
220 field is an FP double while the FP fields remain word aligned. */
221 #undef ROUND_TYPE_ALIGN
222 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
223 ((TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE) \
224 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128) \
226 && (TREE_CODE (STRUCT) == RECORD_TYPE \
227 || TREE_CODE (STRUCT) == UNION_TYPE \
228 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
229 && TYPE_FIELDS (STRUCT) != 0 \
230 && TARGET_ALIGN_NATURAL == 0 \
231 && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode) \
232 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64) \
233 : MAX ((COMPUTED), (SPECIFIED)))
235 /* Indicate that jump tables go in the text section. */
236 #undef JUMP_TABLES_IN_TEXT_SECTION
237 #define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
239 /* The linux ppc64 ABI isn't explicit on whether aggregates smaller
240 than a doubleword should be padded upward or downward. You could
241 reasonably assume that they follow the normal rules for structure
242 layout treating the parameter area as any other block of memory,
243 then map the reg param area to registers. ie. pad updard.
244 Setting both of the following defines results in this behaviour.
245 Setting just the first one will result in aggregates that fit in a
246 doubleword being padded downward, and others being padded upward.
247 Not a bad idea as this results in struct { int x; } being passed
248 the same way as an int. */
249 #define AGGREGATE_PADDING_FIXED TARGET_64BIT
250 #define AGGREGATES_PAD_UPWARD_ALWAYS 0
252 /* We don't want anything in the reg parm area being passed on the
254 #define MUST_PASS_IN_STACK(MODE, TYPE) \
257 && (TREE_CODE (TYPE_SIZE (TYPE)) != INTEGER_CST \
258 || TREE_ADDRESSABLE (TYPE))) \
260 && default_must_pass_in_stack ((MODE), (TYPE))))
262 /* Specify padding for the last element of a block move between
263 registers and memory. FIRST is nonzero if this is the only
265 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
266 (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
268 /* __throw will restore its own return address to be the same as the
269 return address of the function that the throw is being made to.
270 This is unfortunate, because we want to check the original
271 return address to see if we need to restore the TOC.
272 So we have to squirrel it away with this. */
273 #define SETUP_FRAME_ADDRESSES() \
274 do { if (TARGET_64BIT) rs6000_aix_emit_builtin_unwind_init (); } while (0)
276 /* Override svr4.h */
277 #undef MD_EXEC_PREFIX
278 #undef MD_STARTFILE_PREFIX
280 /* Override sysv4.h */
282 #define CPP_SYSV_SPEC ""
284 #undef TARGET_OS_CPP_BUILTINS
285 #define TARGET_OS_CPP_BUILTINS() \
290 builtin_define ("__PPC__"); \
291 builtin_define ("__PPC64__"); \
292 builtin_define ("__powerpc__"); \
293 builtin_define ("__powerpc64__"); \
294 builtin_define ("__PIC__"); \
295 builtin_assert ("cpu=powerpc64"); \
296 builtin_assert ("machine=powerpc64"); \
300 builtin_define_std ("PPC"); \
301 builtin_define_std ("powerpc"); \
302 builtin_assert ("cpu=powerpc"); \
303 builtin_assert ("machine=powerpc"); \
304 TARGET_OS_SYSV_CPP_BUILTINS (); \
309 #undef CPP_OS_DEFAULT_SPEC
310 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
312 /* The GNU C++ standard library currently requires _GNU_SOURCE being
313 defined on glibc-based systems. This temporary hack accomplishes this,
314 it should go away as soon as libstdc++-v3 has a real fix. */
315 #undef CPLUSPLUS_CPP_SPEC
316 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
318 #undef LINK_SHLIB_SPEC
319 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
321 #undef LIB_DEFAULT_SPEC
322 #define LIB_DEFAULT_SPEC "%(lib_linux)"
324 #undef STARTFILE_DEFAULT_SPEC
325 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
327 #undef ENDFILE_DEFAULT_SPEC
328 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
330 #undef LINK_START_DEFAULT_SPEC
331 #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
333 #undef LINK_OS_DEFAULT_SPEC
334 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
336 #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \
337 %{rdynamic:-export-dynamic} \
338 %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
340 #define LINK_OS_LINUX_SPEC64 "-m elf64ppc %{!shared: %{!static: \
341 %{rdynamic:-export-dynamic} \
342 %{!dynamic-linker:-dynamic-linker /lib64/ld64.so.1}}}"
344 #undef TOC_SECTION_ASM_OP
345 #define TOC_SECTION_ASM_OP \
347 ? "\t.section\t\".toc\",\"aw\"" \
348 : "\t.section\t\".got\",\"aw\"")
350 #undef MINIMAL_TOC_SECTION_ASM_OP
351 #define MINIMAL_TOC_SECTION_ASM_OP \
353 ? "\t.section\t\".toc1\",\"aw\"" \
354 : ((TARGET_RELOCATABLE || flag_pic) \
355 ? "\t.section\t\".got2\",\"aw\"" \
356 : "\t.section\t\".got1\",\"aw\""))
358 #undef TARGET_VERSION
359 #define TARGET_VERSION fprintf (stderr, " (PowerPC64 GNU/Linux)");
361 /* Must be at least as big as our pointer type. */
363 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
366 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
369 #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
370 #undef WCHAR_TYPE_SIZE
371 #define WCHAR_TYPE_SIZE 32
373 /* Override rs6000.h definition. */
375 #define ASM_APP_ON "#APP\n"
377 /* Override rs6000.h definition. */
379 #define ASM_APP_OFF "#NO_APP\n"
381 /* PowerPC no-op instruction. */
382 #undef RS6000_CALL_GLUE
383 #define RS6000_CALL_GLUE (TARGET_64BIT ? "nop" : "cror 31,31,31")
386 #define RS6000_MCOUNT "_mcount"
389 /* _init and _fini functions are built from bits spread across many
390 object files, each potentially with a different TOC pointer. For
391 that reason, place a nop after the call so that the linker can
392 restore the TOC pointer if a TOC adjusting call stub is needed. */
393 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
394 asm (SECTION_OP "\n" \
400 /* FP save and restore routines. */
401 #undef SAVE_FP_PREFIX
402 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
403 #undef SAVE_FP_SUFFIX
404 #define SAVE_FP_SUFFIX (TARGET_64BIT ? "" : "_l")
405 #undef RESTORE_FP_PREFIX
406 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
407 #undef RESTORE_FP_SUFFIX
408 #define RESTORE_FP_SUFFIX (TARGET_64BIT ? "" : "_l")
410 /* Dwarf2 debugging. */
411 #undef PREFERRED_DEBUGGING_TYPE
412 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
414 /* This is how to declare the size of a function. */
415 #undef ASM_DECLARE_FUNCTION_SIZE
416 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
419 if (!flag_inhibit_size_directive) \
421 fputs ("\t.size\t", (FILE)); \
423 putc ('.', (FILE)); \
424 assemble_name ((FILE), (FNAME)); \
425 fputs (",.-", (FILE)); \
427 putc ('.', (FILE)); \
428 assemble_name ((FILE), (FNAME)); \
429 putc ('\n', (FILE)); \
434 /* Return nonzero if this entry is to be written into the constant
435 pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
436 or a CONST containing one of them. If -mfp-in-toc (the default),
437 we also do this for floating-point constants. We actually can only
438 do this if the FP formats of the target and host machines are the
439 same, but we can't check that since not every file that uses
440 GO_IF_LEGITIMATE_ADDRESS_P includes real.h. We also do this when
441 we can write the entry into the TOC and the entry is not larger
444 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
445 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
447 && (GET_CODE (X) == SYMBOL_REF \
448 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
449 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
450 || GET_CODE (X) == LABEL_REF \
451 || (GET_CODE (X) == CONST_INT \
452 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
453 || (GET_CODE (X) == CONST_DOUBLE \
455 && (TARGET_POWERPC64 \
456 || TARGET_MINIMAL_TOC \
457 || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
458 && ! TARGET_NO_FP_IN_TOC))) \
460 && !TARGET_NO_FP_IN_TOC \
461 && !TARGET_RELOCATABLE \
462 && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
463 && BITS_PER_WORD == HOST_BITS_PER_INT)))))
465 /* This is the same as the dbxelf.h version, except that we need to
466 use the function code label, not the function descriptor. */
467 #undef ASM_OUTPUT_SOURCE_LINE
468 #define ASM_OUTPUT_SOURCE_LINE(FILE, LINE, COUNTER) \
472 ASM_GENERATE_INTERNAL_LABEL (temp, "LM", COUNTER); \
473 fprintf (FILE, "\t.stabn 68,0,%d,", LINE); \
474 assemble_name (FILE, temp); \
478 assemble_name (FILE, \
479 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\
481 (*targetm.asm_out.internal_label) (FILE, "LM", COUNTER); \
485 /* Similarly, we want the function code label here. */
486 #define DBX_OUTPUT_BRAC(FILE, NAME, BRAC) \
490 fprintf (FILE, "%s%d,0,0,", ASM_STABN_OP, BRAC); \
491 assemble_name (FILE, NAME); \
493 if (current_function_func_begin_label != NULL_TREE) \
494 flab = IDENTIFIER_POINTER (current_function_func_begin_label); \
499 flab = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); \
501 assemble_name (FILE, flab); \
506 #define DBX_OUTPUT_LBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_LBRAC)
507 #define DBX_OUTPUT_RBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_RBRAC)
509 /* Another case where we want the dot name. */
510 #define DBX_OUTPUT_NFUN(FILE, LSCOPE, DECL) \
513 fprintf (FILE, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN); \
514 assemble_name (FILE, LSCOPE); \
518 assemble_name (FILE, XSTR (XEXP (DECL_RTL (DECL), 0), 0)); \
523 /* Select a format to encode pointers in exception handling data. CODE
524 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
525 true if the symbol may be affected by dynamic relocations. */
526 #undef ASM_PREFERRED_EH_DATA_FORMAT
527 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
528 ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \
529 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
530 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
533 /* For backward compatibility, we must continue to use the AIX
534 structure return convention. */
535 #undef DRAFT_V4_STRUCT_RET
536 #define DRAFT_V4_STRUCT_RET (!TARGET_64BIT)
538 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
540 /* Do code reading to identify a signal frame, and set the frame
541 state data appropriately. See unwind-dw2.c for the structs. */
545 #include <sys/ucontext.h>
548 enum { SIGNAL_FRAMESIZE
= 128 };
550 enum { SIGNAL_FRAMESIZE
= 64 };
556 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
558 unsigned char *pc_ = (CONTEXT)->ra; \
559 struct sigcontext *sc_; \
563 /* addi r1, r1, 128; li r0, 0x0077; sc (sigreturn) */ \
564 /* addi r1, r1, 128; li r0, 0x00AC; sc (rt_sigreturn) */ \
565 if (*(unsigned int *) (pc_+0) != 0x38210000 + SIGNAL_FRAMESIZE \
566 || *(unsigned int *) (pc_+8) != 0x44000002) \
568 if (*(unsigned int *) (pc_+4) == 0x38000077) \
571 char gap[SIGNAL_FRAMESIZE]; \
572 struct sigcontext sigctx; \
573 } *rt_ = (CONTEXT)->cfa; \
574 sc_ = &rt_->sigctx; \
576 else if (*(unsigned int *) (pc_+4) == 0x380000AC) \
578 struct rt_sigframe { \
580 struct siginfo *pinfo; \
581 struct ucontext *puc; \
582 } *rt_ = (struct rt_sigframe *) pc_; \
583 sc_ = &rt_->puc->uc_mcontext; \
588 new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM]; \
589 (FS)->cfa_how = CFA_REG_OFFSET; \
590 (FS)->cfa_reg = STACK_POINTER_REGNUM; \
591 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
593 for (i_ = 0; i_ < 32; i_++) \
594 if (i_ != STACK_POINTER_REGNUM) \
596 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
597 (FS)->regs.reg[i_].loc.offset \
598 = (long)&(sc_->regs->gpr[i_]) - new_cfa_; \
601 (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET; \
602 (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset \
603 = (long)&(sc_->regs->link) - new_cfa_; \
605 /* The unwinder expects the IP to point to the following insn, \
606 whereas the kernel returns the address of the actual \
607 faulting insn. We store NIP+4 in an unused register slot to \
608 get the same result for multiple evaluation of the same signal \
610 sc_->regs->gpr[47] = sc_->regs->nip + 4; \
611 (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET; \
612 (FS)->regs.reg[CR0_REGNO].loc.offset \
613 = (long)&(sc_->regs->gpr[47]) - new_cfa_; \
614 (FS)->retaddr_column = CR0_REGNO; \
620 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
622 unsigned char *pc_ = (CONTEXT)->ra; \
623 struct sigcontext *sc_; \
627 /* li r0, 0x7777; sc (sigreturn old) */ \
628 /* li r0, 0x0077; sc (sigreturn new) */ \
629 /* li r0, 0x6666; sc (rt_sigreturn old) */ \
630 /* li r0, 0x00AC; sc (rt_sigreturn new) */ \
631 if (*(unsigned int *) (pc_+4) != 0x44000002) \
633 if (*(unsigned int *) (pc_+0) == 0x38007777 \
634 || *(unsigned int *) (pc_+0) == 0x38000077) \
637 char gap[SIGNAL_FRAMESIZE]; \
638 struct sigcontext sigctx; \
639 } *rt_ = (CONTEXT)->cfa; \
640 sc_ = &rt_->sigctx; \
642 else if (*(unsigned int *) (pc_+0) == 0x38006666 \
643 || *(unsigned int *) (pc_+0) == 0x380000AC) \
645 struct rt_sigframe { \
646 char gap[SIGNAL_FRAMESIZE]; \
647 unsigned long _unused[2]; \
648 struct siginfo *pinfo; \
650 struct siginfo info; \
651 struct ucontext uc; \
652 } *rt_ = (CONTEXT)->cfa; \
653 sc_ = &rt_->uc.uc_mcontext; \
658 new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM]; \
659 (FS)->cfa_how = CFA_REG_OFFSET; \
660 (FS)->cfa_reg = STACK_POINTER_REGNUM; \
661 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
663 for (i_ = 0; i_ < 32; i_++) \
664 if (i_ != STACK_POINTER_REGNUM) \
666 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
667 (FS)->regs.reg[i_].loc.offset \
668 = (long)&(sc_->regs->gpr[i_]) - new_cfa_; \
671 (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET; \
672 (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset \
673 = (long)&(sc_->regs->link) - new_cfa_; \
675 /* The unwinder expects the IP to point to the following insn, \
676 whereas the kernel returns the address of the actual \
677 faulting insn. We store NIP+4 in an unused register slot to \
678 get the same result for multiple evaluation of the same signal \
680 sc_->regs->gpr[47] = sc_->regs->nip + 4; \
681 (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET; \
682 (FS)->regs.reg[CR0_REGNO].loc.offset \
683 = (long)&(sc_->regs->gpr[47]) - new_cfa_; \
684 (FS)->retaddr_column = CR0_REGNO; \