-- one -> second block etc
-- Undefined outside range, and when there's a Nothing
- | CmmJump CmmExpr [LocalReg] -- Jump to another function, with these
- -- parameters.
+ | CmmJump CmmExpr -- Jump to another function,
+ [(CmmExpr, MachHint)] -- with these parameters.
+
+ | CmmReturn -- Return from a function,
+ [(CmmExpr, MachHint)] -- with these return values.
{-
Discussion
| CmmT_jump
| CmmT_foreign
| CmmT_prim
+ | CmmT_return
| CmmT_import
| CmmT_switch
| CmmT_case
( "jump", CmmT_jump ),
( "foreign", CmmT_foreign ),
( "prim", CmmT_prim ),
+ ( "return", CmmT_return ),
( "import", CmmT_import ),
( "switch", CmmT_switch ),
( "case", CmmT_case ),
'jump' { L _ (CmmT_jump) }
'foreign' { L _ (CmmT_foreign) }
'prim' { L _ (CmmT_prim) }
+ 'return' { L _ (CmmT_return) }
'import' { L _ (CmmT_import) }
'switch' { L _ (CmmT_switch) }
'case' { L _ (CmmT_case) }
{ doSwitch $2 $3 $5 $6 }
| 'goto' NAME ';'
{ do l <- lookupLabel $2; stmtEC (CmmBranch l) }
- | 'jump' expr {-maybe_actuals-} ';'
- { do e <- $2; stmtEC (CmmJump e []) }
+ | 'jump' expr maybe_actuals ';'
+ { do e1 <- $2; e2 <- sequence $3; stmtEC (CmmJump e1 e2) }
+ | 'return' maybe_actuals ';'
+ { do e <- sequence $2; stmtEC (CmmReturn e) }
| 'if' bool_expr '{' body '}' else
{ ifThenElse $2 $4 $6 }
: {- empty -} { wordRep }
| '::' type { $2 }
+maybe_actuals :: { [ExtFCode (CmmExpr, MachHint)] }
+ : {- empty -} { [] }
+ | '(' hint_exprs0 ')' { $2 }
+
hint_exprs0 :: { [ExtFCode (CmmExpr, MachHint)] }
: {- empty -} { [] }
| hint_exprs { $1 }
CmmBranch ident -> genBranch ident
CmmCondBranch expr ident -> genCondBranch expr ident
CmmJump expr params -> genJump expr params
+ CmmReturn params -> genReturn params
CmmSwitch arg ids -> genSwitch arg ids
-- --------------------------------------------------------------------------
--
-- jump foo(a, b, c);
--
-genJump :: CmmExpr -> [LocalReg] -> SDoc
-genJump expr actuals =
+genJump :: CmmExpr -> [(CmmExpr, MachHint)] -> SDoc
+genJump expr args =
hcat [ ptext SLIT("jump")
, space
else case expr of
CmmLoad (CmmReg _) _ -> pprExpr expr
_ -> parens (pprExpr expr)
- , pprActuals actuals
+ , parens ( commafy $ map ppr args )
, semi ]
- where
- pprActuals [] = empty
- pprActuals as = parens ( commafy $ map pprLocalReg as )
+-- --------------------------------------------------------------------------
+-- Return from a function. [1], Section 6.8.2 of version 1.128
+--
+-- return (a, b, c);
+--
+genReturn :: [(CmmExpr, MachHint)] -> SDoc
+genReturn args =
+
+ hcat [ ptext SLIT("return")
+ , space
+ , parens ( commafy $ map ppr args )
+ , semi ]
-- --------------------------------------------------------------------------
-- Tabled jump to local label