diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2011-05-11 17:28:26 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2011-05-11 17:28:26 +0100 |
commit | cd54b707b0d77a3c62ee9f57b82dae98727f1c34 (patch) | |
tree | 41901da229321a5fd84b157a19e7536ffe53eca6 /compiler/cmm | |
parent | cbebca1c9164a5e5ae9b117d0dcf5ad217defc6d (diff) | |
parent | 9fb9395beebc5c6f85571991af7fd55b4db86977 (diff) | |
download | haskell-cd54b707b0d77a3c62ee9f57b82dae98727f1c34.tar.gz |
Merge remote branch 'origin/master'
Diffstat (limited to 'compiler/cmm')
-rw-r--r-- | compiler/cmm/CmmNode.hs | 28 | ||||
-rw-r--r-- | compiler/cmm/CmmParse.y | 25 | ||||
-rw-r--r-- | compiler/cmm/cmm-notes | 4 |
3 files changed, 44 insertions, 13 deletions
diff --git a/compiler/cmm/CmmNode.hs b/compiler/cmm/CmmNode.hs index e67321c0b0..ee948fe7ea 100644 --- a/compiler/cmm/CmmNode.hs +++ b/compiler/cmm/CmmNode.hs @@ -30,31 +30,51 @@ import Prelude hiding (succ) data CmmNode e x where CmmEntry :: Label -> CmmNode C O + CmmComment :: FastString -> CmmNode O O + CmmAssign :: CmmReg -> CmmExpr -> CmmNode O O -- Assign to register + CmmStore :: CmmExpr -> CmmExpr -> CmmNode O O -- Assign to memory location. Size is -- given by cmmExprType of the rhs. + CmmUnsafeForeignCall :: -- An unsafe foreign call; see Note [Foreign calls] + -- Like a "fat machine instruction"; can occur + -- in the middle of a block ForeignTarget -> -- call target CmmFormals -> -- zero or more results CmmActuals -> -- zero or more arguments CmmNode O O + -- Semantics: kills only result regs; all other regs (both GlobalReg + -- and LocalReg) are preserved + CmmBranch :: Label -> CmmNode O C -- Goto another block in the same procedure + CmmCondBranch :: { -- conditional branch cml_pred :: CmmExpr, cml_true, cml_false :: Label } -> CmmNode O C + CmmSwitch :: CmmExpr -> [Maybe Label] -> CmmNode O C -- Table branch -- The scrutinee is zero-based; -- zero -> first block -- one -> second block etc -- Undefined outside range, and when there's a Nothing - CmmCall :: { -- A call (native or safe foreign) + + CmmCall :: { -- A native call or tail call cml_target :: CmmExpr, -- never a CmmPrim to a CallishMachOp! cml_cont :: Maybe Label, -- Label of continuation (Nothing for return or tail call) +-- ToDO: add this: +-- cml_args_regs :: [GlobalReg], +-- It says which GlobalRegs are live for the parameters at the +-- moment of the call. Later stages can use this to give liveness +-- everywhere, which in turn guides register allocation. +-- It is the companion of cml_args; cml_args says which stack words +-- hold parameters, while cml_arg_regs says which global regs hold parameters + cml_args :: ByteOff, -- Byte offset, from the *old* end of the Area associated with -- the Label (if cml_cont = Nothing, then Old area), of @@ -78,7 +98,9 @@ data CmmNode e x where -- cml_ret_off are treated as live, even if the sequel of -- the call goes into a loop. } -> CmmNode O C + CmmForeignCall :: { -- A safe foreign call; see Note [Foreign calls] + -- Always the last node of a block tgt :: ForeignTarget, -- call target and convention res :: CmmFormals, -- zero or more results args :: CmmActuals, -- zero or more arguments @@ -89,8 +111,8 @@ data CmmNode e x where {- Note [Foreign calls] ~~~~~~~~~~~~~~~~~~~~~~~ -A MidForeign call is used for *unsafe* foreign calls; -a LastForeign call is used for *safe* foreign calls. +A CmmUnsafeForeignCall is used for *unsafe* foreign calls; +a CmmForeignCall call is used for *safe* foreign calls. Unsafe ones are easy: think of them as a "fat machine instruction". In particular, they do *not* kill all live registers (there was a bit of code in GHC that conservatively assumed otherwise.) diff --git a/compiler/cmm/CmmParse.y b/compiler/cmm/CmmParse.y index 4dc7e3214f..0ee429d9c1 100644 --- a/compiler/cmm/CmmParse.y +++ b/compiler/cmm/CmmParse.y @@ -689,15 +689,7 @@ machOps = listToUFM $ ( "gtu", MO_U_Gt ), ( "ltu", MO_U_Lt ), - ( "flt", MO_S_Lt ), - ( "fle", MO_S_Le ), - ( "feq", MO_Eq ), - ( "fne", MO_Ne ), - ( "fgt", MO_S_Gt ), - ( "fge", MO_S_Ge ), - ( "fneg", MO_S_Neg ), - - ( "and", MO_And ), + ( "and", MO_And ), ( "or", MO_Or ), ( "xor", MO_Xor ), ( "com", MO_Not ), @@ -705,7 +697,20 @@ machOps = listToUFM $ ( "shrl", MO_U_Shr ), ( "shra", MO_S_Shr ), - ( "lobits8", flip MO_UU_Conv W8 ), + ( "fadd", MO_F_Add ), + ( "fsub", MO_F_Sub ), + ( "fneg", MO_F_Neg ), + ( "fmul", MO_F_Mul ), + ( "fquot", MO_F_Quot ), + + ( "feq", MO_F_Eq ), + ( "fne", MO_F_Ne ), + ( "fge", MO_F_Ge ), + ( "fle", MO_F_Le ), + ( "fgt", MO_F_Gt ), + ( "flt", MO_F_Lt ), + + ( "lobits8", flip MO_UU_Conv W8 ), ( "lobits16", flip MO_UU_Conv W16 ), ( "lobits32", flip MO_UU_Conv W32 ), ( "lobits64", flip MO_UU_Conv W64 ), diff --git a/compiler/cmm/cmm-notes b/compiler/cmm/cmm-notes index e787f18b17..c0ccadfbec 100644 --- a/compiler/cmm/cmm-notes +++ b/compiler/cmm/cmm-notes @@ -1,3 +1,7 @@ +More notes (May 11)
+~~~~~~~~~~~~~~~~~~~
+In CmmNode, consider spliting CmmCall into two: call and jump
+
Notes on new codegen (Aug 10)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|