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 | I agree, it should be an error, I fixed that. |
include/clang/Driver/Options.td | ||
---|---|---|
1664–1665 | 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 | Wouldn't it be better to default to ReadTPMode::Soft when not -mtp command line option is given? .... | |
145–146 | .... 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | ||
---|---|---|
140–141 | 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!
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'.
This patch implements just 2 of those values: 'soft' and 'cp15'.
I think this is fine, as long as the default value is 'soft'.
The 'auto' value should automatically pick 'cp15' if that's going to work on what you're targeting. If I understood correctly, that depends both on the architecture version you're targeting and the operating system/kernel you're targeting. So, there could be a lot of details to go through to get 'auto' right in all cases. Which is why I think it's fine to leave an implementation of 'auto' for later.
Is the default value 'soft'?