Index: test/cctest/test-disasm-arm.cc |
diff --git a/test/cctest/test-disasm-arm.cc b/test/cctest/test-disasm-arm.cc |
index 3df476500a18475d29cb5ce85c4782239a2d893c..4a80e702304a479edefad714bac13714babfbc79 100644 |
--- a/test/cctest/test-disasm-arm.cc |
+++ b/test/cctest/test-disasm-arm.cc |
@@ -1393,6 +1393,39 @@ TEST(LoadStore) { |
} |
+static void TestLoadLiteral(byte* buffer, Assembler* assm, bool* failure, |
+ int offset) { |
+ int pc_offset = assm->pc_offset(); |
+ byte *progcounter = &buffer[pc_offset]; |
+ assm->ldr(r0, MemOperand(pc, offset)); |
+ |
+ const char *expected_string_template = |
+ (offset >= 0) ? |
+ "e59f0%03x ldr r0, [pc, #+%d] (addr %p)" : |
+ "e51f0%03x ldr r0, [pc, #%d] (addr %p)"; |
+ char expected_string[80]; |
+ snprintf(expected_string, sizeof(expected_string), expected_string_template, |
+ abs(offset), offset, |
+ progcounter + Instruction::kPCReadOffset + offset); |
+ if (!DisassembleAndCompare(progcounter, expected_string)) *failure = true; |
+} |
+ |
+ |
+TEST(LoadLiteral) { |
+ SET_UP(); |
+ |
+ TestLoadLiteral(buffer, &assm, &failure, 0); |
+ TestLoadLiteral(buffer, &assm, &failure, 1); |
+ TestLoadLiteral(buffer, &assm, &failure, 4); |
+ TestLoadLiteral(buffer, &assm, &failure, 4095); |
+ TestLoadLiteral(buffer, &assm, &failure, -1); |
+ TestLoadLiteral(buffer, &assm, &failure, -4); |
+ TestLoadLiteral(buffer, &assm, &failure, -4095); |
+ |
+ VERIFY_RUN(); |
+} |
+ |
+ |
TEST(Barrier) { |
SET_UP(); |