e781d9527c8aec11e5c62a8d2658af2cf06b3c2d
[oota-llvm.git] / lib / Target / X86 / X86Subtarget.h
1 //=====---- X86Subtarget.h - Define Subtarget for the X86 -----*- C++ -*--====//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the X86 specific subclass of TargetSubtarget.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef X86SUBTARGET_H
15 #define X86SUBTARGET_H
16
17 #include "llvm/Target/TargetSubtarget.h"
18
19 #include <string>
20
21 namespace llvm {
22 class Module;
23
24 class X86Subtarget : public TargetSubtarget {
25 public:
26   enum AsmWriterFlavorTy {
27     att, intel, unset
28   };
29
30 protected:
31   enum X86SSEEnum {
32     NoMMXSSE, MMX, SSE1, SSE2, SSE3
33   };
34
35   /// AsmFlavor - Which x86 asm dialect to use.
36   AsmWriterFlavorTy AsmFlavor;
37
38   /// X86SSELevel - MMX, SSE1, SSE2, SSE3, or none supported.
39   X86SSEEnum X86SSELevel;
40
41   /// HasX86_64 - True if the processor supports X86-64 instructions.
42   bool HasX86_64;
43
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;
47
48   /// Min. memset / memcpy size that is turned into rep/movs, rep/stos ops.
49   unsigned MinRepStrSizeThreshold;
50
51 private:
52   /// Is64Bit - True if the processor supports 64-bit instructions and module
53   /// pointer size is 64 bit.
54   bool Is64Bit;
55
56 public:
57   enum {
58     isELF, isCygwin, isDarwin, isWindows
59   } TargetType;
60     
61   /// This constructor initializes the data members to match that
62   /// of the specified module.
63   ///
64   X86Subtarget(const Module &M, const std::string &FS, bool is64Bit);
65
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; }
70
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
74   /// aligned.
75   unsigned getMinRepStrSizeThreshold() const { return MinRepStrSizeThreshold; }
76  
77   /// DetectSubtargetFeatures - Auto-detect CPU features using CPUID instruction.
78   ///
79   void DetectSubtargetFeatures();
80
81   bool is64Bit() const { return Is64Bit; }
82
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; }
87   
88   bool isFlavorAtt() const { return AsmFlavor == att; }
89   bool isFlavorIntel() const { return AsmFlavor == intel; }
90
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; }  
95 };
96 } // End llvm namespace
97
98 #endif