]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/X86/X86Subtarget.h
Merge lldb trunk r321017 to contrib/llvm/tools/lldb.
[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 HasPFPREFETCHWT1;
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 there is no performance penalty to writing only the lower parts
232   /// of a YMM or ZMM register without clearing the upper part.
233   bool HasFastPartialYMMorZMMWrite;
234
235   /// True if gather is reasonably fast. This is true for Skylake client and
236   /// all AVX-512 CPUs.
237   bool HasFastGather;
238
239   /// True if hardware SQRTSS instruction is at least as fast (latency) as
240   /// RSQRTSS followed by a Newton-Raphson iteration.
241   bool HasFastScalarFSQRT;
242
243   /// True if hardware SQRTPS/VSQRTPS instructions are at least as fast
244   /// (throughput) as RSQRTPS/VRSQRTPS followed by a Newton-Raphson iteration.
245   bool HasFastVectorFSQRT;
246
247   /// True if 8-bit divisions are significantly faster than
248   /// 32-bit divisions and should be used when possible.
249   bool HasSlowDivide32;
250
251   /// True if 32-bit divides are significantly faster than
252   /// 64-bit divisions and should be used when possible.
253   bool HasSlowDivide64;
254
255   /// True if LZCNT instruction is fast.
256   bool HasFastLZCNT;
257
258   /// True if SHLD based rotate is fast.
259   bool HasFastSHLDRotate;
260
261   /// True if the processor supports macrofusion.
262   bool HasMacroFusion;
263
264   /// True if the processor has enhanced REP MOVSB/STOSB.
265   bool HasERMSB;
266
267   /// True if the short functions should be padded to prevent
268   /// a stall when returning too early.
269   bool PadShortFunctions;
270
271   /// True if two memory operand instructions should use a temporary register
272   /// instead.
273   bool SlowTwoMemOps;
274
275   /// True if the LEA instruction inputs have to be ready at address generation
276   /// (AG) time.
277   bool LEAUsesAG;
278
279   /// True if the LEA instruction with certain arguments is slow
280   bool SlowLEA;
281
282   /// True if the LEA instruction has all three source operands: base, index,
283   /// and offset or if the LEA instruction uses base and index registers where
284   /// the base is EBP, RBP,or R13
285   bool Slow3OpsLEA;
286
287   /// True if INC and DEC instructions are slow when writing to flags
288   bool SlowIncDec;
289
290   /// Processor has AVX-512 PreFetch Instructions
291   bool HasPFI;
292
293   /// Processor has AVX-512 Exponential and Reciprocal Instructions
294   bool HasERI;
295
296   /// Processor has AVX-512 Conflict Detection Instructions
297   bool HasCDI;
298
299   /// Processor has AVX-512 population count Instructions
300   bool HasVPOPCNTDQ;
301
302   /// Processor has AVX-512 Doubleword and Quadword instructions
303   bool HasDQI;
304
305   /// Processor has AVX-512 Byte and Word instructions
306   bool HasBWI;
307
308   /// Processor has AVX-512 Vector Length eXtenstions
309   bool HasVLX;
310
311   /// Processor has PKU extenstions
312   bool HasPKU;
313
314   /// Processor has AVX-512 Vector Neural Network Instructions
315   bool HasVNNI;
316
317   /// Processor has AVX-512 Bit Algorithms instructions
318   bool HasBITALG;
319
320   /// Processor supports MPX - Memory Protection Extensions
321   bool HasMPX;
322
323   /// Processor supports CET SHSTK - Control-Flow Enforcement Technology
324   /// using Shadow Stack
325   bool HasSHSTK;
326
327   /// Processor supports CET IBT - Control-Flow Enforcement Technology
328   /// using Indirect Branch Tracking
329   bool HasIBT;
330
331   /// Processor has Software Guard Extensions
332   bool HasSGX;
333
334   /// Processor supports Flush Cache Line instruction
335   bool HasCLFLUSHOPT;
336
337   /// Processor supports Cache Line Write Back instruction
338   bool HasCLWB;
339
340   /// Use software floating point for code generation.
341   bool UseSoftFloat;
342
343   /// The minimum alignment known to hold of the stack frame on
344   /// entry to the function and which must be maintained by every function.
345   unsigned stackAlignment;
346
347   /// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops.
348   ///
349   unsigned MaxInlineSizeThreshold;
350
351   /// What processor and OS we're targeting.
352   Triple TargetTriple;
353
354   /// Instruction itineraries for scheduling
355   InstrItineraryData InstrItins;
356
357   /// GlobalISel related APIs.
358   std::unique_ptr<CallLowering> CallLoweringInfo;
359   std::unique_ptr<LegalizerInfo> Legalizer;
360   std::unique_ptr<RegisterBankInfo> RegBankInfo;
361   std::unique_ptr<InstructionSelector> InstSelector;
362
363 private:
364   /// Override the stack alignment.
365   unsigned StackAlignOverride;
366
367   /// True if compiling for 64-bit, false for 16-bit or 32-bit.
368   bool In64BitMode;
369
370   /// True if compiling for 32-bit, false for 16-bit or 64-bit.
371   bool In32BitMode;
372
373   /// True if compiling for 16-bit, false for 32-bit or 64-bit.
374   bool In16BitMode;
375
376   /// Contains the Overhead of gather\scatter instructions
377   int GatherOverhead;
378   int ScatterOverhead;
379
380   X86SelectionDAGInfo TSInfo;
381   // Ordering here is important. X86InstrInfo initializes X86RegisterInfo which
382   // X86TargetLowering needs.
383   X86InstrInfo InstrInfo;
384   X86TargetLowering TLInfo;
385   X86FrameLowering FrameLowering;
386
387 public:
388   /// This constructor initializes the data members to match that
389   /// of the specified triple.
390   ///
391   X86Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
392                const X86TargetMachine &TM, unsigned StackAlignOverride);
393
394   const X86TargetLowering *getTargetLowering() const override {
395     return &TLInfo;
396   }
397
398   const X86InstrInfo *getInstrInfo() const override { return &InstrInfo; }
399
400   const X86FrameLowering *getFrameLowering() const override {
401     return &FrameLowering;
402   }
403
404   const X86SelectionDAGInfo *getSelectionDAGInfo() const override {
405     return &TSInfo;
406   }
407
408   const X86RegisterInfo *getRegisterInfo() const override {
409     return &getInstrInfo()->getRegisterInfo();
410   }
411
412   /// Returns the minimum alignment known to hold of the
413   /// stack frame on entry to the function and which must be maintained by every
414   /// function for this subtarget.
415   unsigned getStackAlignment() const { return stackAlignment; }
416
417   /// Returns the maximum memset / memcpy size
418   /// that still makes it profitable to inline the call.
419   unsigned getMaxInlineSizeThreshold() const { return MaxInlineSizeThreshold; }
420
421   /// ParseSubtargetFeatures - Parses features string setting specified
422   /// subtarget options.  Definition of function is auto generated by tblgen.
423   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
424
425   /// Methods used by Global ISel
426   const CallLowering *getCallLowering() const override;
427   const InstructionSelector *getInstructionSelector() const override;
428   const LegalizerInfo *getLegalizerInfo() const override;
429   const RegisterBankInfo *getRegBankInfo() const override;
430
431 private:
432   /// Initialize the full set of dependencies so we can use an initializer
433   /// list for X86Subtarget.
434   X86Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
435   void initializeEnvironment();
436   void initSubtargetFeatures(StringRef CPU, StringRef FS);
437
438 public:
439   /// Is this x86_64? (disregarding specific ABI / programming model)
440   bool is64Bit() const {
441     return In64BitMode;
442   }
443
444   bool is32Bit() const {
445     return In32BitMode;
446   }
447
448   bool is16Bit() const {
449     return In16BitMode;
450   }
451
452   /// Is this x86_64 with the ILP32 programming model (x32 ABI)?
453   bool isTarget64BitILP32() const {
454     return In64BitMode && (TargetTriple.getEnvironment() == Triple::GNUX32 ||
455                            TargetTriple.isOSNaCl());
456   }
457
458   /// Is this x86_64 with the LP64 programming model (standard AMD64, no x32)?
459   bool isTarget64BitLP64() const {
460     return In64BitMode && (TargetTriple.getEnvironment() != Triple::GNUX32 &&
461                            !TargetTriple.isOSNaCl());
462   }
463
464   PICStyles::Style getPICStyle() const { return PICStyle; }
465   void setPICStyle(PICStyles::Style Style)  { PICStyle = Style; }
466
467   bool hasX87() const { return HasX87; }
468   bool hasCMov() const { return HasCMov; }
469   bool hasSSE1() const { return X86SSELevel >= SSE1; }
470   bool hasSSE2() const { return X86SSELevel >= SSE2; }
471   bool hasSSE3() const { return X86SSELevel >= SSE3; }
472   bool hasSSSE3() const { return X86SSELevel >= SSSE3; }
473   bool hasSSE41() const { return X86SSELevel >= SSE41; }
474   bool hasSSE42() const { return X86SSELevel >= SSE42; }
475   bool hasAVX() const { return X86SSELevel >= AVX; }
476   bool hasAVX2() const { return X86SSELevel >= AVX2; }
477   bool hasAVX512() const { return X86SSELevel >= AVX512F; }
478   bool hasFp256() const { return hasAVX(); }
479   bool hasInt256() const { return hasAVX2(); }
480   bool hasSSE4A() const { return HasSSE4A; }
481   bool hasMMX() const { return X863DNowLevel >= MMX; }
482   bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
483   bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
484   bool hasPOPCNT() const { return HasPOPCNT; }
485   bool hasAES() const { return HasAES; }
486   bool hasVAES() const { return HasVAES; }
487   bool hasFXSR() const { return HasFXSR; }
488   bool hasXSAVE() const { return HasXSAVE; }
489   bool hasXSAVEOPT() const { return HasXSAVEOPT; }
490   bool hasXSAVEC() const { return HasXSAVEC; }
491   bool hasXSAVES() const { return HasXSAVES; }
492   bool hasPCLMUL() const { return HasPCLMUL; }
493   bool hasVPCLMULQDQ() const { return HasVPCLMULQDQ; }
494   bool hasGFNI() const { return HasGFNI; }
495   // Prefer FMA4 to FMA - its better for commutation/memory folding and
496   // has equal or better performance on all supported targets.
497   bool hasFMA() const { return HasFMA; }
498   bool hasFMA4() const { return HasFMA4; }
499   bool hasAnyFMA() const { return hasFMA() || hasFMA4(); }
500   bool hasXOP() const { return HasXOP; }
501   bool hasTBM() const { return HasTBM; }
502   bool hasLWP() const { return HasLWP; }
503   bool hasMOVBE() const { return HasMOVBE; }
504   bool hasRDRAND() const { return HasRDRAND; }
505   bool hasF16C() const { return HasF16C; }
506   bool hasFSGSBase() const { return HasFSGSBase; }
507   bool hasLZCNT() const { return HasLZCNT; }
508   bool hasBMI() const { return HasBMI; }
509   bool hasBMI2() const { return HasBMI2; }
510   bool hasVBMI() const { return HasVBMI; }
511   bool hasVBMI2() const { return HasVBMI2; }
512   bool hasIFMA() const { return HasIFMA; }
513   bool hasRTM() const { return HasRTM; }
514   bool hasADX() const { return HasADX; }
515   bool hasSHA() const { return HasSHA; }
516   bool hasPRFCHW() const { return HasPRFCHW; }
517   bool hasRDSEED() const { return HasRDSEED; }
518   bool hasLAHFSAHF() const { return HasLAHFSAHF; }
519   bool hasMWAITX() const { return HasMWAITX; }
520   bool hasCLZERO() const { return HasCLZERO; }
521   bool isSHLDSlow() const { return IsSHLDSlow; }
522   bool isPMULLDSlow() const { return IsPMULLDSlow; }
523   bool isUnalignedMem16Slow() const { return IsUAMem16Slow; }
524   bool isUnalignedMem32Slow() const { return IsUAMem32Slow; }
525   int getGatherOverhead() const { return GatherOverhead; }
526   int getScatterOverhead() const { return ScatterOverhead; }
527   bool hasSSEUnalignedMem() const { return HasSSEUnalignedMem; }
528   bool hasCmpxchg16b() const { return HasCmpxchg16b; }
529   bool useLeaForSP() const { return UseLeaForSP; }
530   bool hasFastPartialYMMorZMMWrite() const {
531     return HasFastPartialYMMorZMMWrite;
532   }
533   bool hasFastGather() const { return HasFastGather; }
534   bool hasFastScalarFSQRT() const { return HasFastScalarFSQRT; }
535   bool hasFastVectorFSQRT() const { return HasFastVectorFSQRT; }
536   bool hasFastLZCNT() const { return HasFastLZCNT; }
537   bool hasFastSHLDRotate() const { return HasFastSHLDRotate; }
538   bool hasMacroFusion() const { return HasMacroFusion; }
539   bool hasERMSB() const { return HasERMSB; }
540   bool hasSlowDivide32() const { return HasSlowDivide32; }
541   bool hasSlowDivide64() const { return HasSlowDivide64; }
542   bool padShortFunctions() const { return PadShortFunctions; }
543   bool slowTwoMemOps() const { return SlowTwoMemOps; }
544   bool LEAusesAG() const { return LEAUsesAG; }
545   bool slowLEA() const { return SlowLEA; }
546   bool slow3OpsLEA() const { return Slow3OpsLEA; }
547   bool slowIncDec() const { return SlowIncDec; }
548   bool hasCDI() const { return HasCDI; }
549   bool hasVPOPCNTDQ() const { return HasVPOPCNTDQ; }
550   bool hasPFI() const { return HasPFI; }
551   bool hasERI() const { return HasERI; }
552   bool hasDQI() const { return HasDQI; }
553   bool hasBWI() const { return HasBWI; }
554   bool hasVLX() const { return HasVLX; }
555   bool hasPKU() const { return HasPKU; }
556   bool hasVNNI() const { return HasVNNI; }
557   bool hasBITALG() const { return HasBITALG; }
558   bool hasMPX() const { return HasMPX; }
559   bool hasSHSTK() const { return HasSHSTK; }
560   bool hasIBT() const { return HasIBT; }
561   bool hasCLFLUSHOPT() const { return HasCLFLUSHOPT; }
562   bool hasCLWB() const { return HasCLWB; }
563
564   bool isXRaySupported() const override { return is64Bit(); }
565
566   X86ProcFamilyEnum getProcFamily() const { return X86ProcFamily; }
567
568   /// TODO: to be removed later and replaced with suitable properties
569   bool isAtom() const { return X86ProcFamily == IntelAtom; }
570   bool isSLM() const { return X86ProcFamily == IntelSLM; }
571   bool useSoftFloat() const { return UseSoftFloat; }
572
573   /// Use mfence if we have SSE2 or we're on x86-64 (even if we asked for
574   /// no-sse2). There isn't any reason to disable it if the target processor
575   /// supports it.
576   bool hasMFence() const { return hasSSE2() || is64Bit(); }
577
578   const Triple &getTargetTriple() const { return TargetTriple; }
579
580   bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
581   bool isTargetFreeBSD() const { return TargetTriple.isOSFreeBSD(); }
582   bool isTargetDragonFly() const { return TargetTriple.isOSDragonFly(); }
583   bool isTargetSolaris() const { return TargetTriple.isOSSolaris(); }
584   bool isTargetPS4() const { return TargetTriple.isPS4CPU(); }
585
586   bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
587   bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
588   bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
589
590   bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
591   bool isTargetKFreeBSD() const { return TargetTriple.isOSKFreeBSD(); }
592   bool isTargetGlibc() const { return TargetTriple.isOSGlibc(); }
593   bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
594   bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
595   bool isTargetNaCl32() const { return isTargetNaCl() && !is64Bit(); }
596   bool isTargetNaCl64() const { return isTargetNaCl() && is64Bit(); }
597   bool isTargetMCU() const { return TargetTriple.isOSIAMCU(); }
598   bool isTargetFuchsia() const { return TargetTriple.isOSFuchsia(); }
599
600   bool isTargetWindowsMSVC() const {
601     return TargetTriple.isWindowsMSVCEnvironment();
602   }
603
604   bool isTargetKnownWindowsMSVC() const {
605     return TargetTriple.isKnownWindowsMSVCEnvironment();
606   }
607
608   bool isTargetWindowsCoreCLR() const {
609     return TargetTriple.isWindowsCoreCLREnvironment();
610   }
611
612   bool isTargetWindowsCygwin() const {
613     return TargetTriple.isWindowsCygwinEnvironment();
614   }
615
616   bool isTargetWindowsGNU() const {
617     return TargetTriple.isWindowsGNUEnvironment();
618   }
619
620   bool isTargetWindowsItanium() const {
621     return TargetTriple.isWindowsItaniumEnvironment();
622   }
623
624   bool isTargetCygMing() const { return TargetTriple.isOSCygMing(); }
625
626   bool isOSWindows() const { return TargetTriple.isOSWindows(); }
627
628   bool isTargetWin64() const { return In64BitMode && isOSWindows(); }
629
630   bool isTargetWin32() const { return !In64BitMode && isOSWindows(); }
631
632   bool isPICStyleGOT() const { return PICStyle == PICStyles::GOT; }
633   bool isPICStyleRIPRel() const { return PICStyle == PICStyles::RIPRel; }
634
635   bool isPICStyleStubPIC() const {
636     return PICStyle == PICStyles::StubPIC;
637   }
638
639   bool isPositionIndependent() const { return TM.isPositionIndependent(); }
640
641   bool isCallingConvWin64(CallingConv::ID CC) const {
642     switch (CC) {
643     // On Win64, all these conventions just use the default convention.
644     case CallingConv::C:
645     case CallingConv::Fast:
646     case CallingConv::Swift:
647     case CallingConv::X86_FastCall:
648     case CallingConv::X86_StdCall:
649     case CallingConv::X86_ThisCall:
650     case CallingConv::X86_VectorCall:
651     case CallingConv::Intel_OCL_BI:
652       return isTargetWin64();
653     // This convention allows using the Win64 convention on other targets.
654     case CallingConv::Win64:
655       return true;
656     // This convention allows using the SysV convention on Windows targets.
657     case CallingConv::X86_64_SysV:
658       return false;
659     // Otherwise, who knows what this is.
660     default:
661       return false;
662     }
663   }
664
665   /// Classify a global variable reference for the current subtarget according
666   /// to how we should reference it in a non-pcrel context.
667   unsigned char classifyLocalReference(const GlobalValue *GV) const;
668
669   unsigned char classifyGlobalReference(const GlobalValue *GV,
670                                         const Module &M) const;
671   unsigned char classifyGlobalReference(const GlobalValue *GV) const;
672
673   /// Classify a global function reference for the current subtarget.
674   unsigned char classifyGlobalFunctionReference(const GlobalValue *GV,
675                                                 const Module &M) const;
676   unsigned char classifyGlobalFunctionReference(const GlobalValue *GV) const;
677
678   /// Classify a blockaddress reference for the current subtarget according to
679   /// how we should reference it in a non-pcrel context.
680   unsigned char classifyBlockAddressReference() const;
681
682   /// Return true if the subtarget allows calls to immediate address.
683   bool isLegalToCallImmediateAddr() const;
684
685   /// This function returns the name of a function which has an interface
686   /// like the non-standard bzero function, if such a function exists on
687   /// the current subtarget and it is considered prefereable over
688   /// memset with zero passed as the second argument. Otherwise it
689   /// returns null.
690   const char *getBZeroEntry() const;
691
692   /// This function returns true if the target has sincos() routine in its
693   /// compiler runtime or math libraries.
694   bool hasSinCos() const;
695
696   /// Enable the MachineScheduler pass for all X86 subtargets.
697   bool enableMachineScheduler() const override { return true; }
698
699   // TODO: Update the regression tests and return true.
700   bool supportPrintSchedInfo() const override { return false; }
701
702   bool enableEarlyIfConversion() const override;
703
704   /// Return the instruction itineraries based on the subtarget selection.
705   const InstrItineraryData *getInstrItineraryData() const override {
706     return &InstrItins;
707   }
708
709   AntiDepBreakMode getAntiDepBreakMode() const override {
710     return TargetSubtargetInfo::ANTIDEP_CRITICAL;
711   }
712
713   bool enableAdvancedRASplitCost() const override { return true; }
714 };
715
716 } // end namespace llvm
717
718 #endif // LLVM_LIB_TARGET_X86_X86SUBTARGET_H