diff options
author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2017-12-19 21:47:10 +0000 |
---|---|---|
committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2017-12-19 21:47:10 +0000 |
commit | cb2683d46a5287b29b2494348f1921f7caed5c68 (patch) | |
tree | 94e740724fa69bc0558b47a652c6afd7d92f61c4 /llvm/unittests/CodeGen/MachineOperandTest.cpp | |
parent | bbd610ae925b3d21babc5d41e184cd4a93d172fd (diff) | |
download | bcm5719-llvm-cb2683d46a5287b29b2494348f1921f7caed5c68.tar.gz bcm5719-llvm-cb2683d46a5287b29b2494348f1921f7caed5c68.zip |
[CodeGen] Move printing MO_IntrinsicID operands to MachineOperand::print
Work towards the unification of MIR and debug output by refactoring the
interfaces.
llvm-svn: 321112
Diffstat (limited to 'llvm/unittests/CodeGen/MachineOperandTest.cpp')
-rw-r--r-- | llvm/unittests/CodeGen/MachineOperandTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/MachineOperandTest.cpp b/llvm/unittests/CodeGen/MachineOperandTest.cpp index cce85cafb2a..78a20b83648 100644 --- a/llvm/unittests/CodeGen/MachineOperandTest.cpp +++ b/llvm/unittests/CodeGen/MachineOperandTest.cpp @@ -10,6 +10,7 @@ #include "llvm/CodeGen/MachineOperand.h" #include "llvm/ADT/ilist_node.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/InstrTypes.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/ModuleSlotTracker.h" @@ -382,4 +383,20 @@ TEST(MachineOperandTest, PrintIntrinsicID) { } } +TEST(MachineOperandTest, PrintPredicate) { + // Create a MachineOperand with a generic intrinsic ID. + MachineOperand MO = MachineOperand::CreatePredicate(CmpInst::ICMP_EQ); + + // Checking some preconditions on the newly created + // MachineOperand. + ASSERT_TRUE(MO.isPredicate()); + ASSERT_TRUE(MO.getPredicate() == CmpInst::ICMP_EQ); + + std::string str; + // Print a MachineOperand containing a int predicate ICMP_EQ. + raw_string_ostream OS(str); + MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr); + ASSERT_TRUE(OS.str() == "intpred(eq)"); +} + } // end namespace |