Commit 22240ca8 authored by Matthew Pickering's avatar Matthew Pickering Committed by Ben Gamari

Eliminate trailing whitespace

Reviewers: michalt, bgamari, O26 nofib, goldfire

Reviewed By: michalt, O26 nofib

Differential Revision: https://phabricator.haskell.org/D4045
parent cf032a22
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
{--- Beginnings of X86 specific stuff Arch_X86.hs ---} {--- Beginnings of X86 specific stuff Arch_X86.hs ---}
{------------------------------------------------------------------------} {------------------------------------------------------------------------}
{- {-
This file is part of Cacheprof, a profiling tool for finding This file is part of Cacheprof, a profiling tool for finding
sources of cache misses in programs. sources of cache misses in programs.
Copyright (C) 1999 Julian Seward (jseward@acm.org) Copyright (C) 1999 Julian Seward (jseward@acm.org)
Home page: http://www.cacheprof.org Home page: http://www.cacheprof.org
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
...@@ -38,11 +38,11 @@ module Arch_x86 ( ...@@ -38,11 +38,11 @@ module Arch_x86 (
where where
data Opcode data Opcode
= O_movl | O_movw | O_movb = O_movl | O_movw | O_movb
| O_movzbw | O_movzbl | O_movzwl | O_movzbw | O_movzbl | O_movzwl
| O_movsbw | O_movsbl | O_movswl | O_movsbw | O_movsbl | O_movswl
| O_pushl | O_popl | O_pushl | O_popl
| O_pushfl | O_popfl | O_pushfl | O_popfl
| O_notl | O_notw | O_notb | O_notl | O_notw | O_notb
| O_sall | O_salw | O_salb | O_sall | O_salw | O_salb
...@@ -75,8 +75,8 @@ data Opcode ...@@ -75,8 +75,8 @@ data Opcode
| O_stosl | O_stosw | O_stosb | O_stosl | O_stosw | O_stosb
| O_leave | O_ret | O_call | O_jmp | O_leave | O_ret | O_call | O_jmp
| O_je | O_jne | O_je | O_jne
| O_jl | O_jle | O_jl | O_jle
| O_jg | O_jge | O_jg | O_jge
| O_js | O_jns | O_js | O_jns
| O_jz | O_jnz | O_jz | O_jnz
...@@ -98,7 +98,7 @@ data Opcode ...@@ -98,7 +98,7 @@ data Opcode
| O_cbtw | O_cbtw
| O_rep | O_repz | O_repnz | O_rep | O_repz | O_repnz
| O_fild | O_fildl | O_fildll | O_fild | O_fildl | O_fildll
| O_fsubp | O_fsubr | O_fsubrp | O_fsubrl | O_fsubrs | O_fsubp | O_fsubr | O_fsubrp | O_fsubrl | O_fsubrs
| O_fsubs | O_fsubl | O_fsub | O_fsubs | O_fsubl | O_fsub
| O_faddp | O_fadds | O_faddl | O_fadd | O_fiaddl | O_faddp | O_fadds | O_faddl | O_fadd | O_fiaddl
| O_fmul | O_fmuls | O_fmull | O_fmulp | O_fmul | O_fmuls | O_fmull | O_fmulp
...@@ -130,7 +130,7 @@ data Opcode ...@@ -130,7 +130,7 @@ data Opcode
x86info :: [(Opcode, OperandInfo)] x86info :: [(Opcode, OperandInfo)]
x86info x86info
= [ = [
(O_movl, OI [OE_RW 4 4]), (O_movl, OI [OE_RW 4 4]),
(O_movw, OI [OE_RW 2 2]), (O_movw, OI [OE_RW 2 2]),
...@@ -430,8 +430,8 @@ nonJumpyOpcodes ...@@ -430,8 +430,8 @@ nonJumpyOpcodes
,O_shrl ,O_shrw ,O_shrb ,O_shrl ,O_shrw ,O_shrb
,O_sarl ,O_sarl
,O_leal ,O_leal
,O_movzbw ,O_movzbl ,O_movzwl ,O_movzbw ,O_movzbl ,O_movzwl
,O_movsbw ,O_movsbl ,O_movswl ,O_movsbw ,O_movsbl ,O_movswl
, O_seta , O_setae , O_seta , O_setae
, O_setb , O_setbe , O_setb , O_setbe
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
{--- Generic stuff for all architectures. Generics.hs ---} {--- Generic stuff for all architectures. Generics.hs ---}
{------------------------------------------------------------------------} {------------------------------------------------------------------------}
{- {-
This file is part of Cacheprof, a profiling tool for finding This file is part of Cacheprof, a profiling tool for finding
sources of cache misses in programs. sources of cache misses in programs.
Copyright (C) 1999 Julian Seward (jseward@acm.org) Copyright (C) 1999 Julian Seward (jseward@acm.org)
Home page: http://www.cacheprof.org Home page: http://www.cacheprof.org
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
...@@ -33,7 +33,7 @@ module Generics where ...@@ -33,7 +33,7 @@ module Generics where
internal msg internal msg
= error ("\ncacheann: Internal error: " ++ msg ++ "\n") = error ("\ncacheann: Internal error: " ++ msg ++ "\n")
incomplete msg incomplete msg
= error ("\ncacheann: Unhandled instruction set artefact:\n " = error ("\ncacheann: Unhandled instruction set artefact:\n "
++ msg ++ "\n") ++ msg ++ "\n")
inputerr msg inputerr msg
= error ("\ncacheann: Bad input: " ++ msg ++ "\n") = error ("\ncacheann: Bad input: " ++ msg ++ "\n")
...@@ -105,14 +105,14 @@ pApply f p ts ...@@ -105,14 +105,14 @@ pApply f p ts
= case p ts of = case p ts of
PFail -> PFail PFail -> PFail
POk x uu -> POk (f x) uu POk x uu -> POk (f x) uu
pName :: String -> a -> Parser a pName :: String -> a -> Parser a
pName w x ((LName w2):lxs) pName w x ((LName w2):lxs)
= if w == w2 then POk x lxs else PFail = if w == w2 then POk x lxs else PFail
pName w x _ = PFail pName w x _ = PFail
p2 :: (a -> b -> c) p2 :: (a -> b -> c)
-> Parser a -> Parser b -> Parser c -> Parser a -> Parser b -> Parser c
p2 f p1 p2 ts1 p2 f p1 p2 ts1
= case p1 ts1 of { PFail -> PFail ; POk x1 uu1 -> = case p1 ts1 of { PFail -> PFail ; POk x1 uu1 ->
...@@ -120,7 +120,7 @@ p2 f p1 p2 ts1 ...@@ -120,7 +120,7 @@ p2 f p1 p2 ts1
POk (f x1 x2) uu2 POk (f x1 x2) uu2
}} }}
p3 :: (a -> b -> c -> d) p3 :: (a -> b -> c -> d)
-> Parser a -> Parser b -> Parser c -> Parser d -> Parser a -> Parser b -> Parser c -> Parser d
p3 f p1 p2 p3 ts1 p3 f p1 p2 p3 ts1
= case p1 ts1 of { PFail -> PFail ; POk x1 uu1 -> = case p1 ts1 of { PFail -> PFail ; POk x1 uu1 ->
......
This diff is collapsed.
...@@ -140,10 +140,10 @@ Basic circuit components ...@@ -140,10 +140,10 @@ Basic circuit components
> = None -- no component > = None -- no component
> | Inp -- input to the entire circuit > | Inp -- input to the entire circuit
> | Outp -- output from the entire circuit > | Outp -- output from the entire circuit
> | Dff -- delay flip flop > | Dff -- delay flip flop
> | Inv -- inverter > | Inv -- inverter
> | And2 -- 2-input and gate > | And2 -- 2-input and gate
> | Or2 -- 2-input or gate > | Or2 -- 2-input or gate
> | Xor -- exclusive or gate > | Xor -- exclusive or gate
> deriving (Eq, Show) > deriving (Eq, Show)
...@@ -165,12 +165,12 @@ a is the type of a signal (the value on a wire) ...@@ -165,12 +165,12 @@ a is the type of a signal (the value on a wire)
> a) -- latch to hold the input signal value > a) -- latch to hold the input signal value
> type OutPort a = > type OutPort a =
> (Int, -- output port number for the signal value > (Int, -- output port number for the signal value
> a, -- latch to hold the signal value > a, -- latch to hold the signal value
> Bool, -- need to send it to the left? > Bool, -- need to send it to the left?
> Int, -- distance to send to the left > Int, -- distance to send to the left
> Bool, -- need to send it to the right? > Bool, -- need to send it to the right?
> Int) -- distance to send to the right > Int) -- distance to send to the right
...@@ -235,9 +235,9 @@ a power of two ...@@ -235,9 +235,9 @@ a power of two
> emptyState :: Signal a => State a > emptyState :: Signal a => State a
> emptyState = PS { pid = -1, > emptyState = PS { pid = -1,
> compType = None, > compType = None,
> pathDepth = -1, > pathDepth = -1,
> inports = [], > inports = [],
> outports = []} > outports = []}
...@@ -274,12 +274,12 @@ Packets are just OutPorts with a pid ...@@ -274,12 +274,12 @@ Packets are just OutPorts with a pid
> type Packet a = > type Packet a =
> (Pid, -- id of this packet > (Pid, -- id of this packet
> Int, -- output port number for the signal value > Int, -- output port number for the signal value
> a, -- latch to hold the signal value > a, -- latch to hold the signal value
> Bool, -- need to send it to the left? > Bool, -- need to send it to the left?
> Int, -- distance to send to the left > Int, -- distance to send to the left
> Bool, -- need to send it to the right? > Bool, -- need to send it to the right?
> Int, -- distance to send to the right > Int, -- distance to send to the right
> Int) -- extent > Int) -- extent
...@@ -388,7 +388,7 @@ need to restore them to there original values. ...@@ -388,7 +388,7 @@ need to restore them to there original values.
> restore_requests old_states new_states > restore_requests old_states new_states
> = zipWith restore old_states new_states > = zipWith restore old_states new_states
> where > where
> restore os ns = ns { outports = zipWith restore_outport (outports os) > restore os ns = ns { outports = zipWith restore_outport (outports os)
> (outports ns) } > (outports ns) }
> restore_outport (p,_,ql,dl,qr,dq) (_,m,_,_,_,_) = (p,m,ql,dl,qr,dq) > restore_outport (p,_,ql,dl,qr,dq) (_,m,_,_,_,_) = (p,m,ql,dl,qr,dq)
...@@ -427,10 +427,10 @@ Update both the inports and outports of a state ...@@ -427,10 +427,10 @@ Update both the inports and outports of a state
> update_io :: Signal a => Int -> [(Packet a,Packet a)] -> State a -> State a > update_io :: Signal a => Int -> [(Packet a,Packet a)] -> State a -> State a
> update_io d lrps state = update_os (update_is state) > update_io d lrps state = update_os (update_is state)
> where > where
> update_is state = state { inports = foldr update_i > update_is state = state { inports = foldr update_i
> (inports state) lrps } > (inports state) lrps }
> update_os state = if pathDepth state == d > update_os state = if pathDepth state == d
> then state { outports = zipWith update_o > then state { outports = zipWith update_o
> lrps (outports state) } > lrps (outports state) }
> else state > else state
...@@ -529,7 +529,7 @@ Place input values into circuit's input components ...@@ -529,7 +529,7 @@ Place input values into circuit's input components
> store_inputs :: Signal a => [(Label,a)] -> State a -> State a > store_inputs :: Signal a => [(Label,a)] -> State a -> State a
> store_inputs label_inputs state@(PS {compType=Inp}) > store_inputs label_inputs state@(PS {compType=Inp})
> = head [ update_outports state value > = head [ update_outports state value
> | ((label, input_pid), value) <- label_inputs, > | ((label, input_pid), value) <- label_inputs,
> pid state == input_pid ] > pid state == input_pid ]
> store_inputs label_inputs state = state > store_inputs label_inputs state = state
...@@ -593,7 +593,7 @@ Circuit example -- a register ...@@ -593,7 +593,7 @@ Circuit example -- a register
> compType = Inp, > compType = Inp,
> pathDepth = 0, > pathDepth = 0,
> inports = [], > inports = [],
> outports = [(0, zeroS, False, > outports = [(0, zeroS, False,
> 0, True, 8*(bits-1)+5)] > 0, True, 8*(bits-1)+5)]
> } > }
......
...@@ -29,7 +29,7 @@ data Assign = Var := Value deriving (Eq, Ord, Show) ...@@ -29,7 +29,7 @@ data Assign = Var := Value deriving (Eq, Ord, Show)
type Relation = Assign -> Assign -> Bool type Relation = Assign -> Assign -> Bool
data CSP = CSP { vars, vals :: Int, rel :: Relation } data CSP = CSP { vars, vals :: Int, rel :: Relation }
type State = [Assign] type State = [Assign]
...@@ -111,18 +111,18 @@ data Maybe a = Just a | Nothing deriving Eq ...@@ -111,18 +111,18 @@ data Maybe a = Just a | Nothing deriving Eq
earliestInconsistency :: CSP -> State -> Maybe (Var,Var) earliestInconsistency :: CSP -> State -> Maybe (Var,Var)
earliestInconsistency CSP{rel=rel} [] = Nothing earliestInconsistency CSP{rel=rel} [] = Nothing
earliestInconsistency CSP{rel=rel} (a:as) = earliestInconsistency CSP{rel=rel} (a:as) =
case filter (not . rel a) (reverse as) of case filter (not . rel a) (reverse as) of
[] -> Nothing [] -> Nothing
(b:_) -> Just (level a, level b) (b:_) -> Just (level a, level b)
labelInconsistencies :: CSP -> Transform State (State,Maybe (Var,Var)) labelInconsistencies :: CSP -> Transform State (State,Maybe (Var,Var))
labelInconsistencies csp = mapTree f labelInconsistencies csp = mapTree f
where f s = (s,earliestInconsistency csp s) where f s = (s,earliestInconsistency csp s)
btsolver0 :: CSP -> [State] btsolver0 :: CSP -> [State]
btsolver0 csp = btsolver0 csp =
(filter (complete csp) . leaves . (mapTree fst) . prune ((/= Nothing) . snd) (filter (complete csp) . leaves . (mapTree fst) . prune ((/= Nothing) . snd)
. (labelInconsistencies csp) . mkTree) csp . (labelInconsistencies csp) . mkTree) csp
----------------------------------------------- -----------------------------------------------
...@@ -150,7 +150,7 @@ search labeler csp = ...@@ -150,7 +150,7 @@ search labeler csp =
bt :: Labeler bt :: Labeler
bt csp = mapTree f bt csp = mapTree f
where f s = (s, where f s = (s,
case earliestInconsistency csp s of case earliestInconsistency csp s of
Nothing -> checkComplete csp s Nothing -> checkComplete csp s
Just (a,b) -> Known [a,b]) Just (a,b) -> Known [a,b])
...@@ -211,14 +211,14 @@ fillTable :: State -> CSP -> Table -> Table ...@@ -211,14 +211,14 @@ fillTable :: State -> CSP -> Table -> Table
fillTable [] csp tbl = tbl fillTable [] csp tbl = tbl
fillTable ((var' := val'):as) CSP{vars=vars,vals=vals,rel=rel} tbl = fillTable ((var' := val'):as) CSP{vars=vars,vals=vals,rel=rel} tbl =
zipWith (zipWith f) tbl [[(var,val) | val <- [1..vals]] | var <- [var'+1..vars]] zipWith (zipWith f) tbl [[(var,val) | val <- [1..vals]] | var <- [var'+1..vars]]
where f cs (var,val) = if cs == Unknown && not (rel (var' := val') (var := val)) then where f cs (var,val) = if cs == Unknown && not (rel (var' := val') (var := val)) then
Known [var',var] Known [var',var]
else cs else cs
lookupCache :: CSP -> Transform (State, Table) ((State, ConflictSet), Table) lookupCache :: CSP -> Transform (State, Table) ((State, ConflictSet), Table)
lookupCache csp t = mapTree f t lookupCache csp t = mapTree f t
where f ([], tbl) = (([], Unknown), tbl) where f ([], tbl) = (([], Unknown), tbl)
f (s@(a:_), tbl) = ((s, cs), tbl) f (s@(a:_), tbl) = ((s, cs), tbl)
where cs = if tableEntry == Unknown then checkComplete csp s else tableEntry where cs = if tableEntry == Unknown then checkComplete csp s else tableEntry
tableEntry = (head tbl)!!(value a-1) tableEntry = (head tbl)!!(value a-1)
...@@ -233,18 +233,18 @@ bjbt' :: Labeler ...@@ -233,18 +233,18 @@ bjbt' :: Labeler
bjbt' csp = bj' csp . bt csp bjbt' csp = bj' csp . bt csp
bj :: CSP -> Transform (State, ConflictSet) (State, ConflictSet) bj :: CSP -> Transform (State, ConflictSet) (State, ConflictSet)
bj csp = foldTree f bj csp = foldTree f
where f (a, Known cs) chs = Node (a,Known cs) chs where f (a, Known cs) chs = Node (a,Known cs) chs
f (a, Unknown) chs = Node (a,Known cs') chs f (a, Unknown) chs = Node (a,Known cs') chs
where cs' = combine (map label chs) [] where cs' = combine (map label chs) []
combine :: [(State, ConflictSet)] -> [Var] -> [Var] combine :: [(State, ConflictSet)] -> [Var] -> [Var]
combine [] acc = acc combine [] acc = acc
combine ((s, Known cs):css) acc = combine ((s, Known cs):css) acc =
if maxLevel s `notElem` cs then cs else combine css (cs `union` acc) if maxLevel s `notElem` cs then cs else combine css (cs `union` acc)
bj' :: CSP -> Transform (State, ConflictSet) (State, ConflictSet) bj' :: CSP -> Transform (State, ConflictSet) (State, ConflictSet)
bj' csp = foldTree f bj' csp = foldTree f
where f (a, Known cs) chs = Node (a,Known cs) chs where f (a, Known cs) chs = Node (a,Known cs) chs
f (a, Unknown) chs = if knownConflict cs' then Node (a,cs') [] else Node (a,cs') chs f (a, Unknown) chs = if knownConflict cs' then Node (a,cs') [] else Node (a,cs') chs
where cs' = Known (combine (map label chs) []) where cs' = Known (combine (map label chs) [])
...@@ -262,8 +262,8 @@ collect (Known cs:css) = cs `union` (collect css) ...@@ -262,8 +262,8 @@ collect (Known cs:css) = cs `union` (collect css)
domainWipeOut :: CSP -> Transform ((State, ConflictSet), Table) (State, ConflictSet) domainWipeOut :: CSP -> Transform ((State, ConflictSet), Table) (State, ConflictSet)
domainWipeOut CSP{vars=vars} t = mapTree f t domainWipeOut CSP{vars=vars} t = mapTree f t
where f ((as, cs), tbl) = (as, cs') where f ((as, cs), tbl) = (as, cs')
where wipedDomains = ([vs | vs <- tbl, all (knownConflict) vs]) where wipedDomains = ([vs | vs <- tbl, all (knownConflict) vs])
cs' = if null wipedDomains then cs else Known (collect (head wipedDomains)) cs' = if null wipedDomains then cs else Known (collect (head wipedDomains))
......
...@@ -4,7 +4,7 @@ To: simonpj@dcs.gla.ac.uk ...@@ -4,7 +4,7 @@ To: simonpj@dcs.gla.ac.uk
Subject: Fibonacci Heaps Subject: Fibonacci Heaps
As I promised at the Haskell Workshop, here is a sample program As I promised at the Haskell Workshop, here is a sample program
using encapsulated state. I've translated this from SML, but using encapsulated state. I've translated this from SML, but
in doing so, I noticed that in fact accumArray is all the in doing so, I noticed that in fact accumArray is all the
encapsulated state you really need for this application. In SML, encapsulated state you really need for this application. In SML,
we are forced to use mutable arrays because we don't have such we are forced to use mutable arrays because we don't have such
...@@ -65,13 +65,13 @@ binomial trees. ...@@ -65,13 +65,13 @@ binomial trees.
>data Tree a = Node a [Tree a] >data Tree a = Node a [Tree a]
The degree of a binomial tree is equal to its number of children. The degree of a binomial tree is equal to its number of children.
Every binomial tree of degree k has binomial trees of degrees Every binomial tree of degree k has binomial trees of degrees
k-1...0 as children, in that order. It is easy to show that k-1...0 as children, in that order. It is easy to show that
a binomial tree of degree k has size 2^k. a binomial tree of degree k has size 2^k.
The fundamental operation on binomial trees is linking, which compares The fundamental operation on binomial trees is linking, which compares
the roots of two binomial trees and makes the larger a child of the the roots of two binomial trees and makes the larger a child of the
smaller (thus bumping its degree by one). It is essential that this smaller (thus bumping its degree by one). It is essential that this
only be called on binomial trees of equal degree. only be called on binomial trees of equal degree.
...@@ -135,10 +135,10 @@ with a forest of trees summing to the correct size. ...@@ -135,10 +135,10 @@ with a forest of trees summing to the correct size.
>type Forest a = Bag (TaggedTree a) >type Forest a = Bag (TaggedTree a)
In binomial queues, this forest must be maintained in strictly increasing In binomial queues, this forest must be maintained in strictly increasing
order of degree. For Fibonacci heaps, we adopt a more relaxed attitude: order of degree. For Fibonacci heaps, we adopt a more relaxed attitude:
degrees may be repeated and order does not matter. degrees may be repeated and order does not matter.
To be able to find the minimum element quickly, we keep the tree with the To be able to find the minimum element quickly, we keep the tree with the
minimum root outside of the bag. In addition, at the top level of each heap, minimum root outside of the bag. In addition, at the top level of each heap,
we store the total size of the heap. we store the total size of the heap.
...@@ -182,7 +182,7 @@ the other using accumArray. ...@@ -182,7 +182,7 @@ the other using accumArray.
In the first implementation, there are three steps. In the first implementation, there are three steps.
1. Allocate an array indexed by degrees. 1. Allocate an array indexed by degrees.
2. Insert every tree into this array. If, when inserting a tree of 2. Insert every tree into this array. If, when inserting a tree of
degree k, there already exists a tree of degree k, link the degree k, there already exists a tree of degree k, link the
two trees and reinsert the new larger tree. two trees and reinsert the new larger tree.
3. Transfer the trees into a bag, keeping track of the minimum tree. 3. Transfer the trees into a bag, keeping track of the minimum tree.
...@@ -222,8 +222,8 @@ the highest slot of the array. ...@@ -222,8 +222,8 @@ the highest slot of the array.
> getMin' a mini mint (ConsBag (i, t) b) (i+1) > getMin' a mini mint (ConsBag (i, t) b) (i+1)
> else > else
> getMin' a i t (ConsBag (mini, mint) b) (i+1) > getMin' a i t (ConsBag (mini, mint) b) (i+1)
> >
> in > in
> runST (newArray (0,d) Zero >>= \a -> > runST (newArray (0,d) Zero >>= \a ->
> applyToAll (ins a) f >> > applyToAll (ins a) f >>
> sequence (map (ins a) (getChildren tt)) >> > sequence (map (ins a) (getChildren tt)) >>
...@@ -233,7 +233,7 @@ the highest slot of the array. ...@@ -233,7 +233,7 @@ the highest slot of the array.
--------------------