summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2017-12-14 10:03:18 +0000
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2017-12-14 10:03:18 +0000
commitf726becf7caba94af09e1909a4e10e3e1bd6006f (patch)
tree2bbb55d53de4c87329766bb829f06cdaff53d531 /unittests
parentf6cd582907a9cb4b791e111dfe1be5d9faa8791f (diff)
[CodeGen] Move printing MO_Metadata operands to MachineOperand::print
Work towards the unification of MIR and debug output by refactoring the interfaces. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320684 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/CodeGen/MachineOperandTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/unittests/CodeGen/MachineOperandTest.cpp b/unittests/CodeGen/MachineOperandTest.cpp
index 5c13ddc4b8c..192229be065 100644
--- a/unittests/CodeGen/MachineOperandTest.cpp
+++ b/unittests/CodeGen/MachineOperandTest.cpp
@@ -289,4 +289,29 @@ TEST(MachineOperandTest, PrintRegisterLiveOut) {
ASSERT_TRUE(OS.str() == "liveout(<unknown>)");
}
+TEST(MachineOperandTest, PrintMetadata) {
+ LLVMContext Ctx;
+ Module M("MachineOperandMDNodeTest", Ctx);
+ NamedMDNode *MD = M.getOrInsertNamedMetadata("namedmd");
+ ModuleSlotTracker DummyMST(&M);
+ Metadata *MDS = MDString::get(Ctx, "foo");
+ MDNode *Node = MDNode::get(Ctx, MDS);
+ MD->addOperand(Node);
+
+ // Create a MachineOperand with a metadata and print it.
+ MachineOperand MO = MachineOperand::CreateMetadata(Node);
+
+ // Checking some preconditions on the newly created
+ // MachineOperand.
+ ASSERT_TRUE(MO.isMetadata());
+ ASSERT_TRUE(MO.getMetadata() == Node);
+
+ std::string str;
+ // Print a MachineOperand containing a metadata node.
+ raw_string_ostream OS(str);
+ MO.print(OS, DummyMST, LLT{}, false, false, 0, /*TRI=*/nullptr,
+ /*IntrinsicInfo=*/nullptr);
+ ASSERT_TRUE(OS.str() == "!0");
+}
+
} // end namespace