Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 1 | //===-- AssemblerTest.cpp ---------------------------------------*- C++ -*-===// |
| 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 "../Common/AssemblerUtils.h" |
| 11 | #include "X86InstrInfo.h" |
| 12 | |
| 13 | namespace exegesis { |
Guillaume Chatelet | fb94354 | 2018-08-01 14:41:45 +0000 | [diff] [blame^] | 14 | |
| 15 | void InitializeX86ExegesisTarget(); |
| 16 | |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 17 | namespace { |
| 18 | |
| 19 | using llvm::MCInstBuilder; |
| 20 | using llvm::X86::EAX; |
| 21 | using llvm::X86::MOV32ri; |
| 22 | using llvm::X86::MOV64ri32; |
| 23 | using llvm::X86::RAX; |
| 24 | using llvm::X86::XOR32rr; |
| 25 | |
| 26 | class X86MachineFunctionGeneratorTest |
| 27 | : public MachineFunctionGeneratorBaseTest { |
| 28 | protected: |
| 29 | X86MachineFunctionGeneratorTest() |
| 30 | : MachineFunctionGeneratorBaseTest("x86_64-unknown-linux", "haswell") {} |
| 31 | |
| 32 | static void SetUpTestCase() { |
| 33 | LLVMInitializeX86TargetInfo(); |
| 34 | LLVMInitializeX86TargetMC(); |
| 35 | LLVMInitializeX86Target(); |
| 36 | LLVMInitializeX86AsmPrinter(); |
Guillaume Chatelet | fb94354 | 2018-08-01 14:41:45 +0000 | [diff] [blame^] | 37 | InitializeX86ExegesisTarget(); |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 38 | } |
| 39 | }; |
| 40 | |
Clement Courbet | 3d5e08d | 2018-05-17 11:55:08 +0000 | [diff] [blame] | 41 | TEST_F(X86MachineFunctionGeneratorTest, DISABLED_JitFunction) { |
Guillaume Chatelet | fb94354 | 2018-08-01 14:41:45 +0000 | [diff] [blame^] | 42 | Check(ExegesisTarget::getDefault(), {}, llvm::MCInst(), 0xc3); |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Guillaume Chatelet | fb94354 | 2018-08-01 14:41:45 +0000 | [diff] [blame^] | 45 | TEST_F(X86MachineFunctionGeneratorTest, DISABLED_JitFunctionXOR32rr_Default) { |
| 46 | Check(ExegesisTarget::getDefault(), {EAX}, |
| 47 | MCInstBuilder(XOR32rr).addReg(EAX).addReg(EAX).addReg(EAX), 0x31, 0xc0, |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 48 | 0xc3); |
| 49 | } |
| 50 | |
Guillaume Chatelet | fb94354 | 2018-08-01 14:41:45 +0000 | [diff] [blame^] | 51 | TEST_F(X86MachineFunctionGeneratorTest, DISABLED_JitFunctionXOR32rr_X86) { |
| 52 | const auto *ET = ExegesisTarget::lookup(llvm::Triple("x86_64-unknown-linux")); |
| 53 | ASSERT_NE(ET, nullptr); |
| 54 | Check(*ET, {EAX}, MCInstBuilder(XOR32rr).addReg(EAX).addReg(EAX).addReg(EAX), |
| 55 | // mov eax, 1 |
| 56 | 0xb8, 0x01, 0x00, 0x00, 0x00, |
| 57 | // xor eax, eax |
| 58 | 0x31, 0xc0, 0xc3); |
| 59 | } |
| 60 | |
Clement Courbet | 3d5e08d | 2018-05-17 11:55:08 +0000 | [diff] [blame] | 61 | TEST_F(X86MachineFunctionGeneratorTest, DISABLED_JitFunctionMOV64ri) { |
Guillaume Chatelet | fb94354 | 2018-08-01 14:41:45 +0000 | [diff] [blame^] | 62 | Check(ExegesisTarget::getDefault(), {}, |
| 63 | MCInstBuilder(MOV64ri32).addReg(RAX).addImm(42), 0x48, 0xc7, 0xc0, 0x2a, |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 64 | 0x00, 0x00, 0x00, 0xc3); |
| 65 | } |
| 66 | |
Clement Courbet | 3d5e08d | 2018-05-17 11:55:08 +0000 | [diff] [blame] | 67 | TEST_F(X86MachineFunctionGeneratorTest, DISABLED_JitFunctionMOV32ri) { |
Guillaume Chatelet | fb94354 | 2018-08-01 14:41:45 +0000 | [diff] [blame^] | 68 | Check(ExegesisTarget::getDefault(), {}, |
| 69 | MCInstBuilder(MOV32ri).addReg(EAX).addImm(42), 0xb8, 0x2a, 0x00, 0x00, |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 70 | 0x00, 0xc3); |
| 71 | } |
| 72 | |
| 73 | } // namespace |
| 74 | } // namespace exegesis |