[NFC] This patch adds features for pwr7, pwr8, and pwr9 that can be
used for semachecking builtin functions that are only valid for certain
versions of ppc.
Details
- Reviewers
nemanjai stefanp - Group Reviewers
Restricted Project - Commits
- rG781929b4236b: [PowerPC][NFC] Power ISA features for Semachecking
rG10e0cdfc6526: [PowerPC][NFC] Power ISA features for Semachecking
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Can you please add a test for this similar to clang/test/Driver/ppc-pcrel.cpp and other similar tests?
Also, I imagine this will produce some warnings from the back end since the back end doesn't know what these target features mean. Can you please see what happens when you try to compile something after this patch?
clang/lib/Basic/Targets/PPC.cpp | ||
---|---|---|
452 | Will it be better if name to isa2_07, isa3_0 to make it less confusing? Besides, in backend we have subtarget features isa-v30-instructions and isa-v31-instructions but they're not present at frontend, we should pass these feature flags to backend correctly. |
Parameterizing the ppc builtin arch sema error.
This change is made assuming that the SemaFeatureCheck will be used by other builtins in the future. SemaFeatureCheck is commented to avoid an unused function error when building the compiler. SemaArchFeatureCheck can be used to semacheck builtins which require a minimum version of PPC and require a feature to be enabled.
clang/lib/Sema/SemaChecking.cpp | ||
---|---|---|
3277–3278 | I don't think we need another function here. Simply passing a StringRef parameter to the other one that will have a default value of empty should suffice. Then if the parameter is non-empty, we push it into the diagnostic. if (!S.Context.getTargetInfo().hasFeature(FeatureToCheck)) { S.Diag(TheCall->getBeginLoc(), DiagID); if (!DiagArg.empty()) Diag << DiagArg; Diag << TheCall->getSourceRange(); return true; } (keep in mind that I don't know if I've adequately captured how DiagnosticBuilder works, but something along these lines should be possible). Then of course, the calls to this would be with "7" rather than 7. |
clang/lib/Sema/SemaChecking.cpp | ||
---|---|---|
3279 | may I suggest early exit instead? if (S.Context.getTargetInfo().hasFeature(FeatureToCheck)) return false; if (DiagArg.empty()) S.Diag(TheCall->getBeginLoc(), DiagID) << TheCall->getSourceRange(); else S.Diag(TheCall->getBeginLoc(), DiagID) << DiagArg << TheCall->getSourceRange(); return true; |
The testing is a bit overkill. A single test case with run lines for -mcpu=pwr7-10 and a single prefix for each should suffice. For each prefix, just check for +/- for all the features you expect. The triples can be randomly distributed across the 4 run lines.
And yes, please use early exit as Lei pointed out.
Addressing review comments.
Using an early exit for SemaFeatureCheck and combining the 3 test cases into 1.
Will it be better if name to isa2_07, isa3_0 to make it less confusing?
Besides, in backend we have subtarget features isa-v30-instructions and isa-v31-instructions but they're not present at frontend, we should pass these feature flags to backend correctly.