1 /* Target-dependent code for UltraSPARC.
3 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include "arch-utils.h"
23 #include "dwarf2-frame.h"
24 #include "floatformat.h"
26 #include "frame-base.h"
27 #include "frame-unwind.h"
38 #include "gdb_assert.h"
39 #include "gdb_string.h"
41 #include "sparc64-tdep.h"
43 /* This file implements the The SPARC 64-bit ABI as defined by the
44 section "Low-Level System Information" of the SPARC Compliance
45 Definition (SCD) 2.4.1, which is the 64-bit System V psABI for
48 /* Please use the sparc32_-prefix for 32-bit specific code, the
49 sparc64_-prefix for 64-bit specific code and the sparc_-prefix for
50 code can handle both. */
52 /* The functions on this page are intended to be used to classify
53 function arguments. */
55 /* Check whether TYPE is "Integral or Pointer". */
58 sparc64_integral_or_pointer_p (const struct type
*type
)
60 switch (TYPE_CODE (type
))
68 int len
= TYPE_LENGTH (type
);
69 gdb_assert (len
== 1 || len
== 2 || len
== 4 || len
== 8);
75 int len
= TYPE_LENGTH (type
);
76 gdb_assert (len
== 8);
86 /* Check whether TYPE is "Floating". */
89 sparc64_floating_p (const struct type
*type
)
91 switch (TYPE_CODE (type
))
95 int len
= TYPE_LENGTH (type
);
96 gdb_assert (len
== 4 || len
== 8 || len
== 16);
106 /* Check whether TYPE is "Structure or Union". */
109 sparc64_structure_or_union_p (const struct type
*type
)
111 switch (TYPE_CODE (type
))
113 case TYPE_CODE_STRUCT
:
114 case TYPE_CODE_UNION
:
124 /* Construct types for ISA-specific registers. */
127 sparc64_pstate_type (struct gdbarch
*gdbarch
)
129 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
131 if (!tdep
->sparc64_pstate_type
)
135 type
= init_flags_type ("builtin_type_sparc64_pstate", 8);
136 append_flags_type_flag (type
, 0, "AG");
137 append_flags_type_flag (type
, 1, "IE");
138 append_flags_type_flag (type
, 2, "PRIV");
139 append_flags_type_flag (type
, 3, "AM");
140 append_flags_type_flag (type
, 4, "PEF");
141 append_flags_type_flag (type
, 5, "RED");
142 append_flags_type_flag (type
, 8, "TLE");
143 append_flags_type_flag (type
, 9, "CLE");
144 append_flags_type_flag (type
, 10, "PID0");
145 append_flags_type_flag (type
, 11, "PID1");
147 tdep
->sparc64_pstate_type
= type
;
150 return tdep
->sparc64_pstate_type
;
154 sparc64_fsr_type (struct gdbarch
*gdbarch
)
156 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
158 if (!tdep
->sparc64_fsr_type
)
162 type
= init_flags_type ("builtin_type_sparc64_fsr", 8);
163 append_flags_type_flag (type
, 0, "NXA");
164 append_flags_type_flag (type
, 1, "DZA");
165 append_flags_type_flag (type
, 2, "UFA");
166 append_flags_type_flag (type
, 3, "OFA");
167 append_flags_type_flag (type
, 4, "NVA");
168 append_flags_type_flag (type
, 5, "NXC");
169 append_flags_type_flag (type
, 6, "DZC");
170 append_flags_type_flag (type
, 7, "UFC");
171 append_flags_type_flag (type
, 8, "OFC");
172 append_flags_type_flag (type
, 9, "NVC");
173 append_flags_type_flag (type
, 22, "NS");
174 append_flags_type_flag (type
, 23, "NXM");
175 append_flags_type_flag (type
, 24, "DZM");
176 append_flags_type_flag (type
, 25, "UFM");
177 append_flags_type_flag (type
, 26, "OFM");
178 append_flags_type_flag (type
, 27, "NVM");
180 tdep
->sparc64_fsr_type
= type
;
183 return tdep
->sparc64_fsr_type
;
187 sparc64_fprs_type (struct gdbarch
*gdbarch
)
189 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
191 if (!tdep
->sparc64_fprs_type
)
195 type
= init_flags_type ("builtin_type_sparc64_fprs", 8);
196 append_flags_type_flag (type
, 0, "DL");
197 append_flags_type_flag (type
, 1, "DU");
198 append_flags_type_flag (type
, 2, "FEF");
200 tdep
->sparc64_fprs_type
= type
;
203 return tdep
->sparc64_fprs_type
;
207 /* Register information. */
209 static const char *sparc64_register_names
[] =
211 "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
212 "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7",
213 "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
214 "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7",
216 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
217 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
218 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
219 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
220 "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46",
221 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62",
225 /* FIXME: Give "state" a name until we start using register groups. */
232 /* Total number of registers. */
233 #define SPARC64_NUM_REGS ARRAY_SIZE (sparc64_register_names)
235 /* We provide the aliases %d0..%d62 and %q0..%q60 for the floating
236 registers as "psuedo" registers. */
238 static const char *sparc64_pseudo_register_names
[] =
240 "cwp", "pstate", "asi", "ccr",
242 "d0", "d2", "d4", "d6", "d8", "d10", "d12", "d14",
243 "d16", "d18", "d20", "d22", "d24", "d26", "d28", "d30",
244 "d32", "d34", "d36", "d38", "d40", "d42", "d44", "d46",
245 "d48", "d50", "d52", "d54", "d56", "d58", "d60", "d62",
247 "q0", "q4", "q8", "q12", "q16", "q20", "q24", "q28",
248 "q32", "q36", "q40", "q44", "q48", "q52", "q56", "q60",
251 /* Total number of pseudo registers. */
252 #define SPARC64_NUM_PSEUDO_REGS ARRAY_SIZE (sparc64_pseudo_register_names)
254 /* Return the name of register REGNUM. */
257 sparc64_register_name (struct gdbarch
*gdbarch
, int regnum
)
259 if (regnum
>= 0 && regnum
< SPARC64_NUM_REGS
)
260 return sparc64_register_names
[regnum
];
262 if (regnum
>= SPARC64_NUM_REGS
263 && regnum
< SPARC64_NUM_REGS
+ SPARC64_NUM_PSEUDO_REGS
)
264 return sparc64_pseudo_register_names
[regnum
- SPARC64_NUM_REGS
];
269 /* Return the GDB type object for the "standard" data type of data in
273 sparc64_register_type (struct gdbarch
*gdbarch
, int regnum
)
277 if (regnum
== SPARC_SP_REGNUM
|| regnum
== SPARC_FP_REGNUM
)
278 return builtin_type (gdbarch
)->builtin_data_ptr
;
279 if (regnum
>= SPARC_G0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
)
280 return builtin_type (gdbarch
)->builtin_int64
;
281 if (regnum
>= SPARC_F0_REGNUM
&& regnum
<= SPARC_F31_REGNUM
)
282 return builtin_type (gdbarch
)->builtin_float
;
283 if (regnum
>= SPARC64_F32_REGNUM
&& regnum
<= SPARC64_F62_REGNUM
)
284 return builtin_type (gdbarch
)->builtin_double
;
285 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== SPARC64_NPC_REGNUM
)
286 return builtin_type (gdbarch
)->builtin_func_ptr
;
287 /* This raw register contains the contents of %cwp, %pstate, %asi
288 and %ccr as laid out in a %tstate register. */
289 if (regnum
== SPARC64_STATE_REGNUM
)
290 return builtin_type (gdbarch
)->builtin_int64
;
291 if (regnum
== SPARC64_FSR_REGNUM
)
292 return sparc64_fsr_type (gdbarch
);
293 if (regnum
== SPARC64_FPRS_REGNUM
)
294 return sparc64_fprs_type (gdbarch
);
295 /* "Although Y is a 64-bit register, its high-order 32 bits are
296 reserved and always read as 0." */
297 if (regnum
== SPARC64_Y_REGNUM
)
298 return builtin_type (gdbarch
)->builtin_int64
;
300 /* Pseudo registers. */
302 if (regnum
== SPARC64_CWP_REGNUM
)
303 return builtin_type (gdbarch
)->builtin_int64
;
304 if (regnum
== SPARC64_PSTATE_REGNUM
)
305 return sparc64_pstate_type (gdbarch
);
306 if (regnum
== SPARC64_ASI_REGNUM
)
307 return builtin_type (gdbarch
)->builtin_int64
;
308 if (regnum
== SPARC64_CCR_REGNUM
)
309 return builtin_type (gdbarch
)->builtin_int64
;
310 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
311 return builtin_type (gdbarch
)->builtin_double
;
312 if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
313 return builtin_type (gdbarch
)->builtin_long_double
;
315 internal_error (__FILE__
, __LINE__
, _("invalid regnum"));
319 sparc64_pseudo_register_read (struct gdbarch
*gdbarch
,
320 struct regcache
*regcache
,
321 int regnum
, gdb_byte
*buf
)
323 gdb_assert (regnum
>= SPARC64_NUM_REGS
);
325 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D30_REGNUM
)
327 regnum
= SPARC_F0_REGNUM
+ 2 * (regnum
- SPARC64_D0_REGNUM
);
328 regcache_raw_read (regcache
, regnum
, buf
);
329 regcache_raw_read (regcache
, regnum
+ 1, buf
+ 4);
331 else if (regnum
>= SPARC64_D32_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
333 regnum
= SPARC64_F32_REGNUM
+ (regnum
- SPARC64_D32_REGNUM
);
334 regcache_raw_read (regcache
, regnum
, buf
);
336 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q28_REGNUM
)
338 regnum
= SPARC_F0_REGNUM
+ 4 * (regnum
- SPARC64_Q0_REGNUM
);
339 regcache_raw_read (regcache
, regnum
, buf
);
340 regcache_raw_read (regcache
, regnum
+ 1, buf
+ 4);
341 regcache_raw_read (regcache
, regnum
+ 2, buf
+ 8);
342 regcache_raw_read (regcache
, regnum
+ 3, buf
+ 12);
344 else if (regnum
>= SPARC64_Q32_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
346 regnum
= SPARC64_F32_REGNUM
+ 2 * (regnum
- SPARC64_Q32_REGNUM
);
347 regcache_raw_read (regcache
, regnum
, buf
);
348 regcache_raw_read (regcache
, regnum
+ 1, buf
+ 8);
350 else if (regnum
== SPARC64_CWP_REGNUM
351 || regnum
== SPARC64_PSTATE_REGNUM
352 || regnum
== SPARC64_ASI_REGNUM
353 || regnum
== SPARC64_CCR_REGNUM
)
357 regcache_raw_read_unsigned (regcache
, SPARC64_STATE_REGNUM
, &state
);
360 case SPARC64_CWP_REGNUM
:
361 state
= (state
>> 0) & ((1 << 5) - 1);
363 case SPARC64_PSTATE_REGNUM
:
364 state
= (state
>> 8) & ((1 << 12) - 1);
366 case SPARC64_ASI_REGNUM
:
367 state
= (state
>> 24) & ((1 << 8) - 1);
369 case SPARC64_CCR_REGNUM
:
370 state
= (state
>> 32) & ((1 << 8) - 1);
373 store_unsigned_integer (buf
, 8, state
);
378 sparc64_pseudo_register_write (struct gdbarch
*gdbarch
,
379 struct regcache
*regcache
,
380 int regnum
, const gdb_byte
*buf
)
382 gdb_assert (regnum
>= SPARC64_NUM_REGS
);
384 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D30_REGNUM
)
386 regnum
= SPARC_F0_REGNUM
+ 2 * (regnum
- SPARC64_D0_REGNUM
);
387 regcache_raw_write (regcache
, regnum
, buf
);
388 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 4);
390 else if (regnum
>= SPARC64_D32_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
392 regnum
= SPARC64_F32_REGNUM
+ (regnum
- SPARC64_D32_REGNUM
);
393 regcache_raw_write (regcache
, regnum
, buf
);
395 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q28_REGNUM
)
397 regnum
= SPARC_F0_REGNUM
+ 4 * (regnum
- SPARC64_Q0_REGNUM
);
398 regcache_raw_write (regcache
, regnum
, buf
);
399 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 4);
400 regcache_raw_write (regcache
, regnum
+ 2, buf
+ 8);
401 regcache_raw_write (regcache
, regnum
+ 3, buf
+ 12);
403 else if (regnum
>= SPARC64_Q32_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
405 regnum
= SPARC64_F32_REGNUM
+ 2 * (regnum
- SPARC64_Q32_REGNUM
);
406 regcache_raw_write (regcache
, regnum
, buf
);
407 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 8);
409 else if (regnum
== SPARC64_CWP_REGNUM
410 || regnum
== SPARC64_PSTATE_REGNUM
411 || regnum
== SPARC64_ASI_REGNUM
412 || regnum
== SPARC64_CCR_REGNUM
)
414 ULONGEST state
, bits
;
416 regcache_raw_read_unsigned (regcache
, SPARC64_STATE_REGNUM
, &state
);
417 bits
= extract_unsigned_integer (buf
, 8);
420 case SPARC64_CWP_REGNUM
:
421 state
|= ((bits
& ((1 << 5) - 1)) << 0);
423 case SPARC64_PSTATE_REGNUM
:
424 state
|= ((bits
& ((1 << 12) - 1)) << 8);
426 case SPARC64_ASI_REGNUM
:
427 state
|= ((bits
& ((1 << 8) - 1)) << 24);
429 case SPARC64_CCR_REGNUM
:
430 state
|= ((bits
& ((1 << 8) - 1)) << 32);
433 regcache_raw_write_unsigned (regcache
, SPARC64_STATE_REGNUM
, state
);
438 /* Return PC of first real instruction of the function starting at
442 sparc64_skip_prologue (struct gdbarch
*gdbarch
, CORE_ADDR start_pc
)
444 struct symtab_and_line sal
;
445 CORE_ADDR func_start
, func_end
;
446 struct sparc_frame_cache cache
;
448 /* This is the preferred method, find the end of the prologue by
449 using the debugging information. */
450 if (find_pc_partial_function (start_pc
, NULL
, &func_start
, &func_end
))
452 sal
= find_pc_line (func_start
, 0);
454 if (sal
.end
< func_end
455 && start_pc
<= sal
.end
)
459 return sparc_analyze_prologue (gdbarch
, start_pc
, 0xffffffffffffffffULL
,
465 static struct sparc_frame_cache
*
466 sparc64_frame_cache (struct frame_info
*this_frame
, void **this_cache
)
468 return sparc_frame_cache (this_frame
, this_cache
);
472 sparc64_frame_this_id (struct frame_info
*this_frame
, void **this_cache
,
473 struct frame_id
*this_id
)
475 struct sparc_frame_cache
*cache
=
476 sparc64_frame_cache (this_frame
, this_cache
);
478 /* This marks the outermost frame. */
479 if (cache
->base
== 0)
482 (*this_id
) = frame_id_build (cache
->base
, cache
->pc
);
485 static struct value
*
486 sparc64_frame_prev_register (struct frame_info
*this_frame
, void **this_cache
,
489 struct sparc_frame_cache
*cache
=
490 sparc64_frame_cache (this_frame
, this_cache
);
492 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== SPARC64_NPC_REGNUM
)
494 CORE_ADDR pc
= (regnum
== SPARC64_NPC_REGNUM
) ? 4 : 0;
496 regnum
= cache
->frameless_p
? SPARC_O7_REGNUM
: SPARC_I7_REGNUM
;
497 pc
+= get_frame_register_unsigned (this_frame
, regnum
) + 8;
498 return frame_unwind_got_constant (this_frame
, regnum
, pc
);
501 /* Handle StackGhost. */
503 ULONGEST wcookie
= sparc_fetch_wcookie ();
505 if (wcookie
!= 0 && !cache
->frameless_p
&& regnum
== SPARC_I7_REGNUM
)
507 CORE_ADDR addr
= cache
->base
+ (regnum
- SPARC_L0_REGNUM
) * 8;
510 /* Read the value in from memory. */
511 i7
= get_frame_memory_unsigned (this_frame
, addr
, 8);
512 return frame_unwind_got_constant (this_frame
, regnum
, i7
^ wcookie
);
516 /* The previous frame's `local' and `in' registers have been saved
517 in the register save area. */
518 if (!cache
->frameless_p
519 && regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
)
521 CORE_ADDR addr
= cache
->base
+ (regnum
- SPARC_L0_REGNUM
) * 8;
523 return frame_unwind_got_memory (this_frame
, regnum
, addr
);
526 /* The previous frame's `out' registers are accessable as the
527 current frame's `in' registers. */
528 if (!cache
->frameless_p
529 && regnum
>= SPARC_O0_REGNUM
&& regnum
<= SPARC_O7_REGNUM
)
530 regnum
+= (SPARC_I0_REGNUM
- SPARC_O0_REGNUM
);
532 return frame_unwind_got_register (this_frame
, regnum
, regnum
);
535 static const struct frame_unwind sparc64_frame_unwind
=
538 sparc64_frame_this_id
,
539 sparc64_frame_prev_register
,
541 default_frame_sniffer
546 sparc64_frame_base_address (struct frame_info
*this_frame
, void **this_cache
)
548 struct sparc_frame_cache
*cache
=
549 sparc64_frame_cache (this_frame
, this_cache
);
554 static const struct frame_base sparc64_frame_base
=
556 &sparc64_frame_unwind
,
557 sparc64_frame_base_address
,
558 sparc64_frame_base_address
,
559 sparc64_frame_base_address
562 /* Check whether TYPE must be 16-byte aligned. */
565 sparc64_16_byte_align_p (struct type
*type
)
567 if (sparc64_floating_p (type
) && TYPE_LENGTH (type
) == 16)
570 if (sparc64_structure_or_union_p (type
))
574 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
576 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
578 if (sparc64_16_byte_align_p (subtype
))
586 /* Store floating fields of element ELEMENT of an "parameter array"
587 that has type TYPE and is stored at BITPOS in VALBUF in the
588 apropriate registers of REGCACHE. This function can be called
589 recursively and therefore handles floating types in addition to
593 sparc64_store_floating_fields (struct regcache
*regcache
, struct type
*type
,
594 const gdb_byte
*valbuf
, int element
, int bitpos
)
596 gdb_assert (element
< 16);
598 if (sparc64_floating_p (type
))
600 int len
= TYPE_LENGTH (type
);
605 gdb_assert (bitpos
== 0);
606 gdb_assert ((element
% 2) == 0);
608 regnum
= SPARC64_Q0_REGNUM
+ element
/ 2;
609 regcache_cooked_write (regcache
, regnum
, valbuf
);
613 gdb_assert (bitpos
== 0 || bitpos
== 64);
615 regnum
= SPARC64_D0_REGNUM
+ element
+ bitpos
/ 64;
616 regcache_cooked_write (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
620 gdb_assert (len
== 4);
621 gdb_assert (bitpos
% 32 == 0 && bitpos
>= 0 && bitpos
< 128);
623 regnum
= SPARC_F0_REGNUM
+ element
* 2 + bitpos
/ 32;
624 regcache_cooked_write (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
627 else if (sparc64_structure_or_union_p (type
))
631 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
633 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
634 int subpos
= bitpos
+ TYPE_FIELD_BITPOS (type
, i
);
636 sparc64_store_floating_fields (regcache
, subtype
, valbuf
,
640 /* GCC has an interesting bug. If TYPE is a structure that has
641 a single `float' member, GCC doesn't treat it as a structure
642 at all, but rather as an ordinary `float' argument. This
643 argument will be stored in %f1, as required by the psABI.
644 However, as a member of a structure the psABI requires it to
645 be stored in %f0. This bug is present in GCC 3.3.2, but
646 probably in older releases to. To appease GCC, if a
647 structure has only a single `float' member, we store its
648 value in %f1 too (we already have stored in %f0). */
649 if (TYPE_NFIELDS (type
) == 1)
651 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, 0));
653 if (sparc64_floating_p (subtype
) && TYPE_LENGTH (subtype
) == 4)
654 regcache_cooked_write (regcache
, SPARC_F1_REGNUM
, valbuf
);
659 /* Fetch floating fields from a variable of type TYPE from the
660 appropriate registers for BITPOS in REGCACHE and store it at BITPOS
661 in VALBUF. This function can be called recursively and therefore
662 handles floating types in addition to structures. */
665 sparc64_extract_floating_fields (struct regcache
*regcache
, struct type
*type
,
666 gdb_byte
*valbuf
, int bitpos
)
668 if (sparc64_floating_p (type
))
670 int len
= TYPE_LENGTH (type
);
675 gdb_assert (bitpos
== 0 || bitpos
== 128);
677 regnum
= SPARC64_Q0_REGNUM
+ bitpos
/ 128;
678 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
682 gdb_assert (bitpos
% 64 == 0 && bitpos
>= 0 && bitpos
< 256);
684 regnum
= SPARC64_D0_REGNUM
+ bitpos
/ 64;
685 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
689 gdb_assert (len
== 4);
690 gdb_assert (bitpos
% 32 == 0 && bitpos
>= 0 && bitpos
< 256);
692 regnum
= SPARC_F0_REGNUM
+ bitpos
/ 32;
693 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
696 else if (sparc64_structure_or_union_p (type
))
700 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
702 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
703 int subpos
= bitpos
+ TYPE_FIELD_BITPOS (type
, i
);
705 sparc64_extract_floating_fields (regcache
, subtype
, valbuf
, subpos
);
710 /* Store the NARGS arguments ARGS and STRUCT_ADDR (if STRUCT_RETURN is
711 non-zero) in REGCACHE and on the stack (starting from address SP). */
714 sparc64_store_arguments (struct regcache
*regcache
, int nargs
,
715 struct value
**args
, CORE_ADDR sp
,
716 int struct_return
, CORE_ADDR struct_addr
)
718 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
719 /* Number of extended words in the "parameter array". */
720 int num_elements
= 0;
724 /* Take BIAS into account. */
727 /* First we calculate the number of extended words in the "parameter
728 array". While doing so we also convert some of the arguments. */
733 for (i
= 0; i
< nargs
; i
++)
735 struct type
*type
= value_type (args
[i
]);
736 int len
= TYPE_LENGTH (type
);
738 if (sparc64_structure_or_union_p (type
))
740 /* Structure or Union arguments. */
743 if (num_elements
% 2 && sparc64_16_byte_align_p (type
))
745 num_elements
+= ((len
+ 7) / 8);
749 /* The psABI says that "Structures or unions larger than
750 sixteen bytes are copied by the caller and passed
751 indirectly; the caller will pass the address of a
752 correctly aligned structure value. This sixty-four
753 bit address will occupy one word in the parameter
754 array, and may be promoted to an %o register like any
755 other pointer value." Allocate memory for these
756 values on the stack. */
759 /* Use 16-byte alignment for these values. That's
760 always correct, and wasting a few bytes shouldn't be
764 write_memory (sp
, value_contents (args
[i
]), len
);
765 args
[i
] = value_from_pointer (lookup_pointer_type (type
), sp
);
769 else if (sparc64_floating_p (type
))
771 /* Floating arguments. */
775 /* The psABI says that "Each quad-precision parameter
776 value will be assigned to two extended words in the
780 /* The psABI says that "Long doubles must be
781 quad-aligned, and thus a hole might be introduced
782 into the parameter array to force alignment." Skip
783 an element if necessary. */
784 if (num_elements
% 2)
792 /* Integral and pointer arguments. */
793 gdb_assert (sparc64_integral_or_pointer_p (type
));
795 /* The psABI says that "Each argument value of integral type
796 smaller than an extended word will be widened by the
797 caller to an extended word according to the signed-ness
798 of the argument type." */
800 args
[i
] = value_cast (builtin_type (gdbarch
)->builtin_int64
,
806 /* Allocate the "parameter array". */
807 sp
-= num_elements
* 8;
809 /* The psABI says that "Every stack frame must be 16-byte aligned." */
812 /* Now we store the arguments in to the "paramater array". Some
813 Integer or Pointer arguments and Structure or Union arguments
814 will be passed in %o registers. Some Floating arguments and
815 floating members of structures are passed in floating-point
816 registers. However, for functions with variable arguments,
817 floating arguments are stored in an %0 register, and for
818 functions without a prototype floating arguments are stored in
819 both a floating-point and an %o registers, or a floating-point
820 register and memory. To simplify the logic here we always pass
821 arguments in memory, an %o register, and a floating-point
822 register if appropriate. This should be no problem since the
823 contents of any unused memory or registers in the "parameter
824 array" are undefined. */
828 regcache_cooked_write_unsigned (regcache
, SPARC_O0_REGNUM
, struct_addr
);
832 for (i
= 0; i
< nargs
; i
++)
834 const gdb_byte
*valbuf
= value_contents (args
[i
]);
835 struct type
*type
= value_type (args
[i
]);
836 int len
= TYPE_LENGTH (type
);
840 if (sparc64_structure_or_union_p (type
))
842 /* Structure or Union arguments. */
843 gdb_assert (len
<= 16);
844 memset (buf
, 0, sizeof (buf
));
845 valbuf
= memcpy (buf
, valbuf
, len
);
847 if (element
% 2 && sparc64_16_byte_align_p (type
))
852 regnum
= SPARC_O0_REGNUM
+ element
;
853 if (len
> 8 && element
< 5)
854 regcache_cooked_write (regcache
, regnum
+ 1, valbuf
+ 8);
858 sparc64_store_floating_fields (regcache
, type
, valbuf
, element
, 0);
860 else if (sparc64_floating_p (type
))
862 /* Floating arguments. */
868 regnum
= SPARC64_Q0_REGNUM
+ element
/ 2;
873 regnum
= SPARC64_D0_REGNUM
+ element
;
877 /* The psABI says "Each single-precision parameter value
878 will be assigned to one extended word in the
879 parameter array, and right-justified within that
880 word; the left half (even floatregister) is
881 undefined." Even though the psABI says that "the
882 left half is undefined", set it to zero here. */
884 memcpy (buf
+ 4, valbuf
, 4);
888 regnum
= SPARC64_D0_REGNUM
+ element
;
893 /* Integral and pointer arguments. */
894 gdb_assert (len
== 8);
896 regnum
= SPARC_O0_REGNUM
+ element
;
901 regcache_cooked_write (regcache
, regnum
, valbuf
);
903 /* If we're storing the value in a floating-point register,
904 also store it in the corresponding %0 register(s). */
905 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D10_REGNUM
)
907 gdb_assert (element
< 6);
908 regnum
= SPARC_O0_REGNUM
+ element
;
909 regcache_cooked_write (regcache
, regnum
, valbuf
);
911 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q8_REGNUM
)
913 gdb_assert (element
< 6);
914 regnum
= SPARC_O0_REGNUM
+ element
;
915 regcache_cooked_write (regcache
, regnum
, valbuf
);
916 regcache_cooked_write (regcache
, regnum
+ 1, valbuf
+ 8);
920 /* Always store the argument in memory. */
921 write_memory (sp
+ element
* 8, valbuf
, len
);
922 element
+= ((len
+ 7) / 8);
925 gdb_assert (element
== num_elements
);
927 /* Take BIAS into account. */
933 sparc64_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
934 struct regcache
*regcache
, CORE_ADDR bp_addr
,
935 int nargs
, struct value
**args
, CORE_ADDR sp
,
936 int struct_return
, CORE_ADDR struct_addr
)
938 /* Set return address. */
939 regcache_cooked_write_unsigned (regcache
, SPARC_O7_REGNUM
, bp_addr
- 8);
941 /* Set up function arguments. */
942 sp
= sparc64_store_arguments (regcache
, nargs
, args
, sp
,
943 struct_return
, struct_addr
);
945 /* Allocate the register save area. */
948 /* Stack should be 16-byte aligned at this point. */
949 gdb_assert ((sp
+ BIAS
) % 16 == 0);
951 /* Finally, update the stack pointer. */
952 regcache_cooked_write_unsigned (regcache
, SPARC_SP_REGNUM
, sp
);
958 /* Extract from an array REGBUF containing the (raw) register state, a
959 function return value of TYPE, and copy that into VALBUF. */
962 sparc64_extract_return_value (struct type
*type
, struct regcache
*regcache
,
965 int len
= TYPE_LENGTH (type
);
969 if (sparc64_structure_or_union_p (type
))
971 /* Structure or Union return values. */
972 gdb_assert (len
<= 32);
974 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
975 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
976 if (TYPE_CODE (type
) != TYPE_CODE_UNION
)
977 sparc64_extract_floating_fields (regcache
, type
, buf
, 0);
978 memcpy (valbuf
, buf
, len
);
980 else if (sparc64_floating_p (type
))
982 /* Floating return values. */
983 for (i
= 0; i
< len
/ 4; i
++)
984 regcache_cooked_read (regcache
, SPARC_F0_REGNUM
+ i
, buf
+ i
* 4);
985 memcpy (valbuf
, buf
, len
);
987 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
989 /* Small arrays are returned the same way as small structures. */
990 gdb_assert (len
<= 32);
992 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
993 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
994 memcpy (valbuf
, buf
, len
);
998 /* Integral and pointer return values. */
999 gdb_assert (sparc64_integral_or_pointer_p (type
));
1001 /* Just stripping off any unused bytes should preserve the
1002 signed-ness just fine. */
1003 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
, buf
);
1004 memcpy (valbuf
, buf
+ 8 - len
, len
);
1008 /* Write into the appropriate registers a function return value stored
1009 in VALBUF of type TYPE. */
1012 sparc64_store_return_value (struct type
*type
, struct regcache
*regcache
,
1013 const gdb_byte
*valbuf
)
1015 int len
= TYPE_LENGTH (type
);
1019 if (sparc64_structure_or_union_p (type
))
1021 /* Structure or Union return values. */
1022 gdb_assert (len
<= 32);
1024 /* Simplify matters by storing the complete value (including
1025 floating members) into %o0 and %o1. Floating members are
1026 also store in the appropriate floating-point registers. */
1027 memset (buf
, 0, sizeof (buf
));
1028 memcpy (buf
, valbuf
, len
);
1029 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1030 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1031 if (TYPE_CODE (type
) != TYPE_CODE_UNION
)
1032 sparc64_store_floating_fields (regcache
, type
, buf
, 0, 0);
1034 else if (sparc64_floating_p (type
))
1036 /* Floating return values. */
1037 memcpy (buf
, valbuf
, len
);
1038 for (i
= 0; i
< len
/ 4; i
++)
1039 regcache_cooked_write (regcache
, SPARC_F0_REGNUM
+ i
, buf
+ i
* 4);
1041 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
1043 /* Small arrays are returned the same way as small structures. */
1044 gdb_assert (len
<= 32);
1046 memset (buf
, 0, sizeof (buf
));
1047 memcpy (buf
, valbuf
, len
);
1048 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1049 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1053 /* Integral and pointer return values. */
1054 gdb_assert (sparc64_integral_or_pointer_p (type
));
1056 /* ??? Do we need to do any sign-extension here? */
1058 memcpy (buf
+ 8 - len
, valbuf
, len
);
1059 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
, buf
);
1063 static enum return_value_convention
1064 sparc64_return_value (struct gdbarch
*gdbarch
, struct type
*func_type
,
1065 struct type
*type
, struct regcache
*regcache
,
1066 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
1068 if (TYPE_LENGTH (type
) > 32)
1069 return RETURN_VALUE_STRUCT_CONVENTION
;
1072 sparc64_extract_return_value (type
, regcache
, readbuf
);
1074 sparc64_store_return_value (type
, regcache
, writebuf
);
1076 return RETURN_VALUE_REGISTER_CONVENTION
;
1081 sparc64_dwarf2_frame_init_reg (struct gdbarch
*gdbarch
, int regnum
,
1082 struct dwarf2_frame_state_reg
*reg
,
1083 struct frame_info
*this_frame
)
1087 case SPARC_G0_REGNUM
:
1088 /* Since %g0 is always zero, there is no point in saving it, and
1089 people will be inclined omit it from the CFI. Make sure we
1090 don't warn about that. */
1091 reg
->how
= DWARF2_FRAME_REG_SAME_VALUE
;
1093 case SPARC_SP_REGNUM
:
1094 reg
->how
= DWARF2_FRAME_REG_CFA
;
1096 case SPARC64_PC_REGNUM
:
1097 reg
->how
= DWARF2_FRAME_REG_RA_OFFSET
;
1098 reg
->loc
.offset
= 8;
1100 case SPARC64_NPC_REGNUM
:
1101 reg
->how
= DWARF2_FRAME_REG_RA_OFFSET
;
1102 reg
->loc
.offset
= 12;
1108 sparc64_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
1110 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1112 tdep
->pc_regnum
= SPARC64_PC_REGNUM
;
1113 tdep
->npc_regnum
= SPARC64_NPC_REGNUM
;
1115 /* This is what all the fuss is about. */
1116 set_gdbarch_long_bit (gdbarch
, 64);
1117 set_gdbarch_long_long_bit (gdbarch
, 64);
1118 set_gdbarch_ptr_bit (gdbarch
, 64);
1120 set_gdbarch_num_regs (gdbarch
, SPARC64_NUM_REGS
);
1121 set_gdbarch_register_name (gdbarch
, sparc64_register_name
);
1122 set_gdbarch_register_type (gdbarch
, sparc64_register_type
);
1123 set_gdbarch_num_pseudo_regs (gdbarch
, SPARC64_NUM_PSEUDO_REGS
);
1124 set_gdbarch_pseudo_register_read (gdbarch
, sparc64_pseudo_register_read
);
1125 set_gdbarch_pseudo_register_write (gdbarch
, sparc64_pseudo_register_write
);
1127 /* Register numbers of various important registers. */
1128 set_gdbarch_pc_regnum (gdbarch
, SPARC64_PC_REGNUM
); /* %pc */
1130 /* Call dummy code. */
1131 set_gdbarch_call_dummy_location (gdbarch
, AT_ENTRY_POINT
);
1132 set_gdbarch_push_dummy_code (gdbarch
, NULL
);
1133 set_gdbarch_push_dummy_call (gdbarch
, sparc64_push_dummy_call
);
1135 set_gdbarch_return_value (gdbarch
, sparc64_return_value
);
1136 set_gdbarch_stabs_argument_has_addr
1137 (gdbarch
, default_stabs_argument_has_addr
);
1139 set_gdbarch_skip_prologue (gdbarch
, sparc64_skip_prologue
);
1141 /* Hook in the DWARF CFI frame unwinder. */
1142 dwarf2_frame_set_init_reg (gdbarch
, sparc64_dwarf2_frame_init_reg
);
1143 /* FIXME: kettenis/20050423: Don't enable the unwinder until the
1144 StackGhost issues have been resolved. */
1146 frame_unwind_append_unwinder (gdbarch
, &sparc64_frame_unwind
);
1147 frame_base_set_default (gdbarch
, &sparc64_frame_base
);
1151 /* Helper functions for dealing with register sets. */
1153 #define TSTATE_CWP 0x000000000000001fULL
1154 #define TSTATE_ICC 0x0000000f00000000ULL
1155 #define TSTATE_XCC 0x000000f000000000ULL
1157 #define PSR_S 0x00000080
1158 #define PSR_ICC 0x00f00000
1159 #define PSR_VERS 0x0f000000
1160 #define PSR_IMPL 0xf0000000
1161 #define PSR_V8PLUS 0xff000000
1162 #define PSR_XCC 0x000f0000
1165 sparc64_supply_gregset (const struct sparc_gregset
*gregset
,
1166 struct regcache
*regcache
,
1167 int regnum
, const void *gregs
)
1169 int sparc32
= (gdbarch_ptr_bit (get_regcache_arch (regcache
)) == 32);
1170 const gdb_byte
*regs
= gregs
;
1175 if (regnum
== SPARC32_PSR_REGNUM
|| regnum
== -1)
1177 int offset
= gregset
->r_tstate_offset
;
1178 ULONGEST tstate
, psr
;
1181 tstate
= extract_unsigned_integer (regs
+ offset
, 8);
1182 psr
= ((tstate
& TSTATE_CWP
) | PSR_S
| ((tstate
& TSTATE_ICC
) >> 12)
1183 | ((tstate
& TSTATE_XCC
) >> 20) | PSR_V8PLUS
);
1184 store_unsigned_integer (buf
, 4, psr
);
1185 regcache_raw_supply (regcache
, SPARC32_PSR_REGNUM
, buf
);
1188 if (regnum
== SPARC32_PC_REGNUM
|| regnum
== -1)
1189 regcache_raw_supply (regcache
, SPARC32_PC_REGNUM
,
1190 regs
+ gregset
->r_pc_offset
+ 4);
1192 if (regnum
== SPARC32_NPC_REGNUM
|| regnum
== -1)
1193 regcache_raw_supply (regcache
, SPARC32_NPC_REGNUM
,
1194 regs
+ gregset
->r_npc_offset
+ 4);
1196 if (regnum
== SPARC32_Y_REGNUM
|| regnum
== -1)
1198 int offset
= gregset
->r_y_offset
+ 8 - gregset
->r_y_size
;
1199 regcache_raw_supply (regcache
, SPARC32_Y_REGNUM
, regs
+ offset
);
1204 if (regnum
== SPARC64_STATE_REGNUM
|| regnum
== -1)
1205 regcache_raw_supply (regcache
, SPARC64_STATE_REGNUM
,
1206 regs
+ gregset
->r_tstate_offset
);
1208 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== -1)
1209 regcache_raw_supply (regcache
, SPARC64_PC_REGNUM
,
1210 regs
+ gregset
->r_pc_offset
);
1212 if (regnum
== SPARC64_NPC_REGNUM
|| regnum
== -1)
1213 regcache_raw_supply (regcache
, SPARC64_NPC_REGNUM
,
1214 regs
+ gregset
->r_npc_offset
);
1216 if (regnum
== SPARC64_Y_REGNUM
|| regnum
== -1)
1221 memcpy (buf
+ 8 - gregset
->r_y_size
,
1222 regs
+ gregset
->r_y_offset
, gregset
->r_y_size
);
1223 regcache_raw_supply (regcache
, SPARC64_Y_REGNUM
, buf
);
1226 if ((regnum
== SPARC64_FPRS_REGNUM
|| regnum
== -1)
1227 && gregset
->r_fprs_offset
!= -1)
1228 regcache_raw_supply (regcache
, SPARC64_FPRS_REGNUM
,
1229 regs
+ gregset
->r_fprs_offset
);
1232 if (regnum
== SPARC_G0_REGNUM
|| regnum
== -1)
1233 regcache_raw_supply (regcache
, SPARC_G0_REGNUM
, NULL
);
1235 if ((regnum
>= SPARC_G1_REGNUM
&& regnum
<= SPARC_O7_REGNUM
) || regnum
== -1)
1237 int offset
= gregset
->r_g1_offset
;
1242 for (i
= SPARC_G1_REGNUM
; i
<= SPARC_O7_REGNUM
; i
++)
1244 if (regnum
== i
|| regnum
== -1)
1245 regcache_raw_supply (regcache
, i
, regs
+ offset
);
1250 if ((regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
) || regnum
== -1)
1252 /* Not all of the register set variants include Locals and
1253 Inputs. For those that don't, we read them off the stack. */
1254 if (gregset
->r_l0_offset
== -1)
1258 regcache_cooked_read_unsigned (regcache
, SPARC_SP_REGNUM
, &sp
);
1259 sparc_supply_rwindow (regcache
, sp
, regnum
);
1263 int offset
= gregset
->r_l0_offset
;
1268 for (i
= SPARC_L0_REGNUM
; i
<= SPARC_I7_REGNUM
; i
++)
1270 if (regnum
== i
|| regnum
== -1)
1271 regcache_raw_supply (regcache
, i
, regs
+ offset
);
1279 sparc64_collect_gregset (const struct sparc_gregset
*gregset
,
1280 const struct regcache
*regcache
,
1281 int regnum
, void *gregs
)
1283 int sparc32
= (gdbarch_ptr_bit (get_regcache_arch (regcache
)) == 32);
1284 gdb_byte
*regs
= gregs
;
1289 if (regnum
== SPARC32_PSR_REGNUM
|| regnum
== -1)
1291 int offset
= gregset
->r_tstate_offset
;
1292 ULONGEST tstate
, psr
;
1295 tstate
= extract_unsigned_integer (regs
+ offset
, 8);
1296 regcache_raw_collect (regcache
, SPARC32_PSR_REGNUM
, buf
);
1297 psr
= extract_unsigned_integer (buf
, 4);
1298 tstate
|= (psr
& PSR_ICC
) << 12;
1299 if ((psr
& (PSR_VERS
| PSR_IMPL
)) == PSR_V8PLUS
)
1300 tstate
|= (psr
& PSR_XCC
) << 20;
1301 store_unsigned_integer (buf
, 8, tstate
);
1302 memcpy (regs
+ offset
, buf
, 8);
1305 if (regnum
== SPARC32_PC_REGNUM
|| regnum
== -1)
1306 regcache_raw_collect (regcache
, SPARC32_PC_REGNUM
,
1307 regs
+ gregset
->r_pc_offset
+ 4);
1309 if (regnum
== SPARC32_NPC_REGNUM
|| regnum
== -1)
1310 regcache_raw_collect (regcache
, SPARC32_NPC_REGNUM
,
1311 regs
+ gregset
->r_npc_offset
+ 4);
1313 if (regnum
== SPARC32_Y_REGNUM
|| regnum
== -1)
1315 int offset
= gregset
->r_y_offset
+ 8 - gregset
->r_y_size
;
1316 regcache_raw_collect (regcache
, SPARC32_Y_REGNUM
, regs
+ offset
);
1321 if (regnum
== SPARC64_STATE_REGNUM
|| regnum
== -1)
1322 regcache_raw_collect (regcache
, SPARC64_STATE_REGNUM
,
1323 regs
+ gregset
->r_tstate_offset
);
1325 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== -1)
1326 regcache_raw_collect (regcache
, SPARC64_PC_REGNUM
,
1327 regs
+ gregset
->r_pc_offset
);
1329 if (regnum
== SPARC64_NPC_REGNUM
|| regnum
== -1)
1330 regcache_raw_collect (regcache
, SPARC64_NPC_REGNUM
,
1331 regs
+ gregset
->r_npc_offset
);
1333 if (regnum
== SPARC64_Y_REGNUM
|| regnum
== -1)
1337 regcache_raw_collect (regcache
, SPARC64_Y_REGNUM
, buf
);
1338 memcpy (regs
+ gregset
->r_y_offset
,
1339 buf
+ 8 - gregset
->r_y_size
, gregset
->r_y_size
);
1342 if ((regnum
== SPARC64_FPRS_REGNUM
|| regnum
== -1)
1343 && gregset
->r_fprs_offset
!= -1)
1344 regcache_raw_collect (regcache
, SPARC64_FPRS_REGNUM
,
1345 regs
+ gregset
->r_fprs_offset
);
1349 if ((regnum
>= SPARC_G1_REGNUM
&& regnum
<= SPARC_O7_REGNUM
) || regnum
== -1)
1351 int offset
= gregset
->r_g1_offset
;
1356 /* %g0 is always zero. */
1357 for (i
= SPARC_G1_REGNUM
; i
<= SPARC_O7_REGNUM
; i
++)
1359 if (regnum
== i
|| regnum
== -1)
1360 regcache_raw_collect (regcache
, i
, regs
+ offset
);
1365 if ((regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
) || regnum
== -1)
1367 /* Not all of the register set variants include Locals and
1368 Inputs. For those that don't, we read them off the stack. */
1369 if (gregset
->r_l0_offset
!= -1)
1371 int offset
= gregset
->r_l0_offset
;
1376 for (i
= SPARC_L0_REGNUM
; i
<= SPARC_I7_REGNUM
; i
++)
1378 if (regnum
== i
|| regnum
== -1)
1379 regcache_raw_collect (regcache
, i
, regs
+ offset
);
1387 sparc64_supply_fpregset (struct regcache
*regcache
,
1388 int regnum
, const void *fpregs
)
1390 int sparc32
= (gdbarch_ptr_bit (get_regcache_arch (regcache
)) == 32);
1391 const gdb_byte
*regs
= fpregs
;
1394 for (i
= 0; i
< 32; i
++)
1396 if (regnum
== (SPARC_F0_REGNUM
+ i
) || regnum
== -1)
1397 regcache_raw_supply (regcache
, SPARC_F0_REGNUM
+ i
, regs
+ (i
* 4));
1402 if (regnum
== SPARC32_FSR_REGNUM
|| regnum
== -1)
1403 regcache_raw_supply (regcache
, SPARC32_FSR_REGNUM
,
1404 regs
+ (32 * 4) + (16 * 8) + 4);
1408 for (i
= 0; i
< 16; i
++)
1410 if (regnum
== (SPARC64_F32_REGNUM
+ i
) || regnum
== -1)
1411 regcache_raw_supply (regcache
, SPARC64_F32_REGNUM
+ i
,
1412 regs
+ (32 * 4) + (i
* 8));
1415 if (regnum
== SPARC64_FSR_REGNUM
|| regnum
== -1)
1416 regcache_raw_supply (regcache
, SPARC64_FSR_REGNUM
,
1417 regs
+ (32 * 4) + (16 * 8));
1422 sparc64_collect_fpregset (const struct regcache
*regcache
,
1423 int regnum
, void *fpregs
)
1425 int sparc32
= (gdbarch_ptr_bit (get_regcache_arch (regcache
)) == 32);
1426 gdb_byte
*regs
= fpregs
;
1429 for (i
= 0; i
< 32; i
++)
1431 if (regnum
== (SPARC_F0_REGNUM
+ i
) || regnum
== -1)
1432 regcache_raw_collect (regcache
, SPARC_F0_REGNUM
+ i
, regs
+ (i
* 4));
1437 if (regnum
== SPARC32_FSR_REGNUM
|| regnum
== -1)
1438 regcache_raw_collect (regcache
, SPARC32_FSR_REGNUM
,
1439 regs
+ (32 * 4) + (16 * 8) + 4);
1443 for (i
= 0; i
< 16; i
++)
1445 if (regnum
== (SPARC64_F32_REGNUM
+ i
) || regnum
== -1)
1446 regcache_raw_collect (regcache
, SPARC64_F32_REGNUM
+ i
,
1447 regs
+ (32 * 4) + (i
* 8));
1450 if (regnum
== SPARC64_FSR_REGNUM
|| regnum
== -1)
1451 regcache_raw_collect (regcache
, SPARC64_FSR_REGNUM
,
1452 regs
+ (32 * 4) + (16 * 8));