X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fcmm%2FCmm.hs;h=06e3d16fab62b0f210c9bf3cf0c5ddd8dd9e2ff4;hb=eeaa039982364fb658d4e6824e078c553ba8c748;hp=13961c15d3557899cb627123f7234599d6666e3f;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/compiler/cmm/Cmm.hs b/compiler/cmm/Cmm.hs index 13961c1..06e3d16 100644 --- a/compiler/cmm/Cmm.hs +++ b/compiler/cmm/Cmm.hs @@ -2,7 +2,7 @@ -- -- Cmm data types -- --- (c) The University of Glasgow 2004 +-- (c) The University of Glasgow 2004-2006 -- ----------------------------------------------------------------------------- @@ -26,11 +26,12 @@ module Cmm ( #include "HsVersions.h" import MachOp -import CLabel ( CLabel ) -import ForeignCall ( CCallConv ) -import Unique ( Unique, Uniquable(..) ) -import FastString ( FastString ) -import DATA_WORD ( Word8 ) +import CLabel +import ForeignCall +import Unique +import FastString + +import Data.Word ----------------------------------------------------------------------------- -- Cmm, CmmTop, CmmBasicBlock @@ -132,6 +133,42 @@ data CmmStmt | CmmJump CmmExpr [LocalReg] -- Jump to another function, with these -- parameters. +{- +Discussion +~~~~~~~~~~ + +One possible problem with the above type is that the only way to do a +non-local conditional jump is to encode it as a branch to a block that +contains a single jump. This leads to inefficient code in the back end. + +One possible way to fix this would be: + +data CmmStat = + ... + | CmmJump CmmBranchDest + | CmmCondJump CmmExpr CmmBranchDest + ... + +data CmmBranchDest + = Local BlockId + | NonLocal CmmExpr [LocalReg] + +In favour: + ++ one fewer constructors in CmmStmt ++ allows both cond branch and switch to jump to non-local destinations + +Against: + +- not strictly necessary: can already encode as branch+jump +- not always possible to implement any better in the back end +- could do the optimisation in the back end (but then plat-specific?) +- C-- doesn't have it +- back-end optimisation might be more general (jump shortcutting) + +So we'll stick with the way it is, and add the optimisation to the NCG. +-} + ----------------------------------------------------------------------------- -- CmmCallTarget --