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 | 3c99371c6e6be9f79226f2798e136109da937ab1 (patch) | |
tree | f6527367fe322f346504638ac1e5a571c0a662b4 /llvm/unittests/CodeGen/MachineOperandTest.cpp | |
parent | 2db59382db874146e7bc53c490188ca2767078f6 (diff) | |
download | bcm5719-llvm-3c99371c6e6be9f79226f2798e136109da937ab1.tar.gz bcm5719-llvm-3c99371c6e6be9f79226f2798e136109da937ab1.zip |
[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.
llvm-svn: 320685
Diffstat (limited to 'llvm/unittests/CodeGen/MachineOperandTest.cpp')
-rw-r--r-- | llvm/unittests/CodeGen/MachineOperandTest.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/MachineOperandTest.cpp b/llvm/unittests/CodeGen/MachineOperandTest.cpp index 192229be065..e51207b9571 100644 --- a/llvm/unittests/CodeGen/MachineOperandTest.cpp +++ b/llvm/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 |