-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DirectX] Follow naming conventions for enumerators in DXILABI.h. NFC #86237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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]: clangd/clangd#1983
@llvm/pr-subscribers-llvm-support @llvm/pr-subscribers-backend-directx Author: Justin Bogner (bogner) ChangesThese all-caps names differ from the llvm naming conventions for no good reason, and Full diff: https://github.com/llvm/llvm-project/pull/86237.diff 3 Files Affected:
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";
|
You can test this locally with the following command:git-clang-format --diff 40beb9b001a3c67c60b98fae9e999dcaa2d88717 01cab7b04f2d95273a6512ba8eedb68bb73d381c -- llvm/include/llvm/Support/DXILABI.h llvm/lib/Target/DirectX/DXILOpBuilder.cpp llvm/utils/TableGen/DXILEmitter.cpp View the diff from clang-format here.diff --git a/llvm/lib/Target/DirectX/DXILOpBuilder.cpp b/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
index 0841ae9542..6949382bc1 100644
--- a/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
+++ b/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
@@ -320,8 +320,7 @@ 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::CBufferRet ||
- Kind == ParameterKind::ResourceRet) {
+ if (Kind == ParameterKind::CBufferRet || Kind == ParameterKind::ResourceRet) {
auto *ST = cast<StructType>(OverloadType);
OverloadType = ST->getElementType(0);
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks WAY better than the all caps version.
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.