m680x0: Only keep the bodies in the input file [O. Galibert]

This commit is contained in:
Olivier Galibert 2018-09-14 11:46:58 +02:00
parent ea9cd8aea1
commit 6f0dd96e60
6 changed files with 136 additions and 399 deletions

View File

@ -107,6 +107,26 @@ public:
void autovectors_map(address_map &map);
protected:
static constexpr int NUM_CPU_TYPES = 7;
typedef void (m68000_base_device::*opcode_handler_ptr)();
static opcode_handler_ptr m68ki_instruction_jump_table[NUM_CPU_TYPES][0x10000]; /* opcode handler jump table */
static unsigned char m68ki_cycles[NUM_CPU_TYPES][0x10000]; /* Cycles used by CPU type */
/* This is used to generate the opcode handler jump table */
struct opcode_handler_struct
{
opcode_handler_ptr opcode_handler; /* handler function */
unsigned int mask; /* mask on opcode */
unsigned int match; /* what to match after masking */
unsigned char cycles[NUM_CPU_TYPES]; /* cycles each cpu type takes */
};
static const opcode_handler_struct m68k_opcode_handler_table[];
static void m68ki_set_one(unsigned short opcode, const opcode_handler_struct *s);
static void m68ki_build_opcode_table(void);
void presave();
void postload();

View File

