This revision supports --print-supported-extensions,
it prints out all of the extensions and corresponding version supported.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Support/RISCVISAInfo.cpp | ||
---|---|---|
210 | Question for the community. Should we maintain SupportedExtensions in the order we want printed instead of sorting? |
clang/lib/Driver/Driver.cpp | ||
---|---|---|
4305–4309 | Plz did the similar action like what OPT_print_supported_cpus did instead of just exti 0 And check the triple to make sure only invoke that for riscv | |
llvm/lib/Support/RISCVISAInfo.cpp | ||
209 | I would prefer that print by canonical order *IF* we want to print in some order. And then you can just use RISCVISAInfo::OrderedExtensionMap here. |
llvm/lib/Support/RISCVISAInfo.cpp | ||
---|---|---|
210 | +1 on Kito's suggestion to print by the canonical order. |
llvm/lib/Support/RISCVISAInfo.cpp | ||
---|---|---|
201 | void llvm::RISCVMarchHelp and remove the namespace llvm { |
clang/test/Driver/print-supported-marchs.c | ||
---|---|---|
17 ↗ | (On Diff #506062) | Use -NEXT: whenever applicable so that new extensions can be caught by the test. |
clang/tools/driver/cc1_main.cpp | ||
197 | The check should be added to lib/Driver | |
201 | riscvMarchHelp Use camelCase for new function names. | |
llvm/lib/Support/RISCVISAInfo.cpp | ||
220 | Move '\n' into the "Use -march to specify the target's extension.\n..." string. |
clang/tools/driver/cc1_main.cpp | ||
---|---|---|
197 | RISCV -> RISC-V in user facing messages. |
clang/tools/driver/cc1_main.cpp | ||
---|---|---|
189 | Why do we need to lookup the TargetRegistry? |
Aliasing -march=help to --print-supported-extensions looks weird. I think this patch should remove -march=help.
clang/test/Driver/print-supported-marchs.c | ||
---|---|---|
1 ↗ | (On Diff #508475) | The filename should be fixed. |
Created a GCC feature request: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109349
The subject and summary should be fixed and -march=help references should be removed.
clang/lib/Driver/Driver.cpp | ||
---|---|---|
4308 | The convention is to use Diag(...). | |
4312 | Why is the code needed? Can --print-supported-extensions reuse the approach of OPT_print_supported_cpus? |
I would support have -march=help, but I know it's really not make scene to alias -march=help to --print-supported-extensions for other targets, what about redirect that in Driver.cpp for RISC-V only?
clang/lib/Driver/Driver.cpp | ||
---|---|---|
4312 | Yes, this should reuse some code with the OPT_print_supported_cpus handler. |
Resolved MaskRay's comments.
Should we use @kito-cheng's approach to deal with -march=help? what do you think, @MaskRay ?
I hope that we add just one option, instead of aliases. Aliases are usually added for compatibility when something is deprecated or changed, not for new options.
My "Request Changes" status still holds. The patch hasn't fixed something obvious: the description mentions print-supported-marchs (well, it should really name the exact name, --print-supported-marchs, don't omit dashes) while the implementation uses ...extensions.
Rename clang/test/Driver/print-supported-marchs.c to clang/test/Driver/print-supported-extensions.c
clang/tools/driver/cc1_main.cpp | ||
---|---|---|
187–188 | Plz make sure only RISC-V print that, x86 or other target print RISC-V's ext is really weird. |
LGTM, consider about the GNU compatibility, I would that has -march=help form for that.
-march= -mcpu= -mtune= are from GCC and they traditionally have many opinions on the features.
If GCC is going to have -march=help, I think adding -march=help to Clang to match is fine.
But I'd really like to avoid aliases for non-compatibility reasons. They just cause confusion and make users undecided about which one is canonical.
Done. But this update still doesn't look quite polished. If -march=help is dropped, at the very least the subject needs to updated.
clang/tools/driver/cc1_main.cpp | ||
---|---|---|
187 | Use camelCase for new function names. StringRef TargetStr? | |
llvm/include/llvm/Support/RISCVISAInfo.h | ||
25 | This naming does not match the --print-supported-extensions option name. | |
llvm/lib/Support/RISCVISAInfo.cpp | ||
201 | For most --print-* options, the output goes to stdout instead of stderr. |
Please also mark resolved comments as done, otherwise reviewers can presume that some comments are unresolved and don't necessarily give another round of reviews.
clang/test/Driver/print-supported-extensions.c | ||
---|---|---|
6 ↗ | (On Diff #522411) | Use --implicit-check-not=warning: instead of // CHECK-NOT: warning: argument unused during compilation. We additionally check that there is no warning and the warning doesn't come after the output from --print-supported-extensions. |
6 ↗ | (On Diff #522411) | For a file with just one prefix, conventionally we just use the default CHECK and omit --check-prefix. Have you ever checked that the test detects issues? CHECK below are ignored with --check-prefix=CHECK-RISCV. |
clang/test/Driver/print-supported-extensions.c | ||
---|---|---|
1 ↗ | (On Diff #522411) | Some newer tests use /// to distinguish non-CHECK-non-RUN comments from others. This helps automation tools to catch wrong prefixes (e.g. with a typo) in comments and helps auto-generating checks in the future while retaining manual comments. |
3 ↗ | (On Diff #522411) | If you remove all and RISCV from LLVM_TARGETS_TO_BUILD, you can test whether this feature works without lib/Target/RISCV support. I suspect it works, so you may need another build for verification. |
10 ↗ | (On Diff #522411) | The formatting matters here. To test formatting see --strict-whitespace --match-full-lines (example: See llvm/test/tools/llvm-readobj/ELF/gnu-sections.txt): https://llvm.org/docs/CommandGuide/FileCheck.html |
clang/test/Driver/print-supported-extensions.c | ||
---|---|---|
6 ↗ | (On Diff #522411) | Oh, I missed it, CHECK-NEXT are all ignored... |
clang/test/Driver/print-supported-extensions.c | ||
---|---|---|
3 ↗ | (On Diff #522411) | No it cause an error if I use the command with the target without riscv such as: bin/clang --target=aarch64 --print-supported-extensions or bin/clang --target=x86 --print-supported-extensions |
Sorry for the delay.
clang/include/clang/Frontend/FrontendOptions.h | ||
---|---|---|
286 | ||
290 | stray change? | |
clang/test/Driver/print-supported-extensions.c | ||
6 ↗ | (On Diff #536947) | |
10 ↗ | (On Diff #536947) | For --strict-whitespace --match-full-lines testing, we usually right align CHECK and CHECK-NEXT. |
clang/tools/driver/cc1_main.cpp | ||
187 | printSupportedExtensions. Why does this function return a dummy return value? You can do return printSupportedExtensions(), 0 below to save some lines. | |
llvm/lib/Support/RISCVISAInfo.cpp | ||
214 | I think outs() is more conventional. Most gcc --print-* options go to stdout. clang --print-supported-cpus deviates and we should not copy its issue. |
clang/lib/Driver/Driver.cpp | ||
---|---|---|
4301 | no blank line here | |
clang/test/Driver/print-supported-extensions.c | ||
93 ↗ | (On Diff #545412) | //CHECK-EMPTY: |
120 ↗ | (On Diff #545412) | //CHECK-EMPTY: |
clang/tools/driver/cc1_main.cpp | ||
187 | The call site should just call riscvExtensionsHelp so that this internal linkage function can be avoided. | |
190 | one blank line | |
190 | one blank line | |
llvm/lib/Support/RISCVISAInfo.cpp | ||
219 | clang-format will remove the space after { |
Resolved MaskRay's comments.
clang/include/clang/Frontend/FrontendOptions.h | ||
---|---|---|
290 | Oh, maybe it was added accidentally during rebase lol~ | |
clang/test/Driver/print-supported-extensions.c | ||
10 ↗ | (On Diff #536947) | Oh, I got it, thanks! |
clang/tools/driver/cc1_main.cpp | ||
187 | This is a good idea, return in its caller is much clear for it's intension! | |
187 | Yeah, good idea! | |
llvm/lib/Support/RISCVISAInfo.cpp | ||
214 | Sure, I agree to keep it conventional, since I was following --print-supported-cpus so I made it this way, thank you for pointing out this! |
I think the best place to test RISCVISAInfo.cpp is llvm/unittests/Support/RISCVISAInfoTest.cpp.
clang/test/Driver/print-supported-extensions.c can test just a few lines (there will be some overlap with the testing in llvm/unittests/Support/RISCVISAInfoTest.cpp), so that changes to RISC-V extensions will generally not require updates to clang/test/Driver/print-supported-extensions.c
clang/test/Driver/print-supported-extensions.c | ||
---|---|---|
6 ↗ | (On Diff #545500) | Now that D156363 is stable, we can replace FileCheck --implicit-check-not=warning: with %clang -Werror. |
llvm/lib/Support/RISCVISAInfo.cpp | ||
219 | Not done. |
The goal of this patch is to list the supported extensions and their versions by providing an option, so I guess clang/test/Driver/print-supported-extensions.c aims differently with llvm/unittests/Support/RISCVISAInfoTest.cpp which is testing the functionalities in RISCVISAInfoTest.cpp.
clang/test/Driver/print-supported-extensions.c only tracks the extensions added and the their version changes and riscvExtensionsHelp in llvm/lib/Support/RISCVISAInfo.cpp doesn't have any input or output as well as any side effect, it only reads SupportedExtensions and SupportedExperimentalExtensions and dump the information.
So I think clang/test/Driver/print-supported-extensions.c is enough for this patch?
- Apply clang-format for this patch
- Replace FileCheck --implicit-check-not=warning: with %clang -Werror
My comment is about: the test is placed at the wrong layer. See https://maskray.me/blog/2021-08-08-toolchain-testing#the-test-checks-at-the-wrong-layer
I don't want that RISC-V development in LLVM causes repeated changes to clang/test/Driver.
clang/include/clang/Driver/Options.td | ||
---|---|---|
5255 | CC1Option/CoreOption has been removed. Please rebase. Visibility<[ClangOption, CC1Option, CLOption]>, Remove Group<CompileOnly_Group>. We don't need a workaround to claim the option in the case of clang -xxx a.o |
Maybe this should be -print-supported-extensions to match RISC-V terminology?