diff options
author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2017-12-14 10:03:23 +0000 |
---|---|---|
committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2017-12-14 10:03:23 +0000 |
commit | ee30ab7184f54df3f2539b4648c2b5a94a507f5e (patch) | |
tree | 02f52b3df24c0768ba948be9c6f2e5223a9e2411 /unittests | |
parent | f726becf7caba94af09e1909a4e10e3e1bd6006f (diff) |
[CodeGen] Print MCSymbol operands as <mcsymbol sym> in both MIR and debug output
Work towards the unification of MIR and debug output by printing
`<mcsymbol sym>` instead of `<MCSym=sym>`.
Only debug syntax is affected.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320685 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/CodeGen/MachineOperandTest.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/unittests/CodeGen/MachineOperandTest.cpp b/unittests/CodeGen/MachineOperandTest.cpp index 192229be065..e51207b9571 100644 --- a/unittests/CodeGen/MachineOperandTest.cpp +++ b/unittests/CodeGen/MachineOperandTest.cpp @@ -13,6 +13,8 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/ModuleSlotTracker.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCAsmInfo.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" @@ -314,4 +316,24 @@ TEST(MachineOperandTest, PrintMetadata) { ASSERT_TRUE(OS.str() == "!0"); } +TEST(MachineOperandTest, PrintMCSymbol) { + MCAsmInfo MAI; + MCContext Ctx(&MAI, /*MRI=*/nullptr, /*MOFI=*/nullptr); + MCSymbol *Sym = Ctx.getOrCreateSymbol("foo"); + + // Create a MachineOperand with a metadata and print it. + MachineOperand MO = MachineOperand::CreateMCSymbol(Sym); + + // Checking some preconditions on the newly created + // MachineOperand. + ASSERT_TRUE(MO.isMCSymbol()); + ASSERT_TRUE(MO.getMCSymbol() == Sym); + + std::string str; + // Print a MachineOperand containing a metadata node. + raw_string_ostream OS(str); + MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr); + ASSERT_TRUE(OS.str() == "<mcsymbol foo>"); +} + } // end namespace |