summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2019-02-14 22:41:09 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2019-02-14 22:41:09 +0000
commit530d05e94ac097a15722229138eea8addefc37f5 (patch)
tree6da790889741718432e9f13d9842cce1cb117457 /llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
parent294483f1c04823e5d9efc2f6bc37bd5b9e4b5843 (diff)
downloadbcm5719-llvm-530d05e94ac097a15722229138eea8addefc37f5.tar.gz
bcm5719-llvm-530d05e94ac097a15722229138eea8addefc37f5.zip
GlobalISel: Add alignment to LegalityQuery MMOs
This allows targets to specify the minimum alignment required for the load/store. llvm-svn: 354071
Diffstat (limited to 'llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp')
-rw-r--r--llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp b/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
index 3617388c04e..b342143e139 100644
--- a/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
@@ -356,3 +356,52 @@ TEST(LegalizerInfoTest, RuleSets) {
EXPECT_ACTION(Unsupported, 0, LLT(), LegalityQuery(G_AND, {v2s33}));
}
}
+
+TEST(LegalizerInfoTest, MMOAlignment) {
+ using namespace TargetOpcode;
+
+ const LLT s32 = LLT::scalar(32);
+ const LLT p0 = LLT::pointer(0, 64);
+
+ {
+ LegalizerInfo LI;
+ LI.getActionDefinitionsBuilder(G_LOAD)
+ .legalForTypesWithMemDesc({{s32, p0, 32, 32}});
+
+ LI.computeTables();
+
+ EXPECT_ACTION(Legal, 0, LLT(),
+ LegalityQuery(G_LOAD, {s32, p0},
+ LegalityQuery::MemDesc{
+ 32, 32, AtomicOrdering::NotAtomic}));
+ EXPECT_ACTION(Unsupported, 0, LLT(),
+ LegalityQuery(G_LOAD, {s32, p0},
+ LegalityQuery::MemDesc{
+ 32, 16, AtomicOrdering::NotAtomic }));
+ EXPECT_ACTION(Unsupported, 0, LLT(),
+ LegalityQuery(G_LOAD, {s32, p0},
+ LegalityQuery::MemDesc{
+ 32, 8, AtomicOrdering::NotAtomic}));
+ }
+
+ // Test that the maximum supported alignment value isn't truncated
+ {
+ // Maximum IR defined alignment in bytes.
+ const uint64_t MaxAlignment = UINT64_C(1) << 29;
+ const uint64_t MaxAlignInBits = 8 * MaxAlignment;
+ LegalizerInfo LI;
+ LI.getActionDefinitionsBuilder(G_LOAD)
+ .legalForTypesWithMemDesc({{s32, p0, 32, MaxAlignInBits}});
+
+ LI.computeTables();
+
+ EXPECT_ACTION(Legal, 0, LLT(),
+ LegalityQuery(G_LOAD, {s32, p0},
+ LegalityQuery::MemDesc{32,
+ MaxAlignInBits, AtomicOrdering::NotAtomic}));
+ EXPECT_ACTION(Unsupported, 0, LLT(),
+ LegalityQuery(G_LOAD, {s32, p0},
+ LegalityQuery::MemDesc{
+ 32, 8, AtomicOrdering::NotAtomic }));
+ }
+}
OpenPOWER on IntegriCloud