[clang] [HLSL] Default and Relaxed Availability Diagnostics (PR #92704)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Wed May 29 16:54:47 PDT 2024
================
@@ -1060,18 +1060,25 @@ static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
.Case("ShaderModel", "shadermodel")
.Default(Platform);
}
-static llvm::StringRef getPrettyEnviromentName(llvm::StringRef Environment) {
- return llvm::StringSwitch<llvm::StringRef>(Environment)
- .Case("pixel", "pixel shader")
- .Case("vertex", "vertex shader")
- .Case("geometry", "geometry shader")
- .Case("hull", "hull shader")
- .Case("domain", "domain shader")
- .Case("compute", "compute shader")
- .Case("mesh", "mesh shader")
- .Case("amplification", "amplification shader")
- .Case("library", "shader library")
- .Default(Environment);
+static llvm::StringRef getPrettyEnviromentName(llvm::Triple::EnvironmentType EnvironmentType) {
+ switch (EnvironmentType) {
+ case llvm::Triple::Pixel: return "pixel shader";
+ case llvm::Triple::Vertex: return "vertex shader";
+ case llvm::Triple::Geometry: return "geometry shader";
+ case llvm::Triple::Hull: return "hull shader";
+ case llvm::Triple::Domain: return "domain shader";
+ case llvm::Triple::Compute: return "compute shader";
+ case llvm::Triple::RayGeneration: return "raygeneration shader";
+ case llvm::Triple::Intersection: return "intersection shader";
+ case llvm::Triple::AnyHit: return "anyhit shader";
+ case llvm::Triple::ClosestHit: return "closesthit shader";
+ case llvm::Triple::Miss: return "miss shader";
+ case llvm::Triple::Callable: return "callable shader";
+ case llvm::Triple::Mesh: return "mesh shader";
+ case llvm::Triple::Amplification: return "amplification shader";
+ case llvm::Triple::Library: return "shader library";
+ default: return "";
+ }
----------------
llvm-beanz wrote:
This function is really just doing the same thing as `Triple::getEnvironmentTypeName`, but instead of "pixel" it returns "pixel shader". Is that worth the code duplication? We could instead write this function as:
```suggestion
static llvm::StringRef getPrettyEnviromentName(llvm::Triple::EnvironmentType EnvironmentType) {
if (EnvironmentType >= Pixel && EnvironmentType <= Amplification)
return Triple::getEnvironmentTypeName(EnvironmentType)
return "";
}
```
https://github.com/llvm/llvm-project/pull/92704
More information about the cfe-commits
mailing list