lite-tr: added support for
Added support for some OpInstructions
Added in support for Sub, And, Or, Xor, and Sll OpInstructions
Test: Tree-Hugger
Bug: 277619887
Change-Id: If34ec24deed4e6e0481f0d4d10375fda4dfaa64f
diff --git a/lite_translator/riscv64_to_x86_64/lite_translate_insn_exec_tests.cc b/lite_translator/riscv64_to_x86_64/lite_translate_insn_exec_tests.cc
index a815323..7c844ef 100644
--- a/lite_translator/riscv64_to_x86_64/lite_translate_insn_exec_tests.cc
+++ b/lite_translator/riscv64_to_x86_64/lite_translate_insn_exec_tests.cc
@@ -70,6 +70,16 @@
TEST_F(Riscv64LiteTranslateInsnTest, OpInstructions) {
// Add
TestOp(0x003100b3, {{19, 23, 42}});
+ // Sub
+ TestOp(0x403100b3, {{42, 23, 19}});
+ // And
+ TestOp(0x003170b3, {{0b0101, 0b0011, 0b0001}});
+ // Or
+ TestOp(0x003160b3, {{0b0101, 0b0011, 0b0111}});
+ // Xor
+ TestOp(0x003140b3, {{0b0101, 0b0011, 0b0110}});
+ // Sll
+ TestOp(0x003110b3, {{0b1010, 3, 0b1010'000}});
}
} // namespace
diff --git a/lite_translator/riscv64_to_x86_64/lite_translator.h b/lite_translator/riscv64_to_x86_64/lite_translator.h
index 4879e30..065c3dd 100644
--- a/lite_translator/riscv64_to_x86_64/lite_translator.h
+++ b/lite_translator/riscv64_to_x86_64/lite_translator.h
@@ -52,6 +52,22 @@
case Decoder::OpOpcode::kAdd:
as_.Addq(res, arg2);
break;
+ case Decoder::OpOpcode::kSub:
+ as_.Subq(res, arg2);
+ break;
+ case Decoder::OpOpcode::kAnd:
+ as_.Andq(res, arg2);
+ break;
+ case Decoder::OpOpcode::kOr:
+ as_.Orq(res, arg2);
+ break;
+ case Decoder::OpOpcode::kXor:
+ as_.Xorq(res, arg2);
+ break;
+ case Decoder::OpOpcode::kSll:
+ as_.Movl(as_.rcx, arg2);
+ as_.ShlqByCl(res);
+ break;
default:
Unimplemented();
return {};