diff --git a/llvm/include/llvm/MC/MCDecoder.h b/llvm/include/llvm/MC/MCDecoder.h index 459c8a6a5ea34..87df6c10d8bb2 100644 --- a/llvm/include/llvm/MC/MCDecoder.h +++ b/llvm/include/llvm/MC/MCDecoder.h @@ -72,13 +72,6 @@ insertBits(IntType &field, IntType bits, unsigned startBit, unsigned numBits) { field |= bits << startBit; } -// InsnBitWidth is essentially a type trait used by the decoder emitter to query -// the supported bitwidth for a given type. But default, the value is 0, making -// it an invalid type for use as `InsnType` when instantiating the decoder. -// Individual targets are expected to provide specializations for these based -// on their usage. -template static constexpr uint32_t InsnBitWidth = 0; - } // namespace llvm::MCD #endif // LLVM_MC_MCDECODER_H diff --git a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp index 2dc607608b80c..bb9f811683255 100644 --- a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp +++ b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp @@ -447,13 +447,13 @@ static DecodeStatus decodeVersionImm(MCInst &Inst, unsigned Imm, #include "AMDGPUGenDisassemblerTables.inc" +namespace { // Define bitwidths for various types used to instantiate the decoder. -template <> inline constexpr uint32_t llvm::MCD::InsnBitWidth = 32; -template <> inline constexpr uint32_t llvm::MCD::InsnBitWidth = 64; -template <> -inline constexpr uint32_t llvm::MCD::InsnBitWidth> = 96; -template <> -inline constexpr uint32_t llvm::MCD::InsnBitWidth> = 128; +template <> constexpr uint32_t InsnBitWidth = 32; +template <> constexpr uint32_t InsnBitWidth = 64; +template <> constexpr uint32_t InsnBitWidth> = 96; +template <> constexpr uint32_t InsnBitWidth> = 128; +} // namespace //===----------------------------------------------------------------------===// // diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp index 987d6c7e1900a..b1b7ea5246fda 100644 --- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp +++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp @@ -701,11 +701,13 @@ static constexpr DecoderListEntry DecoderList32[]{ {DecoderTableZdinxRV32Only32, {}, "RV32-only Zdinx (Double in Integer)"}, }; +namespace { // Define bitwidths for various types used to instantiate the decoder. -template <> inline constexpr uint32_t llvm::MCD::InsnBitWidth = 16; -template <> inline constexpr uint32_t llvm::MCD::InsnBitWidth = 32; +template <> constexpr uint32_t InsnBitWidth = 16; +template <> constexpr uint32_t InsnBitWidth = 32; // Use uint64_t to represent 48 bit instructions. -template <> inline constexpr uint32_t llvm::MCD::InsnBitWidth = 48; +template <> constexpr uint32_t InsnBitWidth = 48; +} // namespace DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size, ArrayRef Bytes, diff --git a/llvm/utils/TableGen/DecoderEmitter.cpp b/llvm/utils/TableGen/DecoderEmitter.cpp index 354c2a788d5b1..fcaf433918092 100644 --- a/llvm/utils/TableGen/DecoderEmitter.cpp +++ b/llvm/utils/TableGen/DecoderEmitter.cpp @@ -2479,6 +2479,14 @@ void DecoderEmitter::run(raw_ostream &o) const { #include namespace { + +// InsnBitWidth is essentially a type trait used by the decoder emitter to query +// the supported bitwidth for a given type. But default, the value is 0, making +// it an invalid type for use as `InsnType` when instantiating the decoder. +// Individual targets are expected to provide specializations for these based +// on their usage. +template constexpr uint32_t InsnBitWidth = 0; + )"; // Do extra bookkeeping for variable-length encodings.