From e98c75873475e94d23246c4e92a41c120d0e167b Mon Sep 17 00:00:00 2001 From: sof Date: Wed, 20 Aug 2003 15:16:43 +0000 Subject: [PATCH] [project @ 2003-08-20 15:16:43 by sof] pprInstr{PPC}: insist on xori,ori,andi being fed non-negative immediate values. GAS is barfing on neg. values. [ Don't have access to a PPC box right now to really test the change, so beware.] --- ghc/compiler/nativeGen/PprMach.lhs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ghc/compiler/nativeGen/PprMach.lhs b/ghc/compiler/nativeGen/PprMach.lhs index 3701dd5..2381689 100644 --- a/ghc/compiler/nativeGen/PprMach.lhs +++ b/ghc/compiler/nativeGen/PprMach.lhs @@ -26,9 +26,10 @@ import qualified Outputable #if __GLASGOW_HASKELL__ >= 504 import Data.Array.ST -import Data.Word ( Word8 ) +import Data.Word ( Word8, Word16 ) #else import MutableArray +import Word ( Word16 ) #endif import MONAD_ST @@ -1982,10 +1983,10 @@ pprInstr (AND reg1 reg2 (RIImm imm)) = hcat [ ptext SLIT(", "), pprImm imm ] -pprInstr (AND reg1 reg2 ri) = pprLogic SLIT("and") reg1 reg2 ri +pprInstr (AND reg1 reg2 ri) = pprLogic SLIT("and") reg1 reg2 (toUI16 ri) -pprInstr (OR reg1 reg2 ri) = pprLogic SLIT("or") reg1 reg2 ri -pprInstr (XOR reg1 reg2 ri) = pprLogic SLIT("xor") reg1 reg2 ri +pprInstr (OR reg1 reg2 ri) = pprLogic SLIT("or") reg1 reg2 (toUI16 ri) +pprInstr (XOR reg1 reg2 ri) = pprLogic SLIT("xor") reg1 reg2 (toUI16 ri) pprInstr (XORIS reg1 reg2 imm) = hcat [ char '\t', @@ -2067,6 +2068,16 @@ pprRI (RIImm r) = pprImm r pprFSize DF = empty pprFSize F = char 's' +-- hack to ensure that negative vals come out in non-negative form +-- (assuming that fromIntegral{Int->Word16} will do a 'c-style' +-- conversion, and not throw a fit/exception.) +toUI16 :: RI -> RI +toUI16 (RIImm (ImmInt x)) + | x < 0 = RIImm (ImmInt (fromIntegral ((fromIntegral x) :: Word16))) +toUI16 (RIImm (ImmInteger x)) + | x < 0 = RIImm (ImmInt (fromIntegral ((fromIntegral x) :: Word16))) +toUI16 x = x + {- The Mach-O object file format used in Darwin/Mac OS X needs a so-called "symbol stub" for every function that might be imported from a dynamic -- 1.7.10.4