Skip to content

Commit

Permalink
[DirectX] Follow naming conventions for enumerators in DXILABI.h. NFC (
Browse files Browse the repository at this point in the history
…#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]: clangd/clangd#1983
  • Loading branch information
bogner committed Mar 25, 2024
1 parent 2039268 commit a83ed04
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
18 changes: 9 additions & 9 deletions llvm/include/llvm/Support/DXILABI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions llvm/lib/Target/DirectX/DXILOpBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
50 changes: 25 additions & 25 deletions llvm/utils/TableGen/DXILEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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");
}
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit a83ed04

Please sign in to comment.