| 1 | (* Copyright (C) 2009-2012,2014-2017 Matthew Fluet. |
| 2 | * Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh |
| 3 | * Jagannathan, and Stephen Weeks. |
| 4 | * Copyright (C) 1997-2000 NEC Research Institute. |
| 5 | * |
| 6 | * MLton is released under a BSD-style license. |
| 7 | * See the file MLton-LICENSE for details. |
| 8 | *) |
| 9 | |
| 10 | signature CONTROL_FLAGS = |
| 11 | sig |
| 12 | (* set all flags to their default values *) |
| 13 | val defaults: unit -> unit |
| 14 | |
| 15 | val all : unit -> {name: string, |
| 16 | value: string} list |
| 17 | |
| 18 | (*------------------------------------*) |
| 19 | (* Begin Flags *) |
| 20 | (*------------------------------------*) |
| 21 | |
| 22 | datatype align = Align4 | Align8 |
| 23 | val align: align ref |
| 24 | |
| 25 | val atMLtons: string vector ref |
| 26 | |
| 27 | datatype chunk = |
| 28 | OneChunk |
| 29 | | ChunkPerFunc |
| 30 | | Coalesce of {limit: int} |
| 31 | |
| 32 | val chunk: chunk ref |
| 33 | |
| 34 | val closureConvertGlobalize: bool ref |
| 35 | val closureConvertShrink: bool ref |
| 36 | |
| 37 | structure Codegen: |
| 38 | sig |
| 39 | datatype t = |
| 40 | AMD64Codegen |
| 41 | | CCodegen |
| 42 | | LLVMCodegen |
| 43 | | X86Codegen |
| 44 | val all: t list |
| 45 | val toString: t -> string |
| 46 | end |
| 47 | |
| 48 | datatype codegen = datatype Codegen.t |
| 49 | |
| 50 | val codegen: Codegen.t ref |
| 51 | |
| 52 | val contifyIntoMain: bool ref |
| 53 | |
| 54 | (* Generate an executable with debugging info. *) |
| 55 | val debug: bool ref |
| 56 | |
| 57 | val defaultChar: string ref |
| 58 | val defaultWideChar: string ref |
| 59 | val defaultInt: string ref |
| 60 | val defaultReal: string ref |
| 61 | val defaultWord: string ref |
| 62 | |
| 63 | (* List of pass names to keep diagnostic info on. *) |
| 64 | val diagPasses: Regexp.Compiled.t list ref |
| 65 | |
| 66 | (* List of optimization passes to disable/enable. *) |
| 67 | val executePasses: (Regexp.Compiled.t * bool) list ref |
| 68 | |
| 69 | structure Elaborate: |
| 70 | sig |
| 71 | structure DiagEIW : |
| 72 | sig |
| 73 | datatype t = |
| 74 | Error |
| 75 | | Ignore |
| 76 | | Warn |
| 77 | end |
| 78 | structure DiagDI : |
| 79 | sig |
| 80 | datatype t = |
| 81 | Default |
| 82 | | Ignore |
| 83 | end |
| 84 | structure ResolveScope : |
| 85 | sig |
| 86 | datatype t = |
| 87 | Dec |
| 88 | | Strdec |
| 89 | | Topdec |
| 90 | | Program |
| 91 | end |
| 92 | |
| 93 | type ('args, 'st) t |
| 94 | |
| 95 | val document: {expert: bool} -> Layout.t |
| 96 | |
| 97 | val allowConstant: (bool,bool) t |
| 98 | val allowFFI: (bool,bool) t |
| 99 | val allowOverload: (bool,bool) t |
| 100 | val allowPrim: (bool,bool) t |
| 101 | val allowRedefineSpecialIds: (bool,bool) t |
| 102 | val allowSpecifySpecialIds: (bool,bool) t |
| 103 | val deadCode: (bool,bool) t |
| 104 | val forceUsed: (unit,bool) t |
| 105 | val ffiStr: (string,string option) t |
| 106 | val nonexhaustiveBind: (DiagEIW.t,DiagEIW.t) t |
| 107 | val nonexhaustiveExnBind: (DiagDI.t,DiagDI.t) t |
| 108 | val redundantBind: (DiagEIW.t,DiagEIW.t) t |
| 109 | val nonexhaustiveMatch: (DiagEIW.t,DiagEIW.t) t |
| 110 | val nonexhaustiveExnMatch: (DiagDI.t,DiagDI.t) t |
| 111 | val redundantMatch: (DiagEIW.t,DiagEIW.t) t |
| 112 | val nonexhaustiveRaise: (DiagEIW.t,DiagEIW.t) t |
| 113 | val nonexhaustiveExnRaise: (DiagDI.t,DiagDI.t) t |
| 114 | val redundantRaise: (DiagEIW.t,DiagEIW.t) t |
| 115 | val resolveScope: (ResolveScope.t,ResolveScope.t) t |
| 116 | val sequenceNonUnit: (DiagEIW.t,DiagEIW.t) t |
| 117 | val valrecConstr: (DiagEIW.t,DiagEIW.t) t |
| 118 | val warnUnused: (bool,bool) t |
| 119 | |
| 120 | (* Successor ML *) |
| 121 | val allowDoDecls: (bool,bool) t |
| 122 | val allowExtendedNumConsts: (bool,bool) t |
| 123 | val allowExtendedTextConsts: (bool,bool) t |
| 124 | val allowLineComments: (bool,bool) t |
| 125 | val allowOptBar: (bool,bool) t |
| 126 | val allowOptSemicolon: (bool,bool) t |
| 127 | val allowOrPats: (bool,bool) t |
| 128 | val allowRecordPunExps: (bool,bool) t |
| 129 | val allowSigWithtype: (bool,bool) t |
| 130 | val allowVectorExps: (bool,bool) t |
| 131 | val allowVectorPats: (bool,bool) t |
| 132 | |
| 133 | val current: ('args, 'st) t -> 'st |
| 134 | val default: ('args, 'st) t -> 'st |
| 135 | val enabled: ('args, 'st) t -> bool |
| 136 | val expert: ('args, 'st) t -> bool |
| 137 | val name: ('args, 'st) t -> string |
| 138 | |
| 139 | datatype 'a parseResult = |
| 140 | Bad | Good of 'a | Other | Proxy of 'a list * {deprecated: bool} |
| 141 | |
| 142 | structure Id : |
| 143 | sig |
| 144 | type t |
| 145 | val name: t -> string |
| 146 | end |
| 147 | val equalsId: ('args, 'st) t * Id.t -> bool |
| 148 | val parseId: string -> Id.t parseResult |
| 149 | |
| 150 | structure Args : |
| 151 | sig |
| 152 | type t |
| 153 | val processAnn: t -> (unit -> unit) |
| 154 | end |
| 155 | val parseIdAndArgs: string -> (Id.t * Args.t) parseResult |
| 156 | |
| 157 | val processDefault: string -> Id.t parseResult |
| 158 | val processEnabled: string * bool -> Id.t parseResult |
| 159 | |
| 160 | val withDef: (unit -> 'a) -> 'a |
| 161 | val snapshot: unit -> (unit -> 'a) -> 'a |
| 162 | end |
| 163 | |
| 164 | (* stop after elaboration. So, no need for the elaborator to generate |
| 165 | * valid CoreML. |
| 166 | *) |
| 167 | val elaborateOnly: bool ref |
| 168 | |
| 169 | val emitMain: bool ref |
| 170 | |
| 171 | val exportHeader: File.t option ref |
| 172 | |
| 173 | val exnHistory: bool ref |
| 174 | |
| 175 | structure Format: |
| 176 | sig |
| 177 | datatype t = |
| 178 | Archive |
| 179 | | Executable |
| 180 | | LibArchive |
| 181 | | Library |
| 182 | val all: t list |
| 183 | val toString: t -> string |
| 184 | end |
| 185 | |
| 186 | datatype format = datatype Format.t |
| 187 | |
| 188 | val format: Format.t ref |
| 189 | |
| 190 | (* *) |
| 191 | datatype gcCheck = |
| 192 | Limit |
| 193 | | First |
| 194 | | Every |
| 195 | val gcCheck: gcCheck ref |
| 196 | |
| 197 | (* Indentation used in laying out ILs. *) |
| 198 | val indentation: int ref |
| 199 | |
| 200 | val inlineIntoMain: bool ref |
| 201 | |
| 202 | val inlineLeafA: {loops: bool, repeat: bool, size: int option} ref |
| 203 | val inlineLeafB: {loops: bool, repeat: bool, size: int option} ref |
| 204 | |
| 205 | val inlineNonRec: {small: int, product: int} ref |
| 206 | |
| 207 | (* The input file on the command line, minus path and extension. *) |
| 208 | val inputFile: File.t ref |
| 209 | |
| 210 | (* Whether or not the elaborator keeps def-use information. *) |
| 211 | val keepDefUse: bool ref |
| 212 | |
| 213 | (* Keep dot files for whatever SSA files are produced. *) |
| 214 | val keepDot: bool ref |
| 215 | |
| 216 | (* List of pass names to save the input/output. *) |
| 217 | val keepPasses: Regexp.Compiled.t list ref |
| 218 | |
| 219 | (* Save the AST to a file. *) |
| 220 | val keepAST: bool ref |
| 221 | (* Save the final CoreML to a file. *) |
| 222 | val keepCoreML: bool ref |
| 223 | (* Save the final Machine to a file. *) |
| 224 | val keepMachine: bool ref |
| 225 | (* Save the final RSSA to a file. *) |
| 226 | val keepRSSA: bool ref |
| 227 | (* Save the final SSA to a file. *) |
| 228 | val keepSSA: bool ref |
| 229 | (* Save the final SSA2 to a file. *) |
| 230 | val keepSSA2: bool ref |
| 231 | (* Save the final SXML to a file. *) |
| 232 | val keepSXML: bool ref |
| 233 | (* Save the final XML to a file. *) |
| 234 | val keepXML: bool ref |
| 235 | |
| 236 | (* For the codegen -- do labels for gcc and assembler need an extra leading |
| 237 | * underscore. |
| 238 | *) |
| 239 | val labelsHaveExtra_: bool ref |
| 240 | |
| 241 | (* lib/mlton directory *) |
| 242 | val libDir: Dir.t ref |
| 243 | |
| 244 | (* lib/mlton/target directory *) |
| 245 | val libTargetDir: Dir.t ref |
| 246 | |
| 247 | (* name of the output library *) |
| 248 | val libname : string ref |
| 249 | |
| 250 | (* Number of times to loop through optimization passes. *) |
| 251 | val loopSsaPasses: int ref |
| 252 | val loopSsa2Passes: int ref |
| 253 | |
| 254 | (* Limit the code growth loop unrolling/unswitching will allow. *) |
| 255 | val loopUnrollLimit: int ref |
| 256 | val loopUnswitchLimit: int ref |
| 257 | |
| 258 | (* Should the mutator mark cards? *) |
| 259 | val markCards: bool ref |
| 260 | |
| 261 | val maxFunctionSize: int ref |
| 262 | |
| 263 | val mlbPathVars: {var: string, |
| 264 | path: string} list ref |
| 265 | val mlbPathMap: unit -> {var: string, |
| 266 | path: string} list |
| 267 | |
| 268 | structure Native: |
| 269 | sig |
| 270 | (* whether or not to use comments in native codegen *) |
| 271 | val commented: int ref |
| 272 | |
| 273 | (* whether or not to track liveness of stack slots *) |
| 274 | val liveStack: bool ref |
| 275 | |
| 276 | (* level of optimization to use in native codegen *) |
| 277 | val optimize: int ref |
| 278 | |
| 279 | (* whether or not to use move hoisting in native codegen *) |
| 280 | val moveHoist: bool ref |
| 281 | |
| 282 | (* whether or not to use copy propagation in native codegen *) |
| 283 | val copyProp: bool ref |
| 284 | |
| 285 | (* Don't use copy propagation on blocks larger than this. *) |
| 286 | val copyPropCutoff: int ref |
| 287 | |
| 288 | (* live transfer cutoff distance *) |
| 289 | val cutoff: int ref |
| 290 | |
| 291 | (* whether or not to use live transfer in native codegen *) |
| 292 | val liveTransfer: int ref |
| 293 | |
| 294 | (* whether or not to shuffle registers around C-calls *) |
| 295 | val shuffle: bool ref |
| 296 | |
| 297 | (* whether or not to use strict IEEE floating-point in native codegen *) |
| 298 | val IEEEFP: bool ref |
| 299 | |
| 300 | (* whether or not to split assembly file in native codegen *) |
| 301 | val split: int option ref |
| 302 | end |
| 303 | |
| 304 | val optFuel: int option ref |
| 305 | |
| 306 | val optFuelAvailAndUse: unit -> bool |
| 307 | |
| 308 | val optimizationPasses: |
| 309 | {il: string, set: string -> unit Result.t, get: unit -> string} list ref |
| 310 | |
| 311 | val positionIndependent : bool ref |
| 312 | |
| 313 | (* Only duplicate big functions when |
| 314 | * (size - small) * (number of occurrences - 1) <= product |
| 315 | *) |
| 316 | val polyvariance: |
| 317 | { |
| 318 | hofo: bool, |
| 319 | rounds: int, |
| 320 | small: int, |
| 321 | product: int |
| 322 | } option ref |
| 323 | |
| 324 | val preferAbsPaths: bool ref |
| 325 | |
| 326 | (* List of pass names to keep profiling info on. *) |
| 327 | val profPasses: Regexp.Compiled.t list ref |
| 328 | |
| 329 | (* Insert profiling information. *) |
| 330 | datatype profile = |
| 331 | ProfileNone |
| 332 | | ProfileAlloc |
| 333 | | ProfileCallStack |
| 334 | | ProfileCount |
| 335 | | ProfileDrop |
| 336 | | ProfileLabel |
| 337 | | ProfileTimeField |
| 338 | | ProfileTimeLabel |
| 339 | val profile: profile ref |
| 340 | |
| 341 | val profileBranch: bool ref |
| 342 | |
| 343 | val profileC: Regexp.Compiled.t list ref |
| 344 | |
| 345 | datatype profileIL = ProfileSource | ProfileSSA | ProfileSSA2 |
| 346 | val profileIL: profileIL ref |
| 347 | |
| 348 | val profileInclExcl: (Regexp.Compiled.t * bool) list ref |
| 349 | |
| 350 | val profileRaise: bool ref |
| 351 | |
| 352 | val profileStack: bool ref |
| 353 | |
| 354 | val profileVal: bool ref |
| 355 | |
| 356 | (* Show the basis library. *) |
| 357 | val showBasis: File.t option ref |
| 358 | |
| 359 | val showBasisCompact: bool ref |
| 360 | val showBasisDef: bool ref |
| 361 | val showBasisFlat: bool ref |
| 362 | |
| 363 | (* Show def-use information. *) |
| 364 | val showDefUse: File.t option ref |
| 365 | |
| 366 | (* Should types be printed in ILs. *) |
| 367 | val showTypes: bool ref |
| 368 | |
| 369 | datatype target = |
| 370 | Cross of string |
| 371 | | Self |
| 372 | val target: target ref |
| 373 | |
| 374 | structure Target: |
| 375 | sig |
| 376 | datatype arch = datatype MLton.Platform.Arch.t |
| 377 | val arch: arch ref |
| 378 | |
| 379 | val bigEndian: unit -> bool |
| 380 | val setBigEndian: bool -> unit |
| 381 | |
| 382 | datatype os = datatype MLton.Platform.OS.t |
| 383 | val os: os ref |
| 384 | |
| 385 | structure Size: |
| 386 | sig |
| 387 | val arrayMetaData: unit -> Bits.t |
| 388 | val cint: unit -> Bits.t |
| 389 | val cpointer: unit -> Bits.t |
| 390 | val cptrdiff: unit -> Bits.t |
| 391 | val csize: unit -> Bits.t |
| 392 | val header: unit -> Bits.t |
| 393 | val mplimb: unit -> Bits.t |
| 394 | val normalMetaData: unit -> Bits.t |
| 395 | val objptr: unit -> Bits.t |
| 396 | val seqIndex: unit -> Bits.t |
| 397 | end |
| 398 | val setSizes: {arrayMetaData: Bits.t, |
| 399 | cint: Bits.t, |
| 400 | cpointer: Bits.t, |
| 401 | cptrdiff: Bits.t, |
| 402 | csize: Bits.t, |
| 403 | header: Bits.t, |
| 404 | mplimb: Bits.t, |
| 405 | normalMetaData: Bits.t, |
| 406 | objptr: Bits.t, |
| 407 | seqIndex: Bits.t} -> unit |
| 408 | end |
| 409 | |
| 410 | (* Type check ILs. *) |
| 411 | val typeCheck: bool ref |
| 412 | |
| 413 | datatype verbosity = |
| 414 | Silent |
| 415 | | Top |
| 416 | | Pass |
| 417 | | Detail |
| 418 | val verbosity: verbosity ref |
| 419 | |
| 420 | val warnAnn: bool ref |
| 421 | |
| 422 | val warnDeprecated: bool ref |
| 423 | |
| 424 | val zoneCutDepth: int ref |
| 425 | |
| 426 | (*------------------------------------*) |
| 427 | (* End Flags *) |
| 428 | (*------------------------------------*) |
| 429 | end |