Skip to content
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

[NFC] Use llvm::StringSwitch maybe? #2

Closed
wants to merge 6 commits into from

Conversation

llvm-beanz
Copy link
Owner

This replaces a hand-rolled string parser with an
llvm::StringSwitch that matches full strings. This should be more resilient and maintainable.

@llvm-beanz llvm-beanz changed the title [NFC] Use llvm::StringSwitch [NFC] Use llvm::StringSwitch maybe? Sep 20, 2023
@llvm-beanz llvm-beanz force-pushed the cbieneman/use-stringswitch branch 17 times, most recently from 5f9b327 to 72f1017 Compare September 21, 2023 01:46
@github-actions
Copy link

PR contains clang-format violations. First 50 lines of the diff:

--- tools/clang/lib/SPIRV/SpirvEmitter.cpp	(before formatting)
+++ tools/clang/lib/SPIRV/SpirvEmitter.cpp	(after formatting)
@@ -12054,24 +12054,24 @@
   return nullptr;
 }
 
-hlsl::ShaderModel::Kind SpirvEmitter::getShaderModelKind(StringRef stageName)
-{
-  hlsl::ShaderModel::Kind SMK = llvm::StringSwitch<hlsl::ShaderModel::Kind>(stageName)
-      .Case("pixel", hlsl::ShaderModel::Kind::Pixel)
-      .Case("vertex", hlsl::ShaderModel::Kind::Vertex)
-      .Case("geometry", hlsl::ShaderModel::Kind::Geometry)
-      .Case("hull", hlsl::ShaderModel::Kind::Hull)
-      .Case("domain", hlsl::ShaderModel::Kind::Domain)
-      .Case("compute", hlsl::ShaderModel::Kind::Compute)
-      .Case("raygeneration", hlsl::ShaderModel::Kind::RayGeneration)
-      .Case("intersection", hlsl::ShaderModel::Kind::Intersection)
-      .Case("anyhit", hlsl::ShaderModel::Kind::AnyHit)
-      .Case("closesthit", hlsl::ShaderModel::Kind::ClosestHit)
-      .Case("miss", hlsl::ShaderModel::Kind::Miss)
-      .Case("callable", hlsl::ShaderModel::Kind::Callable)
-      .Case("mesh", hlsl::ShaderModel::Kind::Mesh)
-      .Case("amplification", hlsl::ShaderModel::Kind::Amplification)
-      .Default(hlsl::ShaderModel::Kind::Invalid);
+hlsl::ShaderModel::Kind SpirvEmitter::getShaderModelKind(StringRef stageName) {
+  hlsl::ShaderModel::Kind SMK =
+      llvm::StringSwitch<hlsl::ShaderModel::Kind>(stageName)
+          .Case("pixel", hlsl::ShaderModel::Kind::Pixel)
+          .Case("vertex", hlsl::ShaderModel::Kind::Vertex)
+          .Case("geometry", hlsl::ShaderModel::Kind::Geometry)
+          .Case("hull", hlsl::ShaderModel::Kind::Hull)
+          .Case("domain", hlsl::ShaderModel::Kind::Domain)
+          .Case("compute", hlsl::ShaderModel::Kind::Compute)
+          .Case("raygeneration", hlsl::ShaderModel::Kind::RayGeneration)
+          .Case("intersection", hlsl::ShaderModel::Kind::Intersection)
+          .Case("anyhit", hlsl::ShaderModel::Kind::AnyHit)
+          .Case("closesthit", hlsl::ShaderModel::Kind::ClosestHit)
+          .Case("miss", hlsl::ShaderModel::Kind::Miss)
+          .Case("callable", hlsl::ShaderModel::Kind::Callable)
+          .Case("mesh", hlsl::ShaderModel::Kind::Mesh)
+          .Case("amplification", hlsl::ShaderModel::Kind::Amplification)
+          .Default(hlsl::ShaderModel::Kind::Invalid);
   assert(SMK != hlsl::ShaderModel::Kind::Invalid);
   return SMK;
 }

See action log for the full diff.

python3kgae and others added 2 commits September 20, 2023 22:40
There were a few bugs that were difficult to reproduce. The pull request
branch ref needs to be fetched and checked out manually in order to get
the PR diff to construct. This change also fixes formatting to get a
nice diff printed of the PR output.

See an example of the error output this produces here:

#2
@llvm-beanz llvm-beanz force-pushed the cbieneman/use-stringswitch branch from 395ee1c to c7de16e Compare September 21, 2023 16:56
amaiorano and others added 3 commits September 21, 2023 13:36
When building with apple-clang on MacOS, we get a linker error:

ld64.lld: error: undefined symbol: llvm_assert

Because the llvm_assert implementation is missing the last parameter.
This replaces a hand-rolled string parser with an
llvm::StringSwitch that matches full strings. This should be more
resilient and maintainable.
@llvm-beanz llvm-beanz force-pushed the cbieneman/use-stringswitch branch from c7de16e to 716bfcc Compare September 21, 2023 18:02
@llvm-beanz llvm-beanz closed this Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants