diff options
author | Jacob Bramley <jacob.bramley@arm.com> | 2017-06-22 11:31:43 +0100 |
---|---|---|
committer | Jacob Bramley <jacob.bramley@arm.com> | 2017-06-26 11:06:58 +0100 |
commit | d817e1ed50e3c8d6bea1714ebc56cdebb076373a (patch) | |
tree | 6045802fdc27d3bcff7029a97062710eb3c42705 /test/aarch64 | |
parent | 1bce007699e07bd855b7d194ca93fa5504a73eda (diff) | |
download | vixl-d817e1ed50e3c8d6bea1714ebc56cdebb076373a.tar.gz |
Add --disassemble-test-code.
Much of the time, the infrastructure (RegisterDump) code is distracting,
and often longer than the test. The new --disassemble-test-code option
omits the boiler-plate, and shows only the test code itself.
The normal --disassemble option still works as it did before.
Change-Id: I421f15734f912ef1e7a9f0d5a018c93d4a03e51a
Diffstat (limited to 'test/aarch64')
-rw-r--r-- | test/aarch64/test-assembler-aarch64.cc | 92 |
1 files changed, 59 insertions, 33 deletions
diff --git a/test/aarch64/test-assembler-aarch64.cc b/test/aarch64/test-assembler-aarch64.cc index 22a494af..71e09e14 100644 --- a/test/aarch64/test-assembler-aarch64.cc +++ b/test/aarch64/test-assembler-aarch64.cc @@ -120,7 +120,9 @@ namespace aarch64 { Disassembler disasm; \ Decoder disassembler_decoder; \ disassembler_decoder.AppendVisitor(&disasm); \ - RegisterDump core + RegisterDump core; \ + ptrdiff_t offset_after_infrastructure_start; \ + ptrdiff_t offset_before_infrastructure_end #define START() \ masm.Reset(); \ @@ -138,16 +140,22 @@ namespace aarch64 { } \ if (Test::instruction_stats()) { \ __ EnableInstrumentation(); \ - } - -#define END() \ - if (Test::instruction_stats()) { \ - __ DisableInstrumentation(); \ - } \ - __ Trace(LOG_ALL, TRACE_DISABLE); \ - core.Dump(&masm); \ - __ PopCalleeSavedRegisters(); \ - __ Ret(); \ + } \ + offset_after_infrastructure_start = masm.GetCursorOffset(); \ + /* Avoid unused-variable warnings in case a test never calls RUN(). */ \ + USE(offset_after_infrastructure_start) + +#define END() \ + offset_before_infrastructure_end = masm.GetCursorOffset(); \ + /* Avoid unused-variable warnings in case a test never calls RUN(). */ \ + USE(offset_before_infrastructure_end); \ + if (Test::instruction_stats()) { \ + __ DisableInstrumentation(); \ + } \ + __ Trace(LOG_ALL, TRACE_DISABLE); \ + core.Dump(&masm); \ + __ PopCalleeSavedRegisters(); \ + __ Ret(); \ masm.FinalizeCode() #define RUN() \ @@ -188,16 +196,24 @@ namespace aarch64 { disassembler_decoder.AppendVisitor(&disasm); \ masm.SetGenerateSimulatorCode(false); \ RegisterDump core; \ - CPU::SetUp() - -#define START() \ - masm.Reset(); \ - __ PushCalleeSavedRegisters() - -#define END() \ - core.Dump(&masm); \ - __ PopCalleeSavedRegisters(); \ - __ Ret(); \ + CPU::SetUp(); \ + ptrdiff_t offset_after_infrastructure_start; \ + ptrdiff_t offset_before_infrastructure_end + +#define START() \ + masm.Reset(); \ + __ PushCalleeSavedRegisters(); \ + offset_after_infrastructure_start = masm.GetCursorOffset(); \ + /* Avoid unused-variable warnings in case a test never calls RUN(). */ \ + USE(offset_after_infrastructure_start) + +#define END() \ + offset_before_infrastructure_end = masm.GetCursorOffset(); \ + /* Avoid unused-variable warnings in case a test never calls RUN(). */ \ + USE(offset_before_infrastructure_end); \ + core.Dump(&masm); \ + __ PopCalleeSavedRegisters(); \ + __ Ret(); \ masm.FinalizeCode() // Execute the generated code from the memory area. @@ -221,18 +237,28 @@ namespace aarch64 { #endif // ifdef VIXL_INCLUDE_SIMULATOR_AARCH64. -#define DISASSEMBLE() \ - if (Test::disassemble()) { \ - Instruction* instruction = \ - masm.GetBuffer()->GetStartAddress<Instruction*>(); \ - Instruction* end = masm.GetBuffer()->GetOffsetAddress<Instruction*>( \ - masm.GetSizeOfCodeGenerated()); \ - while (instruction != end) { \ - disassembler_decoder.Decode(instruction); \ - uint32_t encoding = *reinterpret_cast<uint32_t*>(instruction); \ - printf("%08" PRIx32 "\t%s\n", encoding, disasm.GetOutput()); \ - instruction += kInstructionSize; \ - } \ +#define DISASSEMBLE() \ + if (Test::disassemble()) { \ + ptrdiff_t start_offset = offset_after_infrastructure_start; \ + ptrdiff_t end_offset = offset_before_infrastructure_end; \ + if (Test::disassemble_infrastructure()) { \ + start_offset = 0; \ + end_offset = masm.GetSizeOfCodeGenerated(); \ + } else { \ + printf( \ + " Warning: Omitting infrastructure code. " \ + "Use --disassemble to see it.\n"); \ + } \ + Instruction* instruction = \ + masm.GetBuffer()->GetOffsetAddress<Instruction*>(start_offset); \ + Instruction* end = \ + masm.GetBuffer()->GetOffsetAddress<Instruction*>(end_offset); \ + while (instruction != end) { \ + disassembler_decoder.Decode(instruction); \ + uint32_t encoding = *reinterpret_cast<uint32_t*>(instruction); \ + printf("%08" PRIx32 "\t%s\n", encoding, disasm.GetOutput()); \ + instruction += kInstructionSize; \ + } \ } #define ASSERT_EQUAL_NZCV(expected) \ |