Pass control command line options.

It turns out that --enable-collapse is fundamentally misguided. We'll
need a better solution for that. --no-branch-extension looks pretty good.
This commit is contained in:
Michael Martin 2012-06-06 04:33:21 -07:00
parent 7e503df96f
commit 4891849e4a
2 changed files with 12 additions and 8 deletions

View File

@ -6,7 +6,6 @@ import optparse
# You may use, modify, and distribute this file under the MIT # You may use, modify, and distribute this file under the MIT
# license: See README for details. # license: See README for details.
enable_collapse = True
enable_branch_extend = True enable_branch_extend = True
enable_undoc_ops = False enable_undoc_ops = False
enable_65c02_exts = False enable_65c02_exts = False
@ -56,9 +55,6 @@ def parse_args(raw_args):
default=True, help="Do not print warnings") default=True, help="Do not print warnings")
bingrp = optparse.OptionGroup(parser, "Compilation options") bingrp = optparse.OptionGroup(parser, "Compilation options")
bingrp.add_option("--no-collapse", action="store_false",
dest="enable_collapse", default="True",
help="Disable zero-page collapse pass")
bingrp.add_option("--no-branch-extend", action="store_false", bingrp.add_option("--no-branch-extend", action="store_false",
dest="enable_branch_extend", default="True", dest="enable_branch_extend", default="True",
help="Disable branch-extension pass") help="Disable branch-extension pass")
@ -76,7 +72,6 @@ def parse_args(raw_args):
infiles = args infiles = args
outfile = options.outfile outfile = options.outfile
enable_collapse = options.enable_collapse
enable_branch_extend = options.enable_branch_extend enable_branch_extend = options.enable_branch_extend
enable_undoc_ops = options.undoc enable_undoc_ops = options.undoc
enable_65c02_exts = options.c02 enable_65c02_exts = options.c02

View File

@ -29,10 +29,20 @@ def run_all():
l_basic = Ophis.Passes.UpdateLabels() l_basic = Ophis.Passes.UpdateLabels()
l = Ophis.Passes.FixPoint("label update", [l_basic], l = Ophis.Passes.FixPoint("label update", [l_basic],
lambda: not l_basic.changed) lambda: not l_basic.changed)
# The instruction selector is a bunch of fixpoints, and which
# passes run depends on the command line options a bit.
c_basic = Ophis.Passes.Collapse() c_basic = Ophis.Passes.Collapse()
c = Ophis.Passes.FixPoint("instruction selection 1", [l, c_basic], c = Ophis.Passes.FixPoint("instruction selection 1", [l, c_basic],
lambda: not c_basic.changed) lambda: not c_basic.changed)
b = Ophis.Passes.ExtendBranches()
if Ophis.CmdLine.enable_branch_extend:
b = Ophis.Passes.ExtendBranches()
instruction_select = Ophis.Passes.FixPoint("instruction selection 2",
[c, b],
lambda: not b.changed)
else:
instruction_select = c
a = Ophis.Passes.Assembler() a = Ophis.Passes.Assembler()
passes = [] passes = []
@ -44,8 +54,7 @@ def run_all():
passes.extend([Ophis.Passes.CircularityCheck(), passes.extend([Ophis.Passes.CircularityCheck(),
Ophis.Passes.CheckExprs(), Ophis.Passes.CheckExprs(),
Ophis.Passes.EasyModes()]) Ophis.Passes.EasyModes()])
passes.append(Ophis.Passes.FixPoint("instruction selection 2", [c, b], passes.append(instruction_select)
lambda: not b.changed))
passes.extend([Ophis.Passes.NormalizeModes(), passes.extend([Ophis.Passes.NormalizeModes(),
Ophis.Passes.UpdateLabels(), Ophis.Passes.UpdateLabels(),
a]) a])