From b3a0d513749623b8ee51183c127be74350052426 Mon Sep 17 00:00:00 2001 From: Francis Visoiu Mistrih Date: Wed, 13 Dec 2017 10:30:51 +0000 Subject: [CodeGen] Print target index operands as target-index(target-specific) + 8 in both MIR and debug output Work towards the unification of MIR and debug output by printing `target-index(target-specific) + 8` instead of `` and `target-index(target-specific) + 8` instead of ``. Only debug syntax is affected. llvm-svn: 320565 --- llvm/unittests/CodeGen/MachineOperandTest.cpp | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'llvm/unittests/CodeGen/MachineOperandTest.cpp') diff --git a/llvm/unittests/CodeGen/MachineOperandTest.cpp b/llvm/unittests/CodeGen/MachineOperandTest.cpp index c21bff60db0..46f50ab0151 100644 --- a/llvm/unittests/CodeGen/MachineOperandTest.cpp +++ b/llvm/unittests/CodeGen/MachineOperandTest.cpp @@ -151,4 +151,34 @@ TEST(MachineOperandTest, PrintCPI) { } } +TEST(MachineOperandTest, PrintTargetIndexName) { + // Create a MachineOperand with a target index and print it. + MachineOperand MO = MachineOperand::CreateTargetIndex(0, 8); + + // Checking some preconditions on the newly created + // MachineOperand. + ASSERT_TRUE(MO.isTargetIndex()); + ASSERT_TRUE(MO.getIndex() == 0); + ASSERT_TRUE(MO.getOffset() == 8); + + // Print a MachineOperand containing a target index and a positive offset. + std::string str; + { + raw_string_ostream OS(str); + MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr); + ASSERT_TRUE(OS.str() == "target-index() + 8"); + } + + str.clear(); + + MO.setOffset(-12); + + // Print a MachineOperand containing a target index and a negative offset. + { + raw_string_ostream OS(str); + MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr); + ASSERT_TRUE(OS.str() == "target-index() - 12"); + } +} + } // end namespace -- cgit v1.2.3