summaryrefslogtreecommitdiff
path: root/compiler/utils
diff options
context:
space:
mode:
authorPeter Wortmann <scpmw@leeds.ac.uk>2014-12-01 20:21:47 +0100
committerAustin Seipp <austin@well-typed.com>2014-12-16 15:01:40 -0600
commit993975d3a532887b38618eb604efe6502f3c66f8 (patch)
tree7b3ac0561fe537586f77e375f9a024f15db870cf /compiler/utils
parent1b5d758359ef1fec6974d4d67eaf31599ec0309b (diff)
downloadhaskell-993975d3a532887b38618eb604efe6502f3c66f8.tar.gz
Source notes (Core support)
This patch introduces "SourceNote" tickishs that link Core to the source code that generated it. The idea is to retain these source code links throughout code transformations so we can eventually relate object code all the way back to the original source (which we can, say, encode as DWARF information to allow debugging). We generate these SourceNotes like other tickshs in the desugaring phase. The activating command line flag is "-g", consistent with the flag other compilers use to decide DWARF generation. Keeping ticks from getting into the way of Core transformations is tricky, but doable. The changes in this patch produce identical Core in all cases I tested -- which at this point is GHC, all libraries and nofib. Also note that this pass creates *lots* of tick nodes, which we reduce somewhat by removing duplicated and overlapping source ticks. This will still cause significant Tick "clumps" - a possible future optimization could be to make Tick carry a list of Tickishs instead of one at a time. (From Phabricator D169)
Diffstat (limited to 'compiler/utils')
-rw-r--r--compiler/utils/OrdList.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/utils/OrdList.hs b/compiler/utils/OrdList.hs
index ad72ca1d45..9e735e7d80 100644
--- a/compiler/utils/OrdList.hs
+++ b/compiler/utils/OrdList.hs
@@ -9,6 +9,7 @@ Provide trees (of instructions), so that lists of instructions
can be appended in linear time.
-}
+{-# LANGUAGE CPP #-}
module OrdList (
OrdList,
nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL,
@@ -17,6 +18,10 @@ module OrdList (
import Outputable
+#if __GLASGOW_HASKELL__ < 709
+import Data.Monoid ( Monoid(..) )
+#endif
+
infixl 5 `appOL`
infixl 5 `snocOL`
infixr 5 `consOL`
@@ -33,6 +38,11 @@ data OrdList a
instance Outputable a => Outputable (OrdList a) where
ppr ol = ppr (fromOL ol) -- Convert to list and print that
+instance Monoid (OrdList a) where
+ mempty = nilOL
+ mappend = appOL
+ mconcat = concatOL
+
nilOL :: OrdList a
isNilOL :: OrdList a -> Bool