blob: afbf4f4c36895740d01623b4b4877139d2b57d57 [file] [log] [blame]
Marcello Maggioni61f48ca2017-08-10 15:35:25 +00001//===- 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
14using namespace llvm;
15
16namespace {
17
18TEST(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