From b5e0d1514837f6f2aa9c922f84e668a0b4d782e7 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 27 Apr 2025 00:18:01 -0700 Subject: [PATCH] [AMDGPU] Simplify PrintField::printField (NFC) We can use "constexpr if" to combine the two variants of functions. --- .../AMDGPU/Utils/AMDKernelCodeTUtils.cpp | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp index b05696d2dfa05..8997911aa8ae1 100644 --- a/llvm/lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp +++ b/llvm/lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp @@ -222,22 +222,17 @@ static int get_amd_kernel_code_t_FieldIndex(StringRef name) { class PrintField { public: - template , T> * = nullptr> + template static void printField(StringRef Name, const AMDGPUMCKernelCodeT &C, raw_ostream &OS, MCContext &Ctx, AMDGPUMCKernelCodeT::PrintHelper Helper) { - OS << Name << " = "; - const MCExpr *Value = C.*ptr; - Helper(Value, OS, Ctx.getAsmInfo()); - } - - template , T> * = nullptr> - static void printField(StringRef Name, const AMDGPUMCKernelCodeT &C, - raw_ostream &OS, MCContext &, - AMDGPUMCKernelCodeT::PrintHelper) { - OS << Name << " = " << (int)(C.*ptr); + if constexpr (!std::is_integral_v) { + OS << Name << " = "; + const MCExpr *Value = C.*ptr; + Helper(Value, OS, Ctx.getAsmInfo()); + } else { + OS << Name << " = " << (int)(C.*ptr); + } } };