summaryrefslogtreecommitdiff
path: root/unittests
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
commit43c2ba74fca95ca61abf3717b10a8a3b7369f3b3 (patch)
tree563f30b86aa46014ca1ffcd141cd3959a916a9cd /unittests
parent30e8e017c8380c26e3a9fac1b9c2d4a4d1686bae (diff)
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321111 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/CodeGen/MachineOperandTest.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/unittests/CodeGen/MachineOperandTest.cpp b/unittests/CodeGen/MachineOperandTest.cpp
index fb43e10742b..cce85cafb2a 100644
--- a/unittests/CodeGen/MachineOperandTest.cpp
+++ b/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