1 //=====---- X86Subtarget.h - Define Subtarget for the X86 -----*- C++ -*--====//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Nate Begeman and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the X86 specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #ifndef X86SUBTARGET_H
15 #define X86SUBTARGET_H
17 #include "llvm/Target/TargetSubtarget.h"
24 class X86Subtarget : public TargetSubtarget {
26 enum AsmWriterFlavorTy {
32 NoMMXSSE, MMX, SSE1, SSE2, SSE3
35 /// AsmFlavor - Which x86 asm dialect to use.
36 AsmWriterFlavorTy AsmFlavor;
38 /// X86SSELevel - MMX, SSE1, SSE2, SSE3, or none supported.
39 X86SSEEnum X86SSELevel;
41 /// HasX86_64 - True if the processor supports X86-64 instructions.
44 /// stackAlignment - The minimum alignment known to hold of the stack frame on
45 /// entry to the function and which must be maintained by every function.
46 unsigned stackAlignment;
48 /// Min. memset / memcpy size that is turned into rep/movs, rep/stos ops.
49 unsigned MinRepStrSizeThreshold;
52 /// Is64Bit - True if the processor supports 64-bit instructions and module
53 /// pointer size is 64 bit.
58 isELF, isCygwin, isDarwin, isWindows
61 /// This constructor initializes the data members to match that
62 /// of the specified module.
64 X86Subtarget(const Module &M, const std::string &FS, bool is64Bit);
66 /// getStackAlignment - Returns the minimum alignment known to hold of the
67 /// stack frame on entry to the function and which must be maintained by every
68 /// function for this subtarget.
69 unsigned getStackAlignment() const { return stackAlignment; }
71 /// getMinRepStrSizeThreshold - Returns the minimum memset / memcpy size
72 /// required to turn the operation into a X86 rep/movs or rep/stos
73 /// instruction. This is only used if the src / dst alignment is not DWORD
75 unsigned getMinRepStrSizeThreshold() const { return MinRepStrSizeThreshold; }
77 /// DetectSubtargetFeatures - Auto-detect CPU features using CPUID instruction.
79 void DetectSubtargetFeatures();
81 bool is64Bit() const { return Is64Bit; }
83 bool hasMMX() const { return X86SSELevel >= MMX; }
84 bool hasSSE1() const { return X86SSELevel >= SSE1; }
85 bool hasSSE2() const { return X86SSELevel >= SSE2; }
86 bool hasSSE3() const { return X86SSELevel >= SSE3; }
88 bool isFlavorAtt() const { return AsmFlavor == att; }
89 bool isFlavorIntel() const { return AsmFlavor == intel; }
91 bool isTargetDarwin() const { return TargetType == isDarwin; }
92 bool isTargetELF() const { return TargetType == isELF; }
93 bool isTargetWindows() const { return TargetType == isWindows; }
94 bool isTargetCygwin() const { return TargetType == isCygwin; }
96 } // End llvm namespace