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
,
1110 struct frame_info
*next_frame
)
1114 case SPARC_G0_REGNUM
:
1115 /* Since %g0 is always zero, there is no point in saving it, and
1116 people will be inclined omit it from the CFI. Make sure we
1117 don't warn about that. */
1118 reg
->how
= DWARF2_FRAME_REG_SAME_VALUE
;
1120 case SPARC_SP_REGNUM
:
1121 reg
->how
= DWARF2_FRAME_REG_CFA
;
1123 case SPARC64_PC_REGNUM
:
1124 reg
->how
= DWARF2_FRAME_REG_RA_OFFSET
;
1125 reg
->loc
.offset
= 8;
1127 case SPARC64_NPC_REGNUM
:
1128 reg
->how
= DWARF2_FRAME_REG_RA_OFFSET
;
1129 reg
->loc
.offset
= 12;
1135 sparc64_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
1137 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1139 tdep
->pc_regnum
= SPARC64_PC_REGNUM
;
1140 tdep
->npc_regnum
= SPARC64_NPC_REGNUM
;
1142 /* This is what all the fuss is about. */
1143 set_gdbarch_long_bit (gdbarch
, 64);
1144 set_gdbarch_long_long_bit (gdbarch
, 64);
1145 set_gdbarch_ptr_bit (gdbarch
, 64);
1147 set_gdbarch_num_regs (gdbarch
, SPARC64_NUM_REGS
);
1148 set_gdbarch_register_name (gdbarch
, sparc64_register_name
);
1149 set_gdbarch_register_type (gdbarch
, sparc64_register_type
);
1150 set_gdbarch_num_pseudo_regs (gdbarch
, SPARC64_NUM_PSEUDO_REGS
);
1151 set_gdbarch_pseudo_register_read (gdbarch
, sparc64_pseudo_register_read
);
1152 set_gdbarch_pseudo_register_write (gdbarch
, sparc64_pseudo_register_write
);
1154 /* Register numbers of various important registers. */
1155 set_gdbarch_pc_regnum (gdbarch
, SPARC64_PC_REGNUM
); /* %pc */
1157 /* Call dummy code. */
1158 set_gdbarch_call_dummy_location (gdbarch
, AT_ENTRY_POINT
);
1159 set_gdbarch_push_dummy_code (gdbarch
, NULL
);
1160 set_gdbarch_push_dummy_call (gdbarch
, sparc64_push_dummy_call
);
1162 set_gdbarch_return_value (gdbarch
, sparc64_return_value
);
1163 set_gdbarch_stabs_argument_has_addr
1164 (gdbarch
, default_stabs_argument_has_addr
);
1166 set_gdbarch_skip_prologue (gdbarch
, sparc64_skip_prologue
);
1168 /* Hook in the DWARF CFI frame unwinder. */
1169 dwarf2_frame_set_init_reg (gdbarch
, sparc64_dwarf2_frame_init_reg
);
1170 /* FIXME: kettenis/20050423: Don't enable the unwinder until the
1171 StackGhost issues have been resolved. */
1173 frame_unwind_append_sniffer (gdbarch
, sparc64_frame_sniffer
);
1174 frame_base_set_default (gdbarch
, &sparc64_frame_base
);
1178 /* Helper functions for dealing with register sets. */
1180 #define TSTATE_CWP 0x000000000000001fULL
1181 #define TSTATE_ICC 0x0000000f00000000ULL
1182 #define TSTATE_XCC 0x000000f000000000ULL
1184 #define PSR_S 0x00000080
1185 #define PSR_ICC 0x00f00000
1186 #define PSR_VERS 0x0f000000
1187 #define PSR_IMPL 0xf0000000
1188 #define PSR_V8PLUS 0xff000000
1189 #define PSR_XCC 0x000f0000
1192 sparc64_supply_gregset (const struct sparc_gregset
*gregset
,
1193 struct regcache
*regcache
,
1194 int regnum
, const void *gregs
)
1196 int sparc32
= (gdbarch_ptr_bit (current_gdbarch
) == 32);
1197 const gdb_byte
*regs
= gregs
;
1202 if (regnum
== SPARC32_PSR_REGNUM
|| regnum
== -1)
1204 int offset
= gregset
->r_tstate_offset
;
1205 ULONGEST tstate
, psr
;
1208 tstate
= extract_unsigned_integer (regs
+ offset
, 8);
1209 psr
= ((tstate
& TSTATE_CWP
) | PSR_S
| ((tstate
& TSTATE_ICC
) >> 12)
1210 | ((tstate
& TSTATE_XCC
) >> 20) | PSR_V8PLUS
);
1211 store_unsigned_integer (buf
, 4, psr
);
1212 regcache_raw_supply (regcache
, SPARC32_PSR_REGNUM
, buf
);
1215 if (regnum
== SPARC32_PC_REGNUM
|| regnum
== -1)
1216 regcache_raw_supply (regcache
, SPARC32_PC_REGNUM
,
1217 regs
+ gregset
->r_pc_offset
+ 4);
1219 if (regnum
== SPARC32_NPC_REGNUM
|| regnum
== -1)
1220 regcache_raw_supply (regcache
, SPARC32_NPC_REGNUM
,
1221 regs
+ gregset
->r_npc_offset
+ 4);
1223 if (regnum
== SPARC32_Y_REGNUM
|| regnum
== -1)
1225 int offset
= gregset
->r_y_offset
+ 8 - gregset
->r_y_size
;
1226 regcache_raw_supply (regcache
, SPARC32_Y_REGNUM
, regs
+ offset
);
1231 if (regnum
== SPARC64_STATE_REGNUM
|| regnum
== -1)
1232 regcache_raw_supply (regcache
, SPARC64_STATE_REGNUM
,
1233 regs
+ gregset
->r_tstate_offset
);
1235 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== -1)
1236 regcache_raw_supply (regcache
, SPARC64_PC_REGNUM
,
1237 regs
+ gregset
->r_pc_offset
);
1239 if (regnum
== SPARC64_NPC_REGNUM
|| regnum
== -1)
1240 regcache_raw_supply (regcache
, SPARC64_NPC_REGNUM
,
1241 regs
+ gregset
->r_npc_offset
);
1243 if (regnum
== SPARC64_Y_REGNUM
|| regnum
== -1)
1248 memcpy (buf
+ 8 - gregset
->r_y_size
,
1249 regs
+ gregset
->r_y_offset
, gregset
->r_y_size
);
1250 regcache_raw_supply (regcache
, SPARC64_Y_REGNUM
, buf
);
1253 if ((regnum
== SPARC64_FPRS_REGNUM
|| regnum
== -1)
1254 && gregset
->r_fprs_offset
!= -1)
1255 regcache_raw_supply (regcache
, SPARC64_FPRS_REGNUM
,
1256 regs
+ gregset
->r_fprs_offset
);
1259 if (regnum
== SPARC_G0_REGNUM
|| regnum
== -1)
1260 regcache_raw_supply (regcache
, SPARC_G0_REGNUM
, NULL
);
1262 if ((regnum
>= SPARC_G1_REGNUM
&& regnum
<= SPARC_O7_REGNUM
) || regnum
== -1)
1264 int offset
= gregset
->r_g1_offset
;
1269 for (i
= SPARC_G1_REGNUM
; i
<= SPARC_O7_REGNUM
; i
++)
1271 if (regnum
== i
|| regnum
== -1)
1272 regcache_raw_supply (regcache
, i
, regs
+ offset
);
1277 if ((regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
) || regnum
== -1)
1279 /* Not all of the register set variants include Locals and
1280 Inputs. For those that don't, we read them off the stack. */
1281 if (gregset
->r_l0_offset
== -1)
1285 regcache_cooked_read_unsigned (regcache
, SPARC_SP_REGNUM
, &sp
);
1286 sparc_supply_rwindow (regcache
, sp
, regnum
);
1290 int offset
= gregset
->r_l0_offset
;
1295 for (i
= SPARC_L0_REGNUM
; i
<= SPARC_I7_REGNUM
; i
++)
1297 if (regnum
== i
|| regnum
== -1)
1298 regcache_raw_supply (regcache
, i
, regs
+ offset
);
1306 sparc64_collect_gregset (const struct sparc_gregset
*gregset
,
1307 const struct regcache
*regcache
,
1308 int regnum
, void *gregs
)
1310 int sparc32
= (gdbarch_ptr_bit (current_gdbarch
) == 32);
1311 gdb_byte
*regs
= gregs
;
1316 if (regnum
== SPARC32_PSR_REGNUM
|| regnum
== -1)
1318 int offset
= gregset
->r_tstate_offset
;
1319 ULONGEST tstate
, psr
;
1322 tstate
= extract_unsigned_integer (regs
+ offset
, 8);
1323 regcache_raw_collect (regcache
, SPARC32_PSR_REGNUM
, buf
);
1324 psr
= extract_unsigned_integer (buf
, 4);
1325 tstate
|= (psr
& PSR_ICC
) << 12;
1326 if ((psr
& (PSR_VERS
| PSR_IMPL
)) == PSR_V8PLUS
)
1327 tstate
|= (psr
& PSR_XCC
) << 20;
1328 store_unsigned_integer (buf
, 8, tstate
);
1329 memcpy (regs
+ offset
, buf
, 8);
1332 if (regnum
== SPARC32_PC_REGNUM
|| regnum
== -1)
1333 regcache_raw_collect (regcache
, SPARC32_PC_REGNUM
,
1334 regs
+ gregset
->r_pc_offset
+ 4);
1336 if (regnum
== SPARC32_NPC_REGNUM
|| regnum
== -1)
1337 regcache_raw_collect (regcache
, SPARC32_NPC_REGNUM
,
1338 regs
+ gregset
->r_npc_offset
+ 4);
1340 if (regnum
== SPARC32_Y_REGNUM
|| regnum
== -1)
1342 int offset
= gregset
->r_y_offset
+ 8 - gregset
->r_y_size
;
1343 regcache_raw_collect (regcache
, SPARC32_Y_REGNUM
, regs
+ offset
);
1348 if (regnum
== SPARC64_STATE_REGNUM
|| regnum
== -1)
1349 regcache_raw_collect (regcache
, SPARC64_STATE_REGNUM
,
1350 regs
+ gregset
->r_tstate_offset
);
1352 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== -1)
1353 regcache_raw_collect (regcache
, SPARC64_PC_REGNUM
,
1354 regs
+ gregset
->r_pc_offset
);
1356 if (regnum
== SPARC64_NPC_REGNUM
|| regnum
== -1)
1357 regcache_raw_collect (regcache
, SPARC64_NPC_REGNUM
,
1358 regs
+ gregset
->r_npc_offset
);
1360 if (regnum
== SPARC64_Y_REGNUM
|| regnum
== -1)
1364 regcache_raw_collect (regcache
, SPARC64_Y_REGNUM
, buf
);
1365 memcpy (regs
+ gregset
->r_y_offset
,
1366 buf
+ 8 - gregset
->r_y_size
, gregset
->r_y_size
);
1369 if ((regnum
== SPARC64_FPRS_REGNUM
|| regnum
== -1)
1370 && gregset
->r_fprs_offset
!= -1)
1371 regcache_raw_collect (regcache
, SPARC64_FPRS_REGNUM
,
1372 regs
+ gregset
->r_fprs_offset
);
1376 if ((regnum
>= SPARC_G1_REGNUM
&& regnum
<= SPARC_O7_REGNUM
) || regnum
== -1)
1378 int offset
= gregset
->r_g1_offset
;
1383 /* %g0 is always zero. */
1384 for (i
= SPARC_G1_REGNUM
; i
<= SPARC_O7_REGNUM
; i
++)
1386 if (regnum
== i
|| regnum
== -1)
1387 regcache_raw_collect (regcache
, i
, regs
+ offset
);
1392 if ((regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
) || regnum
== -1)
1394 /* Not all of the register set variants include Locals and
1395 Inputs. For those that don't, we read them off the stack. */
1396 if (gregset
->r_l0_offset
!= -1)
1398 int offset
= gregset
->r_l0_offset
;
1403 for (i
= SPARC_L0_REGNUM
; i
<= SPARC_I7_REGNUM
; i
++)
1405 if (regnum
== i
|| regnum
== -1)
1406 regcache_raw_collect (regcache
, i
, regs
+ offset
);
1414 sparc64_supply_fpregset (struct regcache
*regcache
,
1415 int regnum
, const void *fpregs
)
1417 int sparc32
= (gdbarch_ptr_bit (current_gdbarch
) == 32);
1418 const gdb_byte
*regs
= fpregs
;
1421 for (i
= 0; i
< 32; i
++)
1423 if (regnum
== (SPARC_F0_REGNUM
+ i
) || regnum
== -1)
1424 regcache_raw_supply (regcache
, SPARC_F0_REGNUM
+ i
, regs
+ (i
* 4));
1429 if (regnum
== SPARC32_FSR_REGNUM
|| regnum
== -1)
1430 regcache_raw_supply (regcache
, SPARC32_FSR_REGNUM
,
1431 regs
+ (32 * 4) + (16 * 8) + 4);
1435 for (i
= 0; i
< 16; i
++)
1437 if (regnum
== (SPARC64_F32_REGNUM
+ i
) || regnum
== -1)
1438 regcache_raw_supply (regcache
, SPARC64_F32_REGNUM
+ i
,
1439 regs
+ (32 * 4) + (i
* 8));
1442 if (regnum
== SPARC64_FSR_REGNUM
|| regnum
== -1)
1443 regcache_raw_supply (regcache
, SPARC64_FSR_REGNUM
,
1444 regs
+ (32 * 4) + (16 * 8));
1449 sparc64_collect_fpregset (const struct regcache
*regcache
,
1450 int regnum
, void *fpregs
)
1452 int sparc32
= (gdbarch_ptr_bit (current_gdbarch
) == 32);
1453 gdb_byte
*regs
= fpregs
;
1456 for (i
= 0; i
< 32; i
++)
1458 if (regnum
== (SPARC_F0_REGNUM
+ i
) || regnum
== -1)
1459 regcache_raw_collect (regcache
, SPARC_F0_REGNUM
+ i
, regs
+ (i
* 4));
1464 if (regnum
== SPARC32_FSR_REGNUM
|| regnum
== -1)
1465 regcache_raw_collect (regcache
, SPARC32_FSR_REGNUM
,
1466 regs
+ (32 * 4) + (16 * 8) + 4);
1470 for (i
= 0; i
< 16; i
++)
1472 if (regnum
== (SPARC64_F32_REGNUM
+ i
) || regnum
== -1)
1473 regcache_raw_collect (regcache
, SPARC64_F32_REGNUM
+ i
,
1474 regs
+ (32 * 4) + (i
* 8));
1477 if (regnum
== SPARC64_FSR_REGNUM
|| regnum
== -1)
1478 regcache_raw_collect (regcache
, SPARC64_FSR_REGNUM
,
1479 regs
+ (32 * 4) + (16 * 8));