summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2006-11-14 16:00:27 +0000
committerSimon Marlow <simonmar@microsoft.com>2006-11-14 16:00:27 +0000
commit45b5e0b79b4276e761cab5e4a51a7eff9220c3ba (patch)
tree56f915f181211a7ede67444fd11062b58b5019ab /compiler
parent83568675d3e6bf2f8369d67b02b0c5e6d41b8adb (diff)
downloadhaskell-45b5e0b79b4276e761cab5e4a51a7eff9220c3ba.tar.gz
fix types in generated C for comparison MachOps
C comparisons have type 'int', but our generated code assumed they had type 'StgWord', leading to (very) occasional warnings from gcc.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/cmm/PprC.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs
index 90599d74e9..6d63e87647 100644
--- a/compiler/cmm/PprC.hs
+++ b/compiler/cmm/PprC.hs
@@ -356,6 +356,20 @@ pprMachOpApp op args
isMulMayOfloOp _ = False
pprMachOpApp mop args
+ | Just ty <- machOpNeedsCast mop
+ = ty <> parens (pprMachOpApp' mop args)
+ | otherwise
+ = pprMachOpApp' mop args
+
+-- Comparisons in C have type 'int', but we want type W_ (this is what
+-- resultRepOfMachOp says). The other C operations inherit their type
+-- from their operands, so no casting is required.
+machOpNeedsCast :: MachOp -> Maybe SDoc
+machOpNeedsCast mop
+ | isComparisonMachOp mop = Just mkW_
+ | otherwise = Nothing
+
+pprMachOpApp' mop args
= case args of
-- dyadic
[x,y] -> pprArg x <+> pprMachOp_for_C mop <+> pprArg y