From 211af0b2c69b8c022c26a87beb3dc8ff048108d1 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Wed, 11 Feb 2015 01:10:30 -0800 Subject: [PATCH] Fixing mtcr -- needs some tests. --- src/alloy/frontend/ppc/ppc_hir_builder.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/alloy/frontend/ppc/ppc_hir_builder.cc b/src/alloy/frontend/ppc/ppc_hir_builder.cc index ff9fefaeb..b8a81d76d 100644 --- a/src/alloy/frontend/ppc/ppc_hir_builder.cc +++ b/src/alloy/frontend/ppc/ppc_hir_builder.cc @@ -301,13 +301,17 @@ void PPCHIRBuilder::StoreCR(uint32_t n, Value* value) { // Pull out the bits we are interested in. // Optimization passes will kill any unneeded stores (mostly). StoreContext(offsetof(PPCContext, cr0) + (4 * n) + 0, - Truncate(Shr(value, 4 * (7 - n) + 3), INT8_TYPE)); + And(Truncate(Shr(value, 4 * (7 - n) + 3), INT8_TYPE), + LoadConstant(uint8_t(1)))); StoreContext(offsetof(PPCContext, cr0) + (4 * n) + 1, - Truncate(Shr(value, 4 * (7 - n) + 2), INT8_TYPE)); + And(Truncate(Shr(value, 4 * (7 - n) + 2), INT8_TYPE), + LoadConstant(uint8_t(1)))); StoreContext(offsetof(PPCContext, cr0) + (4 * n) + 2, - Truncate(Shr(value, 4 * (7 - n) + 1), INT8_TYPE)); + And(Truncate(Shr(value, 4 * (7 - n) + 1), INT8_TYPE), + LoadConstant(uint8_t(1)))); StoreContext(offsetof(PPCContext, cr0) + (4 * n) + 3, - Truncate(Shr(value, 4 * (7 - n) + 0), INT8_TYPE)); + And(Truncate(Shr(value, 4 * (7 - n) + 0), INT8_TYPE), + LoadConstant(uint8_t(1)))); } void PPCHIRBuilder::StoreCRField(uint32_t n, uint32_t bit, Value* value) {