blob: b7548f8f3c357cb5057492044fad5ed30e266592 [file] [log] [blame]
Clement Courbet44b4c542018-06-19 11:28:59 +00001//===-- Target.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#include "../Target.h"
10
Clement Courbet4860b982018-06-26 08:49:30 +000011#include "../Latency.h"
12#include "../Uops.h"
Clement Courbet717c9762018-06-28 07:41:16 +000013#include "MCTargetDesc/X86BaseInfo.h"
Clement Courbeta51efc22018-06-25 13:12:02 +000014#include "MCTargetDesc/X86MCTargetDesc.h"
Clement Courbet6fd00e32018-06-20 11:54:35 +000015#include "X86.h"
Clement Courbeta51efc22018-06-25 13:12:02 +000016#include "X86RegisterInfo.h"
Clement Courbete7851692018-07-03 06:17:05 +000017#include "X86Subtarget.h"
Clement Courbeta51efc22018-06-25 13:12:02 +000018#include "llvm/MC/MCInstBuilder.h"
Clement Courbet6fd00e32018-06-20 11:54:35 +000019
Clement Courbet44b4c542018-06-19 11:28:59 +000020namespace exegesis {
21
22namespace {
23
Guillaume Chatelet3c639f32018-10-22 14:46:08 +000024// A chunk of instruction's operands that represents a single memory access.
25struct MemoryOperandRange {
26 MemoryOperandRange(llvm::ArrayRef<Operand> Operands) : Ops(Operands) {}
27
28 // Setup InstructionTemplate so the memory access represented by this object
29 // points to [reg] + offset.
30 void fillOrDie(InstructionTemplate &IT, unsigned Reg, unsigned Offset) {
31 switch (Ops.size()) {
32 case 5:
33 IT.getValueFor(Ops[0]) = llvm::MCOperand::createReg(Reg); // BaseReg
34 IT.getValueFor(Ops[1]) = llvm::MCOperand::createImm(1); // ScaleAmt
35 IT.getValueFor(Ops[2]) = llvm::MCOperand::createReg(0); // IndexReg
36 IT.getValueFor(Ops[3]) = llvm::MCOperand::createImm(Offset); // Disp
37 IT.getValueFor(Ops[4]) = llvm::MCOperand::createReg(0); // Segment
38 break;
39 default:
40 llvm::errs() << Ops.size() << "-op are not handled right now ("
41 << IT.Instr.Name << ")\n";
42 llvm_unreachable("Invalid memory configuration");
43 }
44 }
45
46 // Returns whether Range can be filled.
47 static bool isValid(const MemoryOperandRange &Range) {
48 return Range.Ops.size() == 5;
49 }
50
51 // Returns whether Op is a valid memory operand.
52 static bool isMemoryOperand(const Operand &Op) {
53 return Op.isMemory() && Op.isExplicit();
54 }
55
56 llvm::ArrayRef<Operand> Ops;
57};
58
59// X86 memory access involve non constant number of operands, this function
60// extracts contiguous memory operands into MemoryOperandRange so it's easier to
61// check and fill.
62static std::vector<MemoryOperandRange>
63getMemoryOperandRanges(llvm::ArrayRef<Operand> Operands) {
64 std::vector<MemoryOperandRange> Result;
65 while (!Operands.empty()) {
66 Operands = Operands.drop_until(MemoryOperandRange::isMemoryOperand);
67 auto MemoryOps = Operands.take_while(MemoryOperandRange::isMemoryOperand);
68 if (!MemoryOps.empty())
69 Result.push_back(MemoryOps);
70 Operands = Operands.drop_front(MemoryOps.size());
71 }
72 return Result;
73}
74
Guillaume Chatelet946fb052018-10-12 15:12:22 +000075static llvm::Error IsInvalidOpcode(const Instruction &Instr) {
76 const auto OpcodeName = Instr.Name;
77 if (OpcodeName.startswith("POPF") || OpcodeName.startswith("PUSHF") ||
78 OpcodeName.startswith("ADJCALLSTACK"))
79 return llvm::make_error<BenchmarkFailure>(
Clement Courbet8d0dd0b2018-10-19 12:24:49 +000080 "unsupported opcode: Push/Pop/AdjCallStack");
Guillaume Chatelet3c639f32018-10-22 14:46:08 +000081 const bool ValidMemoryOperands = llvm::all_of(
82 getMemoryOperandRanges(Instr.Operands), MemoryOperandRange::isValid);
83 if (!ValidMemoryOperands)
84 return llvm::make_error<BenchmarkFailure>(
85 "unsupported opcode: non uniform memory access");
86 // We do not handle instructions with OPERAND_PCREL.
87 for (const Operand &Op : Instr.Operands)
88 if (Op.isExplicit() &&
89 Op.getExplicitOperandInfo().OperandType == llvm::MCOI::OPERAND_PCREL)
90 return llvm::make_error<BenchmarkFailure>(
91 "unsupported opcode: PC relative operand");
Clement Courbet8d0dd0b2018-10-19 12:24:49 +000092 // We do not handle second-form X87 instructions. We only handle first-form
93 // ones (_Fp), see comment in X86InstrFPStack.td.
94 for (const Operand &Op : Instr.Operands)
95 if (Op.isReg() && Op.isExplicit() &&
96 Op.getExplicitOperandInfo().RegClass == llvm::X86::RSTRegClassID)
97 return llvm::make_error<BenchmarkFailure>(
98 "unsupported second-form X87 instruction");
Guillaume Chatelet946fb052018-10-12 15:12:22 +000099 return llvm::Error::success();
100}
101
102static unsigned GetX86FPFlags(const Instruction &Instr) {
103 return Instr.Description->TSFlags & llvm::X86II::FPTypeMask;
104}
105
106class X86LatencySnippetGenerator : public LatencySnippetGenerator {
107public:
108 using LatencySnippetGenerator::LatencySnippetGenerator;
Clement Courbet4860b982018-06-26 08:49:30 +0000109
Guillaume Chatelet296a8622018-10-15 09:09:19 +0000110 llvm::Expected<std::vector<CodeTemplate>>
111 generateCodeTemplates(const Instruction &Instr) const override {
Guillaume Chatelet946fb052018-10-12 15:12:22 +0000112 if (auto E = IsInvalidOpcode(Instr))
113 return std::move(E);
Clement Courbet717c9762018-06-28 07:41:16 +0000114
Guillaume Chatelet946fb052018-10-12 15:12:22 +0000115 switch (GetX86FPFlags(Instr)) {
Clement Courbet717c9762018-06-28 07:41:16 +0000116 case llvm::X86II::NotFP:
Guillaume Chatelet296a8622018-10-15 09:09:19 +0000117 return LatencySnippetGenerator::generateCodeTemplates(Instr);
Clement Courbet717c9762018-06-28 07:41:16 +0000118 case llvm::X86II::ZeroArgFP:
Clement Courbet717c9762018-06-28 07:41:16 +0000119 case llvm::X86II::OneArgFP:
Guillaume Chatelet946fb052018-10-12 15:12:22 +0000120 case llvm::X86II::SpecialFP:
121 case llvm::X86II::CompareFP:
122 case llvm::X86II::CondMovFP:
123 return llvm::make_error<BenchmarkFailure>("Unsupported x87 Instruction");
Clement Courbet717c9762018-06-28 07:41:16 +0000124 case llvm::X86II::OneArgFPRW:
Guillaume Chatelet946fb052018-10-12 15:12:22 +0000125 case llvm::X86II::TwoArgFP:
126 // These are instructions like
127 // - `ST(0) = fsqrt(ST(0))` (OneArgFPRW)
128 // - `ST(0) = ST(0) + ST(i)` (TwoArgFP)
129 // They are intrinsically serial and do not modify the state of the stack.
Guillaume Chatelet296a8622018-10-15 09:09:19 +0000130 return generateSelfAliasingCodeTemplates(Instr);
Guillaume Chatelet946fb052018-10-12 15:12:22 +0000131 default:
132 llvm_unreachable("Unknown FP Type!");
133 }
134 }
135};
136
137class X86UopsSnippetGenerator : public UopsSnippetGenerator {
138public:
139 using UopsSnippetGenerator::UopsSnippetGenerator;
140
Guillaume Chatelet296a8622018-10-15 09:09:19 +0000141 llvm::Expected<std::vector<CodeTemplate>>
142 generateCodeTemplates(const Instruction &Instr) const override {
Guillaume Chatelet946fb052018-10-12 15:12:22 +0000143 if (auto E = IsInvalidOpcode(Instr))
144 return std::move(E);
145
146 switch (GetX86FPFlags(Instr)) {
147 case llvm::X86II::NotFP:
Guillaume Chatelet296a8622018-10-15 09:09:19 +0000148 return UopsSnippetGenerator::generateCodeTemplates(Instr);
Guillaume Chatelet946fb052018-10-12 15:12:22 +0000149 case llvm::X86II::ZeroArgFP:
150 case llvm::X86II::OneArgFP:
151 case llvm::X86II::SpecialFP:
152 return llvm::make_error<BenchmarkFailure>("Unsupported x87 Instruction");
153 case llvm::X86II::OneArgFPRW:
154 case llvm::X86II::TwoArgFP:
Clement Courbet717c9762018-06-28 07:41:16 +0000155 // These are instructions like
156 // - `ST(0) = fsqrt(ST(0))` (OneArgFPRW)
157 // - `ST(0) = ST(0) + ST(i)` (TwoArgFP)
158 // They are intrinsically serial and do not modify the state of the stack.
159 // We generate the same code for latency and uops.
Guillaume Chatelet296a8622018-10-15 09:09:19 +0000160 return generateSelfAliasingCodeTemplates(Instr);
Clement Courbet717c9762018-06-28 07:41:16 +0000161 case llvm::X86II::CompareFP:
Clement Courbet717c9762018-06-28 07:41:16 +0000162 case llvm::X86II::CondMovFP:
Guillaume Chatelet946fb052018-10-12 15:12:22 +0000163 // We can compute uops for any FP instruction that does not grow or shrink
164 // the stack (either do not touch the stack or push as much as they pop).
Guillaume Chatelet296a8622018-10-15 09:09:19 +0000165 return generateUnconstrainedCodeTemplates(
Guillaume Chatelet946fb052018-10-12 15:12:22 +0000166 Instr, "instruction does not grow/shrink the FP stack");
Clement Courbet717c9762018-06-28 07:41:16 +0000167 default:
168 llvm_unreachable("Unknown FP Type!");
169 }
Clement Courbet4860b982018-06-26 08:49:30 +0000170 }
171};
172
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000173static unsigned GetLoadImmediateOpcode(unsigned RegBitWidth) {
174 switch (RegBitWidth) {
Guillaume Chatelet5ad29092018-09-18 11:26:27 +0000175 case 8:
176 return llvm::X86::MOV8ri;
177 case 16:
178 return llvm::X86::MOV16ri;
179 case 32:
180 return llvm::X86::MOV32ri;
181 case 64:
182 return llvm::X86::MOV64ri;
183 }
184 llvm_unreachable("Invalid Value Width");
185}
186
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000187// Generates instruction to load an immediate value into a register.
188static llvm::MCInst loadImmediate(unsigned Reg, unsigned RegBitWidth,
189 const llvm::APInt &Value) {
190 if (Value.getBitWidth() > RegBitWidth)
191 llvm_unreachable("Value must fit in the Register");
192 return llvm::MCInstBuilder(GetLoadImmediateOpcode(RegBitWidth))
Guillaume Chatelet5ad29092018-09-18 11:26:27 +0000193 .addReg(Reg)
194 .addImm(Value.getZExtValue());
195}
196
197// Allocates scratch memory on the stack.
198static llvm::MCInst allocateStackSpace(unsigned Bytes) {
199 return llvm::MCInstBuilder(llvm::X86::SUB64ri8)
200 .addReg(llvm::X86::RSP)
201 .addReg(llvm::X86::RSP)
202 .addImm(Bytes);
203}
204
205// Fills scratch memory at offset `OffsetBytes` with value `Imm`.
206static llvm::MCInst fillStackSpace(unsigned MovOpcode, unsigned OffsetBytes,
207 uint64_t Imm) {
208 return llvm::MCInstBuilder(MovOpcode)
209 // Address = ESP
210 .addReg(llvm::X86::RSP) // BaseReg
211 .addImm(1) // ScaleAmt
212 .addReg(0) // IndexReg
213 .addImm(OffsetBytes) // Disp
214 .addReg(0) // Segment
215 // Immediate.
216 .addImm(Imm);
217}
218
219// Loads scratch memory into register `Reg` using opcode `RMOpcode`.
220static llvm::MCInst loadToReg(unsigned Reg, unsigned RMOpcode) {
221 return llvm::MCInstBuilder(RMOpcode)
222 .addReg(Reg)
223 // Address = ESP
224 .addReg(llvm::X86::RSP) // BaseReg
225 .addImm(1) // ScaleAmt
226 .addReg(0) // IndexReg
227 .addImm(0) // Disp
228 .addReg(0); // Segment
229}
230
231// Releases scratch memory.
232static llvm::MCInst releaseStackSpace(unsigned Bytes) {
233 return llvm::MCInstBuilder(llvm::X86::ADD64ri8)
234 .addReg(llvm::X86::RSP)
235 .addReg(llvm::X86::RSP)
236 .addImm(Bytes);
237}
238
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000239// Reserves some space on the stack, fills it with the content of the provided
240// constant and provide methods to load the stack value into a register.
Guillaume Chatelet5ad29092018-09-18 11:26:27 +0000241struct ConstantInliner {
Clement Courbet78b2e732018-09-25 07:31:44 +0000242 explicit ConstantInliner(const llvm::APInt &Constant) : Constant_(Constant) {}
Guillaume Chatelet5ad29092018-09-18 11:26:27 +0000243
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000244 std::vector<llvm::MCInst> loadAndFinalize(unsigned Reg, unsigned RegBitWidth,
245 unsigned Opcode) {
Clement Courbet78b2e732018-09-25 07:31:44 +0000246 assert((RegBitWidth & 7) == 0 &&
247 "RegBitWidth must be a multiple of 8 bits");
248 initStack(RegBitWidth / 8);
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000249 add(loadToReg(Reg, Opcode));
Clement Courbet78b2e732018-09-25 07:31:44 +0000250 add(releaseStackSpace(RegBitWidth / 8));
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000251 return std::move(Instructions);
Guillaume Chatelet8721ad92018-09-18 11:26:35 +0000252 }
253
Clement Courbetc51f4522018-10-19 09:56:54 +0000254 std::vector<llvm::MCInst> loadX87STAndFinalize(unsigned Reg) {
255 initStack(kF80Bytes);
256 add(llvm::MCInstBuilder(llvm::X86::LD_F80m)
257 // Address = ESP
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000258 .addReg(llvm::X86::RSP) // BaseReg
259 .addImm(1) // ScaleAmt
260 .addReg(0) // IndexReg
261 .addImm(0) // Disp
262 .addReg(0)); // Segment
263 if (Reg != llvm::X86::ST0)
264 add(llvm::MCInstBuilder(llvm::X86::ST_Frr).addReg(Reg));
Clement Courbetc51f4522018-10-19 09:56:54 +0000265 add(releaseStackSpace(kF80Bytes));
266 return std::move(Instructions);
267 }
268
269 std::vector<llvm::MCInst> loadX87FPAndFinalize(unsigned Reg) {
270 initStack(kF80Bytes);
271 add(llvm::MCInstBuilder(llvm::X86::LD_Fp80m)
272 .addReg(Reg)
273 // Address = ESP
274 .addReg(llvm::X86::RSP) // BaseReg
275 .addImm(1) // ScaleAmt
276 .addReg(0) // IndexReg
277 .addImm(0) // Disp
278 .addReg(0)); // Segment
279 add(releaseStackSpace(kF80Bytes));
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000280 return std::move(Instructions);
281 }
282
283 std::vector<llvm::MCInst> popFlagAndFinalize() {
Clement Courbet78b2e732018-09-25 07:31:44 +0000284 initStack(8);
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000285 add(llvm::MCInstBuilder(llvm::X86::POPF64));
Simon Pilgrimf652ef32018-09-18 15:38:16 +0000286 return std::move(Instructions);
287 }
288
289private:
Clement Courbetc51f4522018-10-19 09:56:54 +0000290 static constexpr const unsigned kF80Bytes = 10; // 80 bits.
291
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000292 ConstantInliner &add(const llvm::MCInst &Inst) {
293 Instructions.push_back(Inst);
294 return *this;
295 }
296
Clement Courbet78b2e732018-09-25 07:31:44 +0000297 void initStack(unsigned Bytes) {
298 assert(Constant_.getBitWidth() <= Bytes * 8 &&
299 "Value does not have the correct size");
300 const llvm::APInt WideConstant = Constant_.getBitWidth() < Bytes * 8
301 ? Constant_.sext(Bytes * 8)
302 : Constant_;
303 add(allocateStackSpace(Bytes));
304 size_t ByteOffset = 0;
305 for (; Bytes - ByteOffset >= 4; ByteOffset += 4)
306 add(fillStackSpace(
307 llvm::X86::MOV32mi, ByteOffset,
308 WideConstant.extractBits(32, ByteOffset * 8).getZExtValue()));
309 if (Bytes - ByteOffset >= 2) {
310 add(fillStackSpace(
311 llvm::X86::MOV16mi, ByteOffset,
312 WideConstant.extractBits(16, ByteOffset * 8).getZExtValue()));
313 ByteOffset += 2;
314 }
315 if (Bytes - ByteOffset >= 1)
316 add(fillStackSpace(
317 llvm::X86::MOV8mi, ByteOffset,
318 WideConstant.extractBits(8, ByteOffset * 8).getZExtValue()));
319 }
320
321 llvm::APInt Constant_;
Guillaume Chatelet5ad29092018-09-18 11:26:27 +0000322 std::vector<llvm::MCInst> Instructions;
323};
324
Clement Courbet44b4c542018-06-19 11:28:59 +0000325class ExegesisX86Target : public ExegesisTarget {
Clement Courbet6fd00e32018-06-20 11:54:35 +0000326 void addTargetSpecificPasses(llvm::PassManagerBase &PM) const override {
327 // Lowers FP pseudo-instructions, e.g. ABS_Fp32 -> ABS_F.
Clement Courbet717c9762018-06-28 07:41:16 +0000328 PM.add(llvm::createX86FloatingPointStackifierPass());
Clement Courbet6fd00e32018-06-20 11:54:35 +0000329 }
330
Guillaume Chateletfb943542018-08-01 14:41:45 +0000331 unsigned getScratchMemoryRegister(const llvm::Triple &TT) const override {
332 if (!TT.isArch64Bit()) {
333 // FIXME: This would require popping from the stack, so we would have to
334 // add some additional setup code.
335 return 0;
336 }
337 return TT.isOSWindows() ? llvm::X86::RCX : llvm::X86::RDI;
338 }
339
340 unsigned getMaxMemoryAccessSize() const override { return 64; }
341
Guillaume Chatelet70ac0192018-09-27 09:23:04 +0000342 void fillMemoryOperands(InstructionTemplate &IT, unsigned Reg,
Guillaume Chateletfb943542018-08-01 14:41:45 +0000343 unsigned Offset) const override {
344 // FIXME: For instructions that read AND write to memory, we use the same
345 // value for input and output.
Guillaume Chatelet3c639f32018-10-22 14:46:08 +0000346 for (auto &MemoryRange : getMemoryOperandRanges(IT.Instr.Operands))
347 MemoryRange.fillOrDie(IT, Reg, Offset);
Guillaume Chateletfb943542018-08-01 14:41:45 +0000348 }
349
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000350 std::vector<llvm::MCInst> setRegTo(const llvm::MCSubtargetInfo &STI,
351 unsigned Reg,
352 const llvm::APInt &Value) const override {
Guillaume Chatelet8721ad92018-09-18 11:26:35 +0000353 if (llvm::X86::GR8RegClass.contains(Reg))
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000354 return {loadImmediate(Reg, 8, Value)};
Guillaume Chatelet8721ad92018-09-18 11:26:35 +0000355 if (llvm::X86::GR16RegClass.contains(Reg))
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000356 return {loadImmediate(Reg, 16, Value)};
Guillaume Chatelet8721ad92018-09-18 11:26:35 +0000357 if (llvm::X86::GR32RegClass.contains(Reg))
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000358 return {loadImmediate(Reg, 32, Value)};
Guillaume Chatelet8721ad92018-09-18 11:26:35 +0000359 if (llvm::X86::GR64RegClass.contains(Reg))
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000360 return {loadImmediate(Reg, 64, Value)};
361 ConstantInliner CI(Value);
Guillaume Chatelet5ad29092018-09-18 11:26:27 +0000362 if (llvm::X86::VR64RegClass.contains(Reg))
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000363 return CI.loadAndFinalize(Reg, 64, llvm::X86::MMX_MOVQ64rm);
Guillaume Chatelet8721ad92018-09-18 11:26:35 +0000364 if (llvm::X86::VR128XRegClass.contains(Reg)) {
365 if (STI.getFeatureBits()[llvm::X86::FeatureAVX512])
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000366 return CI.loadAndFinalize(Reg, 128, llvm::X86::VMOVDQU32Z128rm);
Guillaume Chatelet8721ad92018-09-18 11:26:35 +0000367 if (STI.getFeatureBits()[llvm::X86::FeatureAVX])
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000368 return CI.loadAndFinalize(Reg, 128, llvm::X86::VMOVDQUrm);
369 return CI.loadAndFinalize(Reg, 128, llvm::X86::MOVDQUrm);
Guillaume Chatelet8721ad92018-09-18 11:26:35 +0000370 }
371 if (llvm::X86::VR256XRegClass.contains(Reg)) {
372 if (STI.getFeatureBits()[llvm::X86::FeatureAVX512])
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000373 return CI.loadAndFinalize(Reg, 256, llvm::X86::VMOVDQU32Z256rm);
374 if (STI.getFeatureBits()[llvm::X86::FeatureAVX])
375 return CI.loadAndFinalize(Reg, 256, llvm::X86::VMOVDQUYrm);
Guillaume Chatelet8721ad92018-09-18 11:26:35 +0000376 }
377 if (llvm::X86::VR512RegClass.contains(Reg))
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000378 if (STI.getFeatureBits()[llvm::X86::FeatureAVX512])
379 return CI.loadAndFinalize(Reg, 512, llvm::X86::VMOVDQU32Zrm);
380 if (llvm::X86::RSTRegClass.contains(Reg)) {
Clement Courbetc51f4522018-10-19 09:56:54 +0000381 return CI.loadX87STAndFinalize(Reg);
382 }
383 if (llvm::X86::RFP32RegClass.contains(Reg) ||
384 llvm::X86::RFP64RegClass.contains(Reg) ||
385 llvm::X86::RFP80RegClass.contains(Reg)) {
386 return CI.loadX87FPAndFinalize(Reg);
Guillaume Chatelet8721ad92018-09-18 11:26:35 +0000387 }
Guillaume Chateletc96a97b2018-09-20 12:22:18 +0000388 if (Reg == llvm::X86::EFLAGS)
389 return CI.popFlagAndFinalize();
390 return {}; // Not yet implemented.
Clement Courbeta51efc22018-06-25 13:12:02 +0000391 }
392
Clement Courbetd939f6d2018-09-13 07:40:53 +0000393 std::unique_ptr<SnippetGenerator>
394 createLatencySnippetGenerator(const LLVMState &State) const override {
Guillaume Chatelet946fb052018-10-12 15:12:22 +0000395 return llvm::make_unique<X86LatencySnippetGenerator>(State);
Clement Courbet4860b982018-06-26 08:49:30 +0000396 }
397
Clement Courbetd939f6d2018-09-13 07:40:53 +0000398 std::unique_ptr<SnippetGenerator>
399 createUopsSnippetGenerator(const LLVMState &State) const override {
Guillaume Chatelet946fb052018-10-12 15:12:22 +0000400 return llvm::make_unique<X86UopsSnippetGenerator>(State);
Clement Courbet4860b982018-06-26 08:49:30 +0000401 }
402
Clement Courbet44b4c542018-06-19 11:28:59 +0000403 bool matchesArch(llvm::Triple::ArchType Arch) const override {
404 return Arch == llvm::Triple::x86_64 || Arch == llvm::Triple::x86;
405 }
406};
407
408} // namespace
409
Clement Courbetcff2caa2018-06-25 11:22:23 +0000410static ExegesisTarget *getTheExegesisX86Target() {
Clement Courbet44b4c542018-06-19 11:28:59 +0000411 static ExegesisX86Target Target;
412 return &Target;
413}
414
415void InitializeX86ExegesisTarget() {
416 ExegesisTarget::registerTarget(getTheExegesisX86Target());
417}
418
Clement Courbetcff2caa2018-06-25 11:22:23 +0000419} // namespace exegesis