[llvm] r284760 - [AMDGPU] Make note record name a static const member of target streamer
Konstantin Zhuravlyov via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 20 11:22:37 PDT 2016
Author: kzhuravl
Date: Thu Oct 20 13:22:36 2016
New Revision: 284760
URL: http://llvm.org/viewvc/llvm-project?rev=284760&view=rev
Log:
[AMDGPU] Make note record name a static const member of target streamer
Differential Revision: https://reviews.llvm.org/D25746
Modified:
llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.h
Modified: llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp?rev=284760&r1=284759&r2=284760&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp Thu Oct 20 13:22:36 2016
@@ -86,6 +86,8 @@ void AMDGPUTargetAsmStreamer::EmitAMDGPU
// AMDGPUTargetELFStreamer
//===----------------------------------------------------------------------===//
+const char *AMDGPUTargetELFStreamer::NoteName = "AMD";
+
AMDGPUTargetELFStreamer::AMDGPUTargetELFStreamer(MCStreamer &S)
: AMDGPUTargetStreamer(S), Streamer(S) { }
@@ -100,15 +102,14 @@ AMDGPUTargetELFStreamer::EmitDirectiveHS
MCSectionELF *Note =
OS.getContext().getELFSection(".note", ELF::SHT_NOTE, ELF::SHF_ALLOC);
- unsigned NameSZ = 4;
-
OS.PushSection();
OS.SwitchSection(Note);
- OS.EmitIntValue(NameSZ, 4); // namesz
- OS.EmitIntValue(8, 4); // descz
- OS.EmitIntValue(NT_AMDGPU_HSA_CODE_OBJECT_VERSION, 4); // type
- OS.EmitBytes(StringRef("AMD", NameSZ)); // name
- OS.EmitIntValue(Major, 4); // desc
+ OS.EmitIntValue(strlen(NoteName) + 1, 4); // namesz
+ OS.EmitIntValue(8, 4); // descz
+ OS.EmitIntValue(NT_AMDGPU_HSA_CODE_OBJECT_VERSION, 4); // type
+ OS.EmitBytes(StringRef(NoteName, strlen(NoteName) + 1)); // name
+ OS.EmitValueToAlignment(4);
+ OS.EmitIntValue(Major, 4); // desc
OS.EmitIntValue(Minor, 4);
OS.EmitValueToAlignment(4);
OS.PopSection();
@@ -124,7 +125,6 @@ AMDGPUTargetELFStreamer::EmitDirectiveHS
MCSectionELF *Note =
OS.getContext().getELFSection(".note", ELF::SHT_NOTE, ELF::SHF_ALLOC);
- unsigned NameSZ = 4;
uint16_t VendorNameSize = VendorName.size() + 1;
uint16_t ArchNameSize = ArchName.size() + 1;
unsigned DescSZ = sizeof(VendorNameSize) + sizeof(ArchNameSize) +
@@ -133,11 +133,12 @@ AMDGPUTargetELFStreamer::EmitDirectiveHS
OS.PushSection();
OS.SwitchSection(Note);
- OS.EmitIntValue(NameSZ, 4); // namesz
- OS.EmitIntValue(DescSZ, 4); // descsz
- OS.EmitIntValue(NT_AMDGPU_HSA_ISA, 4); // type
- OS.EmitBytes(StringRef("AMD", 4)); // name
- OS.EmitIntValue(VendorNameSize, 2); // desc
+ OS.EmitIntValue(strlen(NoteName) + 1, 4); // namesz
+ OS.EmitIntValue(DescSZ, 4); // descsz
+ OS.EmitIntValue(NT_AMDGPU_HSA_ISA, 4); // type
+ OS.EmitBytes(StringRef(NoteName, strlen(NoteName) + 1)); // name
+ OS.EmitValueToAlignment(4);
+ OS.EmitIntValue(VendorNameSize, 2); // desc
OS.EmitIntValue(ArchNameSize, 2);
OS.EmitIntValue(Major, 4);
OS.EmitIntValue(Minor, 4);
Modified: llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.h?rev=284760&r1=284759&r2=284760&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.h Thu Oct 20 13:22:36 2016
@@ -71,6 +71,7 @@ class AMDGPUTargetELFStreamer : public A
NT_AMDGPU_HSA_HLDEBUG_TARGET = 102
};
+ static const char *NoteName;
MCStreamer &Streamer;
public:
More information about the llvm-commits
mailing list