Add accessor
[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 public:
51   enum {
52     isELF, isCygwin, isDarwin, isWindows
53   } TargetType;
54     
55   /// This constructor initializes the data members to match that
56   /// of the specified module.
57   ///
58   X86Subtarget(const Module &M, const std::string &FS);
59
60   /// getStackAlignment - Returns the minimum alignment known to hold of the
61   /// stack frame on entry to the function and which must be maintained by every
62   /// function for this subtarget.
63   unsigned getStackAlignment() const { return stackAlignment; }
64
65   /// getMinRepStrSizeThreshold - Returns the minimum memset / memcpy size
66   /// required to turn the operation into a X86 rep/movs or rep/stos
67   /// instruction. This is only used if the src / dst alignment is not DWORD
68   /// aligned.
69   unsigned getMinRepStrSizeThreshold() const { return MinRepStrSizeThreshold; }
70  
71   /// ParseSubtargetFeatures - Parses features string setting specified 
72   /// subtarget options.  Definition of function is auto generated by tblgen.
73   void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
74
75   bool is64Bit() const { return Is64Bit; }
76
77   bool hasMMX() const { return X86SSELevel >= MMX; }
78   bool hasSSE1() const { return X86SSELevel >= SSE1; }
79   bool hasSSE2() const { return X86SSELevel >= SSE2; }
80   bool hasSSE3() const { return X86SSELevel >= SSE3; }
81   bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
82   bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
83
84   bool isTargetDarwin() const { return TargetType == isDarwin; }
85   bool isTargetELF() const { return TargetType == isELF; }
86 };
87 } // End llvm namespace
88
89 #endif