From 3328ddb88b6eb11cb1f6e844f883e7e9d2b8f21b Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Tue, 7 Feb 2017 22:56:36 -0500 Subject: Cmm: Add support for undefined unwinding statements And use to mark `stg_stack_underflow_frame`, which we are unable to determine a caller from. To simplify parsing at the moment we steal the `return` keyword to indicate an undefined unwind value. Perhaps this should be revisited. Reviewers: scpmw, simonmar, austin, erikd Subscribers: dfeuer, thomie Differential Revision: https://phabricator.haskell.org/D2738 --- compiler/cmm/CmmParse.y | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'compiler/cmm/CmmParse.y') diff --git a/compiler/cmm/CmmParse.y b/compiler/cmm/CmmParse.y index cfadc61e84..69925811ce 100644 --- a/compiler/cmm/CmmParse.y +++ b/compiler/cmm/CmmParse.y @@ -639,12 +639,20 @@ stmt :: { CmmParse () } { $2 >>= code . emitUnwind } unwind_regs - :: { CmmParse [(GlobalReg, CmmExpr)] } - : GLOBALREG '=' expr ',' unwind_regs + :: { CmmParse [(GlobalReg, Maybe CmmExpr)] } + : GLOBALREG '=' expr_or_unknown ',' unwind_regs { do e <- $3; rest <- $5; return (($1, e) : rest) } - | GLOBALREG '=' expr + | GLOBALREG '=' expr_or_unknown { do e <- $3; return [($1, e)] } +-- | Used by unwind to indicate unknown unwinding values. +expr_or_unknown + :: { CmmParse (Maybe CmmExpr) } + : 'return' + { do return Nothing } + | expr + { do e <- $1; return (Just e) } + foreignLabel :: { CmmParse CmmExpr } : NAME { return (CmmLit (CmmLabel (mkForeignLabel $1 Nothing ForeignLabelInThisPackage IsFunction))) } -- cgit v1.2.1