[PPC] Shuffle code around to make it cleaner to modify by hand.

- [PPC] Rename ppc_opcode_lookup.cc, ppc_opcode_table.cc to have a _gen
suffix to make it more obvious about their autogenerated nature.
- [PPC] Move autogenerated code from ppc_opcode_disasm.cc to
ppc_opcode_disasm_gen.cc.
- [PPC] Update ppc-table-gen to allow for blacklisting of certain
instructions that have custom disasm code.
This commit is contained in:
gibbed 2019-05-13 00:49:57 -05:00
parent d7d69369d1
commit 9d7058ac96
6 changed files with 5471 additions and 5416 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,33 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2015 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_CPU_PPC_PPC_OPCODE_DISASM_H_
#define XENIA_CPU_PPC_PPC_OPCODE_DISASM_H_
#include <cstdint>
#include "xenia/base/string_buffer.h"
#include "xenia/cpu/ppc/ppc_opcode.h"
namespace xe {
namespace cpu {
namespace ppc {
constexpr size_t kNamePad = 11;
const uint8_t kSpaces[kNamePad] = {0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20};
void PadStringBuffer(StringBuffer* str, size_t base, size_t pad);
void PrintDisasm_bcx(const PPCDecodeData& d, StringBuffer* str);
} // namespace ppc
} // namespace cpu
} // namespace xe
#endif // XENIA_CPU_PPC_PPC_OPCODE_INFO_H_

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,9 @@ import sys
from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring, dump
custom_disasm = ['bcx']
self_path = os.path.dirname(os.path.abspath(__file__))
@ -286,19 +289,13 @@ def generate_disasm(insns):
w0('#include "xenia/base/assert.h"')
w0('#include "xenia/cpu/ppc/ppc_decode_data.h"')
w0('#include "xenia/cpu/ppc/ppc_opcode.h"')
w0('#include "xenia/cpu/ppc/ppc_opcode_disasm.h"')
w0('#include "xenia/cpu/ppc/ppc_opcode_info.h"')
w0('')
w0('namespace xe {')
w0('namespace cpu {')
w0('namespace ppc {')
w0('')
w0('constexpr size_t kNamePad = 11;')
w0('const uint8_t kSpaces[kNamePad] = {0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20};')
w0('void PadStringBuffer(StringBuffer* str, size_t base, size_t pad) {')
w1('size_t added_len = str->length() - base;')
w1('if (added_len < pad) str->AppendBytes(kSpaces, kNamePad - added_len);')
w0('}')
w0('')
for i in insns:
i.mnem = '"' + c_mnem(i.mnem) + '"'
@ -319,7 +316,7 @@ def generate_disasm(insns):
# TODO(benvanik): support alts:
# <disasm cond="![RA]">li [RD], [SIMM]</disasm>
for i in insns:
if not i.disasm_str:
if not i.disasm_str or literal_mnem(i.mnem) in custom_disasm:
continue
w0('void PrintDisasm_%s(const PPCDecodeData& d, StringBuffer* str) {' % (literal_mnem(i.mnem)))
w1('// ' + i.disasm_str)
@ -519,11 +516,11 @@ if __name__ == '__main__':
with open(os.path.join(ppc_src_path, 'ppc_opcode.h'), 'w') as f:
f.write(generate_opcodes(insns))
insns = parse_insns(os.path.join(self_path, 'ppc-instructions.xml'))
with open(os.path.join(ppc_src_path, 'ppc_opcode_table.cc'), 'w') as f:
with open(os.path.join(ppc_src_path, 'ppc_opcode_table_gen.cc'), 'w') as f:
f.write(generate_table(insns))
insns = parse_insns(os.path.join(self_path, 'ppc-instructions.xml'))
with open(os.path.join(ppc_src_path, 'ppc_opcode_disasm.cc'), 'w') as f:
with open(os.path.join(ppc_src_path, 'ppc_opcode_disasm_gen.cc'), 'w') as f:
f.write(generate_disasm(insns))
insns = parse_insns(os.path.join(self_path, 'ppc-instructions.xml'))
with open(os.path.join(ppc_src_path, 'ppc_opcode_lookup.cc'), 'w') as f:
with open(os.path.join(ppc_src_path, 'ppc_opcode_lookup_gen.cc'), 'w') as f:
f.write(generate_lookup(insns))