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