Converting everything to C++ cause I'm a masochist.

This commit is contained in:
Ben Vanik
2013-01-20 01:13:59 -08:00
parent 8a5dcbc1dd
commit ca2908db32
47 changed files with 3966 additions and 3760 deletions

View File

@@ -13,6 +13,12 @@
#include <xenia/common.h>
namespace xe {
namespace cpu {
namespace ppc {
// TODO(benvanik): rename these
typedef enum {
kXEPPCInstrFormatI = 0,
kXEPPCInstrFormatB = 1,
@@ -47,13 +53,12 @@ typedef enum {
} xe_ppc_instr_flag_e;
struct xe_ppc_instr_type;
typedef struct xe_ppc_instr_type xe_ppc_instr_type_t;
class InstrType;
typedef struct {
xe_ppc_instr_type_t *type;
uint32_t address;
InstrType* type;
uint32_t address;
union {
uint32_t code;
@@ -110,28 +115,36 @@ typedef struct {
// kXEPPCInstrFormatVX
// kXEPPCInstrFormatVXR
} data;
} xe_ppc_instr_t;
} InstrData;
typedef struct {
xe_ppc_instr_t instr;
class Instr {
public:
InstrData instr;
// TODO(benvanik): registers changed, special bits, etc
} xe_ppc_dec_instr_t;
typedef int (*xe_ppc_emit_fn)(/* emit context */ xe_ppc_instr_t *instr);
struct xe_ppc_instr_type {
uint32_t opcode;
uint32_t format; // xe_ppc_instr_format_e
uint32_t type; // xe_ppc_instr_type_e
uint32_t flags; // xe_ppc_instr_flag_e
char name[16];
xe_ppc_emit_fn emit;
};
xe_ppc_instr_type_t *xe_ppc_get_instr_type(uint32_t code);
int xe_ppc_register_instr_emit(uint32_t code, xe_ppc_emit_fn emit);
typedef int (*InstrEmitFn)(/* emit context */ Instr* instr);
class InstrType {
public:
uint32_t opcode;
uint32_t format; // xe_ppc_instr_format_e
uint32_t type; // xe_ppc_instr_type_e
uint32_t flags; // xe_ppc_instr_flag_e
char name[16];
InstrEmitFn emit;
};
InstrType* GetInstrType(uint32_t code);
int RegisterInstrEmit(uint32_t code, InstrEmitFn emit);
} // namespace ppc
} // namespace cpu
} // namespace xe
#endif // XENIA_CPU_PPC_INSTR_H_

View File

@@ -13,13 +13,33 @@
#include <xenia/common.h>
namespace XE_PPC_SPR {
enum XE_PPC_SPR_e {
namespace xe {
namespace cpu {
namespace ppc {
namespace SPR {
enum SPR_e {
XER = 1,
LR = 8,
CTR = 9,
};
} // XE_PPC_SPR
} // SPR
namespace FPRF {
enum FPRF_e {
QUIET_NAN = 0x00088000,
NEG_INFINITY = 0x00090000,
NEG_NORMALIZED = 0x00010000,
NEG_DENORMALIZED = 0x00018000,
NEG_ZERO = 0x00048000,
POS_ZERO = 0x00040000,
POS_DENORMALIZED = 0x00028000,
POS_NORMALIZED = 0x00020000,
POS_INFINITY = 0x000A0000,
};
} // FPRF
typedef struct XECACHEALIGN64 {
@@ -88,33 +108,24 @@ typedef struct XECACHEALIGN64 {
// 11 = toward -infinity
} bits;
} fpscr; // Floating-point status and control register
} xe_ppc_registers_t;
uint32_t get_fprf() {
return fpscr.value & 0x000F8000;
}
void set_fprf(const uint32_t v) {
fpscr.value = (fpscr.value & ~0x000F8000) | v;
}
} PpcRegisters;
typedef struct {
xe_ppc_registers_t registers;
} xe_ppc_state_t;
PpcRegisters registers;
} PpcState;
namespace XE_PPC_FPRF {
enum XE_PPC_FPRF_e {
QUIET_NAN = 0x00088000,
NEG_INFINITY = 0x00090000,
NEG_NORMALIZED = 0x00010000,
NEG_DENORMALIZED = 0x00018000,
NEG_ZERO = 0x00048000,
POS_ZERO = 0x00040000,
POS_DENORMALIZED = 0x00028000,
POS_NORMALIZED = 0x00020000,
POS_INFINITY = 0x000A0000,
};
} // XE_PPC_FPRF
uint32_t xe_ppc_get_fprf(const xe_ppc_registers_t *r) {
return r->fpscr.value & 0x000F8000;
}
void xe_ppc_set_fprf(xe_ppc_registers_t *r, const uint32_t v) {
r->fpscr.value = (r->fpscr.value & ~0x000F8000) | v;
}
} // namespace ppc
} // namespace cpu
} // namespace xe
#endif // XENIA_CPU_PPC_STATE_H_