diff options
author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2017-12-08 11:40:06 +0000 |
---|---|---|
committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2017-12-08 11:40:06 +0000 |
commit | ab9bb805758153bd909758e84601c229b2256aeb (patch) | |
tree | 6fde531f4ebe6519fb586ac14018f2fa9221bdae /unittests | |
parent | f4f4ffb1e1f092ba5b71a3acde4e02937c26630a (diff) |
[CodeGen] Move printing MO_CImmediate 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@320140 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/CodeGen/MachineOperandTest.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/unittests/CodeGen/MachineOperandTest.cpp b/unittests/CodeGen/MachineOperandTest.cpp index 5926b6767ff..4884d374521 100644 --- a/unittests/CodeGen/MachineOperandTest.cpp +++ b/unittests/CodeGen/MachineOperandTest.cpp @@ -9,6 +9,8 @@ #include "llvm/ADT/ilist_node.h" #include "llvm/CodeGen/MachineOperand.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/LLVMContext.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" @@ -76,4 +78,26 @@ TEST(MachineOperandTest, PrintSubReg) { ASSERT_TRUE(OS.str() == "%physreg1.subreg5"); } +TEST(MachineOperandTest, PrintCImm) { + LLVMContext Context; + APInt Int(128, UINT64_MAX); + ++Int; + ConstantInt *CImm = ConstantInt::get(Context, Int); + // Create a MachineOperand with an Imm=(UINT64_MAX + 1) + MachineOperand MO = MachineOperand::CreateCImm(CImm); + + // Checking some preconditions on the newly created + // MachineOperand. + ASSERT_TRUE(MO.isCImm()); + ASSERT_TRUE(MO.getCImm() == CImm); + ASSERT_TRUE(MO.getCImm()->getValue() == Int); + + // Print a MachineOperand containing a SubReg. Here we check that without a + // TRI and IntrinsicInfo we can still print the subreg index. + std::string str; + raw_string_ostream OS(str); + MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr); + ASSERT_TRUE(OS.str() == "i128 18446744073709551616"); +} + } // end namespace |