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 @@
{--- Beginnings of X86 specific stuff Arch_X86.hs ---}
{------------------------------------------------------------------------}
{-
{-
This file is part of Cacheprof, a profiling tool for finding
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
This program is free software; you can redistribute it and/or
......@@ -38,11 +38,11 @@ module Arch_x86 (
where
data Opcode
data Opcode
= O_movl | O_movw | O_movb
| O_movzbw | O_movzbl | O_movzwl
| O_movsbw | O_movsbl | O_movswl
| O_pushl | O_popl
| O_movzbw | O_movzbl | O_movzwl
| O_movsbw | O_movsbl | O_movswl
| O_pushl | O_popl
| O_pushfl | O_popfl
| O_notl | O_notw | O_notb
| O_sall | O_salw | O_salb
......@@ -75,8 +75,8 @@ data Opcode
| O_stosl | O_stosw | O_stosb
| O_leave | O_ret | O_call | O_jmp
| O_je | O_jne
| O_jl | O_jle
| O_je | O_jne
| O_jl | O_jle
| O_jg | O_jge
| O_js | O_jns
| O_jz | O_jnz
......@@ -98,7 +98,7 @@ data Opcode
| O_cbtw
| O_rep | O_repz | O_repnz
| 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_faddp | O_fadds | O_faddl | O_fadd | O_fiaddl
| O_fmul | O_fmuls | O_fmull | O_fmulp
......@@ -130,7 +130,7 @@ data Opcode
x86info :: [(Opcode, OperandInfo)]
x86info
x86info
= [
(O_movl, OI [OE_RW 4 4]),
(O_movw, OI [OE_RW 2 2]),
......@@ -430,8 +430,8 @@ nonJumpyOpcodes
,O_shrl ,O_shrw ,O_shrb
,O_sarl
,O_leal
,O_movzbw ,O_movzbl ,O_movzwl
,O_movsbw ,O_movsbl ,O_movswl
,O_movzbw ,O_movzbl ,O_movzwl
,O_movsbw ,O_movsbl ,O_movswl
, O_seta , O_setae
, O_setb , O_setbe
......
......@@ -3,11 +3,11 @@
{--- Generic stuff for all architectures. Generics.hs ---}
{------------------------------------------------------------------------}
{-
{-
This file is part of Cacheprof, a profiling tool for finding
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
This program is free software; you can redistribute it and/or
......@@ -33,7 +33,7 @@ module Generics where
internal msg
= error ("\ncacheann: Internal error: " ++ msg ++ "\n")
incomplete msg
= error ("\ncacheann: Unhandled instruction set artefact:\n "
= error ("\ncacheann: Unhandled instruction set artefact:\n "
++ msg ++ "\n")
inputerr msg
= error ("\ncacheann: Bad input: " ++ msg ++ "\n")
......@@ -105,14 +105,14 @@ pApply f p ts
= case p ts of
PFail -> PFail
POk x uu -> POk (f x) uu
pName :: String -> a -> Parser a
pName w x ((LName w2):lxs)
= if w == w2 then POk x lxs else PFail
pName w x _ = PFail
p2 :: (a -> b -> c)
p2 :: (a -> b -> c)
-> Parser a -> Parser b -> Parser c
p2 f p1 p2 ts1
= case p1 ts1 of { PFail -> PFail ; POk x1 uu1 ->
......@@ -120,7 +120,7 @@ p2 f p1 p2 ts1
POk (f x1 x2) uu2
}}
p3 :: (a -> b -> c -> d)
p3 :: (a -> b -> c -> d)
-> Parser a -> Parser b -> Parser c -> Parser d
p3 f p1 p2 p3 ts1
= case p1 ts1 of { PFail -> PFail ; POk x1 uu1 ->
......
......@@ -4,7 +4,7 @@
{--- CacheAnn.hs ---}
{------------------------------------------------------------------------}
{-
{-
This file is part of Cacheprof, a profiling tool for finding
sources of cache misses in programs.
......@@ -51,7 +51,7 @@ import Generics
-- an instruction (Real)
-- anything else (Pseudo)
-- If instruction counting is to work properly,
-- labels should not be concealed inside Pseudos.
-- labels should not be concealed inside Pseudos.
data PreLine
= PrePseudo Int String
......@@ -66,17 +66,17 @@ instance PP PreLine where
-- section-main
preparse :: String -> [PreLine]
preparse
preparse
= concatMap preparseLine . zip [1..] . lines
preparseLine :: (Int, String) -> [PreLine]
preparseLine (line_number,s)
| null cleaned
| null cleaned
= []
| looks_like_label cleaned
= case span isLabelIsh cleaned of
(label_name, rest)
(label_name, rest)
-> (PreLabel line_number (label_name ++ [head rest]))
: preparseLine (line_number, tail rest)
| head cleaned `elem` ".#"
......@@ -92,12 +92,12 @@ preparseLine (line_number,s)
untabbed x = not (null x) && head x /= '\t'
looks_like_label :: String -> Bool
looks_like_label x
looks_like_label x
= case span isLabelIsh x of
(label_name, rest)
-> not (null label_name)
(label_name, rest)
-> not (null label_name)
&& take 1 rest == ":"
&& (null (tail rest)
&& (null (tail rest)
|| isSpace (head (tail rest)))
......@@ -108,7 +108,7 @@ preparseLine (line_number,s)
-- Turn the list of PreLines into Lines by parsing
-- the instructions.
data PPM
data PPM
= PPM_Debug | PPM_User
deriving Eq
......@@ -123,7 +123,7 @@ class PP a where
ppl m = concat . intersperse "," . map (pp m)
data Line
data Line
= Pseudo Int String
| Label Int String
| Real Int CC Insn
......@@ -135,11 +135,11 @@ instance PP Line where
pp PPM_User (Label ln s) = s
pp PPM_Debug (Label ln s) = "L: " ++ s
pp PPM_User (Real ln cc insn)
pp PPM_User (Real ln cc insn)
= "\t" ++ pp PPM_User insn
pp PPM_Debug (Real ln cc insn)
pp PPM_Debug (Real ln cc insn)
= "R: " ++ pp PPM_Debug insn ++
if isNoCC cc
if isNoCC cc
then ""
else "\n CC = " ++ pp PPM_Debug cc
......@@ -183,20 +183,20 @@ ccGetFuncNm (CC filenm ln funcnm) = funcnm
-- section-main
parse :: [PreLine] -> [Line]
parse
parse
= map f
where
where
f (PrePseudo ln s) = Pseudo ln s
f (PreLabel ln s) = Label ln s
f (PreReal ln s)
= case pInsn (olex s) of
POk i [] -> Real ln NoCC i
_ -> bomb ln s
bomb ln s
= inputerr ("(stdin):" ++ show ln
++ ": syntax error on `" ++ s ++ "'\n" )
{-------------------------------------------}
{--- an lexer for x86, ---}
......@@ -218,9 +218,9 @@ olex (c:cs)
| c == '#' = [] -- comment; arch specific
| c == '%'
= case span isAlpha cs of
= case span isAlpha cs of
(rname, rest)
| rname == "st" && not (null rest)
| rname == "st" && not (null rest)
&& head rest == '('
-> case span (`elem` "(01234567)") rest of
(frname,rest2) -> (LReg (c:rname++frname)) : olex rest2
......@@ -229,7 +229,7 @@ olex (c:cs)
| otherwise
-> barf (c:cs)
| isDigit c
= case span isDigitish cs of
= case span isDigitish cs of
(num, rest) -> (LNum (c:num)) : olex rest
| isAlpha c || c == '_'
= case span isNameIsh cs of
......@@ -265,9 +265,9 @@ barf s = inputerr ( "lexical error on: `" ++ s ++ "'")
amode ::= (reg) -- B
| (reg,reg) -- B I
| (,reg,num) -- I S
| (reg,reg,num) -- B I S
| (reg,reg,num) -- B I S
const ::= (OPTIONAL '-') const_factor
const ::= (OPTIONAL '-') const_factor
(ZEROORMORE signed_const_factor)
signed_const_factor ::= + const_factor
......@@ -315,7 +315,7 @@ getAnns (SomeAnns anns) = anns
isDontAnnMe DontAnnMe = True
isDontAnnMe _ = False
data Insn
data Insn
= Insn Anns Opcode [Operand]
deriving (Show, Eq)
......@@ -332,7 +332,7 @@ data Operand
deriving (Show, Eq)
data AMode
= AM_B Reg
= AM_B Reg
| AM_BI Reg Reg
| AM_IS Reg String
| AM_BIS Reg Reg String
......@@ -340,7 +340,7 @@ data AMode
newtype Const
newtype Const
= Const [SignedFactor]
deriving (Show, Eq)
......@@ -348,18 +348,18 @@ data SignedFactor = Neg UnsignedFactor | Pos UnsignedFactor
deriving (Show, Eq)
data UnsignedFactor
= UF_NUM String
| UF_NAME String
= UF_NUM String
| UF_NAME String
| UF_LABEL String
| UF_TIMES UnsignedFactor UnsignedFactor
deriving (Show, Eq)
data Reg
data Reg
= EAX | EBX | ECX | EDX | EDI | ESI | EBP | ESP
| AX | BX | CX | DX | SI | DI | BP
| AL | BL | CL | DL
| AH | BH | CH | DH
| ST_0 | ST_1 | ST_2 | ST_3
| ST_0 | ST_1 | ST_2 | ST_3
| ST_4 | ST_5 | ST_6 | ST_7
deriving (Show, Eq)
......@@ -368,7 +368,7 @@ pOpcode
= pAlts (map (\o -> pName (drop 2 (show (fst o))) (fst o)) x86info)
pInsn :: Parser Insn
pInsn
pInsn
= p2 (Insn (SomeAnns [])) pOpcode (pStarComma pOperand)
pOperand :: Parser Operand
......@@ -421,7 +421,7 @@ pConst
= pAlts [
p2 (\ ca cas -> Const ((Pos ca):cas))
pUnsignedF (pStar pSignedF),
p3 (\_ ca cas -> Const ((Neg ca):cas))
p3 (\_ ca cas -> Const ((Neg ca):cas))
pLMinus pUnsignedF (pStar pSignedF)
]
......@@ -444,14 +444,14 @@ reg_map
= [("%eax",EAX),("%ebx",EBX),("%ecx",ECX),("%edx",EDX),
("%edi",EDI),("%esi",ESI),("%ebp",EBP),("%esp",ESP),
("%ax",AX), ("%bx",BX), ("%cx",CX), ("%dx",DX),
("%ax",AX), ("%bx",BX), ("%cx",CX), ("%dx",DX),
("%si",SI), ("%di",DI), ("%bp",BP),
("%al",AL), ("%bl",BL), ("%cl",CL), ("%dl",DL),
("%ah",AH), ("%bh",BH), ("%ch",CH), ("%dh",DH),
("%st", ST_0), ("%st(0)", ST_0),
("%st(1)", ST_1), ("%st(2)", ST_2), ("%st(3)", ST_3),
("%st", ST_0), ("%st(0)", ST_0),
("%st(1)", ST_1), ("%st(2)", ST_2), ("%st(3)", ST_3),
("%st(4)", ST_4), ("%st(5)", ST_5), ("%st(6)", ST_6),
("%st(7)", ST_7)
]
......@@ -464,20 +464,20 @@ reg_names
instance PP Insn where
pp ppm insn@(Insn ann opcode operands)
= main_part
= main_part
++ (if ppm == PPM_User
|| null (getAnns ann)
then []
then []
else take (max 0 (36 - length main_part)) (repeat ' ')
++ (if hasRealAnns insn
then " # ANN " else " # ")
++ (if hasRealAnns insn
then " # ANN " else " # ")
++ ppl ppm (getAnns ann)
)
where
main_part
= pp ppm opcode
++ (if null operands
then []
= pp ppm opcode
++ (if null operands
then []
else " " ++ ppl ppm operands)
instance PP Annot where
......@@ -499,7 +499,7 @@ instance PP AMode where
pp ppm (AM_B r1) = paren (pp ppm r1)
pp ppm (AM_BI r1 r2) = paren (pp ppm r1 ++ "," ++ pp ppm r2)
pp ppm (AM_IS r1 n) = paren ("," ++ pp ppm r1 ++ "," ++ n)
pp ppm (AM_BIS r1 r2 n)
pp ppm (AM_BIS r1 r2 n)
= paren (pp ppm r1 ++ "," ++ pp ppm r2 ++ "," ++ n)
instance PP Const where
......@@ -550,7 +550,7 @@ simpl_wrk lc []
simpl_wrk lc ((Real ln cc (Insn (SomeAnns []) O_rep [])) :
(Real _ _ (Insn (SomeAnns []) o_op [])) : lines)
| o_op `elem` [O_movsl, O_movsw, O_movsb,
| o_op `elem` [O_movsl, O_movsw, O_movsb,
O_stosl, O_stosw, O_stosb]
= let (l1,l2)
= (lc,lc+1)
......@@ -564,7 +564,7 @@ simpl_wrk lc ((Real ln cc (Insn (SomeAnns []) O_rep [])) :
mkLabelD ln
= Pseudo ln (mk_arch_label_def (labelName ln))
mkLabelU ln
= OP_D (Const [Pos (UF_LABEL
= OP_D (Const [Pos (UF_LABEL
(mk_arch_label_use (labelName ln)))])
in
[mkInsn O_pushfl [],
......@@ -589,7 +589,7 @@ simpl_wrk lc ((Real ln cc (Insn (SomeAnns []) o_reppy [])) :
| o_reppy `elem` [O_repz]
= O_jnz
| otherwise
= incomplete ("simpl_wrk rep: can't handle "
= incomplete ("simpl_wrk rep: can't handle "
++ show (o_reppy, o_op) ++ "\n")
(l1,l2,l3)
= (lc,lc+1,lc+2)
......@@ -604,7 +604,7 @@ simpl_wrk lc ((Real ln cc (Insn (SomeAnns []) o_reppy [])) :
mkLabelD ln
= Pseudo ln (mk_arch_label_def (labelName ln))
mkLabelU ln
= OP_D (Const [Pos (UF_LABEL
= OP_D (Const [Pos (UF_LABEL
(mk_arch_label_use (labelName ln)))])
......@@ -647,7 +647,7 @@ newtype BB = BB [Line]
instance PP BB where
pp ppm (BB ls)
= "{ -- basic block\n"
= "{ -- basic block\n"
++ unlines (map (pp ppm) ls)
++ "}"
......@@ -659,9 +659,9 @@ identify_bbs = map (\line -> BB [line])
-}
-- something a bit better
-- It could still be improved.
-- It could still be improved.
-- Use --ddump-ident-bbs to get ideas.
identify_bbs
identify_bbs
= merge_bbs . map (\line -> BB [line])
where
merge_bbs [] = []
......@@ -672,7 +672,7 @@ identify_bbs
= let bigger_bb = BB (lines1++[line])
in merge_bbs (bigger_bb : bbs)
| isOriginalInsn line
| isOriginalInsn line
&& any isReal lines1
&& isOriginalInsn last_Real_lines1
&& opcodeOfInsn (insnOfLine last_Real_lines1)
......@@ -743,7 +743,7 @@ annotate_insn insn@(Insn old_ann opcode operands)
| isDontAnnMe old_ann
= insn
| otherwise
= Insn (SomeAnns (filter (isMemOp.getAnnOp)
= Insn (SomeAnns (filter (isMemOp.getAnnOp)
(annsOf opcode operands)))
opcode operands
......@@ -765,7 +765,7 @@ annsOf opcode operands
= let opInfo
= getOperandInfo opcode
no_applicable_info
= incomplete ("operand info ("
= incomplete ("operand info ("
++ show opInfo
++ ") doesn't match operand(s): "
++ ppd (Insn mkNoAnns opcode operands))
......@@ -778,38 +778,38 @@ annsOf opcode operands
Nothing -> no_applicable_info
OI_Jumpy
-> case operands of
[op1] -> case op1 of
-> case operands of
[op1] -> case op1 of
{ OP_STAR o -> [AnnR 4 o]; _ -> [] }
other -> no_applicable_info
OI_NoEffect
-> []
OI_Error
-> internal ( "unsimplified opcode: "
++ ppd (Insn mkNoAnns opcode operands))
OI_Special
| opcode == O_pushl
-> case operands of
-> case operands of
[op1] -> [AnnR 4 op1, AnnW 4 the_sp_plus_4]
other -> no_applicable_info
| opcode == O_call
-> case operands of
-> case operands of
[op1] -> case op1 of
OP_STAR o -> [AnnR 4 o, AnnW 4 the_sp_plus_4]
direct -> [AnnW 4 the_sp_plus_4]
other -> no_applicable_info
| opcode == O_popl
-> case operands of
-> case operands of
[op1] -> [AnnR 4 the_sp_plus_8, AnnW 4 op1]
| opcode == O_ret
-> [AnnR 4 the_sp_plus_8]
| opcode == O_scasb
-> [AnnR 1 the_edi]
| opcode == O_cmpsb
......@@ -827,9 +827,9 @@ annsOf opcode operands
| opcode == O_stosb
-> [AnnW 1 the_edi] -- a guess
other
-> incomplete ("\nunclassifiable opcode: "
-> incomplete ("\nunclassifiable opcode: "
++ ppd (Insn mkNoAnns opcode operands) )
annsFromEffects :: [OperandEffect] -> [Operand] -> Maybe [Annot]
annsFromEffects effects operands
......@@ -841,42 +841,42 @@ annsFromEffects effects operands
case head effects of
OE_RR s1 s2
-> case operands of
-> case operands of
[op1, op2] -> Just [AnnR s1 op1, AnnR s2 op2]
other -> mismatch
OE_RM s1 s2
-> case operands of
-> case operands of
[op1, op2] -> Just [AnnR s1 op1, AnnM s2 op2]
other -> mismatch
OE_RW s1 s2
-> case operands of
-> case operands of
[op1, op2] -> Just [AnnR s1 op1, AnnW s2 op2]
other -> mismatch
OE_R s1
-> case operands of
-> case operands of
[op1] -> Just [AnnR s1 op1]
other -> mismatch