@ -81,204 +81,7 @@
*/
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
M68KMAKE_PROTOTYPE_HEADER
// license:BSD-3-Clause
// copyright-holders:Karl Stenerud
static constexpr int NUM_CPU_TYPES = 7;
typedef void (m68000_base_device::*opcode_handler_ptr)();
static opcode_handler_ptr m68ki_instruction_jump_table[NUM_CPU_TYPES][0x10000]; /* opcode handler jump table */
static unsigned char m68ki_cycles[NUM_CPU_TYPES][0x10000]; /* Cycles used by CPU type */
/* This is used to generate the opcode handler jump table */
struct opcode_handler_struct
{
opcode_handler_ptr opcode_handler; /* handler function */
unsigned int mask; /* mask on opcode */
unsigned int match; /* what to match after masking */
unsigned char cycles[NUM_CPU_TYPES]; /* cycles each cpu type takes */
};
/* Build the opcode handler table */
static void m68ki_set_one(unsigned short opcode, const opcode_handler_struct *s);
static void m68ki_build_opcode_table(void);
/* ======================================================================== */
/* ============================ OPCODE HANDLERS =========================== */
/* ======================================================================== */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
M68KMAKE_PROTOTYPE_FOOTER
/* ======================================================================== */
/* ============================== END OF FILE ============================= */
/* ======================================================================== */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
M68KMAKE_TABLE_HEADER
/* ======================================================================== */
/* ========================= OPCODE TABLE BUILDER ========================= */
/* ======================================================================== */
m68000_base_device::opcode_handler_ptr m68000_base_device::m68ki_instruction_jump_table[NUM_CPU_TYPES][0x10000]; /* opcode handler jump table */
unsigned char m68000_base_device::m68ki_cycles[NUM_CPU_TYPES][0x10000]; /* Cycles used by CPU type */
/* Build the opcode handler jump table */
void m68000_base_device::m68ki_set_one(unsigned short opcode, const opcode_handler_struct *s)
{
for(int i=0; i<NUM_CPU_TYPES; i++)
if(s->cycles[i] != 0xff) {
m68ki_cycles[i][opcode] = s->cycles[i];
m68ki_instruction_jump_table[i][opcode] = s->opcode_handler;
}
}
void m68000_base_device::m68ki_build_opcode_table(void)
{
/* Opcode handler table */
static const opcode_handler_struct m68k_opcode_handler_table[] =
{
/* function mask match 000 010 020 040 */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
M68KMAKE_TABLE_FOOTER
{nullptr, 0, 0, {0, 0, 0, 0, 0}}
};
const opcode_handler_struct *ostruct;
int i;
int j;
int k;
for(i = 0; i < 0x10000; i++)
{
/* default to illegal */
for(k=0;k<NUM_CPU_TYPES;k++)
{
m68ki_instruction_jump_table[k][i] = &m68000_base_device::m68k_op_illegal;
m68ki_cycles[k][i] = 0;
}
}
ostruct = m68k_opcode_handler_table;
while(ostruct->mask != 0xff00)
{
for(i = 0;i < 0x10000;i++)
{
if((i & ostruct->mask) == ostruct->match)
m68ki_set_one(i, ostruct);
}
ostruct++;
}
while(ostruct->mask == 0xff00)
{
for(i = 0;i <= 0xff;i++)
m68ki_set_one(ostruct->match | i, ostruct);
ostruct++;
}
while(ostruct->mask == 0xff20)
{
for(i = 0;i < 4;i++)
{
for(j = 0;j < 32;j++)
{
m68ki_set_one(ostruct->match | (i << 6) | j, ostruct);
}
}
ostruct++;
}
while(ostruct->mask == 0xf1f8)
{
for(i = 0;i < 8;i++)
{
for(j = 0;j < 8;j++)
m68ki_set_one(ostruct->match | (i << 9) | j, ostruct);
}
ostruct++;
}
while(ostruct->mask == 0xffd8)
{
for(i = 0;i < 2;i++)
{
for(j = 0;j < 8;j++)
{
m68ki_set_one(ostruct->match | (i << 5) | j, ostruct);
}
}
ostruct++;
}
while(ostruct->mask == 0xfff0)
{
for(i = 0;i <= 0x0f;i++)
m68ki_set_one(ostruct->match | i, ostruct);
ostruct++;
}
while(ostruct->mask == 0xf1ff)
{
for(i = 0;i <= 0x07;i++)
m68ki_set_one(ostruct->match | (i << 9), ostruct);
ostruct++;
}
while(ostruct->mask == 0xfff8)
{
for(i = 0;i <= 0x07;i++)
m68ki_set_one(ostruct->match | i, ostruct);
ostruct++;
}
while(ostruct->mask == 0xffff)
{
m68ki_set_one(ostruct->match, ostruct);
ostruct++;
}
// if we fell all the way through with a non-zero mask, the opcode table wasn't built properly
if (ostruct->mask != 0)
{
fatalerror("m68ki_build_opcode_table: unhandled opcode mask %x (match %x), m68k core will not function!\n", ostruct->mask, ostruct->match);
}
}
/* ======================================================================== */
/* ============================== END OF FILE ============================= */
/* ======================================================================== */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
M68KMAKE_OPCODE_HANDLER_HEADER
/* ======================================================================== */
/* ========================= INSTRUCTION HANDLERS ========================= */
/* ======================================================================== */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
M68KMAKE_OPCODE_HANDLER_FOOTER
/* ======================================================================== */
/* ============================== END OF FILE ============================= */
/* ======================================================================== */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
M68KMAKE_TABLE_BODY
M68KMAKE_TABLE
/*
The following table is arranged as follows:
@ -881,7 +684,7 @@ unpk 16 mm . 1000...110001... .......... . . U U U U U . . 1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
M68KMAKE_OPCODE_HANDLER_BODY
M68KMAKE_OPCODE_HANDLER
M68KMAKE_OP(1010, 0, ., .)
{
@ -10541,5 +10344,3 @@ M68KMAKE_OP(cpush, 32, ., .)
m68ki_exception_1111();
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
M68KMAKE_END

View File

@ -29,6 +29,11 @@ static const char copyright_notice[] =
#include "m68000.h"
#include "m68kdasm.h"
// Generated data
m68000_base_device::opcode_handler_ptr m68000_base_device::m68ki_instruction_jump_table[NUM_CPU_TYPES][0x10000]; /* opcode handler jump table */
unsigned char m68000_base_device::m68ki_cycles[NUM_CPU_TYPES][0x10000]; /* Cycles used by CPU type */
/* ======================================================================== */
/* ================================= DATA ================================= */
/* ======================================================================== */
@ -2672,3 +2677,107 @@ void mcf5206e_device::device_start()
{
init_cpu_coldfire();
}
void m68000_base_device::m68ki_set_one(unsigned short opcode, const opcode_handler_struct *s)
{
for(int i=0; i<NUM_CPU_TYPES; i++)
if(s->cycles[i] != 0xff) {
m68ki_cycles[i][opcode] = s->cycles[i];
m68ki_instruction_jump_table[i][opcode] = s->opcode_handler;
}
}
void m68000_base_device::m68ki_build_opcode_table()
{
const opcode_handler_struct *ostruct;
int i;
int j;
int k;
for(i = 0; i < 0x10000; i++)
{
/* default to illegal */
for(k=0;k<NUM_CPU_TYPES;k++)
{
m68ki_instruction_jump_table[k][i] = &m68000_base_device::m68k_op_illegal;
m68ki_cycles[k][i] = 0;
}
}
ostruct = m68k_opcode_handler_table;
while(ostruct->mask != 0xff00)
{
for(i = 0;i < 0x10000;i++)
{
if((i & ostruct->mask) == ostruct->match)
m68ki_set_one(i, ostruct);
}
ostruct++;
}
while(ostruct->mask == 0xff00)
{
for(i = 0;i <= 0xff;i++)
m68ki_set_one(ostruct->match | i, ostruct);
ostruct++;
}
while(ostruct->mask == 0xff20)
{
for(i = 0;i < 4;i++)
{
for(j = 0;j < 32;j++)
{
m68ki_set_one(ostruct->match | (i << 6) | j, ostruct);
}
}
ostruct++;
}
while(ostruct->mask == 0xf1f8)
{
for(i = 0;i < 8;i++)
{
for(j = 0;j < 8;j++)
m68ki_set_one(ostruct->match | (i << 9) | j, ostruct);
}
ostruct++;
}
while(ostruct->mask == 0xffd8)
{
for(i = 0;i < 2;i++)
{
for(j = 0;j < 8;j++)
{
m68ki_set_one(ostruct->match | (i << 5) | j, ostruct);
}
}
ostruct++;
}
while(ostruct->mask == 0xfff0)
{
for(i = 0;i <= 0x0f;i++)
m68ki_set_one(ostruct->match | i, ostruct);
ostruct++;
}
while(ostruct->mask == 0xf1ff)
{
for(i = 0;i <= 0x07;i++)
m68ki_set_one(ostruct->match | (i << 9), ostruct);
ostruct++;
}
while(ostruct->mask == 0xfff8)
{
for(i = 0;i <= 0x07;i++)
m68ki_set_one(ostruct->match | i, ostruct);
ostruct++;
}
while(ostruct->mask == 0xffff)
{
m68ki_set_one(ostruct->match, ostruct);
ostruct++;
}
// if we fell all the way through with a non-zero mask, the opcode table wasn't built properly
if (ostruct->mask != 0)
{
fatalerror("m68ki_build_opcode_table: unhandled opcode mask %x (match %x), m68k core will not function!\n", ostruct->mask, ostruct->match);
}
}

