Marcello Maggioni | 61f48ca | 2017-08-10 15:35:25 +0000 | [diff] [blame^] | 1 | //===- MachineOperandTest.cpp ---------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/ADT/ilist_node.h" |
| 11 | #include "llvm/CodeGen/MachineOperand.h" |
| 12 | #include "gtest/gtest.h" |
| 13 | |
| 14 | using namespace llvm; |
| 15 | |
| 16 | namespace { |
| 17 | |
| 18 | TEST(MachineOperandTest, ChangeToTargetIndexTest) { |
| 19 | // Creating a MachineOperand to change it to TargetIndex |
| 20 | MachineOperand MO = MachineOperand::CreateImm(50); |
| 21 | |
| 22 | // Checking some precondition on the newly created |
| 23 | // MachineOperand. |
| 24 | ASSERT_TRUE(MO.isImm()); |
| 25 | ASSERT_TRUE(MO.getImm() == 50); |
| 26 | ASSERT_FALSE(MO.isTargetIndex()); |
| 27 | |
| 28 | // Changing to TargetIndex with some arbitrary values |
| 29 | // for index, offset and flags. |
| 30 | MO.ChangeToTargetIndex(74, 57, 12); |
| 31 | |
| 32 | // Checking that the mutation to TargetIndex happened |
| 33 | // correctly. |
| 34 | ASSERT_TRUE(MO.isTargetIndex()); |
| 35 | ASSERT_TRUE(MO.getIndex() == 74); |
| 36 | ASSERT_TRUE(MO.getOffset() == 57); |
| 37 | ASSERT_TRUE(MO.getTargetFlags() == 12); |
| 38 | } |
| 39 | |
| 40 | } // end namespace |