]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/X86/X86Subtarget.h
Import CK as of commit 5221ae2f3722a78c7fc41e47069ad94983d3bccb.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / X86 / X86Subtarget.h
1 //===-- X86Subtarget.h - Define Subtarget for the X86 ----------*- 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 // This file declares the X86 specific subclass of TargetSubtargetInfo.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_X86_X86SUBTARGET_H
15 #define LLVM_LIB_TARGET_X86_X86SUBTARGET_H
16
17 #include "X86FrameLowering.h"
18 #include "X86ISelLowering.h"
19 #include "X86InstrInfo.h"
20 #include "X86SelectionDAGInfo.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/ADT/Triple.h"
23 #include "llvm/CodeGen/GlobalISel/CallLowering.h"
24 #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
25 #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
26 #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
27 #include "llvm/CodeGen/TargetSubtargetInfo.h"
28 #include "llvm/IR/CallingConv.h"
29 #include "llvm/MC/MCInstrItineraries.h"
30 #include "llvm/Target/TargetMachine.h"
31 #include <memory>
32
33 #define GET_SUBTARGETINFO_HEADER
34 #include "X86GenSubtargetInfo.inc"
35
36 namespace llvm {
37
38 class GlobalValue;
39
40 /// The X86 backend supports a number of different styles of PIC.
41 ///
42 namespace PICStyles {
43
44 enum Style {
45   StubPIC,          // Used on i386-darwin in pic mode.
46   GOT,              // Used on 32 bit elf on when in pic mode.
47   RIPRel,           // Used on X86-64 when in pic mode.
48   None              // Set when not in pic mode.
49 };
50
51 } // end namespace PICStyles
52
53 class X86Subtarget final : public X86GenSubtargetInfo {
54 public:  
55   enum X86ProcFamilyEnum {
56     Others,
57     IntelAtom,
58     IntelSLM,
59     IntelGLM,
60     IntelHaswell,
61     IntelBroadwell,
62     IntelSkylake,
63     IntelKNL,
64     IntelSKX,
65     IntelCannonlake,
66     IntelIcelake,
67   };
68
69 protected:
70   enum X86SSEEnum {
71     NoSSE, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, AVX, AVX2, AVX512F
72   };
73
74   enum X863DNowEnum {
75     NoThreeDNow, MMX, ThreeDNow, ThreeDNowA
76   };
77
78   /// X86 processor family: Intel Atom, and others
79   X86ProcFamilyEnum X86ProcFamily;
80
81   /// Which PIC style to use
82   PICStyles::Style PICStyle;
83
84   const TargetMachine &TM;
85
86   /// SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, or none supported.
87   X86SSEEnum X86SSELevel;
88
89   /// MMX, 3DNow, 3DNow Athlon, or none supported.
90   X863DNowEnum X863DNowLevel;
91
92   /// True if the processor supports X87 instructions.
93   bool HasX87;
94
95   /// True if this processor has conditional move instructions
96   /// (generally pentium pro+).
97   bool HasCMov;
98
99   /// True if the processor supports X86-64 instructions.
100   bool HasX86_64;
101
102   /// True if the processor supports POPCNT.
103   bool HasPOPCNT;
104
105   /// True if the processor supports SSE4A instructions.
106   bool HasSSE4A;
107
108   /// Target has AES instructions
109   bool HasAES;
110   bool HasVAES;
111
112   /// Target has FXSAVE/FXRESTOR instructions
113   bool HasFXSR;
114
115   /// Target has XSAVE instructions
116   bool HasXSAVE;
117
118   /// Target has XSAVEOPT instructions
119   bool HasXSAVEOPT;
120
121   /// Target has XSAVEC instructions
122   bool HasXSAVEC;
123
124   /// Target has XSAVES instructions
125   bool HasXSAVES;
126
127   /// Target has carry-less multiplication
128   bool HasPCLMUL;
129   bool HasVPCLMULQDQ;
130
131   /// Target has Galois Field Arithmetic instructions
132   bool HasGFNI;
133
134   /// Target has 3-operand fused multiply-add
135   bool HasFMA;
136
137   /// Target has 4-operand fused multiply-add
138   bool HasFMA4;
139
140   /// Target has XOP instructions
141   bool HasXOP;
142
143   /// Target has TBM instructions.
144   bool HasTBM;
145
146   /// Target has LWP instructions
147   bool HasLWP;
148
149   /// True if the processor has the MOVBE instruction.
150   bool HasMOVBE;
151
152   /// True if the processor has the RDRAND instruction.
153   bool HasRDRAND;
154
155   /// Processor has 16-bit floating point conversion instructions.
156   bool HasF16C;
157
158   /// Processor has FS/GS base insturctions.
159   bool HasFSGSBase;
160
161   /// Processor has LZCNT instruction.
162   bool HasLZCNT;
163
164   /// Processor has BMI1 instructions.
165   bool HasBMI;
166
167   /// Processor has BMI2 instructions.
168   bool HasBMI2;
169
170   /// Processor has VBMI instructions.
171   bool HasVBMI;
172
173   /// Processor has VBMI2 instructions.
174   bool HasVBMI2;
175
176   /// Processor has Integer Fused Multiply Add
177   bool HasIFMA;
178
179   /// Processor has RTM instructions.
180   bool HasRTM;
181
182   /// Processor has ADX instructions.
183   bool HasADX;
184
185   /// Processor has SHA instructions.
186   bool HasSHA;
187
188   /// Processor has PRFCHW instructions.
189   bool HasPRFCHW;
190
191   /// Processor has RDSEED instructions.
192   bool HasRDSEED;
193
194   /// Processor has LAHF/SAHF instructions.
195   bool HasLAHFSAHF;
196
197   /// Processor has MONITORX/MWAITX instructions.
198   bool HasMWAITX;
199
200   /// Processor has Cache Line Zero instruction
201   bool HasCLZERO;
202
203   /// Processor has Prefetch with intent to Write instruction
204   bool HasPREFETCHWT1;
205
206   /// True if SHLD instructions are slow.
207   bool IsSHLDSlow;
208
209   /// True if the PMULLD instruction is slow compared to PMULLW/PMULHW and
210   //  PMULUDQ.
211   bool IsPMULLDSlow;
212
213   /// True if unaligned memory accesses of 16-bytes are slow.
214   bool IsUAMem16Slow;
215
216   /// True if unaligned memory accesses of 32-bytes are slow.
217   bool IsUAMem32Slow;
218
219   /// True if SSE operations can have unaligned memory operands.
220   /// This may require setting a configuration bit in the processor.
221   bool HasSSEUnalignedMem;
222
223   /// True if this processor has the CMPXCHG16B instruction;
224   /// this is true for most x86-64 chips, but not the first AMD chips.
225   bool HasCmpxchg16b;
226
227   /// True if the LEA instruction should be used for adjusting
228   /// the stack pointer. This is an optimization for Intel Atom processors.
229   bool UseLeaForSP;
230
231   /// True if its preferable to combine to a single shuffle using a variable
232   /// mask over multiple fixed shuffles.
233   bool HasFastVariableShuffle;
234
235   /// True if there is no performance penalty to writing only the lower parts
236   /// of a YMM or ZMM register without clearing the upper part.
237   bool HasFastPartialYMMorZMMWrite;
238
239   /// True if gather is reasonably fast. This is true for Skylake client and
240   /// all AVX-512 CPUs.
241   bool HasFastGather;
242
243   /// True if hardware SQRTSS instruction is at least as fast (latency) as
244   /// RSQRTSS followed by a Newton-Raphson iteration.
245   bool HasFastScalarFSQRT;
246
247   /// True if hardware SQRTPS/VSQRTPS instructions are at least as fast
248   /// (throughput) as RSQRTPS/VRSQRTPS followed by a Newton-Raphson iteration.
249   bool HasFastVectorFSQRT;
250
251   /// True if 8-bit divisions are significantly faster than
252   /// 32-bit divisions and should be used when possible.
253   bool HasSlowDivide32;
254
255   /// True if 32-bit divides are significantly faster than
256   /// 64-bit divisions and should be used when possible.
257   bool HasSlowDivide64;
258
259   /// True if LZCNT instruction is fast.
260   bool HasFastLZCNT;
261
262   /// True if SHLD based rotate is fast.
263   bool HasFastSHLDRotate;
264
265   /// True if the processor supports macrofusion.
266   bool HasMacroFusion;
267
268   /// True if the processor has enhanced REP MOVSB/STOSB.
269   bool HasERMSB;
270
271   /// True if the short functions should be padded to prevent
272   /// a stall when returning too early.
273   bool PadShortFunctions;
274
275   /// True if two memory operand instructions should use a temporary register
276   /// instead.
277   bool SlowTwoMemOps;
278
279   /// True if the LEA instruction inputs have to be ready at address generation
280   /// (AG) time.
281   bool LEAUsesAG;
282
283   /// True if the LEA instruction with certain arguments is slow
284   bool SlowLEA;
285
286   /// True if the LEA instruction has all three source operands: base, index,
287   /// and offset or if the LEA instruction uses base and index registers where
288   /// the base is EBP, RBP,or R13
289   bool Slow3OpsLEA;
290
291   /// True if INC and DEC instructions are slow when writing to flags
292   bool SlowIncDec;
293
294   /// Processor has AVX-512 PreFetch Instructions
295   bool HasPFI;
296
297   /// Processor has AVX-512 Exponential and Reciprocal Instructions
298   bool HasERI;
299
300   /// Processor has AVX-512 Conflict Detection Instructions
301   bool HasCDI;
302
303   /// Processor has AVX-512 population count Instructions
304   bool HasVPOPCNTDQ;
305
306   /// Processor has AVX-512 Doubleword and Quadword instructions
307   bool HasDQI;
308
309   /// Processor has AVX-512 Byte and Word instructions
310   bool HasBWI;
311
312   /// Processor has AVX-512 Vector Length eXtenstions
313   bool HasVLX;
314
315   /// Processor has PKU extenstions
316   bool HasPKU;
317
318   /// Processor has AVX-512 Vector Neural Network Instructions
319   bool HasVNNI;
320
321   /// Processor has AVX-512 Bit Algorithms instructions
322   bool HasBITALG;
323
324   /// Processor supports MPX - Memory Protection Extensions
325   bool HasMPX;
326
327   /// Processor supports CET SHSTK - Control-Flow Enforcement Technology
328   /// using Shadow Stack
329   bool HasSHSTK;
330
331   /// Processor supports CET IBT - Control-Flow Enforcement Technology
332   /// using Indirect Branch Tracking
333   bool HasIBT;
334
335   /// Processor has Software Guard Extensions
336   bool HasSGX;
337
338   /// Processor supports Flush Cache Line instruction
339   bool HasCLFLUSHOPT;
340
341   /// Processor supports Cache Line Write Back instruction
342   bool HasCLWB;
343
344   /// Use a retpoline thunk rather than indirect calls to block speculative
345   /// execution.
346   bool UseRetpoline;
347
348   /// When using a retpoline thunk, call an externally provided thunk rather
349   /// than emitting one inside the compiler.
350   bool UseRetpolineExternalThunk;
351
352   /// Use software floating point for code generation.
353   bool UseSoftFloat;
354
355   /// The minimum alignment known to hold of the stack frame on
356   /// entry to the function and which must be maintained by every function.
357   unsigned stackAlignment;
358
359   /// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops.
360   ///
361   unsigned MaxInlineSizeThreshold;
362
363   /// What processor and OS we're targeting.
364   Triple TargetTriple;
365
366   /// Instruction itineraries for scheduling
367   InstrItineraryData InstrItins;
368
369   /// GlobalISel related APIs.
370   std::unique_ptr<CallLowering> CallLoweringInfo;
371   std::unique_ptr<LegalizerInfo> Legalizer;
372   std::unique_ptr<RegisterBankInfo> RegBankInfo;
373   std::unique_ptr<InstructionSelector> InstSelector;
374
375 private:
376   /// Override the stack alignment.
377   unsigned StackAlignOverride;
378
379   /// True if compiling for 64-bit, false for 16-bit or 32-bit.
380   bool In64BitMode;
381
382   /// True if compiling for 32-bit, false for 16-bit or 64-bit.
383   bool In32BitMode;
384
385   /// True if compiling for 16-bit, false for 32-bit or 64-bit.
386   bool In16BitMode;
387
388   /// Contains the Overhead of gather\scatter instructions
389   int GatherOverhead;
390   int ScatterOverhead;
391
392   X86SelectionDAGInfo TSInfo;
393   // Ordering here is important. X86InstrInfo initializes X86RegisterInfo which
394   // X86TargetLowering needs.
395   X86InstrInfo InstrInfo;
396   X86TargetLowering TLInfo;
397   X86FrameLowering FrameLowering;
398
399 public:
400   /// This constructor initializes the data members to match that
401   /// of the specified triple.
402   ///
403   X86Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
404                const X86TargetMachine &TM, unsigned StackAlignOverride);
405
406   const X86TargetLowering *getTargetLowering() const override {
407     return &TLInfo;
408   }
409
410   const X86InstrInfo *getInstrInfo() const override { return &InstrInfo; }
411
412   const X86FrameLowering *getFrameLowering() const override {
413     return &FrameLowering;
414   }
415
416   const X86SelectionDAGInfo *getSelectionDAGInfo() const override {
417     return &TSInfo;
418   }
419
420   const X86RegisterInfo *getRegisterInfo() const override {
421     return &getInstrInfo()->getRegisterInfo();
422   }
423
424   /// Returns the minimum alignment known to hold of the
425   /// stack frame on entry to the function and which must be maintained by every
426   /// function for this subtarget.
427   unsigned getStackAlignment() const { return stackAlignment; }
428
429   /// Returns the maximum memset / memcpy size
430   /// that still makes it profitable to inline the call.
431   unsigned getMaxInlineSizeThreshold() const { return MaxInlineSizeThreshold; }
432
433   /// ParseSubtargetFeatures - Parses features string setting specified
434   /// subtarget options.  Definition of function is auto generated by tblgen.
435   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
436
437   /// Methods used by Global ISel
438   const CallLowering *getCallLowering() const override;
439   const InstructionSelector *getInstructionSelector() const override;
440   const LegalizerInfo *getLegalizerInfo() const override;
441   const RegisterBankInfo *getRegBankInfo() const override;
442
443 private:
444   /// Initialize the full set of dependencies so we can use an initializer
445   /// list for X86Subtarget.
446   X86Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
447   void initializeEnvironment();
448   void initSubtargetFeatures(StringRef CPU, StringRef FS);
449
450 public:
451   /// Is this x86_64? (disregarding specific ABI / programming model)
452   bool is64Bit() const {
453     return In64BitMode;
454   }
455
456   bool is32Bit() const {
457     return In32BitMode;
458   }
459
460   bool is16Bit() const {
461     return In16BitMode;
462   }
463
464   /// Is this x86_64 with the ILP32 programming model (x32 ABI)?
465   bool isTarget64BitILP32() const {
466     return In64BitMode && (TargetTriple.getEnvironment() == Triple::GNUX32 ||
467                            TargetTriple.isOSNaCl());
468   }
469
470   /// Is this x86_64 with the LP64 programming model (standard AMD64, no x32)?
471   bool isTarget64BitLP64() const {
472     return In64BitMode && (TargetTriple.getEnvironment() != Triple::GNUX32 &&
473                            !TargetTriple.isOSNaCl());
474   }
475
476   PICStyles::Style getPICStyle() const { return PICStyle; }
477   void setPICStyle(PICStyles::Style Style)  { PICStyle = Style; }
478
479   bool hasX87() const { return HasX87; }
480   bool hasCMov() const { return HasCMov; }
481   bool hasSSE1() const { return X86SSELevel >= SSE1; }
482   bool hasSSE2() const { return X86SSELevel >= SSE2; }
483   bool hasSSE3() const { return X86SSELevel >= SSE3; }
484   bool hasSSSE3() const { return X86SSELevel >= SSSE3; }
485   bool hasSSE41() const { return X86SSELevel >= SSE41; }
486   bool hasSSE42() const { return X86SSELevel >= SSE42; }
487   bool hasAVX() const { return X86SSELevel >= AVX; }
488   bool hasAVX2() const { return X86SSELevel >= AVX2; }
489   bool hasAVX512() const { return X86SSELevel >= AVX512F; }
490   bool hasFp256() const { return hasAVX(); }
491   bool hasInt256() const { return hasAVX2(); }
492   bool hasSSE4A() const { return HasSSE4A; }
493   bool hasMMX() const { return X863DNowLevel >= MMX; }
494   bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
495   bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
496   bool hasPOPCNT() const { return HasPOPCNT; }
497   bool hasAES() const { return HasAES; }
498   bool hasVAES() const { return HasVAES; }
499   bool hasFXSR() const { return HasFXSR; }
500   bool hasXSAVE() const { return HasXSAVE; }
501   bool hasXSAVEOPT() const { return HasXSAVEOPT; }
502   bool hasXSAVEC() const { return HasXSAVEC; }
503   bool hasXSAVES() const { return HasXSAVES; }
504   bool hasPCLMUL() const { return HasPCLMUL; }
505   bool hasVPCLMULQDQ() const { return HasVPCLMULQDQ; }
506   bool hasGFNI() const { return HasGFNI; }
507   // Prefer FMA4 to FMA - its better for commutation/memory folding and
508   // has equal or better performance on all supported targets.
509   bool hasFMA() const { return HasFMA; }
510   bool hasFMA4() const { return HasFMA4; }
511   bool hasAnyFMA() const { return hasFMA() || hasFMA4(); }
512   bool hasXOP() const { return HasXOP; }
513   bool hasTBM() const { return HasTBM; }
514   bool hasLWP() const { return HasLWP; }
515   bool hasMOVBE() const { return HasMOVBE; }
516   bool hasRDRAND() const { return HasRDRAND; }
517   bool hasF16C() const { return HasF16C; }
518   bool hasFSGSBase() const { return HasFSGSBase; }
519   bool hasLZCNT() const { return HasLZCNT; }
520   bool hasBMI() const { return HasBMI; }
521   bool hasBMI2() const { return HasBMI2; }
522   bool hasVBMI() const { return HasVBMI; }
523   bool hasVBMI2() const { return HasVBMI2; }
524   bool hasIFMA() const { return HasIFMA; }
525   bool hasRTM() const { return HasRTM; }
526   bool hasADX() const { return HasADX; }
527   bool hasSHA() const { return HasSHA; }
528   bool hasPRFCHW() const { return HasPRFCHW || HasPREFETCHWT1; }
529   bool hasPREFETCHWT1() const { return HasPREFETCHWT1; }
530   bool hasSSEPrefetch() const {
531     // We implicitly enable these when we have a write prefix supporting cache
532     // level OR if we have prfchw, but don't already have a read prefetch from
533     // 3dnow.
534     return hasSSE1() || (hasPRFCHW() && !has3DNow()) || hasPREFETCHWT1();
535   }
536   bool hasRDSEED() const { return HasRDSEED; }
537   bool hasLAHFSAHF() const { return HasLAHFSAHF; }
538   bool hasMWAITX() const { return HasMWAITX; }
539   bool hasCLZERO() const { return HasCLZERO; }
540   bool isSHLDSlow() const { return IsSHLDSlow; }
541   bool isPMULLDSlow() const { return IsPMULLDSlow; }
542   bool isUnalignedMem16Slow() const { return IsUAMem16Slow; }
543   bool isUnalignedMem32Slow() const { return IsUAMem32Slow; }
544   int getGatherOverhead() const { return GatherOverhead; }
545   int getScatterOverhead() const { return ScatterOverhead; }
546   bool hasSSEUnalignedMem() const { return HasSSEUnalignedMem; }
547   bool hasCmpxchg16b() const { return HasCmpxchg16b; }
548   bool useLeaForSP() const { return UseLeaForSP; }
549   bool hasFastVariableShuffle() const {
550     return HasFastVariableShuffle;
551   }
552   bool hasFastPartialYMMorZMMWrite() const {
553     return HasFastPartialYMMorZMMWrite;
554   }
555   bool hasFastGather() const { return HasFastGather; }
556   bool hasFastScalarFSQRT() const { return HasFastScalarFSQRT; }
557   bool hasFastVectorFSQRT() const { return HasFastVectorFSQRT; }
558   bool hasFastLZCNT() const { return HasFastLZCNT; }
559   bool hasFastSHLDRotate() const { return HasFastSHLDRotate; }
560   bool hasMacroFusion() const { return HasMacroFusion; }
561   bool hasERMSB() const { return HasERMSB; }
562   bool hasSlowDivide32() const { return HasSlowDivide32; }
563   bool hasSlowDivide64() const { return HasSlowDivide64; }
564   bool padShortFunctions() const { return PadShortFunctions; }
565   bool slowTwoMemOps() const { return SlowTwoMemOps; }
566   bool LEAusesAG() const { return LEAUsesAG; }
567   bool slowLEA() const { return SlowLEA; }
568   bool slow3OpsLEA() const { return Slow3OpsLEA; }
569   bool slowIncDec() const { return SlowIncDec; }
570   bool hasCDI() const { return HasCDI; }
571   bool hasVPOPCNTDQ() const { return HasVPOPCNTDQ; }
572   bool hasPFI() const { return HasPFI; }
573   bool hasERI() const { return HasERI; }
574   bool hasDQI() const { return HasDQI; }
575   bool hasBWI() const { return HasBWI; }
576   bool hasVLX() const { return HasVLX; }
577   bool hasPKU() const { return HasPKU; }
578   bool hasVNNI() const { return HasVNNI; }
579   bool hasBITALG() const { return HasBITALG; }
580   bool hasMPX() const { return HasMPX; }
581   bool hasSHSTK() const { return HasSHSTK; }
582   bool hasIBT() const { return HasIBT; }
583   bool hasCLFLUSHOPT() const { return HasCLFLUSHOPT; }
584   bool hasCLWB() const { return HasCLWB; }
585   bool useRetpoline() const { return UseRetpoline; }
586   bool useRetpolineExternalThunk() const { return UseRetpolineExternalThunk; }
587
588   bool isXRaySupported() const override { return is64Bit(); }
589
590   X86ProcFamilyEnum getProcFamily() const { return X86ProcFamily; }
591
592   /// TODO: to be removed later and replaced with suitable properties
593   bool isAtom() const { return X86ProcFamily == IntelAtom; }
594   bool isSLM() const { return X86ProcFamily == IntelSLM; }
595   bool useSoftFloat() const { return UseSoftFloat; }
596
597   /// Use mfence if we have SSE2 or we're on x86-64 (even if we asked for
598   /// no-sse2). There isn't any reason to disable it if the target processor
599   /// supports it.
600   bool hasMFence() const { return hasSSE2() || is64Bit(); }
601
602   const Triple &getTargetTriple() const { return TargetTriple; }
603
604   bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
605   bool isTargetFreeBSD() const { return TargetTriple.isOSFreeBSD(); }
606   bool isTargetDragonFly() const { return TargetTriple.isOSDragonFly(); }
607   bool isTargetSolaris() const { return TargetTriple.isOSSolaris(); }
608   bool isTargetPS4() const { return TargetTriple.isPS4CPU(); }
609
610   bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
611   bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
612   bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
613
614   bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
615   bool isTargetKFreeBSD() const { return TargetTriple.isOSKFreeBSD(); }
616   bool isTargetGlibc() const { return TargetTriple.isOSGlibc(); }
617   bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
618   bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
619   bool isTargetNaCl32() const { return isTargetNaCl() && !is64Bit(); }
620   bool isTargetNaCl64() const { return isTargetNaCl() && is64Bit(); }
621   bool isTargetMCU() const { return TargetTriple.isOSIAMCU(); }
622   bool isTargetFuchsia() const { return TargetTriple.isOSFuchsia(); }
623
624   bool isTargetWindowsMSVC() const {
625     return TargetTriple.isWindowsMSVCEnvironment();
626   }
627
628   bool isTargetKnownWindowsMSVC() const {
629     return TargetTriple.isKnownWindowsMSVCEnvironment();
630   }
631
632   bool isTargetWindowsCoreCLR() const {
633     return TargetTriple.isWindowsCoreCLREnvironment();
634   }
635
636   bool isTargetWindowsCygwin() const {
637     return TargetTriple.isWindowsCygwinEnvironment();
638   }
639
640   bool isTargetWindowsGNU() const {
641     return TargetTriple.isWindowsGNUEnvironment();
642   }
643
644   bool isTargetWindowsItanium() const {
645     return TargetTriple.isWindowsItaniumEnvironment();
646   }
647
648   bool isTargetCygMing() const { return TargetTriple.isOSCygMing(); }
649
650   bool isOSWindows() const { return TargetTriple.isOSWindows(); }
651
652   bool isTargetWin64() const { return In64BitMode && isOSWindows(); }
653
654   bool isTargetWin32() const { return !In64BitMode && isOSWindows(); }
655
656   bool isPICStyleGOT() const { return PICStyle == PICStyles::GOT; }
657   bool isPICStyleRIPRel() const { return PICStyle == PICStyles::RIPRel; }
658
659   bool isPICStyleStubPIC() const {
660     return PICStyle == PICStyles::StubPIC;
661   }
662
663   bool isPositionIndependent() const { return TM.isPositionIndependent(); }
664
665   bool isCallingConvWin64(CallingConv::ID CC) const {
666     switch (CC) {
667     // On Win64, all these conventions just use the default convention.
668     case CallingConv::C:
669     case CallingConv::Fast:
670     case CallingConv::Swift:
671     case CallingConv::X86_FastCall:
672     case CallingConv::X86_StdCall:
673     case CallingConv::X86_ThisCall:
674     case CallingConv::X86_VectorCall:
675     case CallingConv::Intel_OCL_BI:
676       return isTargetWin64();
677     // This convention allows using the Win64 convention on other targets.
678     case CallingConv::Win64:
679       return true;
680     // This convention allows using the SysV convention on Windows targets.
681     case CallingConv::X86_64_SysV:
682       return false;
683     // Otherwise, who knows what this is.
684     default:
685       return false;
686     }
687   }
688
689   /// Classify a global variable reference for the current subtarget according
690   /// to how we should reference it in a non-pcrel context.
691   unsigned char classifyLocalReference(const GlobalValue *GV) const;
692
693   unsigned char classifyGlobalReference(const GlobalValue *GV,
694                                         const Module &M) const;
695   unsigned char classifyGlobalReference(const GlobalValue *GV) const;
696
697   /// Classify a global function reference for the current subtarget.
698   unsigned char classifyGlobalFunctionReference(const GlobalValue *GV,
699                                                 const Module &M) const;
700   unsigned char classifyGlobalFunctionReference(const GlobalValue *GV) const;
701
702   /// Classify a blockaddress reference for the current subtarget according to
703   /// how we should reference it in a non-pcrel context.
704   unsigned char classifyBlockAddressReference() const;
705
706   /// Return true if the subtarget allows calls to immediate address.
707   bool isLegalToCallImmediateAddr() const;
708
709   /// If we are using retpolines, we need to expand indirectbr to avoid it
710   /// lowering to an actual indirect jump.
711   bool enableIndirectBrExpand() const override { return useRetpoline(); }
712
713   /// Enable the MachineScheduler pass for all X86 subtargets.
714   bool enableMachineScheduler() const override { return true; }
715
716   // TODO: Update the regression tests and return true.
717   bool supportPrintSchedInfo() const override { return false; }
718
719   bool enableEarlyIfConversion() const override;
720
721   /// Return the instruction itineraries based on the subtarget selection.
722   const InstrItineraryData *getInstrItineraryData() const override {
723     return &InstrItins;
724   }
725
726   AntiDepBreakMode getAntiDepBreakMode() const override {
727     return TargetSubtargetInfo::ANTIDEP_CRITICAL;
728   }
729
730   bool enableAdvancedRASplitCost() const override { return true; }
731 };
732
733 } // end namespace llvm
734
735 #endif // LLVM_LIB_TARGET_X86_X86SUBTARGET_H