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
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
);
53 int argspace
= 0; /* 0 is an initial wrong guess. */
56 gdb_assert (tdep
->wordsize
== 4);
58 regcache_cooked_read_unsigned (regcache
, gdbarch_sp_regnum (gdbarch
),
61 /* Go through the argument list twice.
63 Pass 1: Figure out how much new stack space is required for
64 arguments and pushed values. Unlike the PowerOpen ABI, the SysV
65 ABI doesn't reserve any extra space for parameters which are put
66 in registers, but does always push structures and then pass their
69 Pass 2: Replay the same computation but this time also write the
70 values out to the target. */
72 for (write_pass
= 0; write_pass
< 2; write_pass
++)
75 /* Next available floating point register for float and double
78 /* Next available general register for non-float, non-vector
81 /* Next available vector register for vector arguments. */
83 /* Arguments start above the "LR save word" and "Back chain". */
84 int argoffset
= 2 * tdep
->wordsize
;
85 /* Structures start after the arguments. */
86 int structoffset
= argoffset
+ argspace
;
88 /* If the function is returning a `struct', then the first word
89 (which will be passed in r3) is used for struct return
90 address. In that case we should advance one word and start
91 from r4 register to copy parameters. */
95 regcache_cooked_write_signed (regcache
,
96 tdep
->ppc_gp0_regnum
+ greg
,
101 for (argno
= 0; argno
< nargs
; argno
++)
103 struct value
*arg
= args
[argno
];
104 struct type
*type
= check_typedef (value_type (arg
));
105 int len
= TYPE_LENGTH (type
);
106 const bfd_byte
*val
= value_contents (arg
);
108 if (TYPE_CODE (type
) == TYPE_CODE_FLT
&& len
<= 8
109 && !tdep
->soft_float
)
111 /* Floating point value converted to "double" then
112 passed in an FP register, when the registers run out,
113 8 byte aligned stack is used. */
118 /* Always store the floating point value using
119 the register's floating-point format. */
120 gdb_byte regval
[MAX_REGISTER_SIZE
];
122 = register_type (gdbarch
, tdep
->ppc_fp0_regnum
+ freg
);
123 convert_typed_floating (val
, type
, regval
, regtype
);
124 regcache_cooked_write (regcache
,
125 tdep
->ppc_fp0_regnum
+ freg
,
132 /* The SysV ABI tells us to convert floats to
133 doubles before writing them to an 8 byte aligned
134 stack location. Unfortunately GCC does not do
135 that, and stores floats into 4 byte aligned
136 locations without converting them to doubles.
137 Since there is no know compiler that actually
138 follows the ABI here, we implement the GCC
141 /* Align to 4 bytes or 8 bytes depending on the type of
142 the argument (float or double). */
143 argoffset
= align_up (argoffset
, len
);
145 write_memory (sp
+ argoffset
, val
, len
);
149 else if (TYPE_CODE (type
) == TYPE_CODE_FLT
152 && (gdbarch_long_double_format (gdbarch
)
153 == floatformats_ibm_long_double
))
155 /* IBM long double passed in two FP registers if
156 available, otherwise 8-byte aligned stack. */
161 regcache_cooked_write (regcache
,
162 tdep
->ppc_fp0_regnum
+ freg
,
164 regcache_cooked_write (regcache
,
165 tdep
->ppc_fp0_regnum
+ freg
+ 1,
172 argoffset
= align_up (argoffset
, 8);
174 write_memory (sp
+ argoffset
, val
, len
);
179 && (TYPE_CODE (type
) == TYPE_CODE_INT
/* long long */
180 || TYPE_CODE (type
) == TYPE_CODE_FLT
/* double */
181 || (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
182 && tdep
->soft_float
)))
184 /* "long long" or soft-float "double" or "_Decimal64"
185 passed in an odd/even register pair with the low
186 addressed word in the odd register and the high
187 addressed word in the even register, or when the
188 registers run out an 8 byte aligned stack
192 /* Just in case GREG was 10. */
194 argoffset
= align_up (argoffset
, 8);
196 write_memory (sp
+ argoffset
, val
, len
);
201 /* Must start on an odd register - r3/r4 etc. */
206 regcache_cooked_write (regcache
,
207 tdep
->ppc_gp0_regnum
+ greg
+ 0,
209 regcache_cooked_write (regcache
,
210 tdep
->ppc_gp0_regnum
+ greg
+ 1,
217 && ((TYPE_CODE (type
) == TYPE_CODE_FLT
218 && (gdbarch_long_double_format (gdbarch
)
219 == floatformats_ibm_long_double
))
220 || (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
221 && tdep
->soft_float
)))
223 /* Soft-float IBM long double or _Decimal128 passed in
224 four consecutive registers, or on the stack. The
225 registers are not necessarily odd/even pairs. */
229 argoffset
= align_up (argoffset
, 8);
231 write_memory (sp
+ argoffset
, val
, len
);
238 regcache_cooked_write (regcache
,
239 tdep
->ppc_gp0_regnum
+ greg
+ 0,
241 regcache_cooked_write (regcache
,
242 tdep
->ppc_gp0_regnum
+ greg
+ 1,
244 regcache_cooked_write (regcache
,
245 tdep
->ppc_gp0_regnum
+ greg
+ 2,
247 regcache_cooked_write (regcache
,
248 tdep
->ppc_gp0_regnum
+ greg
+ 3,
254 else if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& len
<= 8
255 && !tdep
->soft_float
)
257 /* 32-bit and 64-bit decimal floats go in f1 .. f8. They can
264 gdb_byte regval
[MAX_REGISTER_SIZE
];
267 /* 32-bit decimal floats are right aligned in the
269 if (TYPE_LENGTH (type
) == 4)
271 memcpy (regval
+ 4, val
, 4);
277 regcache_cooked_write (regcache
,
278 tdep
->ppc_fp0_regnum
+ freg
, p
);
285 argoffset
= align_up (argoffset
, len
);
288 /* Write value in the stack's parameter save area. */
289 write_memory (sp
+ argoffset
, val
, len
);
294 else if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& len
== 16
295 && !tdep
->soft_float
)
297 /* 128-bit decimal floats go in f2 .. f7, always in even/odd
298 pairs. They can end up in memory, using two doublewords. */
302 /* Make sure freg is even. */
307 regcache_cooked_write (regcache
,
308 tdep
->ppc_fp0_regnum
+ freg
, val
);
309 regcache_cooked_write (regcache
,
310 tdep
->ppc_fp0_regnum
+ freg
+ 1, val
+ 8);
315 argoffset
= align_up (argoffset
, 8);
318 write_memory (sp
+ argoffset
, val
, 16);
323 /* If a 128-bit decimal float goes to the stack because only f7
324 and f8 are free (thus there's no even/odd register pair
325 available), these registers should be marked as occupied.
326 Hence we increase freg even when writing to memory. */
330 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
331 && TYPE_VECTOR (type
)
332 && tdep
->vector_abi
== POWERPC_VEC_ALTIVEC
)
334 /* Vector parameter passed in an Altivec register, or
335 when that runs out, 16 byte aligned stack location. */
339 regcache_cooked_write (regcache
,
340 tdep
->ppc_vr0_regnum
+ vreg
, val
);
345 argoffset
= align_up (argoffset
, 16);
347 write_memory (sp
+ argoffset
, val
, 16);
352 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
353 && TYPE_VECTOR (type
)
354 && tdep
->vector_abi
== POWERPC_VEC_SPE
)
356 /* Vector parameter passed in an e500 register, or when
357 that runs out, 8 byte aligned stack location. Note
358 that since e500 vector and general purpose registers
359 both map onto the same underlying register set, a
360 "greg" and not a "vreg" is consumed here. A cooked
361 write stores the value in the correct locations
362 within the raw register cache. */
366 regcache_cooked_write (regcache
,
367 tdep
->ppc_ev0_regnum
+ greg
, val
);
372 argoffset
= align_up (argoffset
, 8);
374 write_memory (sp
+ argoffset
, val
, 8);
380 /* Reduce the parameter down to something that fits in a
382 gdb_byte word
[MAX_REGISTER_SIZE
];
383 memset (word
, 0, MAX_REGISTER_SIZE
);
384 if (len
> tdep
->wordsize
385 || TYPE_CODE (type
) == TYPE_CODE_STRUCT
386 || TYPE_CODE (type
) == TYPE_CODE_UNION
)
388 /* Structs and large values are put in an
389 aligned stack slot ... */
390 if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
391 && TYPE_VECTOR (type
)
393 structoffset
= align_up (structoffset
, 16);
395 structoffset
= align_up (structoffset
, 8);
398 write_memory (sp
+ structoffset
, val
, len
);
399 /* ... and then a "word" pointing to that address is
400 passed as the parameter. */
401 store_unsigned_integer (word
, tdep
->wordsize
,
405 else if (TYPE_CODE (type
) == TYPE_CODE_INT
)
406 /* Sign or zero extend the "int" into a "word". */
407 store_unsigned_integer (word
, tdep
->wordsize
,
408 unpack_long (type
, val
));
410 /* Always goes in the low address. */
411 memcpy (word
, val
, len
);
412 /* Store that "word" in a register, or on the stack.
413 The words have "4" byte alignment. */
417 regcache_cooked_write (regcache
,
418 tdep
->ppc_gp0_regnum
+ greg
, word
);
423 argoffset
= align_up (argoffset
, tdep
->wordsize
);
425 write_memory (sp
+ argoffset
, word
, tdep
->wordsize
);
426 argoffset
+= tdep
->wordsize
;
431 /* Compute the actual stack space requirements. */
434 /* Remember the amount of space needed by the arguments. */
435 argspace
= argoffset
;
436 /* Allocate space for both the arguments and the structures. */
437 sp
-= (argoffset
+ structoffset
);
438 /* Ensure that the stack is still 16 byte aligned. */
439 sp
= align_down (sp
, 16);
442 /* The psABI says that "A caller of a function that takes a
443 variable argument list shall set condition register bit 6 to
444 1 if it passes one or more arguments in the floating-point
445 registers. It is strongly recommended that the caller set the
446 bit to 0 otherwise..." Doing this for normal functions too
452 regcache_cooked_read_unsigned (regcache
, tdep
->ppc_cr_regnum
, &cr
);
457 regcache_cooked_write_unsigned (regcache
, tdep
->ppc_cr_regnum
, cr
);
462 regcache_cooked_write_signed (regcache
, gdbarch_sp_regnum (gdbarch
), sp
);
464 /* Write the backchain (it occupies WORDSIZED bytes). */
465 write_memory_signed_integer (sp
, tdep
->wordsize
, saved_sp
);
467 /* Point the inferior function call's return address at the dummy's
469 regcache_cooked_write_signed (regcache
, tdep
->ppc_lr_regnum
, bp_addr
);
474 /* Handle the return-value conventions for Decimal Floating Point values
475 in both ppc32 and ppc64, which are the same. */
477 get_decimal_float_return_value (struct gdbarch
*gdbarch
, struct type
*valtype
,
478 struct regcache
*regcache
, gdb_byte
*readbuf
,
479 const gdb_byte
*writebuf
)
481 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
483 gdb_assert (TYPE_CODE (valtype
) == TYPE_CODE_DECFLOAT
);
485 /* 32-bit and 64-bit decimal floats in f1. */
486 if (TYPE_LENGTH (valtype
) <= 8)
488 if (writebuf
!= NULL
)
490 gdb_byte regval
[MAX_REGISTER_SIZE
];
493 /* 32-bit decimal float is right aligned in the doubleword. */
494 if (TYPE_LENGTH (valtype
) == 4)
496 memcpy (regval
+ 4, writebuf
, 4);
502 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1, p
);
506 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1, readbuf
);
508 /* Left align 32-bit decimal float. */
509 if (TYPE_LENGTH (valtype
) == 4)
510 memcpy (readbuf
, readbuf
+ 4, 4);
513 /* 128-bit decimal floats in f2,f3. */
514 else if (TYPE_LENGTH (valtype
) == 16)
516 if (writebuf
!= NULL
|| readbuf
!= NULL
)
520 for (i
= 0; i
< 2; i
++)
522 if (writebuf
!= NULL
)
523 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 2 + i
,
526 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 2 + i
,
533 internal_error (__FILE__
, __LINE__
, "Unknown decimal float size.");
535 return RETURN_VALUE_REGISTER_CONVENTION
;
538 /* Handle the return-value conventions specified by the SysV 32-bit
539 PowerPC ABI (including all the supplements):
541 no floating-point: floating-point values returned using 32-bit
542 general-purpose registers.
544 Altivec: 128-bit vectors returned using vector registers.
546 e500: 64-bit vectors returned using the full full 64 bit EV
547 register, floating-point values returned using 32-bit
548 general-purpose registers.
550 GCC (broken): Small struct values right (instead of left) aligned
551 when returned in general-purpose registers. */
553 static enum return_value_convention
554 do_ppc_sysv_return_value (struct gdbarch
*gdbarch
, struct type
*type
,
555 struct regcache
*regcache
, gdb_byte
*readbuf
,
556 const gdb_byte
*writebuf
, int broken_gcc
)
558 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
559 gdb_assert (tdep
->wordsize
== 4);
560 if (TYPE_CODE (type
) == TYPE_CODE_FLT
561 && TYPE_LENGTH (type
) <= 8
562 && !tdep
->soft_float
)
566 /* Floats and doubles stored in "f1". Convert the value to
567 the required type. */
568 gdb_byte regval
[MAX_REGISTER_SIZE
];
569 struct type
*regtype
= register_type (gdbarch
,
570 tdep
->ppc_fp0_regnum
+ 1);
571 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1, regval
);
572 convert_typed_floating (regval
, regtype
, readbuf
, type
);
576 /* Floats and doubles stored in "f1". Convert the value to
577 the register's "double" type. */
578 gdb_byte regval
[MAX_REGISTER_SIZE
];
579 struct type
*regtype
= register_type (gdbarch
, tdep
->ppc_fp0_regnum
);
580 convert_typed_floating (writebuf
, type
, regval
, regtype
);
581 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1, regval
);
583 return RETURN_VALUE_REGISTER_CONVENTION
;
585 if (TYPE_CODE (type
) == TYPE_CODE_FLT
586 && TYPE_LENGTH (type
) == 16
588 && (gdbarch_long_double_format (gdbarch
) == floatformats_ibm_long_double
))
590 /* IBM long double stored in f1 and f2. */
593 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1, readbuf
);
594 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 2,
599 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1, writebuf
);
600 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 2,
603 return RETURN_VALUE_REGISTER_CONVENTION
;
605 if (TYPE_LENGTH (type
) == 16
606 && ((TYPE_CODE (type
) == TYPE_CODE_FLT
607 && (gdbarch_long_double_format (gdbarch
) == floatformats_ibm_long_double
))
608 || (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& tdep
->soft_float
)))
610 /* Soft-float IBM long double or _Decimal128 stored in r3, r4,
614 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3, readbuf
);
615 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
617 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 5,
619 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 6,
624 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3, writebuf
);
625 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
627 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 5,
629 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 6,
632 return RETURN_VALUE_REGISTER_CONVENTION
;
634 if ((TYPE_CODE (type
) == TYPE_CODE_INT
&& TYPE_LENGTH (type
) == 8)
635 || (TYPE_CODE (type
) == TYPE_CODE_FLT
&& TYPE_LENGTH (type
) == 8)
636 || (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& TYPE_LENGTH (type
) == 8
637 && tdep
->soft_float
))
641 /* A long long, double or _Decimal64 stored in the 32 bit
643 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3,
645 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
650 /* A long long, double or _Decimal64 stored in the 32 bit
652 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3,
654 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
657 return RETURN_VALUE_REGISTER_CONVENTION
;
659 if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& !tdep
->soft_float
)
660 return get_decimal_float_return_value (gdbarch
, type
, regcache
, readbuf
,
662 else if ((TYPE_CODE (type
) == TYPE_CODE_INT
663 || TYPE_CODE (type
) == TYPE_CODE_CHAR
664 || TYPE_CODE (type
) == TYPE_CODE_BOOL
665 || TYPE_CODE (type
) == TYPE_CODE_PTR
666 || TYPE_CODE (type
) == TYPE_CODE_REF
667 || TYPE_CODE (type
) == TYPE_CODE_ENUM
)
668 && TYPE_LENGTH (type
) <= tdep
->wordsize
)
672 /* Some sort of integer stored in r3. Since TYPE isn't
673 bigger than the register, sign extension isn't a problem
674 - just do everything unsigned. */
676 regcache_cooked_read_unsigned (regcache
, tdep
->ppc_gp0_regnum
+ 3,
678 store_unsigned_integer (readbuf
, TYPE_LENGTH (type
), regval
);
682 /* Some sort of integer stored in r3. Use unpack_long since
683 that should handle any required sign extension. */
684 regcache_cooked_write_unsigned (regcache
, tdep
->ppc_gp0_regnum
+ 3,
685 unpack_long (type
, writebuf
));
687 return RETURN_VALUE_REGISTER_CONVENTION
;
689 if (TYPE_LENGTH (type
) == 16
690 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
691 && TYPE_VECTOR (type
)
692 && tdep
->vector_abi
== POWERPC_VEC_ALTIVEC
)
696 /* Altivec places the return value in "v2". */
697 regcache_cooked_read (regcache
, tdep
->ppc_vr0_regnum
+ 2, readbuf
);
701 /* Altivec places the return value in "v2". */
702 regcache_cooked_write (regcache
, tdep
->ppc_vr0_regnum
+ 2, writebuf
);
704 return RETURN_VALUE_REGISTER_CONVENTION
;
706 if (TYPE_LENGTH (type
) == 16
707 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
708 && TYPE_VECTOR (type
)
709 && tdep
->vector_abi
== POWERPC_VEC_GENERIC
)
711 /* GCC -maltivec -mabi=no-altivec returns vectors in r3/r4/r5/r6.
712 GCC without AltiVec returns them in memory, but it warns about
713 ABI risks in that case; we don't try to support it. */
716 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3,
718 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
720 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 5,
722 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 6,
727 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3,
729 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
731 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 5,
733 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 6,
736 return RETURN_VALUE_REGISTER_CONVENTION
;
738 if (TYPE_LENGTH (type
) == 8
739 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
740 && TYPE_VECTOR (type
)
741 && tdep
->vector_abi
== POWERPC_VEC_SPE
)
743 /* The e500 ABI places return values for the 64-bit DSP types
744 (__ev64_opaque__) in r3. However, in GDB-speak, ev3
745 corresponds to the entire r3 value for e500, whereas GDB's r3
746 only corresponds to the least significant 32-bits. So place
747 the 64-bit DSP type's value in ev3. */
749 regcache_cooked_read (regcache
, tdep
->ppc_ev0_regnum
+ 3, readbuf
);
751 regcache_cooked_write (regcache
, tdep
->ppc_ev0_regnum
+ 3, writebuf
);
752 return RETURN_VALUE_REGISTER_CONVENTION
;
754 if (broken_gcc
&& TYPE_LENGTH (type
) <= 8)
756 /* GCC screwed up for structures or unions whose size is less
757 than or equal to 8 bytes.. Instead of left-aligning, it
758 right-aligns the data into the buffer formed by r3, r4. */
759 gdb_byte regvals
[MAX_REGISTER_SIZE
* 2];
760 int len
= TYPE_LENGTH (type
);
761 int offset
= (2 * tdep
->wordsize
- len
) % tdep
->wordsize
;
765 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3,
766 regvals
+ 0 * tdep
->wordsize
);
767 if (len
> tdep
->wordsize
)
768 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
769 regvals
+ 1 * tdep
->wordsize
);
770 memcpy (readbuf
, regvals
+ offset
, len
);
774 memset (regvals
, 0, sizeof regvals
);
775 memcpy (regvals
+ offset
, writebuf
, len
);
776 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3,
777 regvals
+ 0 * tdep
->wordsize
);
778 if (len
> tdep
->wordsize
)
779 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
780 regvals
+ 1 * tdep
->wordsize
);
783 return RETURN_VALUE_REGISTER_CONVENTION
;
785 if (TYPE_LENGTH (type
) <= 8)
789 /* This matches SVr4 PPC, it does not match GCC. */
790 /* The value is right-padded to 8 bytes and then loaded, as
791 two "words", into r3/r4. */
792 gdb_byte regvals
[MAX_REGISTER_SIZE
* 2];
793 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3,
794 regvals
+ 0 * tdep
->wordsize
);
795 if (TYPE_LENGTH (type
) > tdep
->wordsize
)
796 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
797 regvals
+ 1 * tdep
->wordsize
);
798 memcpy (readbuf
, regvals
, TYPE_LENGTH (type
));
802 /* This matches SVr4 PPC, it does not match GCC. */
803 /* The value is padded out to 8 bytes and then loaded, as
804 two "words" into r3/r4. */
805 gdb_byte regvals
[MAX_REGISTER_SIZE
* 2];
806 memset (regvals
, 0, sizeof regvals
);
807 memcpy (regvals
, writebuf
, TYPE_LENGTH (type
));
808 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3,
809 regvals
+ 0 * tdep
->wordsize
);
810 if (TYPE_LENGTH (type
) > tdep
->wordsize
)
811 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
812 regvals
+ 1 * tdep
->wordsize
);
814 return RETURN_VALUE_REGISTER_CONVENTION
;
816 return RETURN_VALUE_STRUCT_CONVENTION
;
819 enum return_value_convention
820 ppc_sysv_abi_return_value (struct gdbarch
*gdbarch
, struct type
*func_type
,
821 struct type
*valtype
, struct regcache
*regcache
,
822 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
824 return do_ppc_sysv_return_value (gdbarch
, valtype
, regcache
, readbuf
,
828 enum return_value_convention
829 ppc_sysv_abi_broken_return_value (struct gdbarch
*gdbarch
,
830 struct type
*func_type
,
831 struct type
*valtype
,
832 struct regcache
*regcache
,
833 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
835 return do_ppc_sysv_return_value (gdbarch
, valtype
, regcache
, readbuf
,
839 /* The helper function for 64-bit SYSV push_dummy_call. Converts the
840 function's code address back into the function's descriptor
843 Find a value for the TOC register. Every symbol should have both
844 ".FN" and "FN" in the minimal symbol table. "FN" points at the
845 FN's descriptor, while ".FN" points at the entry point (which
846 matches FUNC_ADDR). Need to reverse from FUNC_ADDR back to the
847 FN's descriptor address (while at the same time being careful to
848 find "FN" in the same object file as ".FN"). */
851 convert_code_addr_to_desc_addr (CORE_ADDR code_addr
, CORE_ADDR
*desc_addr
)
853 struct obj_section
*dot_fn_section
;
854 struct minimal_symbol
*dot_fn
;
855 struct minimal_symbol
*fn
;
857 /* Find the minimal symbol that corresponds to CODE_ADDR (should
858 have a name of the form ".FN"). */
859 dot_fn
= lookup_minimal_symbol_by_pc (code_addr
);
860 if (dot_fn
== NULL
|| SYMBOL_LINKAGE_NAME (dot_fn
)[0] != '.')
862 /* Get the section that contains CODE_ADDR. Need this for the
863 "objfile" that it contains. */
864 dot_fn_section
= find_pc_section (code_addr
);
865 if (dot_fn_section
== NULL
|| dot_fn_section
->objfile
== NULL
)
867 /* Now find the corresponding "FN" (dropping ".") minimal symbol's
868 address. Only look for the minimal symbol in ".FN"'s object file
869 - avoids problems when two object files (i.e., shared libraries)
870 contain a minimal symbol with the same name. */
871 fn
= lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (dot_fn
) + 1, NULL
,
872 dot_fn_section
->objfile
);
875 /* Found a descriptor. */
876 (*desc_addr
) = SYMBOL_VALUE_ADDRESS (fn
);
880 /* Pass the arguments in either registers, or in the stack. Using the
883 This implements a dumbed down version of the ABI. It always writes
884 values to memory, GPR and FPR, even when not necessary. Doing this
885 greatly simplifies the logic. */
888 ppc64_sysv_abi_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
889 struct regcache
*regcache
, CORE_ADDR bp_addr
,
890 int nargs
, struct value
**args
, CORE_ADDR sp
,
891 int struct_return
, CORE_ADDR struct_addr
)
893 CORE_ADDR func_addr
= find_function_addr (function
, NULL
);
894 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
896 /* See for-loop comment below. */
898 /* Size of the Altivec's vector parameter region, the final value is
899 computed in the for-loop below. */
900 LONGEST vparam_size
= 0;
901 /* Size of the general parameter region, the final value is computed
902 in the for-loop below. */
903 LONGEST gparam_size
= 0;
904 /* Kevin writes ... I don't mind seeing tdep->wordsize used in the
905 calls to align_up(), align_down(), etc. because this makes it
906 easier to reuse this code (in a copy/paste sense) in the future,
907 but it is a 64-bit ABI and asserting that the wordsize is 8 bytes
908 at some point makes it easier to verify that this function is
909 correct without having to do a non-local analysis to figure out
910 the possible values of tdep->wordsize. */
911 gdb_assert (tdep
->wordsize
== 8);
913 /* This function exists to support a calling convention that
914 requires floating-point registers. It shouldn't be used on
915 processors that lack them. */
916 gdb_assert (ppc_floating_point_unit_p (gdbarch
));
918 /* By this stage in the proceedings, SP has been decremented by "red
919 zone size" + "struct return size". Fetch the stack-pointer from
920 before this and use that as the BACK_CHAIN. */
921 regcache_cooked_read_unsigned (regcache
, gdbarch_sp_regnum (gdbarch
),
924 /* Go through the argument list twice.
926 Pass 1: Compute the function call's stack space and register
929 Pass 2: Replay the same computation but this time also write the
930 values out to the target. */
932 for (write_pass
= 0; write_pass
< 2; write_pass
++)
935 /* Next available floating point register for float and double
938 /* Next available general register for non-vector (but possibly
941 /* Next available vector register for vector arguments. */
943 /* The address, at which the next general purpose parameter
944 (integer, struct, float, ...) should be saved. */
946 /* Address, at which the next Altivec vector parameter should be
952 /* During the first pass, GPARAM and VPARAM are more like
953 offsets (start address zero) than addresses. That way
954 they accumulate the total stack space each region
961 /* Decrement the stack pointer making space for the Altivec
962 and general on-stack parameters. Set vparam and gparam
963 to their corresponding regions. */
964 vparam
= align_down (sp
- vparam_size
, 16);
965 gparam
= align_down (vparam
- gparam_size
, 16);
966 /* Add in space for the TOC, link editor double word,
967 compiler double word, LR save area, CR save area. */
968 sp
= align_down (gparam
- 48, 16);
971 /* If the function is returning a `struct', then there is an
972 extra hidden parameter (which will be passed in r3)
973 containing the address of that struct.. In that case we
974 should advance one word and start from r4 register to copy
975 parameters. This also consumes one on-stack parameter slot. */
979 regcache_cooked_write_signed (regcache
,
980 tdep
->ppc_gp0_regnum
+ greg
,
983 gparam
= align_up (gparam
+ tdep
->wordsize
, tdep
->wordsize
);
986 for (argno
= 0; argno
< nargs
; argno
++)
988 struct value
*arg
= args
[argno
];
989 struct type
*type
= check_typedef (value_type (arg
));
990 const bfd_byte
*val
= value_contents (arg
);
992 if (TYPE_CODE (type
) == TYPE_CODE_FLT
&& TYPE_LENGTH (type
) <= 8)
994 /* Floats and Doubles go in f1 .. f13. They also
995 consume a left aligned GREG,, and can end up in
999 gdb_byte regval
[MAX_REGISTER_SIZE
];
1002 /* Version 1.7 of the 64-bit PowerPC ELF ABI says:
1004 "Single precision floating point values are mapped to
1005 the first word in a single doubleword."
1007 And version 1.9 says:
1009 "Single precision floating point values are mapped to
1010 the second word in a single doubleword."
1012 GDB then writes single precision floating point values
1013 at both words in a doubleword, to support both ABIs. */
1014 if (TYPE_LENGTH (type
) == 4)
1016 memcpy (regval
, val
, 4);
1017 memcpy (regval
+ 4, val
, 4);
1023 /* Write value in the stack's parameter save area. */
1024 write_memory (gparam
, p
, 8);
1028 struct type
*regtype
1029 = register_type (gdbarch
, tdep
->ppc_fp0_regnum
);
1031 convert_typed_floating (val
, type
, regval
, regtype
);
1032 regcache_cooked_write (regcache
,
1033 tdep
->ppc_fp0_regnum
+ freg
,
1037 regcache_cooked_write (regcache
,
1038 tdep
->ppc_gp0_regnum
+ greg
,
1044 /* Always consume parameter stack space. */
1045 gparam
= align_up (gparam
+ 8, tdep
->wordsize
);
1047 else if (TYPE_CODE (type
) == TYPE_CODE_FLT
1048 && TYPE_LENGTH (type
) == 16
1049 && (gdbarch_long_double_format (gdbarch
)
1050 == floatformats_ibm_long_double
))
1052 /* IBM long double stored in two doublewords of the
1053 parameter save area and corresponding registers. */
1056 if (!tdep
->soft_float
&& freg
<= 13)
1058 regcache_cooked_write (regcache
,
1059 tdep
->ppc_fp0_regnum
+ freg
,
1062 regcache_cooked_write (regcache
,
1063 tdep
->ppc_fp0_regnum
+ freg
+ 1,
1068 regcache_cooked_write (regcache
,
1069 tdep
->ppc_gp0_regnum
+ greg
,
1072 regcache_cooked_write (regcache
,
1073 tdep
->ppc_gp0_regnum
+ greg
+ 1,
1076 write_memory (gparam
, val
, TYPE_LENGTH (type
));
1080 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1082 else if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
1083 && TYPE_LENGTH (type
) <= 8)
1085 /* 32-bit and 64-bit decimal floats go in f1 .. f13. They can
1086 end up in memory. */
1089 gdb_byte regval
[MAX_REGISTER_SIZE
];
1092 /* 32-bit decimal floats are right aligned in the
1094 if (TYPE_LENGTH (type
) == 4)
1096 memcpy (regval
+ 4, val
, 4);
1102 /* Write value in the stack's parameter save area. */
1103 write_memory (gparam
, p
, 8);
1106 regcache_cooked_write (regcache
,
1107 tdep
->ppc_fp0_regnum
+ freg
, p
);
1112 /* Always consume parameter stack space. */
1113 gparam
= align_up (gparam
+ 8, tdep
->wordsize
);
1115 else if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&&
1116 TYPE_LENGTH (type
) == 16)
1118 /* 128-bit decimal floats go in f2 .. f12, always in even/odd
1119 pairs. They can end up in memory, using two doublewords. */
1124 /* Make sure freg is even. */
1126 regcache_cooked_write (regcache
,
1127 tdep
->ppc_fp0_regnum
+ freg
, val
);
1128 regcache_cooked_write (regcache
,
1129 tdep
->ppc_fp0_regnum
+ freg
+ 1, val
+ 8);
1132 write_memory (gparam
, val
, TYPE_LENGTH (type
));
1137 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1139 else if (TYPE_LENGTH (type
) == 16 && TYPE_VECTOR (type
)
1140 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
1141 && tdep
->ppc_vr0_regnum
>= 0)
1143 /* In the Altivec ABI, vectors go in the vector
1144 registers v2 .. v13, or when that runs out, a vector
1145 annex which goes above all the normal parameters.
1146 NOTE: cagney/2003-09-21: This is a guess based on the
1147 PowerOpen Altivec ABI. */
1151 regcache_cooked_write (regcache
,
1152 tdep
->ppc_vr0_regnum
+ vreg
, val
);
1158 write_memory (vparam
, val
, TYPE_LENGTH (type
));
1159 vparam
= align_up (vparam
+ TYPE_LENGTH (type
), 16);
1162 else if ((TYPE_CODE (type
) == TYPE_CODE_INT
1163 || TYPE_CODE (type
) == TYPE_CODE_ENUM
1164 || TYPE_CODE (type
) == TYPE_CODE_BOOL
1165 || TYPE_CODE (type
) == TYPE_CODE_CHAR
1166 || TYPE_CODE (type
) == TYPE_CODE_PTR
1167 || TYPE_CODE (type
) == TYPE_CODE_REF
)
1168 && TYPE_LENGTH (type
) <= 8)
1170 /* Scalars and Pointers get sign[un]extended and go in
1171 gpr3 .. gpr10. They can also end up in memory. */
1174 /* Sign extend the value, then store it unsigned. */
1175 ULONGEST word
= unpack_long (type
, val
);
1176 /* Convert any function code addresses into
1178 if (TYPE_CODE (type
) == TYPE_CODE_PTR
1179 || TYPE_CODE (type
) == TYPE_CODE_REF
)
1181 struct type
*target_type
;
1182 target_type
= check_typedef (TYPE_TARGET_TYPE (type
));
1184 if (TYPE_CODE (target_type
) == TYPE_CODE_FUNC
1185 || TYPE_CODE (target_type
) == TYPE_CODE_METHOD
)
1187 CORE_ADDR desc
= word
;
1188 convert_code_addr_to_desc_addr (word
, &desc
);
1193 regcache_cooked_write_unsigned (regcache
,
1194 tdep
->ppc_gp0_regnum
+
1196 write_memory_unsigned_integer (gparam
, tdep
->wordsize
,
1200 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1205 for (byte
= 0; byte
< TYPE_LENGTH (type
);
1206 byte
+= tdep
->wordsize
)
1208 if (write_pass
&& greg
<= 10)
1210 gdb_byte regval
[MAX_REGISTER_SIZE
];
1211 int len
= TYPE_LENGTH (type
) - byte
;
1212 if (len
> tdep
->wordsize
)
1213 len
= tdep
->wordsize
;
1214 memset (regval
, 0, sizeof regval
);
1215 /* The ABI (version 1.9) specifies that values
1216 smaller than one doubleword are right-aligned
1217 and those larger are left-aligned. GCC
1218 versions before 3.4 implemented this
1220 <http://gcc.gnu.org/gcc-3.4/powerpc-abi.html>. */
1222 memcpy (regval
+ tdep
->wordsize
- len
,
1225 memcpy (regval
, val
+ byte
, len
);
1226 regcache_cooked_write (regcache
, greg
, regval
);
1232 /* WARNING: cagney/2003-09-21: Strictly speaking, this
1233 isn't necessary, unfortunately, GCC appears to get
1234 "struct convention" parameter passing wrong putting
1235 odd sized structures in memory instead of in a
1236 register. Work around this by always writing the
1237 value to memory. Fortunately, doing this
1238 simplifies the code. */
1239 int len
= TYPE_LENGTH (type
);
1240 if (len
< tdep
->wordsize
)
1241 write_memory (gparam
+ tdep
->wordsize
- len
, val
, len
);
1243 write_memory (gparam
, val
, len
);
1246 && TYPE_CODE (type
) == TYPE_CODE_STRUCT
1247 && TYPE_NFIELDS (type
) == 1
1248 && TYPE_LENGTH (type
) <= 16)
1250 /* The ABI (version 1.9) specifies that structs
1251 containing a single floating-point value, at any
1252 level of nesting of single-member structs, are
1253 passed in floating-point registers. */
1254 while (TYPE_CODE (type
) == TYPE_CODE_STRUCT
1255 && TYPE_NFIELDS (type
) == 1)
1256 type
= check_typedef (TYPE_FIELD_TYPE (type
, 0));
1257 if (TYPE_CODE (type
) == TYPE_CODE_FLT
)
1259 if (TYPE_LENGTH (type
) <= 8)
1263 gdb_byte regval
[MAX_REGISTER_SIZE
];
1264 struct type
*regtype
1265 = register_type (gdbarch
,
1266 tdep
->ppc_fp0_regnum
);
1267 convert_typed_floating (val
, type
, regval
,
1269 regcache_cooked_write (regcache
,
1270 (tdep
->ppc_fp0_regnum
1276 else if (TYPE_LENGTH (type
) == 16
1277 && (gdbarch_long_double_format (gdbarch
)
1278 == floatformats_ibm_long_double
))
1282 regcache_cooked_write (regcache
,
1283 (tdep
->ppc_fp0_regnum
1287 regcache_cooked_write (regcache
,
1288 (tdep
->ppc_fp0_regnum
1296 /* Always consume parameter stack space. */
1297 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1303 /* Save the true region sizes ready for the second pass. */
1304 vparam_size
= vparam
;
1305 /* Make certain that the general parameter save area is at
1306 least the minimum 8 registers (or doublewords) in size. */
1308 gparam_size
= 8 * tdep
->wordsize
;
1310 gparam_size
= gparam
;
1315 regcache_cooked_write_signed (regcache
, gdbarch_sp_regnum (gdbarch
), sp
);
1317 /* Write the backchain (it occupies WORDSIZED bytes). */
1318 write_memory_signed_integer (sp
, tdep
->wordsize
, back_chain
);
1320 /* Point the inferior function call's return address at the dummy's
1322 regcache_cooked_write_signed (regcache
, tdep
->ppc_lr_regnum
, bp_addr
);
1324 /* Use the func_addr to find the descriptor, and use that to find
1327 CORE_ADDR desc_addr
;
1328 if (convert_code_addr_to_desc_addr (func_addr
, &desc_addr
))
1330 /* The TOC is the second double word in the descriptor. */
1332 read_memory_unsigned_integer (desc_addr
+ tdep
->wordsize
,
1334 regcache_cooked_write_unsigned (regcache
,
1335 tdep
->ppc_gp0_regnum
+ 2, toc
);
1343 /* The 64 bit ABI return value convention.
1345 Return non-zero if the return-value is stored in a register, return
1346 0 if the return-value is instead stored on the stack (a.k.a.,
1347 struct return convention).
1349 For a return-value stored in a register: when WRITEBUF is non-NULL,
1350 copy the buffer to the corresponding register return-value location
1351 location; when READBUF is non-NULL, fill the buffer from the
1352 corresponding register return-value location. */
1353 enum return_value_convention
1354 ppc64_sysv_abi_return_value (struct gdbarch
*gdbarch
, struct type
*func_type
,
1355 struct type
*valtype
, struct regcache
*regcache
,
1356 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
1358 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1360 /* This function exists to support a calling convention that
1361 requires floating-point registers. It shouldn't be used on
1362 processors that lack them. */
1363 gdb_assert (ppc_floating_point_unit_p (gdbarch
));
1365 /* Floats and doubles in F1. */
1366 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
&& TYPE_LENGTH (valtype
) <= 8)
1368 gdb_byte regval
[MAX_REGISTER_SIZE
];
1369 struct type
*regtype
= register_type (gdbarch
, tdep
->ppc_fp0_regnum
);
1370 if (writebuf
!= NULL
)
1372 convert_typed_floating (writebuf
, valtype
, regval
, regtype
);
1373 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1, regval
);
1375 if (readbuf
!= NULL
)
1377 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1, regval
);
1378 convert_typed_floating (regval
, regtype
, readbuf
, valtype
);
1380 return RETURN_VALUE_REGISTER_CONVENTION
;
1382 if (TYPE_CODE (valtype
) == TYPE_CODE_DECFLOAT
)
1383 return get_decimal_float_return_value (gdbarch
, valtype
, regcache
, readbuf
,
1385 /* Integers in r3. */
1386 if ((TYPE_CODE (valtype
) == TYPE_CODE_INT
1387 || TYPE_CODE (valtype
) == TYPE_CODE_ENUM
1388 || TYPE_CODE (valtype
) == TYPE_CODE_CHAR
1389 || TYPE_CODE (valtype
) == TYPE_CODE_BOOL
)
1390 && TYPE_LENGTH (valtype
) <= 8)
1392 if (writebuf
!= NULL
)
1394 /* Be careful to sign extend the value. */
1395 regcache_cooked_write_unsigned (regcache
, tdep
->ppc_gp0_regnum
+ 3,
1396 unpack_long (valtype
, writebuf
));
1398 if (readbuf
!= NULL
)
1400 /* Extract the integer from r3. Since this is truncating the
1401 value, there isn't a sign extension problem. */
1403 regcache_cooked_read_unsigned (regcache
, tdep
->ppc_gp0_regnum
+ 3,
1405 store_unsigned_integer (readbuf
, TYPE_LENGTH (valtype
), regval
);
1407 return RETURN_VALUE_REGISTER_CONVENTION
;
1409 /* All pointers live in r3. */
1410 if (TYPE_CODE (valtype
) == TYPE_CODE_PTR
1411 || TYPE_CODE (valtype
) == TYPE_CODE_REF
)
1413 /* All pointers live in r3. */
1414 if (writebuf
!= NULL
)
1415 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3, writebuf
);
1416 if (readbuf
!= NULL
)
1417 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3, readbuf
);
1418 return RETURN_VALUE_REGISTER_CONVENTION
;
1420 /* Array type has more than one use. */
1421 if (TYPE_CODE (valtype
) == TYPE_CODE_ARRAY
)
1423 /* Small character arrays are returned, right justified, in r3. */
1424 if (TYPE_LENGTH (valtype
) <= 8
1425 && TYPE_CODE (TYPE_TARGET_TYPE (valtype
)) == TYPE_CODE_INT
1426 && TYPE_LENGTH (TYPE_TARGET_TYPE (valtype
)) == 1)
1428 int offset
= (register_size (gdbarch
, tdep
->ppc_gp0_regnum
+ 3)
1429 - TYPE_LENGTH (valtype
));
1430 if (writebuf
!= NULL
)
1431 regcache_cooked_write_part (regcache
, tdep
->ppc_gp0_regnum
+ 3,
1432 offset
, TYPE_LENGTH (valtype
), writebuf
);
1433 if (readbuf
!= NULL
)
1434 regcache_cooked_read_part (regcache
, tdep
->ppc_gp0_regnum
+ 3,
1435 offset
, TYPE_LENGTH (valtype
), readbuf
);
1436 return RETURN_VALUE_REGISTER_CONVENTION
;
1438 /* A VMX vector is returned in v2. */
1439 if (TYPE_CODE (valtype
) == TYPE_CODE_ARRAY
1440 && TYPE_VECTOR (valtype
) && tdep
->ppc_vr0_regnum
>= 0)
1443 regcache_cooked_read (regcache
, tdep
->ppc_vr0_regnum
+ 2, readbuf
);
1445 regcache_cooked_write (regcache
, tdep
->ppc_vr0_regnum
+ 2, writebuf
);
1446 return RETURN_VALUE_REGISTER_CONVENTION
;
1449 /* Big floating point values get stored in adjacent floating
1450 point registers, starting with F1. */
1451 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
1452 && (TYPE_LENGTH (valtype
) == 16 || TYPE_LENGTH (valtype
) == 32))
1454 if (writebuf
|| readbuf
!= NULL
)
1457 for (i
= 0; i
< TYPE_LENGTH (valtype
) / 8; i
++)
1459 if (writebuf
!= NULL
)
1460 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1 + i
,
1461 (const bfd_byte
*) writebuf
+ i
* 8);
1462 if (readbuf
!= NULL
)
1463 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1 + i
,
1464 (bfd_byte
*) readbuf
+ i
* 8);
1467 return RETURN_VALUE_REGISTER_CONVENTION
;
1469 /* Complex values get returned in f1:f2, need to convert. */
1470 if (TYPE_CODE (valtype
) == TYPE_CODE_COMPLEX
1471 && (TYPE_LENGTH (valtype
) == 8 || TYPE_LENGTH (valtype
) == 16))
1473 if (regcache
!= NULL
)
1476 for (i
= 0; i
< 2; i
++)
1478 gdb_byte regval
[MAX_REGISTER_SIZE
];
1479 struct type
*regtype
=
1480 register_type (gdbarch
, tdep
->ppc_fp0_regnum
);
1481 if (writebuf
!= NULL
)
1483 convert_typed_floating ((const bfd_byte
*) writebuf
+
1484 i
* (TYPE_LENGTH (valtype
) / 2),
1485 valtype
, regval
, regtype
);
1486 regcache_cooked_write (regcache
,
1487 tdep
->ppc_fp0_regnum
+ 1 + i
,
1490 if (readbuf
!= NULL
)
1492 regcache_cooked_read (regcache
,
1493 tdep
->ppc_fp0_regnum
+ 1 + i
,
1495 convert_typed_floating (regval
, regtype
,
1496 (bfd_byte
*) readbuf
+
1497 i
* (TYPE_LENGTH (valtype
) / 2),
1502 return RETURN_VALUE_REGISTER_CONVENTION
;
1504 /* Big complex values get stored in f1:f4. */
1505 if (TYPE_CODE (valtype
) == TYPE_CODE_COMPLEX
&& TYPE_LENGTH (valtype
) == 32)
1507 if (regcache
!= NULL
)
1510 for (i
= 0; i
< 4; i
++)
1512 if (writebuf
!= NULL
)
1513 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1 + i
,
1514 (const bfd_byte
*) writebuf
+ i
* 8);
1515 if (readbuf
!= NULL
)
1516 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1 + i
,
1517 (bfd_byte
*) readbuf
+ i
* 8);
1520 return RETURN_VALUE_REGISTER_CONVENTION
;
1522 return RETURN_VALUE_STRUCT_CONVENTION
;