Ticket #5900: 0002-PPC-Handle-right-shift-of-31-bits.-Fix-5999.patch

File 0002-PPC-Handle-right-shift-of-31-bits.-Fix-5999.patch, 1.9 KB (added by erikd, 15 months ago)
  • compiler/nativeGen/PPC/Ppr.hs

    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  
    587587pprInstr platform (NOT reg1 reg2) = pprUnary platform (sLit "not") reg1 reg2 
    588588 
    589589pprInstr platform (SLW reg1 reg2 ri) = pprLogic platform (sLit "slw") reg1 reg2 (limitShiftRI ri) 
     590 
     591pprInstr 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)) 
    590596pprInstr platform (SRW reg1 reg2 ri) = pprLogic platform (sLit "srw") reg1 reg2 (limitShiftRI ri) 
     597 
    591598pprInstr platform (SRAW reg1 reg2 ri) = pprLogic platform (sLit "sraw") reg1 reg2 (limitShiftRI ri) 
    592599pprInstr platform (RLWINM reg1 reg2 sh mb me) = hcat [ 
    593600        ptext (sLit "\trlwinm\t"), 
     
    705712pprFSize FF32     = char 's' 
    706713pprFSize _        = panic "PPC.Ppr.pprFSize: no match" 
    707714 
    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 
    710716limitShiftRI :: RI -> RI 
    711 limitShiftRI (RIImm (ImmInt i)) | i > 32 || i < 0 = RIImm (ImmInt 32) 
     717limitShiftRI (RIImm (ImmInt i)) | i > 31 || i < 0 = 
     718  panic $ "PPC.Ppr: Shift by " ++ show i ++ " bits is not allowed." 
    712719limitShiftRI x = x 
    713720