1 /* Target-dependent code for UltraSPARC.
3 Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "arch-utils.h"
22 #include "dwarf2-frame.h"
23 #include "floatformat.h"
25 #include "frame-base.h"
26 #include "frame-unwind.h"
37 #include "gdb_assert.h"
38 #include "gdb_string.h"
40 #include "sparc64-tdep.h"
42 /* This file implements the The SPARC 64-bit ABI as defined by the
43 section "Low-Level System Information" of the SPARC Compliance
44 Definition (SCD) 2.4.1, which is the 64-bit System V psABI for
47 /* Please use the sparc32_-prefix for 32-bit specific code, the
48 sparc64_-prefix for 64-bit specific code and the sparc_-prefix for
49 code can handle both. */
51 /* The functions on this page are intended to be used to classify
52 function arguments. */
54 /* Check whether TYPE is "Integral or Pointer". */
57 sparc64_integral_or_pointer_p (const struct type
*type
)
59 switch (TYPE_CODE (type
))
67 int len
= TYPE_LENGTH (type
);
68 gdb_assert (len
== 1 || len
== 2 || len
== 4 || len
== 8);
74 int len
= TYPE_LENGTH (type
);
75 gdb_assert (len
== 8);
85 /* Check whether TYPE is "Floating". */
88 sparc64_floating_p (const struct type
*type
)
90 switch (TYPE_CODE (type
))
94 int len
= TYPE_LENGTH (type
);
95 gdb_assert (len
== 4 || len
== 8 || len
== 16);
105 /* Check whether TYPE is "Structure or Union". */
108 sparc64_structure_or_union_p (const struct type
*type
)
110 switch (TYPE_CODE (type
))
112 case TYPE_CODE_STRUCT
:
113 case TYPE_CODE_UNION
:
123 /* Type for %pstate. */
124 struct type
*sparc64_pstate_type
;
127 struct type
*sparc64_fsr_type
;
129 /* Type for %fprs. */
130 struct type
*sparc64_fprs_type
;
132 /* Construct types for ISA-specific registers. */
135 sparc64_init_types (void)
139 type
= init_flags_type ("builtin_type_sparc64_pstate", 8);
140 append_flags_type_flag (type
, 0, "AG");
141 append_flags_type_flag (type
, 1, "IE");
142 append_flags_type_flag (type
, 2, "PRIV");
143 append_flags_type_flag (type
, 3, "AM");
144 append_flags_type_flag (type
, 4, "PEF");
145 append_flags_type_flag (type
, 5, "RED");
146 append_flags_type_flag (type
, 8, "TLE");
147 append_flags_type_flag (type
, 9, "CLE");
148 append_flags_type_flag (type
, 10, "PID0");
149 append_flags_type_flag (type
, 11, "PID1");
150 sparc64_pstate_type
= type
;
152 type
= init_flags_type ("builtin_type_sparc64_fsr", 8);
153 append_flags_type_flag (type
, 0, "NXA");
154 append_flags_type_flag (type
, 1, "DZA");
155 append_flags_type_flag (type
, 2, "UFA");
156 append_flags_type_flag (type
, 3, "OFA");
157 append_flags_type_flag (type
, 4, "NVA");
158 append_flags_type_flag (type
, 5, "NXC");
159 append_flags_type_flag (type
, 6, "DZC");
160 append_flags_type_flag (type
, 7, "UFC");
161 append_flags_type_flag (type
, 8, "OFC");
162 append_flags_type_flag (type
, 9, "NVC");
163 append_flags_type_flag (type
, 22, "NS");
164 append_flags_type_flag (type
, 23, "NXM");
165 append_flags_type_flag (type
, 24, "DZM");
166 append_flags_type_flag (type
, 25, "UFM");
167 append_flags_type_flag (type
, 26, "OFM");
168 append_flags_type_flag (type
, 27, "NVM");
169 sparc64_fsr_type
= type
;
171 type
= init_flags_type ("builtin_type_sparc64_fprs", 8);
172 append_flags_type_flag (type
, 0, "DL");
173 append_flags_type_flag (type
, 1, "DU");
174 append_flags_type_flag (type
, 2, "FEF");
175 sparc64_fprs_type
= type
;
178 /* Register information. */
180 static const char *sparc64_register_names
[] =
182 "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
183 "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7",
184 "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
185 "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7",
187 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
188 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
189 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
190 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
191 "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46",
192 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62",
196 /* FIXME: Give "state" a name until we start using register groups. */
203 /* Total number of registers. */
204 #define SPARC64_NUM_REGS ARRAY_SIZE (sparc64_register_names)
206 /* We provide the aliases %d0..%d62 and %q0..%q60 for the floating
207 registers as "psuedo" registers. */
209 static const char *sparc64_pseudo_register_names
[] =
211 "cwp", "pstate", "asi", "ccr",
213 "d0", "d2", "d4", "d6", "d8", "d10", "d12", "d14",
214 "d16", "d18", "d20", "d22", "d24", "d26", "d28", "d30",
215 "d32", "d34", "d36", "d38", "d40", "d42", "d44", "d46",
216 "d48", "d50", "d52", "d54", "d56", "d58", "d60", "d62",
218 "q0", "q4", "q8", "q12", "q16", "q20", "q24", "q28",
219 "q32", "q36", "q40", "q44", "q48", "q52", "q56", "q60",
222 /* Total number of pseudo registers. */
223 #define SPARC64_NUM_PSEUDO_REGS ARRAY_SIZE (sparc64_pseudo_register_names)
225 /* Return the name of register REGNUM. */
228 sparc64_register_name (int regnum
)
230 if (regnum
>= 0 && regnum
< SPARC64_NUM_REGS
)
231 return sparc64_register_names
[regnum
];
233 if (regnum
>= SPARC64_NUM_REGS
234 && regnum
< SPARC64_NUM_REGS
+ SPARC64_NUM_PSEUDO_REGS
)
235 return sparc64_pseudo_register_names
[regnum
- SPARC64_NUM_REGS
];
240 /* Return the GDB type object for the "standard" data type of data in
244 sparc64_register_type (struct gdbarch
*gdbarch
, int regnum
)
248 if (regnum
== SPARC_SP_REGNUM
|| regnum
== SPARC_FP_REGNUM
)
249 return builtin_type_void_data_ptr
;
250 if (regnum
>= SPARC_G0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
)
251 return builtin_type_int64
;
252 if (regnum
>= SPARC_F0_REGNUM
&& regnum
<= SPARC_F31_REGNUM
)
253 return builtin_type_float
;
254 if (regnum
>= SPARC64_F32_REGNUM
&& regnum
<= SPARC64_F62_REGNUM
)
255 return builtin_type_double
;
256 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== SPARC64_NPC_REGNUM
)
257 return builtin_type_void_func_ptr
;
258 /* This raw register contains the contents of %cwp, %pstate, %asi
259 and %ccr as laid out in a %tstate register. */
260 if (regnum
== SPARC64_STATE_REGNUM
)
261 return builtin_type_int64
;
262 if (regnum
== SPARC64_FSR_REGNUM
)
263 return sparc64_fsr_type
;
264 if (regnum
== SPARC64_FPRS_REGNUM
)
265 return sparc64_fprs_type
;
266 /* "Although Y is a 64-bit register, its high-order 32 bits are
267 reserved and always read as 0." */
268 if (regnum
== SPARC64_Y_REGNUM
)
269 return builtin_type_int64
;
271 /* Pseudo registers. */
273 if (regnum
== SPARC64_CWP_REGNUM
)
274 return builtin_type_int64
;
275 if (regnum
== SPARC64_PSTATE_REGNUM
)
276 return sparc64_pstate_type
;
277 if (regnum
== SPARC64_ASI_REGNUM
)
278 return builtin_type_int64
;
279 if (regnum
== SPARC64_CCR_REGNUM
)
280 return builtin_type_int64
;
281 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
282 return builtin_type_double
;
283 if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
284 return builtin_type_long_double
;
286 internal_error (__FILE__
, __LINE__
, _("invalid regnum"));
290 sparc64_pseudo_register_read (struct gdbarch
*gdbarch
,
291 struct regcache
*regcache
,
292 int regnum
, gdb_byte
*buf
)
294 gdb_assert (regnum
>= SPARC64_NUM_REGS
);
296 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D30_REGNUM
)
298 regnum
= SPARC_F0_REGNUM
+ 2 * (regnum
- SPARC64_D0_REGNUM
);
299 regcache_raw_read (regcache
, regnum
, buf
);
300 regcache_raw_read (regcache
, regnum
+ 1, buf
+ 4);
302 else if (regnum
>= SPARC64_D32_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
304 regnum
= SPARC64_F32_REGNUM
+ (regnum
- SPARC64_D32_REGNUM
);
305 regcache_raw_read (regcache
, regnum
, buf
);
307 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q28_REGNUM
)
309 regnum
= SPARC_F0_REGNUM
+ 4 * (regnum
- SPARC64_Q0_REGNUM
);
310 regcache_raw_read (regcache
, regnum
, buf
);
311 regcache_raw_read (regcache
, regnum
+ 1, buf
+ 4);
312 regcache_raw_read (regcache
, regnum
+ 2, buf
+ 8);
313 regcache_raw_read (regcache
, regnum
+ 3, buf
+ 12);
315 else if (regnum
>= SPARC64_Q32_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
317 regnum
= SPARC64_F32_REGNUM
+ 2 * (regnum
- SPARC64_Q32_REGNUM
);
318 regcache_raw_read (regcache
, regnum
, buf
);
319 regcache_raw_read (regcache
, regnum
+ 1, buf
+ 8);
321 else if (regnum
== SPARC64_CWP_REGNUM
322 || regnum
== SPARC64_PSTATE_REGNUM
323 || regnum
== SPARC64_ASI_REGNUM
324 || regnum
== SPARC64_CCR_REGNUM
)
328 regcache_raw_read_unsigned (regcache
, SPARC64_STATE_REGNUM
, &state
);
331 case SPARC64_CWP_REGNUM
:
332 state
= (state
>> 0) & ((1 << 5) - 1);
334 case SPARC64_PSTATE_REGNUM
:
335 state
= (state
>> 8) & ((1 << 12) - 1);
337 case SPARC64_ASI_REGNUM
:
338 state
= (state
>> 24) & ((1 << 8) - 1);
340 case SPARC64_CCR_REGNUM
:
341 state
= (state
>> 32) & ((1 << 8) - 1);
344 store_unsigned_integer (buf
, 8, state
);
349 sparc64_pseudo_register_write (struct gdbarch
*gdbarch
,
350 struct regcache
*regcache
,
351 int regnum
, const gdb_byte
*buf
)
353 gdb_assert (regnum
>= SPARC64_NUM_REGS
);
355 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D30_REGNUM
)
357 regnum
= SPARC_F0_REGNUM
+ 2 * (regnum
- SPARC64_D0_REGNUM
);
358 regcache_raw_write (regcache
, regnum
, buf
);
359 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 4);
361 else if (regnum
>= SPARC64_D32_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
363 regnum
= SPARC64_F32_REGNUM
+ (regnum
- SPARC64_D32_REGNUM
);
364 regcache_raw_write (regcache
, regnum
, buf
);
366 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q28_REGNUM
)
368 regnum
= SPARC_F0_REGNUM
+ 4 * (regnum
- SPARC64_Q0_REGNUM
);
369 regcache_raw_write (regcache
, regnum
, buf
);
370 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 4);
371 regcache_raw_write (regcache
, regnum
+ 2, buf
+ 8);
372 regcache_raw_write (regcache
, regnum
+ 3, buf
+ 12);
374 else if (regnum
>= SPARC64_Q32_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
376 regnum
= SPARC64_F32_REGNUM
+ 2 * (regnum
- SPARC64_Q32_REGNUM
);
377 regcache_raw_write (regcache
, regnum
, buf
);
378 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 8);
380 else if (regnum
== SPARC64_CWP_REGNUM
381 || regnum
== SPARC64_PSTATE_REGNUM
382 || regnum
== SPARC64_ASI_REGNUM
383 || regnum
== SPARC64_CCR_REGNUM
)
385 ULONGEST state
, bits
;
387 regcache_raw_read_unsigned (regcache
, SPARC64_STATE_REGNUM
, &state
);
388 bits
= extract_unsigned_integer (buf
, 8);
391 case SPARC64_CWP_REGNUM
:
392 state
|= ((bits
& ((1 << 5) - 1)) << 0);
394 case SPARC64_PSTATE_REGNUM
:
395 state
|= ((bits
& ((1 << 12) - 1)) << 8);
397 case SPARC64_ASI_REGNUM
:
398 state
|= ((bits
& ((1 << 8) - 1)) << 24);
400 case SPARC64_CCR_REGNUM
:
401 state
|= ((bits
& ((1 << 8) - 1)) << 32);
404 regcache_raw_write_unsigned (regcache
, SPARC64_STATE_REGNUM
, state
);
409 /* Return PC of first real instruction of the function starting at
413 sparc64_skip_prologue (CORE_ADDR start_pc
)
415 struct symtab_and_line sal
;
416 CORE_ADDR func_start
, func_end
;
417 struct sparc_frame_cache cache
;
419 /* This is the preferred method, find the end of the prologue by
420 using the debugging information. */
421 if (find_pc_partial_function (start_pc
, NULL
, &func_start
, &func_end
))
423 sal
= find_pc_line (func_start
, 0);
425 if (sal
.end
< func_end
426 && start_pc
<= sal
.end
)
430 return sparc_analyze_prologue (start_pc
, 0xffffffffffffffffULL
, &cache
);
435 static struct sparc_frame_cache
*
436 sparc64_frame_cache (struct frame_info
*next_frame
, void **this_cache
)
438 return sparc_frame_cache (next_frame
, this_cache
);
442 sparc64_frame_this_id (struct frame_info
*next_frame
, void **this_cache
,
443 struct frame_id
*this_id
)
445 struct sparc_frame_cache
*cache
=
446 sparc64_frame_cache (next_frame
, this_cache
);
448 /* This marks the outermost frame. */
449 if (cache
->base
== 0)
452 (*this_id
) = frame_id_build (cache
->base
, cache
->pc
);
456 sparc64_frame_prev_register (struct frame_info
*next_frame
, void **this_cache
,
457 int regnum
, int *optimizedp
,
458 enum lval_type
*lvalp
, CORE_ADDR
*addrp
,
459 int *realnump
, gdb_byte
*valuep
)
461 struct sparc_frame_cache
*cache
=
462 sparc64_frame_cache (next_frame
, this_cache
);
464 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== SPARC64_NPC_REGNUM
)
472 CORE_ADDR pc
= (regnum
== SPARC64_NPC_REGNUM
) ? 4 : 0;
474 regnum
= cache
->frameless_p
? SPARC_O7_REGNUM
: SPARC_I7_REGNUM
;
475 pc
+= frame_unwind_register_unsigned (next_frame
, regnum
) + 8;
476 store_unsigned_integer (valuep
, 8, pc
);
481 /* Handle StackGhost. */
483 ULONGEST wcookie
= sparc_fetch_wcookie ();
485 if (wcookie
!= 0 && !cache
->frameless_p
&& regnum
== SPARC_I7_REGNUM
)
493 CORE_ADDR addr
= cache
->base
+ (regnum
- SPARC_L0_REGNUM
) * 8;
496 /* Read the value in from memory. */
497 i7
= get_frame_memory_unsigned (next_frame
, addr
, 8);
498 store_unsigned_integer (valuep
, 8, i7
^ wcookie
);
504 /* The previous frame's `local' and `in' registers have been saved
505 in the register save area. */
506 if (!cache
->frameless_p
507 && regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
)
510 *lvalp
= lval_memory
;
511 *addrp
= cache
->base
+ (regnum
- SPARC_L0_REGNUM
) * 8;
515 struct gdbarch
*gdbarch
= get_frame_arch (next_frame
);
517 /* Read the value in from memory. */
518 read_memory (*addrp
, valuep
, register_size (gdbarch
, regnum
));
523 /* The previous frame's `out' registers are accessable as the
524 current frame's `in' registers. */
525 if (!cache
->frameless_p
526 && regnum
>= SPARC_O0_REGNUM
&& regnum
<= SPARC_O7_REGNUM
)
527 regnum
+= (SPARC_I0_REGNUM
- SPARC_O0_REGNUM
);
530 *lvalp
= lval_register
;
534 frame_unwind_register (next_frame
, regnum
, valuep
);
537 static const struct frame_unwind sparc64_frame_unwind
=
540 sparc64_frame_this_id
,
541 sparc64_frame_prev_register
544 static const struct frame_unwind
*
545 sparc64_frame_sniffer (struct frame_info
*next_frame
)
547 return &sparc64_frame_unwind
;
552 sparc64_frame_base_address (struct frame_info
*next_frame
, void **this_cache
)
554 struct sparc_frame_cache
*cache
=
555 sparc64_frame_cache (next_frame
, this_cache
);
560 static const struct frame_base sparc64_frame_base
=
562 &sparc64_frame_unwind
,
563 sparc64_frame_base_address
,
564 sparc64_frame_base_address
,
565 sparc64_frame_base_address
568 /* Check whether TYPE must be 16-byte aligned. */
571 sparc64_16_byte_align_p (struct type
*type
)
573 if (sparc64_floating_p (type
) && TYPE_LENGTH (type
) == 16)
576 if (sparc64_structure_or_union_p (type
))
580 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
582 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
584 if (sparc64_16_byte_align_p (subtype
))
592 /* Store floating fields of element ELEMENT of an "parameter array"
593 that has type TYPE and is stored at BITPOS in VALBUF in the
594 apropriate registers of REGCACHE. This function can be called
595 recursively and therefore handles floating types in addition to
599 sparc64_store_floating_fields (struct regcache
*regcache
, struct type
*type
,
600 const gdb_byte
*valbuf
, int element
, int bitpos
)
602 gdb_assert (element
< 16);
604 if (sparc64_floating_p (type
))
606 int len
= TYPE_LENGTH (type
);
611 gdb_assert (bitpos
== 0);
612 gdb_assert ((element
% 2) == 0);
614 regnum
= SPARC64_Q0_REGNUM
+ element
/ 2;
615 regcache_cooked_write (regcache
, regnum
, valbuf
);
619 gdb_assert (bitpos
== 0 || bitpos
== 64);
621 regnum
= SPARC64_D0_REGNUM
+ element
+ bitpos
/ 64;
622 regcache_cooked_write (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
626 gdb_assert (len
== 4);
627 gdb_assert (bitpos
% 32 == 0 && bitpos
>= 0 && bitpos
< 128);
629 regnum
= SPARC_F0_REGNUM
+ element
* 2 + bitpos
/ 32;
630 regcache_cooked_write (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
633 else if (sparc64_structure_or_union_p (type
))
637 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
639 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
640 int subpos
= bitpos
+ TYPE_FIELD_BITPOS (type
, i
);
642 sparc64_store_floating_fields (regcache
, subtype
, valbuf
,
646 /* GCC has an interesting bug. If TYPE is a structure that has
647 a single `float' member, GCC doesn't treat it as a structure
648 at all, but rather as an ordinary `float' argument. This
649 argument will be stored in %f1, as required by the psABI.
650 However, as a member of a structure the psABI requires it to
651 be stored in %f0. This bug is present in GCC 3.3.2, but
652 probably in older releases to. To appease GCC, if a
653 structure has only a single `float' member, we store its
654 value in %f1 too (we already have stored in %f0). */
655 if (TYPE_NFIELDS (type
) == 1)
657 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, 0));
659 if (sparc64_floating_p (subtype
) && TYPE_LENGTH (subtype
) == 4)
660 regcache_cooked_write (regcache
, SPARC_F1_REGNUM
, valbuf
);
665 /* Fetch floating fields from a variable of type TYPE from the
666 appropriate registers for BITPOS in REGCACHE and store it at BITPOS
667 in VALBUF. This function can be called recursively and therefore
668 handles floating types in addition to structures. */
671 sparc64_extract_floating_fields (struct regcache
*regcache
, struct type
*type
,
672 gdb_byte
*valbuf
, int bitpos
)
674 if (sparc64_floating_p (type
))
676 int len
= TYPE_LENGTH (type
);
681 gdb_assert (bitpos
== 0 || bitpos
== 128);
683 regnum
= SPARC64_Q0_REGNUM
+ bitpos
/ 128;
684 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
688 gdb_assert (bitpos
% 64 == 0 && bitpos
>= 0 && bitpos
< 256);
690 regnum
= SPARC64_D0_REGNUM
+ bitpos
/ 64;
691 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
695 gdb_assert (len
== 4);
696 gdb_assert (bitpos
% 32 == 0 && bitpos
>= 0 && bitpos
< 256);
698 regnum
= SPARC_F0_REGNUM
+ bitpos
/ 32;
699 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
702 else if (sparc64_structure_or_union_p (type
))
706 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
708 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
709 int subpos
= bitpos
+ TYPE_FIELD_BITPOS (type
, i
);
711 sparc64_extract_floating_fields (regcache
, subtype
, valbuf
, subpos
);
716 /* Store the NARGS arguments ARGS and STRUCT_ADDR (if STRUCT_RETURN is
717 non-zero) in REGCACHE and on the stack (starting from address SP). */
720 sparc64_store_arguments (struct regcache
*regcache
, int nargs
,
721 struct value
**args
, CORE_ADDR sp
,
722 int struct_return
, CORE_ADDR struct_addr
)
724 /* Number of extended words in the "parameter array". */
725 int num_elements
= 0;
729 /* Take BIAS into account. */
732 /* First we calculate the number of extended words in the "parameter
733 array". While doing so we also convert some of the arguments. */
738 for (i
= 0; i
< nargs
; i
++)
740 struct type
*type
= value_type (args
[i
]);
741 int len
= TYPE_LENGTH (type
);
743 if (sparc64_structure_or_union_p (type
))
745 /* Structure or Union arguments. */
748 if (num_elements
% 2 && sparc64_16_byte_align_p (type
))
750 num_elements
+= ((len
+ 7) / 8);
754 /* The psABI says that "Structures or unions larger than
755 sixteen bytes are copied by the caller and passed
756 indirectly; the caller will pass the address of a
757 correctly aligned structure value. This sixty-four
758 bit address will occupy one word in the parameter
759 array, and may be promoted to an %o register like any
760 other pointer value." Allocate memory for these
761 values on the stack. */
764 /* Use 16-byte alignment for these values. That's
765 always correct, and wasting a few bytes shouldn't be
769 write_memory (sp
, value_contents (args
[i
]), len
);
770 args
[i
] = value_from_pointer (lookup_pointer_type (type
), sp
);
774 else if (sparc64_floating_p (type
))
776 /* Floating arguments. */
780 /* The psABI says that "Each quad-precision parameter
781 value will be assigned to two extended words in the
785 /* The psABI says that "Long doubles must be
786 quad-aligned, and thus a hole might be introduced
787 into the parameter array to force alignment." Skip
788 an element if necessary. */
789 if (num_elements
% 2)
797 /* Integral and pointer arguments. */
798 gdb_assert (sparc64_integral_or_pointer_p (type
));
800 /* The psABI says that "Each argument value of integral type
801 smaller than an extended word will be widened by the
802 caller to an extended word according to the signed-ness
803 of the argument type." */
805 args
[i
] = value_cast (builtin_type_int64
, args
[i
]);
810 /* Allocate the "parameter array". */
811 sp
-= num_elements
* 8;
813 /* The psABI says that "Every stack frame must be 16-byte aligned." */
816 /* Now we store the arguments in to the "paramater array". Some
817 Integer or Pointer arguments and Structure or Union arguments
818 will be passed in %o registers. Some Floating arguments and
819 floating members of structures are passed in floating-point
820 registers. However, for functions with variable arguments,
821 floating arguments are stored in an %0 register, and for
822 functions without a prototype floating arguments are stored in
823 both a floating-point and an %o registers, or a floating-point
824 register and memory. To simplify the logic here we always pass
825 arguments in memory, an %o register, and a floating-point
826 register if appropriate. This should be no problem since the
827 contents of any unused memory or registers in the "parameter
828 array" are undefined. */
832 regcache_cooked_write_unsigned (regcache
, SPARC_O0_REGNUM
, struct_addr
);
836 for (i
= 0; i
< nargs
; i
++)
838 const gdb_byte
*valbuf
= value_contents (args
[i
]);
839 struct type
*type
= value_type (args
[i
]);
840 int len
= TYPE_LENGTH (type
);
844 if (sparc64_structure_or_union_p (type
))
846 /* Structure or Union arguments. */
847 gdb_assert (len
<= 16);
848 memset (buf
, 0, sizeof (buf
));
849 valbuf
= memcpy (buf
, valbuf
, len
);
851 if (element
% 2 && sparc64_16_byte_align_p (type
))
856 regnum
= SPARC_O0_REGNUM
+ element
;
857 if (len
> 8 && element
< 5)
858 regcache_cooked_write (regcache
, regnum
+ 1, valbuf
+ 8);
862 sparc64_store_floating_fields (regcache
, type
, valbuf
, element
, 0);
864 else if (sparc64_floating_p (type
))
866 /* Floating arguments. */
872 regnum
= SPARC64_Q0_REGNUM
+ element
/ 2;
877 regnum
= SPARC64_D0_REGNUM
+ element
;
881 /* The psABI says "Each single-precision parameter value
882 will be assigned to one extended word in the
883 parameter array, and right-justified within that
884 word; the left half (even floatregister) is
885 undefined." Even though the psABI says that "the
886 left half is undefined", set it to zero here. */
888 memcpy (buf
+ 4, valbuf
, 4);
892 regnum
= SPARC64_D0_REGNUM
+ element
;
897 /* Integral and pointer arguments. */
898 gdb_assert (len
== 8);
900 regnum
= SPARC_O0_REGNUM
+ element
;
905 regcache_cooked_write (regcache
, regnum
, valbuf
);
907 /* If we're storing the value in a floating-point register,
908 also store it in the corresponding %0 register(s). */
909 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D10_REGNUM
)
911 gdb_assert (element
< 6);
912 regnum
= SPARC_O0_REGNUM
+ element
;
913 regcache_cooked_write (regcache
, regnum
, valbuf
);
915 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q8_REGNUM
)
917 gdb_assert (element
< 6);
918 regnum
= SPARC_O0_REGNUM
+ element
;
919 regcache_cooked_write (regcache
, regnum
, valbuf
);
920 regcache_cooked_write (regcache
, regnum
+ 1, valbuf
+ 8);
924 /* Always store the argument in memory. */
925 write_memory (sp
+ element
* 8, valbuf
, len
);
926 element
+= ((len
+ 7) / 8);
929 gdb_assert (element
== num_elements
);
931 /* Take BIAS into account. */
937 sparc64_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
938 struct regcache
*regcache
, CORE_ADDR bp_addr
,
939 int nargs
, struct value
**args
, CORE_ADDR sp
,
940 int struct_return
, CORE_ADDR struct_addr
)
942 /* Set return address. */
943 regcache_cooked_write_unsigned (regcache
, SPARC_O7_REGNUM
, bp_addr
- 8);
945 /* Set up function arguments. */
946 sp
= sparc64_store_arguments (regcache
, nargs
, args
, sp
,
947 struct_return
, struct_addr
);
949 /* Allocate the register save area. */
952 /* Stack should be 16-byte aligned at this point. */
953 gdb_assert ((sp
+ BIAS
) % 16 == 0);
955 /* Finally, update the stack pointer. */
956 regcache_cooked_write_unsigned (regcache
, SPARC_SP_REGNUM
, sp
);
962 /* Extract from an array REGBUF containing the (raw) register state, a
963 function return value of TYPE, and copy that into VALBUF. */
966 sparc64_extract_return_value (struct type
*type
, struct regcache
*regcache
,
969 int len
= TYPE_LENGTH (type
);
973 if (sparc64_structure_or_union_p (type
))
975 /* Structure or Union return values. */
976 gdb_assert (len
<= 32);
978 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
979 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
980 if (TYPE_CODE (type
) != TYPE_CODE_UNION
)
981 sparc64_extract_floating_fields (regcache
, type
, buf
, 0);
982 memcpy (valbuf
, buf
, len
);
984 else if (sparc64_floating_p (type
))
986 /* Floating return values. */
987 for (i
= 0; i
< len
/ 4; i
++)
988 regcache_cooked_read (regcache
, SPARC_F0_REGNUM
+ i
, buf
+ i
* 4);
989 memcpy (valbuf
, buf
, len
);
991 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
993 /* Small arrays are returned the same way as small structures. */
994 gdb_assert (len
<= 32);
996 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
997 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
998 memcpy (valbuf
, buf
, len
);
1002 /* Integral and pointer return values. */
1003 gdb_assert (sparc64_integral_or_pointer_p (type
));
1005 /* Just stripping off any unused bytes should preserve the
1006 signed-ness just fine. */
1007 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
, buf
);
1008 memcpy (valbuf
, buf
+ 8 - len
, len
);
1012 /* Write into the appropriate registers a function return value stored
1013 in VALBUF of type TYPE. */
1016 sparc64_store_return_value (struct type
*type
, struct regcache
*regcache
,
1017 const gdb_byte
*valbuf
)
1019 int len
= TYPE_LENGTH (type
);
1023 if (sparc64_structure_or_union_p (type
))
1025 /* Structure or Union return values. */
1026 gdb_assert (len
<= 32);
1028 /* Simplify matters by storing the complete value (including
1029 floating members) into %o0 and %o1. Floating members are
1030 also store in the appropriate floating-point registers. */
1031 memset (buf
, 0, sizeof (buf
));
1032 memcpy (buf
, valbuf
, len
);
1033 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1034 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1035 if (TYPE_CODE (type
) != TYPE_CODE_UNION
)
1036 sparc64_store_floating_fields (regcache
, type
, buf
, 0, 0);
1038 else if (sparc64_floating_p (type
))
1040 /* Floating return values. */
1041 memcpy (buf
, valbuf
, len
);
1042 for (i
= 0; i
< len
/ 4; i
++)
1043 regcache_cooked_write (regcache
, SPARC_F0_REGNUM
+ i
, buf
+ i
* 4);
1045 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
1047 /* Small arrays are returned the same way as small structures. */
1048 gdb_assert (len
<= 32);
1050 memset (buf
, 0, sizeof (buf
));
1051 memcpy (buf
, valbuf
, len
);
1052 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1053 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1057 /* Integral and pointer return values. */
1058 gdb_assert (sparc64_integral_or_pointer_p (type
));
1060 /* ??? Do we need to do any sign-extension here? */
1062 memcpy (buf
+ 8 - len
, valbuf
, len
);
1063 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
, buf
);
1067 static enum return_value_convention
1068 sparc64_return_value (struct gdbarch
*gdbarch
, struct type
*type
,
1069 struct regcache
*regcache
, gdb_byte
*readbuf
,
1070 const gdb_byte
*writebuf
)
1072 if (TYPE_LENGTH (type
) > 32)
1073 return RETURN_VALUE_STRUCT_CONVENTION
;
1076 sparc64_extract_return_value (type
, regcache
, readbuf
);
1078 sparc64_store_return_value (type
, regcache
, writebuf
);
1080 return RETURN_VALUE_REGISTER_CONVENTION
;
1085 sparc64_dwarf2_frame_init_reg (struct gdbarch
*gdbarch
, int regnum
,
1086 struct dwarf2_frame_state_reg
*reg
,
1087 struct frame_info
*next_frame
)
1091 case SPARC_G0_REGNUM
:
1092 /* Since %g0 is always zero, there is no point in saving it, and
1093 people will be inclined omit it from the CFI. Make sure we
1094 don't warn about that. */
1095 reg
->how
= DWARF2_FRAME_REG_SAME_VALUE
;
1097 case SPARC_SP_REGNUM
:
1098 reg
->how
= DWARF2_FRAME_REG_CFA
;
1100 case SPARC64_PC_REGNUM
:
1101 reg
->how
= DWARF2_FRAME_REG_RA_OFFSET
;
1102 reg
->loc
.offset
= 8;
1104 case SPARC64_NPC_REGNUM
:
1105 reg
->how
= DWARF2_FRAME_REG_RA_OFFSET
;
1106 reg
->loc
.offset
= 12;
1112 sparc64_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
1114 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1116 tdep
->pc_regnum
= SPARC64_PC_REGNUM
;
1117 tdep
->npc_regnum
= SPARC64_NPC_REGNUM
;
1119 /* This is what all the fuss is about. */
1120 set_gdbarch_long_bit (gdbarch
, 64);
1121 set_gdbarch_long_long_bit (gdbarch
, 64);
1122 set_gdbarch_ptr_bit (gdbarch
, 64);
1124 set_gdbarch_num_regs (gdbarch
, SPARC64_NUM_REGS
);
1125 set_gdbarch_register_name (gdbarch
, sparc64_register_name
);
1126 set_gdbarch_register_type (gdbarch
, sparc64_register_type
);
1127 set_gdbarch_num_pseudo_regs (gdbarch
, SPARC64_NUM_PSEUDO_REGS
);
1128 set_gdbarch_pseudo_register_read (gdbarch
, sparc64_pseudo_register_read
);
1129 set_gdbarch_pseudo_register_write (gdbarch
, sparc64_pseudo_register_write
);
1131 /* Register numbers of various important registers. */
1132 set_gdbarch_pc_regnum (gdbarch
, SPARC64_PC_REGNUM
); /* %pc */
1134 /* Call dummy code. */
1135 set_gdbarch_call_dummy_location (gdbarch
, AT_ENTRY_POINT
);
1136 set_gdbarch_push_dummy_code (gdbarch
, NULL
);
1137 set_gdbarch_push_dummy_call (gdbarch
, sparc64_push_dummy_call
);
1139 set_gdbarch_return_value (gdbarch
, sparc64_return_value
);
1140 set_gdbarch_stabs_argument_has_addr
1141 (gdbarch
, default_stabs_argument_has_addr
);
1143 set_gdbarch_skip_prologue (gdbarch
, sparc64_skip_prologue
);
1145 /* Hook in the DWARF CFI frame unwinder. */
1146 dwarf2_frame_set_init_reg (gdbarch
, sparc64_dwarf2_frame_init_reg
);
1147 /* FIXME: kettenis/20050423: Don't enable the unwinder until the
1148 StackGhost issues have been resolved. */
1150 frame_unwind_append_sniffer (gdbarch
, sparc64_frame_sniffer
);
1151 frame_base_set_default (gdbarch
, &sparc64_frame_base
);
1155 /* Helper functions for dealing with register sets. */
1157 #define TSTATE_CWP 0x000000000000001fULL
1158 #define TSTATE_ICC 0x0000000f00000000ULL
1159 #define TSTATE_XCC 0x000000f000000000ULL
1161 #define PSR_S 0x00000080
1162 #define PSR_ICC 0x00f00000
1163 #define PSR_VERS 0x0f000000
1164 #define PSR_IMPL 0xf0000000
1165 #define PSR_V8PLUS 0xff000000
1166 #define PSR_XCC 0x000f0000
1169 sparc64_supply_gregset (const struct sparc_gregset
*gregset
,
1170 struct regcache
*regcache
,
1171 int regnum
, const void *gregs
)
1173 int sparc32
= (gdbarch_ptr_bit (get_regcache_arch (regcache
)) == 32);
1174 const gdb_byte
*regs
= gregs
;
1179 if (regnum
== SPARC32_PSR_REGNUM
|| regnum
== -1)
1181 int offset
= gregset
->r_tstate_offset
;
1182 ULONGEST tstate
, psr
;
1185 tstate
= extract_unsigned_integer (regs
+ offset
, 8);
1186 psr
= ((tstate
& TSTATE_CWP
) | PSR_S
| ((tstate
& TSTATE_ICC
) >> 12)
1187 | ((tstate
& TSTATE_XCC
) >> 20) | PSR_V8PLUS
);
1188 store_unsigned_integer (buf
, 4, psr
);
1189 regcache_raw_supply (regcache
, SPARC32_PSR_REGNUM
, buf
);
1192 if (regnum
== SPARC32_PC_REGNUM
|| regnum
== -1)
1193 regcache_raw_supply (regcache
, SPARC32_PC_REGNUM
,
1194 regs
+ gregset
->r_pc_offset
+ 4);
1196 if (regnum
== SPARC32_NPC_REGNUM
|| regnum
== -1)
1197 regcache_raw_supply (regcache
, SPARC32_NPC_REGNUM
,
1198 regs
+ gregset
->r_npc_offset
+ 4);
1200 if (regnum
== SPARC32_Y_REGNUM
|| regnum
== -1)
1202 int offset
= gregset
->r_y_offset
+ 8 - gregset
->r_y_size
;
1203 regcache_raw_supply (regcache
, SPARC32_Y_REGNUM
, regs
+ offset
);
1208 if (regnum
== SPARC64_STATE_REGNUM
|| regnum
== -1)
1209 regcache_raw_supply (regcache
, SPARC64_STATE_REGNUM
,
1210 regs
+ gregset
->r_tstate_offset
);
1212 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== -1)
1213 regcache_raw_supply (regcache
, SPARC64_PC_REGNUM
,
1214 regs
+ gregset
->r_pc_offset
);
1216 if (regnum
== SPARC64_NPC_REGNUM
|| regnum
== -1)
1217 regcache_raw_supply (regcache
, SPARC64_NPC_REGNUM
,
1218 regs
+ gregset
->r_npc_offset
);
1220 if (regnum
== SPARC64_Y_REGNUM
|| regnum
== -1)
1225 memcpy (buf
+ 8 - gregset
->r_y_size
,
1226 regs
+ gregset
->r_y_offset
, gregset
->r_y_size
);
1227 regcache_raw_supply (regcache
, SPARC64_Y_REGNUM
, buf
);
1230 if ((regnum
== SPARC64_FPRS_REGNUM
|| regnum
== -1)
1231 && gregset
->r_fprs_offset
!= -1)
1232 regcache_raw_supply (regcache
, SPARC64_FPRS_REGNUM
,
1233 regs
+ gregset
->r_fprs_offset
);
1236 if (regnum
== SPARC_G0_REGNUM
|| regnum
== -1)
1237 regcache_raw_supply (regcache
, SPARC_G0_REGNUM
, NULL
);
1239 if ((regnum
>= SPARC_G1_REGNUM
&& regnum
<= SPARC_O7_REGNUM
) || regnum
== -1)
1241 int offset
= gregset
->r_g1_offset
;
1246 for (i
= SPARC_G1_REGNUM
; i
<= SPARC_O7_REGNUM
; i
++)
1248 if (regnum
== i
|| regnum
== -1)
1249 regcache_raw_supply (regcache
, i
, regs
+ offset
);
1254 if ((regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
) || regnum
== -1)
1256 /* Not all of the register set variants include Locals and
1257 Inputs. For those that don't, we read them off the stack. */
1258 if (gregset
->r_l0_offset
== -1)
1262 regcache_cooked_read_unsigned (regcache
, SPARC_SP_REGNUM
, &sp
);
1263 sparc_supply_rwindow (regcache
, sp
, regnum
);
1267 int offset
= gregset
->r_l0_offset
;
1272 for (i
= SPARC_L0_REGNUM
; i
<= SPARC_I7_REGNUM
; i
++)
1274 if (regnum
== i
|| regnum
== -1)
1275 regcache_raw_supply (regcache
, i
, regs
+ offset
);
1283 sparc64_collect_gregset (const struct sparc_gregset
*gregset
,
1284 const struct regcache
*regcache
,
1285 int regnum
, void *gregs
)
1287 int sparc32
= (gdbarch_ptr_bit (get_regcache_arch (regcache
)) == 32);
1288 gdb_byte
*regs
= gregs
;
1293 if (regnum
== SPARC32_PSR_REGNUM
|| regnum
== -1)
1295 int offset
= gregset
->r_tstate_offset
;
1296 ULONGEST tstate
, psr
;
1299 tstate
= extract_unsigned_integer (regs
+ offset
, 8);
1300 regcache_raw_collect (regcache
, SPARC32_PSR_REGNUM
, buf
);
1301 psr
= extract_unsigned_integer (buf
, 4);
1302 tstate
|= (psr
& PSR_ICC
) << 12;
1303 if ((psr
& (PSR_VERS
| PSR_IMPL
)) == PSR_V8PLUS
)
1304 tstate
|= (psr
& PSR_XCC
) << 20;
1305 store_unsigned_integer (buf
, 8, tstate
);
1306 memcpy (regs
+ offset
, buf
, 8);
1309 if (regnum
== SPARC32_PC_REGNUM
|| regnum
== -1)
1310 regcache_raw_collect (regcache
, SPARC32_PC_REGNUM
,
1311 regs
+ gregset
->r_pc_offset
+ 4);
1313 if (regnum
== SPARC32_NPC_REGNUM
|| regnum
== -1)
1314 regcache_raw_collect (regcache
, SPARC32_NPC_REGNUM
,
1315 regs
+ gregset
->r_npc_offset
+ 4);
1317 if (regnum
== SPARC32_Y_REGNUM
|| regnum
== -1)
1319 int offset
= gregset
->r_y_offset
+ 8 - gregset
->r_y_size
;
1320 regcache_raw_collect (regcache
, SPARC32_Y_REGNUM
, regs
+ offset
);
1325 if (regnum
== SPARC64_STATE_REGNUM
|| regnum
== -1)
1326 regcache_raw_collect (regcache
, SPARC64_STATE_REGNUM
,
1327 regs
+ gregset
->r_tstate_offset
);
1329 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== -1)
1330 regcache_raw_collect (regcache
, SPARC64_PC_REGNUM
,
1331 regs
+ gregset
->r_pc_offset
);
1333 if (regnum
== SPARC64_NPC_REGNUM
|| regnum
== -1)
1334 regcache_raw_collect (regcache
, SPARC64_NPC_REGNUM
,
1335 regs
+ gregset
->r_npc_offset
);
1337 if (regnum
== SPARC64_Y_REGNUM
|| regnum
== -1)
1341 regcache_raw_collect (regcache
, SPARC64_Y_REGNUM
, buf
);
1342 memcpy (regs
+ gregset
->r_y_offset
,
1343 buf
+ 8 - gregset
->r_y_size
, gregset
->r_y_size
);
1346 if ((regnum
== SPARC64_FPRS_REGNUM
|| regnum
== -1)
1347 && gregset
->r_fprs_offset
!= -1)
1348 regcache_raw_collect (regcache
, SPARC64_FPRS_REGNUM
,
1349 regs
+ gregset
->r_fprs_offset
);
1353 if ((regnum
>= SPARC_G1_REGNUM
&& regnum
<= SPARC_O7_REGNUM
) || regnum
== -1)
1355 int offset
= gregset
->r_g1_offset
;
1360 /* %g0 is always zero. */
1361 for (i
= SPARC_G1_REGNUM
; i
<= SPARC_O7_REGNUM
; i
++)
1363 if (regnum
== i
|| regnum
== -1)
1364 regcache_raw_collect (regcache
, i
, regs
+ offset
);
1369 if ((regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
) || regnum
== -1)
1371 /* Not all of the register set variants include Locals and
1372 Inputs. For those that don't, we read them off the stack. */
1373 if (gregset
->r_l0_offset
!= -1)
1375 int offset
= gregset
->r_l0_offset
;
1380 for (i
= SPARC_L0_REGNUM
; i
<= SPARC_I7_REGNUM
; i
++)
1382 if (regnum
== i
|| regnum
== -1)
1383 regcache_raw_collect (regcache
, i
, regs
+ offset
);
1391 sparc64_supply_fpregset (struct regcache
*regcache
,
1392 int regnum
, const void *fpregs
)
1394 int sparc32
= (gdbarch_ptr_bit (get_regcache_arch (regcache
)) == 32);
1395 const gdb_byte
*regs
= fpregs
;
1398 for (i
= 0; i
< 32; i
++)
1400 if (regnum
== (SPARC_F0_REGNUM
+ i
) || regnum
== -1)
1401 regcache_raw_supply (regcache
, SPARC_F0_REGNUM
+ i
, regs
+ (i
* 4));
1406 if (regnum
== SPARC32_FSR_REGNUM
|| regnum
== -1)
1407 regcache_raw_supply (regcache
, SPARC32_FSR_REGNUM
,
1408 regs
+ (32 * 4) + (16 * 8) + 4);
1412 for (i
= 0; i
< 16; i
++)
1414 if (regnum
== (SPARC64_F32_REGNUM
+ i
) || regnum
== -1)
1415 regcache_raw_supply (regcache
, SPARC64_F32_REGNUM
+ i
,
1416 regs
+ (32 * 4) + (i
* 8));
1419 if (regnum
== SPARC64_FSR_REGNUM
|| regnum
== -1)
1420 regcache_raw_supply (regcache
, SPARC64_FSR_REGNUM
,
1421 regs
+ (32 * 4) + (16 * 8));
1426 sparc64_collect_fpregset (const struct regcache
*regcache
,
1427 int regnum
, void *fpregs
)
1429 int sparc32
= (gdbarch_ptr_bit (get_regcache_arch (regcache
)) == 32);
1430 gdb_byte
*regs
= fpregs
;
1433 for (i
= 0; i
< 32; i
++)
1435 if (regnum
== (SPARC_F0_REGNUM
+ i
) || regnum
== -1)
1436 regcache_raw_collect (regcache
, SPARC_F0_REGNUM
+ i
, regs
+ (i
* 4));
1441 if (regnum
== SPARC32_FSR_REGNUM
|| regnum
== -1)
1442 regcache_raw_collect (regcache
, SPARC32_FSR_REGNUM
,
1443 regs
+ (32 * 4) + (16 * 8) + 4);
1447 for (i
= 0; i
< 16; i
++)
1449 if (regnum
== (SPARC64_F32_REGNUM
+ i
) || regnum
== -1)
1450 regcache_raw_collect (regcache
, SPARC64_F32_REGNUM
+ i
,
1451 regs
+ (32 * 4) + (i
* 8));
1454 if (regnum
== SPARC64_FSR_REGNUM
|| regnum
== -1)
1455 regcache_raw_collect (regcache
, SPARC64_FSR_REGNUM
,
1456 regs
+ (32 * 4) + (16 * 8));
1461 /* Provide a prototype to silence -Wmissing-prototypes. */
1462 void _initialize_sparc64_tdep (void);
1465 _initialize_sparc64_tdep (void)
1467 /* Initialize the UltraSPARC-specific register types. */
1468 sparc64_init_types();