https://svn.lrde.epita.fr/svn/nolimips/trunk
ChangeLog | 5 +
dev/nolimips.py | 36 +++++++++++-
dev/nolimips.xml | 156 +++++++++----------------------------------------------
3 files changed, 63 insertions(+), 134 deletions(-)
Index: ChangeLog
from Benoît Perrot <benoit(a)lrde.epita.fr>
* dev/nolimips.py, dev/nolimips.xml: Introduce predefined
attributes to reduce data redundancy.
2005-08-07 Benoît Perrot <benoit(a)lrde.epita.fr>
Index: dev/nolimips.py
--- dev/nolimips.py (revision 186)
+++ dev/nolimips.py (revision 187)
@@ -134,6 +134,25 @@
self.attributes = []
def __init__(self):
self.reset()
+ def set_to_predefined(self, template):
+ self.type = template
+ if template == "register":
+ self.attributes = [
+ Attribute("Register", "", "dest", ""),
+ Attribute("Register", "", "src1", ""),
+ Attribute("Register", "", "src2", "")]
+ elif template == "immediate":
+ self.attributes = [
+ Attribute("Register", "", "dest", ""),
+ Attribute("Register", "", "src", ""),
+ Attribute("Exp", "", "imm", "")]
+ elif template == "jump":
+ self.attributes = [
+ Attribute("Register", "", "src1", ""),
+ Attribute("Register", "", "src2", ""),
+ Attribute("Exp", "", "label", "")]
+ else:
+ assert(False)
def get(self):
return Format(self.type, self.attributes)
@@ -204,6 +223,8 @@
Token("register", "", "", ""),
Token("register", "", "", ""),
Token("label", "", "", "")]
+ else:
+ assert(False)
def get(self):
return Syntax(self.tokens, self.alias, self.level)
@@ -263,22 +284,24 @@
self.inst_b.opcode = attrs["opcode"]
self.inst_b.level = attrs["level"]
self.inst_b.kind = attrs["kind"]
+
elif name == "description":
self.content = ""
+
elif name == "format":
self.format_b = FormatBuilder()
if attrs.has_key("type"):
self.format_b.type = attrs["type"]
+ elif name == "predefinedAttributes":
+ self.format_b = FormatBuilder()
+ self.format_b.set_to_predefined(attrs["template"])
elif name == "attribute":
self.attr_b.reset()
self.attr_b.type = attrs["type"]
if attrs.has_key("restriction"):
self.attr_b.restriction = attrs["restriction"]
self.attr_b.name = attrs["name"]
-# if attrs.has_key("default"):
-# self.attr_b.default = attrs["default"]
-# if attrs.has_key("value"):
-# self.attr_b.value = attrs["value"]
+
elif name == "syntax":
self.syntax_b.reset()
if attrs.has_key("alias"):
@@ -312,12 +335,17 @@
self.syntax_b.tokens.append(self.token_b.get())
elif name == "syntax" or name == "predefinedSyntax":
self.inst_b.syntaxes.append(self.syntax_b.get())
+
if name == "attribute":
self.format_b.attributes.append(self.attr_b.get())
+ elif name == "predefinedAttributes":
+ self.inst_b.format = self.format_b.get()
elif name == "format":
self.inst_b.format = self.format_b.get()
+
elif name == "description":
self.inst_b.desc = self.content
+
elif name == "instruction":
self.instructions.append(self.inst_b.get())
Index: dev/nolimips.xml
--- dev/nolimips.xml (revision 186)
+++ dev/nolimips.xml (revision 187)
@@ -21,22 +21,14 @@
<instruction opcode="add" level="native"
kind="arithmetic">
<description>Add src1 and src2 and store the result in dest
(32-bit integers). If an overflow occurs, then trap.</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="addi"/>
</instruction>
<instruction opcode="addu" level="native"
kind="arithmetic">
<description>Add src1 and src2 and store the result in dest
(32-bit integers).</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="addiu"/>
</instruction>
@@ -44,32 +36,20 @@
<instruction opcode="addi" level="native"
kind="arithmetic">
<description>Add a constant imm and src and store the result in dest
(32-bit integers). If overflow occurs, then trap.</description>
- <format type="immediate">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src" />
- <attribute type="Exp" name="imm" />
- </format>
+ <predefinedAttributes template="immediate" />
<predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="addiu" level="native"
kind="arithmetic">
<description>Add a constant imm and src and store the result in dest
(32-bit integer).</description>
- <format type="immediate">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src" />
- <attribute type="Exp" name="imm" />
- </format>
+ <predefinedAttributes template="immediate" />
<predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="sub" level="native"
kind="arithmetic">
<description>Subtract src2 from src1 and store the result in dest
(32-bit integers). If an overflow occurs (FIXME), then trap.</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
<syntax alias="addi">
<token kind="register" />
@@ -80,11 +60,7 @@
<instruction opcode="subu" level="native"
kind="arithmetic">
<description>Subtract src2 from src1 and store the result in dest
(32-bit integers).</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
<syntax alias="addiu">
<token kind="register" />
@@ -124,11 +100,7 @@
<instruction opcode="mul" level="native"
kind="arithmetic">
<description>Multiply two words src1 and src2 and write the result
to dest.</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
<syntax level="complex">
<token kind="register" />
@@ -198,66 +170,42 @@
<instruction opcode="sll" level="native"
kind="bitwise">
<description>Left-shift (logical) the word src by the fixed number imm of
bits and store the result in dest.</description>
- <format type="immediate">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src" />
- <attribute type="Exp" name="imm" />
- </format>
+ <predefinedAttributes template="immediate" />
<predefinedSyntax template="immediate" />
<predefinedSyntax template="register" alias="sllv" />
</instruction>
<instruction opcode="sllv" level="native"
kind="bitwise">
<description>Left-shift (logical) the word src1 by the variable number
src2 of bits and store the result in dest.</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
</instruction>
<instruction opcode="sra" level="native"
kind="bitwise">
<description>Right-shift (arithmetic) the word src by the fixed number
imm of bits and store the result in dest.</description>
- <format type="immediate">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src" />
- <attribute type="Exp" name="imm" />
- </format>
+ <predefinedAttributes template="immediate" />
<predefinedSyntax template="immediate" />
<predefinedSyntax template="register" alias="srav" />
</instruction>
<instruction opcode="srav" level="native"
kind="bitwise">
<description>Right-shift (arithmetic) the word src1 by the variable number
src2 of bits and store the result in dest.</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
</instruction>
<instruction opcode="srl" level="native"
kind="bitwise">
<description>Right-shift (logical) the word src1 by the variable number
src2 of bits and store the result in dest.</description>
- <format type="immediate">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src" />
- <attribute type="Exp" name="imm" />
- </format>
+ <predefinedAttributes template="immediate" />
<predefinedSyntax template="immediate" />
<predefinedSyntax template="register" alias="srlv"/>
</instruction>
<instruction opcode="srlv" level="native"
kind="bitwise">
<description>Right-shift (logical) the word src1 by the variable number
src2 of bits and store the result in dest.</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
</instruction>
@@ -279,22 +227,14 @@
<instruction opcode="and" level="native"
kind="bitwise">
<description>Compute the bitwise logical AND between src1 and src2
and store the result to dest.</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="andi" />
</instruction>
<instruction opcode="andi" level="native"
kind="bitwise">
<description>Compute the bitwise logical AND between src and a constant imm
and store the result to dest.</description>
- <format type="immediate">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src" />
- <attribute type="Exp" name="imm" />
- </format>
+ <predefinedAttributes template="immediate" />
<predefinedSyntax template="immediate" />
</instruction>
@@ -302,22 +242,14 @@
<instruction opcode="or" level="native"
kind="bitwise">
<description>Compute the bitwise logical OR between src1 and src2
and store the result to dest.</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="ori" />
</instruction>
<instruction opcode="ori" level="native"
kind="bitwise">
<description>Compute the bitwise logical OR between src and a constant imm
and store the result to dest.</description>
- <format type="immediate">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src" />
- <attribute type="Exp" name="imm" />
- </format>
+ <predefinedAttributes template="immediate" />
<predefinedSyntax template="immediate" />
</instruction>
@@ -325,22 +257,14 @@
<instruction opcode="xor" level="native"
kind="bitwise">
<description>Compute the bitwise logical XOR between src1 and src2
and store the result to dest.</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="xori"/>
</instruction>
<instruction opcode="xori" level="native"
kind="bitwise">
<description>Compute the bitwise logical XOR between src and a constant imm
and store the result to dest.</description>
- <format type="immediate">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src" />
- <attribute type="Exp" name="imm" />
- </format>
+ <predefinedAttributes template="immediate" />
<predefinedSyntax template="immediate" />
</instruction>
@@ -348,11 +272,7 @@
<instruction opcode="nor" level="native"
kind="bitwise">
<description>Compute the bitwise logical NOR between src1 and src2
and store the result to dest.</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
<syntax level="complex">
<token kind="register" name="dest" />
@@ -437,22 +357,14 @@
<instruction opcode="slt" level="native"
kind="comparison">
<description>Set dest to 1 if src1 is lower than src2
(signed comparison), else clear it.</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="slti" />
</instruction>
<instruction opcode="sltu" level="native"
kind="comparison">
<description>Set dest to 1 if src1 is lower than src2
(unsigned comparison), else clear it.</description>
- <format type="register">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src1" />
- <attribute type="Register" name="src2" />
- </format>
+ <predefinedAttributes template="register" />
<predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="sltiu" />
</instruction>
@@ -460,21 +372,13 @@
<instruction opcode="slti" level="native"
kind="comparison">
<description>Set dest to 1 if src1 is lower than a constant imm
(signed comparison), else clear it.</description>
- <format type="immediate">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src" />
- <attribute type="Exp" name="imm" />
- </format>
+ <predefinedAttributes template="immediate" />
<predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="sltiu" level="native"
kind="comparison">
<description>Set dest to 1 if src1 is lower than a constant imm
(unsigned comparison), else clear it.</description>
- <format type="immediate">
- <attribute type="Register" name="dest" />
- <attribute type="Register" name="src" />
- <attribute type="Exp" name="imm" />
- </format>
+ <predefinedAttributes template="immediate" />
<predefinedSyntax template="immediate" />
</instruction>
@@ -482,11 +386,7 @@
<!-- Branch instructions -->
<instruction opcode="beq" level="native"
kind="branch">
<description>Branch to label if src1 equals src2.</description>
- <format type="jump">
- <attribute type="Register" name="src1"/>
- <attribute type="Register" name="src2"/>
- <attribute type="Exp" name="label"/>
- </format>
+ <predefinedAttributes template="jump" />
<predefinedSyntax template="jump" />
<syntax level="complex">
<token kind="register" />
@@ -505,11 +405,7 @@
<instruction opcode="bne" level="native"
kind="branch">
<description>Branch to label if src1 does not equal src2.</description>
- <format type="jump">
- <attribute type="Register" name="src1"/>
- <attribute type="Register" name="src2"/>
- <attribute type="Exp" name="label"/>
- </format>
+ <predefinedAttributes template="jump" />
<predefinedSyntax template="jump" />
<syntax level="complex">
<token kind="register" />