- Add unittest to {ARM | AArch64}TargetParser
- Correct a incorrect indexing problem in AArch64TargetParser The architecture enumeration is shared across ARM and AArch64 in original implementation.But In the code,I just used the index which was offset by the ARM, and this would index into the array incorrectly. To make AArch64 has its own arch enum,or we will do a lot of slowly iterating.
- Correct a spelling error by the way. parameter of llvm::AArch64::getArchExtName
- Correct a writing mistake, in llvm::ARM::parseArchISA
Details
Diff Detail
Event Timeline
include/llvm/Support/TargetParser.h | ||
---|---|---|
152 | I think that you should use the AK_ prefix as is the norm. That said, you could do something else which IMO is better: use enum class and drop the prefix. | |
unittests/Support/TargetParserTest.cpp | ||
45 | Please delete this. I had added it to avoid hardcoding the offset. Just iterate over the enumeration below. In fact, it is unused. | |
89 | This set really feels weird to me. |
Remove uncessary items according to inline comments.
include/llvm/Support/TargetParser.h | ||
---|---|---|
152 | If we use enum class, we must do type casting when we perform operations between "unsigned int" and archkind. There are a lot of cases like this, in the TargetParser and places using it. And some generic structure definition shared between arm and aarch64, should be made a set for each. | |
unittests/Support/TargetParserTest.cpp | ||
45 | Indeed,remove it. | |
89 | I removed two of these which are unnecessary. |
- Add unittest to ARMTargetParser
- Correct a writing mistake,in llvm::ARM::parseArchISA.
- Make some small changes on AArch64TargetParser
include/llvm/Support/TargetParser.h | ||
---|---|---|
152 | I think we should leave that discussion for when we change this to a class design, or when we move to table-generated tables. I think it should be fine as is, for now. |
Hi Jojo,
Thanks for the patch. I like how thorough were your tests, and it'll certainly cover a lot more than the current TripleTest. At some point, after we finish this, I think we should clean that one up, so that it stops redundant (and slow) tests.
Saleem (@compnerd), are you happy with the changes? I think we can discuss style in the class discussion (since it's going to change again, anyway), and just get all tools to use the parser for now.
cheers,
--renato
I think that Id still prefer the AK_ prefix. However, the only thing that is preventing me from accepting the change is that I haven't really carefully looked through all the cases. If you have done so, and everything looks okay, fine by me :-).
Dear all,
I‘m not so sure about the changes.That would be appreciated if you could give any advice.
It will take some time to read through all the changes,Thank you very much for your review.
I don't mind either way (AK, AAK), but if there is anything stopping us from using AK, we should move that discussion later.
If not, I agree we should just keep AK instead. AK means "ArchKind", not "ARMKind", so AArch64 would also be "ArchKind", thus AK.
That would also make this change a lot smaller, and clearer.
thanks,
--renato
Looks like that keep using prefix AK is more reasonable.Update diff to use AK instead.
There are a bunch of place that could use a range based for loop, please prefer them instead.
lib/Support/TargetParser.cpp | ||
---|---|---|
419 | Isn't this the original bug that is being fixed rather than just adding tests for the target parser? | |
455 | I don't think that this is necessarily bad. It does make it more obvious if you are targeting a newer architecture variant. | |
462 | Given that you are doing explicit checks, why not simplify this to: if (ArchKind == ...) ... if (ArchKind == ...) ... return ArchKind > AArch64::ArchKind::AK_INVALID && ArchKind < AArch64::ArchKind::AK_LAST; | |
467–469 | Shouldn't this check for AK_INVALID as well? | |
485–487 | Shouldn't this check for AK_INVALID as well? | |
unittests/Support/TargetParserTest.cpp | ||
170 | space before the <. Why not use a range based loop? for (const auto &ARMCPUName : kARMCPUNames) EXPECT_EQ(ARMCPUName.DefaultFPU, ARM::getDefaultFPU(ARMCPUName.Name, 0)); | |
179 | Similar. | |
215 | clang-format this |
lib/Support/TargetParser.cpp | ||
---|---|---|
419 | Yes.this is a bug fixing. For AArch64,it's unnecessary to OR the ArchBaseExtensions,as the tables for ARM and AArch64 have not exactly the same design. | |
467–469 | There is a record for "invalid" in ARCHNames table. | |
485–487 | the same as above | |
unittests/Support/TargetParserTest.cpp | ||
170 | Yes,indeed. | |
215 | Do you mean like this? { "crc", "+crc"}, |
unittests/Support/TargetParserTest.cpp | ||
---|---|---|
215 | He probably just mean running "clang-format" over the file. $ clang-format unittests/Support/TargetParserTest.cpp should do. |
unittests/Support/TargetParserTest.cpp | ||
---|---|---|
215 | Oh, No brainer. |
I think that you should use the AK_ prefix as is the norm. That said, you could do something else which IMO is better: use enum class and drop the prefix.