View File

@ -249,24 +249,10 @@ class Info:
# first block skipped
for i in range(1, len(blocks)):
b = blocks[i]
if b.startswith('M68KMAKE_PROTOTYPE_HEADER\n\n'):
self.prototype_header = b[27:]
elif b.startswith('M68KMAKE_PROTOTYPE_FOOTER\n\n'):
self.prototype_footer = b[27:]
elif b.startswith('M68KMAKE_TABLE_HEADER\n\n'):
self.table_header = b[23:]
elif b.startswith('M68KMAKE_TABLE_FOOTER\n\n'):
self.table_footer = b[23:]
elif b.startswith('M68KMAKE_OPCODE_HANDLER_HEADER\n\n'):
self.opcode_handler_header = b[32:]
elif b.startswith('M68KMAKE_OPCODE_HANDLER_FOOTER\n\n'):
self.opcode_handler_footer = b[32:]
elif b.startswith('M68KMAKE_TABLE_BODY\n'):
if b.startswith('M68KMAKE_TABLE\n'):
self.handle_table_body(b[20:])
elif b.startswith('M68KMAKE_OPCODE_HANDLER_BODY\n\n'):
elif b.startswith('M68KMAKE_OPCODE_HANDLER\n\n'):
self.handle_opcode_handler_body(b[30:])
elif b.startswith('M68KMAKE_END\n\n'):
pass
def handle_table_body(self, b):
s1 = b[b.index('M68KMAKE_TABLE_START\n')+21:]
@ -289,10 +275,8 @@ class Info:
def save_header(self, f):
f.write("// Generated source, edits will be lost. Run m68kmake.py instead\n")
f.write("\n")
f.write(self.prototype_header)
for h in self.opcode_handlers:
f.write('void %s();\n' % h.function_name)
f.write(self.prototype_footer)
def save_source(self, f):
f.write("// Generated source, edits will be lost. Run m68kmake.py instead\n")
@ -300,11 +284,9 @@ class Info:
f.write("#include \"emu.h\"\n")
f.write("#include \"m68000.h\"\n")
f.write("\n")
f.write(self.opcode_handler_header)
for h in self.opcode_handlers:
f.write('void m68000_base_device::%s()\n%s' % (h.function_name, h.body))
f.write(self.opcode_handler_footer)
f.write(self.table_header)
f.write("const m68000_base_device::opcode_handler_struct m68000_base_device::m68k_opcode_handler_table[] =\n{\n")
order = list(range(len(self.opcode_handlers)))
order.sort(key = lambda id: "%02d %04x %04x" % (self.opcode_handlers[id].bits, self.opcode_handlers[id].op_mask, self.opcode_handlers[id].op_value))
for id in order:
@ -315,7 +297,7 @@ class Info:
f.write(", ")
f.write("%3d" % (255 if oh.cycles[i] == None else oh.cycles[i]))
f.write("}},\n")
f.write(self.table_footer)
f.write("\t{nullptr, 0, 0, {0, 0, 0, 0, 0}}\n};\n")
def main(argv):
if len(argv) != 4:

