#include "dis-asm.h"
#include "dwarf2.h"
#include "dwarf2-frame.h"
-#include "floatformat.h"
#include "frame.h"
#include "frame-base.h"
#include "frame-unwind.h"
return 0;
}
+/* Check whether TYPE is returned on registers. */
+
+static bool
+sparc_structure_return_p (const struct type *type)
+{
+ if (TYPE_CODE (type) == TYPE_CODE_ARRAY && TYPE_LENGTH (type) <= 8)
+ {
+ struct type *t = check_typedef (TYPE_TARGET_TYPE (type));
+
+ if (sparc_floating_p (t) && TYPE_LENGTH (t) == 8)
+ return true;
+ return false;
+ }
+ if (sparc_floating_p (type) && TYPE_LENGTH (type) == 16)
+ return true;
+ return sparc_structure_or_union_p (type);
+}
+
+/* Check whether TYPE is passed on registers. */
+
+static bool
+sparc_arg_on_registers_p (const struct type *type)
+{
+ if (TYPE_CODE (type) == TYPE_CODE_ARRAY && TYPE_LENGTH (type) <= 8)
+ {
+ struct type *t = check_typedef (TYPE_TARGET_TYPE (type));
+
+ if (sparc_floating_p (t) && TYPE_LENGTH (t) == 8)
+ return false;
+ return true;
+ }
+ if (sparc_structure_or_union_p (type) || sparc_complex_floating_p (type)
+ || (sparc_floating_p (type) && TYPE_LENGTH (type) == 16))
+ return false;
+ return true;
+}
+
/* Register information. */
#define SPARC32_FPU_REGISTERS \
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
{
struct type *type;
- type = arch_flags_type (gdbarch, "builtin_type_sparc_psr", 4);
+ type = arch_flags_type (gdbarch, "builtin_type_sparc_psr", 32);
append_flags_type_flag (type, 5, "ET");
append_flags_type_flag (type, 6, "PS");
append_flags_type_flag (type, 7, "S");
{
struct type *type;
- type = arch_flags_type (gdbarch, "builtin_type_sparc_fsr", 4);
+ type = arch_flags_type (gdbarch, "builtin_type_sparc_fsr", 32);
append_flags_type_flag (type, 0, "NXA");
append_flags_type_flag (type, 1, "DZA");
append_flags_type_flag (type, 2, "UFA");
struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch *gdbarch = regcache->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* Number of words in the "parameter array". */
int num_elements = 0;
struct type *type = value_type (args[i]);
int len = TYPE_LENGTH (type);
- if (sparc_structure_or_union_p (type)
- || (sparc_floating_p (type) && len == 16)
- || sparc_complex_floating_p (type))
+ if (!sparc_arg_on_registers_p (type))
{
/* Structure, Union and Quad-Precision Arguments. */
sp -= len;
else
{
/* Integral and pointer arguments. */
- gdb_assert (sparc_integral_or_pointer_p (type));
-
- if (len < 4)
- args[i] = value_cast (builtin_type (gdbarch)->builtin_int32,
- args[i]);
+ gdb_assert (sparc_integral_or_pointer_p (type)
+ || (TYPE_CODE (type) == TYPE_CODE_ARRAY && len <= 8));
num_elements += ((len + 3) / 4);
}
}
const bfd_byte *valbuf = value_contents (args[i]);
struct type *type = value_type (args[i]);
int len = TYPE_LENGTH (type);
+ gdb_byte buf[4];
+
+ if (len < 4)
+ {
+ memset (buf, 0, 4 - len);
+ memcpy (buf + 4 - len, valbuf, len);
+ valbuf = buf;
+ len = 4;
+ }
gdb_assert (len == 4 || len == 8);
int len = TYPE_LENGTH (type);
gdb_byte buf[32];
- gdb_assert (!sparc_structure_or_union_p (type));
- gdb_assert (!(sparc_floating_p (type) && len == 16));
+ gdb_assert (!sparc_structure_return_p (type));
- if (sparc_floating_p (type) || sparc_complex_floating_p (type))
+ if (sparc_floating_p (type) || sparc_complex_floating_p (type)
+ || TYPE_CODE (type) == TYPE_CODE_ARRAY)
{
/* Floating return values. */
regcache_cooked_read (regcache, SPARC_F0_REGNUM, buf);
const gdb_byte *valbuf)
{
int len = TYPE_LENGTH (type);
- gdb_byte buf[8];
+ gdb_byte buf[32];
- gdb_assert (!sparc_structure_or_union_p (type));
- gdb_assert (!(sparc_floating_p (type) && len == 16));
- gdb_assert (len <= 8);
+ gdb_assert (!sparc_structure_return_p (type));
if (sparc_floating_p (type) || sparc_complex_floating_p (type))
{
guarantees that we can always find the return value, not just
before the function returns. */
- if (sparc_structure_or_union_p (type)
- || (sparc_floating_p (type) && TYPE_LENGTH (type) == 16))
+ if (sparc_structure_return_p (type))
{
ULONGEST sp;
CORE_ADDR addr;
uint64_t reg;
int size = register_size (gdbarch, 0);
- dwarf2_frame_state_alloc_regs (&fs->regs, 32);
+ fs->regs.alloc_regs (32);
for (reg = 8; reg < 16; reg++)
{
fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_REG;
struct frame_info *frame = get_current_frame ();
/* Trap instruction (TRAP). */
- return gdbarch_tdep (get_regcache_arch (regcache))->step_trap (frame,
+ return gdbarch_tdep (regcache->arch ())->step_trap (frame,
insn);
}
static std::vector<CORE_ADDR>
sparc_software_single_step (struct regcache *regcache)
{
- struct gdbarch *arch = get_regcache_arch (regcache);
+ struct gdbarch *arch = regcache->arch ();
struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
CORE_ADDR npc, nnpc;
static void
sparc_write_pc (struct regcache *regcache, CORE_ADDR pc)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
+ struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ());
regcache_cooked_write_unsigned (regcache, tdep->pc_regnum, pc);
regcache_cooked_write_unsigned (regcache, tdep->npc_regnum, pc + 4);
set_gdbarch_frame_args_skip (gdbarch, 8);
- set_gdbarch_print_insn (gdbarch, print_insn_sparc);
-
set_gdbarch_software_single_step (gdbarch, sparc_software_single_step);
set_gdbarch_write_pc (gdbarch, sparc_write_pc);
}
/* Target description may have changed. */
- info.tdep_info = tdesc_data;
+ info.tdesc_data = tdesc_data;
tdesc_use_registers (gdbarch, tdesc, tdesc_data);
}
void
sparc_supply_rwindow (struct regcache *regcache, CORE_ADDR sp, int regnum)
{
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch *gdbarch = regcache->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int offset = 0;
gdb_byte buf[8];
/* Clear out the top half of the temporary buffer, and put the
register value in the bottom half if we're in 64-bit mode. */
- if (gdbarch_ptr_bit (get_regcache_arch (regcache)) == 64)
+ if (gdbarch_ptr_bit (regcache->arch ()) == 64)
{
memset (buf, 0, 4);
offset = 4;
sparc_collect_rwindow (const struct regcache *regcache,
CORE_ADDR sp, int regnum)
{
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch *gdbarch = regcache->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int offset = 0;
gdb_byte buf[8];
sp &= 0xffffffffUL;
/* Only use the bottom half if we're in 64-bit mode. */
- if (gdbarch_ptr_bit (get_regcache_arch (regcache)) == 64)
+ if (gdbarch_ptr_bit (regcache->arch ()) == 64)
offset = 4;
for (i = SPARC_L0_REGNUM; i <= SPARC_I7_REGNUM; i++)
0 * 4, /* %f0 */
32 * 4, /* %fsr */
};
-\f
-
-/* Provide a prototype to silence -Wmissing-prototypes. */
-void _initialize_sparc_tdep (void);
void
_initialize_sparc_tdep (void)