diff options
author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2017-12-13 10:30:45 +0000 |
---|---|---|
committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2017-12-13 10:30:45 +0000 |
commit | 26ae8a6582c8c420b222e5b672c6845e182340f5 (patch) | |
tree | a2c146ace61de186baec22106525bfffb3732769 /llvm/unittests/CodeGen/MachineOperandTest.cpp | |
parent | fead6ae660ac5f4548250f972ccbd905a038132a (diff) | |
download | bcm5719-llvm-26ae8a6582c8c420b222e5b672c6845e182340f5.tar.gz bcm5719-llvm-26ae8a6582c8c420b222e5b672c6845e182340f5.zip |
[CodeGen] Print constant pool index operands as %const.0 + 8 in both MIR and debug output
Work towards the unification of MIR and debug output by printing
`%const.0 + 8` instead of `<cp#0+8>` and `%const.0 - 8` instead of
`<cp#0-8>`.
Only debug syntax is affected.
Differential Revision: https://reviews.llvm.org/D41116
llvm-svn: 320564
Diffstat (limited to 'llvm/unittests/CodeGen/MachineOperandTest.cpp')
-rw-r--r-- | llvm/unittests/CodeGen/MachineOperandTest.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/MachineOperandTest.cpp b/llvm/unittests/CodeGen/MachineOperandTest.cpp index 24a7f5563ff..c21bff60db0 100644 --- a/llvm/unittests/CodeGen/MachineOperandTest.cpp +++ b/llvm/unittests/CodeGen/MachineOperandTest.cpp @@ -119,4 +119,36 @@ TEST(MachineOperandTest, PrintSubRegIndex) { ASSERT_TRUE(OS.str() == "%subreg.3"); } +TEST(MachineOperandTest, PrintCPI) { + // Create a MachineOperand with a constant pool index and print it. + MachineOperand MO = MachineOperand::CreateCPI(0, 8); + + // Checking some preconditions on the newly created + // MachineOperand. + ASSERT_TRUE(MO.isCPI()); + ASSERT_TRUE(MO.getIndex() == 0); + ASSERT_TRUE(MO.getOffset() == 8); + + // Print a MachineOperand containing a constant pool index and a positive + // offset. + std::string str; + { + raw_string_ostream OS(str); + MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr); + ASSERT_TRUE(OS.str() == "%const.0 + 8"); + } + + str.clear(); + + MO.setOffset(-12); + + // Print a MachineOperand containing a constant pool index and a negative + // offset. + { + raw_string_ostream OS(str); + MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr); + ASSERT_TRUE(OS.str() == "%const.0 - 12"); + } +} + } // end namespace |