include/ChangeLog:
[deliverable/binutils-gdb.git] / gdb / ppc-sysv-tdep.c
1 /* Target-dependent code for PowerPC systems using the SVR4 ABI
2 for GDB, the GNU debugger.
3
4 Copyright (C) 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009, 2010, 2011
5 Free Software Foundation, Inc.
6
7 This file is part of GDB.
8
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.
13
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.
18
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/>. */
21
22 #include "defs.h"
23 #include "gdbcore.h"
24 #include "inferior.h"
25 #include "regcache.h"
26 #include "value.h"
27 #include "gdb_string.h"
28 #include "gdb_assert.h"
29 #include "ppc-tdep.h"
30 #include "target.h"
31 #include "objfiles.h"
32 #include "infcall.h"
33 #include "dwarf2.h"
34
35 /* Pass the arguments in either registers, or in the stack. Using the
36 ppc sysv ABI, the first eight words of the argument list (that might
37 be less than eight parameters if some parameters occupy more than one
38 word) are passed in r3..r10 registers. float and double parameters are
39 passed in fpr's, in addition to that. Rest of the parameters if any
40 are passed in user stack.
41
42 If the function is returning a structure, then the return address is passed
43 in r3, then the first 7 words of the parametes can be passed in registers,
44 starting from r4. */
45
46 CORE_ADDR
47 ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
48 struct regcache *regcache, CORE_ADDR bp_addr,
49 int nargs, struct value **args, CORE_ADDR sp,
50 int struct_return, CORE_ADDR struct_addr)
51 {
52 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
53 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
54 struct type *ftype;
55 int opencl_abi = 0;
56 ULONGEST saved_sp;
57 int argspace = 0; /* 0 is an initial wrong guess. */
58 int write_pass;
59
60 gdb_assert (tdep->wordsize == 4);
61
62 regcache_cooked_read_unsigned (regcache, gdbarch_sp_regnum (gdbarch),
63 &saved_sp);
64
65 ftype = check_typedef (value_type (function));
66 if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
67 ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
68 if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
69 && TYPE_CALLING_CONVENTION (ftype) == DW_CC_GDB_IBM_OpenCL)
70 opencl_abi = 1;
71
72 /* Go through the argument list twice.
73
74 Pass 1: Figure out how much new stack space is required for
75 arguments and pushed values. Unlike the PowerOpen ABI, the SysV
76 ABI doesn't reserve any extra space for parameters which are put
77 in registers, but does always push structures and then pass their
78 address.
79
80 Pass 2: Replay the same computation but this time also write the
81 values out to the target. */
82
83 for (write_pass = 0; write_pass < 2; write_pass++)
84 {
85 int argno;
86 /* Next available floating point register for float and double
87 arguments. */
88 int freg = 1;
89 /* Next available general register for non-float, non-vector
90 arguments. */
91 int greg = 3;
92 /* Next available vector register for vector arguments. */
93 int vreg = 2;
94 /* Arguments start above the "LR save word" and "Back chain". */
95 int argoffset = 2 * tdep->wordsize;
96 /* Structures start after the arguments. */
97 int structoffset = argoffset + argspace;
98
99 /* If the function is returning a `struct', then the first word
100 (which will be passed in r3) is used for struct return
101 address. In that case we should advance one word and start
102 from r4 register to copy parameters. */
103 if (struct_return)
104 {
105 if (write_pass)
106 regcache_cooked_write_signed (regcache,
107 tdep->ppc_gp0_regnum + greg,
108 struct_addr);
109 greg++;
110 }
111
112 for (argno = 0; argno < nargs; argno++)
113 {
114 struct value *arg = args[argno];
115 struct type *type = check_typedef (value_type (arg));
116 int len = TYPE_LENGTH (type);
117 const bfd_byte *val = value_contents (arg);
118
119 if (TYPE_CODE (type) == TYPE_CODE_FLT && len <= 8
120 && !tdep->soft_float)
121 {
122 /* Floating point value converted to "double" then
123 passed in an FP register, when the registers run out,
124 8 byte aligned stack is used. */
125 if (freg <= 8)
126 {
127 if (write_pass)
128 {
129 /* Always store the floating point value using
130 the register's floating-point format. */
131 gdb_byte regval[MAX_REGISTER_SIZE];
132 struct type *regtype
133 = register_type (gdbarch, tdep->ppc_fp0_regnum + freg);
134 convert_typed_floating (val, type, regval, regtype);
135 regcache_cooked_write (regcache,
136 tdep->ppc_fp0_regnum + freg,
137 regval);
138 }
139 freg++;
140 }
141 else
142 {
143 /* The SysV ABI tells us to convert floats to
144 doubles before writing them to an 8 byte aligned
145 stack location. Unfortunately GCC does not do
146 that, and stores floats into 4 byte aligned
147 locations without converting them to doubles.
148 Since there is no know compiler that actually
149 follows the ABI here, we implement the GCC
150 convention. */
151
152 /* Align to 4 bytes or 8 bytes depending on the type of
153 the argument (float or double). */
154 argoffset = align_up (argoffset, len);
155 if (write_pass)
156 write_memory (sp + argoffset, val, len);
157 argoffset += len;
158 }
159 }
160 else if (TYPE_CODE (type) == TYPE_CODE_FLT
161 && len == 16
162 && !tdep->soft_float
163 && (gdbarch_long_double_format (gdbarch)
164 == floatformats_ibm_long_double))
165 {
166 /* IBM long double passed in two FP registers if
167 available, otherwise 8-byte aligned stack. */
168 if (freg <= 7)
169 {
170 if (write_pass)
171 {
172 regcache_cooked_write (regcache,
173 tdep->ppc_fp0_regnum + freg,
174 val);
175 regcache_cooked_write (regcache,
176 tdep->ppc_fp0_regnum + freg + 1,
177 val + 8);
178 }
179 freg += 2;
180 }
181 else
182 {
183 argoffset = align_up (argoffset, 8);
184 if (write_pass)
185 write_memory (sp + argoffset, val, len);
186 argoffset += 16;
187 }
188 }
189 else if (len == 8
190 && (TYPE_CODE (type) == TYPE_CODE_INT /* long long */
191 || TYPE_CODE (type) == TYPE_CODE_FLT /* double */
192 || (TYPE_CODE (type) == TYPE_CODE_DECFLOAT
193 && tdep->soft_float)))
194 {
195 /* "long long" or soft-float "double" or "_Decimal64"
196 passed in an odd/even register pair with the low
197 addressed word in the odd register and the high
198 addressed word in the even register, or when the
199 registers run out an 8 byte aligned stack
200 location. */
201 if (greg > 9)
202 {
203 /* Just in case GREG was 10. */
204 greg = 11;
205 argoffset = align_up (argoffset, 8);
206 if (write_pass)
207 write_memory (sp + argoffset, val, len);
208 argoffset += 8;
209 }
210 else
211 {
212 /* Must start on an odd register - r3/r4 etc. */
213 if ((greg & 1) == 0)
214 greg++;
215 if (write_pass)
216 {
217 regcache_cooked_write (regcache,
218 tdep->ppc_gp0_regnum + greg + 0,
219 val + 0);
220 regcache_cooked_write (regcache,
221 tdep->ppc_gp0_regnum + greg + 1,
222 val + 4);
223 }
224 greg += 2;
225 }
226 }
227 else if (len == 16
228 && ((TYPE_CODE (type) == TYPE_CODE_FLT
229 && (gdbarch_long_double_format (gdbarch)
230 == floatformats_ibm_long_double))
231 || (TYPE_CODE (type) == TYPE_CODE_DECFLOAT
232 && tdep->soft_float)))
233 {
234 /* Soft-float IBM long double or _Decimal128 passed in
235 four consecutive registers, or on the stack. The
236 registers are not necessarily odd/even pairs. */
237 if (greg > 7)
238 {
239 greg = 11;
240 argoffset = align_up (argoffset, 8);
241 if (write_pass)
242 write_memory (sp + argoffset, val, len);
243 argoffset += 16;
244 }
245 else
246 {
247 if (write_pass)
248 {
249 regcache_cooked_write (regcache,
250 tdep->ppc_gp0_regnum + greg + 0,
251 val + 0);
252 regcache_cooked_write (regcache,
253 tdep->ppc_gp0_regnum + greg + 1,
254 val + 4);
255 regcache_cooked_write (regcache,
256 tdep->ppc_gp0_regnum + greg + 2,
257 val + 8);
258 regcache_cooked_write (regcache,
259 tdep->ppc_gp0_regnum + greg + 3,
260 val + 12);
261 }
262 greg += 4;
263 }
264 }
265 else if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT && len <= 8
266 && !tdep->soft_float)
267 {
268 /* 32-bit and 64-bit decimal floats go in f1 .. f8. They can
269 end up in memory. */
270
271 if (freg <= 8)
272 {
273 if (write_pass)
274 {
275 gdb_byte regval[MAX_REGISTER_SIZE];
276 const gdb_byte *p;
277
278 /* 32-bit decimal floats are right aligned in the
279 doubleword. */
280 if (TYPE_LENGTH (type) == 4)
281 {
282 memcpy (regval + 4, val, 4);
283 p = regval;
284 }
285 else
286 p = val;
287
288 regcache_cooked_write (regcache,
289 tdep->ppc_fp0_regnum + freg, p);
290 }
291
292 freg++;
293 }
294 else
295 {
296 argoffset = align_up (argoffset, len);
297
298 if (write_pass)
299 /* Write value in the stack's parameter save area. */
300 write_memory (sp + argoffset, val, len);
301
302 argoffset += len;
303 }
304 }
305 else if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT && len == 16
306 && !tdep->soft_float)
307 {
308 /* 128-bit decimal floats go in f2 .. f7, always in even/odd
309 pairs. They can end up in memory, using two doublewords. */
310
311 if (freg <= 6)
312 {
313 /* Make sure freg is even. */
314 freg += freg & 1;
315
316 if (write_pass)
317 {
318 regcache_cooked_write (regcache,
319 tdep->ppc_fp0_regnum + freg, val);
320 regcache_cooked_write (regcache,
321 tdep->ppc_fp0_regnum + freg + 1, val + 8);
322 }
323 }
324 else
325 {
326 argoffset = align_up (argoffset, 8);
327
328 if (write_pass)
329 write_memory (sp + argoffset, val, 16);
330
331 argoffset += 16;
332 }
333
334 /* If a 128-bit decimal float goes to the stack because only f7
335 and f8 are free (thus there's no even/odd register pair
336 available), these registers should be marked as occupied.
337 Hence we increase freg even when writing to memory. */
338 freg += 2;
339 }
340 else if (len < 16
341 && TYPE_CODE (type) == TYPE_CODE_ARRAY
342 && TYPE_VECTOR (type)
343 && opencl_abi)
344 {
345 /* OpenCL vectors shorter than 16 bytes are passed as if
346 a series of independent scalars. */
347 struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type));
348 int i, nelt = TYPE_LENGTH (type) / TYPE_LENGTH (eltype);
349
350 for (i = 0; i < nelt; i++)
351 {
352 const gdb_byte *elval = val + i * TYPE_LENGTH (eltype);
353
354 if (TYPE_CODE (eltype) == TYPE_CODE_FLT && !tdep->soft_float)
355 {
356 if (freg <= 8)
357 {
358 if (write_pass)
359 {
360 int regnum = tdep->ppc_fp0_regnum + freg;
361 gdb_byte regval[MAX_REGISTER_SIZE];
362 struct type *regtype
363 = register_type (gdbarch, regnum);
364 convert_typed_floating (elval, eltype,
365 regval, regtype);
366 regcache_cooked_write (regcache, regnum, regval);
367 }
368 freg++;
369 }
370 else
371 {
372 argoffset = align_up (argoffset, len);
373 if (write_pass)
374 write_memory (sp + argoffset, val, len);
375 argoffset += len;
376 }
377 }
378 else if (TYPE_LENGTH (eltype) == 8)
379 {
380 if (greg > 9)
381 {
382 /* Just in case GREG was 10. */
383 greg = 11;
384 argoffset = align_up (argoffset, 8);
385 if (write_pass)
386 write_memory (sp + argoffset, elval,
387 TYPE_LENGTH (eltype));
388 argoffset += 8;
389 }
390 else
391 {
392 /* Must start on an odd register - r3/r4 etc. */
393 if ((greg & 1) == 0)
394 greg++;
395 if (write_pass)
396 {
397 int regnum = tdep->ppc_gp0_regnum + greg;
398 regcache_cooked_write (regcache,
399 regnum + 0, elval + 0);
400 regcache_cooked_write (regcache,
401 regnum + 1, elval + 4);
402 }
403 greg += 2;
404 }
405 }
406 else
407 {
408 gdb_byte word[MAX_REGISTER_SIZE];
409 store_unsigned_integer (word, tdep->wordsize, byte_order,
410 unpack_long (eltype, elval));
411
412 if (greg <= 10)
413 {
414 if (write_pass)
415 regcache_cooked_write (regcache,
416 tdep->ppc_gp0_regnum + greg,
417 word);
418 greg++;
419 }
420 else
421 {
422 argoffset = align_up (argoffset, tdep->wordsize);
423 if (write_pass)
424 write_memory (sp + argoffset, word, tdep->wordsize);
425 argoffset += tdep->wordsize;
426 }
427 }
428 }
429 }
430 else if (len >= 16
431 && TYPE_CODE (type) == TYPE_CODE_ARRAY
432 && TYPE_VECTOR (type)
433 && opencl_abi)
434 {
435 /* OpenCL vectors 16 bytes or longer are passed as if
436 a series of AltiVec vectors. */
437 int i;
438
439 for (i = 0; i < len / 16; i++)
440 {
441 const gdb_byte *elval = val + i * 16;
442
443 if (vreg <= 13)
444 {
445 if (write_pass)
446 regcache_cooked_write (regcache,
447 tdep->ppc_vr0_regnum + vreg,
448 elval);
449 vreg++;
450 }
451 else
452 {
453 argoffset = align_up (argoffset, 16);
454 if (write_pass)
455 write_memory (sp + argoffset, elval, 16);
456 argoffset += 16;
457 }
458 }
459 }
460 else if (len == 16
461 && TYPE_CODE (type) == TYPE_CODE_ARRAY
462 && TYPE_VECTOR (type)
463 && tdep->vector_abi == POWERPC_VEC_ALTIVEC)
464 {
465 /* Vector parameter passed in an Altivec register, or
466 when that runs out, 16 byte aligned stack location. */
467 if (vreg <= 13)
468 {
469 if (write_pass)
470 regcache_cooked_write (regcache,
471 tdep->ppc_vr0_regnum + vreg, val);
472 vreg++;
473 }
474 else
475 {
476 argoffset = align_up (argoffset, 16);
477 if (write_pass)
478 write_memory (sp + argoffset, val, 16);
479 argoffset += 16;
480 }
481 }
482 else if (len == 8
483 && TYPE_CODE (type) == TYPE_CODE_ARRAY
484 && TYPE_VECTOR (type)
485 && tdep->vector_abi == POWERPC_VEC_SPE)
486 {
487 /* Vector parameter passed in an e500 register, or when
488 that runs out, 8 byte aligned stack location. Note
489 that since e500 vector and general purpose registers
490 both map onto the same underlying register set, a
491 "greg" and not a "vreg" is consumed here. A cooked
492 write stores the value in the correct locations
493 within the raw register cache. */
494 if (greg <= 10)
495 {
496 if (write_pass)
497 regcache_cooked_write (regcache,
498 tdep->ppc_ev0_regnum + greg, val);
499 greg++;
500 }
501 else
502 {
503 argoffset = align_up (argoffset, 8);
504 if (write_pass)
505 write_memory (sp + argoffset, val, 8);
506 argoffset += 8;
507 }
508 }
509 else
510 {
511 /* Reduce the parameter down to something that fits in a
512 "word". */
513 gdb_byte word[MAX_REGISTER_SIZE];
514 memset (word, 0, MAX_REGISTER_SIZE);
515 if (len > tdep->wordsize
516 || TYPE_CODE (type) == TYPE_CODE_STRUCT
517 || TYPE_CODE (type) == TYPE_CODE_UNION)
518 {
519 /* Structs and large values are put in an
520 aligned stack slot ... */
521 if (TYPE_CODE (type) == TYPE_CODE_ARRAY
522 && TYPE_VECTOR (type)
523 && len >= 16)
524 structoffset = align_up (structoffset, 16);
525 else
526 structoffset = align_up (structoffset, 8);
527
528 if (write_pass)
529 write_memory (sp + structoffset, val, len);
530 /* ... and then a "word" pointing to that address is
531 passed as the parameter. */
532 store_unsigned_integer (word, tdep->wordsize, byte_order,
533 sp + structoffset);
534 structoffset += len;
535 }
536 else if (TYPE_CODE (type) == TYPE_CODE_INT)
537 /* Sign or zero extend the "int" into a "word". */
538 store_unsigned_integer (word, tdep->wordsize, byte_order,
539 unpack_long (type, val));
540 else
541 /* Always goes in the low address. */
542 memcpy (word, val, len);
543 /* Store that "word" in a register, or on the stack.
544 The words have "4" byte alignment. */
545 if (greg <= 10)
546 {
547 if (write_pass)
548 regcache_cooked_write (regcache,
549 tdep->ppc_gp0_regnum + greg, word);
550 greg++;
551 }
552 else
553 {
554 argoffset = align_up (argoffset, tdep->wordsize);
555 if (write_pass)
556 write_memory (sp + argoffset, word, tdep->wordsize);
557 argoffset += tdep->wordsize;
558 }
559 }
560 }
561
562 /* Compute the actual stack space requirements. */
563 if (!write_pass)
564 {
565 /* Remember the amount of space needed by the arguments. */
566 argspace = argoffset;
567 /* Allocate space for both the arguments and the structures. */
568 sp -= (argoffset + structoffset);
569 /* Ensure that the stack is still 16 byte aligned. */
570 sp = align_down (sp, 16);
571 }
572
573 /* The psABI says that "A caller of a function that takes a
574 variable argument list shall set condition register bit 6 to
575 1 if it passes one or more arguments in the floating-point
576 registers. It is strongly recommended that the caller set the
577 bit to 0 otherwise..." Doing this for normal functions too
578 shouldn't hurt. */
579 if (write_pass)
580 {
581 ULONGEST cr;
582
583 regcache_cooked_read_unsigned (regcache, tdep->ppc_cr_regnum, &cr);
584 if (freg > 1)
585 cr |= 0x02000000;
586 else
587 cr &= ~0x02000000;
588 regcache_cooked_write_unsigned (regcache, tdep->ppc_cr_regnum, cr);
589 }
590 }
591
592 /* Update %sp. */
593 regcache_cooked_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp);
594
595 /* Write the backchain (it occupies WORDSIZED bytes). */
596 write_memory_signed_integer (sp, tdep->wordsize, byte_order, saved_sp);
597
598 /* Point the inferior function call's return address at the dummy's
599 breakpoint. */
600 regcache_cooked_write_signed (regcache, tdep->ppc_lr_regnum, bp_addr);
601
602 return sp;
603 }
604
605 /* Handle the return-value conventions for Decimal Floating Point values
606 in both ppc32 and ppc64, which are the same. */
607 static int
608 get_decimal_float_return_value (struct gdbarch *gdbarch, struct type *valtype,
609 struct regcache *regcache, gdb_byte *readbuf,
610 const gdb_byte *writebuf)
611 {
612 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
613
614 gdb_assert (TYPE_CODE (valtype) == TYPE_CODE_DECFLOAT);
615
616 /* 32-bit and 64-bit decimal floats in f1. */
617 if (TYPE_LENGTH (valtype) <= 8)
618 {
619 if (writebuf != NULL)
620 {
621 gdb_byte regval[MAX_REGISTER_SIZE];
622 const gdb_byte *p;
623
624 /* 32-bit decimal float is right aligned in the doubleword. */
625 if (TYPE_LENGTH (valtype) == 4)
626 {
627 memcpy (regval + 4, writebuf, 4);
628 p = regval;
629 }
630 else
631 p = writebuf;
632
633 regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1, p);
634 }
635 if (readbuf != NULL)
636 {
637 regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1, readbuf);
638
639 /* Left align 32-bit decimal float. */
640 if (TYPE_LENGTH (valtype) == 4)
641 memcpy (readbuf, readbuf + 4, 4);
642 }
643 }
644 /* 128-bit decimal floats in f2,f3. */
645 else if (TYPE_LENGTH (valtype) == 16)
646 {
647 if (writebuf != NULL || readbuf != NULL)
648 {
649 int i;
650
651 for (i = 0; i < 2; i++)
652 {
653 if (writebuf != NULL)
654 regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 2 + i,
655 writebuf + i * 8);
656 if (readbuf != NULL)
657 regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 2 + i,
658 readbuf + i * 8);
659 }
660 }
661 }
662 else
663 /* Can't happen. */
664 internal_error (__FILE__, __LINE__, _("Unknown decimal float size."));
665
666 return RETURN_VALUE_REGISTER_CONVENTION;
667 }
668
669 /* Handle the return-value conventions specified by the SysV 32-bit
670 PowerPC ABI (including all the supplements):
671
672 no floating-point: floating-point values returned using 32-bit
673 general-purpose registers.
674
675 Altivec: 128-bit vectors returned using vector registers.
676
677 e500: 64-bit vectors returned using the full full 64 bit EV
678 register, floating-point values returned using 32-bit
679 general-purpose registers.
680
681 GCC (broken): Small struct values right (instead of left) aligned
682 when returned in general-purpose registers. */
683
684 static enum return_value_convention
685 do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type,
686 struct type *type, struct regcache *regcache,
687 gdb_byte *readbuf, const gdb_byte *writebuf,
688 int broken_gcc)
689 {
690 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
691 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
692 int opencl_abi = 0;
693
694 if (func_type
695 && TYPE_CALLING_CONVENTION (func_type) == DW_CC_GDB_IBM_OpenCL)
696 opencl_abi = 1;
697
698 gdb_assert (tdep->wordsize == 4);
699
700 if (TYPE_CODE (type) == TYPE_CODE_FLT
701 && TYPE_LENGTH (type) <= 8
702 && !tdep->soft_float)
703 {
704 if (readbuf)
705 {
706 /* Floats and doubles stored in "f1". Convert the value to
707 the required type. */
708 gdb_byte regval[MAX_REGISTER_SIZE];
709 struct type *regtype = register_type (gdbarch,
710 tdep->ppc_fp0_regnum + 1);
711 regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1, regval);
712 convert_typed_floating (regval, regtype, readbuf, type);
713 }
714 if (writebuf)
715 {
716 /* Floats and doubles stored in "f1". Convert the value to
717 the register's "double" type. */
718 gdb_byte regval[MAX_REGISTER_SIZE];
719 struct type *regtype = register_type (gdbarch, tdep->ppc_fp0_regnum);
720 convert_typed_floating (writebuf, type, regval, regtype);
721 regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1, regval);
722 }
723 return RETURN_VALUE_REGISTER_CONVENTION;
724 }
725 if (TYPE_CODE (type) == TYPE_CODE_FLT
726 && TYPE_LENGTH (type) == 16
727 && !tdep->soft_float
728 && (gdbarch_long_double_format (gdbarch)
729 == floatformats_ibm_long_double))
730 {
731 /* IBM long double stored in f1 and f2. */
732 if (readbuf)
733 {
734 regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1, readbuf);
735 regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 2,
736 readbuf + 8);
737 }
738 if (writebuf)
739 {
740 regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1, writebuf);
741 regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 2,
742 writebuf + 8);
743 }
744 return RETURN_VALUE_REGISTER_CONVENTION;
745 }
746 if (TYPE_LENGTH (type) == 16
747 && ((TYPE_CODE (type) == TYPE_CODE_FLT
748 && (gdbarch_long_double_format (gdbarch)
749 == floatformats_ibm_long_double))
750 || (TYPE_CODE (type) == TYPE_CODE_DECFLOAT && tdep->soft_float)))
751 {
752 /* Soft-float IBM long double or _Decimal128 stored in r3, r4,
753 r5, r6. */
754 if (readbuf)
755 {
756 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3, readbuf);
757 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 4,
758 readbuf + 4);
759 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 5,
760 readbuf + 8);
761 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 6,
762 readbuf + 12);
763 }
764 if (writebuf)
765 {
766 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3, writebuf);
767 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 4,
768 writebuf + 4);
769 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 5,
770 writebuf + 8);
771 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 6,
772 writebuf + 12);
773 }
774 return RETURN_VALUE_REGISTER_CONVENTION;
775 }
776 if ((TYPE_CODE (type) == TYPE_CODE_INT && TYPE_LENGTH (type) == 8)
777 || (TYPE_CODE (type) == TYPE_CODE_FLT && TYPE_LENGTH (type) == 8)
778 || (TYPE_CODE (type) == TYPE_CODE_DECFLOAT && TYPE_LENGTH (type) == 8
779 && tdep->soft_float))
780 {
781 if (readbuf)
782 {
783 /* A long long, double or _Decimal64 stored in the 32 bit
784 r3/r4. */
785 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3,
786 readbuf + 0);
787 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 4,
788 readbuf + 4);
789 }
790 if (writebuf)
791 {
792 /* A long long, double or _Decimal64 stored in the 32 bit
793 r3/r4. */
794 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3,
795 writebuf + 0);
796 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 4,
797 writebuf + 4);
798 }
799 return RETURN_VALUE_REGISTER_CONVENTION;
800 }
801 if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT && !tdep->soft_float)
802 return get_decimal_float_return_value (gdbarch, type, regcache, readbuf,
803 writebuf);
804 else if ((TYPE_CODE (type) == TYPE_CODE_INT
805 || TYPE_CODE (type) == TYPE_CODE_CHAR
806 || TYPE_CODE (type) == TYPE_CODE_BOOL
807 || TYPE_CODE (type) == TYPE_CODE_PTR
808 || TYPE_CODE (type) == TYPE_CODE_REF
809 || TYPE_CODE (type) == TYPE_CODE_ENUM)
810 && TYPE_LENGTH (type) <= tdep->wordsize)
811 {
812 if (readbuf)
813 {
814 /* Some sort of integer stored in r3. Since TYPE isn't
815 bigger than the register, sign extension isn't a problem
816 - just do everything unsigned. */
817 ULONGEST regval;
818 regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
819 &regval);
820 store_unsigned_integer (readbuf, TYPE_LENGTH (type), byte_order,
821 regval);
822 }
823 if (writebuf)
824 {
825 /* Some sort of integer stored in r3. Use unpack_long since
826 that should handle any required sign extension. */
827 regcache_cooked_write_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
828 unpack_long (type, writebuf));
829 }
830 return RETURN_VALUE_REGISTER_CONVENTION;
831 }
832 /* OpenCL vectors < 16 bytes are returned as distinct
833 scalars in f1..f2 or r3..r10. */
834 if (TYPE_CODE (type) == TYPE_CODE_ARRAY
835 && TYPE_VECTOR (type)
836 && TYPE_LENGTH (type) < 16
837 && opencl_abi)
838 {
839 struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type));
840 int i, nelt = TYPE_LENGTH (type) / TYPE_LENGTH (eltype);
841
842 for (i = 0; i < nelt; i++)
843 {
844 int offset = i * TYPE_LENGTH (eltype);
845
846 if (TYPE_CODE (eltype) == TYPE_CODE_FLT)
847 {
848 int regnum = tdep->ppc_fp0_regnum + 1 + i;
849 gdb_byte regval[MAX_REGISTER_SIZE];
850 struct type *regtype = register_type (gdbarch, regnum);
851
852 if (writebuf != NULL)
853 {
854 convert_typed_floating (writebuf + offset, eltype,
855 regval, regtype);
856 regcache_cooked_write (regcache, regnum, regval);
857 }
858 if (readbuf != NULL)
859 {
860 regcache_cooked_read (regcache, regnum, regval);
861 convert_typed_floating (regval, regtype,
862 readbuf + offset, eltype);
863 }
864 }
865 else
866 {
867 int regnum = tdep->ppc_gp0_regnum + 3 + i;
868 ULONGEST regval;
869
870 if (writebuf != NULL)
871 {
872 regval = unpack_long (eltype, writebuf + offset);
873 regcache_cooked_write_unsigned (regcache, regnum, regval);
874 }
875 if (readbuf != NULL)
876 {
877 regcache_cooked_read_unsigned (regcache, regnum, &regval);
878 store_unsigned_integer (readbuf + offset,
879 TYPE_LENGTH (eltype), byte_order,
880 regval);
881 }
882 }
883 }
884
885 return RETURN_VALUE_REGISTER_CONVENTION;
886 }
887 /* OpenCL vectors >= 16 bytes are returned in v2..v9. */
888 if (TYPE_CODE (type) == TYPE_CODE_ARRAY
889 && TYPE_VECTOR (type)
890 && TYPE_LENGTH (type) >= 16
891 && opencl_abi)
892 {
893 int n_regs = TYPE_LENGTH (type) / 16;
894 int i;
895
896 for (i = 0; i < n_regs; i++)
897 {
898 int offset = i * 16;
899 int regnum = tdep->ppc_vr0_regnum + 2 + i;
900
901 if (writebuf != NULL)
902 regcache_cooked_write (regcache, regnum, writebuf + offset);
903 if (readbuf != NULL)
904 regcache_cooked_read (regcache, regnum, readbuf + offset);
905 }
906
907 return RETURN_VALUE_REGISTER_CONVENTION;
908 }
909 if (TYPE_LENGTH (type) == 16
910 && TYPE_CODE (type) == TYPE_CODE_ARRAY
911 && TYPE_VECTOR (type)
912 && tdep->vector_abi == POWERPC_VEC_ALTIVEC)
913 {
914 if (readbuf)
915 {
916 /* Altivec places the return value in "v2". */
917 regcache_cooked_read (regcache, tdep->ppc_vr0_regnum + 2, readbuf);
918 }
919 if (writebuf)
920 {
921 /* Altivec places the return value in "v2". */
922 regcache_cooked_write (regcache, tdep->ppc_vr0_regnum + 2, writebuf);
923 }
924 return RETURN_VALUE_REGISTER_CONVENTION;
925 }
926 if (TYPE_LENGTH (type) == 16
927 && TYPE_CODE (type) == TYPE_CODE_ARRAY
928 && TYPE_VECTOR (type)
929 && tdep->vector_abi == POWERPC_VEC_GENERIC)
930 {
931 /* GCC -maltivec -mabi=no-altivec returns vectors in r3/r4/r5/r6.
932 GCC without AltiVec returns them in memory, but it warns about
933 ABI risks in that case; we don't try to support it. */
934 if (readbuf)
935 {
936 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3,
937 readbuf + 0);
938 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 4,
939 readbuf + 4);
940 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 5,
941 readbuf + 8);
942 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 6,
943 readbuf + 12);
944 }
945 if (writebuf)
946 {
947 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3,
948 writebuf + 0);
949 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 4,
950 writebuf + 4);
951 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 5,
952 writebuf + 8);
953 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 6,
954 writebuf + 12);
955 }
956 return RETURN_VALUE_REGISTER_CONVENTION;
957 }
958 if (TYPE_LENGTH (type) == 8
959 && TYPE_CODE (type) == TYPE_CODE_ARRAY
960 && TYPE_VECTOR (type)
961 && tdep->vector_abi == POWERPC_VEC_SPE)
962 {
963 /* The e500 ABI places return values for the 64-bit DSP types
964 (__ev64_opaque__) in r3. However, in GDB-speak, ev3
965 corresponds to the entire r3 value for e500, whereas GDB's r3
966 only corresponds to the least significant 32-bits. So place
967 the 64-bit DSP type's value in ev3. */
968 if (readbuf)
969 regcache_cooked_read (regcache, tdep->ppc_ev0_regnum + 3, readbuf);
970 if (writebuf)
971 regcache_cooked_write (regcache, tdep->ppc_ev0_regnum + 3, writebuf);
972 return RETURN_VALUE_REGISTER_CONVENTION;
973 }
974 if (broken_gcc && TYPE_LENGTH (type) <= 8)
975 {
976 /* GCC screwed up for structures or unions whose size is less
977 than or equal to 8 bytes.. Instead of left-aligning, it
978 right-aligns the data into the buffer formed by r3, r4. */
979 gdb_byte regvals[MAX_REGISTER_SIZE * 2];
980 int len = TYPE_LENGTH (type);
981 int offset = (2 * tdep->wordsize - len) % tdep->wordsize;
982
983 if (readbuf)
984 {
985 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3,
986 regvals + 0 * tdep->wordsize);
987 if (len > tdep->wordsize)
988 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 4,
989 regvals + 1 * tdep->wordsize);
990 memcpy (readbuf, regvals + offset, len);
991 }
992 if (writebuf)
993 {
994 memset (regvals, 0, sizeof regvals);
995 memcpy (regvals + offset, writebuf, len);
996 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3,
997 regvals + 0 * tdep->wordsize);
998 if (len > tdep->wordsize)
999 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 4,
1000 regvals + 1 * tdep->wordsize);
1001 }
1002
1003 return RETURN_VALUE_REGISTER_CONVENTION;
1004 }
1005 if (TYPE_LENGTH (type) <= 8)
1006 {
1007 if (readbuf)
1008 {
1009 /* This matches SVr4 PPC, it does not match GCC. */
1010 /* The value is right-padded to 8 bytes and then loaded, as
1011 two "words", into r3/r4. */
1012 gdb_byte regvals[MAX_REGISTER_SIZE * 2];
1013 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3,
1014 regvals + 0 * tdep->wordsize);
1015 if (TYPE_LENGTH (type) > tdep->wordsize)
1016 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 4,
1017 regvals + 1 * tdep->wordsize);
1018 memcpy (readbuf, regvals, TYPE_LENGTH (type));
1019 }
1020 if (writebuf)
1021 {
1022 /* This matches SVr4 PPC, it does not match GCC. */
1023 /* The value is padded out to 8 bytes and then loaded, as
1024 two "words" into r3/r4. */
1025 gdb_byte regvals[MAX_REGISTER_SIZE * 2];
1026 memset (regvals, 0, sizeof regvals);
1027 memcpy (regvals, writebuf, TYPE_LENGTH (type));
1028 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3,
1029 regvals + 0 * tdep->wordsize);
1030 if (TYPE_LENGTH (type) > tdep->wordsize)
1031 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 4,
1032 regvals + 1 * tdep->wordsize);
1033 }
1034 return RETURN_VALUE_REGISTER_CONVENTION;
1035 }
1036 return RETURN_VALUE_STRUCT_CONVENTION;
1037 }
1038
1039 enum return_value_convention
1040 ppc_sysv_abi_return_value (struct gdbarch *gdbarch, struct type *func_type,
1041 struct type *valtype, struct regcache *regcache,
1042 gdb_byte *readbuf, const gdb_byte *writebuf)
1043 {
1044 return do_ppc_sysv_return_value (gdbarch, func_type, valtype, regcache,
1045 readbuf, writebuf, 0);
1046 }
1047
1048 enum return_value_convention
1049 ppc_sysv_abi_broken_return_value (struct gdbarch *gdbarch,
1050 struct type *func_type,
1051 struct type *valtype,
1052 struct regcache *regcache,
1053 gdb_byte *readbuf, const gdb_byte *writebuf)
1054 {
1055 return do_ppc_sysv_return_value (gdbarch, func_type, valtype, regcache,
1056 readbuf, writebuf, 1);
1057 }
1058
1059 /* The helper function for 64-bit SYSV push_dummy_call. Converts the
1060 function's code address back into the function's descriptor
1061 address.
1062
1063 Find a value for the TOC register. Every symbol should have both
1064 ".FN" and "FN" in the minimal symbol table. "FN" points at the
1065 FN's descriptor, while ".FN" points at the entry point (which
1066 matches FUNC_ADDR). Need to reverse from FUNC_ADDR back to the
1067 FN's descriptor address (while at the same time being careful to
1068 find "FN" in the same object file as ".FN"). */
1069
1070 static int
1071 convert_code_addr_to_desc_addr (CORE_ADDR code_addr, CORE_ADDR *desc_addr)
1072 {
1073 struct obj_section *dot_fn_section;
1074 struct minimal_symbol *dot_fn;
1075 struct minimal_symbol *fn;
1076 CORE_ADDR toc;
1077 /* Find the minimal symbol that corresponds to CODE_ADDR (should
1078 have a name of the form ".FN"). */
1079 dot_fn = lookup_minimal_symbol_by_pc (code_addr);
1080 if (dot_fn == NULL || SYMBOL_LINKAGE_NAME (dot_fn)[0] != '.')
1081 return 0;
1082 /* Get the section that contains CODE_ADDR. Need this for the
1083 "objfile" that it contains. */
1084 dot_fn_section = find_pc_section (code_addr);
1085 if (dot_fn_section == NULL || dot_fn_section->objfile == NULL)
1086 return 0;
1087 /* Now find the corresponding "FN" (dropping ".") minimal symbol's
1088 address. Only look for the minimal symbol in ".FN"'s object file
1089 - avoids problems when two object files (i.e., shared libraries)
1090 contain a minimal symbol with the same name. */
1091 fn = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (dot_fn) + 1, NULL,
1092 dot_fn_section->objfile);
1093 if (fn == NULL)
1094 return 0;
1095 /* Found a descriptor. */
1096 (*desc_addr) = SYMBOL_VALUE_ADDRESS (fn);
1097 return 1;
1098 }
1099
1100 /* Pass the arguments in either registers, or in the stack. Using the
1101 ppc 64 bit SysV ABI.
1102
1103 This implements a dumbed down version of the ABI. It always writes
1104 values to memory, GPR and FPR, even when not necessary. Doing this
1105 greatly simplifies the logic. */
1106
1107 CORE_ADDR
1108 ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch,
1109 struct value *function,
1110 struct regcache *regcache, CORE_ADDR bp_addr,
1111 int nargs, struct value **args, CORE_ADDR sp,
1112 int struct_return, CORE_ADDR struct_addr)
1113 {
1114 CORE_ADDR func_addr = find_function_addr (function, NULL);
1115 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1116 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1117 struct type *ftype;
1118 int opencl_abi = 0;
1119 ULONGEST back_chain;
1120 /* See for-loop comment below. */
1121 int write_pass;
1122 /* Size of the general parameter region, the final value is computed
1123 in the for-loop below. */
1124 LONGEST gparam_size = 0;
1125 /* Kevin writes ... I don't mind seeing tdep->wordsize used in the
1126 calls to align_up(), align_down(), etc. because this makes it
1127 easier to reuse this code (in a copy/paste sense) in the future,
1128 but it is a 64-bit ABI and asserting that the wordsize is 8 bytes
1129 at some point makes it easier to verify that this function is
1130 correct without having to do a non-local analysis to figure out
1131 the possible values of tdep->wordsize. */
1132 gdb_assert (tdep->wordsize == 8);
1133
1134 /* This function exists to support a calling convention that
1135 requires floating-point registers. It shouldn't be used on
1136 processors that lack them. */
1137 gdb_assert (ppc_floating_point_unit_p (gdbarch));
1138
1139 /* By this stage in the proceedings, SP has been decremented by "red
1140 zone size" + "struct return size". Fetch the stack-pointer from
1141 before this and use that as the BACK_CHAIN. */
1142 regcache_cooked_read_unsigned (regcache, gdbarch_sp_regnum (gdbarch),
1143 &back_chain);
1144
1145 ftype = check_typedef (value_type (function));
1146 if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
1147 ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
1148 if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
1149 && TYPE_CALLING_CONVENTION (ftype) == DW_CC_GDB_IBM_OpenCL)
1150 opencl_abi = 1;
1151
1152 /* Go through the argument list twice.
1153
1154 Pass 1: Compute the function call's stack space and register
1155 requirements.
1156
1157 Pass 2: Replay the same computation but this time also write the
1158 values out to the target. */
1159
1160 for (write_pass = 0; write_pass < 2; write_pass++)
1161 {
1162 int argno;
1163 /* Next available floating point register for float and double
1164 arguments. */
1165 int freg = 1;
1166 /* Next available general register for non-vector (but possibly
1167 float) arguments. */
1168 int greg = 3;
1169 /* Next available vector register for vector arguments. */
1170 int vreg = 2;
1171 /* The address, at which the next general purpose parameter
1172 (integer, struct, float, vector, ...) should be saved. */
1173 CORE_ADDR gparam;
1174
1175 if (!write_pass)
1176 {
1177 /* During the first pass, GPARAM is more like an offset
1178 (start address zero) than an address. That way it
1179 accumulates the total stack space required. */
1180 gparam = 0;
1181 }
1182 else
1183 {
1184 /* Decrement the stack pointer making space for the on-stack
1185 stack parameters. Set gparam to that region. */
1186 gparam = align_down (sp - gparam_size, 16);
1187 /* Add in space for the TOC, link editor double word,
1188 compiler double word, LR save area, CR save area. */
1189 sp = align_down (gparam - 48, 16);
1190 }
1191
1192 /* If the function is returning a `struct', then there is an
1193 extra hidden parameter (which will be passed in r3)
1194 containing the address of that struct.. In that case we
1195 should advance one word and start from r4 register to copy
1196 parameters. This also consumes one on-stack parameter slot. */
1197 if (struct_return)
1198 {
1199 if (write_pass)
1200 regcache_cooked_write_signed (regcache,
1201 tdep->ppc_gp0_regnum + greg,
1202 struct_addr);
1203 greg++;
1204 gparam = align_up (gparam + tdep->wordsize, tdep->wordsize);
1205 }
1206
1207 for (argno = 0; argno < nargs; argno++)
1208 {
1209 struct value *arg = args[argno];
1210 struct type *type = check_typedef (value_type (arg));
1211 const bfd_byte *val = value_contents (arg);
1212
1213 if (TYPE_CODE (type) == TYPE_CODE_FLT && TYPE_LENGTH (type) <= 8)
1214 {
1215 /* Floats and Doubles go in f1 .. f13. They also
1216 consume a left aligned GREG,, and can end up in
1217 memory. */
1218 if (write_pass)
1219 {
1220 gdb_byte regval[MAX_REGISTER_SIZE];
1221 const gdb_byte *p;
1222
1223 /* Version 1.7 of the 64-bit PowerPC ELF ABI says:
1224
1225 "Single precision floating point values are mapped to
1226 the first word in a single doubleword."
1227
1228 And version 1.9 says:
1229
1230 "Single precision floating point values are mapped to
1231 the second word in a single doubleword."
1232
1233 GDB then writes single precision floating point values
1234 at both words in a doubleword, to support both ABIs. */
1235 if (TYPE_LENGTH (type) == 4)
1236 {
1237 memcpy (regval, val, 4);
1238 memcpy (regval + 4, val, 4);
1239 p = regval;
1240 }
1241 else
1242 p = val;
1243
1244 /* Write value in the stack's parameter save area. */
1245 write_memory (gparam, p, 8);
1246
1247 if (freg <= 13)
1248 {
1249 struct type *regtype
1250 = register_type (gdbarch, tdep->ppc_fp0_regnum);
1251
1252 convert_typed_floating (val, type, regval, regtype);
1253 regcache_cooked_write (regcache,
1254 tdep->ppc_fp0_regnum + freg,
1255 regval);
1256 }
1257 if (greg <= 10)
1258 regcache_cooked_write (regcache,
1259 tdep->ppc_gp0_regnum + greg,
1260 regval);
1261 }
1262
1263 freg++;
1264 greg++;
1265 /* Always consume parameter stack space. */
1266 gparam = align_up (gparam + 8, tdep->wordsize);
1267 }
1268 else if (TYPE_CODE (type) == TYPE_CODE_FLT
1269 && TYPE_LENGTH (type) == 16
1270 && (gdbarch_long_double_format (gdbarch)
1271 == floatformats_ibm_long_double))
1272 {
1273 /* IBM long double stored in two doublewords of the
1274 parameter save area and corresponding registers. */
1275 if (write_pass)
1276 {
1277 if (!tdep->soft_float && freg <= 13)
1278 {
1279 regcache_cooked_write (regcache,
1280 tdep->ppc_fp0_regnum + freg,
1281 val);
1282 if (freg <= 12)
1283 regcache_cooked_write (regcache,
1284 tdep->ppc_fp0_regnum + freg + 1,
1285 val + 8);
1286 }
1287 if (greg <= 10)
1288 {
1289 regcache_cooked_write (regcache,
1290 tdep->ppc_gp0_regnum + greg,
1291 val);
1292 if (greg <= 9)
1293 regcache_cooked_write (regcache,
1294 tdep->ppc_gp0_regnum + greg + 1,
1295 val + 8);
1296 }
1297 write_memory (gparam, val, TYPE_LENGTH (type));
1298 }
1299 freg += 2;
1300 greg += 2;
1301 gparam = align_up (gparam + TYPE_LENGTH (type), tdep->wordsize);
1302 }
1303 else if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT
1304 && TYPE_LENGTH (type) <= 8)
1305 {
1306 /* 32-bit and 64-bit decimal floats go in f1 .. f13. They can
1307 end up in memory. */
1308 if (write_pass)
1309 {
1310 gdb_byte regval[MAX_REGISTER_SIZE];
1311 const gdb_byte *p;
1312
1313 /* 32-bit decimal floats are right aligned in the
1314 doubleword. */
1315 if (TYPE_LENGTH (type) == 4)
1316 {
1317 memcpy (regval + 4, val, 4);
1318 p = regval;
1319 }
1320 else
1321 p = val;
1322
1323 /* Write value in the stack's parameter save area. */
1324 write_memory (gparam, p, 8);
1325
1326 if (freg <= 13)
1327 regcache_cooked_write (regcache,
1328 tdep->ppc_fp0_regnum + freg, p);
1329 }
1330
1331 freg++;
1332 greg++;
1333 /* Always consume parameter stack space. */
1334 gparam = align_up (gparam + 8, tdep->wordsize);
1335 }
1336 else if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT &&
1337 TYPE_LENGTH (type) == 16)
1338 {
1339 /* 128-bit decimal floats go in f2 .. f12, always in even/odd
1340 pairs. They can end up in memory, using two doublewords. */
1341 if (write_pass)
1342 {
1343 if (freg <= 12)
1344 {
1345 /* Make sure freg is even. */
1346 freg += freg & 1;
1347 regcache_cooked_write (regcache,
1348 tdep->ppc_fp0_regnum + freg, val);
1349 regcache_cooked_write (regcache,
1350 tdep->ppc_fp0_regnum + freg + 1, val + 8);
1351 }
1352
1353 write_memory (gparam, val, TYPE_LENGTH (type));
1354 }
1355
1356 freg += 2;
1357 greg += 2;
1358 gparam = align_up (gparam + TYPE_LENGTH (type), tdep->wordsize);
1359 }
1360 else if (TYPE_LENGTH (type) < 16
1361 && TYPE_CODE (type) == TYPE_CODE_ARRAY
1362 && TYPE_VECTOR (type)
1363 && opencl_abi)
1364 {
1365 /* OpenCL vectors shorter than 16 bytes are passed as if
1366 a series of independent scalars. */
1367 struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type));
1368 int i, nelt = TYPE_LENGTH (type) / TYPE_LENGTH (eltype);
1369
1370 for (i = 0; i < nelt; i++)
1371 {
1372 const gdb_byte *elval = val + i * TYPE_LENGTH (eltype);
1373
1374 if (TYPE_CODE (eltype) == TYPE_CODE_FLT)
1375 {
1376 if (write_pass)
1377 {
1378 gdb_byte regval[MAX_REGISTER_SIZE];
1379 const gdb_byte *p;
1380
1381 if (TYPE_LENGTH (eltype) == 4)
1382 {
1383 memcpy (regval, elval, 4);
1384 memcpy (regval + 4, elval, 4);
1385 p = regval;
1386 }
1387 else
1388 p = elval;
1389
1390 write_memory (gparam, p, 8);
1391
1392 if (freg <= 13)
1393 {
1394 int regnum = tdep->ppc_fp0_regnum + freg;
1395 struct type *regtype
1396 = register_type (gdbarch, regnum);
1397
1398 convert_typed_floating (elval, eltype,
1399 regval, regtype);
1400 regcache_cooked_write (regcache, regnum, regval);
1401 }
1402
1403 if (greg <= 10)
1404 regcache_cooked_write (regcache,
1405 tdep->ppc_gp0_regnum + greg,
1406 regval);
1407 }
1408
1409 freg++;
1410 greg++;
1411 gparam = align_up (gparam + 8, tdep->wordsize);
1412 }
1413 else
1414 {
1415 if (write_pass)
1416 {
1417 ULONGEST word = unpack_long (eltype, elval);
1418 if (greg <= 10)
1419 regcache_cooked_write_unsigned
1420 (regcache, tdep->ppc_gp0_regnum + greg, word);
1421
1422 write_memory_unsigned_integer
1423 (gparam, tdep->wordsize, byte_order, word);
1424 }
1425
1426 greg++;
1427 gparam = align_up (gparam + TYPE_LENGTH (eltype),
1428 tdep->wordsize);
1429 }
1430 }
1431 }
1432 else if (TYPE_LENGTH (type) >= 16
1433 && TYPE_CODE (type) == TYPE_CODE_ARRAY
1434 && TYPE_VECTOR (type)
1435 && opencl_abi)
1436 {
1437 /* OpenCL vectors 16 bytes or longer are passed as if
1438 a series of AltiVec vectors. */
1439 int i;
1440
1441 for (i = 0; i < TYPE_LENGTH (type) / 16; i++)
1442 {
1443 const gdb_byte *elval = val + i * 16;
1444
1445 gparam = align_up (gparam, 16);
1446 greg += greg & 1;
1447
1448 if (write_pass)
1449 {
1450 if (vreg <= 13)
1451 regcache_cooked_write (regcache,
1452 tdep->ppc_vr0_regnum + vreg,
1453 elval);
1454
1455 write_memory (gparam, elval, 16);
1456 }
1457
1458 greg += 2;
1459 vreg++;
1460 gparam += 16;
1461 }
1462 }
1463 else if (TYPE_LENGTH (type) == 16 && TYPE_VECTOR (type)
1464 && TYPE_CODE (type) == TYPE_CODE_ARRAY
1465 && tdep->ppc_vr0_regnum >= 0)
1466 {
1467 /* In the Altivec ABI, vectors go in the vector registers
1468 v2 .. v13, as well as the parameter area -- always at
1469 16-byte aligned addresses. */
1470
1471 gparam = align_up (gparam, 16);
1472 greg += greg & 1;
1473
1474 if (write_pass)
1475 {
1476 if (vreg <= 13)
1477 regcache_cooked_write (regcache,
1478 tdep->ppc_vr0_regnum + vreg, val);
1479
1480 write_memory (gparam, val, TYPE_LENGTH (type));
1481 }
1482
1483 greg += 2;
1484 vreg++;
1485 gparam += 16;
1486 }
1487 else if ((TYPE_CODE (type) == TYPE_CODE_INT
1488 || TYPE_CODE (type) == TYPE_CODE_ENUM
1489 || TYPE_CODE (type) == TYPE_CODE_BOOL
1490 || TYPE_CODE (type) == TYPE_CODE_CHAR
1491 || TYPE_CODE (type) == TYPE_CODE_PTR
1492 || TYPE_CODE (type) == TYPE_CODE_REF)
1493 && TYPE_LENGTH (type) <= 8)
1494 {
1495 /* Scalars and Pointers get sign[un]extended and go in
1496 gpr3 .. gpr10. They can also end up in memory. */
1497 if (write_pass)
1498 {
1499 /* Sign extend the value, then store it unsigned. */
1500 ULONGEST word = unpack_long (type, val);
1501 /* Convert any function code addresses into
1502 descriptors. */
1503 if (TYPE_CODE (type) == TYPE_CODE_PTR
1504 || TYPE_CODE (type) == TYPE_CODE_REF)
1505 {
1506 struct type *target_type;
1507 target_type = check_typedef (TYPE_TARGET_TYPE (type));
1508
1509 if (TYPE_CODE (target_type) == TYPE_CODE_FUNC
1510 || TYPE_CODE (target_type) == TYPE_CODE_METHOD)
1511 {
1512 CORE_ADDR desc = word;
1513 convert_code_addr_to_desc_addr (word, &desc);
1514 word = desc;
1515 }
1516 }
1517 if (greg <= 10)
1518 regcache_cooked_write_unsigned (regcache,
1519 tdep->ppc_gp0_regnum +
1520 greg, word);
1521 write_memory_unsigned_integer (gparam, tdep->wordsize,
1522 byte_order, word);
1523 }
1524 greg++;
1525 gparam = align_up (gparam + TYPE_LENGTH (type), tdep->wordsize);
1526 }
1527 else
1528 {
1529 int byte;
1530 for (byte = 0; byte < TYPE_LENGTH (type);
1531 byte += tdep->wordsize)
1532 {
1533 if (write_pass && greg <= 10)
1534 {
1535 gdb_byte regval[MAX_REGISTER_SIZE];
1536 int len = TYPE_LENGTH (type) - byte;
1537 if (len > tdep->wordsize)
1538 len = tdep->wordsize;
1539 memset (regval, 0, sizeof regval);
1540 /* The ABI (version 1.9) specifies that values
1541 smaller than one doubleword are right-aligned
1542 and those larger are left-aligned. GCC
1543 versions before 3.4 implemented this
1544 incorrectly; see
1545 <http://gcc.gnu.org/gcc-3.4/powerpc-abi.html>. */
1546 if (byte == 0)
1547 memcpy (regval + tdep->wordsize - len,
1548 val + byte, len);
1549 else
1550 memcpy (regval, val + byte, len);
1551 regcache_cooked_write (regcache, greg, regval);
1552 }
1553 greg++;
1554 }
1555 if (write_pass)
1556 {
1557 /* WARNING: cagney/2003-09-21: Strictly speaking, this
1558 isn't necessary, unfortunately, GCC appears to get
1559 "struct convention" parameter passing wrong putting
1560 odd sized structures in memory instead of in a
1561 register. Work around this by always writing the
1562 value to memory. Fortunately, doing this
1563 simplifies the code. */
1564 int len = TYPE_LENGTH (type);
1565 if (len < tdep->wordsize)
1566 write_memory (gparam + tdep->wordsize - len, val, len);
1567 else
1568 write_memory (gparam, val, len);
1569 }
1570 if (freg <= 13
1571 && TYPE_CODE (type) == TYPE_CODE_STRUCT
1572 && TYPE_NFIELDS (type) == 1
1573 && TYPE_LENGTH (type) <= 16)
1574 {
1575 /* The ABI (version 1.9) specifies that structs
1576 containing a single floating-point value, at any
1577 level of nesting of single-member structs, are
1578 passed in floating-point registers. */
1579 while (TYPE_CODE (type) == TYPE_CODE_STRUCT
1580 && TYPE_NFIELDS (type) == 1)
1581 type = check_typedef (TYPE_FIELD_TYPE (type, 0));
1582 if (TYPE_CODE (type) == TYPE_CODE_FLT)
1583 {
1584 if (TYPE_LENGTH (type) <= 8)
1585 {
1586 if (write_pass)
1587 {
1588 gdb_byte regval[MAX_REGISTER_SIZE];
1589 struct type *regtype
1590 = register_type (gdbarch,
1591 tdep->ppc_fp0_regnum);
1592 convert_typed_floating (val, type, regval,
1593 regtype);
1594 regcache_cooked_write (regcache,
1595 (tdep->ppc_fp0_regnum
1596 + freg),
1597 regval);
1598 }
1599 freg++;
1600 }
1601 else if (TYPE_LENGTH (type) == 16
1602 && (gdbarch_long_double_format (gdbarch)
1603 == floatformats_ibm_long_double))
1604 {
1605 if (write_pass)
1606 {
1607 regcache_cooked_write (regcache,
1608 (tdep->ppc_fp0_regnum
1609 + freg),
1610 val);
1611 if (freg <= 12)
1612 regcache_cooked_write (regcache,
1613 (tdep->ppc_fp0_regnum
1614 + freg + 1),
1615 val + 8);
1616 }
1617 freg += 2;
1618 }
1619 }
1620 }
1621 /* Always consume parameter stack space. */
1622 gparam = align_up (gparam + TYPE_LENGTH (type), tdep->wordsize);
1623 }
1624 }
1625
1626 if (!write_pass)
1627 {
1628 /* Save the true region sizes ready for the second pass.
1629 Make certain that the general parameter save area is at
1630 least the minimum 8 registers (or doublewords) in size. */
1631 if (greg < 8)
1632 gparam_size = 8 * tdep->wordsize;
1633 else
1634 gparam_size = gparam;
1635 }
1636 }
1637
1638 /* Update %sp. */
1639 regcache_cooked_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp);
1640
1641 /* Write the backchain (it occupies WORDSIZED bytes). */
1642 write_memory_signed_integer (sp, tdep->wordsize, byte_order, back_chain);
1643
1644 /* Point the inferior function call's return address at the dummy's
1645 breakpoint. */
1646 regcache_cooked_write_signed (regcache, tdep->ppc_lr_regnum, bp_addr);
1647
1648 /* Use the func_addr to find the descriptor, and use that to find
1649 the TOC. If we're calling via a function pointer, the pointer
1650 itself identifies the descriptor. */
1651 {
1652 struct type *ftype = check_typedef (value_type (function));
1653 CORE_ADDR desc_addr = value_as_address (function);
1654
1655 if (TYPE_CODE (ftype) == TYPE_CODE_PTR
1656 || convert_code_addr_to_desc_addr (func_addr, &desc_addr))
1657 {
1658 /* The TOC is the second double word in the descriptor. */
1659 CORE_ADDR toc =
1660 read_memory_unsigned_integer (desc_addr + tdep->wordsize,
1661 tdep->wordsize, byte_order);
1662 regcache_cooked_write_unsigned (regcache,
1663 tdep->ppc_gp0_regnum + 2, toc);
1664 }
1665 }
1666
1667 return sp;
1668 }
1669
1670
1671 /* The 64 bit ABI return value convention.
1672
1673 Return non-zero if the return-value is stored in a register, return
1674 0 if the return-value is instead stored on the stack (a.k.a.,
1675 struct return convention).
1676
1677 For a return-value stored in a register: when WRITEBUF is non-NULL,
1678 copy the buffer to the corresponding register return-value location
1679 location; when READBUF is non-NULL, fill the buffer from the
1680 corresponding register return-value location. */
1681 enum return_value_convention
1682 ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct type *func_type,
1683 struct type *valtype, struct regcache *regcache,
1684 gdb_byte *readbuf, const gdb_byte *writebuf)
1685 {
1686 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1687 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1688 int opencl_abi = 0;
1689
1690 if (func_type
1691 && TYPE_CALLING_CONVENTION (func_type) == DW_CC_GDB_IBM_OpenCL)
1692 opencl_abi = 1;
1693
1694 /* This function exists to support a calling convention that
1695 requires floating-point registers. It shouldn't be used on
1696 processors that lack them. */
1697 gdb_assert (ppc_floating_point_unit_p (gdbarch));
1698
1699 /* Floats and doubles in F1. */
1700 if (TYPE_CODE (valtype) == TYPE_CODE_FLT && TYPE_LENGTH (valtype) <= 8)
1701 {
1702 gdb_byte regval[MAX_REGISTER_SIZE];
1703 struct type *regtype = register_type (gdbarch, tdep->ppc_fp0_regnum);
1704 if (writebuf != NULL)
1705 {
1706 convert_typed_floating (writebuf, valtype, regval, regtype);
1707 regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1, regval);
1708 }
1709 if (readbuf != NULL)
1710 {
1711 regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1, regval);
1712 convert_typed_floating (regval, regtype, readbuf, valtype);
1713 }
1714 return RETURN_VALUE_REGISTER_CONVENTION;
1715 }
1716 if (TYPE_CODE (valtype) == TYPE_CODE_DECFLOAT)
1717 return get_decimal_float_return_value (gdbarch, valtype, regcache, readbuf,
1718 writebuf);
1719 /* Integers in r3. */
1720 if ((TYPE_CODE (valtype) == TYPE_CODE_INT
1721 || TYPE_CODE (valtype) == TYPE_CODE_ENUM
1722 || TYPE_CODE (valtype) == TYPE_CODE_CHAR
1723 || TYPE_CODE (valtype) == TYPE_CODE_BOOL)
1724 && TYPE_LENGTH (valtype) <= 8)
1725 {
1726 if (writebuf != NULL)
1727 {
1728 /* Be careful to sign extend the value. */
1729 regcache_cooked_write_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
1730 unpack_long (valtype, writebuf));
1731 }
1732 if (readbuf != NULL)
1733 {
1734 /* Extract the integer from r3. Since this is truncating the
1735 value, there isn't a sign extension problem. */
1736 ULONGEST regval;
1737 regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
1738 &regval);
1739 store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), byte_order,
1740 regval);
1741 }
1742 return RETURN_VALUE_REGISTER_CONVENTION;
1743 }
1744 /* All pointers live in r3. */
1745 if (TYPE_CODE (valtype) == TYPE_CODE_PTR
1746 || TYPE_CODE (valtype) == TYPE_CODE_REF)
1747 {
1748 /* All pointers live in r3. */
1749 if (writebuf != NULL)
1750 regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3, writebuf);
1751 if (readbuf != NULL)
1752 regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3, readbuf);
1753 return RETURN_VALUE_REGISTER_CONVENTION;
1754 }
1755 /* OpenCL vectors < 16 bytes are returned as distinct
1756 scalars in f1..f2 or r3..r10. */
1757 if (TYPE_CODE (valtype) == TYPE_CODE_ARRAY
1758 && TYPE_VECTOR (valtype)
1759 && TYPE_LENGTH (valtype) < 16
1760 && opencl_abi)
1761 {
1762 struct type *eltype = check_typedef (TYPE_TARGET_TYPE (valtype));
1763 int i, nelt = TYPE_LENGTH (valtype) / TYPE_LENGTH (eltype);
1764
1765 for (i = 0; i < nelt; i++)
1766 {
1767 int offset = i * TYPE_LENGTH (eltype);
1768
1769 if (TYPE_CODE (eltype) == TYPE_CODE_FLT)
1770 {
1771 int regnum = tdep->ppc_fp0_regnum + 1 + i;
1772 gdb_byte regval[MAX_REGISTER_SIZE];
1773 struct type *regtype = register_type (gdbarch, regnum);
1774
1775 if (writebuf != NULL)
1776 {
1777 convert_typed_floating (writebuf + offset, eltype,
1778 regval, regtype);
1779 regcache_cooked_write (regcache, regnum, regval);
1780 }
1781 if (readbuf != NULL)
1782 {
1783 regcache_cooked_read (regcache, regnum, regval);
1784 convert_typed_floating (regval, regtype,
1785 readbuf + offset, eltype);
1786 }
1787 }
1788 else
1789 {
1790 int regnum = tdep->ppc_gp0_regnum + 3 + i;
1791 ULONGEST regval;
1792
1793 if (writebuf != NULL)
1794 {
1795 regval = unpack_long (eltype, writebuf + offset);
1796 regcache_cooked_write_unsigned (regcache, regnum, regval);
1797 }
1798 if (readbuf != NULL)
1799 {
1800 regcache_cooked_read_unsigned (regcache, regnum, &regval);
1801 store_unsigned_integer (readbuf + offset,
1802 TYPE_LENGTH (eltype), byte_order,
1803 regval);
1804 }
1805 }
1806 }
1807
1808 return RETURN_VALUE_REGISTER_CONVENTION;
1809 }
1810 /* OpenCL vectors >= 16 bytes are returned in v2..v9. */
1811 if (TYPE_CODE (valtype) == TYPE_CODE_ARRAY
1812 && TYPE_VECTOR (valtype)
1813 && TYPE_LENGTH (valtype) >= 16
1814 && opencl_abi)
1815 {
1816 int n_regs = TYPE_LENGTH (valtype) / 16;
1817 int i;
1818
1819 for (i = 0; i < n_regs; i++)
1820 {
1821 int offset = i * 16;
1822 int regnum = tdep->ppc_vr0_regnum + 2 + i;
1823
1824 if (writebuf != NULL)
1825 regcache_cooked_write (regcache, regnum, writebuf + offset);
1826 if (readbuf != NULL)
1827 regcache_cooked_read (regcache, regnum, readbuf + offset);
1828 }
1829
1830 return RETURN_VALUE_REGISTER_CONVENTION;
1831 }
1832 /* Array type has more than one use. */
1833 if (TYPE_CODE (valtype) == TYPE_CODE_ARRAY)
1834 {
1835 /* Small character arrays are returned, right justified, in r3. */
1836 if (TYPE_LENGTH (valtype) <= 8
1837 && TYPE_CODE (TYPE_TARGET_TYPE (valtype)) == TYPE_CODE_INT
1838 && TYPE_LENGTH (TYPE_TARGET_TYPE (valtype)) == 1)
1839 {
1840 int offset = (register_size (gdbarch, tdep->ppc_gp0_regnum + 3)
1841 - TYPE_LENGTH (valtype));
1842 if (writebuf != NULL)
1843 regcache_cooked_write_part (regcache, tdep->ppc_gp0_regnum + 3,
1844 offset, TYPE_LENGTH (valtype), writebuf);
1845 if (readbuf != NULL)
1846 regcache_cooked_read_part (regcache, tdep->ppc_gp0_regnum + 3,
1847 offset, TYPE_LENGTH (valtype), readbuf);
1848 return RETURN_VALUE_REGISTER_CONVENTION;
1849 }
1850 /* A VMX vector is returned in v2. */
1851 if (TYPE_CODE (valtype) == TYPE_CODE_ARRAY
1852 && TYPE_VECTOR (valtype) && tdep->ppc_vr0_regnum >= 0)
1853 {
1854 if (readbuf)
1855 regcache_cooked_read (regcache, tdep->ppc_vr0_regnum + 2, readbuf);
1856 if (writebuf)
1857 regcache_cooked_write (regcache, tdep->ppc_vr0_regnum + 2,
1858 writebuf);
1859 return RETURN_VALUE_REGISTER_CONVENTION;
1860 }
1861 }
1862 /* Big floating point values get stored in adjacent floating
1863 point registers, starting with F1. */
1864 if (TYPE_CODE (valtype) == TYPE_CODE_FLT
1865 && (TYPE_LENGTH (valtype) == 16 || TYPE_LENGTH (valtype) == 32))
1866 {
1867 if (writebuf || readbuf != NULL)
1868 {
1869 int i;
1870 for (i = 0; i < TYPE_LENGTH (valtype) / 8; i++)
1871 {
1872 if (writebuf != NULL)
1873 regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1 + i,
1874 (const bfd_byte *) writebuf + i * 8);
1875 if (readbuf != NULL)
1876 regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1 + i,
1877 (bfd_byte *) readbuf + i * 8);
1878 }
1879 }
1880 return RETURN_VALUE_REGISTER_CONVENTION;
1881 }
1882 /* Complex values get returned in f1:f2, need to convert. */
1883 if (TYPE_CODE (valtype) == TYPE_CODE_COMPLEX
1884 && (TYPE_LENGTH (valtype) == 8 || TYPE_LENGTH (valtype) == 16))
1885 {
1886 if (regcache != NULL)
1887 {
1888 int i;
1889 for (i = 0; i < 2; i++)
1890 {
1891 gdb_byte regval[MAX_REGISTER_SIZE];
1892 struct type *regtype =
1893 register_type (gdbarch, tdep->ppc_fp0_regnum);
1894 if (writebuf != NULL)
1895 {
1896 convert_typed_floating ((const bfd_byte *) writebuf +
1897 i * (TYPE_LENGTH (valtype) / 2),
1898 valtype, regval, regtype);
1899 regcache_cooked_write (regcache,
1900 tdep->ppc_fp0_regnum + 1 + i,
1901 regval);
1902 }
1903 if (readbuf != NULL)
1904 {
1905 regcache_cooked_read (regcache,
1906 tdep->ppc_fp0_regnum + 1 + i,
1907 regval);
1908 convert_typed_floating (regval, regtype,
1909 (bfd_byte *) readbuf +
1910 i * (TYPE_LENGTH (valtype) / 2),
1911 valtype);
1912 }
1913 }
1914 }
1915 return RETURN_VALUE_REGISTER_CONVENTION;
1916 }
1917 /* Big complex values get stored in f1:f4. */
1918 if (TYPE_CODE (valtype) == TYPE_CODE_COMPLEX && TYPE_LENGTH (valtype) == 32)
1919 {
1920 if (regcache != NULL)
1921 {
1922 int i;
1923 for (i = 0; i < 4; i++)
1924 {
1925 if (writebuf != NULL)
1926 regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1 + i,
1927 (const bfd_byte *) writebuf + i * 8);
1928 if (readbuf != NULL)
1929 regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1 + i,
1930 (bfd_byte *) readbuf + i * 8);
1931 }
1932 }
1933 return RETURN_VALUE_REGISTER_CONVENTION;
1934 }
1935 return RETURN_VALUE_STRUCT_CONVENTION;
1936 }
1937
This page took 0.066978 seconds and 5 git commands to generate.