Committing X86-64 support.
[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   enum X863DNowEnum {
36     NoThreeDNow, ThreeDNow, ThreeDNowA
37   };
38
39   /// AsmFlavor - Which x86 asm dialect to use.
40   AsmWriterFlavorTy AsmFlavor;
41
42   /// X86SSELevel - MMX, SSE1, SSE2, SSE3, or none supported.
43   X86SSEEnum X86SSELevel;
44
45   /// X863DNowLevel - 3DNow or 3DNow Athlon, or none supported.
46   X863DNowEnum X863DNowLevel;
47
48   /// HasX86_64 - True if the processor supports X86-64 instructions.
49   bool HasX86_64;
50
51   /// stackAlignment - The minimum alignment known to hold of the stack frame on
52   /// entry to the function and which must be maintained by every function.
53   unsigned stackAlignment;
54
55   /// Min. memset / memcpy size that is turned into rep/movs, rep/stos ops.
56   unsigned MinRepStrSizeThreshold;
57
58 private:
59   /// Is64Bit - True if the processor supports 64-bit instructions and module
60   /// pointer size is 64 bit.
61   bool Is64Bit;
62
63 public:
64   enum {
65     isELF, isCygwin, isDarwin, isWindows
66   } TargetType;
67     
68   /// This constructor initializes the data members to match that
69   /// of the specified module.
70   ///
71   X86Subtarget(const Module &M, const std::string &FS, bool is64Bit);
72
73   /// getStackAlignment - Returns the minimum alignment known to hold of the
74   /// stack frame on entry to the function and which must be maintained by every
75   /// function for this subtarget.
76   unsigned getStackAlignment() const { return stackAlignment; }
77
78   /// getMinRepStrSizeThreshold - Returns the minimum memset / memcpy size
79   /// required to turn the operation into a X86 rep/movs or rep/stos
80   /// instruction. This is only used if the src / dst alignment is not DWORD
81   /// aligned.
82   unsigned getMinRepStrSizeThreshold() const { return MinRepStrSizeThreshold; }
83  
84   /// ParseSubtargetFeatures - Parses features string setting specified 
85   /// subtarget options.  Definition of function is auto generated by tblgen.
86   void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
87
88   bool is64Bit() const { return Is64Bit; }
89
90   bool hasMMX() const { return X86SSELevel >= MMX; }
91   bool hasSSE1() const { return X86SSELevel >= SSE1; }
92   bool hasSSE2() const { return X86SSELevel >= SSE2; }
93   bool hasSSE3() const { return X86SSELevel >= SSE3; }
94   bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
95   bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
96   
97   bool isFlavorAtt() const { return AsmFlavor == att; }
98   bool isFlavorIntel() const { return AsmFlavor == intel; }
99
100   bool isTargetDarwin() const { return TargetType == isDarwin; }
101   bool isTargetELF() const { return TargetType == isELF; }
102 };
103 } // End llvm namespace
104
105 #endif