1 /* Target-dependent code for UltraSPARC.
3 Copyright (C) 2003, 2004, 2005 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 2 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, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
23 #include "arch-utils.h"
24 #include "dwarf2-frame.h"
25 #include "floatformat.h"
27 #include "frame-base.h"
28 #include "frame-unwind.h"
39 #include "gdb_assert.h"
40 #include "gdb_string.h"
42 #include "sparc64-tdep.h"
44 /* This file implements the The SPARC 64-bit ABI as defined by the
45 section "Low-Level System Information" of the SPARC Compliance
46 Definition (SCD) 2.4.1, which is the 64-bit System V psABI for
49 /* Please use the sparc32_-prefix for 32-bit specific code, the
50 sparc64_-prefix for 64-bit specific code and the sparc_-prefix for
51 code can handle both. */
53 /* The functions on this page are intended to be used to classify
54 function arguments. */
56 /* Check whether TYPE is "Integral or Pointer". */
59 sparc64_integral_or_pointer_p (const struct type
*type
)
61 switch (TYPE_CODE (type
))
69 int len
= TYPE_LENGTH (type
);
70 gdb_assert (len
== 1 || len
== 2 || len
== 4 || len
== 8);
76 int len
= TYPE_LENGTH (type
);
77 gdb_assert (len
== 8);
87 /* Check whether TYPE is "Floating". */
90 sparc64_floating_p (const struct type
*type
)
92 switch (TYPE_CODE (type
))
96 int len
= TYPE_LENGTH (type
);
97 gdb_assert (len
== 4 || len
== 8 || len
== 16);
107 /* Check whether TYPE is "Structure or Union". */
110 sparc64_structure_or_union_p (const struct type
*type
)
112 switch (TYPE_CODE (type
))
114 case TYPE_CODE_STRUCT
:
115 case TYPE_CODE_UNION
:
124 /* Register information. */
126 struct sparc64_register_info
132 static struct sparc64_register_info sparc64_register_info
[] =
134 { "g0", &builtin_type_int64
},
135 { "g1", &builtin_type_int64
},
136 { "g2", &builtin_type_int64
},
137 { "g3", &builtin_type_int64
},
138 { "g4", &builtin_type_int64
},
139 { "g5", &builtin_type_int64
},
140 { "g6", &builtin_type_int64
},
141 { "g7", &builtin_type_int64
},
143 { "o0", &builtin_type_int64
},
144 { "o1", &builtin_type_int64
},
145 { "o2", &builtin_type_int64
},
146 { "o3", &builtin_type_int64
},
147 { "o4", &builtin_type_int64
},
148 { "o5", &builtin_type_int64
},
149 { "sp", &builtin_type_void_data_ptr
},
150 { "o7", &builtin_type_int64
},
152 { "l0", &builtin_type_int64
},
153 { "l1", &builtin_type_int64
},
154 { "l2", &builtin_type_int64
},
155 { "l3", &builtin_type_int64
},
156 { "l4", &builtin_type_int64
},
157 { "l5", &builtin_type_int64
},
158 { "l6", &builtin_type_int64
},
159 { "l7", &builtin_type_int64
},
161 { "i0", &builtin_type_int64
},
162 { "i1", &builtin_type_int64
},
163 { "i2", &builtin_type_int64
},
164 { "i3", &builtin_type_int64
},
165 { "i4", &builtin_type_int64
},
166 { "i5", &builtin_type_int64
},
167 { "fp", &builtin_type_void_data_ptr
},
168 { "i7", &builtin_type_int64
},
170 { "f0", &builtin_type_float
},
171 { "f1", &builtin_type_float
},
172 { "f2", &builtin_type_float
},
173 { "f3", &builtin_type_float
},
174 { "f4", &builtin_type_float
},
175 { "f5", &builtin_type_float
},
176 { "f6", &builtin_type_float
},
177 { "f7", &builtin_type_float
},
178 { "f8", &builtin_type_float
},
179 { "f9", &builtin_type_float
},
180 { "f10", &builtin_type_float
},
181 { "f11", &builtin_type_float
},
182 { "f12", &builtin_type_float
},
183 { "f13", &builtin_type_float
},
184 { "f14", &builtin_type_float
},
185 { "f15", &builtin_type_float
},
186 { "f16", &builtin_type_float
},
187 { "f17", &builtin_type_float
},
188 { "f18", &builtin_type_float
},
189 { "f19", &builtin_type_float
},
190 { "f20", &builtin_type_float
},
191 { "f21", &builtin_type_float
},
192 { "f22", &builtin_type_float
},
193 { "f23", &builtin_type_float
},
194 { "f24", &builtin_type_float
},
195 { "f25", &builtin_type_float
},
196 { "f26", &builtin_type_float
},
197 { "f27", &builtin_type_float
},
198 { "f28", &builtin_type_float
},
199 { "f29", &builtin_type_float
},
200 { "f30", &builtin_type_float
},
201 { "f31", &builtin_type_float
},
202 { "f32", &builtin_type_double
},
203 { "f34", &builtin_type_double
},
204 { "f36", &builtin_type_double
},
205 { "f38", &builtin_type_double
},
206 { "f40", &builtin_type_double
},
207 { "f42", &builtin_type_double
},
208 { "f44", &builtin_type_double
},
209 { "f46", &builtin_type_double
},
210 { "f48", &builtin_type_double
},
211 { "f50", &builtin_type_double
},
212 { "f52", &builtin_type_double
},
213 { "f54", &builtin_type_double
},
214 { "f56", &builtin_type_double
},
215 { "f58", &builtin_type_double
},
216 { "f60", &builtin_type_double
},
217 { "f62", &builtin_type_double
},
219 { "pc", &builtin_type_void_func_ptr
},
220 { "npc", &builtin_type_void_func_ptr
},
222 /* This raw register contains the contents of %cwp, %pstate, %asi
223 and %ccr as laid out in a %tstate register. */
224 /* FIXME: Give it a name until we start using register groups. */
225 { "state", &builtin_type_int64
},
227 { "fsr", &builtin_type_int64
},
228 { "fprs", &builtin_type_int64
},
230 /* "Although Y is a 64-bit register, its high-order 32 bits are
231 reserved and always read as 0." */
232 { "y", &builtin_type_int64
}
235 /* Total number of registers. */
236 #define SPARC64_NUM_REGS ARRAY_SIZE (sparc64_register_info)
238 /* We provide the aliases %d0..%d62 and %q0..%q60 for the floating
239 registers as "psuedo" registers. */
241 static struct sparc64_register_info sparc64_pseudo_register_info
[] =
243 { "cwp", &builtin_type_int64
},
244 { "pstate", &builtin_type_int64
},
245 { "asi", &builtin_type_int64
},
246 { "ccr", &builtin_type_int64
},
248 { "d0", &builtin_type_double
},
249 { "d2", &builtin_type_double
},
250 { "d4", &builtin_type_double
},
251 { "d6", &builtin_type_double
},
252 { "d8", &builtin_type_double
},
253 { "d10", &builtin_type_double
},
254 { "d12", &builtin_type_double
},
255 { "d14", &builtin_type_double
},
256 { "d16", &builtin_type_double
},
257 { "d18", &builtin_type_double
},
258 { "d20", &builtin_type_double
},
259 { "d22", &builtin_type_double
},
260 { "d24", &builtin_type_double
},
261 { "d26", &builtin_type_double
},
262 { "d28", &builtin_type_double
},
263 { "d30", &builtin_type_double
},
264 { "d32", &builtin_type_double
},
265 { "d34", &builtin_type_double
},
266 { "d36", &builtin_type_double
},
267 { "d38", &builtin_type_double
},
268 { "d40", &builtin_type_double
},
269 { "d42", &builtin_type_double
},
270 { "d44", &builtin_type_double
},
271 { "d46", &builtin_type_double
},
272 { "d48", &builtin_type_double
},
273 { "d50", &builtin_type_double
},
274 { "d52", &builtin_type_double
},
275 { "d54", &builtin_type_double
},
276 { "d56", &builtin_type_double
},
277 { "d58", &builtin_type_double
},
278 { "d60", &builtin_type_double
},
279 { "d62", &builtin_type_double
},
281 { "q0", &builtin_type_long_double
},
282 { "q4", &builtin_type_long_double
},
283 { "q8", &builtin_type_long_double
},
284 { "q12", &builtin_type_long_double
},
285 { "q16", &builtin_type_long_double
},
286 { "q20", &builtin_type_long_double
},
287 { "q24", &builtin_type_long_double
},
288 { "q28", &builtin_type_long_double
},
289 { "q32", &builtin_type_long_double
},
290 { "q36", &builtin_type_long_double
},
291 { "q40", &builtin_type_long_double
},
292 { "q44", &builtin_type_long_double
},
293 { "q48", &builtin_type_long_double
},
294 { "q52", &builtin_type_long_double
},
295 { "q56", &builtin_type_long_double
},
296 { "q60", &builtin_type_long_double
}
299 /* Total number of pseudo registers. */
300 #define SPARC64_NUM_PSEUDO_REGS ARRAY_SIZE (sparc64_pseudo_register_info)
302 /* Return the name of register REGNUM. */
305 sparc64_register_name (int regnum
)
307 if (regnum
>= 0 && regnum
< SPARC64_NUM_REGS
)
308 return sparc64_register_info
[regnum
].name
;
310 if (regnum
>= SPARC64_NUM_REGS
311 && regnum
< SPARC64_NUM_REGS
+ SPARC64_NUM_PSEUDO_REGS
)
312 return sparc64_pseudo_register_info
[regnum
- SPARC64_NUM_REGS
].name
;
317 /* Return the GDB type object for the "standard" data type of data in
321 sparc64_register_type (struct gdbarch
*gdbarch
, int regnum
)
323 if (regnum
>= SPARC64_NUM_REGS
324 && regnum
< SPARC64_NUM_REGS
+ SPARC64_NUM_PSEUDO_REGS
)
325 return *sparc64_pseudo_register_info
[regnum
- SPARC64_NUM_REGS
].type
;
327 gdb_assert (regnum
>= 0 && regnum
< SPARC64_NUM_REGS
);
328 return *sparc64_register_info
[regnum
].type
;
332 sparc64_pseudo_register_read (struct gdbarch
*gdbarch
,
333 struct regcache
*regcache
,
334 int regnum
, gdb_byte
*buf
)
336 gdb_assert (regnum
>= SPARC64_NUM_REGS
);
338 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D30_REGNUM
)
340 regnum
= SPARC_F0_REGNUM
+ 2 * (regnum
- SPARC64_D0_REGNUM
);
341 regcache_raw_read (regcache
, regnum
, buf
);
342 regcache_raw_read (regcache
, regnum
+ 1, buf
+ 4);
344 else if (regnum
>= SPARC64_D32_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
346 regnum
= SPARC64_F32_REGNUM
+ (regnum
- SPARC64_D32_REGNUM
);
347 regcache_raw_read (regcache
, regnum
, buf
);
349 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q28_REGNUM
)
351 regnum
= SPARC_F0_REGNUM
+ 4 * (regnum
- SPARC64_Q0_REGNUM
);
352 regcache_raw_read (regcache
, regnum
, buf
);
353 regcache_raw_read (regcache
, regnum
+ 1, buf
+ 4);
354 regcache_raw_read (regcache
, regnum
+ 2, buf
+ 8);
355 regcache_raw_read (regcache
, regnum
+ 3, buf
+ 12);
357 else if (regnum
>= SPARC64_Q32_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
359 regnum
= SPARC64_F32_REGNUM
+ 2 * (regnum
- SPARC64_Q32_REGNUM
);
360 regcache_raw_read (regcache
, regnum
, buf
);
361 regcache_raw_read (regcache
, regnum
+ 1, buf
+ 8);
363 else if (regnum
== SPARC64_CWP_REGNUM
364 || regnum
== SPARC64_PSTATE_REGNUM
365 || regnum
== SPARC64_ASI_REGNUM
366 || regnum
== SPARC64_CCR_REGNUM
)
370 regcache_raw_read_unsigned (regcache
, SPARC64_STATE_REGNUM
, &state
);
373 case SPARC64_CWP_REGNUM
:
374 state
= (state
>> 0) & ((1 << 5) - 1);
376 case SPARC64_PSTATE_REGNUM
:
377 state
= (state
>> 8) & ((1 << 12) - 1);
379 case SPARC64_ASI_REGNUM
:
380 state
= (state
>> 24) & ((1 << 8) - 1);
382 case SPARC64_CCR_REGNUM
:
383 state
= (state
>> 32) & ((1 << 8) - 1);
386 store_unsigned_integer (buf
, 8, state
);
391 sparc64_pseudo_register_write (struct gdbarch
*gdbarch
,
392 struct regcache
*regcache
,
393 int regnum
, const gdb_byte
*buf
)
395 gdb_assert (regnum
>= SPARC64_NUM_REGS
);
397 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D30_REGNUM
)
399 regnum
= SPARC_F0_REGNUM
+ 2 * (regnum
- SPARC64_D0_REGNUM
);
400 regcache_raw_write (regcache
, regnum
, buf
);
401 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 4);
403 else if (regnum
>= SPARC64_D32_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
405 regnum
= SPARC64_F32_REGNUM
+ (regnum
- SPARC64_D32_REGNUM
);
406 regcache_raw_write (regcache
, regnum
, buf
);
408 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q28_REGNUM
)
410 regnum
= SPARC_F0_REGNUM
+ 4 * (regnum
- SPARC64_Q0_REGNUM
);
411 regcache_raw_write (regcache
, regnum
, buf
);
412 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 4);
413 regcache_raw_write (regcache
, regnum
+ 2, buf
+ 8);
414 regcache_raw_write (regcache
, regnum
+ 3, buf
+ 12);
416 else if (regnum
>= SPARC64_Q32_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
418 regnum
= SPARC64_F32_REGNUM
+ 2 * (regnum
- SPARC64_Q32_REGNUM
);
419 regcache_raw_write (regcache
, regnum
, buf
);
420 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 8);
422 else if (regnum
== SPARC64_CWP_REGNUM
423 || regnum
== SPARC64_PSTATE_REGNUM
424 || regnum
== SPARC64_ASI_REGNUM
425 || regnum
== SPARC64_CCR_REGNUM
)
427 ULONGEST state
, bits
;
429 regcache_raw_read_unsigned (regcache
, SPARC64_STATE_REGNUM
, &state
);
430 bits
= extract_unsigned_integer (buf
, 8);
433 case SPARC64_CWP_REGNUM
:
434 state
|= ((bits
& ((1 << 5) - 1)) << 0);
436 case SPARC64_PSTATE_REGNUM
:
437 state
|= ((bits
& ((1 << 12) - 1)) << 8);
439 case SPARC64_ASI_REGNUM
:
440 state
|= ((bits
& ((1 << 8) - 1)) << 24);
442 case SPARC64_CCR_REGNUM
:
443 state
|= ((bits
& ((1 << 8) - 1)) << 32);
446 regcache_raw_write_unsigned (regcache
, SPARC64_STATE_REGNUM
, state
);
451 /* Return PC of first real instruction of the function starting at
455 sparc64_skip_prologue (CORE_ADDR start_pc
)
457 struct symtab_and_line sal
;
458 CORE_ADDR func_start
, func_end
;
459 struct sparc_frame_cache cache
;
461 /* This is the preferred method, find the end of the prologue by
462 using the debugging information. */
463 if (find_pc_partial_function (start_pc
, NULL
, &func_start
, &func_end
))
465 sal
= find_pc_line (func_start
, 0);
467 if (sal
.end
< func_end
468 && start_pc
<= sal
.end
)
472 return sparc_analyze_prologue (start_pc
, 0xffffffffffffffffULL
, &cache
);
477 static struct sparc_frame_cache
*
478 sparc64_frame_cache (struct frame_info
*next_frame
, void **this_cache
)
480 return sparc_frame_cache (next_frame
, this_cache
);
484 sparc64_frame_this_id (struct frame_info
*next_frame
, void **this_cache
,
485 struct frame_id
*this_id
)
487 struct sparc_frame_cache
*cache
=
488 sparc64_frame_cache (next_frame
, this_cache
);
490 /* This marks the outermost frame. */
491 if (cache
->base
== 0)
494 (*this_id
) = frame_id_build (cache
->base
, cache
->pc
);
498 sparc64_frame_prev_register (struct frame_info
*next_frame
, void **this_cache
,
499 int regnum
, int *optimizedp
,
500 enum lval_type
*lvalp
, CORE_ADDR
*addrp
,
501 int *realnump
, gdb_byte
*valuep
)
503 struct sparc_frame_cache
*cache
=
504 sparc64_frame_cache (next_frame
, this_cache
);
506 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== SPARC64_NPC_REGNUM
)
514 CORE_ADDR pc
= (regnum
== SPARC64_NPC_REGNUM
) ? 4 : 0;
516 regnum
= cache
->frameless_p
? SPARC_O7_REGNUM
: SPARC_I7_REGNUM
;
517 pc
+= frame_unwind_register_unsigned (next_frame
, regnum
) + 8;
518 store_unsigned_integer (valuep
, 8, pc
);
523 /* Handle StackGhost. */
525 ULONGEST wcookie
= sparc_fetch_wcookie ();
527 if (wcookie
!= 0 && !cache
->frameless_p
&& regnum
== SPARC_I7_REGNUM
)
535 CORE_ADDR addr
= cache
->base
+ (regnum
- SPARC_L0_REGNUM
) * 8;
538 /* Read the value in from memory. */
539 i7
= get_frame_memory_unsigned (next_frame
, addr
, 8);
540 store_unsigned_integer (valuep
, 8, i7
^ wcookie
);
546 /* The previous frame's `local' and `in' registers have been saved
547 in the register save area. */
548 if (!cache
->frameless_p
549 && regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
)
552 *lvalp
= lval_memory
;
553 *addrp
= cache
->base
+ (regnum
- SPARC_L0_REGNUM
) * 8;
557 struct gdbarch
*gdbarch
= get_frame_arch (next_frame
);
559 /* Read the value in from memory. */
560 read_memory (*addrp
, valuep
, register_size (gdbarch
, regnum
));
565 /* The previous frame's `out' registers are accessable as the
566 current frame's `in' registers. */
567 if (!cache
->frameless_p
568 && regnum
>= SPARC_O0_REGNUM
&& regnum
<= SPARC_O7_REGNUM
)
569 regnum
+= (SPARC_I0_REGNUM
- SPARC_O0_REGNUM
);
572 *lvalp
= lval_register
;
576 frame_unwind_register (next_frame
, regnum
, valuep
);
579 static const struct frame_unwind sparc64_frame_unwind
=
582 sparc64_frame_this_id
,
583 sparc64_frame_prev_register
586 static const struct frame_unwind
*
587 sparc64_frame_sniffer (struct frame_info
*next_frame
)
589 return &sparc64_frame_unwind
;
594 sparc64_frame_base_address (struct frame_info
*next_frame
, void **this_cache
)
596 struct sparc_frame_cache
*cache
=
597 sparc64_frame_cache (next_frame
, this_cache
);
602 static const struct frame_base sparc64_frame_base
=
604 &sparc64_frame_unwind
,
605 sparc64_frame_base_address
,
606 sparc64_frame_base_address
,
607 sparc64_frame_base_address
610 /* Check whether TYPE must be 16-byte aligned. */
613 sparc64_16_byte_align_p (struct type
*type
)
615 if (sparc64_floating_p (type
) && TYPE_LENGTH (type
) == 16)
618 if (sparc64_structure_or_union_p (type
))
622 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
624 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
626 if (sparc64_16_byte_align_p (subtype
))
634 /* Store floating fields of element ELEMENT of an "parameter array"
635 that has type TYPE and is stored at BITPOS in VALBUF in the
636 apropriate registers of REGCACHE. This function can be called
637 recursively and therefore handles floating types in addition to
641 sparc64_store_floating_fields (struct regcache
*regcache
, struct type
*type
,
642 const gdb_byte
*valbuf
, int element
, int bitpos
)
644 gdb_assert (element
< 16);
646 if (sparc64_floating_p (type
))
648 int len
= TYPE_LENGTH (type
);
653 gdb_assert (bitpos
== 0);
654 gdb_assert ((element
% 2) == 0);
656 regnum
= SPARC64_Q0_REGNUM
+ element
/ 2;
657 regcache_cooked_write (regcache
, regnum
, valbuf
);
661 gdb_assert (bitpos
== 0 || bitpos
== 64);
663 regnum
= SPARC64_D0_REGNUM
+ element
+ bitpos
/ 64;
664 regcache_cooked_write (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
668 gdb_assert (len
== 4);
669 gdb_assert (bitpos
% 32 == 0 && bitpos
>= 0 && bitpos
< 128);
671 regnum
= SPARC_F0_REGNUM
+ element
* 2 + bitpos
/ 32;
672 regcache_cooked_write (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
675 else if (sparc64_structure_or_union_p (type
))
679 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
681 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
682 int subpos
= bitpos
+ TYPE_FIELD_BITPOS (type
, i
);
684 sparc64_store_floating_fields (regcache
, subtype
, valbuf
,
688 /* GCC has an interesting bug. If TYPE is a structure that has
689 a single `float' member, GCC doesn't treat it as a structure
690 at all, but rather as an ordinary `float' argument. This
691 argument will be stored in %f1, as required by the psABI.
692 However, as a member of a structure the psABI requires it to
693 be stored in %f0. This bug is present in GCC 3.3.2, but
694 probably in older releases to. To appease GCC, if a
695 structure has only a single `float' member, we store its
696 value in %f1 too (we already have stored in %f0). */
697 if (TYPE_NFIELDS (type
) == 1)
699 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, 0));
701 if (sparc64_floating_p (subtype
) && TYPE_LENGTH (subtype
) == 4)
702 regcache_cooked_write (regcache
, SPARC_F1_REGNUM
, valbuf
);
707 /* Fetch floating fields from a variable of type TYPE from the
708 appropriate registers for BITPOS in REGCACHE and store it at BITPOS
709 in VALBUF. This function can be called recursively and therefore
710 handles floating types in addition to structures. */
713 sparc64_extract_floating_fields (struct regcache
*regcache
, struct type
*type
,
714 gdb_byte
*valbuf
, int bitpos
)
716 if (sparc64_floating_p (type
))
718 int len
= TYPE_LENGTH (type
);
723 gdb_assert (bitpos
== 0 || bitpos
== 128);
725 regnum
= SPARC64_Q0_REGNUM
+ bitpos
/ 128;
726 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
730 gdb_assert (bitpos
% 64 == 0 && bitpos
>= 0 && bitpos
< 256);
732 regnum
= SPARC64_D0_REGNUM
+ bitpos
/ 64;
733 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
737 gdb_assert (len
== 4);
738 gdb_assert (bitpos
% 32 == 0 && bitpos
>= 0 && bitpos
< 256);
740 regnum
= SPARC_F0_REGNUM
+ bitpos
/ 32;
741 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
744 else if (sparc64_structure_or_union_p (type
))
748 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
750 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
751 int subpos
= bitpos
+ TYPE_FIELD_BITPOS (type
, i
);
753 sparc64_extract_floating_fields (regcache
, subtype
, valbuf
, subpos
);
758 /* Store the NARGS arguments ARGS and STRUCT_ADDR (if STRUCT_RETURN is
759 non-zero) in REGCACHE and on the stack (starting from address SP). */
762 sparc64_store_arguments (struct regcache
*regcache
, int nargs
,
763 struct value
**args
, CORE_ADDR sp
,
764 int struct_return
, CORE_ADDR struct_addr
)
766 /* Number of extended words in the "parameter array". */
767 int num_elements
= 0;
771 /* Take BIAS into account. */
774 /* First we calculate the number of extended words in the "parameter
775 array". While doing so we also convert some of the arguments. */
780 for (i
= 0; i
< nargs
; i
++)
782 struct type
*type
= value_type (args
[i
]);
783 int len
= TYPE_LENGTH (type
);
785 if (sparc64_structure_or_union_p (type
))
787 /* Structure or Union arguments. */
790 if (num_elements
% 2 && sparc64_16_byte_align_p (type
))
792 num_elements
+= ((len
+ 7) / 8);
796 /* The psABI says that "Structures or unions larger than
797 sixteen bytes are copied by the caller and passed
798 indirectly; the caller will pass the address of a
799 correctly aligned structure value. This sixty-four
800 bit address will occupy one word in the parameter
801 array, and may be promoted to an %o register like any
802 other pointer value." Allocate memory for these
803 values on the stack. */
806 /* Use 16-byte alignment for these values. That's
807 always correct, and wasting a few bytes shouldn't be
811 write_memory (sp
, value_contents (args
[i
]), len
);
812 args
[i
] = value_from_pointer (lookup_pointer_type (type
), sp
);
816 else if (sparc64_floating_p (type
))
818 /* Floating arguments. */
822 /* The psABI says that "Each quad-precision parameter
823 value will be assigned to two extended words in the
827 /* The psABI says that "Long doubles must be
828 quad-aligned, and thus a hole might be introduced
829 into the parameter array to force alignment." Skip
830 an element if necessary. */
831 if (num_elements
% 2)
839 /* Integral and pointer arguments. */
840 gdb_assert (sparc64_integral_or_pointer_p (type
));
842 /* The psABI says that "Each argument value of integral type
843 smaller than an extended word will be widened by the
844 caller to an extended word according to the signed-ness
845 of the argument type." */
847 args
[i
] = value_cast (builtin_type_int64
, args
[i
]);
852 /* Allocate the "parameter array". */
853 sp
-= num_elements
* 8;
855 /* The psABI says that "Every stack frame must be 16-byte aligned." */
858 /* Now we store the arguments in to the "paramater array". Some
859 Integer or Pointer arguments and Structure or Union arguments
860 will be passed in %o registers. Some Floating arguments and
861 floating members of structures are passed in floating-point
862 registers. However, for functions with variable arguments,
863 floating arguments are stored in an %0 register, and for
864 functions without a prototype floating arguments are stored in
865 both a floating-point and an %o registers, or a floating-point
866 register and memory. To simplify the logic here we always pass
867 arguments in memory, an %o register, and a floating-point
868 register if appropriate. This should be no problem since the
869 contents of any unused memory or registers in the "parameter
870 array" are undefined. */
874 regcache_cooked_write_unsigned (regcache
, SPARC_O0_REGNUM
, struct_addr
);
878 for (i
= 0; i
< nargs
; i
++)
880 const gdb_byte
*valbuf
= value_contents (args
[i
]);
881 struct type
*type
= value_type (args
[i
]);
882 int len
= TYPE_LENGTH (type
);
886 if (sparc64_structure_or_union_p (type
))
888 /* Structure or Union arguments. */
889 gdb_assert (len
<= 16);
890 memset (buf
, 0, sizeof (buf
));
891 valbuf
= memcpy (buf
, valbuf
, len
);
893 if (element
% 2 && sparc64_16_byte_align_p (type
))
898 regnum
= SPARC_O0_REGNUM
+ element
;
899 if (len
> 8 && element
< 5)
900 regcache_cooked_write (regcache
, regnum
+ 1, valbuf
+ 8);
904 sparc64_store_floating_fields (regcache
, type
, valbuf
, element
, 0);
906 else if (sparc64_floating_p (type
))
908 /* Floating arguments. */
914 regnum
= SPARC64_Q0_REGNUM
+ element
/ 2;
919 regnum
= SPARC64_D0_REGNUM
+ element
;
923 /* The psABI says "Each single-precision parameter value
924 will be assigned to one extended word in the
925 parameter array, and right-justified within that
926 word; the left half (even floatregister) is
927 undefined." Even though the psABI says that "the
928 left half is undefined", set it to zero here. */
930 memcpy (buf
+ 4, valbuf
, 4);
934 regnum
= SPARC64_D0_REGNUM
+ element
;
939 /* Integral and pointer arguments. */
940 gdb_assert (len
== 8);
942 regnum
= SPARC_O0_REGNUM
+ element
;
947 regcache_cooked_write (regcache
, regnum
, valbuf
);
949 /* If we're storing the value in a floating-point register,
950 also store it in the corresponding %0 register(s). */
951 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D10_REGNUM
)
953 gdb_assert (element
< 6);
954 regnum
= SPARC_O0_REGNUM
+ element
;
955 regcache_cooked_write (regcache
, regnum
, valbuf
);
957 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q8_REGNUM
)
959 gdb_assert (element
< 6);
960 regnum
= SPARC_O0_REGNUM
+ element
;
961 regcache_cooked_write (regcache
, regnum
, valbuf
);
962 regcache_cooked_write (regcache
, regnum
+ 1, valbuf
+ 8);
966 /* Always store the argument in memory. */
967 write_memory (sp
+ element
* 8, valbuf
, len
);
968 element
+= ((len
+ 7) / 8);
971 gdb_assert (element
== num_elements
);
973 /* Take BIAS into account. */
979 sparc64_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
980 struct regcache
*regcache
, CORE_ADDR bp_addr
,
981 int nargs
, struct value
**args
, CORE_ADDR sp
,
982 int struct_return
, CORE_ADDR struct_addr
)
984 /* Set return address. */
985 regcache_cooked_write_unsigned (regcache
, SPARC_O7_REGNUM
, bp_addr
- 8);
987 /* Set up function arguments. */
988 sp
= sparc64_store_arguments (regcache
, nargs
, args
, sp
,
989 struct_return
, struct_addr
);
991 /* Allocate the register save area. */
994 /* Stack should be 16-byte aligned at this point. */
995 gdb_assert ((sp
+ BIAS
) % 16 == 0);
997 /* Finally, update the stack pointer. */
998 regcache_cooked_write_unsigned (regcache
, SPARC_SP_REGNUM
, sp
);
1004 /* Extract from an array REGBUF containing the (raw) register state, a
1005 function return value of TYPE, and copy that into VALBUF. */
1008 sparc64_extract_return_value (struct type
*type
, struct regcache
*regcache
,
1011 int len
= TYPE_LENGTH (type
);
1015 if (sparc64_structure_or_union_p (type
))
1017 /* Structure or Union return values. */
1018 gdb_assert (len
<= 32);
1020 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1021 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1022 if (TYPE_CODE (type
) != TYPE_CODE_UNION
)
1023 sparc64_extract_floating_fields (regcache
, type
, buf
, 0);
1024 memcpy (valbuf
, buf
, len
);
1026 else if (sparc64_floating_p (type
))
1028 /* Floating return values. */
1029 for (i
= 0; i
< len
/ 4; i
++)
1030 regcache_cooked_read (regcache
, SPARC_F0_REGNUM
+ i
, buf
+ i
* 4);
1031 memcpy (valbuf
, buf
, len
);
1035 /* Integral and pointer return values. */
1036 gdb_assert (sparc64_integral_or_pointer_p (type
));
1038 /* Just stripping off any unused bytes should preserve the
1039 signed-ness just fine. */
1040 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
, buf
);
1041 memcpy (valbuf
, buf
+ 8 - len
, len
);
1045 /* Write into the appropriate registers a function return value stored
1046 in VALBUF of type TYPE. */
1049 sparc64_store_return_value (struct type
*type
, struct regcache
*regcache
,
1050 const gdb_byte
*valbuf
)
1052 int len
= TYPE_LENGTH (type
);
1056 if (sparc64_structure_or_union_p (type
))
1058 /* Structure or Union return values. */
1059 gdb_assert (len
<= 32);
1061 /* Simplify matters by storing the complete value (including
1062 floating members) into %o0 and %o1. Floating members are
1063 also store in the appropriate floating-point registers. */
1064 memset (buf
, 0, sizeof (buf
));
1065 memcpy (buf
, valbuf
, len
);
1066 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1067 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1068 if (TYPE_CODE (type
) != TYPE_CODE_UNION
)
1069 sparc64_store_floating_fields (regcache
, type
, buf
, 0, 0);
1071 else if (sparc64_floating_p (type
))
1073 /* Floating return values. */
1074 memcpy (buf
, valbuf
, len
);
1075 for (i
= 0; i
< len
/ 4; i
++)
1076 regcache_cooked_write (regcache
, SPARC_F0_REGNUM
+ i
, buf
+ i
* 4);
1080 /* Integral and pointer return values. */
1081 gdb_assert (sparc64_integral_or_pointer_p (type
));
1083 /* ??? Do we need to do any sign-extension here? */
1085 memcpy (buf
+ 8 - len
, valbuf
, len
);
1086 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
, buf
);
1090 static enum return_value_convention
1091 sparc64_return_value (struct gdbarch
*gdbarch
, struct type
*type
,
1092 struct regcache
*regcache
, gdb_byte
*readbuf
,
1093 const gdb_byte
*writebuf
)
1095 if (TYPE_LENGTH (type
) > 32)
1096 return RETURN_VALUE_STRUCT_CONVENTION
;
1099 sparc64_extract_return_value (type
, regcache
, readbuf
);
1101 sparc64_store_return_value (type
, regcache
, writebuf
);
1103 return RETURN_VALUE_REGISTER_CONVENTION
;
1108 sparc64_dwarf2_frame_init_reg (struct gdbarch
*gdbarch
, int regnum
,
1109 struct dwarf2_frame_state_reg
*reg
)
1113 case SPARC_G0_REGNUM
:
1114 /* Since %g0 is always zero, there is no point in saving it, and
1115 people will be inclined omit it from the CFI. Make sure we
1116 don't warn about that. */
1117 reg
->how
= DWARF2_FRAME_REG_SAME_VALUE
;
1119 case SPARC_SP_REGNUM
:
1120 reg
->how
= DWARF2_FRAME_REG_CFA
;
1122 case SPARC64_PC_REGNUM
:
1123 reg
->how
= DWARF2_FRAME_REG_RA_OFFSET
;
1124 reg
->loc
.offset
= 8;
1126 case SPARC64_NPC_REGNUM
:
1127 reg
->how
= DWARF2_FRAME_REG_RA_OFFSET
;
1128 reg
->loc
.offset
= 12;
1134 sparc64_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
1136 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1138 tdep
->pc_regnum
= SPARC64_PC_REGNUM
;
1139 tdep
->npc_regnum
= SPARC64_NPC_REGNUM
;
1141 /* This is what all the fuss is about. */
1142 set_gdbarch_long_bit (gdbarch
, 64);
1143 set_gdbarch_long_long_bit (gdbarch
, 64);
1144 set_gdbarch_ptr_bit (gdbarch
, 64);
1146 set_gdbarch_num_regs (gdbarch
, SPARC64_NUM_REGS
);
1147 set_gdbarch_register_name (gdbarch
, sparc64_register_name
);
1148 set_gdbarch_register_type (gdbarch
, sparc64_register_type
);
1149 set_gdbarch_num_pseudo_regs (gdbarch
, SPARC64_NUM_PSEUDO_REGS
);
1150 set_gdbarch_pseudo_register_read (gdbarch
, sparc64_pseudo_register_read
);
1151 set_gdbarch_pseudo_register_write (gdbarch
, sparc64_pseudo_register_write
);
1153 /* Register numbers of various important registers. */
1154 set_gdbarch_pc_regnum (gdbarch
, SPARC64_PC_REGNUM
); /* %pc */
1156 /* Call dummy code. */
1157 set_gdbarch_call_dummy_location (gdbarch
, AT_ENTRY_POINT
);
1158 set_gdbarch_push_dummy_code (gdbarch
, NULL
);
1159 set_gdbarch_push_dummy_call (gdbarch
, sparc64_push_dummy_call
);
1161 set_gdbarch_return_value (gdbarch
, sparc64_return_value
);
1162 set_gdbarch_stabs_argument_has_addr
1163 (gdbarch
, default_stabs_argument_has_addr
);
1165 set_gdbarch_skip_prologue (gdbarch
, sparc64_skip_prologue
);
1167 /* Hook in the DWARF CFI frame unwinder. */
1168 dwarf2_frame_set_init_reg (gdbarch
, sparc64_dwarf2_frame_init_reg
);
1169 /* FIXME: kettenis/20050423: Don't enable the unwinder until the
1170 StackGhost issues have been resolved. */
1172 frame_unwind_append_sniffer (gdbarch
, sparc64_frame_sniffer
);
1173 frame_base_set_default (gdbarch
, &sparc64_frame_base
);
1177 /* Helper functions for dealing with register sets. */
1179 #define TSTATE_CWP 0x000000000000001fULL
1180 #define TSTATE_ICC 0x0000000f00000000ULL
1181 #define TSTATE_XCC 0x000000f000000000ULL
1183 #define PSR_S 0x00000080
1184 #define PSR_ICC 0x00f00000
1185 #define PSR_VERS 0x0f000000
1186 #define PSR_IMPL 0xf0000000
1187 #define PSR_V8PLUS 0xff000000
1188 #define PSR_XCC 0x000f0000
1191 sparc64_supply_gregset (const struct sparc_gregset
*gregset
,
1192 struct regcache
*regcache
,
1193 int regnum
, const void *gregs
)
1195 int sparc32
= (gdbarch_ptr_bit (current_gdbarch
) == 32);
1196 const gdb_byte
*regs
= gregs
;
1201 if (regnum
== SPARC32_PSR_REGNUM
|| regnum
== -1)
1203 int offset
= gregset
->r_tstate_offset
;
1204 ULONGEST tstate
, psr
;
1207 tstate
= extract_unsigned_integer (regs
+ offset
, 8);
1208 psr
= ((tstate
& TSTATE_CWP
) | PSR_S
| ((tstate
& TSTATE_ICC
) >> 12)
1209 | ((tstate
& TSTATE_XCC
) >> 20) | PSR_V8PLUS
);
1210 store_unsigned_integer (buf
, 4, psr
);
1211 regcache_raw_supply (regcache
, SPARC32_PSR_REGNUM
, buf
);
1214 if (regnum
== SPARC32_PC_REGNUM
|| regnum
== -1)
1215 regcache_raw_supply (regcache
, SPARC32_PC_REGNUM
,
1216 regs
+ gregset
->r_pc_offset
+ 4);
1218 if (regnum
== SPARC32_NPC_REGNUM
|| regnum
== -1)
1219 regcache_raw_supply (regcache
, SPARC32_NPC_REGNUM
,
1220 regs
+ gregset
->r_npc_offset
+ 4);
1222 if (regnum
== SPARC32_Y_REGNUM
|| regnum
== -1)
1224 int offset
= gregset
->r_y_offset
+ 8 - gregset
->r_y_size
;
1225 regcache_raw_supply (regcache
, SPARC32_Y_REGNUM
, regs
+ offset
);
1230 if (regnum
== SPARC64_STATE_REGNUM
|| regnum
== -1)
1231 regcache_raw_supply (regcache
, SPARC64_STATE_REGNUM
,
1232 regs
+ gregset
->r_tstate_offset
);
1234 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== -1)
1235 regcache_raw_supply (regcache
, SPARC64_PC_REGNUM
,
1236 regs
+ gregset
->r_pc_offset
);
1238 if (regnum
== SPARC64_NPC_REGNUM
|| regnum
== -1)
1239 regcache_raw_supply (regcache
, SPARC64_NPC_REGNUM
,
1240 regs
+ gregset
->r_npc_offset
);
1242 if (regnum
== SPARC64_Y_REGNUM
|| regnum
== -1)
1247 memcpy (buf
+ 8 - gregset
->r_y_size
,
1248 regs
+ gregset
->r_y_offset
, gregset
->r_y_size
);
1249 regcache_raw_supply (regcache
, SPARC64_Y_REGNUM
, buf
);
1252 if ((regnum
== SPARC64_FPRS_REGNUM
|| regnum
== -1)
1253 && gregset
->r_fprs_offset
!= -1)
1254 regcache_raw_supply (regcache
, SPARC64_FPRS_REGNUM
,
1255 regs
+ gregset
->r_fprs_offset
);
1258 if (regnum
== SPARC_G0_REGNUM
|| regnum
== -1)
1259 regcache_raw_supply (regcache
, SPARC_G0_REGNUM
, NULL
);
1261 if ((regnum
>= SPARC_G1_REGNUM
&& regnum
<= SPARC_O7_REGNUM
) || regnum
== -1)
1263 int offset
= gregset
->r_g1_offset
;
1268 for (i
= SPARC_G1_REGNUM
; i
<= SPARC_O7_REGNUM
; i
++)
1270 if (regnum
== i
|| regnum
== -1)
1271 regcache_raw_supply (regcache
, i
, regs
+ offset
);
1276 if ((regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
) || regnum
== -1)
1278 /* Not all of the register set variants include Locals and
1279 Inputs. For those that don't, we read them off the stack. */
1280 if (gregset
->r_l0_offset
== -1)
1284 regcache_cooked_read_unsigned (regcache
, SPARC_SP_REGNUM
, &sp
);
1285 sparc_supply_rwindow (regcache
, sp
, regnum
);
1289 int offset
= gregset
->r_l0_offset
;
1294 for (i
= SPARC_L0_REGNUM
; i
<= SPARC_I7_REGNUM
; i
++)
1296 if (regnum
== i
|| regnum
== -1)
1297 regcache_raw_supply (regcache
, i
, regs
+ offset
);
1305 sparc64_collect_gregset (const struct sparc_gregset
*gregset
,
1306 const struct regcache
*regcache
,
1307 int regnum
, void *gregs
)
1309 int sparc32
= (gdbarch_ptr_bit (current_gdbarch
) == 32);
1310 gdb_byte
*regs
= gregs
;
1315 if (regnum
== SPARC32_PSR_REGNUM
|| regnum
== -1)
1317 int offset
= gregset
->r_tstate_offset
;
1318 ULONGEST tstate
, psr
;
1321 tstate
= extract_unsigned_integer (regs
+ offset
, 8);
1322 regcache_raw_collect (regcache
, SPARC32_PSR_REGNUM
, buf
);
1323 psr
= extract_unsigned_integer (buf
, 4);
1324 tstate
|= (psr
& PSR_ICC
) << 12;
1325 if ((psr
& (PSR_VERS
| PSR_IMPL
)) == PSR_V8PLUS
)
1326 tstate
|= (psr
& PSR_XCC
) << 20;
1327 store_unsigned_integer (buf
, 8, tstate
);
1328 memcpy (regs
+ offset
, buf
, 8);
1331 if (regnum
== SPARC32_PC_REGNUM
|| regnum
== -1)
1332 regcache_raw_collect (regcache
, SPARC32_PC_REGNUM
,
1333 regs
+ gregset
->r_pc_offset
+ 4);
1335 if (regnum
== SPARC32_NPC_REGNUM
|| regnum
== -1)
1336 regcache_raw_collect (regcache
, SPARC32_NPC_REGNUM
,
1337 regs
+ gregset
->r_npc_offset
+ 4);
1339 if (regnum
== SPARC32_Y_REGNUM
|| regnum
== -1)
1341 int offset
= gregset
->r_y_offset
+ 8 - gregset
->r_y_size
;
1342 regcache_raw_collect (regcache
, SPARC32_Y_REGNUM
, regs
+ offset
);
1347 if (regnum
== SPARC64_STATE_REGNUM
|| regnum
== -1)
1348 regcache_raw_collect (regcache
, SPARC64_STATE_REGNUM
,
1349 regs
+ gregset
->r_tstate_offset
);
1351 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== -1)
1352 regcache_raw_collect (regcache
, SPARC64_PC_REGNUM
,
1353 regs
+ gregset
->r_pc_offset
);
1355 if (regnum
== SPARC64_NPC_REGNUM
|| regnum
== -1)
1356 regcache_raw_collect (regcache
, SPARC64_NPC_REGNUM
,
1357 regs
+ gregset
->r_npc_offset
);
1359 if (regnum
== SPARC64_Y_REGNUM
|| regnum
== -1)
1363 regcache_raw_collect (regcache
, SPARC64_Y_REGNUM
, buf
);
1364 memcpy (regs
+ gregset
->r_y_offset
,
1365 buf
+ 8 - gregset
->r_y_size
, gregset
->r_y_size
);
1368 if ((regnum
== SPARC64_FPRS_REGNUM
|| regnum
== -1)
1369 && gregset
->r_fprs_offset
!= -1)
1370 regcache_raw_collect (regcache
, SPARC64_FPRS_REGNUM
,
1371 regs
+ gregset
->r_fprs_offset
);
1375 if ((regnum
>= SPARC_G1_REGNUM
&& regnum
<= SPARC_O7_REGNUM
) || regnum
== -1)
1377 int offset
= gregset
->r_g1_offset
;
1382 /* %g0 is always zero. */
1383 for (i
= SPARC_G1_REGNUM
; i
<= SPARC_O7_REGNUM
; i
++)
1385 if (regnum
== i
|| regnum
== -1)
1386 regcache_raw_collect (regcache
, i
, regs
+ offset
);
1391 if ((regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
) || regnum
== -1)
1393 /* Not all of the register set variants include Locals and
1394 Inputs. For those that don't, we read them off the stack. */
1395 if (gregset
->r_l0_offset
!= -1)
1397 int offset
= gregset
->r_l0_offset
;
1402 for (i
= SPARC_L0_REGNUM
; i
<= SPARC_I7_REGNUM
; i
++)
1404 if (regnum
== i
|| regnum
== -1)
1405 regcache_raw_collect (regcache
, i
, regs
+ offset
);
1413 sparc64_supply_fpregset (struct regcache
*regcache
,
1414 int regnum
, const void *fpregs
)
1416 int sparc32
= (gdbarch_ptr_bit (current_gdbarch
) == 32);
1417 const gdb_byte
*regs
= fpregs
;
1420 for (i
= 0; i
< 32; i
++)
1422 if (regnum
== (SPARC_F0_REGNUM
+ i
) || regnum
== -1)
1423 regcache_raw_supply (regcache
, SPARC_F0_REGNUM
+ i
, regs
+ (i
* 4));
1428 if (regnum
== SPARC32_FSR_REGNUM
|| regnum
== -1)
1429 regcache_raw_supply (regcache
, SPARC32_FSR_REGNUM
,
1430 regs
+ (32 * 4) + (16 * 8) + 4);
1434 for (i
= 0; i
< 16; i
++)
1436 if (regnum
== (SPARC64_F32_REGNUM
+ i
) || regnum
== -1)
1437 regcache_raw_supply (regcache
, SPARC64_F32_REGNUM
+ i
,
1438 regs
+ (32 * 4) + (i
* 8));
1441 if (regnum
== SPARC64_FSR_REGNUM
|| regnum
== -1)
1442 regcache_raw_supply (regcache
, SPARC64_FSR_REGNUM
,
1443 regs
+ (32 * 4) + (16 * 8));
1448 sparc64_collect_fpregset (const struct regcache
*regcache
,
1449 int regnum
, void *fpregs
)
1451 int sparc32
= (gdbarch_ptr_bit (current_gdbarch
) == 32);
1452 gdb_byte
*regs
= fpregs
;
1455 for (i
= 0; i
< 32; i
++)
1457 if (regnum
== (SPARC_F0_REGNUM
+ i
) || regnum
== -1)
1458 regcache_raw_collect (regcache
, SPARC_F0_REGNUM
+ i
, regs
+ (i
* 4));
1463 if (regnum
== SPARC32_FSR_REGNUM
|| regnum
== -1)
1464 regcache_raw_collect (regcache
, SPARC32_FSR_REGNUM
,
1465 regs
+ (32 * 4) + (16 * 8) + 4);
1469 for (i
= 0; i
< 16; i
++)
1471 if (regnum
== (SPARC64_F32_REGNUM
+ i
) || regnum
== -1)
1472 regcache_raw_collect (regcache
, SPARC64_F32_REGNUM
+ i
,
1473 regs
+ (32 * 4) + (i
* 8));
1476 if (regnum
== SPARC64_FSR_REGNUM
|| regnum
== -1)
1477 regcache_raw_collect (regcache
, SPARC64_FSR_REGNUM
,
1478 regs
+ (32 * 4) + (16 * 8));