[llvm] [DirectX] Follow naming conventions for enumerators in DXILABI.h. NFC (PR #86237)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 21 20:20:33 PDT 2024
https://github.com/bogner created https://github.com/llvm/llvm-project/pull/86237
These all-caps names differ from the llvm naming conventions for no good reason, and `VOID` in all caps can cause problems in windows environments (see [1]). Rename them to UpperCamelCase.
[1]: https://github.com/clangd/clangd/issues/1983
>From 01cab7b04f2d95273a6512ba8eedb68bb73d381c Mon Sep 17 00:00:00 2001
From: Justin Bogner <mail at justinbogner.com>
Date: Thu, 21 Mar 2024 20:11:21 -0700
Subject: [PATCH] [DirectX] Follow naming conventions for enumerators in
DXILABI.h. NFC
These all-caps names differ from the llvm naming conventions for no
good reason, and `VOID` in all caps can cause problems in windows
environments (see [1]). Rename them to UpperCamelCase.
[1]: https://github.com/clangd/clangd/issues/1983
---
llvm/include/llvm/Support/DXILABI.h | 18 ++++----
llvm/lib/Target/DirectX/DXILOpBuilder.cpp | 18 ++++----
llvm/utils/TableGen/DXILEmitter.cpp | 50 +++++++++++------------
3 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/llvm/include/llvm/Support/DXILABI.h b/llvm/include/llvm/Support/DXILABI.h
index c1d81775b6711e..da4bea8fc46e3a 100644
--- a/llvm/include/llvm/Support/DXILABI.h
+++ b/llvm/include/llvm/Support/DXILABI.h
@@ -23,20 +23,20 @@ namespace llvm {
namespace dxil {
enum class ParameterKind : uint8_t {
- INVALID = 0,
- VOID,
- HALF,
- FLOAT,
- DOUBLE,
+ Invalid = 0,
+ Void,
+ Half,
+ Float,
+ Double,
I1,
I8,
I16,
I32,
I64,
- OVERLOAD,
- CBUFFER_RET,
- RESOURCE_RET,
- DXIL_HANDLE,
+ Overload,
+ CBufferRet,
+ ResourceRet,
+ DXILHandle,
};
/// The kind of resource for an SRV or UAV resource. Sometimes referred to as
diff --git a/llvm/lib/Target/DirectX/DXILOpBuilder.cpp b/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
index a1eacc2d48009c..0841ae95423c7b 100644
--- a/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
+++ b/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
@@ -190,13 +190,13 @@ static StructType *getHandleType(LLVMContext &Ctx) {
static Type *getTypeFromParameterKind(ParameterKind Kind, Type *OverloadTy) {
auto &Ctx = OverloadTy->getContext();
switch (Kind) {
- case ParameterKind::VOID:
+ case ParameterKind::Void:
return Type::getVoidTy(Ctx);
- case ParameterKind::HALF:
+ case ParameterKind::Half:
return Type::getHalfTy(Ctx);
- case ParameterKind::FLOAT:
+ case ParameterKind::Float:
return Type::getFloatTy(Ctx);
- case ParameterKind::DOUBLE:
+ case ParameterKind::Double:
return Type::getDoubleTy(Ctx);
case ParameterKind::I1:
return Type::getInt1Ty(Ctx);
@@ -208,11 +208,11 @@ static Type *getTypeFromParameterKind(ParameterKind Kind, Type *OverloadTy) {
return Type::getInt32Ty(Ctx);
case ParameterKind::I64:
return Type::getInt64Ty(Ctx);
- case ParameterKind::OVERLOAD:
+ case ParameterKind::Overload:
return OverloadTy;
- case ParameterKind::RESOURCE_RET:
+ case ParameterKind::ResourceRet:
return getResRetType(OverloadTy, Ctx);
- case ParameterKind::DXIL_HANDLE:
+ case ParameterKind::DXILHandle:
return getHandleType(Ctx);
default:
break;
@@ -320,8 +320,8 @@ Type *DXILOpBuilder::getOverloadTy(dxil::OpCode OpCode, FunctionType *FT) {
auto ParamKinds = getOpCodeParameterKind(*Prop);
auto Kind = ParamKinds[Prop->OverloadParamIndex];
// For ResRet and CBufferRet, OverloadTy is in field of StructType.
- if (Kind == ParameterKind::CBUFFER_RET ||
- Kind == ParameterKind::RESOURCE_RET) {
+ if (Kind == ParameterKind::CBufferRet ||
+ Kind == ParameterKind::ResourceRet) {
auto *ST = cast<StructType>(OverloadType);
OverloadType = ST->getElementType(0);
}
diff --git a/llvm/utils/TableGen/DXILEmitter.cpp b/llvm/utils/TableGen/DXILEmitter.cpp
index af1efb8aa99f73..9adeca821ff5ef 100644
--- a/llvm/utils/TableGen/DXILEmitter.cpp
+++ b/llvm/utils/TableGen/DXILEmitter.cpp
@@ -74,13 +74,13 @@ static ParameterKind getParameterKind(const Record *R) {
auto VTRec = R->getValueAsDef("VT");
switch (getValueType(VTRec)) {
case MVT::isVoid:
- return ParameterKind::VOID;
+ return ParameterKind::Void;
case MVT::f16:
- return ParameterKind::HALF;
+ return ParameterKind::Half;
case MVT::f32:
- return ParameterKind::FLOAT;
+ return ParameterKind::Float;
case MVT::f64:
- return ParameterKind::DOUBLE;
+ return ParameterKind::Double;
case MVT::i1:
return ParameterKind::I1;
case MVT::i8:
@@ -91,11 +91,11 @@ static ParameterKind getParameterKind(const Record *R) {
return ParameterKind::I32;
case MVT::fAny:
case MVT::iAny:
- return ParameterKind::OVERLOAD;
+ return ParameterKind::Overload;
case MVT::Other:
// Handle DXIL-specific overload types
if (R->getValueAsInt("isHalfOrFloat") || R->getValueAsInt("isI16OrI32")) {
- return ParameterKind::OVERLOAD;
+ return ParameterKind::Overload;
}
LLVM_FALLTHROUGH;
default:
@@ -201,16 +201,16 @@ DXILOperationDesc::DXILOperationDesc(const Record *R) {
/// \return std::string string representation of input Kind
static std::string getParameterKindStr(ParameterKind Kind) {
switch (Kind) {
- case ParameterKind::INVALID:
- return "INVALID";
- case ParameterKind::VOID:
- return "VOID";
- case ParameterKind::HALF:
- return "HALF";
- case ParameterKind::FLOAT:
- return "FLOAT";
- case ParameterKind::DOUBLE:
- return "DOUBLE";
+ case ParameterKind::Invalid:
+ return "Invalid";
+ case ParameterKind::Void:
+ return "Void";
+ case ParameterKind::Half:
+ return "Half";
+ case ParameterKind::Float:
+ return "Float";
+ case ParameterKind::Double:
+ return "Double";
case ParameterKind::I1:
return "I1";
case ParameterKind::I8:
@@ -221,14 +221,14 @@ static std::string getParameterKindStr(ParameterKind Kind) {
return "I32";
case ParameterKind::I64:
return "I64";
- case ParameterKind::OVERLOAD:
- return "OVERLOAD";
- case ParameterKind::CBUFFER_RET:
- return "CBUFFER_RET";
- case ParameterKind::RESOURCE_RET:
- return "RESOURCE_RET";
- case ParameterKind::DXIL_HANDLE:
- return "DXIL_HANDLE";
+ case ParameterKind::Overload:
+ return "Overload";
+ case ParameterKind::CBufferRet:
+ return "CBufferRet";
+ case ParameterKind::ResourceRet:
+ return "ResourceRet";
+ case ParameterKind::DXILHandle:
+ return "DXILHandle";
}
llvm_unreachable("Unknown llvm::dxil::ParameterKind enum");
}
@@ -462,7 +462,7 @@ static void emitDXILOperationTable(std::vector<DXILOperationDesc> &Ops,
[](raw_ostream &ParamOS, ParameterKind Kind) {
ParamOS << "ParameterKind::" << getParameterKindStr(Kind);
},
- "ParameterKind::INVALID");
+ "ParameterKind::Invalid");
OS << " };\n\n";
OS << " unsigned Index = Prop.ParameterTableOffset;\n";
OS << " return DXILOpParameterKindTable + Index;\n";
More information about the llvm-commits
mailing list