summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/CodeGen/MachineOperandTest.cpp
diff options
context:
space:
mode:
authorMarcello Maggioni <hayarms@gmail.com>2017-08-10 15:35:25 +0000
committerMarcello Maggioni <hayarms@gmail.com>2017-08-10 15:35:25 +0000
commit61f48ca35e0bc16f41443beb60d38dea181a25a9 (patch)
treecd3b292d88377dc2493d87ec1a0ccef824c3a7b4 /llvm/unittests/CodeGen/MachineOperandTest.cpp
parenta9d31f9199f7e47bc50e9d20db4f1a273a199d7b (diff)
downloadbcm5719-llvm-61f48ca35e0bc16f41443beb60d38dea181a25a9.tar.gz
bcm5719-llvm-61f48ca35e0bc16f41443beb60d38dea181a25a9.zip
[unittests] Adding a unittest for ChangeTaTargetIndex. NFC
Differential Revision: https://reviews.llvm.org/D36565 llvm-svn: 310610
Diffstat (limited to 'llvm/unittests/CodeGen/MachineOperandTest.cpp')
-rw-r--r--llvm/unittests/CodeGen/MachineOperandTest.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/MachineOperandTest.cpp b/llvm/unittests/CodeGen/MachineOperandTest.cpp
new file mode 100644
index 00000000000..afbf4f4c368
--- /dev/null
+++ b/llvm/unittests/CodeGen/MachineOperandTest.cpp
@@ -0,0 +1,40 @@
+//===- MachineOperandTest.cpp ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/ilist_node.h"
+#include "llvm/CodeGen/MachineOperand.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+
+TEST(MachineOperandTest, ChangeToTargetIndexTest) {
+ // Creating a MachineOperand to change it to TargetIndex
+ MachineOperand MO = MachineOperand::CreateImm(50);
+
+ // Checking some precondition on the newly created
+ // MachineOperand.
+ ASSERT_TRUE(MO.isImm());
+ ASSERT_TRUE(MO.getImm() == 50);
+ ASSERT_FALSE(MO.isTargetIndex());
+
+ // Changing to TargetIndex with some arbitrary values
+ // for index, offset and flags.
+ MO.ChangeToTargetIndex(74, 57, 12);
+
+ // Checking that the mutation to TargetIndex happened
+ // correctly.
+ ASSERT_TRUE(MO.isTargetIndex());
+ ASSERT_TRUE(MO.getIndex() == 74);
+ ASSERT_TRUE(MO.getOffset() == 57);
+ ASSERT_TRUE(MO.getTargetFlags() == 12);
+}
+
+} // end namespace
OpenPOWER on IntegriCloud