Commit ca9c1a47 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

2005-08-07 Benoît Perrot <benoit@lrde.epita.fr>

	* dev/nolimips.py, dev/nolimips.xml: Introduce predefined
	attributes to reduce data redundancy.
parent 6c99efdc
2005-08-07 Benot Perrot <benoit@lrde.epita.fr>
* dev/nolimips.py, dev/nolimips.xml: Introduce predefined
attributes to reduce data redundancy.
2005-08-07 Benot Perrot <benoit@lrde.epita.fr> 2005-08-07 Benot Perrot <benoit@lrde.epita.fr>
* dev/nolimips.py, dev/nolimips.xml: Introduce predefined syntaxes * dev/nolimips.py, dev/nolimips.xml: Introduce predefined syntaxes
......
...@@ -134,6 +134,25 @@ class FormatBuilder: ...@@ -134,6 +134,25 @@ class FormatBuilder:
self.attributes = [] self.attributes = []
def __init__(self): def __init__(self):
self.reset() 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): def get(self):
return Format(self.type, self.attributes) return Format(self.type, self.attributes)
...@@ -204,6 +223,8 @@ class SyntaxBuilder: ...@@ -204,6 +223,8 @@ class SyntaxBuilder:
Token("register", "", "", ""), Token("register", "", "", ""),
Token("register", "", "", ""), Token("register", "", "", ""),
Token("label", "", "", "")] Token("label", "", "", "")]
else:
assert(False)
def get(self): def get(self):
return Syntax(self.tokens, self.alias, self.level) return Syntax(self.tokens, self.alias, self.level)
...@@ -263,22 +284,24 @@ class InstructionSetHandler(ContentHandler): ...@@ -263,22 +284,24 @@ class InstructionSetHandler(ContentHandler):
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"):
self.format_b.type = attrs["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": elif name == "attribute":
self.attr_b.reset() self.attr_b.reset()
self.attr_b.type = attrs["type"] self.attr_b.type = attrs["type"]
if attrs.has_key("restriction"): if attrs.has_key("restriction"):
self.attr_b.restriction = attrs["restriction"] self.attr_b.restriction = attrs["restriction"]
self.attr_b.name = attrs["name"] 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": elif name == "syntax":
self.syntax_b.reset() self.syntax_b.reset()
if attrs.has_key("alias"): if attrs.has_key("alias"):
...@@ -312,12 +335,17 @@ class InstructionSetHandler(ContentHandler): ...@@ -312,12 +335,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":
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())
......
...@@ -21,22 +21,14 @@ ...@@ -21,22 +21,14 @@
<instruction opcode="add" level="native" kind="arithmetic"> <instruction opcode="add" level="native" kind="arithmetic">
<description>Add src1 and src2 and store the result in dest <description>Add src1 and src2 and store the result in dest
(32-bit integers). If an overflow occurs, then trap.</description> (32-bit integers). If an overflow occurs, then trap.</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="addi"/> <predefinedSyntax template="immediate" alias="addi"/>
</instruction> </instruction>
<instruction opcode="addu" level="native" kind="arithmetic"> <instruction opcode="addu" level="native" kind="arithmetic">
<description>Add src1 and src2 and store the result in dest <description>Add src1 and src2 and store the result in dest
(32-bit integers).</description> (32-bit integers).</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="addiu"/> <predefinedSyntax template="immediate" alias="addiu"/>
</instruction> </instruction>
...@@ -44,32 +36,20 @@ ...@@ -44,32 +36,20 @@
<instruction opcode="addi" level="native" kind="arithmetic"> <instruction opcode="addi" level="native" kind="arithmetic">
<description>Add a constant imm and src and store the result in dest <description>Add a constant imm and src and store the result in dest
(32-bit integers). If overflow occurs, then trap.</description> (32-bit integers). If overflow occurs, then trap.</description>
<format type="immediate"> <predefinedAttributes template="immediate" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
<predefinedSyntax template="immediate" /> <predefinedSyntax template="immediate" />
</instruction> </instruction>
<instruction opcode="addiu" level="native" kind="arithmetic"> <instruction opcode="addiu" level="native" kind="arithmetic">
<description>Add a constant imm and src and store the result in dest <description>Add a constant imm and src and store the result in dest
(32-bit integer).</description> (32-bit integer).</description>
<format type="immediate"> <predefinedAttributes template="immediate" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
<predefinedSyntax template="immediate" /> <predefinedSyntax template="immediate" />
</instruction> </instruction>
<instruction opcode="sub" level="native" kind="arithmetic"> <instruction opcode="sub" level="native" kind="arithmetic">
<description>Subtract src2 from src1 and store the result in dest <description>Subtract src2 from src1 and store the result in dest
(32-bit integers). If an overflow occurs (FIXME), then trap.</description> (32-bit integers). If an overflow occurs (FIXME), then trap.</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
<syntax alias="addi"> <syntax alias="addi">
<token kind="register" /> <token kind="register" />
...@@ -80,11 +60,7 @@ ...@@ -80,11 +60,7 @@
<instruction opcode="subu" level="native" kind="arithmetic"> <instruction opcode="subu" level="native" kind="arithmetic">
<description>Subtract src2 from src1 and store the result in dest <description>Subtract src2 from src1 and store the result in dest
(32-bit integers).</description> (32-bit integers).</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
<syntax alias="addiu"> <syntax alias="addiu">
<token kind="register" /> <token kind="register" />
...@@ -124,11 +100,7 @@ write it to dest.</description> ...@@ -124,11 +100,7 @@ write it to dest.</description>
<instruction opcode="mul" level="native" kind="arithmetic"> <instruction opcode="mul" level="native" kind="arithmetic">
<description>Multiply two words src1 and src2 and write the result <description>Multiply two words src1 and src2 and write the result
to dest.</description> to dest.</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
<syntax level="complex"> <syntax level="complex">
<token kind="register" /> <token kind="register" />
...@@ -198,66 +170,42 @@ the quotient in LO and the remainder in HI (32-bit integer).</description> ...@@ -198,66 +170,42 @@ the quotient in LO and the remainder in HI (32-bit integer).</description>
<instruction opcode="sll" level="native" kind="bitwise"> <instruction opcode="sll" level="native" kind="bitwise">
<description>Left-shift (logical) the word src by the fixed number imm of <description>Left-shift (logical) the word src by the fixed number imm of
bits and store the result in dest.</description> bits and store the result in dest.</description>
<format type="immediate"> <predefinedAttributes template="immediate" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
<predefinedSyntax template="immediate" /> <predefinedSyntax template="immediate" />
<predefinedSyntax template="register" alias="sllv" /> <predefinedSyntax template="register" alias="sllv" />
</instruction> </instruction>
<instruction opcode="sllv" level="native" kind="bitwise"> <instruction opcode="sllv" level="native" kind="bitwise">
<description>Left-shift (logical) the word src1 by the variable number <description>Left-shift (logical) the word src1 by the variable number
src2 of bits and store the result in dest.</description> src2 of bits and store the result in dest.</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
</instruction> </instruction>
<instruction opcode="sra" level="native" kind="bitwise"> <instruction opcode="sra" level="native" kind="bitwise">
<description>Right-shift (arithmetic) the word src by the fixed number <description>Right-shift (arithmetic) the word src by the fixed number
imm of bits and store the result in dest.</description> imm of bits and store the result in dest.</description>
<format type="immediate"> <predefinedAttributes template="immediate" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
<predefinedSyntax template="immediate" /> <predefinedSyntax template="immediate" />
<predefinedSyntax template="register" alias="srav" /> <predefinedSyntax template="register" alias="srav" />
</instruction> </instruction>
<instruction opcode="srav" level="native" kind="bitwise"> <instruction opcode="srav" level="native" kind="bitwise">
<description>Right-shift (arithmetic) the word src1 by the variable number <description>Right-shift (arithmetic) the word src1 by the variable number
src2 of bits and store the result in dest.</description> src2 of bits and store the result in dest.</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
</instruction> </instruction>
<instruction opcode="srl" level="native" kind="bitwise"> <instruction opcode="srl" level="native" kind="bitwise">
<description>Right-shift (logical) the word src1 by the variable number <description>Right-shift (logical) the word src1 by the variable number
src2 of bits and store the result in dest.</description> src2 of bits and store the result in dest.</description>
<format type="immediate"> <predefinedAttributes template="immediate" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
<predefinedSyntax template="immediate" /> <predefinedSyntax template="immediate" />
<predefinedSyntax template="register" alias="srlv"/> <predefinedSyntax template="register" alias="srlv"/>
</instruction> </instruction>
<instruction opcode="srlv" level="native" kind="bitwise"> <instruction opcode="srlv" level="native" kind="bitwise">
<description>Right-shift (logical) the word src1 by the variable number <description>Right-shift (logical) the word src1 by the variable number
src2 of bits and store the result in dest.</description> src2 of bits and store the result in dest.</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
</instruction> </instruction>
...@@ -279,22 +227,14 @@ and store the result in dest.</description> ...@@ -279,22 +227,14 @@ and store the result in dest.</description>
<instruction opcode="and" level="native" kind="bitwise"> <instruction opcode="and" level="native" kind="bitwise">
<description>Compute the bitwise logical AND between src1 and src2 <description>Compute the bitwise logical AND between src1 and src2
and store the result to dest.</description> and store the result to dest.</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="andi" /> <predefinedSyntax template="immediate" alias="andi" />
</instruction> </instruction>
<instruction opcode="andi" level="native" kind="bitwise"> <instruction opcode="andi" level="native" kind="bitwise">
<description>Compute the bitwise logical AND between src and a constant imm <description>Compute the bitwise logical AND between src and a constant imm
and store the result to dest.</description> and store the result to dest.</description>
<format type="immediate"> <predefinedAttributes template="immediate" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
<predefinedSyntax template="immediate" /> <predefinedSyntax template="immediate" />
</instruction> </instruction>
...@@ -302,22 +242,14 @@ and store the result to dest.</description> ...@@ -302,22 +242,14 @@ and store the result to dest.</description>
<instruction opcode="or" level="native" kind="bitwise"> <instruction opcode="or" level="native" kind="bitwise">
<description>Compute the bitwise logical OR between src1 and src2 <description>Compute the bitwise logical OR between src1 and src2
and store the result to dest.</description> and store the result to dest.</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="ori" /> <predefinedSyntax template="immediate" alias="ori" />
</instruction> </instruction>
<instruction opcode="ori" level="native" kind="bitwise"> <instruction opcode="ori" level="native" kind="bitwise">
<description>Compute the bitwise logical OR between src and a constant imm <description>Compute the bitwise logical OR between src and a constant imm
and store the result to dest.</description> and store the result to dest.</description>
<format type="immediate"> <predefinedAttributes template="immediate" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
<predefinedSyntax template="immediate" /> <predefinedSyntax template="immediate" />
</instruction> </instruction>
...@@ -325,22 +257,14 @@ and store the result to dest.</description> ...@@ -325,22 +257,14 @@ and store the result to dest.</description>
<instruction opcode="xor" level="native" kind="bitwise"> <instruction opcode="xor" level="native" kind="bitwise">
<description>Compute the bitwise logical XOR between src1 and src2 <description>Compute the bitwise logical XOR between src1 and src2
and store the result to dest.</description> and store the result to dest.</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="xori"/> <predefinedSyntax template="immediate" alias="xori"/>
</instruction> </instruction>
<instruction opcode="xori" level="native" kind="bitwise"> <instruction opcode="xori" level="native" kind="bitwise">
<description>Compute the bitwise logical XOR between src and a constant imm <description>Compute the bitwise logical XOR between src and a constant imm
and store the result to dest.</description> and store the result to dest.</description>
<format type="immediate"> <predefinedAttributes template="immediate" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
<predefinedSyntax template="immediate" /> <predefinedSyntax template="immediate" />
</instruction> </instruction>
...@@ -348,11 +272,7 @@ and store the result to dest.</description> ...@@ -348,11 +272,7 @@ and store the result to dest.</description>
<instruction opcode="nor" level="native" kind="bitwise"> <instruction opcode="nor" level="native" kind="bitwise">
<description>Compute the bitwise logical NOR between src1 and src2 <description>Compute the bitwise logical NOR between src1 and src2
and store the result to dest.</description> and store the result to dest.</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
<syntax level="complex"> <syntax level="complex">
<token kind="register" name="dest" /> <token kind="register" name="dest" />
...@@ -437,22 +357,14 @@ else clear it.</description> ...@@ -437,22 +357,14 @@ else clear it.</description>
<instruction opcode="slt" level="native" kind="comparison"> <instruction opcode="slt" level="native" kind="comparison">
<description>Set dest to 1 if src1 is lower than src2 <description>Set dest to 1 if src1 is lower than src2
(signed comparison), else clear it.</description> (signed comparison), else clear it.</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="slti" /> <predefinedSyntax template="immediate" alias="slti" />
</instruction> </instruction>
<instruction opcode="sltu" level="native" kind="comparison"> <instruction opcode="sltu" level="native" kind="comparison">
<description>Set dest to 1 if src1 is lower than src2 <description>Set dest to 1 if src1 is lower than src2
(unsigned comparison), else clear it.</description> (unsigned comparison), else clear it.</description>
<format type="register"> <predefinedAttributes template="register" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
<predefinedSyntax template="register" /> <predefinedSyntax template="register" />
<predefinedSyntax template="immediate" alias="sltiu" /> <predefinedSyntax template="immediate" alias="sltiu" />
</instruction> </instruction>
...@@ -460,21 +372,13 @@ else clear it.</description> ...@@ -460,21 +372,13 @@ else clear it.</description>
<instruction opcode="slti" level="native" kind="comparison"> <instruction opcode="slti" level="native" kind="comparison">
<description>Set dest to 1 if src1 is lower than a constant imm <description>Set dest to 1 if src1 is lower than a constant imm
(signed comparison), else clear it.</description> (signed comparison), else clear it.</description>
<format type="immediate"> <predefinedAttributes template="immediate" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
<predefinedSyntax template="immediate" /> <predefinedSyntax template="immediate" />
</instruction> </instruction>
<instruction opcode="sltiu" level="native" kind="comparison"> <instruction opcode="sltiu" level="native" kind="comparison">
<description>Set dest to 1 if src1 is lower than a constant imm <description>Set dest to 1 if src1 is lower than a constant imm
(unsigned comparison), else clear it.</description> (unsigned comparison), else clear it.</description>
<format type="immediate"> <predefinedAttributes template="immediate" />
<attribute type="Register" name="dest" />
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
<predefinedSyntax template="immediate" /> <predefinedSyntax template="immediate" />
</instruction> </instruction>
...@@ -482,11 +386,7 @@ else clear it.</description> ...@@ -482,11 +386,7 @@ else clear it.</description>
<!-- Branch instructions --> <!-- Branch instructions -->
<instruction opcode="beq" level="native" kind="branch"> <instruction opcode="beq" level="native" kind="branch">
<description>Branch to label if src1 equals src2.</description> <description>Branch to label if src1 equals src2.</description>
<format type="jump"> <predefinedAttributes template="jump" />
<attribute type="Register" name="src1"/>
<attribute type="Register" name="src2"/>
<attribute type="Exp" name="label"/>
</format>
<predefinedSyntax template="jump" /> <predefinedSyntax template="jump" />
<syntax level="complex"> <syntax level="complex">
<token kind="register" /> <token kind="register" />
...@@ -505,11 +405,7 @@ else clear it.</description> ...@@ -505,11 +405,7 @@ else clear it.</description>
<instruction opcode="bne" level="native" kind="branch"> <instruction opcode="bne" level="native" kind="branch">
<description>Branch to label if src1 does not equal src2.</description> <description>Branch to label if src1 does not equal src2.</description>
<format type="jump"> <predefinedAttributes template="jump" />
<attribute type="Register" name="src1"/>
<attribute type="Register" name="src2"/>
<attribute type="Exp" name="label"/>
</format>
<predefinedSyntax template="jump" /> <predefinedSyntax template="jump" />
<syntax level="complex"> <syntax level="complex">
<token kind="register" /> <token kind="register" />
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment