Commit 9fcaec4d authored by Akim Demaille's avatar Akim Demaille

style: untabify Python programs

* dev/nolimips.py, doc/inst-set.texi.gen.py, src/inst/nodes.gen.py,
* src/inst/nodes.mk.gen.py, src/inst/program_builder.hh.gen.py,
* src/inst/program_solver.gen.py, src/parse/asm-parse.yy.gen.py,
* src/parse/asm-scan.ll.gen.py:
Untabify.
parent 70269b03
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by ## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or ## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version. ## (at your option) any later version.
## ##
## Nolimips is distributed in the hope that it will be useful, ## Nolimips is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of ## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details. ## GNU General Public License for more details.
## ##
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>. ## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
## ##
...@@ -31,12 +31,12 @@ license = """// ...@@ -31,12 +31,12 @@ license = """//
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// Nolimips is distributed in the hope that it will be useful, // Nolimips is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Nolimips. If not, see <http://www.gnu.org/licenses/>. // along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
// //
...@@ -181,7 +181,7 @@ class TokenBuilder: ...@@ -181,7 +181,7 @@ class TokenBuilder:
def reset(self): def reset(self):
self.kind = "" self.kind = ""
self.name = "" self.name = ""
self.value = "" self.value = ""
self.default = "" self.default = ""
def __init__(self): def __init__(self):
self.reset() self.reset()
...@@ -281,17 +281,17 @@ class InstructionSetHandler(ContentHandler): ...@@ -281,17 +281,17 @@ class InstructionSetHandler(ContentHandler):
self.content = "" self.content = ""
def __init__(self): def __init__(self):
self.reset() self.reset()
def startElement(self, name, attrs): def startElement(self, name, attrs):
if name == "instruction": if name == "instruction":
self.inst_b.reset() self.inst_b.reset()
self.inst_b.opcode = attrs["opcode"] self.inst_b.opcode = attrs["opcode"]
self.inst_b.level = attrs["level"] self.inst_b.level = attrs["level"]
self.inst_b.kind = attrs["kind"] self.inst_b.kind = attrs["kind"]
elif name == "description": elif name == "description":
self.content = "" self.content = ""
elif name == "format": elif name == "format":
self.format_b = FormatBuilder() self.format_b = FormatBuilder()
if attrs.has_key("type"): if attrs.has_key("type"):
...@@ -339,17 +339,17 @@ class InstructionSetHandler(ContentHandler): ...@@ -339,17 +339,17 @@ class InstructionSetHandler(ContentHandler):
self.syntax_b.tokens.append(self.token_b.get()) self.syntax_b.tokens.append(self.token_b.get())
elif name == "syntax" or name == "predefinedSyntax": elif name == "syntax" or name == "predefinedSyntax":
self.inst_b.syntaxes.append(self.syntax_b.get()) self.inst_b.syntaxes.append(self.syntax_b.get())
if name == "attribute": if name == "attribute":
self.format_b.attributes.append(self.attr_b.get()) self.format_b.attributes.append(self.attr_b.get())
elif name == "predefinedAttributes": elif name == "predefinedAttributes":
self.inst_b.format = self.format_b.get() self.inst_b.format = self.format_b.get()
elif name == "format": elif name == "format":
self.inst_b.format = self.format_b.get() self.inst_b.format = self.format_b.get()
elif name == "description": elif name == "description":
self.inst_b.desc = self.content self.inst_b.desc = self.content
elif name == "instruction": elif name == "instruction":
self.instructions.append(self.inst_b.get()) self.instructions.append(self.inst_b.get())
...@@ -365,7 +365,7 @@ class InstructionSetParser: ...@@ -365,7 +365,7 @@ class InstructionSetParser:
h = InstructionSetHandler() h = InstructionSetHandler()
# Tell the parser to use our handler # Tell the parser to use our handler
parser.setContentHandler(h) parser.setContentHandler(h)
# Parse the input # Parse the input
parser.parse(file) parser.parse(file)
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by ## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or ## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version. ## (at your option) any later version.
## ##
## Nolimips is distributed in the hope that it will be useful, ## Nolimips is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of ## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details. ## GNU General Public License for more details.
## ##
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>. ## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
## ##
...@@ -55,10 +55,10 @@ for inst in instructions: ...@@ -55,10 +55,10 @@ for inst in instructions:
kind = inst.kind kind = inst.kind
print "@node " + string.capwords(kind) + " instructions" print "@node " + string.capwords(kind) + " instructions"
print "@subsection " + string.capwords(kind) + " instructions" print "@subsection " + string.capwords(kind) + " instructions"
desc = string.replace(inst.desc, "\n", " ") desc = string.replace(inst.desc, "\n", " ")
desc = string.replace(desc, " ", " ") desc = string.replace(desc, " ", " ")
print "@subsubsection " + string.upper(inst.opcode) print "@subsubsection " + string.upper(inst.opcode)
print "@findex " + string.upper(inst.opcode) print "@findex " + string.upper(inst.opcode)
print desc print desc
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by ## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or ## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version. ## (at your option) any later version.
## ##
## Nolimips is distributed in the hope that it will be useful, ## Nolimips is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of ## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details. ## GNU General Public License for more details.
## ##
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>. ## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
## ##
...@@ -44,12 +44,12 @@ def class_generate(inst): ...@@ -44,12 +44,12 @@ def class_generate(inst):
file_id = nolimips.file_id(inst.opcode) file_id = nolimips.file_id(inst.opcode)
banner = nolimips.license + "\n" + nolimips.generated_by_hand banner = nolimips.license + "\n" + nolimips.generated_by_hand
format = inst.format format = inst.format
## Open header, inline and implementation files ## Open header, inline and implementation files
header = file(file_id + ".hh.tmp", "w") header = file(file_id + ".hh.tmp", "w")
inline = file(file_id + ".hxx.tmp", "w") inline = file(file_id + ".hxx.tmp", "w")
impl = file(file_id + ".cc.tmp", "w") impl = file(file_id + ".cc.tmp", "w")
for f, ext, brief in [(header, "hh", "Declare the interface"), for f, ext, brief in [(header, "hh", "Declare the interface"),
(inline, "hxx", "Inline methods"), (inline, "hxx", "Inline methods"),
(impl, "cc", "Implementation")]: (impl, "cc", "Implementation")]:
...@@ -71,7 +71,7 @@ def class_generate(inst): ...@@ -71,7 +71,7 @@ def class_generate(inst):
sys.stdout = impl sys.stdout = impl
print "#include \"inst/visitor.hh\"" print "#include \"inst/visitor.hh\""
for f in [inline, impl]: for f in [inline, impl]:
sys.stdout = f sys.stdout = f
print "#include \"inst/" + file_id + ".hh\"" print "#include \"inst/" + file_id + ".hh\""
...@@ -91,13 +91,13 @@ namespace inst ...@@ -91,13 +91,13 @@ namespace inst
print " class " + class_id + ":" print " class " + class_id + ":"
print " public Inst" print " public Inst"
print " {" print " {"
# Constructor and destructor # Constructor and destructor
args = "" args = ""
init = "" init = ""
dels = "" dels = ""
for attribute in format.attributes: for attribute in format.attributes:
if attribute.type == "Register": if attribute.type == "Register":
args = args + "const " + attribute.type + " &" args = args + "const " + attribute.type + " &"
elif attribute.type == "Exp": elif attribute.type == "Exp":
...@@ -159,7 +159,7 @@ namespace inst ...@@ -159,7 +159,7 @@ namespace inst
print " }" print " }"
sys.stdout = header sys.stdout = header
print " /** \\} */" print " /** \\} */"
# Method: visitor entry point # Method: visitor entry point
sys.stdout = inline sys.stdout = inline
print "" print ""
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by ## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or ## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version. ## (at your option) any later version.
## ##
## Nolimips is distributed in the hope that it will be useful, ## Nolimips is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of ## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details. ## GNU General Public License for more details.
## ##
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>. ## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
## ##
...@@ -28,13 +28,13 @@ from nolimips import depth ...@@ -28,13 +28,13 @@ from nolimips import depth
parser = nolimips.InstructionSetParser() parser = nolimips.InstructionSetParser()
instructions = parser.parse(sys.stdin) instructions = parser.parse(sys.stdin)
print "FROM_NODES_GEN_PY = \\" print "FROM_NODES_GEN_PY = \\"
for i in range(0, len(instructions)): for i in range(0, len(instructions)):
if instructions[i].level == "native": if instructions[i].level == "native":
line = "\t" line = "\t"
for ext in ["hh", "hxx", "cc"]: for ext in ["hh", "hxx", "cc"]:
line = line + instructions[i].opcode + "." + ext + " " line = line + instructions[i].opcode + "." + ext + " "
print line + "\t\t\\" print line + "\t\t\\"
print """ fwd.hh \\ print """ fwd.hh \\
all.hh \\ all.hh \\
visitor.hh""" visitor.hh"""
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by ## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or ## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version. ## (at your option) any later version.
## ##
## Nolimips is distributed in the hope that it will be useful, ## Nolimips is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of ## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details. ## GNU General Public License for more details.
## ##
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>. ## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
## ##
...@@ -52,7 +52,7 @@ namespace inst ...@@ -52,7 +52,7 @@ namespace inst
{ {
using vm::Cpu; using vm::Cpu;
class ProgramBuilder class ProgramBuilder
{ {
public: public:
...@@ -62,9 +62,9 @@ namespace inst ...@@ -62,9 +62,9 @@ namespace inst
void reset(); void reset();
void set_nop_after_branch(bool nop_after_branch_p); void set_nop_after_branch(bool nop_after_branch_p);
Program *get(); Program *get();
public: public:
void define_inst_label(const misc::unique_string &id); void define_inst_label(const misc::unique_string &id);
void define_data_label(const misc::unique_string &id); void define_data_label(const misc::unique_string &id);
...@@ -95,7 +95,7 @@ for inst in instructions: ...@@ -95,7 +95,7 @@ for inst in instructions:
for syntax in inst.syntaxes: for syntax in inst.syntaxes:
if (syntax.alias != "") or (syntax.level == "pseudo"): if (syntax.alias != "") or (syntax.level == "pseudo"):
continue continue
if syntax.level == "native": if syntax.level == "native":
proto = "" proto = ""
call = "" call = ""
...@@ -112,14 +112,14 @@ for inst in instructions: ...@@ -112,14 +112,14 @@ for inst in instructions:
print " program_->text_section().add_inst (" + call + ");" print " program_->text_section().add_inst (" + call + ");"
if inst.kind == "branch": if inst.kind == "branch":
print " if (nop_after_branch_p_)" print " if (nop_after_branch_p_)"
print " program_->text_section()." print " program_->text_section()."
print " add_inst (new Sll(Register(Register::general, " + \ print " add_inst (new Sll(Register(Register::general, " + \
"Cpu::zero), " "Cpu::zero), "
print " Register(Register::general, " + \ print " Register(Register::general, " + \
"Cpu::zero), " "Cpu::zero), "
print " new IntExp(0)));" print " new IntExp(0)));"
print " }" print " }"
else: # syntax.level == "complex" else: # syntax.level == "complex"
proto = "" proto = ""
for token in syntax.tokens: for token in syntax.tokens:
...@@ -129,7 +129,7 @@ for inst in instructions: ...@@ -129,7 +129,7 @@ for inst in instructions:
proto = proto + ", " proto = proto + ", "
proto = string.rstrip(proto, ", ") proto = string.rstrip(proto, ", ")
print " void\tadd_" + inst.opcode + "(" + proto + ");" print " void\tadd_" + inst.opcode + "(" + proto + ");"
print """ print """
protected: protected:
Program *program_; Program *program_;
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by ## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or ## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version. ## (at your option) any later version.
## ##
## Nolimips is distributed in the hope that it will be useful, ## Nolimips is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of ## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details. ## GNU General Public License for more details.
## ##
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>. ## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
## ##
...@@ -52,7 +52,7 @@ namespace inst ...@@ -52,7 +52,7 @@ namespace inst
{ {
class ProgramSolver: class ProgramSolver:
protected Visitor, protected Visitor,
protected ExpVisitor protected ExpVisitor
{ {
public: public:
...@@ -84,9 +84,9 @@ namespace inst ...@@ -84,9 +84,9 @@ namespace inst
print " protected:" print " protected:"
for inst in instructions: for inst in instructions:
if inst.level == "native": if inst.level == "native":
print " virtual void visit(" +\ print " virtual void visit(" +\
nolimips.class_id(inst.opcode) + " &);" nolimips.class_id(inst.opcode) + " &);"
print """ print """
protected: protected:
Program *program_; Program *program_;
...@@ -144,14 +144,14 @@ namespace inst ...@@ -144,14 +144,14 @@ namespace inst
{ {
if (! program_->data_section().has_label(l.get_name())) if (! program_->data_section().has_label(l.get_name()))
if (! program_->text_section().has_label(l.get_name())) if (! program_->text_section().has_label(l.get_name()))
{ {
std::cerr << \"Undefined label: \" << l.get_name() std::cerr << \"Undefined label: \" << l.get_name()
<< std::endl; << std::endl;
exit_set(exit_solve); exit_set(exit_solve);
} }
else else
l.set_immediate(program_->text_section(). l.set_immediate(program_->text_section().
get_offset(l.get_name()) - pc_); get_offset(l.get_name()) - pc_);
else else
l.set_immediate(program_->data_section().get_offset(l.get_name())); l.set_immediate(program_->data_section().get_offset(l.get_name()));
} }
...@@ -164,21 +164,21 @@ namespace inst ...@@ -164,21 +164,21 @@ namespace inst
switch (o.kind_) switch (o.kind_)
{ {
case OpExp::add: case OpExp::add:
o.set_immediate(o.get_left().get_immediate() + o.set_immediate(o.get_left().get_immediate() +
o.get_right().get_immediate()); o.get_right().get_immediate());
break; break;
case OpExp::sub: case OpExp::sub:
o.set_immediate(o.get_left().get_immediate() - o.set_immediate(o.get_left().get_immediate() -
o.get_right().get_immediate()); o.get_right().get_immediate());
break; break;
case OpExp::mul: case OpExp::mul:
o.set_immediate(o.get_left().get_immediate() * o.set_immediate(o.get_left().get_immediate() *
o.get_right().get_immediate()); o.get_right().get_immediate());
break; break;
case OpExp::div: case OpExp::div:
o.set_immediate(o.get_left().get_immediate() / o.set_immediate(o.get_left().get_immediate() /
o.get_right().get_immediate()); o.get_right().get_immediate());
break; break;
} }
} }
...@@ -188,46 +188,46 @@ namespace inst ...@@ -188,46 +188,46 @@ namespace inst
switch (reg.get_kind()) switch (reg.get_kind())
{ {
case Register::generic: case Register::generic:
reg.set_kind(Register::general); reg.set_kind(Register::general);
case Register::general: case Register::general:
if ((reg.get_index() == vm::Cpu::t9 && max_caller_save_ < 10) if ((reg.get_index() == vm::Cpu::t9 && max_caller_save_ < 10)
|| (reg.get_index() == vm::Cpu::t8 && max_caller_save_ < 9) || (reg.get_index() == vm::Cpu::t8 && max_caller_save_ < 9)
|| (vm::Cpu::t0 + max_caller_save_ - 1 < reg.get_index() || (vm::Cpu::t0 + max_caller_save_ - 1 < reg.get_index()
&& reg.get_index() <= vm::Cpu::t7)) && reg.get_index() <= vm::Cpu::t7))
{ {
std::cerr << \"Caller-save register limited.\" << std::endl; std::cerr << \"Caller-save register limited.\" << std::endl;
exit_set(exit_solve); exit_set(exit_solve);
} }
else if (vm::Cpu::s0 + max_callee_save_ - 1 < reg.get_index() && else if (vm::Cpu::s0 + max_callee_save_ - 1 < reg.get_index() &&
reg.get_index() <= vm::Cpu::s7) reg.get_index() <= vm::Cpu::s7)
{ {
std::cerr << \"Callee-save register limited.\" << std::endl; std::cerr << \"Callee-save register limited.\" << std::endl;
exit_set(exit_solve); exit_set(exit_solve);
} }
else if (vm::Cpu::a0 + max_args_ - 1 < reg.get_index() && else if (vm::Cpu::a0 + max_args_ - 1 < reg.get_index() &&
reg.get_index() <= vm::Cpu::a3) reg.get_index() <= vm::Cpu::a3)
{ {
std::cerr << \"Argument register limited.\" << std::endl; std::cerr << \"Argument register limited.\" << std::endl;
exit_set(exit_solve); exit_set(exit_solve);
} }
break; break;
case Register::unlimited: case Register::unlimited:
if (!unlimited_regs_enabled_) if (!unlimited_regs_enabled_)
{ {
std::cerr << \"Unlimited registers prohibited.\" << std::endl; std::cerr << \"Unlimited registers prohibited.\" << std::endl;
exit_set(exit_solve); exit_set(exit_solve);
} }
break; break;
}; };
} }
void void
ProgramSolver::solve_cop_register(Register &reg) const ProgramSolver::solve_cop_register(Register &reg) const
{ {
if (reg.get_kind() != Register::generic) if (reg.get_kind() != Register::generic)
{ {
std::cerr << \"Coprocessor registers must be generic.\" << std::endl; std::cerr << \"Coprocessor registers must be generic.\" << std::endl;
exit_set(exit_solve); exit_set(exit_solve);
} }
} }
...@@ -236,7 +236,7 @@ namespace inst ...@@ -236,7 +236,7 @@ namespace inst
for inst in instructions: