Whoops, didn't mean to check this in yet.
[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 protected:
26   enum X86SSEEnum {
27     NoMMXSSE, MMX, SSE1, SSE2, SSE3
28   };
29
30   enum X863DNowEnum {
31     NoThreeDNow, ThreeDNow, ThreeDNowA
32   };
33
34   /// X86SSELevel - MMX, SSE1, SSE2, SSE3, or none supported.
35   X86SSEEnum X86SSELevel;
36
37   /// X863DNowLevel - 3DNow or 3DNow Athlon, or none supported.
38   X863DNowEnum X863DNowLevel;
39
40   /// Is64Bit - True if the processor supports Em64T.
41   bool Is64Bit;
42
43   /// stackAlignment - The minimum alignment known to hold of the stack frame on
44   /// entry to the function and which must be maintained by every function.
45   unsigned stackAlignment;
46
47   /// Min. memset / memcpy size that is turned into rep/movs, rep/stos ops.
48   unsigned MinRepStrSizeThreshold;
49
50   /// Used by instruction selector
51   bool indirectExternAndWeakGlobals;
52
53 public:
54   enum {
55     isELF, isCygwin, isDarwin, isWindows
56   } TargetType;
57     
58   /// This constructor initializes the data members to match that
59   /// of the specified module.
60   ///
61   X86Subtarget(const Module &M, const std::string &FS);
62
63   /// getStackAlignment - Returns the minimum alignment known to hold of the
64   /// stack frame on entry to the function and which must be maintained by every
65   /// function for this subtarget.
66   unsigned getStackAlignment() const { return stackAlignment; }
67
68   /// getMinRepStrSizeThreshold - Returns the minimum memset / memcpy size
69   /// required to turn the operation into a X86 rep/movs or rep/stos
70   /// instruction. This is only used if the src / dst alignment is not DWORD
71   /// aligned.
72   unsigned getMinRepStrSizeThreshold() const { return MinRepStrSizeThreshold; }
73  
74   /// Returns true if the instruction selector should treat global values
75   /// referencing external or weak symbols as indirect rather than direct
76   /// references.
77   bool getIndirectExternAndWeakGlobals() const {
78     return indirectExternAndWeakGlobals;
79   }
80
81   /// ParseSubtargetFeatures - Parses features string setting specified 
82   /// subtarget options.  Definition of function is auto generated by tblgen.
83   void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
84
85   bool is64Bit() const { return Is64Bit; }
86
87   bool hasMMX() const { return X86SSELevel >= MMX; }
88   bool hasSSE1() const { return X86SSELevel >= SSE1; }
89   bool hasSSE2() const { return X86SSELevel >= SSE2; }
90   bool hasSSE3() const { return X86SSELevel >= SSE3; }
91   bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
92   bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
93 };
94 } // End llvm namespace
95
96 #endif