-
Notifications
You must be signed in to change notification settings - Fork 182
Expand file tree
/
Copy pathFlags.hs
More file actions
368 lines (336 loc) · 10.3 KB
/
Copy pathFlags.hs
File metadata and controls
368 lines (336 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
module Flags(
Flags(..),
remapFlagsPaths,
redSteps,
ResourceFlag(..), SATFlag(..), MsgListFlag(..),
DumpFlag(..),
hasDump, hasDumpStrict, dumpInfo,
Verbosity(..), extraVerbose, verbose, quiet,
moreTalkative, lessTalkative, setVerbose,
) where
import Control.Applicative((<|>))
import Data.Maybe(isJust)
import Backend
-- -------------------------
-- Internal flags
--
-- This is the data structure which will be carried through the program.
data Flags = Flags {
aggImpConds :: Bool,
allowIncoherentMatches :: Bool,
backend :: Maybe Backend,
bdir :: Maybe String,
biasMethodScheduling :: Bool,
bluespecDir :: String,
cIncPath :: [String],
cLibPath :: [String],
cLibs :: [String],
cDebug :: Bool,
cFlags :: [String],
cxxFlags :: [String],
cppFlags :: [String],
linkFlags :: [String],
cdir :: Maybe String,
cpp :: Bool,
defines :: [String],
demoteErrors :: MsgListFlag,
disableAssertions :: Bool,
passThroughAssertions :: Bool,
doICheck :: Bool,
dumpAll :: Maybe (Maybe FilePath), -- maybe dump to file or stdout
dumps :: [(DumpFlag, Maybe FilePath)], -- dump to file or stdout
-- prefix remappings applied to file paths stored in .bo/.ba
-- files (source positions, the .ba module path fields, and the
-- path-valued fields of this record as stored in .ba), so that
-- outputs do not depend on the build machine's directory layout
remapPathPrefix :: [(String, String)],
enablePoisonPills :: Bool,
entry :: Maybe String,
expandATSlimit :: Int,
expandIf :: Bool,
fdir :: Maybe String,
finalcleanup :: Int,
genABin :: Bool,
genABinVerilog :: Bool,
genName :: [String],
genSysC :: Bool,
ifcPathRaw :: [String],
ifcPath :: [String],
infoDir :: Maybe String,
inlineBool :: Bool,
inlineISyntax :: Bool,
inlineSimple :: Bool,
keepAddSize :: Bool,
keepFires :: Bool,
keepInlined :: Bool,
kill :: Maybe (DumpFlag, Maybe String),
ifLift :: Bool,
letGen :: Bool,
maxTIStackDepth :: Int,
methodBVI :: Bool,
methodConf :: Bool,
methodConditions :: Bool,
neatNames :: Bool,
oFile :: String,
optAggInline :: Bool,
optATS :: Bool,
optAndOr :: Bool,
optBitConst :: Bool,
optBool :: Bool,
optFinalPass :: Bool,
optIfMux :: Bool,
optIfMuxSize :: Integer,
optJoinDefs :: Bool,
optMux :: Bool,
optMuxExpand :: Bool,
optMuxConst :: Bool,
optSched :: Bool,
optUndet :: Bool,
crossInfo :: Bool,
parallelSimLink :: Integer,
printFlags :: Bool,
printFlagsHidden :: Bool,
printFlagsRaw :: Bool,
preprocessOnly :: Bool,
promoteWarnings :: MsgListFlag,
readableMux :: Bool,
redStepsWarnInterval :: Integer,
redStepsMaxIntervals :: Integer,
relaxMethodEarliness :: Bool,
removeEmptyRules :: Bool,
removeFalseRules :: Bool,
removeInoutConnect :: Bool,
removePrimModules :: Bool,
removeCReg :: Bool,
removeReg :: Bool,
removeRWire :: Bool,
removeCross :: Bool,
removeStarvedRules :: Bool,
removeUnusedMods :: Bool,
removeVerilogDollar :: Bool,
resetName :: String,
resource :: ResourceFlag,
rstGate :: Bool,
ruleNameCheck :: Bool,
satBackend :: SATFlag,
schedConds:: Bool,
schedDOT :: Bool,
schedQueries :: [(String,String)],
showCSyntax :: Bool,
showCodeGen :: Bool,
showElabProgress :: Bool,
showIESyntax :: Bool,
showISyntax :: Bool,
showModuleUse :: Bool,
showRangeConflict :: Bool,
showSchedule :: Bool,
showStats :: Bool,
showUpds :: Bool,
simplifyCSyntax :: Bool,
strictMethodSched :: Bool,
suppressWarnings :: MsgListFlag,
synthesize :: Bool,
systemVerilogTasks :: Bool,
tclShowHidden :: Bool,
timeStamps :: Bool,
showVersion :: Bool,
testAssert :: Bool,
unsafeAlwaysRdy :: Bool,
unSpecTo :: String,
updCheck :: Bool,
useDPI :: Bool,
useNegate :: Bool,
usePrelude :: Bool,
useProvisoSAT :: Bool,
stdlibNames :: Bool,
v95 :: Bool,
vFlags :: [String],
vdir :: Maybe String,
vPathRaw :: [String],
vPath :: [String],
vpp :: Bool,
vsim :: Maybe String,
verbosity :: Verbosity,
verilogDeclareAllFirst :: Bool,
verilogFilter :: [String],
warnActionShadowing :: Bool,
warnMethodUrgency :: Bool,
warnUndetPred :: Bool
}
-- don't derive Show -- it causes an optimized ghc build to take a long time
-- deriving (Show)
data Verbosity = Quiet | Normal | Verbose | ExtraVerbose
deriving(Eq, Show, Ord, Enum)
extraVerbose :: Flags -> Bool
extraVerbose = (== ExtraVerbose) . verbosity
verbose :: Flags -> Bool
verbose = (>= Verbose) . verbosity
setVerbose :: Bool -> Flags -> Flags
setVerbose False f = f
setVerbose True f = f { verbosity = max Verbose (verbosity f) }
quiet :: Flags -> Bool
quiet = (== Quiet) . verbosity
moreTalkative :: Flags -> Flags
moreTalkative f =
case verbosity f of
ExtraVerbose -> f
v -> f { verbosity = succ v }
lessTalkative :: Flags -> Flags
lessTalkative f =
case verbosity f of
Quiet -> f
v -> f { verbosity = pred v }
data DumpFlag
=
-- Bluespec source file
DFdepend
| DFcpp
| DFvpp
| DFbsvlex
| DFparsed
| DFimports
| DFopparse
| DFsyminitial
| DFsympostgenwrap
| DFsympostderiving
| DFsympostctxreduce
| DFsympostbinary
| DFgenfuncwrap
| DFgenwrap
| DFderiving
| DFctxreduce
| DFconvinst
| DFtypecheck
| DFgenforeign
| DFgenVPI
| DFsimplified
| DFinternal
| DFbinary
| DFfixup
| DFisimplify
| DFwriteBin
-- module generation
| DFexpanded
| DFinlineFmt
| DFinline
| DFtransform
| DFsplitIf
| DFlift
| DFiparams
| DFidroprules
| DFATS
| DFATSexpand
| DFdumpLambdaCalculus
| DFdumpSAL
| DFATSperfspec
| DFATSsplice
| DFATSclean
| DFpathsPreSched
| DFschedule
| DFresources
| DFvschedinfo
| DFscheduledefs
| DFdumpschedule
| DFcheckproofs
| DFpathsPostSched
| DFnoinline
| DFaddSchedAssumps
| DFremoveAssumps
| DFdropundet
| DFwriteABin
| DFwrappergen
| DFwrappercomp
-- Wrapper compilation phases
| DFwrapper_ctxreduce
| DFwrapper_typecheck
| DFwrapper_simplified
| DFwrapper_internal
| DFwrapper_fixup
-- Generate Verilog
| DFforeignMap
| DFastate
| DFrwire
| DFcreg
| DFrenameio
| DFadropdefs
| DFaopt
| DFsynthesize
| DFveriquirks
| DFfinalcleanup
| DFIOproperties
| DFverilog
| DFverilogDollar
| DFwriteVerilog
-- Link
| DFreadelab
-- Link Verilog
| DFcompileVPI
| DFveriloglink
-- Generate/Link Bluesim
| DFsimExpand
| DFsimDepend
| DFsimPackageOpt
| DFsimMakeCBlocks
| DFsimCOpt
| DFsimBlocksToC
| DFgenSystemC
| DFwriteC
| DFbluesimcompile
| DFbluesimlink
deriving (Eq, Read, Show, Enum, Bounded)
data ResourceFlag
= RFoff -- don't reschedule: fail if not enough resources
| RFsimple -- reschedule: arbitrate resources (drop first edge in graph)
deriving (Eq, Show)
data SATFlag
= SAT_Yices
| SAT_STP
deriving (Eq, Show)
data MsgListFlag = AllMsgs | SomeMsgs [String]
deriving (Show, Eq)
-----
-- The number of reduction steps is defined based on the interval
redSteps :: Flags -> Integer
redSteps flags = (redStepsWarnInterval flags) *
(redStepsMaxIntervals flags)
-----
hasDump :: Flags -> DumpFlag -> Bool
hasDump f d = (isJust $ dumpAll f) || (hasDumpStrict f d)
hasDumpStrict :: Flags -> DumpFlag -> Bool
hasDumpStrict f d = isJust $ lookup d (dumps f)
dumpInfo :: Flags -> DumpFlag -> Maybe (Maybe FilePath)
dumpInfo f d = lookup d (dumps f) <|> dumpAll f
-- -------------------------
-- Apply the -remap-path-prefix mappings to the path-valued fields of
-- the record itself. Used on the copy of Flags stored in .ba files
-- (which is consumed only by bluetcl introspection), so that .ba
-- bytes do not depend on the build machine's directory layout. The
-- remapping helper lives in FileNameUtil; it is passed in here to
-- avoid an import cycle.
remapFlagsPaths :: ([(String, String)] -> FilePath -> FilePath) -> Flags -> Flags
remapFlagsPaths remap flags =
let ps = remapPathPrefix flags
r = remap ps
rM = fmap r
rL = map r
in if null ps then flags else flags {
-- the stored flags describe the remapped world: no further
-- remapping applies (and the FROM prefixes are themselves
-- machine-specific, which is the very thing being scrubbed)
remapPathPrefix = [],
bdir = rM (bdir flags),
bluespecDir = r (bluespecDir flags),
cIncPath = rL (cIncPath flags),
cLibPath = rL (cLibPath flags),
cdir = rM (cdir flags),
fdir = rM (fdir flags),
ifcPathRaw = rL (ifcPathRaw flags),
ifcPath = rL (ifcPath flags),
infoDir = rM (infoDir flags),
oFile = r (oFile flags),
vdir = rM (vdir flags),
vPathRaw = rL (vPathRaw flags),
vPath = rL (vPath flags),
dumps = [ (d, rM mf) | (d, mf) <- dumps flags ],
dumpAll = fmap rM (dumpAll flags)
}