1//===- subzero/unittest/AssemblerX8664/GPRArith.cpp -----------------------===//
2//
3//                        The Subzero Code Generator
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9#include "AssemblerX8664/TestUtil.h"
10
11namespace Ice {
12namespace X8664 {
13namespace Test {
14namespace {
15
16TEST_F(AssemblerX8664LowLevelTest, Nop) {
17#define TestImpl(Size, ...)                                                    \
18  do {                                                                         \
19    static constexpr char TestString[] = "(" #Size ", " #__VA_ARGS__ ")";      \
20    __ nop(Size);                                                              \
21    ASSERT_EQ(Size##u, codeBytesSize()) << TestString;                         \
22    ASSERT_TRUE(verifyBytes<Size>(codeBytes(), __VA_ARGS__)) << TestString;    \
23    reset();                                                                   \
24  } while (0);
25
26  TestImpl(1, 0x90);
27  TestImpl(2, 0x66, 0x90);
28  TestImpl(3, 0x0F, 0x1F, 0x00);
29  TestImpl(4, 0x0F, 0x1F, 0x40, 0x00);
30  TestImpl(5, 0x0F, 0x1F, 0x44, 0x00, 0x00);
31  TestImpl(6, 0x66, 0x0F, 0x1F, 0x44, 0x00, 0x00);
32  TestImpl(7, 0x0F, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00);
33  TestImpl(8, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00);
34
35#undef TestImpl
36}
37
38TEST_F(AssemblerX8664LowLevelTest, Int3) {
39  __ int3();
40  static constexpr uint32_t ByteCount = 1;
41  ASSERT_EQ(ByteCount, codeBytesSize());
42  verifyBytes<ByteCount>(codeBytes(), 0xCC);
43}
44
45TEST_F(AssemblerX8664LowLevelTest, Hlt) {
46  __ hlt();
47  static constexpr uint32_t ByteCount = 1;
48  ASSERT_EQ(ByteCount, codeBytesSize());
49  verifyBytes<ByteCount>(codeBytes(), 0xF4);
50}
51
52TEST_F(AssemblerX8664LowLevelTest, Ud2) {
53  __ ud2();
54  static constexpr uint32_t ByteCount = 2;
55  ASSERT_EQ(ByteCount, codeBytesSize());
56  verifyBytes<ByteCount>(codeBytes(), 0x0F, 0x0B);
57}
58
59} // end of anonymous namespace
60} // end of namespace Test
61} // end of namespace X8664
62} // end of namespace Ice
63