summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/CodeGen/MachineOperandTest.cpp
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
commit2db59382db874146e7bc53c490188ca2767078f6 (patch)
treed9f33ce28364235caf4a5eae2dbe8d25dd1dfbf5 /llvm/unittests/CodeGen/MachineOperandTest.cpp
parentbdaf8bfa99830bad36c9833ca6a661294fb27577 (diff)
downloadbcm5719-llvm-2db59382db874146e7bc53c490188ca2767078f6.tar.gz
bcm5719-llvm-2db59382db874146e7bc53c490188ca2767078f6.zip
[CodeGen] Move printing MO_Metadata operands to MachineOperand::print
Work towards the unification of MIR and debug output by refactoring the interfaces. llvm-svn: 320684
Diffstat (limited to 'llvm/unittests/CodeGen/MachineOperandTest.cpp')
-rw-r--r--llvm/unittests/CodeGen/MachineOperandTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/MachineOperandTest.cpp b/llvm/unittests/CodeGen/MachineOperandTest.cpp
index 5c13ddc4b8c..192229be065 100644
--- a/llvm/unittests/CodeGen/MachineOperandTest.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud