cr* operations.

This commit is contained in:
Ben Vanik 2014-08-05 14:59:48 -07:00
parent 75eb87f33d
commit f668dcd56b
3 changed files with 53 additions and 16 deletions

View File

@ -338,43 +338,75 @@ XEEMITTER(bclrx, 0x4C000020, XL)(PPCHIRBuilder& f, InstrData& i) {
// Condition register logical (A-23) // Condition register logical (A-23)
XEEMITTER(crand, 0x4C000202, XL)(PPCHIRBuilder& f, InstrData& i) { XEEMITTER(crand, 0x4C000202, XL)(PPCHIRBuilder& f, InstrData& i) {
XEINSTRNOTIMPLEMENTED(); // CR[bt] <- CR[ba] & CR[bb] bt=bo, ba=bi, bb=bb
return 1; Value* ba = f.LoadCRField(i.XL.BI >> 2, i.XL.BI & 3);
Value* bb = f.LoadCRField(i.XL.BB >> 2, i.XL.BB & 3);
Value* bt = f.And(ba, bb);
f.StoreCRField(i.XL.BO >> 2, i.XL.BO & 3, bt);
return 0;
} }
XEEMITTER(crandc, 0x4C000102, XL)(PPCHIRBuilder& f, InstrData& i) { XEEMITTER(crandc, 0x4C000102, XL)(PPCHIRBuilder& f, InstrData& i) {
XEINSTRNOTIMPLEMENTED(); // CR[bt] <- CR[ba] & ¬CR[bb] bt=bo, ba=bi, bb=bb
return 1; Value* ba = f.LoadCRField(i.XL.BI >> 2, i.XL.BI & 3);
Value* bb = f.LoadCRField(i.XL.BB >> 2, i.XL.BB & 3);
Value* bt = f.And(ba, f.Not(bb));
f.StoreCRField(i.XL.BO >> 2, i.XL.BO & 3, bt);
return 0;
} }
XEEMITTER(creqv, 0x4C000242, XL)(PPCHIRBuilder& f, InstrData& i) { XEEMITTER(creqv, 0x4C000242, XL)(PPCHIRBuilder& f, InstrData& i) {
XEINSTRNOTIMPLEMENTED(); // CR[bt] <- CR[ba] == CR[bb] bt=bo, ba=bi, bb=bb
return 1; Value* ba = f.LoadCRField(i.XL.BI >> 2, i.XL.BI & 3);
Value* bb = f.LoadCRField(i.XL.BB >> 2, i.XL.BB & 3);
Value* bt = f.CompareEQ(ba, bb);
f.StoreCRField(i.XL.BO >> 2, i.XL.BO & 3, bt);
return 0;
} }
XEEMITTER(crnand, 0x4C0001C2, XL)(PPCHIRBuilder& f, InstrData& i) { XEEMITTER(crnand, 0x4C0001C2, XL)(PPCHIRBuilder& f, InstrData& i) {
XEINSTRNOTIMPLEMENTED(); // CR[bt] <- ¬(CR[ba] & CR[bb]) bt=bo, ba=bi, bb=bb
return 1; Value* ba = f.LoadCRField(i.XL.BI >> 2, i.XL.BI & 3);
Value* bb = f.LoadCRField(i.XL.BB >> 2, i.XL.BB & 3);
Value* bt = f.Not(f.And(ba, bb));
f.StoreCRField(i.XL.BO >> 2, i.XL.BO & 3, bt);
return 0;
} }
XEEMITTER(crnor, 0x4C000042, XL)(PPCHIRBuilder& f, InstrData& i) { XEEMITTER(crnor, 0x4C000042, XL)(PPCHIRBuilder& f, InstrData& i) {
XEINSTRNOTIMPLEMENTED(); // CR[bt] <- ¬(CR[ba] | CR[bb]) bt=bo, ba=bi, bb=bb
return 1; Value* ba = f.LoadCRField(i.XL.BI >> 2, i.XL.BI & 3);
Value* bb = f.LoadCRField(i.XL.BB >> 2, i.XL.BB & 3);
Value* bt = f.Not(f.Or(ba, bb));
f.StoreCRField(i.XL.BO >> 2, i.XL.BO & 3, bt);
return 0;
} }
XEEMITTER(cror, 0x4C000382, XL)(PPCHIRBuilder& f, InstrData& i) { XEEMITTER(cror, 0x4C000382, XL)(PPCHIRBuilder& f, InstrData& i) {
XEINSTRNOTIMPLEMENTED(); // CR[bt] <- CR[ba] | CR[bb] bt=bo, ba=bi, bb=bb
return 1; Value* ba = f.LoadCRField(i.XL.BI >> 2, i.XL.BI & 3);
Value* bb = f.LoadCRField(i.XL.BB >> 2, i.XL.BB & 3);
Value* bt = f.Or(ba, bb);
f.StoreCRField(i.XL.BO >> 2, i.XL.BO & 3, bt);
return 0;
} }
XEEMITTER(crorc, 0x4C000342, XL)(PPCHIRBuilder& f, InstrData& i) { XEEMITTER(crorc, 0x4C000342, XL)(PPCHIRBuilder& f, InstrData& i) {
XEINSTRNOTIMPLEMENTED(); // CR[bt] <- CR[ba] | ¬CR[bb] bt=bo, ba=bi, bb=bb
return 1; Value* ba = f.LoadCRField(i.XL.BI >> 2, i.XL.BI & 3);
Value* bb = f.LoadCRField(i.XL.BB >> 2, i.XL.BB & 3);
Value* bt = f.Or(ba, f.Not(bb));
f.StoreCRField(i.XL.BO >> 2, i.XL.BO & 3, bt);
return 0;
} }
XEEMITTER(crxor, 0x4C000182, XL)(PPCHIRBuilder& f, InstrData& i) { XEEMITTER(crxor, 0x4C000182, XL)(PPCHIRBuilder& f, InstrData& i) {
XEINSTRNOTIMPLEMENTED(); // CR[bt] <- CR[ba] xor CR[bb] bt=bo, ba=bi, bb=bb
return 1; Value* ba = f.LoadCRField(i.XL.BI >> 2, i.XL.BI & 3);
Value* bb = f.LoadCRField(i.XL.BB >> 2, i.XL.BB & 3);
Value* bt = f.Xor(ba, bb);
f.StoreCRField(i.XL.BO >> 2, i.XL.BO & 3, bt);
return 0;
} }
XEEMITTER(mcrf, 0x4C000000, XL)(PPCHIRBuilder& f, InstrData& i) { XEEMITTER(mcrf, 0x4C000000, XL)(PPCHIRBuilder& f, InstrData& i) {

View File

@ -230,6 +230,10 @@ void PPCHIRBuilder::StoreCR(uint32_t n, Value* value) {
assert_always(); assert_always();
} }
void PPCHIRBuilder::StoreCRField(uint32_t n, uint32_t bit, Value* value) {
StoreContext(offsetof(PPCContext, cr0) + (4 * n) + bit, value);
}
void PPCHIRBuilder::UpdateCR(uint32_t n, Value* lhs, bool is_signed) { void PPCHIRBuilder::UpdateCR(uint32_t n, Value* lhs, bool is_signed) {
UpdateCR(n, lhs, LoadZero(lhs->type), is_signed); UpdateCR(n, lhs, LoadZero(lhs->type), is_signed);
} }

View File

@ -46,6 +46,7 @@ class PPCHIRBuilder : public hir::HIRBuilder {
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);
void StoreCRField(uint32_t n, uint32_t bit, Value* value);
void UpdateCR(uint32_t n, Value* lhs, bool is_signed = true); void UpdateCR(uint32_t n, Value* lhs, bool is_signed = true);
void UpdateCR(uint32_t n, Value* lhs, Value* rhs, bool is_signed = true); void UpdateCR(uint32_t n, Value* lhs, Value* rhs, bool is_signed = true);
void UpdateCR6(Value* src_value); void UpdateCR6(Value* src_value);