1 /* Target-dependent code for PowerPC systems using the SVR4 ABI
2 for GDB, the GNU debugger.
4 Copyright (C) 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009, 2010, 2011
5 Free Software Foundation, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 #include "gdb_string.h"
28 #include "gdb_assert.h"
34 /* Pass the arguments in either registers, or in the stack. Using the
35 ppc sysv ABI, the first eight words of the argument list (that might
36 be less than eight parameters if some parameters occupy more than one
37 word) are passed in r3..r10 registers. float and double parameters are
38 passed in fpr's, in addition to that. Rest of the parameters if any
39 are passed in user stack.
41 If the function is returning a structure, then the return address is passed
42 in r3, then the first 7 words of the parametes can be passed in registers,
46 ppc_sysv_abi_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
47 struct regcache
*regcache
, CORE_ADDR bp_addr
,
48 int nargs
, struct value
**args
, CORE_ADDR sp
,
49 int struct_return
, CORE_ADDR struct_addr
)
51 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
52 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
54 int argspace
= 0; /* 0 is an initial wrong guess. */
57 gdb_assert (tdep
->wordsize
== 4);
59 regcache_cooked_read_unsigned (regcache
, gdbarch_sp_regnum (gdbarch
),
62 /* Go through the argument list twice.
64 Pass 1: Figure out how much new stack space is required for
65 arguments and pushed values. Unlike the PowerOpen ABI, the SysV
66 ABI doesn't reserve any extra space for parameters which are put
67 in registers, but does always push structures and then pass their
70 Pass 2: Replay the same computation but this time also write the
71 values out to the target. */
73 for (write_pass
= 0; write_pass
< 2; write_pass
++)
76 /* Next available floating point register for float and double
79 /* Next available general register for non-float, non-vector
82 /* Next available vector register for vector arguments. */
84 /* Arguments start above the "LR save word" and "Back chain". */
85 int argoffset
= 2 * tdep
->wordsize
;
86 /* Structures start after the arguments. */
87 int structoffset
= argoffset
+ argspace
;
89 /* If the function is returning a `struct', then the first word
90 (which will be passed in r3) is used for struct return
91 address. In that case we should advance one word and start
92 from r4 register to copy parameters. */
96 regcache_cooked_write_signed (regcache
,
97 tdep
->ppc_gp0_regnum
+ greg
,
102 for (argno
= 0; argno
< nargs
; argno
++)
104 struct value
*arg
= args
[argno
];
105 struct type
*type
= check_typedef (value_type (arg
));
106 int len
= TYPE_LENGTH (type
);
107 const bfd_byte
*val
= value_contents (arg
);
109 if (TYPE_CODE (type
) == TYPE_CODE_FLT
&& len
<= 8
110 && !tdep
->soft_float
)
112 /* Floating point value converted to "double" then
113 passed in an FP register, when the registers run out,
114 8 byte aligned stack is used. */
119 /* Always store the floating point value using
120 the register's floating-point format. */
121 gdb_byte regval
[MAX_REGISTER_SIZE
];
123 = register_type (gdbarch
, tdep
->ppc_fp0_regnum
+ freg
);
124 convert_typed_floating (val
, type
, regval
, regtype
);
125 regcache_cooked_write (regcache
,
126 tdep
->ppc_fp0_regnum
+ freg
,
133 /* The SysV ABI tells us to convert floats to
134 doubles before writing them to an 8 byte aligned
135 stack location. Unfortunately GCC does not do
136 that, and stores floats into 4 byte aligned
137 locations without converting them to doubles.
138 Since there is no know compiler that actually
139 follows the ABI here, we implement the GCC
142 /* Align to 4 bytes or 8 bytes depending on the type of
143 the argument (float or double). */
144 argoffset
= align_up (argoffset
, len
);
146 write_memory (sp
+ argoffset
, val
, len
);
150 else if (TYPE_CODE (type
) == TYPE_CODE_FLT
153 && (gdbarch_long_double_format (gdbarch
)
154 == floatformats_ibm_long_double
))
156 /* IBM long double passed in two FP registers if
157 available, otherwise 8-byte aligned stack. */
162 regcache_cooked_write (regcache
,
163 tdep
->ppc_fp0_regnum
+ freg
,
165 regcache_cooked_write (regcache
,
166 tdep
->ppc_fp0_regnum
+ freg
+ 1,
173 argoffset
= align_up (argoffset
, 8);
175 write_memory (sp
+ argoffset
, val
, len
);
180 && (TYPE_CODE (type
) == TYPE_CODE_INT
/* long long */
181 || TYPE_CODE (type
) == TYPE_CODE_FLT
/* double */
182 || (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
183 && tdep
->soft_float
)))
185 /* "long long" or soft-float "double" or "_Decimal64"
186 passed in an odd/even register pair with the low
187 addressed word in the odd register and the high
188 addressed word in the even register, or when the
189 registers run out an 8 byte aligned stack
193 /* Just in case GREG was 10. */
195 argoffset
= align_up (argoffset
, 8);
197 write_memory (sp
+ argoffset
, val
, len
);
202 /* Must start on an odd register - r3/r4 etc. */
207 regcache_cooked_write (regcache
,
208 tdep
->ppc_gp0_regnum
+ greg
+ 0,
210 regcache_cooked_write (regcache
,
211 tdep
->ppc_gp0_regnum
+ greg
+ 1,
218 && ((TYPE_CODE (type
) == TYPE_CODE_FLT
219 && (gdbarch_long_double_format (gdbarch
)
220 == floatformats_ibm_long_double
))
221 || (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
222 && tdep
->soft_float
)))
224 /* Soft-float IBM long double or _Decimal128 passed in
225 four consecutive registers, or on the stack. The
226 registers are not necessarily odd/even pairs. */
230 argoffset
= align_up (argoffset
, 8);
232 write_memory (sp
+ argoffset
, val
, len
);
239 regcache_cooked_write (regcache
,
240 tdep
->ppc_gp0_regnum
+ greg
+ 0,
242 regcache_cooked_write (regcache
,
243 tdep
->ppc_gp0_regnum
+ greg
+ 1,
245 regcache_cooked_write (regcache
,
246 tdep
->ppc_gp0_regnum
+ greg
+ 2,
248 regcache_cooked_write (regcache
,
249 tdep
->ppc_gp0_regnum
+ greg
+ 3,
255 else if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& len
<= 8
256 && !tdep
->soft_float
)
258 /* 32-bit and 64-bit decimal floats go in f1 .. f8. They can
265 gdb_byte regval
[MAX_REGISTER_SIZE
];
268 /* 32-bit decimal floats are right aligned in the
270 if (TYPE_LENGTH (type
) == 4)
272 memcpy (regval
+ 4, val
, 4);
278 regcache_cooked_write (regcache
,
279 tdep
->ppc_fp0_regnum
+ freg
, p
);
286 argoffset
= align_up (argoffset
, len
);
289 /* Write value in the stack's parameter save area. */
290 write_memory (sp
+ argoffset
, val
, len
);
295 else if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& len
== 16
296 && !tdep
->soft_float
)
298 /* 128-bit decimal floats go in f2 .. f7, always in even/odd
299 pairs. They can end up in memory, using two doublewords. */
303 /* Make sure freg is even. */
308 regcache_cooked_write (regcache
,
309 tdep
->ppc_fp0_regnum
+ freg
, val
);
310 regcache_cooked_write (regcache
,
311 tdep
->ppc_fp0_regnum
+ freg
+ 1, val
+ 8);
316 argoffset
= align_up (argoffset
, 8);
319 write_memory (sp
+ argoffset
, val
, 16);
324 /* If a 128-bit decimal float goes to the stack because only f7
325 and f8 are free (thus there's no even/odd register pair
326 available), these registers should be marked as occupied.
327 Hence we increase freg even when writing to memory. */
331 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
332 && TYPE_VECTOR (type
)
333 && tdep
->vector_abi
== POWERPC_VEC_ALTIVEC
)
335 /* Vector parameter passed in an Altivec register, or
336 when that runs out, 16 byte aligned stack location. */
340 regcache_cooked_write (regcache
,
341 tdep
->ppc_vr0_regnum
+ vreg
, val
);
346 argoffset
= align_up (argoffset
, 16);
348 write_memory (sp
+ argoffset
, val
, 16);
353 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
354 && TYPE_VECTOR (type
)
355 && tdep
->vector_abi
== POWERPC_VEC_SPE
)
357 /* Vector parameter passed in an e500 register, or when
358 that runs out, 8 byte aligned stack location. Note
359 that since e500 vector and general purpose registers
360 both map onto the same underlying register set, a
361 "greg" and not a "vreg" is consumed here. A cooked
362 write stores the value in the correct locations
363 within the raw register cache. */
367 regcache_cooked_write (regcache
,
368 tdep
->ppc_ev0_regnum
+ greg
, val
);
373 argoffset
= align_up (argoffset
, 8);
375 write_memory (sp
+ argoffset
, val
, 8);
381 /* Reduce the parameter down to something that fits in a
383 gdb_byte word
[MAX_REGISTER_SIZE
];
384 memset (word
, 0, MAX_REGISTER_SIZE
);
385 if (len
> tdep
->wordsize
386 || TYPE_CODE (type
) == TYPE_CODE_STRUCT
387 || TYPE_CODE (type
) == TYPE_CODE_UNION
)
389 /* Structs and large values are put in an
390 aligned stack slot ... */
391 if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
392 && TYPE_VECTOR (type
)
394 structoffset
= align_up (structoffset
, 16);
396 structoffset
= align_up (structoffset
, 8);
399 write_memory (sp
+ structoffset
, val
, len
);
400 /* ... and then a "word" pointing to that address is
401 passed as the parameter. */
402 store_unsigned_integer (word
, tdep
->wordsize
, byte_order
,
406 else if (TYPE_CODE (type
) == TYPE_CODE_INT
)
407 /* Sign or zero extend the "int" into a "word". */
408 store_unsigned_integer (word
, tdep
->wordsize
, byte_order
,
409 unpack_long (type
, val
));
411 /* Always goes in the low address. */
412 memcpy (word
, val
, len
);
413 /* Store that "word" in a register, or on the stack.
414 The words have "4" byte alignment. */
418 regcache_cooked_write (regcache
,
419 tdep
->ppc_gp0_regnum
+ greg
, word
);
424 argoffset
= align_up (argoffset
, tdep
->wordsize
);
426 write_memory (sp
+ argoffset
, word
, tdep
->wordsize
);
427 argoffset
+= tdep
->wordsize
;
432 /* Compute the actual stack space requirements. */
435 /* Remember the amount of space needed by the arguments. */
436 argspace
= argoffset
;
437 /* Allocate space for both the arguments and the structures. */
438 sp
-= (argoffset
+ structoffset
);
439 /* Ensure that the stack is still 16 byte aligned. */
440 sp
= align_down (sp
, 16);
443 /* The psABI says that "A caller of a function that takes a
444 variable argument list shall set condition register bit 6 to
445 1 if it passes one or more arguments in the floating-point
446 registers. It is strongly recommended that the caller set the
447 bit to 0 otherwise..." Doing this for normal functions too
453 regcache_cooked_read_unsigned (regcache
, tdep
->ppc_cr_regnum
, &cr
);
458 regcache_cooked_write_unsigned (regcache
, tdep
->ppc_cr_regnum
, cr
);
463 regcache_cooked_write_signed (regcache
, gdbarch_sp_regnum (gdbarch
), sp
);
465 /* Write the backchain (it occupies WORDSIZED bytes). */
466 write_memory_signed_integer (sp
, tdep
->wordsize
, byte_order
, saved_sp
);
468 /* Point the inferior function call's return address at the dummy's
470 regcache_cooked_write_signed (regcache
, tdep
->ppc_lr_regnum
, bp_addr
);
475 /* Handle the return-value conventions for Decimal Floating Point values
476 in both ppc32 and ppc64, which are the same. */
478 get_decimal_float_return_value (struct gdbarch
*gdbarch
, struct type
*valtype
,
479 struct regcache
*regcache
, gdb_byte
*readbuf
,
480 const gdb_byte
*writebuf
)
482 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
484 gdb_assert (TYPE_CODE (valtype
) == TYPE_CODE_DECFLOAT
);
486 /* 32-bit and 64-bit decimal floats in f1. */
487 if (TYPE_LENGTH (valtype
) <= 8)
489 if (writebuf
!= NULL
)
491 gdb_byte regval
[MAX_REGISTER_SIZE
];
494 /* 32-bit decimal float is right aligned in the doubleword. */
495 if (TYPE_LENGTH (valtype
) == 4)
497 memcpy (regval
+ 4, writebuf
, 4);
503 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1, p
);
507 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1, readbuf
);
509 /* Left align 32-bit decimal float. */
510 if (TYPE_LENGTH (valtype
) == 4)
511 memcpy (readbuf
, readbuf
+ 4, 4);
514 /* 128-bit decimal floats in f2,f3. */
515 else if (TYPE_LENGTH (valtype
) == 16)
517 if (writebuf
!= NULL
|| readbuf
!= NULL
)
521 for (i
= 0; i
< 2; i
++)
523 if (writebuf
!= NULL
)
524 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 2 + i
,
527 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 2 + i
,
534 internal_error (__FILE__
, __LINE__
, _("Unknown decimal float size."));
536 return RETURN_VALUE_REGISTER_CONVENTION
;
539 /* Handle the return-value conventions specified by the SysV 32-bit
540 PowerPC ABI (including all the supplements):
542 no floating-point: floating-point values returned using 32-bit
543 general-purpose registers.
545 Altivec: 128-bit vectors returned using vector registers.
547 e500: 64-bit vectors returned using the full full 64 bit EV
548 register, floating-point values returned using 32-bit
549 general-purpose registers.
551 GCC (broken): Small struct values right (instead of left) aligned
552 when returned in general-purpose registers. */
554 static enum return_value_convention
555 do_ppc_sysv_return_value (struct gdbarch
*gdbarch
, struct type
*type
,
556 struct regcache
*regcache
, gdb_byte
*readbuf
,
557 const gdb_byte
*writebuf
, int broken_gcc
)
559 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
560 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
561 gdb_assert (tdep
->wordsize
== 4);
562 if (TYPE_CODE (type
) == TYPE_CODE_FLT
563 && TYPE_LENGTH (type
) <= 8
564 && !tdep
->soft_float
)
568 /* Floats and doubles stored in "f1". Convert the value to
569 the required type. */
570 gdb_byte regval
[MAX_REGISTER_SIZE
];
571 struct type
*regtype
= register_type (gdbarch
,
572 tdep
->ppc_fp0_regnum
+ 1);
573 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1, regval
);
574 convert_typed_floating (regval
, regtype
, readbuf
, type
);
578 /* Floats and doubles stored in "f1". Convert the value to
579 the register's "double" type. */
580 gdb_byte regval
[MAX_REGISTER_SIZE
];
581 struct type
*regtype
= register_type (gdbarch
, tdep
->ppc_fp0_regnum
);
582 convert_typed_floating (writebuf
, type
, regval
, regtype
);
583 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1, regval
);
585 return RETURN_VALUE_REGISTER_CONVENTION
;
587 if (TYPE_CODE (type
) == TYPE_CODE_FLT
588 && TYPE_LENGTH (type
) == 16
590 && (gdbarch_long_double_format (gdbarch
)
591 == floatformats_ibm_long_double
))
593 /* IBM long double stored in f1 and f2. */
596 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1, readbuf
);
597 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 2,
602 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1, writebuf
);
603 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 2,
606 return RETURN_VALUE_REGISTER_CONVENTION
;
608 if (TYPE_LENGTH (type
) == 16
609 && ((TYPE_CODE (type
) == TYPE_CODE_FLT
610 && (gdbarch_long_double_format (gdbarch
)
611 == floatformats_ibm_long_double
))
612 || (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& tdep
->soft_float
)))
614 /* Soft-float IBM long double or _Decimal128 stored in r3, r4,
618 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3, readbuf
);
619 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
621 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 5,
623 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 6,
628 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3, writebuf
);
629 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
631 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 5,
633 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 6,
636 return RETURN_VALUE_REGISTER_CONVENTION
;
638 if ((TYPE_CODE (type
) == TYPE_CODE_INT
&& TYPE_LENGTH (type
) == 8)
639 || (TYPE_CODE (type
) == TYPE_CODE_FLT
&& TYPE_LENGTH (type
) == 8)
640 || (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& TYPE_LENGTH (type
) == 8
641 && tdep
->soft_float
))
645 /* A long long, double or _Decimal64 stored in the 32 bit
647 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3,
649 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
654 /* A long long, double or _Decimal64 stored in the 32 bit
656 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3,
658 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
661 return RETURN_VALUE_REGISTER_CONVENTION
;
663 if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& !tdep
->soft_float
)
664 return get_decimal_float_return_value (gdbarch
, type
, regcache
, readbuf
,
666 else if ((TYPE_CODE (type
) == TYPE_CODE_INT
667 || TYPE_CODE (type
) == TYPE_CODE_CHAR
668 || TYPE_CODE (type
) == TYPE_CODE_BOOL
669 || TYPE_CODE (type
) == TYPE_CODE_PTR
670 || TYPE_CODE (type
) == TYPE_CODE_REF
671 || TYPE_CODE (type
) == TYPE_CODE_ENUM
)
672 && TYPE_LENGTH (type
) <= tdep
->wordsize
)
676 /* Some sort of integer stored in r3. Since TYPE isn't
677 bigger than the register, sign extension isn't a problem
678 - just do everything unsigned. */
680 regcache_cooked_read_unsigned (regcache
, tdep
->ppc_gp0_regnum
+ 3,
682 store_unsigned_integer (readbuf
, TYPE_LENGTH (type
), byte_order
,
687 /* Some sort of integer stored in r3. Use unpack_long since
688 that should handle any required sign extension. */
689 regcache_cooked_write_unsigned (regcache
, tdep
->ppc_gp0_regnum
+ 3,
690 unpack_long (type
, writebuf
));
692 return RETURN_VALUE_REGISTER_CONVENTION
;
694 if (TYPE_LENGTH (type
) == 16
695 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
696 && TYPE_VECTOR (type
)
697 && tdep
->vector_abi
== POWERPC_VEC_ALTIVEC
)
701 /* Altivec places the return value in "v2". */
702 regcache_cooked_read (regcache
, tdep
->ppc_vr0_regnum
+ 2, readbuf
);
706 /* Altivec places the return value in "v2". */
707 regcache_cooked_write (regcache
, tdep
->ppc_vr0_regnum
+ 2, writebuf
);
709 return RETURN_VALUE_REGISTER_CONVENTION
;
711 if (TYPE_LENGTH (type
) == 16
712 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
713 && TYPE_VECTOR (type
)
714 && tdep
->vector_abi
== POWERPC_VEC_GENERIC
)
716 /* GCC -maltivec -mabi=no-altivec returns vectors in r3/r4/r5/r6.
717 GCC without AltiVec returns them in memory, but it warns about
718 ABI risks in that case; we don't try to support it. */
721 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3,
723 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
725 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 5,
727 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 6,
732 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3,
734 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
736 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 5,
738 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 6,
741 return RETURN_VALUE_REGISTER_CONVENTION
;
743 if (TYPE_LENGTH (type
) == 8
744 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
745 && TYPE_VECTOR (type
)
746 && tdep
->vector_abi
== POWERPC_VEC_SPE
)
748 /* The e500 ABI places return values for the 64-bit DSP types
749 (__ev64_opaque__) in r3. However, in GDB-speak, ev3
750 corresponds to the entire r3 value for e500, whereas GDB's r3
751 only corresponds to the least significant 32-bits. So place
752 the 64-bit DSP type's value in ev3. */
754 regcache_cooked_read (regcache
, tdep
->ppc_ev0_regnum
+ 3, readbuf
);
756 regcache_cooked_write (regcache
, tdep
->ppc_ev0_regnum
+ 3, writebuf
);
757 return RETURN_VALUE_REGISTER_CONVENTION
;
759 if (broken_gcc
&& TYPE_LENGTH (type
) <= 8)
761 /* GCC screwed up for structures or unions whose size is less
762 than or equal to 8 bytes.. Instead of left-aligning, it
763 right-aligns the data into the buffer formed by r3, r4. */
764 gdb_byte regvals
[MAX_REGISTER_SIZE
* 2];
765 int len
= TYPE_LENGTH (type
);
766 int offset
= (2 * tdep
->wordsize
- len
) % tdep
->wordsize
;
770 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3,
771 regvals
+ 0 * tdep
->wordsize
);
772 if (len
> tdep
->wordsize
)
773 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
774 regvals
+ 1 * tdep
->wordsize
);
775 memcpy (readbuf
, regvals
+ offset
, len
);
779 memset (regvals
, 0, sizeof regvals
);
780 memcpy (regvals
+ offset
, writebuf
, len
);
781 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3,
782 regvals
+ 0 * tdep
->wordsize
);
783 if (len
> tdep
->wordsize
)
784 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
785 regvals
+ 1 * tdep
->wordsize
);
788 return RETURN_VALUE_REGISTER_CONVENTION
;
790 if (TYPE_LENGTH (type
) <= 8)
794 /* This matches SVr4 PPC, it does not match GCC. */
795 /* The value is right-padded to 8 bytes and then loaded, as
796 two "words", into r3/r4. */
797 gdb_byte regvals
[MAX_REGISTER_SIZE
* 2];
798 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3,
799 regvals
+ 0 * tdep
->wordsize
);
800 if (TYPE_LENGTH (type
) > tdep
->wordsize
)
801 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
802 regvals
+ 1 * tdep
->wordsize
);
803 memcpy (readbuf
, regvals
, TYPE_LENGTH (type
));
807 /* This matches SVr4 PPC, it does not match GCC. */
808 /* The value is padded out to 8 bytes and then loaded, as
809 two "words" into r3/r4. */
810 gdb_byte regvals
[MAX_REGISTER_SIZE
* 2];
811 memset (regvals
, 0, sizeof regvals
);
812 memcpy (regvals
, writebuf
, TYPE_LENGTH (type
));
813 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3,
814 regvals
+ 0 * tdep
->wordsize
);
815 if (TYPE_LENGTH (type
) > tdep
->wordsize
)
816 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
817 regvals
+ 1 * tdep
->wordsize
);
819 return RETURN_VALUE_REGISTER_CONVENTION
;
821 return RETURN_VALUE_STRUCT_CONVENTION
;
824 enum return_value_convention
825 ppc_sysv_abi_return_value (struct gdbarch
*gdbarch
, struct type
*func_type
,
826 struct type
*valtype
, struct regcache
*regcache
,
827 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
829 return do_ppc_sysv_return_value (gdbarch
, valtype
, regcache
, readbuf
,
833 enum return_value_convention
834 ppc_sysv_abi_broken_return_value (struct gdbarch
*gdbarch
,
835 struct type
*func_type
,
836 struct type
*valtype
,
837 struct regcache
*regcache
,
838 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
840 return do_ppc_sysv_return_value (gdbarch
, valtype
, regcache
, readbuf
,
844 /* The helper function for 64-bit SYSV push_dummy_call. Converts the
845 function's code address back into the function's descriptor
848 Find a value for the TOC register. Every symbol should have both
849 ".FN" and "FN" in the minimal symbol table. "FN" points at the
850 FN's descriptor, while ".FN" points at the entry point (which
851 matches FUNC_ADDR). Need to reverse from FUNC_ADDR back to the
852 FN's descriptor address (while at the same time being careful to
853 find "FN" in the same object file as ".FN"). */
856 convert_code_addr_to_desc_addr (CORE_ADDR code_addr
, CORE_ADDR
*desc_addr
)
858 struct obj_section
*dot_fn_section
;
859 struct minimal_symbol
*dot_fn
;
860 struct minimal_symbol
*fn
;
862 /* Find the minimal symbol that corresponds to CODE_ADDR (should
863 have a name of the form ".FN"). */
864 dot_fn
= lookup_minimal_symbol_by_pc (code_addr
);
865 if (dot_fn
== NULL
|| SYMBOL_LINKAGE_NAME (dot_fn
)[0] != '.')
867 /* Get the section that contains CODE_ADDR. Need this for the
868 "objfile" that it contains. */
869 dot_fn_section
= find_pc_section (code_addr
);
870 if (dot_fn_section
== NULL
|| dot_fn_section
->objfile
== NULL
)
872 /* Now find the corresponding "FN" (dropping ".") minimal symbol's
873 address. Only look for the minimal symbol in ".FN"'s object file
874 - avoids problems when two object files (i.e., shared libraries)
875 contain a minimal symbol with the same name. */
876 fn
= lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (dot_fn
) + 1, NULL
,
877 dot_fn_section
->objfile
);
880 /* Found a descriptor. */
881 (*desc_addr
) = SYMBOL_VALUE_ADDRESS (fn
);
885 /* Pass the arguments in either registers, or in the stack. Using the
888 This implements a dumbed down version of the ABI. It always writes
889 values to memory, GPR and FPR, even when not necessary. Doing this
890 greatly simplifies the logic. */
893 ppc64_sysv_abi_push_dummy_call (struct gdbarch
*gdbarch
,
894 struct value
*function
,
895 struct regcache
*regcache
, CORE_ADDR bp_addr
,
896 int nargs
, struct value
**args
, CORE_ADDR sp
,
897 int struct_return
, CORE_ADDR struct_addr
)
899 CORE_ADDR func_addr
= find_function_addr (function
, NULL
);
900 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
901 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
903 /* See for-loop comment below. */
905 /* Size of the general parameter region, the final value is computed
906 in the for-loop below. */
907 LONGEST gparam_size
= 0;
908 /* Kevin writes ... I don't mind seeing tdep->wordsize used in the
909 calls to align_up(), align_down(), etc. because this makes it
910 easier to reuse this code (in a copy/paste sense) in the future,
911 but it is a 64-bit ABI and asserting that the wordsize is 8 bytes
912 at some point makes it easier to verify that this function is
913 correct without having to do a non-local analysis to figure out
914 the possible values of tdep->wordsize. */
915 gdb_assert (tdep
->wordsize
== 8);
917 /* This function exists to support a calling convention that
918 requires floating-point registers. It shouldn't be used on
919 processors that lack them. */
920 gdb_assert (ppc_floating_point_unit_p (gdbarch
));
922 /* By this stage in the proceedings, SP has been decremented by "red
923 zone size" + "struct return size". Fetch the stack-pointer from
924 before this and use that as the BACK_CHAIN. */
925 regcache_cooked_read_unsigned (regcache
, gdbarch_sp_regnum (gdbarch
),
928 /* Go through the argument list twice.
930 Pass 1: Compute the function call's stack space and register
933 Pass 2: Replay the same computation but this time also write the
934 values out to the target. */
936 for (write_pass
= 0; write_pass
< 2; write_pass
++)
939 /* Next available floating point register for float and double
942 /* Next available general register for non-vector (but possibly
945 /* Next available vector register for vector arguments. */
947 /* The address, at which the next general purpose parameter
948 (integer, struct, float, vector, ...) should be saved. */
953 /* During the first pass, GPARAM is more like an offset
954 (start address zero) than an address. That way it
955 accumulates the total stack space required. */
960 /* Decrement the stack pointer making space for the on-stack
961 stack parameters. Set gparam to that region. */
962 gparam
= align_down (sp
- gparam_size
, 16);
963 /* Add in space for the TOC, link editor double word,
964 compiler double word, LR save area, CR save area. */
965 sp
= align_down (gparam
- 48, 16);
968 /* If the function is returning a `struct', then there is an
969 extra hidden parameter (which will be passed in r3)
970 containing the address of that struct.. In that case we
971 should advance one word and start from r4 register to copy
972 parameters. This also consumes one on-stack parameter slot. */
976 regcache_cooked_write_signed (regcache
,
977 tdep
->ppc_gp0_regnum
+ greg
,
980 gparam
= align_up (gparam
+ tdep
->wordsize
, tdep
->wordsize
);
983 for (argno
= 0; argno
< nargs
; argno
++)
985 struct value
*arg
= args
[argno
];
986 struct type
*type
= check_typedef (value_type (arg
));
987 const bfd_byte
*val
= value_contents (arg
);
989 if (TYPE_CODE (type
) == TYPE_CODE_FLT
&& TYPE_LENGTH (type
) <= 8)
991 /* Floats and Doubles go in f1 .. f13. They also
992 consume a left aligned GREG,, and can end up in
996 gdb_byte regval
[MAX_REGISTER_SIZE
];
999 /* Version 1.7 of the 64-bit PowerPC ELF ABI says:
1001 "Single precision floating point values are mapped to
1002 the first word in a single doubleword."
1004 And version 1.9 says:
1006 "Single precision floating point values are mapped to
1007 the second word in a single doubleword."
1009 GDB then writes single precision floating point values
1010 at both words in a doubleword, to support both ABIs. */
1011 if (TYPE_LENGTH (type
) == 4)
1013 memcpy (regval
, val
, 4);
1014 memcpy (regval
+ 4, val
, 4);
1020 /* Write value in the stack's parameter save area. */
1021 write_memory (gparam
, p
, 8);
1025 struct type
*regtype
1026 = register_type (gdbarch
, tdep
->ppc_fp0_regnum
);
1028 convert_typed_floating (val
, type
, regval
, regtype
);
1029 regcache_cooked_write (regcache
,
1030 tdep
->ppc_fp0_regnum
+ freg
,
1034 regcache_cooked_write (regcache
,
1035 tdep
->ppc_gp0_regnum
+ greg
,
1041 /* Always consume parameter stack space. */
1042 gparam
= align_up (gparam
+ 8, tdep
->wordsize
);
1044 else if (TYPE_CODE (type
) == TYPE_CODE_FLT
1045 && TYPE_LENGTH (type
) == 16
1046 && (gdbarch_long_double_format (gdbarch
)
1047 == floatformats_ibm_long_double
))
1049 /* IBM long double stored in two doublewords of the
1050 parameter save area and corresponding registers. */
1053 if (!tdep
->soft_float
&& freg
<= 13)
1055 regcache_cooked_write (regcache
,
1056 tdep
->ppc_fp0_regnum
+ freg
,
1059 regcache_cooked_write (regcache
,
1060 tdep
->ppc_fp0_regnum
+ freg
+ 1,
1065 regcache_cooked_write (regcache
,
1066 tdep
->ppc_gp0_regnum
+ greg
,
1069 regcache_cooked_write (regcache
,
1070 tdep
->ppc_gp0_regnum
+ greg
+ 1,
1073 write_memory (gparam
, val
, TYPE_LENGTH (type
));
1077 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1079 else if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
1080 && TYPE_LENGTH (type
) <= 8)
1082 /* 32-bit and 64-bit decimal floats go in f1 .. f13. They can
1083 end up in memory. */
1086 gdb_byte regval
[MAX_REGISTER_SIZE
];
1089 /* 32-bit decimal floats are right aligned in the
1091 if (TYPE_LENGTH (type
) == 4)
1093 memcpy (regval
+ 4, val
, 4);
1099 /* Write value in the stack's parameter save area. */
1100 write_memory (gparam
, p
, 8);
1103 regcache_cooked_write (regcache
,
1104 tdep
->ppc_fp0_regnum
+ freg
, p
);
1109 /* Always consume parameter stack space. */
1110 gparam
= align_up (gparam
+ 8, tdep
->wordsize
);
1112 else if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&&
1113 TYPE_LENGTH (type
) == 16)
1115 /* 128-bit decimal floats go in f2 .. f12, always in even/odd
1116 pairs. They can end up in memory, using two doublewords. */
1121 /* Make sure freg is even. */
1123 regcache_cooked_write (regcache
,
1124 tdep
->ppc_fp0_regnum
+ freg
, val
);
1125 regcache_cooked_write (regcache
,
1126 tdep
->ppc_fp0_regnum
+ freg
+ 1, val
+ 8);
1129 write_memory (gparam
, val
, TYPE_LENGTH (type
));
1134 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1136 else if (TYPE_LENGTH (type
) == 16 && TYPE_VECTOR (type
)
1137 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
1138 && tdep
->ppc_vr0_regnum
>= 0)
1140 /* In the Altivec ABI, vectors go in the vector registers
1141 v2 .. v13, as well as the parameter area -- always at
1142 16-byte aligned addresses. */
1144 gparam
= align_up (gparam
, 16);
1150 regcache_cooked_write (regcache
,
1151 tdep
->ppc_vr0_regnum
+ vreg
, val
);
1153 write_memory (gparam
, val
, TYPE_LENGTH (type
));
1160 else if ((TYPE_CODE (type
) == TYPE_CODE_INT
1161 || TYPE_CODE (type
) == TYPE_CODE_ENUM
1162 || TYPE_CODE (type
) == TYPE_CODE_BOOL
1163 || TYPE_CODE (type
) == TYPE_CODE_CHAR
1164 || TYPE_CODE (type
) == TYPE_CODE_PTR
1165 || TYPE_CODE (type
) == TYPE_CODE_REF
)
1166 && TYPE_LENGTH (type
) <= 8)
1168 /* Scalars and Pointers get sign[un]extended and go in
1169 gpr3 .. gpr10. They can also end up in memory. */
1172 /* Sign extend the value, then store it unsigned. */
1173 ULONGEST word
= unpack_long (type
, val
);
1174 /* Convert any function code addresses into
1176 if (TYPE_CODE (type
) == TYPE_CODE_PTR
1177 || TYPE_CODE (type
) == TYPE_CODE_REF
)
1179 struct type
*target_type
;
1180 target_type
= check_typedef (TYPE_TARGET_TYPE (type
));
1182 if (TYPE_CODE (target_type
) == TYPE_CODE_FUNC
1183 || TYPE_CODE (target_type
) == TYPE_CODE_METHOD
)
1185 CORE_ADDR desc
= word
;
1186 convert_code_addr_to_desc_addr (word
, &desc
);
1191 regcache_cooked_write_unsigned (regcache
,
1192 tdep
->ppc_gp0_regnum
+
1194 write_memory_unsigned_integer (gparam
, tdep
->wordsize
,
1198 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1203 for (byte
= 0; byte
< TYPE_LENGTH (type
);
1204 byte
+= tdep
->wordsize
)
1206 if (write_pass
&& greg
<= 10)
1208 gdb_byte regval
[MAX_REGISTER_SIZE
];
1209 int len
= TYPE_LENGTH (type
) - byte
;
1210 if (len
> tdep
->wordsize
)
1211 len
= tdep
->wordsize
;
1212 memset (regval
, 0, sizeof regval
);
1213 /* The ABI (version 1.9) specifies that values
1214 smaller than one doubleword are right-aligned
1215 and those larger are left-aligned. GCC
1216 versions before 3.4 implemented this
1218 <http://gcc.gnu.org/gcc-3.4/powerpc-abi.html>. */
1220 memcpy (regval
+ tdep
->wordsize
- len
,
1223 memcpy (regval
, val
+ byte
, len
);
1224 regcache_cooked_write (regcache
, greg
, regval
);
1230 /* WARNING: cagney/2003-09-21: Strictly speaking, this
1231 isn't necessary, unfortunately, GCC appears to get
1232 "struct convention" parameter passing wrong putting
1233 odd sized structures in memory instead of in a
1234 register. Work around this by always writing the
1235 value to memory. Fortunately, doing this
1236 simplifies the code. */
1237 int len
= TYPE_LENGTH (type
);
1238 if (len
< tdep
->wordsize
)
1239 write_memory (gparam
+ tdep
->wordsize
- len
, val
, len
);
1241 write_memory (gparam
, val
, len
);
1244 && TYPE_CODE (type
) == TYPE_CODE_STRUCT
1245 && TYPE_NFIELDS (type
) == 1
1246 && TYPE_LENGTH (type
) <= 16)
1248 /* The ABI (version 1.9) specifies that structs
1249 containing a single floating-point value, at any
1250 level of nesting of single-member structs, are
1251 passed in floating-point registers. */
1252 while (TYPE_CODE (type
) == TYPE_CODE_STRUCT
1253 && TYPE_NFIELDS (type
) == 1)
1254 type
= check_typedef (TYPE_FIELD_TYPE (type
, 0));
1255 if (TYPE_CODE (type
) == TYPE_CODE_FLT
)
1257 if (TYPE_LENGTH (type
) <= 8)
1261 gdb_byte regval
[MAX_REGISTER_SIZE
];
1262 struct type
*regtype
1263 = register_type (gdbarch
,
1264 tdep
->ppc_fp0_regnum
);
1265 convert_typed_floating (val
, type
, regval
,
1267 regcache_cooked_write (regcache
,
1268 (tdep
->ppc_fp0_regnum
1274 else if (TYPE_LENGTH (type
) == 16
1275 && (gdbarch_long_double_format (gdbarch
)
1276 == floatformats_ibm_long_double
))
1280 regcache_cooked_write (regcache
,
1281 (tdep
->ppc_fp0_regnum
1285 regcache_cooked_write (regcache
,
1286 (tdep
->ppc_fp0_regnum
1294 /* Always consume parameter stack space. */
1295 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1301 /* Save the true region sizes ready for the second pass.
1302 Make certain that the general parameter save area is at
1303 least the minimum 8 registers (or doublewords) in size. */
1305 gparam_size
= 8 * tdep
->wordsize
;
1307 gparam_size
= gparam
;
1312 regcache_cooked_write_signed (regcache
, gdbarch_sp_regnum (gdbarch
), sp
);
1314 /* Write the backchain (it occupies WORDSIZED bytes). */
1315 write_memory_signed_integer (sp
, tdep
->wordsize
, byte_order
, back_chain
);
1317 /* Point the inferior function call's return address at the dummy's
1319 regcache_cooked_write_signed (regcache
, tdep
->ppc_lr_regnum
, bp_addr
);
1321 /* Use the func_addr to find the descriptor, and use that to find
1322 the TOC. If we're calling via a function pointer, the pointer
1323 itself identifies the descriptor. */
1325 struct type
*ftype
= check_typedef (value_type (function
));
1326 CORE_ADDR desc_addr
= value_as_address (function
);
1328 if (TYPE_CODE (ftype
) == TYPE_CODE_PTR
1329 || convert_code_addr_to_desc_addr (func_addr
, &desc_addr
))
1331 /* The TOC is the second double word in the descriptor. */
1333 read_memory_unsigned_integer (desc_addr
+ tdep
->wordsize
,
1334 tdep
->wordsize
, byte_order
);
1335 regcache_cooked_write_unsigned (regcache
,
1336 tdep
->ppc_gp0_regnum
+ 2, toc
);
1344 /* The 64 bit ABI return value convention.
1346 Return non-zero if the return-value is stored in a register, return
1347 0 if the return-value is instead stored on the stack (a.k.a.,
1348 struct return convention).
1350 For a return-value stored in a register: when WRITEBUF is non-NULL,
1351 copy the buffer to the corresponding register return-value location
1352 location; when READBUF is non-NULL, fill the buffer from the
1353 corresponding register return-value location. */
1354 enum return_value_convention
1355 ppc64_sysv_abi_return_value (struct gdbarch
*gdbarch
, struct type
*func_type
,
1356 struct type
*valtype
, struct regcache
*regcache
,
1357 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
1359 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1360 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1362 /* This function exists to support a calling convention that
1363 requires floating-point registers. It shouldn't be used on
1364 processors that lack them. */
1365 gdb_assert (ppc_floating_point_unit_p (gdbarch
));
1367 /* Floats and doubles in F1. */
1368 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
&& TYPE_LENGTH (valtype
) <= 8)
1370 gdb_byte regval
[MAX_REGISTER_SIZE
];
1371 struct type
*regtype
= register_type (gdbarch
, tdep
->ppc_fp0_regnum
);
1372 if (writebuf
!= NULL
)
1374 convert_typed_floating (writebuf
, valtype
, regval
, regtype
);
1375 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1, regval
);
1377 if (readbuf
!= NULL
)
1379 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1, regval
);
1380 convert_typed_floating (regval
, regtype
, readbuf
, valtype
);
1382 return RETURN_VALUE_REGISTER_CONVENTION
;
1384 if (TYPE_CODE (valtype
) == TYPE_CODE_DECFLOAT
)
1385 return get_decimal_float_return_value (gdbarch
, valtype
, regcache
, readbuf
,
1387 /* Integers in r3. */
1388 if ((TYPE_CODE (valtype
) == TYPE_CODE_INT
1389 || TYPE_CODE (valtype
) == TYPE_CODE_ENUM
1390 || TYPE_CODE (valtype
) == TYPE_CODE_CHAR
1391 || TYPE_CODE (valtype
) == TYPE_CODE_BOOL
)
1392 && TYPE_LENGTH (valtype
) <= 8)
1394 if (writebuf
!= NULL
)
1396 /* Be careful to sign extend the value. */
1397 regcache_cooked_write_unsigned (regcache
, tdep
->ppc_gp0_regnum
+ 3,
1398 unpack_long (valtype
, writebuf
));
1400 if (readbuf
!= NULL
)
1402 /* Extract the integer from r3. Since this is truncating the
1403 value, there isn't a sign extension problem. */
1405 regcache_cooked_read_unsigned (regcache
, tdep
->ppc_gp0_regnum
+ 3,
1407 store_unsigned_integer (readbuf
, TYPE_LENGTH (valtype
), byte_order
,
1410 return RETURN_VALUE_REGISTER_CONVENTION
;
1412 /* All pointers live in r3. */
1413 if (TYPE_CODE (valtype
) == TYPE_CODE_PTR
1414 || TYPE_CODE (valtype
) == TYPE_CODE_REF
)
1416 /* All pointers live in r3. */
1417 if (writebuf
!= NULL
)
1418 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3, writebuf
);
1419 if (readbuf
!= NULL
)
1420 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3, readbuf
);
1421 return RETURN_VALUE_REGISTER_CONVENTION
;
1423 /* Array type has more than one use. */
1424 if (TYPE_CODE (valtype
) == TYPE_CODE_ARRAY
)
1426 /* Small character arrays are returned, right justified, in r3. */
1427 if (TYPE_LENGTH (valtype
) <= 8
1428 && TYPE_CODE (TYPE_TARGET_TYPE (valtype
)) == TYPE_CODE_INT
1429 && TYPE_LENGTH (TYPE_TARGET_TYPE (valtype
)) == 1)
1431 int offset
= (register_size (gdbarch
, tdep
->ppc_gp0_regnum
+ 3)
1432 - TYPE_LENGTH (valtype
));
1433 if (writebuf
!= NULL
)
1434 regcache_cooked_write_part (regcache
, tdep
->ppc_gp0_regnum
+ 3,
1435 offset
, TYPE_LENGTH (valtype
), writebuf
);
1436 if (readbuf
!= NULL
)
1437 regcache_cooked_read_part (regcache
, tdep
->ppc_gp0_regnum
+ 3,
1438 offset
, TYPE_LENGTH (valtype
), readbuf
);
1439 return RETURN_VALUE_REGISTER_CONVENTION
;
1441 /* A VMX vector is returned in v2. */
1442 if (TYPE_CODE (valtype
) == TYPE_CODE_ARRAY
1443 && TYPE_VECTOR (valtype
) && tdep
->ppc_vr0_regnum
>= 0)
1446 regcache_cooked_read (regcache
, tdep
->ppc_vr0_regnum
+ 2, readbuf
);
1448 regcache_cooked_write (regcache
, tdep
->ppc_vr0_regnum
+ 2,
1450 return RETURN_VALUE_REGISTER_CONVENTION
;
1453 /* Big floating point values get stored in adjacent floating
1454 point registers, starting with F1. */
1455 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
1456 && (TYPE_LENGTH (valtype
) == 16 || TYPE_LENGTH (valtype
) == 32))
1458 if (writebuf
|| readbuf
!= NULL
)
1461 for (i
= 0; i
< TYPE_LENGTH (valtype
) / 8; i
++)
1463 if (writebuf
!= NULL
)
1464 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1 + i
,
1465 (const bfd_byte
*) writebuf
+ i
* 8);
1466 if (readbuf
!= NULL
)
1467 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1 + i
,
1468 (bfd_byte
*) readbuf
+ i
* 8);
1471 return RETURN_VALUE_REGISTER_CONVENTION
;
1473 /* Complex values get returned in f1:f2, need to convert. */
1474 if (TYPE_CODE (valtype
) == TYPE_CODE_COMPLEX
1475 && (TYPE_LENGTH (valtype
) == 8 || TYPE_LENGTH (valtype
) == 16))
1477 if (regcache
!= NULL
)
1480 for (i
= 0; i
< 2; i
++)
1482 gdb_byte regval
[MAX_REGISTER_SIZE
];
1483 struct type
*regtype
=
1484 register_type (gdbarch
, tdep
->ppc_fp0_regnum
);
1485 if (writebuf
!= NULL
)
1487 convert_typed_floating ((const bfd_byte
*) writebuf
+
1488 i
* (TYPE_LENGTH (valtype
) / 2),
1489 valtype
, regval
, regtype
);
1490 regcache_cooked_write (regcache
,
1491 tdep
->ppc_fp0_regnum
+ 1 + i
,
1494 if (readbuf
!= NULL
)
1496 regcache_cooked_read (regcache
,
1497 tdep
->ppc_fp0_regnum
+ 1 + i
,
1499 convert_typed_floating (regval
, regtype
,
1500 (bfd_byte
*) readbuf
+
1501 i
* (TYPE_LENGTH (valtype
) / 2),
1506 return RETURN_VALUE_REGISTER_CONVENTION
;
1508 /* Big complex values get stored in f1:f4. */
1509 if (TYPE_CODE (valtype
) == TYPE_CODE_COMPLEX
&& TYPE_LENGTH (valtype
) == 32)
1511 if (regcache
!= NULL
)
1514 for (i
= 0; i
< 4; i
++)
1516 if (writebuf
!= NULL
)
1517 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1 + i
,
1518 (const bfd_byte
*) writebuf
+ i
* 8);
1519 if (readbuf
!= NULL
)
1520 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1 + i
,
1521 (bfd_byte
*) readbuf
+ i
* 8);
1524 return RETURN_VALUE_REGISTER_CONVENTION
;
1526 return RETURN_VALUE_STRUCT_CONVENTION
;