compiler: move settings to a separate Config struct

Moving settings to a separate config struct has two benefits:
  - It decouples the compiler a bit from other packages, most
    importantly the compileopts package. Decoupling is generally a good
    thing.
  - Perhaps more importantly, it precisely specifies which settings are
    used while compiling and affect the resulting LLVM module. This will
    be necessary for caching the LLVM module.
    While it would have been possible to cache without this refactor, it
    would have been very easy to miss a setting and thus let the
    compiler work with invalid/stale data.
This commit is contained in:
Ayke van Laethem
2021-01-25 11:06:54 +01:00
committed by Ron Evans
parent 868933e67c
commit 9612af466b
14 changed files with 136 additions and 98 deletions
+2 -2
View File
@@ -85,7 +85,7 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i
return errs
}
if config.FuncImplementation() == compileopts.FuncValueSwitch {
if config.FuncImplementation() == "switch" {
LowerFuncValues(mod)
}
@@ -104,7 +104,7 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i
if err != nil {
return []error{err}
}
if config.FuncImplementation() == compileopts.FuncValueSwitch {
if config.FuncImplementation() == "switch" {
LowerFuncValues(mod)
}
errs := LowerInterrupts(mod)