Commit 9c4b3b77 authored by Michael D. Adams's avatar Michael D. Adams
Browse files

Changed C-- parser to allow multiple return values

parent 0e504ed5
...@@ -254,24 +254,16 @@ stmt :: { ExtCode } ...@@ -254,24 +254,16 @@ stmt :: { ExtCode }
| NAME ':' | NAME ':'
{ do l <- newLabel $1; code (labelC l) } { do l <- newLabel $1; code (labelC l) }
| lreg '=' expr ';' -- HACK: this should just be lregs but that causes a shift/reduce conflict
{ do reg <- $1; e <- $3; stmtEC (CmmAssign reg e) } -- with foreign calls
| hint_lregs '=' expr ';'
{ do reg <- head $1; e <- $3; stmtEC (CmmAssign (fst reg) e) }
| type '[' expr ']' '=' expr ';' | type '[' expr ']' '=' expr ';'
{ doStore $1 $3 $6 } { doStore $1 $3 $6 }
| 'foreign' STRING expr '(' hint_exprs0 ')' vols ';' | maybe_results 'foreign' STRING expr '(' hint_exprs0 ')' vols ';'
{% foreignCall $2 [] $3 $5 $7 } {% foreignCall $3 $1 $4 $6 $8 }
| lreg '=' 'foreign' STRING expr '(' hint_exprs0 ')' vols ';' | maybe_results 'prim' '%' NAME '(' hint_exprs0 ')' vols ';'
{% let result = do r <- $1; return (r,NoHint) in {% primCall $1 $4 $6 $8 }
foreignCall $4 [result] $5 $7 $9 }
| 'prim' '%' NAME '(' hint_exprs0 ')' vols ';'
{% primCall [] $3 $5 $7 }
| lreg '=' 'prim' '%' NAME '(' hint_exprs0 ')' vols ';'
{% let result = do r <- $1; return (r,NoHint) in
primCall [result] $5 $7 $9 }
| STRING lreg '=' 'foreign' STRING expr '(' hint_exprs0 ')' vols ';'
{% do h <- parseHint $1;
let result = do r <- $2; return (r,h) in
foreignCall $5 [result] $6 $8 $10 }
-- stmt-level macros, stealing syntax from ordinary C-- function calls. -- stmt-level macros, stealing syntax from ordinary C-- function calls.
-- Perhaps we ought to use the %%-form? -- Perhaps we ought to use the %%-form?
| NAME '(' exprs0 ')' ';' | NAME '(' exprs0 ')' ';'
...@@ -405,6 +397,21 @@ reg :: { ExtFCode CmmExpr } ...@@ -405,6 +397,21 @@ reg :: { ExtFCode CmmExpr }
: NAME { lookupName $1 } : NAME { lookupName $1 }
| GLOBALREG { return (CmmReg (CmmGlobal $1)) } | GLOBALREG { return (CmmReg (CmmGlobal $1)) }
maybe_results :: { [ExtFCode (CmmReg, MachHint)] }
: {- empty -} { [] }
| hint_lregs '=' { $1 }
hint_lregs :: { [ExtFCode (CmmReg, MachHint)] }
: hint_lreg ',' { [$1] }
| hint_lreg { [$1] }
| hint_lreg ',' hint_lregs { $1 : $3 }
hint_lreg :: { ExtFCode (CmmReg, MachHint) }
: lreg { do e <- $1; return (e, inferHint (CmmReg e)) }
| STRING lreg {% do h <- parseHint $1;
return $ do
e <- $2; return (e,h) }
lreg :: { ExtFCode CmmReg } lreg :: { ExtFCode CmmReg }
: NAME { do e <- lookupName $1; : NAME { do e <- lookupName $1;
return $ return $
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment