summaryrefslogtreecommitdiff
path: root/unittests
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
commit2b16863067fa1f188f616f80ab6ea23e7d1cb7c1 (patch)
tree83d8573492cd0e0f3dd8ff264794178bdfe1dd65 /unittests
parentc84690975acd7c5f43e4c44d4653a9f7e384ba8f (diff)
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320565 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/CodeGen/MachineOperandTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/unittests/CodeGen/MachineOperandTest.cpp b/unittests/CodeGen/MachineOperandTest.cpp
index c21bff60db0..46f50ab0151 100644
--- a/unittests/CodeGen/MachineOperandTest.cpp
+++ b/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