Commit 3e2940e5 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Augment supported instruction set and syntaxes

parent b33ae777
2003-07-05 Benot Perrot <benoit@lrde.epita.fr>
* dev/mipsy.xml,
* src/inst/program_builder.cc, src/inst/program_solver.hh,
* src/vm/virtual_machine.hh, src/vm/virtual_machine.cc:
Support more comparison instructions.
Implement shift (logical and arithmetical) and rotate.
Add some syntaxes to branch instructions.
2003-06-29 Benot Perrot <benoit@lrde.epita.fr> 2003-06-29 Benot Perrot <benoit@lrde.epita.fr>
* dev/mipsy.xml, src/inst/program_builder.cc: * dev/mipsy.xml, src/inst/program_builder.cc:
......
...@@ -115,20 +115,44 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -115,20 +115,44 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="neg" level="pseudo">
<syntax alias="sub">
<register />
<hidden value="* new Register(Register::zero)" />
<register default="@0" />
</syntax>
</instruction>
<instruction opcode="negu" level="pseudo">
<syntax alias="subu">
<register />
<hidden value="* new Register(Register::zero)" />
<register default="@0" />
</syntax>
</instruction>
<instruction opcode="sll" level="native"> <instruction opcode="abs" level="complex">
<syntax>
<register />
<register default="@0" />
</syntax>
</instruction>
<instruction opcode="mul" level="native">
<format> <format>
<register name="dest" /> <register name="dest" />
<register name="src" /> <register name="src1" />
<immediate name="imm" /> <register name="src2" />
</format> </format>
<syntax> <syntax>
<register /> <register />
<register /> <register />
<immediate /> <register />
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="slv" level="native">
<instruction opcode="div" level="native">
<format> <format>
<register name="dest" /> <register name="dest" />
<register name="src1" /> <register name="src1" />
...@@ -140,31 +164,53 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -140,31 +164,53 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<register /> <register />
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="divu" level="native">
<format>
<instruction opcode="neg" level="pseudo"> <register name="dest" />
<syntax alias="sub"> <register name="src1" />
<register name="src2" />
</format>
<syntax>
<register />
<register />
<register /> <register />
<hidden value="* new Register(Register::zero)" />
<register default="@0" />
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="negu" level="pseudo">
<syntax alias="subu"> <instruction opcode="remu" level="native">
<format>
<register name="dest" />
<register name="src1" />
<register name="src2" />
</format>
<syntax>
<register />
<register />
<register /> <register />
<hidden value="* new Register(Register::zero)" />
<register default="@0" />
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="abs" level="complex">
<!-- Binary instructions -->
<instruction opcode="sll" level="native">
<format>
<register name="dest" />
<register name="src" />
<immediate name="imm" />
</format>
<syntax> <syntax>
<register /> <register />
<register default="@0" /> <register />
<immediate />
</syntax>
<syntax alias="sllv">
<register />
<register />
<register />
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="sllv" level="native">
<instruction opcode="mul" level="native">
<format> <format>
<register name="dest" /> <register name="dest" />
<register name="src1" /> <register name="src1" />
...@@ -177,20 +223,24 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -177,20 +223,24 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="sra" level="native">
<instruction opcode="div" level="native">
<format> <format>
<register name="dest" /> <register name="dest" />
<register name="src1" /> <register name="src" />
<register name="src2" /> <immediate name="imm" />
</format> </format>
<syntax> <syntax>
<register />
<register />
<immediate />
</syntax>
<syntax alias="srav">
<register /> <register />
<register /> <register />
<register /> <register />
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="divu" level="native"> <instruction opcode="srav" level="native">
<format> <format>
<register name="dest" /> <register name="dest" />
<register name="src1" /> <register name="src1" />
...@@ -203,7 +253,24 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -203,7 +253,24 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="remu" level="native"> <instruction opcode="srl" level="native">
<format>
<register name="dest" />
<register name="src" />
<immediate name="imm" />
</format>
<syntax>
<register />
<register />
<immediate />
</syntax>
<syntax alias="srlv">
<register />
<register />
<register />
</syntax>
</instruction>
<instruction opcode="srlv" level="native">
<format> <format>
<register name="dest" /> <register name="dest" />
<register name="src1" /> <register name="src1" />
...@@ -216,8 +283,32 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -216,8 +283,32 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="rol" level="complex">
<syntax>
<register />
<register />
<register />
</syntax>
<syntax>
<register />
<register />
<immediate />
</syntax>
</instruction>
<instruction opcode="ror" level="complex">
<syntax>
<register />
<register />
<register />
</syntax>
<syntax>
<register />
<register />
<immediate />
</syntax>
</instruction>
<!-- Binary instructions -->
<instruction opcode="and" level="native"> <instruction opcode="and" level="native">
<format> <format>
<register name="dest" /> <register name="dest" />
...@@ -289,6 +380,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -289,6 +380,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<register default="@0" /> <register default="@0" />
<register /> <register />
</syntax> </syntax>
<syntax level="complex">
<register />
<register default="@0" />
<immediate />
</syntax>
</instruction> </instruction>
<instruction opcode="xor" level="native"> <instruction opcode="xor" level="native">
...@@ -322,41 +418,117 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -322,41 +418,117 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</instruction> </instruction>
<instruction opcode="not" level="pseudo"> <instruction opcode="not" level="pseudo">
<syntax alias="xori"> <syntax alias="nor">
<register /> <register />
<register default="@0"/> <register default="@0"/>
<hidden value="* new IntExp(~0)" /> <hidden value="* new Register(Register::zero)" />
</syntax> </syntax>
</instruction> </instruction>
<!-- Test instructions --> <!-- Test instructions -->
<instruction opcode="slt" level="native"> <instruction opcode="seq" level="complex">
<format>
<register name="dest" />
<register name="src1" />
<register name="src2" />
</format>
<syntax> <syntax>
<register /> <register />
<register /> <register />
<register /> <register />
</syntax> </syntax>
<syntax>
<register />
<register />
<immediate />
</syntax>
</instruction> </instruction>
<instruction opcode="slti" level="native"> <instruction opcode="sne" level="complex">
<format> <syntax>
<register name="dest" /> <register />
<register name="src" /> <register />
<immediate name="imm" /> <register />
</format> </syntax>
<syntax> <syntax>
<register /> <register />
<register /> <register />
<immediate /> <immediate />
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="sltu" level="native">
<instruction opcode="sge" level="complex">
<syntax>
<register />
<register />
<register />
</syntax>
<syntax>
<register />
<register />
<immediate />
</syntax>
</instruction>
<instruction opcode="sgeu" level="complex">
<syntax>
<register />
<register />
<register />
</syntax>
<syntax>
<register />
<register />
<immediate />
</syntax>
</instruction>
<instruction opcode="sgt" level="complex">
<syntax alias="slt">
<register />
<register value="@2"/>
<register value="@1"/>
</syntax>
<syntax>
<register />
<register />
<immediate />
</syntax>
</instruction>
<instruction opcode="sgtu" level="complex">
<syntax alias="sltu">
<register />
<register value="@2"/>
<register value="@1"/>
</syntax>
<syntax>
<register />
<register />
<immediate />
</syntax>
</instruction>
<instruction opcode="sle" level="complex">
<syntax>
<register />
<register />
<register />
</syntax>
<syntax>
<register />
<register />
<immediate />
</syntax>
</instruction>
<instruction opcode="sleu" level="complex">
<syntax>
<register />
<register />
<register />
</syntax>
<syntax>
<register />
<register />
<immediate />
</syntax>
</instruction>
<instruction opcode="slt" level="native">
<format> <format>
<register name="dest" /> <register name="dest" />
<register name="src1" /> <register name="src1" />
...@@ -367,8 +539,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -367,8 +539,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<register /> <register />
<register /> <register />
</syntax> </syntax>
<syntax alias="slti">
<register />
<register />
<immediate />
</syntax>
</instruction> </instruction>
<instruction opcode="sltiu" level="native"> <instruction opcode="slti" level="native">
<format> <format>
<register name="dest" /> <register name="dest" />
<register name="src" /> <register name="src" />
...@@ -380,25 +557,29 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -380,25 +557,29 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<immediate /> <immediate />
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="sltu" level="native">
<instruction opcode="seq" level="complex"> <format>
<register name="dest" />
<register name="src1" />
<register name="src2" />
</format>
<syntax> <syntax>
<register /> <register />
<register /> <register />
<register /> <register />
</syntax> </syntax>
<syntax> <syntax alias="sltiu">
<register /> <register />
<register /> <register />
<immediate /> <immediate />
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="sne" level="complex"> <instruction opcode="sltiu" level="native">
<syntax> <format>
<register /> <register name="dest" />
<register /> <register name="src" />
<register /> <immediate name="imm" />
</syntax> </format>
<syntax> <syntax>
<register /> <register />
<register /> <register />
...@@ -408,6 +589,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -408,6 +589,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<!-- Branch instructions --> <!-- Branch instructions -->
<instruction opcode="beq" level="native"> <instruction opcode="beq" level="native">
<format> <format>
<register name="src1"/> <register name="src1"/>
...@@ -419,14 +601,20 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -419,14 +601,20 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<register /> <register />
<label /> <label />
</syntax> </syntax>
<syntax level="complex">
<register />
<immediate />
<label />
</syntax>
</instruction> </instruction>
<instruction opcode="beqz" level="pseudo"> <instruction opcode="beqz" level="pseudo">
<syntax alias="beq"> <syntax alias="beq">
<hidden value="* new Register(Register::zero)"/>
<register /> <register />
<hidden value="* new Register(Register::zero)"/>
<label /> <label />
</syntax> </syntax>
</instruction> </instruction>
<instruction opcode="bne" level="native"> <instruction opcode="bne" level="native">
<format> <format>
<register name="src1"/> <register name="src1"/>
...@@ -438,8 +626,21 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -438,8 +626,21 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<register /> <register />
<label /> <label />
</syntax> </syntax>
<syntax level="complex">
<register />
<immediate />
<label />
</syntax>
</instruction>
<instruction opcode="bnez" level="pseudo">
<syntax alias="bne">
<register />
<hidden value="* new Register(Register::zero)"/>
<label />
</syntax>
</instruction> </instruction>
<instruction opcode="bge" level="complex"> <instruction opcode="bge" level="complex">
<syntax> <syntax>
<register /> <register />
...@@ -638,6 +839,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -638,6 +839,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</syntax> </syntax>
</instruction> </instruction>
<!-- Load instructions -->
<instruction opcode="lw" level="native"> <instruction opcode="lw" level="native">
<format> <format>
...@@ -702,6 +904,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -702,6 +904,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</instruction> </instruction>
<!-- Store instructions -->
<instruction opcode="sw" level="native"> <instruction opcode="sw" level="native">
<format> <format>
...@@ -730,6 +933,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -730,6 +933,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</instruction> </instruction>
<!-- Data movement instructions -->
<instruction opcode="move" level="pseudo"> <instruction opcode="move" level="pseudo">
<syntax alias="add"> <syntax alias="add">
<register /> <register />
...@@ -738,6 +943,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ...@@ -738,6 +943,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</syntax> </syntax>
</instruction> </instruction>
<!-- Exception and trap instructions -->
<instruction opcode="syscall" level="native"> <instruction opcode="syscall" level="native">
<format> <format>
......
...@@ -36,8 +36,60 @@ namespace inst ...@@ -36,8 +36,60 @@ namespace inst
add_inst(* new Sub(dest, * new Register(Register::zero), src)); add_inst(* new Sub(dest, * new Register(Register::zero), src));
} }
// Bitwise instructions -------------------------------------
void
ProgramBuilder::add_rol(Register& dest, Register& src1, Register& src2)
{
Register& at = * new Register(Register::at);
_program->text_section ().
add_inst(* new Subu(at, * new Register(Register::zero), src2));
_program->text_section ().add_inst(* new Srlv(at, src1, at));
_program->text_section ().add_inst(* new Sllv(dest, src1, src2));
_program->text_section ().add_inst(* new Or(dest, dest, at));
}
void
ProgramBuilder::add_rol(Register& dest, Register& src1, Exp& src2)
{
Register& at = * new Register(Register::at);