View File

@ -3,13 +3,6 @@
#include "emu.h"
#include "m68000.h"
/* ======================================================================== */
/* ========================= INSTRUCTION HANDLERS ========================= */
/* ======================================================================== */
void m68000_base_device::m68k_op_1010()
{
m68ki_exception_1010();
@ -32732,39 +32725,8 @@ void m68000_base_device::m68k_op_cpush_32()
m68ki_exception_1111();
}
/* ======================================================================== */
/* ============================== END OF FILE ============================= */
/* ======================================================================== */
/* ======================================================================== */
/* ========================= OPCODE TABLE BUILDER ========================= */
/* ======================================================================== */
m68000_base_device::opcode_handler_ptr m68000_base_device::m68ki_instruction_jump_table[NUM_CPU_TYPES][0x10000]; /* opcode handler jump table */
unsigned char m68000_base_device::m68ki_cycles[NUM_CPU_TYPES][0x10000]; /* Cycles used by CPU type */
/* Build the opcode handler jump table */
void m68000_base_device::m68ki_set_one(unsigned short opcode, const opcode_handler_struct *s)
const m68000_base_device::opcode_handler_struct m68000_base_device::m68k_opcode_handler_table[] =
{
for(int i=0; i<NUM_CPU_TYPES; i++)
if(s->cycles[i] != 0xff) {
m68ki_cycles[i][opcode] = s->cycles[i];
m68ki_instruction_jump_table[i][opcode] = s->opcode_handler;
}
}
void m68000_base_device::m68ki_build_opcode_table(void)
{
/* Opcode handler table */
static const opcode_handler_struct m68k_opcode_handler_table[] =
{
/* function mask match 000 010 020 040 */
{&m68000_base_device::m68k_op_1010, 0xf000, 0xa000, { 4, 4, 4, 4, 4, 4, 4}},
{&m68000_base_device::m68k_op_1111, 0xf000, 0xf000, { 4, 4, 4, 4, 4, 4, 4}},
{&m68000_base_device::m68k_op_moveq_32, 0xf100, 0x7000, { 4, 4, 2, 2, 2, 2, 2}},
@ -34739,105 +34701,3 @@ static const opcode_handler_struct m68k_opcode_handler_table[] =
{&m68000_base_device::m68k_op_bfins_32_al, 0xffff, 0xeff9, {255, 255, 21, 21, 21, 21, 17}},
{nullptr, 0, 0, {0, 0, 0, 0, 0}}
};
const opcode_handler_struct *ostruct;
int i;
int j;
int k;
for(i = 0; i < 0x10000; i++)
{
/* default to illegal */
for(k=0;k<NUM_CPU_TYPES;k++)
{
m68ki_instruction_jump_table[k][i] = &m68000_base_device::m68k_op_illegal;
m68ki_cycles[k][i] = 0;
}
}
ostruct = m68k_opcode_handler_table;
while(ostruct->mask != 0xff00)
{
for(i = 0;i < 0x10000;i++)
{
if((i & ostruct->mask) == ostruct->match)
m68ki_set_one(i, ostruct);
}
ostruct++;
}
while(ostruct->mask == 0xff00)
{
for(i = 0;i <= 0xff;i++)
m68ki_set_one(ostruct->match | i, ostruct);
ostruct++;
}
while(ostruct->mask == 0xff20)
{
for(i = 0;i < 4;i++)
{
for(j = 0;j < 32;j++)
{
m68ki_set_one(ostruct->match | (i << 6) | j, ostruct);
}
}
ostruct++;
}
while(ostruct->mask == 0xf1f8)
{
for(i = 0;i < 8;i++)
{
for(j = 0;j < 8;j++)
m68ki_set_one(ostruct->match | (i << 9) | j, ostruct);
}
ostruct++;
}
while(ostruct->mask == 0xffd8)
{
for(i = 0;i < 2;i++)
{
for(j = 0;j < 8;j++)
{
m68ki_set_one(ostruct->match | (i << 5) | j, ostruct);
}
}
ostruct++;
}
while(ostruct->mask == 0xfff0)
{
for(i = 0;i <= 0x0f;i++)
m68ki_set_one(ostruct->match | i, ostruct);
ostruct++;
}
while(ostruct->mask == 0xf1ff)
{
for(i = 0;i <= 0x07;i++)
m68ki_set_one(ostruct->match | (i << 9), ostruct);
ostruct++;
}
while(ostruct->mask == 0xfff8)
{
for(i = 0;i <= 0x07;i++)
m68ki_set_one(ostruct->match | i, ostruct);
ostruct++;
}
while(ostruct->mask == 0xffff)
{
m68ki_set_one(ostruct->match, ostruct);
ostruct++;
}
// if we fell all the way through with a non-zero mask, the opcode table wasn't built properly
if (ostruct->mask != 0)
{
fatalerror("m68ki_build_opcode_table: unhandled opcode mask %x (match %x), m68k core will not function!\n", ostruct->mask, ostruct->match);
}
}
/* ======================================================================== */
/* ============================== END OF FILE ============================= */
/* ======================================================================== */

