+ -- The entry, jump, and return areas should be the same.
+ -- This code is horrible, but there's no point trying to fix it until we've figured
+ -- out our interface for calling conventions.
+ -- All return statements are required to use return areas of equal size.
+ -- This isn't necessarily required to write correct programs, but it's sane.
+ area = case foldr retBlock (retStmts ss Nothing) other_blocks of
+ Just (as, _) -> mkCallArea id as $ Just args
+ Nothing -> mkCallArea id [] $ Just args
+ retBlock (BasicBlock _ ss) z = retStmts ss z
+ retStmts [CmmReturn ress] z@(Just (_, n)) =
+ if size ress == n then z
+ else panic "return statements in C-- procs must return the same results"
+ retStmts [CmmReturn ress] Nothing = Just (ress, size ress)
+ retStmts (_ : rst) z = retStmts rst z
+ retStmts [] z = z
+ size args = areaSize $ mkCallArea id args Nothing