Adding instruction emitting functions.

All empty, all ready to go!
This commit is contained in:
Ben Vanik 2013-01-21 11:55:42 -08:00
parent 95a8be078b
commit b29dd22850
10 changed files with 1516 additions and 16 deletions

View File

@ -133,15 +133,6 @@ typedef struct {
};
} InstrData;
class Instr {
public:
InstrData instr;
// TODO(benvanik): registers changed, special bits, etc
};
typedef int (*InstrEmitFn)(/* emit context */ Instr* instr);
class InstrType {
public:
uint32_t opcode;
@ -150,11 +141,11 @@ public:
uint32_t flags; // xe_ppc_instr_flag_e
char name[16];
InstrEmitFn emit;
void* emit;
};
InstrType* GetInstrType(uint32_t code);
int RegisterInstrEmit(uint32_t code, InstrEmitFn emit);
int RegisterInstrEmit(uint32_t code, void* emit);
} // namespace ppc

40
src/cpu/codegen/emit.h Normal file
View File

@ -0,0 +1,40 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_CPU_CODEGEN_EMIT_H_
#define XENIA_CPU_CODEGEN_EMIT_H_
#include <xenia/cpu/ppc/instr.h>
namespace xe {
namespace cpu {
namespace codegen {
void RegisterEmitCategoryALU();
void RegisterEmitCategoryControl();
void RegisterEmitCategoryFPU();
void RegisterEmitCategoryMemory();
#define XEEMITTER(name, opcode, format) int InstrEmit_##name
#define XEREGISTEREMITTER(name, opcode) \
RegisterInstrEmit(opcode, (void*)InstrEmit_##name)
#define XEINSTRNOTIMPLEMENTED XEASSERTALWAYS
} // namespace codegen
} // namespace cpu
} // namespace xe
#endif // XENIA_CPU_CODEGEN_EMIT_H_

448
src/cpu/codegen/emit_alu.cc Normal file
View File

@ -0,0 +1,448 @@
/*
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "cpu/codegen/emit.h"
#include <xenia/cpu/codegen/function_generator.h>
using namespace llvm;
using namespace xe::cpu::codegen;
using namespace xe::cpu::ppc;
namespace xe {
namespace cpu {
namespace codegen {
// Integer arithmetic (A-3)
XEEMITTER(addx, 0x7C000214, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(addcx, 0X7C000014, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(addex, 0x7C000114, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(addi, 0x38000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(addic, 0x30000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(addicx, 0x34000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(addis, 0x3C000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(addmex, 0x7C0001D4, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(addzex, 0x7C000194, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(divdx, 0x7C0003D2, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(divdux, 0x7C000392, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(divwx, 0x7C0003D6, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(divwux, 0x7C000396, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mulhdx, 0x7C000092, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mulhdux, 0x7C000012, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mulhwx, 0x7C000096, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mulhwux, 0x7C000016, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mulldx, 0x7C0001D2, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mulli, 0x1C000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mullwx, 0x7C0001D6, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(negx, 0x7C0000D0, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(subfx, 0x7C000050, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(subfcx, 0x7C000010, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(subficx, 0x20000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(subfex, 0x7C000110, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(subfmex, 0x7C0001D0, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(subfzex, 0x7C000190, XO )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Integer compare (A-4)
XEEMITTER(cmp, 0x7C000000, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(cmpi, 0x2C000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(cmpl, 0x7C000040, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(cmpli, 0x28000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Integer logical (A-5)
XEEMITTER(andx, 0x7C000038, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(andcx, 0x7C000078, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(andix, 0x70000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(andisx, 0x74000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(cntlzdx, 0x7C000074, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(cntlzwx, 0x7C000034, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(eqvx, 0x7C000238, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(extsbx, 0x7C000774, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(extshx, 0x7C000734, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(extswx, 0x7C0007B4, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(nandx, 0x7C0003B8, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(norx, 0x7C0000F8, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(orx, 0x7C000378, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(orcx, 0x7C000338, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(ori, 0x60000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(oris, 0x64000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(xorx, 0x7C000278, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(xori, 0x68000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(xoris, 0x6C000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Integer rotate (A-6)
XEEMITTER(rldclx, 0x78000010, MDS)(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(rldcrx, 0x78000012, MDS)(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(rldicx, 0x78000008, MD )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(rldiclx, 0x78000000, MD )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(rldicrx, 0x78000004, MD )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(rldimix, 0x7800000C, MD )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(rlwimix, 0x50000000, M )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(rlwinmx, 0x54000000, M )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(rlwnmx, 0x5C000000, M )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Integer shift (A-7)
XEEMITTER(sldx, 0x7C000036, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(slwx, 0x7C000030, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(sradx, 0x7C000634, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(sradix, 0x7C000674, XS )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(srawx, 0x7C000630, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(srawix, 0x7C000670, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(srdx, 0x7C000436, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(srwx, 0x7C000430, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
void RegisterEmitCategoryALU() {
XEREGISTEREMITTER(addx, 0x7C000214);
XEREGISTEREMITTER(addcx, 0X7C000014);
XEREGISTEREMITTER(addex, 0x7C000114);
XEREGISTEREMITTER(addi, 0x38000000);
XEREGISTEREMITTER(addic, 0x30000000);
XEREGISTEREMITTER(addicx, 0x34000000);
XEREGISTEREMITTER(addis, 0x3C000000);
XEREGISTEREMITTER(addmex, 0x7C0001D4);
XEREGISTEREMITTER(addzex, 0x7C000194);
XEREGISTEREMITTER(divdx, 0x7C0003D2);
XEREGISTEREMITTER(divdux, 0x7C000392);
XEREGISTEREMITTER(divwx, 0x7C0003D6);
XEREGISTEREMITTER(divwux, 0x7C000396);
XEREGISTEREMITTER(mulhdx, 0x7C000092);
XEREGISTEREMITTER(mulhdux, 0x7C000012);
XEREGISTEREMITTER(mulhwx, 0x7C000096);
XEREGISTEREMITTER(mulhwux, 0x7C000016);
XEREGISTEREMITTER(mulldx, 0x7C0001D2);
XEREGISTEREMITTER(mulli, 0x1C000000);
XEREGISTEREMITTER(mullwx, 0x7C0001D6);
XEREGISTEREMITTER(negx, 0x7C0000D0);
XEREGISTEREMITTER(subfx, 0x7C000050);
XEREGISTEREMITTER(subfcx, 0x7C000010);
XEREGISTEREMITTER(subficx, 0x20000000);
XEREGISTEREMITTER(subfex, 0x7C000110);
XEREGISTEREMITTER(subfmex, 0x7C0001D0);
XEREGISTEREMITTER(subfzex, 0x7C000190);
XEREGISTEREMITTER(cmp, 0x7C000000);
XEREGISTEREMITTER(cmpi, 0x2C000000);
XEREGISTEREMITTER(cmpl, 0x7C000040);
XEREGISTEREMITTER(cmpli, 0x28000000);
XEREGISTEREMITTER(andx, 0x7C000038);
XEREGISTEREMITTER(andcx, 0x7C000078);
XEREGISTEREMITTER(andix, 0x70000000);
XEREGISTEREMITTER(andisx, 0x74000000);
XEREGISTEREMITTER(cntlzdx, 0x7C000074);
XEREGISTEREMITTER(cntlzwx, 0x7C000034);
XEREGISTEREMITTER(eqvx, 0x7C000238);
XEREGISTEREMITTER(extsbx, 0x7C000774);
XEREGISTEREMITTER(extshx, 0x7C000734);
XEREGISTEREMITTER(extswx, 0x7C0007B4);
XEREGISTEREMITTER(nandx, 0x7C0003B8);
XEREGISTEREMITTER(norx, 0x7C0000F8);
XEREGISTEREMITTER(orx, 0x7C000378);
XEREGISTEREMITTER(orcx, 0x7C000338);
XEREGISTEREMITTER(ori, 0x60000000);
XEREGISTEREMITTER(oris, 0x64000000);
XEREGISTEREMITTER(xorx, 0x7C000278);
XEREGISTEREMITTER(xori, 0x68000000);
XEREGISTEREMITTER(xoris, 0x6C000000);
XEREGISTEREMITTER(rldclx, 0x78000010);
XEREGISTEREMITTER(rldcrx, 0x78000012);
XEREGISTEREMITTER(rldicx, 0x78000008);
XEREGISTEREMITTER(rldiclx, 0x78000000);
XEREGISTEREMITTER(rldicrx, 0x78000004);
XEREGISTEREMITTER(rldimix, 0x7800000C);
XEREGISTEREMITTER(rlwimix, 0x50000000);
XEREGISTEREMITTER(rlwinmx, 0x54000000);
XEREGISTEREMITTER(rlwnmx, 0x5C000000);
XEREGISTEREMITTER(sldx, 0x7C000036);
XEREGISTEREMITTER(slwx, 0x7C000030);
XEREGISTEREMITTER(sradx, 0x7C000634);
XEREGISTEREMITTER(sradix, 0x7C000674);
XEREGISTEREMITTER(srawx, 0x7C000630);
XEREGISTEREMITTER(srawix, 0x7C000670);
XEREGISTEREMITTER(srdx, 0x7C000436);
XEREGISTEREMITTER(srwx, 0x7C000430);
}
} // namespace codegen
} // namespace cpu
} // namespace xe

View File

@ -0,0 +1,182 @@
/*
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "cpu/codegen/emit.h"
#include <xenia/cpu/codegen/function_generator.h>
using namespace llvm;
using namespace xe::cpu::codegen;
using namespace xe::cpu::ppc;
namespace xe {
namespace cpu {
namespace codegen {
XEEMITTER(bx, 0x48000000, I )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(bcx, 0x40000000, B )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(bcctrx, 0x4C000420, XL )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(bclrx, 0x4C000020, XL )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Condition register logical (A-23)
XEEMITTER(crand, 0x4C000202, XL )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(crandc, 0x4C000102, XL )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(creqv, 0x4C000242, XL )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(crnand, 0x4C0001C2, XL )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(crnor, 0x4C000042, XL )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(cror, 0x4C000382, XL )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(crorc, 0x4C000342, XL )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(crxor, 0x4C000182, XL )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mcrf, 0x4C000000, XL )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// System linkage (A-24)
XEEMITTER(sc, 0x44000002, SC )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Trap (A-25)
XEEMITTER(td, 0x7C000088, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(tdi, 0x08000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(tw, 0x7C000008, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(twi, 0x0C000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Processor control (A-26)
XEEMITTER(mfcr, 0x7C000026, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mfspr, 0x7C0002A6, XFX)(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mftb, 0x7C0002E6, XFX)(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mtcrf, 0x7C000120, XFX)(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mtspr, 0x7C0003A6, XFX)(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
void RegisterEmitCategoryControl() {
XEREGISTEREMITTER(bx, 0x48000000);
XEREGISTEREMITTER(bcx, 0x40000000);
XEREGISTEREMITTER(bcctrx, 0x4C000420);
XEREGISTEREMITTER(bclrx, 0x4C000020);
XEREGISTEREMITTER(crand, 0x4C000202);
XEREGISTEREMITTER(crandc, 0x4C000102);
XEREGISTEREMITTER(creqv, 0x4C000242);
XEREGISTEREMITTER(crnand, 0x4C0001C2);
XEREGISTEREMITTER(crnor, 0x4C000042);
XEREGISTEREMITTER(cror, 0x4C000382);
XEREGISTEREMITTER(crorc, 0x4C000342);
XEREGISTEREMITTER(crxor, 0x4C000182);
XEREGISTEREMITTER(mcrf, 0x4C000000);
XEREGISTEREMITTER(sc, 0x44000002);
XEREGISTEREMITTER(td, 0x7C000088);
XEREGISTEREMITTER(tdi, 0x08000000);
XEREGISTEREMITTER(tw, 0x7C000008);
XEREGISTEREMITTER(twi, 0x0C000000);
XEREGISTEREMITTER(mfcr, 0x7C000026);
XEREGISTEREMITTER(mfspr, 0x7C0002A6);
XEREGISTEREMITTER(mftb, 0x7C0002E6);
XEREGISTEREMITTER(mtcrf, 0x7C000120);
XEREGISTEREMITTER(mtspr, 0x7C0003A6);
}
} // namespace codegen
} // namespace cpu
} // namespace xe

283
src/cpu/codegen/emit_fpu.cc Normal file
View File

@ -0,0 +1,283 @@
/*
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "cpu/codegen/emit.h"
#include <xenia/cpu/codegen/function_generator.h>
using namespace llvm;
using namespace xe::cpu::codegen;
using namespace xe::cpu::ppc;
namespace xe {
namespace cpu {
namespace codegen {
// Floating-point arithmetic (A-8)
XEEMITTER(faddx, 0xFC00002A, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(faddsx, 0xEC00002A, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fdivx, 0xFC000024, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fdivsx, 0xEC000024, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fmulx, 0xFC000032, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fmulsx, 0xEC000032, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fresx, 0xEC000030, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(frsqrtex, 0xFC000034, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fsubx, 0xFC000028, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fsubsx, 0xEC000028, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fselx, 0xFC00002E, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fsqrtx, 0xFC00002C, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fsqrtsx, 0xEC00002C, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Floating-point multiply-add (A-9)
XEEMITTER(fmaddx, 0xFC00003A, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fmaddsx, 0xEC00003A, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fmsubx, 0xFC000038, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fmsubsx, 0xEC000038, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fnmaddx, 0xFC00003E, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fnmaddsx, 0xEC00003E, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fnmsubx, 0xFC00003C, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fnmsubsx, 0xEC00003C, A )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Floating-point rounding and conversion (A-10)
XEEMITTER(fcfidx, 0xFC00069C, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fctidx, 0xFC00065C, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fctidzx, 0xFC00065E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fctiwx, 0xFC00001C, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fctiwzx, 0xFC00001E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(frspx, 0xFC000018, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Floating-point compare (A-11)
XEEMITTER(fcmpo, 0xFC000040, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fcmpu, 0xFC000000, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Floating-point status and control register (A
XEEMITTER(mcrfs, 0xFC000080, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mffsx, 0xFC00048E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mtfsb0x, 0xFC00008C, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mtfsb1x, 0xFC00004C, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mtfsfx, 0xFC00058E, XFL)(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(mtfsfix, 0xFC00010C, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Floating-point move (A-21)
XEEMITTER(fabsx, 0xFC000210, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fmrx, 0xFC000090, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fnabsx, 0xFC000110, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(fnegx, 0xFC000050, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
void RegisterEmitCategoryFPU() {
XEREGISTEREMITTER(faddx, 0xFC00002A);
XEREGISTEREMITTER(faddsx, 0xEC00002A);
XEREGISTEREMITTER(fdivx, 0xFC000024);
XEREGISTEREMITTER(fdivsx, 0xEC000024);
XEREGISTEREMITTER(fmulx, 0xFC000032);
XEREGISTEREMITTER(fmulsx, 0xEC000032);
XEREGISTEREMITTER(fresx, 0xEC000030);
XEREGISTEREMITTER(frsqrtex, 0xFC000034);
XEREGISTEREMITTER(fsubx, 0xFC000028);
XEREGISTEREMITTER(fsubsx, 0xEC000028);
XEREGISTEREMITTER(fselx, 0xFC00002E);
XEREGISTEREMITTER(fsqrtx, 0xFC00002C);
XEREGISTEREMITTER(fsqrtsx, 0xEC00002C);
XEREGISTEREMITTER(fmaddx, 0xFC00003A);
XEREGISTEREMITTER(fmaddsx, 0xEC00003A);
XEREGISTEREMITTER(fmsubx, 0xFC000038);
XEREGISTEREMITTER(fmsubsx, 0xEC000038);
XEREGISTEREMITTER(fnmaddx, 0xFC00003E);
XEREGISTEREMITTER(fnmaddsx, 0xEC00003E);
XEREGISTEREMITTER(fnmsubx, 0xFC00003C);
XEREGISTEREMITTER(fnmsubsx, 0xEC00003C);
XEREGISTEREMITTER(fcfidx, 0xFC00069C);
XEREGISTEREMITTER(fctidx, 0xFC00065C);
XEREGISTEREMITTER(fctidzx, 0xFC00065E);
XEREGISTEREMITTER(fctiwx, 0xFC00001C);
XEREGISTEREMITTER(fctiwzx, 0xFC00001E);
XEREGISTEREMITTER(frspx, 0xFC000018);
XEREGISTEREMITTER(fcmpo, 0xFC000040);
XEREGISTEREMITTER(fcmpu, 0xFC000000);
XEREGISTEREMITTER(mcrfs, 0xFC000080);
XEREGISTEREMITTER(mffsx, 0xFC00048E);
XEREGISTEREMITTER(mtfsb0x, 0xFC00008C);
XEREGISTEREMITTER(mtfsb1x, 0xFC00004C);
XEREGISTEREMITTER(mtfsfx, 0xFC00058E);
XEREGISTEREMITTER(mtfsfix, 0xFC00010C);
XEREGISTEREMITTER(fabsx, 0xFC000210);
XEREGISTEREMITTER(fmrx, 0xFC000090);
XEREGISTEREMITTER(fnabsx, 0xFC000110);
XEREGISTEREMITTER(fnegx, 0xFC000050);
}
} // namespace codegen
} // namespace cpu
} // namespace xe

View File

@ -0,0 +1,542 @@
/*
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "cpu/codegen/emit.h"
#include <xenia/cpu/codegen/function_generator.h>
using namespace llvm;
using namespace xe::cpu::codegen;
using namespace xe::cpu::ppc;
namespace xe {
namespace cpu {
namespace codegen {
// Integer load (A-13)
XEEMITTER(lbz, 0x88000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lbzu, 0x8C000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lbzux, 0x7C0000EE, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lbzx, 0x7C0000AE, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(ld, 0xE8000000, DS )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(ldux, 0x7C00006A, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(ldx, 0x7C00002A, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lha, 0xA8000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lhau, 0xAC000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lhaux, 0x7C0002EE, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lhax, 0x7C0002AE, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lhz, 0xA0000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lhzu, 0xA4000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lhzux, 0x7C00026E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lhzx, 0x7C00022E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lwa, 0xE8000002, DS )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lwaux, 0x7C0002EA, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lwax, 0x7C0002AA, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lwz, 0x80000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lwzu, 0x84000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lwzux, 0x7C00006E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lwzx, 0x7C00002E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Integer store (A-14)
XEEMITTER(stb, 0x98000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stbu, 0x9C000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stbux, 0x7C0001EE, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stbx, 0x7C0001AE, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(std, 0xF8000000, DS )(FunctionGenerator& g, InstrData& i) {
//const uint64 b = r(instr.DS.A);
//const uint64 EA = b + EXTS16(instr.DS.ds << 2);
//MEMSET64(EA, instr.DS.S);
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stdu, 0xF8000001, DS )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stdux, 0x7C00016A, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stdx, 0x7C00012A, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(sth, 0xB0000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(sthu, 0xB4000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(sthux, 0x7C00036E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(sthx, 0x7C00032E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stw, 0x90000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stwu, 0x94000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stwux, 0x7C00016E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stwx, 0x7C00012E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Integer load and store with byte reverse (A-1
XEEMITTER(lhbrx, 0x7C00062C, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lwbrx, 0x7C00042C, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(ldbrx, 0x7C000428, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(sthbrx, 0x7C00072C, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stwbrx, 0x7C00052C, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stdbrx, 0x7C000528, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Integer load and store multiple (A-16)
XEEMITTER(lmw, 0xB8000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stmw, 0xBC000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Integer load and store string (A-17)
XEEMITTER(lswi, 0x7C0004AA, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lswx, 0x7C00042A, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stswi, 0x7C0005AA, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stswx, 0x7C00052A, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Memory synchronization (A-18)
XEEMITTER(eieio, 0x7C0006AC, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(isync, 0x4C00012C, XL )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(ldarx, 0x7C0000A8, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lwarx, 0x7C000028, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stdcx, 0x7C0001AD, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stwcx, 0x7C00012D, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(sync, 0x7C0004AC, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Floating-point load (A-19)
XEEMITTER(lfd, 0xC8000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lfdu, 0xCC000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lfdux, 0x7C0004EE, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lfdx, 0x7C0004AE, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lfs, 0xC0000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lfsu, 0xC4000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lfsux, 0x7C00046E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(lfsx, 0x7C00042E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Floating-point store (A-20)
XEEMITTER(stfd, 0xD8000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stfdu, 0xDC000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stfdux, 0x7C0005EE, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stfdx, 0x7C0005AE, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stfiwx, 0x7C0007AE, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stfs, 0xD0000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stfsu, 0xD4000000, D )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stfsux, 0x7C00056E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(stfsx, 0x7C00052E, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
// Cache management (A-27)
XEEMITTER(dcbf, 0x7C0000AC, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(dcbst, 0x7C00006C, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(dcbt, 0x7C00022C, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(dcbtst, 0x7C0001EC, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(dcbz, 0x7C0007EC, X )(FunctionGenerator& g, InstrData& i) {
// or dcbz128 0x7C2007EC
XEINSTRNOTIMPLEMENTED();
return 1;
}
XEEMITTER(icbi, 0x7C0007AC, X )(FunctionGenerator& g, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
}
void RegisterEmitCategoryMemory() {
XEREGISTEREMITTER(lbz, 0x88000000);
XEREGISTEREMITTER(lbzu, 0x8C000000);
XEREGISTEREMITTER(lbzux, 0x7C0000EE);
XEREGISTEREMITTER(lbzx, 0x7C0000AE);
XEREGISTEREMITTER(ld, 0xE8000000);
XEREGISTEREMITTER(ldux, 0x7C00006A);
XEREGISTEREMITTER(ldx, 0x7C00002A);
XEREGISTEREMITTER(lha, 0xA8000000);
XEREGISTEREMITTER(lhau, 0xAC000000);
XEREGISTEREMITTER(lhaux, 0x7C0002EE);
XEREGISTEREMITTER(lhax, 0x7C0002AE);
XEREGISTEREMITTER(lhz, 0xA0000000);
XEREGISTEREMITTER(lhzu, 0xA4000000);
XEREGISTEREMITTER(lhzux, 0x7C00026E);
XEREGISTEREMITTER(lhzx, 0x7C00022E);
XEREGISTEREMITTER(lwa, 0xE8000002);
XEREGISTEREMITTER(lwaux, 0x7C0002EA);
XEREGISTEREMITTER(lwax, 0x7C0002AA);
XEREGISTEREMITTER(lwz, 0x80000000);
XEREGISTEREMITTER(lwzu, 0x84000000);
XEREGISTEREMITTER(lwzux, 0x7C00006E);
XEREGISTEREMITTER(lwzx, 0x7C00002E);
XEREGISTEREMITTER(stb, 0x98000000);
XEREGISTEREMITTER(stbu, 0x9C000000);
XEREGISTEREMITTER(stbux, 0x7C0001EE);
XEREGISTEREMITTER(stbx, 0x7C0001AE);
XEREGISTEREMITTER(std, 0xF8000000);
XEREGISTEREMITTER(stdu, 0xF8000001);
XEREGISTEREMITTER(stdux, 0x7C00016A);
XEREGISTEREMITTER(stdx, 0x7C00012A);
XEREGISTEREMITTER(sth, 0xB0000000);
XEREGISTEREMITTER(sthu, 0xB4000000);
XEREGISTEREMITTER(sthux, 0x7C00036E);
XEREGISTEREMITTER(sthx, 0x7C00032E);
XEREGISTEREMITTER(stw, 0x90000000);
XEREGISTEREMITTER(stwu, 0x94000000);
XEREGISTEREMITTER(stwux, 0x7C00016E);
XEREGISTEREMITTER(stwx, 0x7C00012E);
XEREGISTEREMITTER(lhbrx, 0x7C00062C);
XEREGISTEREMITTER(lwbrx, 0x7C00042C);
XEREGISTEREMITTER(ldbrx, 0x7C000428);
XEREGISTEREMITTER(sthbrx, 0x7C00072C);
XEREGISTEREMITTER(stwbrx, 0x7C00052C);
XEREGISTEREMITTER(stdbrx, 0x7C000528);
XEREGISTEREMITTER(lmw, 0xB8000000);
XEREGISTEREMITTER(stmw, 0xBC000000);
XEREGISTEREMITTER(lswi, 0x7C0004AA);
XEREGISTEREMITTER(lswx, 0x7C00042A);
XEREGISTEREMITTER(stswi, 0x7C0005AA);
XEREGISTEREMITTER(stswx, 0x7C00052A);
XEREGISTEREMITTER(eieio, 0x7C0006AC);
XEREGISTEREMITTER(isync, 0x4C00012C);
XEREGISTEREMITTER(ldarx, 0x7C0000A8);
XEREGISTEREMITTER(lwarx, 0x7C000028);
XEREGISTEREMITTER(stdcx, 0x7C0001AD);
XEREGISTEREMITTER(stwcx, 0x7C00012D);
XEREGISTEREMITTER(sync, 0x7C0004AC);
XEREGISTEREMITTER(lfd, 0xC8000000);
XEREGISTEREMITTER(lfdu, 0xCC000000);
XEREGISTEREMITTER(lfdux, 0x7C0004EE);
XEREGISTEREMITTER(lfdx, 0x7C0004AE);
XEREGISTEREMITTER(lfs, 0xC0000000);
XEREGISTEREMITTER(lfsu, 0xC4000000);
XEREGISTEREMITTER(lfsux, 0x7C00046E);
XEREGISTEREMITTER(lfsx, 0x7C00042E);
XEREGISTEREMITTER(stfd, 0xD8000000);
XEREGISTEREMITTER(stfdu, 0xDC000000);
XEREGISTEREMITTER(stfdux, 0x7C0005EE);
XEREGISTEREMITTER(stfdx, 0x7C0005AE);
XEREGISTEREMITTER(stfiwx, 0x7C0007AE);
XEREGISTEREMITTER(stfs, 0xD0000000);
XEREGISTEREMITTER(stfsu, 0xD4000000);
XEREGISTEREMITTER(stfsux, 0x7C00056E);
XEREGISTEREMITTER(stfsx, 0x7C00052E);
XEREGISTEREMITTER(dcbf, 0x7C0000AC);
XEREGISTEREMITTER(dcbst, 0x7C00006C);
XEREGISTEREMITTER(dcbt, 0x7C00022C);
XEREGISTEREMITTER(dcbtst, 0x7C0001EC);
XEREGISTEREMITTER(dcbz, 0x7C0007EC);
XEREGISTEREMITTER(icbi, 0x7C0007AC);
}
} // namespace codegen
} // namespace cpu
} // namespace xe

View File

@ -1,6 +1,10 @@
# Copyright 2013 Ben Vanik. All Rights Reserved.
{
'sources': [
'emit_alu.cc',
'emit_control.cc',
'emit_fpu.cc',
'emit_memory.cc',
'function_generator.cc',
'module_generator.cc',
],

View File

@ -27,8 +27,8 @@ InstrType* xe::cpu::ppc::GetInstrType(uint32_t code) {
slot = &xe::cpu::ppc::tables::instr_table_19[XESELECTBITS(code, 1, 10)];
break;
case 30:
// Opcode = 30, index = bits 5-1 (5)
slot = &xe::cpu::ppc::tables::instr_table_30[XESELECTBITS(code, 1, 5)];
// Opcode = 30, index = bits 4-1 (4)
slot = &xe::cpu::ppc::tables::instr_table_30[XESELECTBITS(code, 1, 4)];
break;
case 31:
// Opcode = 31, index = bits 10-1 (10)
@ -60,8 +60,9 @@ InstrType* xe::cpu::ppc::GetInstrType(uint32_t code) {
return slot;
}
int xe::cpu::ppc::RegisterInstrEmit(uint32_t code, InstrEmitFn emit) {
int xe::cpu::ppc::RegisterInstrEmit(uint32_t code, void* emit) {
InstrType* instr_type = GetInstrType(code);
XEASSERTNOTNULL(instr_type);
if (!instr_type) {
return 1;
}

View File

@ -72,7 +72,7 @@ static InstrType instr_table_19_unprep[] = {
static InstrType* instr_table_19 = instr_table_prep(
instr_table_19_unprep, XECOUNT(instr_table_19_unprep), 1, 10);
// Opcode = 30, index = bits 5-1 (5)
// Opcode = 30, index = bits 4-1 (4)
static InstrType instr_table_30_unprep[] = {
INSTRUCTION(rldiclx, 0x78000000, MD , General , 0),
INSTRUCTION(rldicrx, 0x78000004, MD , General , 0),
@ -82,7 +82,7 @@ static InstrType instr_table_30_unprep[] = {
INSTRUCTION(rldcrx, 0x78000012, MDS, General , 0),
};
static InstrType* instr_table_30 = instr_table_prep(
instr_table_30_unprep, XECOUNT(instr_table_30_unprep), 2, 4);
instr_table_30_unprep, XECOUNT(instr_table_30_unprep), 1, 4);
// Opcode = 31, index = bits 10-1 (10)
static InstrType instr_table_31_unprep[] = {

View File

@ -17,6 +17,8 @@
#include <llvm/Support/ManagedStatic.h>
#include <llvm/Support/TargetSelect.h>
#include "cpu/codegen/emit.h"
using namespace llvm;
using namespace xe;
@ -28,9 +30,16 @@ Processor::Processor(xe_pal_ref pal, xe_memory_ref memory) {
pal_ = xe_pal_retain(pal);
memory_ = xe_memory_retain(memory);
// TODO(benvanik): only do this once
LLVMLinkInInterpreter();
LLVMLinkInJIT();
InitializeNativeTarget();
// TODO(benvanik): only do this once
codegen::RegisterEmitCategoryALU();
codegen::RegisterEmitCategoryControl();
codegen::RegisterEmitCategoryFPU();
codegen::RegisterEmitCategoryMemory();
}
Processor::~Processor() {