Commit 9171d91c authored by georgia.kouveli's avatar georgia.kouveli Committed by Commit bot

[arm] Print address for load literal instructions.

BUG=

Review-Url: https://codereview.chromium.org/2871863003
Cr-Commit-Position: refs/heads/master@{#45297}
parent 4acca5ba
......@@ -667,6 +667,28 @@ int Decoder::FormatOption(Instruction* instr, const char* format) {
case 'v': {
return FormatVFPinstruction(instr, format);
}
case 'A': {
// Print pc-relative address.
int offset = instr->Offset12Value();
byte* pc = reinterpret_cast<byte*>(instr) + Instruction::kPCReadOffset;
byte* addr;
switch (instr->PUField()) {
case db_x: {
addr = pc - offset;
break;
}
case ib_x: {
addr = pc + offset;
break;
}
default: {
UNREACHABLE();
return -1;
}
}
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%p", addr);
return 1;
}
case 'S':
case 'D': {
return FormatVFPRegister(instr, format);
......@@ -1033,11 +1055,19 @@ void Decoder::DecodeType2(Instruction* instr) {
break;
}
case db_x: {
Format(instr, "'memop'cond'b 'rd, ['rn, #-'off12]'w");
if (instr->HasL() && (instr->RnValue() == kPCRegister)) {
Format(instr, "'memop'cond'b 'rd, [pc, #-'off12]'w (addr 'A)");
} else {
Format(instr, "'memop'cond'b 'rd, ['rn, #-'off12]'w");
}
break;
}
case ib_x: {
Format(instr, "'memop'cond'b 'rd, ['rn, #+'off12]'w");
if (instr->HasL() && (instr->RnValue() == kPCRegister)) {
Format(instr, "'memop'cond'b 'rd, [pc, #+'off12]'w (addr 'A)");
} else {
Format(instr, "'memop'cond'b 'rd, ['rn, #+'off12]'w");
}
break;
}
default: {
......
......@@ -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();
......
Markdown is supported
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