This is the mail archive of the sid@sources.redhat.com mailing list for the SID project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch][rfa] Support multiple bfd machines in cgen-cpu disassembly


Approved by fche and committed.

Dave Brolley wrote:

Hi,

Currently the 'mach' file of the disassemble_info struct initialized by cgen_disassemble is left with the default value of 0, which indicates to use the default bfd machine. This patch allows the specification of a bfd machine number, so that targets with multiple cgen MACHs can filter the insn set correctly when disassembling.

The machine number is an optional argument to cgen_bi_endian_cpu::disassemble with a default value of zero, to preserve the current behaviour in ports which don't use this feature. The machine number is then passed to cgen_disassemble which stores it in the disassemble_info for use by the disassembler. The machine number is also stored in the bfd_arch_hack struct by register_name and is compared against the requested machine number in bfd_lookup_arch.

This has been tested against an internal port which uses this feature and against xstormy16 which does not.

ok to commit?

Dave

------------------------------------------------------------------------

Index: sid/component/cgen-cpu/cgen-cpu.h
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/cgen-cpu.h,v
retrieving revision 1.9
diff -c -p -r1.9 cgen-cpu.h
*** sid/component/cgen-cpu/cgen-cpu.h 15 Jan 2003 20:04:57 -0000 1.9
--- sid/component/cgen-cpu/cgen-cpu.h 24 Jun 2004 20:13:52 -0000
***************
*** 1,6 ****
// cgen-cpu.h -*- C++ -*-
! // Copyright (C) 2000, 2001, 2002, 2003 Red Hat.
// This file is part of SID and is licensed under the GPL.
// See the file COPYING.SID for conditions for redistribution.
--- 1,6 ----
// cgen-cpu.h -*- C++ -*-
! // Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat.
// This file is part of SID and is licensed under the GPL.
// See the file COPYING.SID for conditions for redistribution.
*************** public:
*** 68,74 ****
// Disassembly tracing support
void disassemble (PCADDR pc, disassembler_ftype printfn,
enum bfd_flavour flavour, enum bfd_architecture arch,
! enum bfd_endian endian, const char *name, unsigned long isa_mask = 0);
struct disassemble_info info;
protected:
static int cgen_read_memory (bfd_vma memaddr, bfd_byte *myaddr,
--- 68,74 ----
// Disassembly tracing support
void disassemble (PCADDR pc, disassembler_ftype printfn,
enum bfd_flavour flavour, enum bfd_architecture arch,
! enum bfd_endian endian, const char *name, unsigned long isa_mask = 0, int machine = 0);
struct disassemble_info info;
protected:
static int cgen_read_memory (bfd_vma memaddr, bfd_byte *myaddr,
Index: sid/component/cgen-cpu/compCGEN.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/compCGEN.cxx,v
retrieving revision 1.12
diff -c -p -r1.12 compCGEN.cxx
*** sid/component/cgen-cpu/compCGEN.cxx 29 Aug 2003 19:26:22 -0000 1.12
--- sid/component/cgen-cpu/compCGEN.cxx 24 Jun 2004 20:13:52 -0000
***************
*** 1,6 ****
// compCGEN.cxx - CPU components. -*- C++ -*-
! // Copyright (C) 1999, 2000, 2001, 2002, 2003 Red Hat.
// This file is part of SID and is licensed under the GPL.
// See the file COPYING.SID for conditions for redistribution.
--- 1,6 ----
// compCGEN.cxx - CPU components. -*- C++ -*-
! // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Red Hat.
// This file is part of SID and is licensed under the GPL.
// See the file COPYING.SID for conditions for redistribution.
*************** cgen::cgen_bi_endian_cpu::disassemble (P
*** 155,161 ****
enum bfd_architecture arch,
enum bfd_endian endian,
const char *name,
! unsigned long isa_mask)
{
cgen_disassemble((bfd_vma)pc, &this->info, this,
& cgen_bi_endian_cpu::cgen_read_memory,
--- 155,162 ----
enum bfd_architecture arch,
enum bfd_endian endian,
const char *name,
! unsigned long isa_mask,
! int machine)
{
cgen_disassemble((bfd_vma)pc, &this->info, this,
& cgen_bi_endian_cpu::cgen_read_memory,
*************** cgen::cgen_bi_endian_cpu::disassemble (P
*** 165,170 ****
--- 166,172 ----
printfn,
flavour,
arch,
+ machine,
endian,
name,
isa_mask);
Index: sid/component/cgen-cpu/tracedis.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/tracedis.cxx,v
retrieving revision 1.3
diff -c -p -r1.3 tracedis.cxx
*** sid/component/cgen-cpu/tracedis.cxx 26 Mar 2004 20:23:40 -0000 1.3
--- sid/component/cgen-cpu/tracedis.cxx 24 Jun 2004 20:13:52 -0000
***************
*** 1,6 ****
// tracedis.cxx - disassembly tracing support. -*- C++ -*-
! // Copyright (C) 2001, 2002 Red Hat.
// This file is part of SID and is licensed under the GPL.
// See the file COPYING.SID for conditions for redistribution.
--- 1,6 ----
// tracedis.cxx - disassembly tracing support. -*- C++ -*-
! // Copyright (C) 2001-2004 Red Hat.
// This file is part of SID and is licensed under the GPL.
// See the file COPYING.SID for conditions for redistribution.
***************
*** 12,18 ****
#include "sidcomputil.h"
#include "sidcpuutil.h"
! void register_name(enum bfd_architecture, const char *);
// XXX: for compatibility with older libraries
static
--- 12,18 ----
#include "sidcomputil.h"
#include "sidcpuutil.h"
! void register_name(enum bfd_architecture, const char *, int);
// XXX: for compatibility with older libraries
static
*************** cgen_disassemble(bfd_vma pc,
*** 41,56 ****
disassembler_ftype fp,
enum bfd_flavour flavour,
enum bfd_architecture arch,
enum bfd_endian endian,
const char *name,
unsigned long isa_mask)
{
! register_name(arch, name);
INIT_DISASSEMBLE_INFO(*info, this_ptr, trace_printf);
info->application_data = this_ptr;
info->flavour = flavour;
info->insn_sets = isa_mask; /* may be 0 */
info->arch = arch;
info->endian = endian;
info->read_memory_func = read_mem_func;
info->memory_error_func = memory_error_func;
--- 41,58 ----
disassembler_ftype fp,
enum bfd_flavour flavour,
enum bfd_architecture arch,
+ int machine,
enum bfd_endian endian,
const char *name,
unsigned long isa_mask)
{
! register_name(arch, name, machine);
INIT_DISASSEMBLE_INFO(*info, this_ptr, trace_printf);
info->application_data = this_ptr;
info->flavour = flavour;
info->insn_sets = isa_mask; /* may be 0 */
info->arch = arch;
+ info->mach = machine;
info->endian = endian;
info->read_memory_func = read_mem_func;
info->memory_error_func = memory_error_func;
*************** bfd_get_bits (const void* addr, int bits
*** 174,186 ****
struct bfd_arch_hack {
struct bfd_arch_hack *next;
enum bfd_architecture arch;
const char *name;
};
struct bfd_arch_hack *hack_list;
void
! register_name(enum bfd_architecture arch, const char *name)
{
struct bfd_arch_hack *p;
--- 176,189 ----
struct bfd_arch_hack {
struct bfd_arch_hack *next;
enum bfd_architecture arch;
+ int machine;
const char *name;
};
struct bfd_arch_hack *hack_list;
void
! register_name(enum bfd_architecture arch, const char *name, int machine)
{
struct bfd_arch_hack *p;
*************** register_name(enum bfd_architecture arch
*** 189,194 ****
--- 192,198 ----
hack_list = (struct bfd_arch_hack *)xmalloc(sizeof *hack_list);
hack_list->next = NULL;
hack_list->arch = arch;
+ hack_list->machine = machine;
hack_list->name = name;
return;
}
*************** register_name(enum bfd_architecture arch
*** 197,207 ****
--- 201,213 ----
if (strcmp(p->name, name) == 0)
{
p->arch = arch;
+ p->machine = machine;
return;
}
p = (struct bfd_arch_hack *)xmalloc(sizeof *hack_list);
p->next = hack_list;
p->arch = arch;
+ p->machine = machine;
p->name = name;
}
*************** bfd_lookup_arch (enum bfd_architecture a
*** 213,219 ****
for (b = hack_list; b->name; b++)
{
! if (b->arch == arch)
{
info.printable_name = b->name;
return &info;
--- 219,225 ----
for (b = hack_list; b->name; b++)
{
! if (b->arch == arch && b->machine == machine)
{
info.printable_name = b->name;
return &info;
Index: sid/component/cgen-cpu/tracedis.h
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/tracedis.h,v
retrieving revision 1.2
diff -c -p -r1.2 tracedis.h
*** sid/component/cgen-cpu/tracedis.h 7 Feb 2002 17:32:28 -0000 1.2
--- sid/component/cgen-cpu/tracedis.h 24 Jun 2004 20:13:52 -0000
*************** typedef void (*MEMERR)(int status, bfd_v
*** 9,12 ****
typedef void (*PRINTADDR)(bfd_vma addr, struct disassemble_info *info);
typedef int (*SYMATADDR)(bfd_vma addr, struct disassemble_info * info);
! void cgen_disassemble(bfd_vma, disassemble_info *, void *, READMEM, MEMERR, PRINTADDR, SYMATADDR, disassembler_ftype, enum bfd_flavour, enum bfd_architecture, enum bfd_endian, const char *, unsigned long isa_mask);
--- 9,12 ----
typedef void (*PRINTADDR)(bfd_vma addr, struct disassemble_info *info);
typedef int (*SYMATADDR)(bfd_vma addr, struct disassemble_info * info);
! void cgen_disassemble(bfd_vma, disassemble_info *, void *, READMEM, MEMERR, PRINTADDR, SYMATADDR, disassembler_ftype, enum bfd_flavour, enum bfd_architecture, int machine, enum bfd_endian, const char *, unsigned long isa_mask);


------------------------------------------------------------------------

2004-06-21 Dave Brolley <brolley@redhat.com>

	* tracedis.cxx (register_name): Add parameter for the cgen MACH. Save
	it in hack_list->machine or p->machine.
	(cgen_disassemble): Add parameter for the cgen MACH. Pass it to
	register_name. Use it to set info->mach.
	(arch_hack): New field 'machine'.
	(bfd_lookup_arch): Make sure the machines match.
	* cgen-cpu.h (disassemble): Add parameter for the cgen MACH.
	* compCGEN.cxx (disassemble): Add parameter for the cgen MACH. Pass it
	to cgen_disassemble.
	* tracedis.h (cgen_disassemble): Add parameter for the cgen MACH.





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]