Commit 9b3d7ebd authored by sewardj's avatar sewardj
Browse files

[project @ 2001-12-17 18:03:08 by sewardj]

Redo translation of array indexing primops in order to insert 8 <-> 32
bit casts when dealing with Char arrays.  Also facilitate future removal
of CMem and MO_{Read,Write}OSBI.

In the process, notice and fix a large bogon in x86/sparc implementation
of signed and unsigned integer widening.
parent 1a3dfff8
This diff is collapsed.
......@@ -159,6 +159,9 @@ data MachOp
| MO_16U_to_NatU
| MO_32U_to_NatU
| MO_8U_to_32U -- zero extend
| MO_32U_to_8U -- mask out all but lowest byte
-- Reading/writing arrays
| MO_ReadOSBI Int PrimRep -- args: [base_ptr, index_value]
| MO_WriteOSBI Int PrimRep -- args: [base_ptr, index_value, value_to_write]
......@@ -294,6 +297,9 @@ pprMachOp MO_8U_to_NatU = text "MO_8U_to_NatU"
pprMachOp MO_16U_to_NatU = text "MO_16U_to_NatU"
pprMachOp MO_32U_to_NatU = text "MO_32U_to_NatU"
pprMachOp MO_8U_to_32U = text "MO_8U_to_32U"
pprMachOp MO_32U_to_8U = text "MO_32U_to_8U"
pprMachOp (MO_ReadOSBI offset rep)
= text "MO_ReadOSBI" <> parens (int offset <> comma <> ppr rep)
pprMachOp (MO_WriteOSBI offset rep)
......@@ -434,7 +440,7 @@ machOpProps MO_Flt_Sqrt = (Just FloatRep, [])
machOpProps MO_Flt_Neg = (Just FloatRep, [inline])
machOpProps MO_32U_to_NatS = (Just IntRep, [inline])
machOpProps MO_NatS_to_32U = (Just WordRep, [inline])
machOpProps MO_NatS_to_32U = (Just Word32Rep, [inline])
machOpProps MO_NatS_to_Dbl = (Just DoubleRep, [inline])
machOpProps MO_Dbl_to_NatS = (Just IntRep, [inline])
......@@ -461,8 +467,8 @@ machOpProps MO_8U_to_NatU = (Just WordRep, [inline])
machOpProps MO_16U_to_NatU = (Just WordRep, [inline])
machOpProps MO_32U_to_NatU = (Just WordRep, [inline])
machOpProps MO_8U_to_32U = (Just Word32Rep, [inline])
machOpProps MO_32U_to_8U = (Just Word8Rep, [inline])
machOpProps (MO_ReadOSBI offset rep) = (Just rep, [inline])
machOpProps (MO_WriteOSBI offset rep) = (Nothing, [inline])
......@@ -762,6 +762,9 @@ pprMachOp_for_C MO_8U_to_NatU = text "(StgWord8)(StgWord)"
pprMachOp_for_C MO_16U_to_NatU = text "(StgWord16)(StgWord)"
pprMachOp_for_C MO_32U_to_NatU = text "(StgWord32)(StgWord)"
pprMachOp_for_C MO_8U_to_32U = text "(StgWord32)"
pprMachOp_for_C MO_32U_to_8U = text "(StgWord8)"
pprMachOp_for_C (MO_ReadOSBI _ _) = panic "pprMachOp_for_C:MO_ReadOSBI"
pprMachOp_for_C (MO_WriteOSBI _ _) = panic "pprMachOp_for_C:MO_WriteOSBI"
......
......@@ -831,6 +831,7 @@ getRegister (StMachOp mop [x]) -- unary MachOps
= case mop of
MO_NatS_Neg -> trivialUCode (NEGI L) x
MO_Nat_Not -> trivialUCode (NOT L) x
MO_32U_to_8U -> trivialUCode (AND L (OpImm (ImmInt 255))) x
MO_Flt_Neg -> trivialUFCode FloatRep (GNEG F) x
MO_Dbl_Neg -> trivialUFCode DoubleRep (GNEG DF) x
......@@ -871,6 +872,7 @@ getRegister (StMachOp mop [x]) -- unary MachOps
MO_8S_to_NatS -> integerExtend True 24 x
MO_16U_to_NatU -> integerExtend False 16 x
MO_16S_to_NatS -> integerExtend True 16 x
MO_8U_to_32U -> integerExtend False 24 x
other_op
-> getRegister (
......@@ -882,7 +884,7 @@ getRegister (StMachOp mop [x]) -- unary MachOps
integerExtend signed nBits x
= getRegister (
StMachOp (if signed then MO_Nat_Sar else MO_Nat_Shr)
[StInt nBits, StMachOp MO_Nat_Shl [StInt nBits, x]]
[StMachOp MO_Nat_Shl [x, StInt nBits], StInt nBits]
)
conversionNop new_rep expr
......@@ -1270,7 +1272,7 @@ getRegister (StMachOp mop [x]) -- unary PrimOps
integerExtend signed nBits x
= getRegister (
StMachOp (if signed then MO_Nat_Sar else MO_Nat_Shr)
[StInt nBits, StMachOp MO_Nat_Shl [StInt nBits, x]]
[StMachOp MO_Nat_Shl [x, StInt nBits], StInt nBits]
)
conversionNop new_rep expr
= getRegister expr `thenNat` \ e_code ->
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment