Created
July 26, 2015 14:24
-
-
Save nkaretnikov/599047a27bb85fc1f902 to your computer and use it in GitHub Desktop.
emitPrimOp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs | |
index 243e2a3..b603e1d 100644 | |
--- a/compiler/codeGen/StgCmmPrim.hs | |
+++ b/compiler/codeGen/StgCmmPrim.hs | |
@@ -50,6 +50,11 @@ import Prelude hiding ((<*>)) | |
import Data.Bits ((.&.), bit) | |
import Control.Monad (liftM, when) | |
+-- XXX: Remove. | |
+import BlockId | |
+import UniqSupply | |
+import System.IO.Unsafe | |
+ | |
------------------------------------------------------------------------ | |
-- Primitive operations and foreign calls | |
------------------------------------------------------------------------ | |
@@ -794,7 +799,17 @@ emitPrimOp dflags r@[res] op args | |
emitPrimOp dflags results op args | |
= case callishPrimOpSupported dflags op of | |
- Left op -> emit $ mkUnsafeCall (PrimTarget op) results args | |
+-- XXX: Clean up. | |
+ Left op -> -- emit $ mkUnsafeCall (PrimTarget op) results args | |
+ emit $ | |
+ pprTrace | |
+ "emitPrimOp:" | |
+ (ppr $ | |
+ labelAGraph | |
+ (mkBlockId $ uniqFromSupply $ unsafePerformIO $ mkSplitUniqSupply 'a') | |
+ ( mkUnsafeCall (PrimTarget op) results args | |
+ , GlobalScope ) ) | |
+ (mkUnsafeCall (PrimTarget op) results args) | |
Right gen -> gen results args | |
type GenericOp = [CmmFormal] -> [CmmActual] -> FCode () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MagicHash #-} | |
{-# LANGUAGE UnboxedTuples #-} | |
module Main where | |
import Control.Monad | |
import GHC.Base | |
import GHC.Prim | |
main :: IO () | |
main = let (# x, y #) = (addIntC# 2# 3#) | |
in print (I# x, I# y) | |
{- | |
$ ghc/inplace/bin/ghc-stage2 --make Main.hs | |
[1 of 1] Compiling Main ( Main.hs, Main.o ) | |
emitPrimOp: | |
{offset | |
aMI: | |
(_sMl::I64, _sMm::I64) = call MO_AddIntC W64(2, 3); | |
goto aMI; | |
} | |
Linking Main ... | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment