From: Fangrui Song Date: Tue, 18 Jun 2019 06:35:18 +0000 (+0000) Subject: [llvm-objdump] Tidy up AMDGCNPrettyPrinter X-Git-Tag: android-x86-9.0-r1~1761 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0ef6742182ddae5ebb117b16a1e2724157053d1f;p=android-x86%2Fexternal-llvm.git [llvm-objdump] Tidy up AMDGCNPrettyPrinter git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363650 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CodeGen/AMDGPU/nop-data.ll b/test/CodeGen/AMDGPU/nop-data.ll index 4e836a398ee..b3e6a6cb855 100644 --- a/test/CodeGen/AMDGPU/nop-data.ll +++ b/test/CodeGen/AMDGPU/nop-data.ll @@ -78,7 +78,7 @@ entry: ; CHECK-NEXT: s_nop 0 ; CHECK-NEXT: s_nop 0 // 0000000001FC: BF800000 -; CHECK-NEXT: {{^$}} +; CHECK-EMPTY: ; CHECK-NEXT: kernel1: ; CHECK-NEXT: s_endpgm define amdgpu_kernel void @kernel1(i32 addrspace(1)* addrspace(4)* %ptr.out) align 256 { diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index 7305f2bf634..ebe271dba38 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -658,6 +658,7 @@ public: } }; PrettyPrinter PrettyPrinterInst; + class HexagonPrettyPrinter : public PrettyPrinter { public: void printLead(ArrayRef Bytes, uint64_t Address, @@ -748,8 +749,6 @@ public: if (SP && (PrintSource || PrintLines)) SP->printSourceLine(OS, Address); - typedef support::ulittle32_t U32; - if (MI) { SmallString<40> InstStr; raw_svector_ostream IS(InstStr); @@ -763,7 +762,7 @@ public: // remaining if (Bytes.size() >= 4) { OS << format("\t.long 0x%08" PRIx32 " ", - static_cast(*reinterpret_cast(Bytes.data()))); + support::endian::read32(Bytes.data())); OS.indent(42); } else { OS << format("\t.byte 0x%02" PRIx8, Bytes[0]); @@ -773,20 +772,21 @@ public: } } - OS << format("// %012" PRIX64 ": ", Address.Address); - if (Bytes.size() >=4) { - for (auto D : makeArrayRef(reinterpret_cast(Bytes.data()), - Bytes.size() / sizeof(U32))) - // D should be explicitly casted to uint32_t here as it is passed - // by format to snprintf as vararg. - OS << format("%08" PRIX32 " ", static_cast(D)); + OS << format("// %012" PRIX64 ":", Address.Address); + if (Bytes.size() >= 4) { + // D should be casted to uint32_t here as it is passed by format to + // snprintf as vararg. + for (uint32_t D : makeArrayRef( + reinterpret_cast(Bytes.data()), + Bytes.size() / 4)) + OS << format(" %08" PRIX32, D); } else { - for (unsigned int i = 0; i < Bytes.size(); i++) - OS << format("%02" PRIX8 " ", Bytes[i]); + for (unsigned char B : Bytes) + OS << format(" %02" PRIX8, B); } if (!Annot.empty()) - OS << "// " << Annot; + OS << " // " << Annot; } }; AMDGCNPrettyPrinter AMDGCNPrettyPrinterInst;