This patch enables option for reading thread pointer directly from coprocessor register (-mread-tp-hard). This option is supported in llc also ( https://reviews.llvm.org/D34408 ).
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Hi Strahinja,
Does GCC already has a similar option? If so, does this share the same name?
Hi Bruno,
Yes, GCC has similar option (-mtp=soft/hard), but name is not same. I put the same option name as in backend (https://reviews.llvm.org/D34408).
If there's a precedence for a flag name there, it's nice to be compatible here. You don't necessarily need to use the same name as the backend.
lib/Driver/ToolChains/Arch/ARM.cpp | ||
---|---|---|
136 ↗ | (On Diff #109088) | I agree, it should be an error, I fixed that. |
include/clang/Driver/Options.td | ||
---|---|---|
1664–1665 ↗ | (On Diff #109571) | Looking at the gcc documentation for this option (https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html), gcc accepts 3 values: 'soft', 'cp15' and 'auto', with the default setting being 'auto'. |
lib/Driver/ToolChains/Arch/ARM.cpp | ||
128 ↗ | (On Diff #109571) | Wouldn't it be better to default to ReadTPMode::Soft when not -mtp command line option is given? .... |
145–146 ↗ | (On Diff #109571) | .... and always give an error if an invalid mtp command line option was given, rather than default back to soft mode? |
lib/Driver/ToolChains/Clang.cpp | ||
1348–1358 ↗ | (On Diff #109571) | My inexperience in this part of the code base is probably showing, but why is this needed at all? |
test/Driver/clang-translation.c | ||
78–82 ↗ | (On Diff #109571) | It probably would be good to also have a test that when no mtp option is given, the equivalent of when '-mtp soft' is specified would happen. |
include/clang/Driver/Options.td | ||
---|---|---|
1664–1665 ↗ | (On Diff #109571) | I agree with your opinion about 'auto'. If -mtp option is not specified, yes, default value is soft. |
lib/Driver/ToolChains/Arch/ARM.cpp | ||
128 ↗ | (On Diff #109571) | When there is no -mtp in command line ReadTPMode::Soft is default value, ReadTPMode::Invalid is in case when someone try to put in -mtp value that is not cp15 or soft (e.g. -mtp=x). |
145–146 ↗ | (On Diff #109571) | If 'mtp' takes invalid value, error is always provided. This is the case when there is no -mtp option in command line, you can see how the case of invalid mtp argument is handled in the code above. |
lib/Driver/ToolChains/Clang.cpp | ||
1348–1358 ↗ | (On Diff #109571) | Well, actually you are right, we can remove this part of the code, I was thinking that maybe someone in future will need in backend that '-mtp' option also can be recgonized, so I added this, but you are right, I will remove this. |
test/Driver/clang-translation.c | ||
78–82 ↗ | (On Diff #109571) | Checks for '-mtp' in the output are unnecessary when we remove part of the code that you mentioned in previous comment. |
lib/Driver/ToolChains/Arch/ARM.cpp | ||
---|---|---|
145–146 ↗ | (On Diff #109571) | Right. if (Arg *A = ...) { ThreadPointer = llvm::StringSwitch... ; if (!Invalid) return ThreadPointer; if (empty) D.Diag(); else D.Diag(); return Invalid; } return ReadTPMode::Soft; And probably is also slightly closer to the coding standard described in https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code |
lib/Driver/ToolChains/Arch/ARM.cpp | ||
---|---|---|
149–150 ↗ | (On Diff #114573) | Yes, my mistake, I will fix that. |
Thanks Strahinja!
I thought that some indentations looked a bit strange, so I'd just still check that clang-format formats your changes the same way.
Otherwise LGTM!