12fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto//===- subzero/unittest/AssemblerX8632/Other.cpp --------------------------===// 22fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto// 32fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto// The Subzero Code Generator 42fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto// 52fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto// This file is distributed under the University of Illinois Open Source 62fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto// License. See LICENSE.TXT for details. 72fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto// 82fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto//===----------------------------------------------------------------------===// 92fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto#include "AssemblerX8632/TestUtil.h" 102fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto 112fea26cae5a6b140c67e18aec3dcf645a16694d5John Portonamespace Ice { 122fea26cae5a6b140c67e18aec3dcf645a16694d5John Portonamespace X8632 { 132fea26cae5a6b140c67e18aec3dcf645a16694d5John Portonamespace Test { 142fea26cae5a6b140c67e18aec3dcf645a16694d5John Portonamespace { 152fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto 162fea26cae5a6b140c67e18aec3dcf645a16694d5John PortoTEST_F(AssemblerX8632LowLevelTest, Nop) { 172fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto#define TestImpl(Size, ...) \ 182fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto do { \ 192fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto static constexpr char TestString[] = "(" #Size ", " #__VA_ARGS__ ")"; \ 202fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto __ nop(Size); \ 212fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto ASSERT_EQ(Size##u, codeBytesSize()) << TestString; \ 222fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto ASSERT_TRUE(verifyBytes<Size>(codeBytes(), __VA_ARGS__)) << TestString; \ 232fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto reset(); \ 242fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto } while (0); 252fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto 262fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(1, 0x90); 272fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(2, 0x66, 0x90); 282fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(3, 0x0F, 0x1F, 0x00); 292fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(4, 0x0F, 0x1F, 0x40, 0x00); 302fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(5, 0x0F, 0x1F, 0x44, 0x00, 0x00); 312fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(6, 0x66, 0x0F, 0x1F, 0x44, 0x00, 0x00); 322fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(7, 0x0F, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00); 332fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(8, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00); 342fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto 352fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto#undef TestImpl 362fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto} 372fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto 382fea26cae5a6b140c67e18aec3dcf645a16694d5John PortoTEST_F(AssemblerX8632LowLevelTest, Int3) { 392fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto __ int3(); 402fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto static constexpr uint32_t ByteCount = 1; 412fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto ASSERT_EQ(ByteCount, codeBytesSize()); 422fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto verifyBytes<ByteCount>(codeBytes(), 0xCC); 432fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto} 442fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto 452fea26cae5a6b140c67e18aec3dcf645a16694d5John PortoTEST_F(AssemblerX8632LowLevelTest, Hlt) { 462fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto __ hlt(); 472fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto static constexpr uint32_t ByteCount = 1; 482fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto ASSERT_EQ(ByteCount, codeBytesSize()); 492fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto verifyBytes<ByteCount>(codeBytes(), 0xF4); 502fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto} 512fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto 522fea26cae5a6b140c67e18aec3dcf645a16694d5John PortoTEST_F(AssemblerX8632LowLevelTest, Ud2) { 532fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto __ ud2(); 542fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto static constexpr uint32_t ByteCount = 2; 552fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto ASSERT_EQ(ByteCount, codeBytesSize()); 562fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto verifyBytes<ByteCount>(codeBytes(), 0x0F, 0x0B); 572fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto} 582fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto 592fea26cae5a6b140c67e18aec3dcf645a16694d5John PortoTEST_F(AssemblerX8632LowLevelTest, EmitSegmentOverride) { 602fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto#define TestImpl(Prefix) \ 612fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto do { \ 622fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto static constexpr uint8_t ByteCount = 1; \ 632fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto __ emitSegmentOverride(Prefix); \ 642fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto ASSERT_EQ(ByteCount, codeBytesSize()) << Prefix; \ 652fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto verifyBytes<ByteCount>(codeBytes(), Prefix); \ 662fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto reset(); \ 672fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto } while (0) 682fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto 692fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(0x26); 702fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(0x2E); 712fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(0x36); 722fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(0x3E); 732fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(0x64); 742fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(0x65); 752fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(0x66); 762fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto TestImpl(0x67); 772fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto 782fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto#undef TestImpl 792fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto} 802fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto 812fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto} // end of anonymous namespace 822fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto} // end of namespace Test 832fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto} // end of namespace X8632 842fea26cae5a6b140c67e18aec3dcf645a16694d5John Porto} // end of namespace Ice 85