View File

@ -1,33 +1,5 @@
// Generated source, edits will be lost. Run m68kmake.py instead
// license:BSD-3-Clause
// copyright-holders:Karl Stenerud
static constexpr int NUM_CPU_TYPES = 7;
typedef void (m68000_base_device::*opcode_handler_ptr)();
static opcode_handler_ptr m68ki_instruction_jump_table[NUM_CPU_TYPES][0x10000]; /* opcode handler jump table */
static unsigned char m68ki_cycles[NUM_CPU_TYPES][0x10000]; /* Cycles used by CPU type */
/* This is used to generate the opcode handler jump table */
struct opcode_handler_struct
{
opcode_handler_ptr opcode_handler; /* handler function */
unsigned int mask; /* mask on opcode */
unsigned int match; /* what to match after masking */
unsigned char cycles[NUM_CPU_TYPES]; /* cycles each cpu type takes */
};
/* Build the opcode handler table */
static void m68ki_set_one(unsigned short opcode, const opcode_handler_struct *s);
static void m68ki_build_opcode_table(void);
/* ======================================================================== */
/* ============================ OPCODE HANDLERS =========================== */
/* ======================================================================== */
void m68k_op_1010();
void m68k_op_1111();
void m68k_op_040fpu0_32();
@ -2000,10 +1972,3 @@ void m68k_op_unpk_16_mm_axy7();
void m68k_op_unpk_16_mm();
void m68k_op_cinv_32();
void m68k_op_cpush_32();
/* ======================================================================== */
/* ============================== END OF FILE ============================= */
/* ======================================================================== */