Commit 7a14e3ed authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Index: ChangeLog

from  Benoît Perrot  <benoit@lrde.epita.fr>

	Li is not a native instruction

	* dev/nolimips.xml, src/int/program_builder.cc:
	Make `li' a pseudo instruction for `addiu'.
	* src/vm/cpu.hh, src/vm/cpu.cc:
	Remove emulation of `li'.
parent 49fde67a
2004-09-20 Benot Perrot <benoit@lrde.epita.fr>
Li is not a native instruction
* dev/nolimips.xml, src/int/program_builder.cc:
Make `li' a pseudo instruction for `addiu'.
* src/vm/cpu.hh, src/vm/cpu.cc:
Remove emulation of `li'.
2004-09-19 Benot Perrot <benoit@lrde.epita.fr>
Limit access to callee-save and caller-save registers.
......
......@@ -1026,15 +1026,11 @@ dest as a signed value.</description>
</syntax>
</instruction>
<!-- FIXME, should be a complex form -->
<instruction opcode="li" level="native" kind="load">
<instruction opcode="li" level="pseudo" kind="load">
<description>Move the constant imm into dest.</description>
<format>
<attribute type="Register" name="dest"/>
<attribute type="Exp" name="imm"/>
</format>
<syntax>
<syntax alias="ori">
<token kind="register" />
<token kind="hidden" value="new Register(Register::general, Cpu::zero)"/>
<token kind="immediate" />
</syntax>
</instruction>
......
......@@ -50,7 +50,8 @@ namespace inst
{
// Warning: is not implemented in as for mips, check why.
program_->text_section ().
add_inst(new Li(Register(Register::general, Cpu::at), src2));
add_inst(new Addiu(Register(Register::general, Cpu::at),
Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Mul(*dest, *src1, Register(Register::general, Cpu::at)));
}
......@@ -67,7 +68,8 @@ namespace inst
{
// FIXME: program_solver must warn and/or break when exp is zero
program_->text_section ().
add_inst(new Li(Register(Register::general, Cpu::at), src2));
add_inst(new Addiu(Register(Register::general, Cpu::at),
Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Div(*src1, Register(Register::general, Cpu::at)));
program_->text_section ().add_inst(new Mflo(*dest));
......@@ -84,7 +86,8 @@ namespace inst
{
// FIXME: program_solver must warn and/or break when exp is zero
program_->text_section ().
add_inst(new Li(Register(Register::general, Cpu::at), src2));
add_inst(new Addiu(Register(Register::general, Cpu::at),
Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Divu(*src1, Register(Register::general, Cpu::at)));
program_->text_section ().add_inst(new Mflo(*dest));
......@@ -234,7 +237,8 @@ namespace inst
ProgramBuilder::add_sgt(Register *dest, Register *src1, Exp *src2)
{
program_->text_section ().
add_inst(new Li(Register(Register::general, Cpu::at), src2));
add_inst(new Addiu(Register(Register::general, Cpu::at),
Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Slt(*dest, Register(Register::general, Cpu::at), *src1));
}
......@@ -242,7 +246,8 @@ namespace inst
ProgramBuilder::add_sgtu(Register *dest, Register *src1, Exp *src2)
{
program_->text_section ().
add_inst(new Li(Register(Register::general, Cpu::at), src2));
add_inst(new Addiu(Register(Register::general, Cpu::at),
Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Sltu(*dest, Register(Register::general, Cpu::at), *src1));
}
......@@ -258,7 +263,8 @@ namespace inst
ProgramBuilder::add_sle(Register *dest, Register *src1, Exp *src2)
{
program_->text_section ().
add_inst(new Li(Register(Register::general, Cpu::at), src2));
add_inst(new Addiu(Register(Register::general, Cpu::at),
Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Slt(*dest, Register(Register::general, Cpu::at), *src1));
program_->text_section ().add_inst(new Xori(*dest, *dest, new IntExp(1)));
......@@ -273,7 +279,8 @@ namespace inst
ProgramBuilder::add_sleu(Register *dest, Register *src1, Exp *src2)
{
program_->text_section ().
add_inst(new Li(Register(Register::general, Cpu::at), src2));
add_inst(new Addiu(Register(Register::general, Cpu::at),
Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Sltu(*dest, Register(Register::general, Cpu::at), *src1));
program_->text_section ().
......@@ -288,7 +295,8 @@ namespace inst
ProgramBuilder::add_bne(Register *src1, Exp *src2, Exp *dest)
{
program_->text_section ().
add_inst(new Li(Register(Register::general, Cpu::at), src2));
add_inst(new Addiu(Register(Register::general, Cpu::at),
Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Bne(*src1, Register(Register::general, Cpu::at), dest));
// This nop is in the delay slot
......@@ -301,7 +309,8 @@ namespace inst
ProgramBuilder::add_beq(Register *src1, Exp *src2, Exp *dest)
{
program_->text_section ().
add_inst(new Li(Register(Register::general, Cpu::at), src2));
add_inst(new Addiu(Register(Register::general, Cpu::at),
Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Beq(*src1, Register(Register::general, Cpu::at), dest));
// This nop is in the delay slot
......@@ -545,7 +554,10 @@ namespace inst
new IntExp(0)));
}
// Load address ------------------------------------------
// Load --------------------------------------------------
// Load address
// FIXME: alias?
void
ProgramBuilder::add_la (Register *dest, Exp *exp, Register *base)
{
......@@ -554,8 +566,8 @@ namespace inst
void
ProgramBuilder::add_la (Register *reg, Exp *exp)
{
// FIXME: alias
program_->text_section ().add_inst(new Li(*reg, exp));
program_->text_section ().
add_inst(new Addiu(*reg, Register(Register::general, Cpu::zero), exp));
}
} // namespace inst
......@@ -365,12 +365,6 @@ namespace vm
// Move instructions
// --------------------------------------------------------------------------
void
Cpu::visit(const inst::Li& li)
{
set_register(li.get_dest (), li.get_imm ());
}
// Store
void
Cpu::visit(const inst::Sb& sb)
......
......@@ -195,7 +195,6 @@ namespace vm
virtual void visit(const inst::Lb& lb);
virtual void visit(const inst::Lbu& Lbu);
virtual void visit(const inst::Lw& lw);
virtual void visit(const inst::Li& li);
virtual void visit(const inst::Sb& sb);
virtual void visit(const inst::Sw& sw);
......
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