summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/CodeGen/MachineOperandTest.cpp
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2017-12-13 10:30:51 +0000
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2017-12-13 10:30:51 +0000
commitb3a0d513749623b8ee51183c127be74350052426 (patch)
tree150eba20d019bb866ef70b22fc74f2ee9007b34a /llvm/unittests/CodeGen/MachineOperandTest.cpp
parent26ae8a6582c8c420b222e5b672c6845e182340f5 (diff)
downloadbcm5719-llvm-b3a0d513749623b8ee51183c127be74350052426.tar.gz
bcm5719-llvm-b3a0d513749623b8ee51183c127be74350052426.zip
[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 `<ti#0+8>` and `target-index(target-specific) + 8` instead of `<ti#0-8>`. Only debug syntax is affected. llvm-svn: 320565
Diffstat (limited to 'llvm/unittests/CodeGen/MachineOperandTest.cpp')
-rw-r--r--llvm/unittests/CodeGen/MachineOperandTest.cpp30
1 files changed, 30 insertions, 0 deletions
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(<unknown>) + 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(<unknown>) - 12");
+ }
+}
+
} // end namespace
OpenPOWER on IntegriCloud