GlobalISel: fix misuse of using declaration in test.

Clang didn't diagnose it before. Oops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283451 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Tim Northover 2016-10-06 13:57:31 +00:00
parent 665e97634e
commit 2d767ebb66

View File

@ -12,32 +12,22 @@
#include "gtest/gtest.h"
using namespace llvm;
using llvm::MachineLegalizer::LegalizeAction::Legal;
using llvm::MachineLegalizer::LegalizeAction::Lower;
using llvm::MachineLegalizer::LegalizeAction::NarrowScalar;
using llvm::MachineLegalizer::LegalizeAction::WidenScalar;
using llvm::MachineLegalizer::LegalizeAction::FewerElements;
using llvm::MachineLegalizer::LegalizeAction::MoreElements;
using llvm::MachineLegalizer::LegalizeAction::Libcall;
using llvm::MachineLegalizer::LegalizeAction::Custom;
using llvm::MachineLegalizer::LegalizeAction::Unsupported;
using llvm::MachineLegalizer::LegalizeAction::NotFound;
// Define a couple of pretty printers to help debugging when things go wrong.
namespace llvm {
std::ostream &
operator<<(std::ostream &OS, const llvm::MachineLegalizer::LegalizeAction Act) {
switch (Act) {
case Lower: OS << "Lower"; break;
case Legal: OS << "Legal"; break;
case NarrowScalar: OS << "NarrowScalar"; break;
case WidenScalar: OS << "WidenScalar"; break;
case FewerElements: OS << "FewerElements"; break;
case MoreElements: OS << "MoreElements"; break;
case Libcall: OS << "Libcall"; break;
case Custom: OS << "Custom"; break;
case Unsupported: OS << "Unsupported"; break;
case NotFound: OS << "NotFound";
case MachineLegalizer::Lower: OS << "Lower"; break;
case MachineLegalizer::Legal: OS << "Legal"; break;
case MachineLegalizer::NarrowScalar: OS << "NarrowScalar"; break;
case MachineLegalizer::WidenScalar: OS << "WidenScalar"; break;
case MachineLegalizer::FewerElements: OS << "FewerElements"; break;
case MachineLegalizer::MoreElements: OS << "MoreElements"; break;
case MachineLegalizer::Libcall: OS << "Libcall"; break;
case MachineLegalizer::Custom: OS << "Custom"; break;
case MachineLegalizer::Unsupported: OS << "Unsupported"; break;
case MachineLegalizer::NotFound: OS << "NotFound";
}
return OS;
}
@ -59,51 +49,52 @@ TEST(MachineLegalizerTest, ScalarRISC) {
using namespace TargetOpcode;
MachineLegalizer L;
// Typical RISCy set of operations based on AArch64.
L.setAction({G_ADD, LLT::scalar(8)}, WidenScalar);
L.setAction({G_ADD, LLT::scalar(16)}, WidenScalar);
L.setAction({G_ADD, LLT::scalar(32)}, Legal);
L.setAction({G_ADD, LLT::scalar(64)}, Legal);
L.setAction({G_ADD, LLT::scalar(8)}, MachineLegalizer::WidenScalar);
L.setAction({G_ADD, LLT::scalar(16)}, MachineLegalizer::WidenScalar);
L.setAction({G_ADD, LLT::scalar(32)}, MachineLegalizer::Legal);
L.setAction({G_ADD, LLT::scalar(64)}, MachineLegalizer::Legal);
L.computeTables();
// Check we infer the correct types and actually do what we're told.
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(8)}),
std::make_pair(WidenScalar, LLT::scalar(32)));
std::make_pair(MachineLegalizer::WidenScalar, LLT::scalar(32)));
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(16)}),
std::make_pair(WidenScalar, LLT::scalar(32)));
std::make_pair(MachineLegalizer::WidenScalar, LLT::scalar(32)));
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(32)}),
std::make_pair(Legal, LLT::scalar(32)));
std::make_pair(MachineLegalizer::Legal, LLT::scalar(32)));
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(64)}),
std::make_pair(Legal, LLT::scalar(64)));
std::make_pair(MachineLegalizer::Legal, LLT::scalar(64)));
// Make sure the default for over-sized types applies.
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(128)}),
std::make_pair(NarrowScalar, LLT::scalar(64)));
std::make_pair(MachineLegalizer::NarrowScalar, LLT::scalar(64)));
}
TEST(MachineLegalizerTest, VectorRISC) {
using namespace TargetOpcode;
MachineLegalizer L;
// Typical RISCy set of operations based on ARM.
L.setScalarInVectorAction(G_ADD, LLT::scalar(8), Legal);
L.setScalarInVectorAction(G_ADD, LLT::scalar(16), Legal);
L.setScalarInVectorAction(G_ADD, LLT::scalar(32), Legal);
L.setScalarInVectorAction(G_ADD, LLT::scalar(8), MachineLegalizer::Legal);
L.setScalarInVectorAction(G_ADD, LLT::scalar(16), MachineLegalizer::Legal);
L.setScalarInVectorAction(G_ADD, LLT::scalar(32), MachineLegalizer::Legal);
L.setAction({G_ADD, LLT::vector(8, 8)}, Legal);
L.setAction({G_ADD, LLT::vector(16, 8)}, Legal);
L.setAction({G_ADD, LLT::vector(4, 16)}, Legal);
L.setAction({G_ADD, LLT::vector(8, 16)}, Legal);
L.setAction({G_ADD, LLT::vector(2, 32)}, Legal);
L.setAction({G_ADD, LLT::vector(4, 32)}, Legal);
L.setAction({G_ADD, LLT::vector(8, 8)}, MachineLegalizer::Legal);
L.setAction({G_ADD, LLT::vector(16, 8)}, MachineLegalizer::Legal);
L.setAction({G_ADD, LLT::vector(4, 16)}, MachineLegalizer::Legal);
L.setAction({G_ADD, LLT::vector(8, 16)}, MachineLegalizer::Legal);
L.setAction({G_ADD, LLT::vector(2, 32)}, MachineLegalizer::Legal);
L.setAction({G_ADD, LLT::vector(4, 32)}, MachineLegalizer::Legal);
L.computeTables();
// Check we infer the correct types and actually do what we're told for some
// simple cases.
ASSERT_EQ(L.getAction({G_ADD, LLT::vector(2, 8)}),
std::make_pair(MoreElements, LLT::vector(8, 8)));
std::make_pair(MachineLegalizer::MoreElements, LLT::vector(8, 8)));
ASSERT_EQ(L.getAction({G_ADD, LLT::vector(8, 8)}),
std::make_pair(Legal, LLT::vector(8, 8)));
ASSERT_EQ(L.getAction({G_ADD, LLT::vector(8, 32)}),
std::make_pair(FewerElements, LLT::vector(4, 32)));
std::make_pair(MachineLegalizer::Legal, LLT::vector(8, 8)));
ASSERT_EQ(
L.getAction({G_ADD, LLT::vector(8, 32)}),
std::make_pair(MachineLegalizer::FewerElements, LLT::vector(4, 32)));
}
TEST(MachineLegalizerTest, MultipleTypes) {
@ -114,14 +105,16 @@ TEST(MachineLegalizerTest, MultipleTypes) {
LLT s64 = LLT::scalar(64);
// Typical RISCy set of operations based on AArch64.
L.setAction({G_PTRTOINT, 0, s64}, Legal);
L.setAction({G_PTRTOINT, 1, p0}, Legal);
L.setAction({G_PTRTOINT, 0, s64}, MachineLegalizer::Legal);
L.setAction({G_PTRTOINT, 1, p0}, MachineLegalizer::Legal);
L.setAction({G_PTRTOINT, 0, s32}, WidenScalar);
L.setAction({G_PTRTOINT, 0, s32}, MachineLegalizer::WidenScalar);
L.computeTables();
// Check we infer the correct types and actually do what we're told.
ASSERT_EQ(L.getAction({G_PTRTOINT, 0, s64}), std::make_pair(Legal, s64));
ASSERT_EQ(L.getAction({G_PTRTOINT, 1, p0}), std::make_pair(Legal, p0));
ASSERT_EQ(L.getAction({G_PTRTOINT, 0, s64}),
std::make_pair(MachineLegalizer::Legal, s64));
ASSERT_EQ(L.getAction({G_PTRTOINT, 1, p0}),
std::make_pair(MachineLegalizer::Legal, p0));
}
}