Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions aeneas/src/ir/SsaNormalizer.v3
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ class SsaRaNormalizer extends SsaRebuilder {
context.method = newMethod;
context.graph = newMethod.ssa;
context.printSsa("Normalized");
if (context.compiler.NormOptimize &&
context.compiler.optEnabled("(ra)", newMethod, null, null)) {
if (context.compiler.NormOptimize) {
var opt = SsaOptimizer.new(context);
opt.optimize_loads = context.compiler.LoadOptimize &&
context.compiler.optEnabled("(ra loads)", newMethod, null, null);
opt.optimize_loads = context.compiler.LoadOptimize;
opt.optGraph();
context.printSsa("Norm Optimized");
}
Expand Down
3 changes: 1 addition & 2 deletions aeneas/src/mach/MachProgram.v3
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class MachProgram extends TargetProgram {
var methods = prog.ir.methods;
for (i < methods.length) {
lowering.doMethod(methods[i]);
if (compiler.MachOptimize &&
compiler.optEnabled("(mach)", methods[i], null, null)) {
if (compiler.MachOptimize) {
opt.reset(lowering.context.graph);
opt.optGraph();
lowering.context.printSsa("Mach Optimized");
Expand Down
8 changes: 0 additions & 8 deletions aeneas/src/main/CLOptions.v3
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ component CLOptions {
"Limit the maximum number of scalars allowed for auto-unboxing variant types.");
def INLINE = sharedOpt.newMatcherOption("inline",
"Force inlining of direct calls to the given method(s).");
def FIRST_ENABLED = sharedOpt.newIntOption("first-enabled", -1,
"First optimization decision enabled (count from 1)");
def LAST_ENABLED = sharedOpt.newIntOption("last-enabled", Int.MAX_VALUE,
"Last optimization decision enabled (count from 1)");
def FIRST_DISABLED = sharedOpt.newIntOption("first-disabled", Int.MAX_VALUE,
"First optimization decision disabled (count from 1)");
def LAST_DISABLED = sharedOpt.newIntOption("last-disabled", -1,
"Last optimization decision disabled (count from 1)");
def LICM = sharedOpt.newBoolOption("licm", false,
"Optimize with loop invariant code motion.");
def USE_GLOBALREGALLOC = sharedOpt.newMatcherOption("global-regalloc",
Expand Down
66 changes: 2 additions & 64 deletions aeneas/src/main/Compiler.v3
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ class Compiler(target: Target) {
var MachBuildOpt = flags.get("MachBuildOpt", false);
var LoopInvariantCodeMotion = flags.get("LoopInvariantCodeMotion", CLOptions.LICM.val);
var IrAlloc = CLOptions.IR_ALLOC.get();
var firstEnabled = CLOptions.FIRST_ENABLED.get();
var lastEnabled = CLOptions.LAST_ENABLED.get();
var firstDisabled = CLOptions.FIRST_DISABLED.get();
var lastDisabled = CLOptions.LAST_DISABLED.get();
var optCount = 0; // count of optimization decision points
private var doOptEnabledCheck = false;
// XXX: flags for folding, reduction, typechecks, dead code, phi simplification
// XXX: implement CSE and code motion
// unsafe optimization settings; for performance testing only
Expand Down Expand Up @@ -141,33 +135,6 @@ class Compiler(target: Target) {

// target configures the compiler only once
if (target != null) target.configureCompiler(this);
doOptEnabledCheck = !(firstEnabled == CLOptions.FIRST_ENABLED.init &&
lastEnabled == CLOptions.LAST_ENABLED.init &&
firstDisabled == CLOptions.FIRST_DISABLED.init &&
lastDisabled == CLOptions.LAST_DISABLED.init);
}

def optEnabledAt(count: int) -> bool {
if (count < firstEnabled || count > lastEnabled) return false;
if (count < firstDisabled || count > lastDisabled) return true;
return false;
}
def optEnabled(s: string, meth: IrMethod, block: SsaBlock, inst: SsaInstr) -> bool {
if (!doOptEnabledCheck) return true;
// want to identify enabled / disabled and transitions
var prev = optCount++;
var prevEnabled = optEnabledAt(prev);
var nowEnabled = optEnabledAt(optCount);
if (nowEnabled && !prevEnabled) {
var sb = Terminal.buf.yellow().put1("First enabled after disabled optimization #%d: ", optCount).end();
showPoint(sb, s, meth, block, inst);
sb.outln();
} else if (prevEnabled && !nowEnabled) {
var sb = Terminal.buf.yellow().put1("First disabled after enabled optimization #%d: ", optCount).end();
showPoint(sb, s, meth, block, inst);
sb.outln();
}
return nowEnabled;
}
def setLinkingModel(default: LinkingModel, supported: LinkingModel.set) {
if (linking == LinkingModel.NONE) return;
Expand All @@ -177,32 +144,6 @@ class Compiler(target: Target) {
optError.addError(null, null, "target does not support linking model", linking.opt);
}
}
def showPoint(sb: StringBuilder, s: string, meth: IrMethod, block: SsaBlock, inst: SsaInstr) {
var sep = "";
if (s != null && s.length > 0) {
sb.put1("%s", s);
sep = " ";
}
if (meth != null) {
sb.put3("%sMethod %q.%q", sep, meth.receiver.render, meth.render);
sep = " ";
}
if (block != null) {
sb.put2("%sBlock #%d", sep, block.uid);
sep = " ";
}
if (inst != null) {
sb.put2("%sSsaInst #%d", sep, inst.uid);
}
}

def showOptCount() -> bool {
if (doOptEnabledCheck) {
Terminal.buf.yellow().put1("Number of optimization decision points: %d", optCount).end().outln();
}
return true;
}

def getOutputFileName(fileName: string, ext: string) -> string {
return Paths.assemble(CLOptions.OUTPUT.get(), fileName, ext);
}
Expand Down Expand Up @@ -258,7 +199,6 @@ class Compilation(compiler: Compiler, prog: Program) {
&& (!compiler.VstInit || init())
&& (!compiler.Reachability || reachability())
&& (!compiler.Emit || emit())
&& compiler.showOptCount()
&& prog.ERROR.noErrors;
}
def parse() -> bool {
Expand Down Expand Up @@ -421,12 +361,10 @@ class Compilation(compiler: Compiler, prog: Program) {
SsaOptimizer.new(context).optControlFlow();
context.printSsa("Control Optimized");
}
if (compiler.PostpassOptimize &&
compiler.optEnabled("(gen)", meth, null, null)) {
if (compiler.PostpassOptimize) {
// Run the post-pass optimizer.
var opt = SsaOptimizer.new(context);
opt.optimize_loads = compiler.LoadOptimize &&
compiler.optEnabled("(gen loads)", meth, null, null);
opt.optimize_loads = compiler.LoadOptimize;
opt.optGraph();
context.printSsa("Postpass Optimized");
}
Expand Down
2 changes: 1 addition & 1 deletion aeneas/src/main/Version.v3
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
// Updated by VCS scripts. DO NOT EDIT.
component Version {
def UNSTABLE = true;
def version: string = "III-13.2006";
def version: string = "III-13.2007";
var buildData: string;
}
Loading