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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/clang-format-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: install clang-format
run: sudo apt install -y clang-format
- name: Comparing PR against target branch
env:
PR_NUMBER: ${{ github.event.number }}
GH_TOKEN: ${{ github.token }}
run: |
echo Comparing $GITHUB_BASE_REF vs HEAD
git diff -U0 --no-color origin/$GITHUB_BASE_REF..HEAD | clang-format-diff -p1 | tee format.diff
if [ -s "format.diff" ]
echo Comparing $PR_NUMBER vs target branch
git fetch origin refs/pull/$PR_NUMBER/head:pull/$PR_NUMBER
git checkout pull/$PR_NUMBER
git diff -U0 --no-color $GITHUB_REF..pull/$PR_NUMBER | clang-format-diff-15 -p1 | tee format.diff
if [ -s format.diff ]
then
echo PR contains clang-format violations. First 50 lines of the diff: >> message.txt
echo ``` >> message.txt
echo \`\`\`diff >> message.txt
cat format.diff | head -n 50 >> message.txt
echo ``` >> message.txt
echo See [action log]\(https://github.com/microsoft/DirectXShaderCompiler/actions/runs/$GITHUB_RUN_ID/job/$GITHUB_JOB\) for the full diff. >> message.txt
echo \`\`\` >> message.txt
echo See [action log]\(https://github.com/microsoft/DirectXShaderCompiler/actions/runs/$GITHUB_RUN_ID/\) for the full diff. >> message.txt
gh pr comment $PR_NUMBER --body-file message.txt
exit 1
fi
3 changes: 2 additions & 1 deletion lib/Support/assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ void llvm_assert(const char *_Message, const char *_File, unsigned _Line,

#include <assert.h>

void llvm_assert(const char *message, const char *, unsigned) {
void llvm_assert(const char *message, const char *, unsigned,
const char *_Function) {
assert(false && message);
}

Expand Down
86 changes: 19 additions & 67 deletions tools/clang/lib/SPIRV/SpirvEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12055,73 +12055,25 @@ SpirvConstant *SpirvEmitter::tryToEvaluateAsConst(const Expr *expr) {
}

hlsl::ShaderModel::Kind SpirvEmitter::getShaderModelKind(StringRef stageName) {
hlsl::ShaderModel::Kind smk;
switch (stageName[0]) {
case 'c':
switch (stageName[1]) {
case 'o':
smk = hlsl::ShaderModel::Kind::Compute;
break;
case 'l':
smk = hlsl::ShaderModel::Kind::ClosestHit;
break;
case 'a':
smk = hlsl::ShaderModel::Kind::Callable;
break;
default:
smk = hlsl::ShaderModel::Kind::Invalid;
break;
}
break;
case 'v':
smk = hlsl::ShaderModel::Kind::Vertex;
break;
case 'h':
smk = hlsl::ShaderModel::Kind::Hull;
break;
case 'd':
smk = hlsl::ShaderModel::Kind::Domain;
break;
case 'g':
smk = hlsl::ShaderModel::Kind::Geometry;
break;
case 'p':
smk = hlsl::ShaderModel::Kind::Pixel;
break;
case 'r':
smk = hlsl::ShaderModel::Kind::RayGeneration;
break;
case 'i':
smk = hlsl::ShaderModel::Kind::Intersection;
break;
case 'a':
switch (stageName[1]) {
case 'm':
smk = hlsl::ShaderModel::Kind::Amplification;
break;
case 'n':
smk = hlsl::ShaderModel::Kind::AnyHit;
break;
}
break;
case 'm':
switch (stageName[1]) {
case 'e':
smk = hlsl::ShaderModel::Kind::Mesh;
break;
case 'i':
smk = hlsl::ShaderModel::Kind::Miss;
break;
}
break;
default:
smk = hlsl::ShaderModel::Kind::Invalid;
break;
}
if (smk == hlsl::ShaderModel::Kind::Invalid) {
llvm_unreachable("unknown stage name");
}
return smk;
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;
}

spv::ExecutionModel
Expand Down
2 changes: 1 addition & 1 deletion tools/clang/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ add_lit_testsuite(check-clang "Running the Clang regression tests"
${CMAKE_CURRENT_BINARY_DIR}
#LIT ${LLVM_LIT}
PARAMS ${CLANG_TEST_PARAMS}
skip_taef_exec=True
skip_taef_exec=False
DEPENDS ${CLANG_TEST_DEPS}
ARGS ${CLANG_TEST_EXTRA_ARGS}
)
Expand Down
5 changes: 5 additions & 0 deletions utils/hct/hcttest.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ if "%TEST_USE_LIT%"=="1" (
cmake --build %HLSL_BLD_DIR% --config %BUILD_CONFIG% --target check-all
set RES_CLANG=!ERRORLEVEL!
set RES_DXILCONV=!RES_CLANG!
rem check exec.
if defined EXEC_ADAPTER (
echo The -adapter parameter is supported only when running just execution tests ^(hcttest.cmd exec^)
)
set RES_EXEC=!ERRORLEVEL!
) else (
if "%TEST_DXILCONV%"=="1" (
cmake --build %HLSL_BLD_DIR% --config %BUILD_CONFIG% --target check-dxilconv
Expand Down