[llvm] r310610 - [unittests] Adding a unittest for ChangeTaTargetIndex. NFC
Marcello Maggioni via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 10 08:35:25 PDT 2017
Author: mggm
Date: Thu Aug 10 08:35:25 2017
New Revision: 310610
URL: http://llvm.org/viewvc/llvm-project?rev=310610&view=rev
Log:
[unittests] Adding a unittest for ChangeTaTargetIndex. NFC
Differential Revision: https://reviews.llvm.org/D36565
Added:
llvm/trunk/unittests/CodeGen/MachineOperandTest.cpp
Modified:
llvm/trunk/unittests/CodeGen/CMakeLists.txt
Modified: llvm/trunk/unittests/CodeGen/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CodeGen/CMakeLists.txt?rev=310610&r1=310609&r2=310610&view=diff
==============================================================================
--- llvm/trunk/unittests/CodeGen/CMakeLists.txt (original)
+++ llvm/trunk/unittests/CodeGen/CMakeLists.txt Thu Aug 10 08:35:25 2017
@@ -9,6 +9,7 @@ set(CodeGenSources
DIEHashTest.cpp
LowLevelTypeTest.cpp
MachineInstrBundleIteratorTest.cpp
+ MachineOperandTest.cpp
ScalableVectorMVTsTest.cpp
)
Added: llvm/trunk/unittests/CodeGen/MachineOperandTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CodeGen/MachineOperandTest.cpp?rev=310610&view=auto
==============================================================================
--- llvm/trunk/unittests/CodeGen/MachineOperandTest.cpp (added)
+++ llvm/trunk/unittests/CodeGen/MachineOperandTest.cpp Thu Aug 10 08:35:25 2017
@@ -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
More information about the llvm-commits
mailing list