Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 1 | //===-- AssemblerTest.cpp ---------------------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "../Common/AssemblerUtils.h" |
| 10 | #include "X86InstrInfo.h" |
| 11 | |
Fangrui Song | 32401af | 2018-10-22 17:10:47 +0000 | [diff] [blame] | 12 | namespace llvm { |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 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 | |
Clement Courbet | 2caa3a2 | 2019-10-09 07:52:07 +0000 | [diff] [blame^] | 19 | using X86::EAX; |
| 20 | using X86::MOV32ri; |
| 21 | using X86::MOV64ri32; |
| 22 | using X86::RAX; |
| 23 | using X86::XOR32rr; |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 24 | |
| 25 | class X86MachineFunctionGeneratorTest |
| 26 | : public MachineFunctionGeneratorBaseTest { |
| 27 | protected: |
| 28 | X86MachineFunctionGeneratorTest() |
| 29 | : MachineFunctionGeneratorBaseTest("x86_64-unknown-linux", "haswell") {} |
| 30 | |
| 31 | static void SetUpTestCase() { |
| 32 | LLVMInitializeX86TargetInfo(); |
| 33 | LLVMInitializeX86TargetMC(); |
| 34 | LLVMInitializeX86Target(); |
| 35 | LLVMInitializeX86AsmPrinter(); |
Guillaume Chatelet | fb94354 | 2018-08-01 14:41:45 +0000 | [diff] [blame] | 36 | InitializeX86ExegesisTarget(); |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 37 | } |
| 38 | }; |
| 39 | |
Clement Courbet | 3d5e08d | 2018-05-17 11:55:08 +0000 | [diff] [blame] | 40 | TEST_F(X86MachineFunctionGeneratorTest, DISABLED_JitFunction) { |
Guillaume Chatelet | c96a97b | 2018-09-20 12:22:18 +0000 | [diff] [blame] | 41 | Check({}, llvm::MCInst(), 0xc3); |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 42 | } |
| 43 | |
Guillaume Chatelet | fb94354 | 2018-08-01 14:41:45 +0000 | [diff] [blame] | 44 | TEST_F(X86MachineFunctionGeneratorTest, DISABLED_JitFunctionXOR32rr_X86) { |
Guillaume Chatelet | c96a97b | 2018-09-20 12:22:18 +0000 | [diff] [blame] | 45 | Check({{EAX, llvm::APInt(32, 1)}}, |
| 46 | MCInstBuilder(XOR32rr).addReg(EAX).addReg(EAX).addReg(EAX), |
Guillaume Chatelet | fb94354 | 2018-08-01 14:41:45 +0000 | [diff] [blame] | 47 | // mov eax, 1 |
| 48 | 0xb8, 0x01, 0x00, 0x00, 0x00, |
| 49 | // xor eax, eax |
| 50 | 0x31, 0xc0, 0xc3); |
| 51 | } |
| 52 | |
Clement Courbet | 3d5e08d | 2018-05-17 11:55:08 +0000 | [diff] [blame] | 53 | TEST_F(X86MachineFunctionGeneratorTest, DISABLED_JitFunctionMOV64ri) { |
Guillaume Chatelet | c96a97b | 2018-09-20 12:22:18 +0000 | [diff] [blame] | 54 | Check({}, MCInstBuilder(MOV64ri32).addReg(RAX).addImm(42), 0x48, 0xc7, 0xc0, |
| 55 | 0x2a, 0x00, 0x00, 0x00, 0xc3); |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 56 | } |
| 57 | |
Clement Courbet | 3d5e08d | 2018-05-17 11:55:08 +0000 | [diff] [blame] | 58 | TEST_F(X86MachineFunctionGeneratorTest, DISABLED_JitFunctionMOV32ri) { |
Guillaume Chatelet | c96a97b | 2018-09-20 12:22:18 +0000 | [diff] [blame] | 59 | Check({}, MCInstBuilder(MOV32ri).addReg(EAX).addImm(42), 0xb8, 0x2a, 0x00, |
| 60 | 0x00, 0x00, 0xc3); |
Clement Courbet | 0e69e2d | 2018-05-17 10:52:18 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | } // namespace |
| 64 | } // namespace exegesis |
Fangrui Song | 32401af | 2018-10-22 17:10:47 +0000 | [diff] [blame] | 65 | } // namespace llvm |