[llvm] 288ea82 - [AMDGPU] Refactor AMDGPUTargetStreamer::EmitCodeEnd
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 9 11:02:36 PST 2021
Author: Jay Foad
Date: 2021-03-09T19:02:18Z
New Revision: 288ea820cf4a7a946ce55166bee6f46504576cc8
URL: https://github.com/llvm/llvm-project/commit/288ea820cf4a7a946ce55166bee6f46504576cc8
DIFF: https://github.com/llvm/llvm-project/commit/288ea820cf4a7a946ce55166bee6f46504576cc8.diff
LOG: [AMDGPU] Refactor AMDGPUTargetStreamer::EmitCodeEnd
Refactor and add comments to explain where the magic numbers come from
in terms of the instruction cache line size. NFC.
Differential Revision: https://reviews.llvm.org/D98266
Added:
Modified:
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
index 842356008a4c..54bcd6cafa61 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
@@ -264,15 +264,21 @@ bool AMDGPUTargetAsmStreamer::EmitCodeEnd(const MCSubtargetInfo &STI) {
const uint32_t Encoded_s_code_end = 0xbf9f0000;
const uint32_t Encoded_s_nop = 0xbf800000;
uint32_t Encoded_pad = Encoded_s_code_end;
- unsigned FillSize = 48;
+
+ // Instruction cache line size in bytes.
+ const unsigned Log2CacheLineSize = 6;
+ const unsigned CacheLineSize = 1u << Log2CacheLineSize;
+
+ // Extra padding amount in bytes to support prefetch mode 3.
+ unsigned FillSize = 3 * CacheLineSize;
if (AMDGPU::isGFX90A(STI)) {
Encoded_pad = Encoded_s_nop;
- FillSize = 256;
+ FillSize = 16 * CacheLineSize;
}
- OS << "\t.p2alignl 6, " << Encoded_pad << '\n';
- OS << "\t.fill " << FillSize << ", 4, " << Encoded_pad << '\n';
+ OS << "\t.p2alignl " << Log2CacheLineSize << ", " << Encoded_pad << '\n';
+ OS << "\t.fill " << (FillSize / 4) << ", 4, " << Encoded_pad << '\n';
return true;
}
@@ -641,17 +647,23 @@ bool AMDGPUTargetELFStreamer::EmitCodeEnd(const MCSubtargetInfo &STI) {
const uint32_t Encoded_s_code_end = 0xbf9f0000;
const uint32_t Encoded_s_nop = 0xbf800000;
uint32_t Encoded_pad = Encoded_s_code_end;
- unsigned FillSize = 48;
+
+ // Instruction cache line size in bytes.
+ const unsigned Log2CacheLineSize = 6;
+ const unsigned CacheLineSize = 1u << Log2CacheLineSize;
+
+ // Extra padding amount in bytes to support prefetch mode 3.
+ unsigned FillSize = 3 * CacheLineSize;
if (AMDGPU::isGFX90A(STI)) {
Encoded_pad = Encoded_s_nop;
- FillSize = 256;
+ FillSize = 16 * CacheLineSize;
}
MCStreamer &OS = getStreamer();
OS.PushSection();
- OS.emitValueToAlignment(64, Encoded_pad, 4);
- for (unsigned I = 0; I < FillSize; ++I)
+ OS.emitValueToAlignment(CacheLineSize, Encoded_pad, 4);
+ for (unsigned I = 0; I < FillSize; I += 4)
OS.emitInt32(Encoded_pad);
OS.PopSection();
return true;
More information about the llvm-commits
mailing list