From 3018b2f554ea2cfdfb80ee7f7b62ac5a41118fc9 Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <erikd@mega-nerd.com>
Date: Thu, 1 Mar 2012 07:29:24 +1100
Subject: [PATCH 2/2] PPC: Handle right shift of > 31 bits. Fix #5999.
---
compiler/nativeGen/PPC/Ppr.hs | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/compiler/nativeGen/PPC/Ppr.hs b/compiler/nativeGen/PPC/Ppr.hs
index 56f1bd3..3cd90db 100644
|
a
|
b
|
|
| 587 | 587 | pprInstr platform (NOT reg1 reg2) = pprUnary platform (sLit "not") reg1 reg2 |
| 588 | 588 | |
| 589 | 589 | pprInstr platform (SLW reg1 reg2 ri) = pprLogic platform (sLit "slw") reg1 reg2 (limitShiftRI ri) |
| | 590 | |
| | 591 | pprInstr platform (SRW reg1 reg2 (RIImm (ImmInt i))) | i > 31 || i < 0 = |
| | 592 | -- Handle the case where we are asked to shift a 32 bit register by |
| | 593 | -- less than zero or more than 31 bits. We convert this into a clear |
| | 594 | -- of the destination register. |
| | 595 | pprInstr platform (XOR reg1 reg2 (RIReg reg2)) |
| 590 | 596 | pprInstr platform (SRW reg1 reg2 ri) = pprLogic platform (sLit "srw") reg1 reg2 (limitShiftRI ri) |
| | 597 | |
| 591 | 598 | pprInstr platform (SRAW reg1 reg2 ri) = pprLogic platform (sLit "sraw") reg1 reg2 (limitShiftRI ri) |
| 592 | 599 | pprInstr platform (RLWINM reg1 reg2 sh mb me) = hcat [ |
| 593 | 600 | ptext (sLit "\trlwinm\t"), |
| … |
… |
|
| 705 | 712 | pprFSize FF32 = char 's' |
| 706 | 713 | pprFSize _ = panic "PPC.Ppr.pprFSize: no match" |
| 707 | 714 | |
| 708 | | -- limit immediate argument for shift instruction to range 0..32 |
| 709 | | -- (yes, the maximum is really 32, not 31) |
| | 715 | -- limit immediate argument for shift instruction to range 0..31 |
| 710 | 716 | limitShiftRI :: RI -> RI |
| 711 | | limitShiftRI (RIImm (ImmInt i)) | i > 32 || i < 0 = RIImm (ImmInt 32) |
| | 717 | limitShiftRI (RIImm (ImmInt i)) | i > 31 || i < 0 = |
| | 718 | panic $ "PPC.Ppr: Shift by " ++ show i ++ " bits is not allowed." |
| 712 | 719 | limitShiftRI x = x |
| 713 | 720 | |