From d8ee737fdbf380c5bb90c9270c8d1087ac23e76c Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Fri, 28 Mar 2014 15:43:40 +0000 Subject: Add support for adding two integers in optimizing compiler. Change-Id: I5524e193cd07f2692a57c6b4f8069904471b2928 --- compiler/optimizing/codegen_test.cc | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'compiler/optimizing/codegen_test.cc') diff --git a/compiler/optimizing/codegen_test.cc b/compiler/optimizing/codegen_test.cc index ff743d8ed3..d40990e86b 100644 --- a/compiler/optimizing/codegen_test.cc +++ b/compiler/optimizing/codegen_test.cc @@ -196,4 +196,42 @@ TEST(CodegenTest, ReturnIf2) { TestCode(data, true, 0); } +TEST(CodegenTest, ReturnAdd1) { + const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( + Instruction::CONST_4 | 3 << 12 | 0, + Instruction::CONST_4 | 4 << 12 | 1 << 8, + Instruction::ADD_INT, 1 << 8 | 0, + Instruction::RETURN); + + TestCode(data, true, 7); +} + +TEST(CodegenTest, ReturnAdd2) { + const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( + Instruction::CONST_4 | 3 << 12 | 0, + Instruction::CONST_4 | 4 << 12 | 1 << 8, + Instruction::ADD_INT_2ADDR | 1 << 12, + Instruction::RETURN); + + TestCode(data, true, 7); +} + +TEST(CodegenTest, ReturnAdd3) { + const uint16_t data[] = ONE_REGISTER_CODE_ITEM( + Instruction::CONST_4 | 4 << 12 | 0 << 8, + Instruction::ADD_INT_LIT8, 3 << 8 | 0, + Instruction::RETURN); + + TestCode(data, true, 7); +} + +TEST(CodegenTest, ReturnAdd4) { + const uint16_t data[] = ONE_REGISTER_CODE_ITEM( + Instruction::CONST_4 | 4 << 12 | 0 << 8, + Instruction::ADD_INT_LIT16, 3, + Instruction::RETURN); + + TestCode(data, true, 7); +} + } // namespace art -- cgit v1.2.3