summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/CodeGen/MachineOperandTest.cpp
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2017-12-19 21:47:05 +0000
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2017-12-19 21:47:05 +0000
commitbbd610ae925b3d21babc5d41e184cd4a93d172fd (patch)
tree9328b3b3dba7e2b4603333a0965b0d38465df9e8 /llvm/unittests/CodeGen/MachineOperandTest.cpp
parent3b265c8fcfef59a35ff00937e9ce06ffc62cf349 (diff)
downloadbcm5719-llvm-bbd610ae925b3d21babc5d41e184cd4a93d172fd.tar.gz
bcm5719-llvm-bbd610ae925b3d21babc5d41e184cd4a93d172fd.zip
[CodeGen] Move printing MO_IntrinsicID operands to MachineOperand::print
Work towards the unification of MIR and debug output by refactoring the interfaces. Also add support for printing with a null TargetIntrinsicInfo and no MachineFunction. llvm-svn: 321111
Diffstat (limited to 'llvm/unittests/CodeGen/MachineOperandTest.cpp')
-rw-r--r--llvm/unittests/CodeGen/MachineOperandTest.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/MachineOperandTest.cpp b/llvm/unittests/CodeGen/MachineOperandTest.cpp
index fb43e10742b..cce85cafb2a 100644
--- a/llvm/unittests/CodeGen/MachineOperandTest.cpp
+++ b/llvm/unittests/CodeGen/MachineOperandTest.cpp
@@ -353,4 +353,33 @@ TEST(MachineOperandTest, PrintCFI) {
ASSERT_TRUE(OS.str() == "<cfi directive>");
}
+TEST(MachineOperandTest, PrintIntrinsicID) {
+ // Create a MachineOperand with a generic intrinsic ID.
+ MachineOperand MO = MachineOperand::CreateIntrinsicID(Intrinsic::bswap);
+
+ // Checking some preconditions on the newly created
+ // MachineOperand.
+ ASSERT_TRUE(MO.isIntrinsicID());
+ ASSERT_TRUE(MO.getIntrinsicID() == Intrinsic::bswap);
+
+ std::string str;
+ {
+ // Print a MachineOperand containing a generic intrinsic ID.
+ raw_string_ostream OS(str);
+ MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr);
+ ASSERT_TRUE(OS.str() == "intrinsic(@llvm.bswap)");
+ }
+
+ str.clear();
+ // Set a target-specific intrinsic.
+ MO = MachineOperand::CreateIntrinsicID((Intrinsic::ID)-1);
+ {
+ // Print a MachineOperand containing a target-specific intrinsic ID but not
+ // IntrinsicInfo.
+ raw_string_ostream OS(str);
+ MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr);
+ ASSERT_TRUE(OS.str() == "intrinsic(4294967295)");
+ }
+}
+
} // end namespace
OpenPOWER on IntegriCloud