summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/CodeGen/MachineOperandTest.cpp
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2017-12-14 10:02:58 +0000
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2017-12-14 10:02:58 +0000
commite76c5fcd70695f3b838b868ba53471f2554e0ee6 (patch)
treebb996f6afec330eee3b622142337dc8fe75d275e /llvm/unittests/CodeGen/MachineOperandTest.cpp
parent753395fa0abe3b612e4b6e36c78b516ddad2b2a7 (diff)
downloadbcm5719-llvm-e76c5fcd70695f3b838b868ba53471f2554e0ee6.tar.gz
bcm5719-llvm-e76c5fcd70695f3b838b868ba53471f2554e0ee6.zip
[CodeGen] Print external symbols as $symbol in both MIR and debug output
Work towards the unification of MIR and debug output by printing `$symbol` instead of `<es:symbol>`. Only debug syntax is affected. llvm-svn: 320681
Diffstat (limited to 'llvm/unittests/CodeGen/MachineOperandTest.cpp')
-rw-r--r--llvm/unittests/CodeGen/MachineOperandTest.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/MachineOperandTest.cpp b/llvm/unittests/CodeGen/MachineOperandTest.cpp
index aed60c0a3d6..36897d918b3 100644
--- a/llvm/unittests/CodeGen/MachineOperandTest.cpp
+++ b/llvm/unittests/CodeGen/MachineOperandTest.cpp
@@ -197,4 +197,42 @@ TEST(MachineOperandTest, PrintJumpTableIndex) {
ASSERT_TRUE(OS.str() == "%jump-table.3");
}
+TEST(MachineOperandTest, PrintExternalSymbol) {
+ // Create a MachineOperand with an external symbol and print it.
+ MachineOperand MO = MachineOperand::CreateES("foo");
+
+ // Checking some preconditions on the newly created
+ // MachineOperand.
+ ASSERT_TRUE(MO.isSymbol());
+ ASSERT_TRUE(MO.getSymbolName() == StringRef("foo"));
+
+ // Print a MachineOperand containing an external symbol and no offset.
+ std::string str;
+ {
+ raw_string_ostream OS(str);
+ MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr);
+ ASSERT_TRUE(OS.str() == "$foo");
+ }
+
+ str.clear();
+ MO.setOffset(12);
+
+ // Print a MachineOperand containing an external symbol and a positive offset.
+ {
+ raw_string_ostream OS(str);
+ MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr);
+ ASSERT_TRUE(OS.str() == "$foo + 12");
+ }
+
+ str.clear();
+ MO.setOffset(-12);
+
+ // Print a MachineOperand containing an external symbol and a negative offset.
+ {
+ raw_string_ostream OS(str);
+ MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr);
+ ASSERT_TRUE(OS.str() == "$foo - 12");
+ }
+}
+
} // end namespace
OpenPOWER on IntegriCloud