Old style mfcr.

This commit is contained in:
Ben Vanik 2015-02-01 20:49:47 -08:00
parent 7b48332782
commit 93ded5ef0f
4 changed files with 28 additions and 13 deletions

View File

@ -547,21 +547,24 @@ XEEMITTER(mfcr, 0x7C000026, XFX)(PPCHIRBuilder& f, InstrData& i) {
// extrwi r3, r10, 1, 26 // extrwi r3, r10, 1, 26
// Could recognize this and only load the appropriate CR bit. // Could recognize this and only load the appropriate CR bit.
assert_true(i.XFX.spr & (1 << 9));
uint32_t bits = (i.XFX.spr & 0x1FF) >> 1;
int count = 0;
int cri = 0;
for (int b = 0; b <= 7; ++b) {
if (bits & (1 << b)) {
cri = 7 - b;
++count;
}
}
Value* v; Value* v;
if (count == 1) { if (i.XFX.spr & (1 << 9)) {
v = f.LoadCR(cri); uint32_t bits = (i.XFX.spr & 0x1FF) >> 1;
int count = 0;
int cri = 0;
for (int b = 0; b <= 7; ++b) {
if (bits & (1 << b)) {
cri = 7 - b;
++count;
}
}
if (count == 1) {
v = f.LoadCR(cri);
} else {
v = f.LoadZero(INT64_TYPE);
}
} else { } else {
v = f.LoadZero(INT64_TYPE); v = f.LoadCR();
} }
f.StoreGPR(i.XFX.RT, v); f.StoreGPR(i.XFX.RT, v);
return 0; return 0;

View File

@ -252,6 +252,16 @@ void PPCHIRBuilder::StoreCTR(Value* value) {
trace_reg.value = value; trace_reg.value = value;
} }
Value* PPCHIRBuilder::LoadCR() {
// All bits. This is expensive, but seems to be less used than the
// field-specific LoadCR.
Value* v = LoadCR(0);
for (int i = 1; i <= 7; ++i) {
v = Or(v, LoadCR(i));
}
return v;
}
Value* PPCHIRBuilder::LoadCR(uint32_t n) { Value* PPCHIRBuilder::LoadCR(uint32_t n) {
// Construct the entire word of just the bits we care about. // Construct the entire word of just the bits we care about.
// This makes it easier for the optimizer to exclude things, though // This makes it easier for the optimizer to exclude things, though

View File

@ -50,6 +50,7 @@ class PPCHIRBuilder : public hir::HIRBuilder {
void StoreLR(Value* value); void StoreLR(Value* value);
Value* LoadCTR(); Value* LoadCTR();
void StoreCTR(Value* value); void StoreCTR(Value* value);
Value* LoadCR();
Value* LoadCR(uint32_t n); Value* LoadCR(uint32_t n);
Value* LoadCRField(uint32_t n, uint32_t bit); Value* LoadCRField(uint32_t n, uint32_t bit);
void StoreCR(uint32_t n, Value* value); void StoreCR(uint32_t n, Value* value);

View File

@ -33,6 +33,7 @@ KernelState* shared_kernel_state_ = nullptr;
KernelState::KernelState(Emulator* emulator) KernelState::KernelState(Emulator* emulator)
: emulator_(emulator), : emulator_(emulator),
memory_(emulator->memory()), memory_(emulator->memory()),
object_table_(nullptr),
has_notified_startup_(false), has_notified_startup_(false),
process_type_(X_PROCTYPE_USER), process_type_(X_PROCTYPE_USER),
executable_module_(nullptr) { executable_module_(nullptr) {