https://svn.lrde.epita.fr/svn/nolimips/trunk
ChangeLog | 11 +
dev/nolimips.py | 35 ++++-
dev/nolimips.xml | 384 +++++++++----------------------------------------------
3 files changed, 104 insertions(+), 326 deletions(-)
Index: ChangeLog
from Benoît Perrot <benoit(a)nostromo.lrde.epita.fr>
2005-08-07 Benoît Perrot <benoit(a)lrde.epita.fr>
* dev/nolimips.py, dev/nolimips.xml: Introduce predefined syntaxes
to reduce data redundancy.
2005-07-31 Benoît Perrot <benoit(a)lrde.epita.fr>
2005-07-31 Benoît Perrot <benoit(a)lrde.epita.fr>
2005-07-11 Benoît Perrot <benoit(a)lrde.epita.fr>
Index: dev/nolimips.py
--- dev/nolimips.py (revision 185)
+++ dev/nolimips.py (revision 186)
@@ -1,7 +1,7 @@
#!/usr/bin/env python
##
## This file is part of Nolimips, a MIPS simulator with unlimited registers
-## Copyright (C) 2003, 2004 Benoit Perrot <benoit(a)lrde.epita.fr>
+## Copyright (C) 2003, 2004, 2005 Benoit Perrot <benoit(a)lrde.epita.fr>
##
## Nolimips is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
license = """//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
-// Copyright (C) 2004 Benoit Perrot <benoit(a)lrde.epita.fr>
+// Copyright (C) 2004, 2005 Benoit Perrot <benoit(a)lrde.epita.fr>
//
// Nolimips is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -183,8 +183,27 @@
def reset(self):
self.tokens = []
self.alias = ""
+ self.level = ""
def __init__(self):
self.reset()
+ def set_to_predefined(self, template, alias, level):
+ self.alias = alias
+ self.level = level
+ if template == "register":
+ self.tokens = [
+ Token("register", "dest", "", ""),
+ Token("register", "", "", "${dest}"),
+ Token("register", "", "", "")]
+ elif template == "immediate":
+ self.tokens = [
+ Token("register", "dest", "", ""),
+ Token("register", "", "", "${dest}"),
+ Token("immediate", "", "", "")]
+ elif template == "jump":
+ self.tokens = [
+ Token("register", "", "", ""),
+ Token("register", "", "", ""),
+ Token("label", "", "", "")]
def get(self):
return Syntax(self.tokens, self.alias, self.level)
@@ -268,6 +287,16 @@
self.syntax_b.level = attrs["level"]
else:
self.syntax_b.level = self.inst_b.level
+ elif name == "predefinedSyntax":
+ alias = ""
+ if attrs.has_key("alias"):
+ alias = attrs["alias"]
+ level = ""
+ if attrs.has_key("level"):
+ level = attrs["level"]
+ else:
+ level = self.inst_b.level
+ self.syntax_b.set_to_predefined(attrs["template"], alias, level)
elif name == "token":
self.token_b.reset()
self.token_b.kind = attrs["kind"]
@@ -281,7 +310,7 @@
def endElement(self, name):
if name == "token":
self.syntax_b.tokens.append(self.token_b.get())
- elif name == "syntax":
+ 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())
Index: dev/nolimips.xml
--- dev/nolimips.xml (revision 185)
+++ dev/nolimips.xml (revision 186)
@@ -26,16 +26,8 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}" />
- <token kind="register" />
- </syntax>
- <syntax alias="addi">
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}" />
- <token kind="immediate" />
- </syntax>
+ <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
@@ -45,16 +37,8 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}"/>
- <token kind="register" />
- </syntax>
- <syntax alias="addiu">
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="register" />
+ <predefinedSyntax template="immediate" alias="addiu"/>
</instruction>
<instruction opcode="addi" level="native"
kind="arithmetic">
@@ -65,11 +49,7 @@
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
- <syntax>
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="addiu" level="native"
kind="arithmetic">
<description>Add a constant imm and src and store the result in dest
@@ -79,11 +59,7 @@
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
- <syntax>
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="sub" level="native"
kind="arithmetic">
@@ -94,11 +70,7 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
+ <predefinedSyntax template="register" />
<syntax alias="addi">
<token kind="register" />
<token kind="register" />
@@ -113,11 +85,7 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
+ <predefinedSyntax template="register" />
<syntax alias="addiu">
<token kind="register" />
<token kind="register" />
@@ -161,11 +129,7 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
+ <predefinedSyntax template="register" />
<syntax level="complex">
<token kind="register" />
<token kind="register" />
@@ -221,20 +185,12 @@
<instruction opcode="rem" level="complex"
kind="arithmetic">
<description>Compute the remainder from dividing src1 by src2
(32-bit signed integers) and write it to dest.</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
+ <predefinedSyntax template="register" />
</instruction>
<instruction opcode="remu" level="complex"
kind="arithmetic">
<description>Compute the remainder from dividing src1 by src2
(32-bit unsigned integers) and write it to dest.</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
+ <predefinedSyntax template="register" />
</instruction>
@@ -247,16 +203,8 @@
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
- <syntax alias="sllv">
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
+ <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
@@ -266,11 +214,7 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
+ <predefinedSyntax template="register" />
</instruction>
<instruction opcode="sra" level="native"
kind="bitwise">
@@ -281,16 +225,8 @@
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
- <syntax alias="srav">
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
+ <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
@@ -300,11 +236,7 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
+ <predefinedSyntax template="register" />
</instruction>
<instruction opcode="srl" level="native"
kind="bitwise">
@@ -315,16 +247,8 @@
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
- <syntax alias="srlv">
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
+ <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
@@ -334,41 +258,21 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
+ <predefinedSyntax template="register" />
</instruction>
<instruction opcode="rol" level="complex"
kind="bitwise">
<description>Left-rotate the word src by a number of bits (imm or src2)
and store the result in dest.</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="register" />
+ <predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="ror" level="complex"
kind="bitwise">
<description>Right-rotate the word src by a number (imm or src2) of bits
and store the result in dest.</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="register" />
+ <predefinedSyntax template="immediate" />
</instruction>
@@ -380,16 +284,8 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}" />
- <token kind="register" />
- </syntax>
- <syntax alias="andi">
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}" />
- <token kind="immediate" />
- </syntax>
+ <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
@@ -399,11 +295,7 @@
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="immediate" />
</instruction>
@@ -415,16 +307,8 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}" />
- <token kind="register" />
- </syntax>
- <syntax alias="ori">
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}" />
- <token kind="immediate" />
- </syntax>
+ <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
@@ -434,11 +318,7 @@
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="immediate" />
</instruction>
@@ -450,16 +330,8 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}" />
- <token kind="register" />
- </syntax>
- <syntax alias="xori">
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}" />
- <token kind="immediate" />
- </syntax>
+ <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
@@ -469,11 +341,7 @@
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="immediate" />
</instruction>
@@ -485,11 +353,7 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" name="dest" />
- <token kind="register" default="${dest}" />
- <token kind="register" />
- </syntax>
+ <predefinedSyntax template="register" />
<syntax level="complex">
<token kind="register" name="dest" />
<token kind="register" default="${dest}" />
@@ -513,59 +377,27 @@
<instruction opcode="seq" level="complex"
kind="comparison">
<description>Set dest to 1 if src1 equals src2,
else clear it.</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="register" />
+ <predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="sne" level="complex"
kind="comparison">
<description>Set dest to 1 if src1 does not equal src2,
else clear it.</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="register" />
+ <predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="sge" level="complex"
kind="comparison">
<description>Set dest to 1 if src1 is greater or equal to src2
(signed comparison), else clear it.</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="register" />
+ <predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="sgeu" level="complex"
kind="comparison">
<description>Set dest to 1 if src1 is greater or equal to src2
(unsigned comparison), else clear it.</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="register" />
+ <predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="sgt" level="complex"
kind="comparison">
@@ -576,11 +408,7 @@
<token kind="register" name="src1"
value="${src2}"/>
<token kind="register" name="src2"
value="${src1}"/>
</syntax>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="sgtu" level="complex"
kind="comparison">
<description>Set dest to 1 if src1 is greater than src2
@@ -590,40 +418,20 @@
<token kind="register" name="src1"
value="${src2}"/>
<token kind="register" name="src2"
value="${src1}"/>
</syntax>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="sle" level="complex"
kind="comparison">
<description>Set dest to 1 if src1 is lower or equal to src2
(signed comparison), else clear it.</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="register" />
+ <predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="sleu" level="complex"
kind="comparison">
<description>Set dest to 1 if src1 is lower or equal to src2
(unsigned comparison), else clear it.</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="register" />
+ <predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="slt" level="native"
kind="comparison">
@@ -634,16 +442,8 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
- <syntax alias="slti">
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <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
@@ -653,16 +453,8 @@
<attribute type="Register" name="src1" />
<attribute type="Register" name="src2" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="register" />
- </syntax>
- <syntax alias="sltiu">
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="register" />
+ <predefinedSyntax template="immediate" alias="sltiu" />
</instruction>
<instruction opcode="slti" level="native"
kind="comparison">
@@ -673,11 +465,7 @@
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="immediate" />
</instruction>
<instruction opcode="sltiu" level="native"
kind="comparison">
<description>Set dest to 1 if src1 is lower than a constant imm
@@ -687,11 +475,7 @@
<attribute type="Register" name="src" />
<attribute type="Exp" name="imm" />
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="immediate" />
- </syntax>
+ <predefinedSyntax template="immediate" />
</instruction>
@@ -703,11 +487,7 @@
<attribute type="Register" name="src2"/>
<attribute type="Exp" name="label"/>
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="label" />
- </syntax>
+ <predefinedSyntax template="jump" />
<syntax level="complex">
<token kind="register" />
<token kind="immediate" />
@@ -730,11 +510,7 @@
<attribute type="Register" name="src2"/>
<attribute type="Exp" name="label"/>
</format>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="label" />
- </syntax>
+ <predefinedSyntax template="jump" />
<syntax level="complex">
<token kind="register" />
<token kind="immediate" />
@@ -754,11 +530,7 @@
<instruction opcode="bge" level="complex"
kind="branch">
<description>Branch to label if src1 is greater or equal to src2
(signed comparison).</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="label" />
- </syntax>
+ <predefinedSyntax template="jump" />
<syntax>
<token kind="register" />
<token kind="immediate" />
@@ -768,11 +540,7 @@
<instruction opcode="bgeu" level="complex"
kind="branch">
<description>Branch to label if src1 is greater or equal to src2
(unsigned comparison).</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="label" />
- </syntax>
+ <predefinedSyntax template="jump" />
<syntax>
<token kind="register" />
<token kind="immediate" />
@@ -807,11 +575,7 @@
<instruction opcode="bgt" level="complex"
kind="branch">
<description>Branch to label if src1 is greater than src2
(signed comparison).</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="label" />
- </syntax>
+ <predefinedSyntax template="jump" />
<syntax>
<token kind="register" />
<token kind="immediate" />
@@ -821,11 +585,7 @@
<instruction opcode="bgtu" level="complex"
kind="branch">
<description>Branch to label if src1 is greater than src2
(unsigned comparison).</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="label" />
- </syntax>
+ <predefinedSyntax template="jump" />
<syntax>
<token kind="register" />
<token kind="immediate" />
@@ -848,11 +608,7 @@
<instruction opcode="ble" level="complex"
kind="branch">
<description>Branch to label if src1 is lower or equal to src2
(signed comparison).</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="label" />
- </syntax>
+ <predefinedSyntax template="jump" />
<syntax>
<token kind="register" />
<token kind="immediate" />
@@ -862,11 +618,7 @@
<instruction opcode="bleu" level="complex"
kind="branch">
<description>Branch to label if src1 is lower or equal to src2
(unsigned comparison).</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="label" />
- </syntax>
+ <predefinedSyntax template="jump" />
<syntax>
<token kind="register" />
<token kind="immediate" />
@@ -889,11 +641,7 @@
<instruction opcode="blt" level="complex"
kind="branch">
<description>Branch to label if src1 is lower than src2
(signed comparison).</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="label" />
- </syntax>
+ <predefinedSyntax template="jump" />
<syntax>
<token kind="register" />
<token kind="immediate" />
@@ -903,11 +651,7 @@
<instruction opcode="bltu" level="complex"
kind="branch">
<description>Branch to label if src1 is lower than src2
(unsigned comparison).</description>
- <syntax>
- <token kind="register" />
- <token kind="register" />
- <token kind="label" />
- </syntax>
+ <predefinedSyntax template="jump" />
<syntax>
<token kind="register" />
<token kind="immediate" />