Add 8-bit regclass and pattern for sext_inreg
[llvm/msp430.git] / lib / Target / X86 / X86Subtarget.h
blobded26e891e16c62e8f39eef0ff72b398a7c6d83b
1 //=====---- X86Subtarget.h - Define Subtarget for the X86 -----*- C++ -*--====//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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"
18 #include <string>
20 namespace llvm {
21 class Module;
22 class GlobalValue;
23 class TargetMachine;
25 namespace PICStyles {
26 enum Style {
27 Stub, GOT, RIPRel, WinPIC, None
31 class X86Subtarget : public TargetSubtarget {
32 public:
33 enum AsmWriterFlavorTy {
34 // Note: This numbering has to match the GCC assembler dialects for inline
35 // asm alternatives to work right.
36 ATT = 0, Intel = 1, Unset
38 protected:
39 enum X86SSEEnum {
40 NoMMXSSE, MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42
43 enum X863DNowEnum {
44 NoThreeDNow, ThreeDNow, ThreeDNowA
47 /// AsmFlavor - Which x86 asm dialect to use.
48 ///
49 AsmWriterFlavorTy AsmFlavor;
51 /// PICStyle - Which PIC style to use
52 ///
53 PICStyles::Style PICStyle;
55 /// X86SSELevel - MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, or
56 /// none supported.
57 X86SSEEnum X86SSELevel;
59 /// X863DNowLevel - 3DNow or 3DNow Athlon, or none supported.
60 ///
61 X863DNowEnum X863DNowLevel;
63 /// HasX86_64 - True if the processor supports X86-64 instructions.
64 ///
65 bool HasX86_64;
67 /// IsBTMemSlow - True if BT (bit test) of memory instructions are slow.
68 bool IsBTMemSlow;
70 /// DarwinVers - Nonzero if this is a darwin platform: the numeric
71 /// version of the platform, e.g. 8 = 10.4 (Tiger), 9 = 10.5 (Leopard), etc.
72 unsigned char DarwinVers; // Is any darwin-x86 platform.
74 /// isLinux - true if this is a "linux" platform.
75 bool IsLinux;
77 /// stackAlignment - The minimum alignment known to hold of the stack frame on
78 /// entry to the function and which must be maintained by every function.
79 unsigned stackAlignment;
81 /// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops.
82 ///
83 unsigned MaxInlineSizeThreshold;
85 private:
86 /// Is64Bit - True if the processor supports 64-bit instructions and module
87 /// pointer size is 64 bit.
88 bool Is64Bit;
90 public:
91 enum {
92 isELF, isCygwin, isDarwin, isWindows, isMingw
93 } TargetType;
95 /// This constructor initializes the data members to match that
96 /// of the specified module.
97 ///
98 X86Subtarget(const Module &M, const std::string &FS, bool is64Bit);
100 /// getStackAlignment - Returns the minimum alignment known to hold of the
101 /// stack frame on entry to the function and which must be maintained by every
102 /// function for this subtarget.
103 unsigned getStackAlignment() const { return stackAlignment; }
105 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
106 /// that still makes it profitable to inline the call.
107 unsigned getMaxInlineSizeThreshold() const { return MaxInlineSizeThreshold; }
109 /// ParseSubtargetFeatures - Parses features string setting specified
110 /// subtarget options. Definition of function is auto generated by tblgen.
111 void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
113 /// AutoDetectSubtargetFeatures - Auto-detect CPU features using CPUID
114 /// instruction.
115 void AutoDetectSubtargetFeatures();
117 bool is64Bit() const { return Is64Bit; }
119 PICStyles::Style getPICStyle() const { return PICStyle; }
120 void setPICStyle(PICStyles::Style Style) { PICStyle = Style; }
122 bool hasMMX() const { return X86SSELevel >= MMX; }
123 bool hasSSE1() const { return X86SSELevel >= SSE1; }
124 bool hasSSE2() const { return X86SSELevel >= SSE2; }
125 bool hasSSE3() const { return X86SSELevel >= SSE3; }
126 bool hasSSSE3() const { return X86SSELevel >= SSSE3; }
127 bool hasSSE41() const { return X86SSELevel >= SSE41; }
128 bool hasSSE42() const { return X86SSELevel >= SSE42; }
129 bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
130 bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
132 bool isBTMemSlow() const { return IsBTMemSlow; }
134 unsigned getAsmFlavor() const {
135 return AsmFlavor != Unset ? unsigned(AsmFlavor) : 0;
138 bool isFlavorAtt() const { return AsmFlavor == ATT; }
139 bool isFlavorIntel() const { return AsmFlavor == Intel; }
141 bool isTargetDarwin() const { return TargetType == isDarwin; }
142 bool isTargetELF() const {
143 return TargetType == isELF;
145 bool isTargetWindows() const { return TargetType == isWindows; }
146 bool isTargetMingw() const { return TargetType == isMingw; }
147 bool isTargetCygMing() const { return (TargetType == isMingw ||
148 TargetType == isCygwin); }
149 bool isTargetCygwin() const { return TargetType == isCygwin; }
150 bool isTargetWin64() const {
151 return (Is64Bit && (TargetType == isMingw || TargetType == isWindows));
154 std::string getDataLayout() const {
155 const char *p;
156 if (is64Bit())
157 p = "e-p:64:64-s:64-f64:64:64-i64:64:64-f80:128:128";
158 else {
159 if (isTargetDarwin())
160 p = "e-p:32:32-f64:32:64-i64:32:64-f80:128:128";
161 else
162 p = "e-p:32:32-f64:32:64-i64:32:64-f80:32:32";
164 return std::string(p);
167 bool isPICStyleSet() const { return PICStyle != PICStyles::None; }
168 bool isPICStyleGOT() const { return PICStyle == PICStyles::GOT; }
169 bool isPICStyleStub() const { return PICStyle == PICStyles::Stub; }
170 bool isPICStyleRIPRel() const { return PICStyle == PICStyles::RIPRel; }
171 bool isPICStyleWinPIC() const { return PICStyle == PICStyles:: WinPIC; }
173 /// getDarwinVers - Return the darwin version number, 8 = tiger, 9 = leopard.
174 unsigned getDarwinVers() const { return DarwinVers; }
176 /// isLinux - Return true if the target is "Linux".
177 bool isLinux() const { return IsLinux; }
179 /// True if accessing the GV requires an extra load. For Windows, dllimported
180 /// symbols are indirect, loading the value at address GV rather then the
181 /// value of GV itself. This means that the GlobalAddress must be in the base
182 /// or index register of the address, not the GV offset field.
183 bool GVRequiresExtraLoad(const GlobalValue* GV, const TargetMachine& TM,
184 bool isDirectCall) const;
186 /// True if accessing the GV requires a register. This is a superset of the
187 /// cases where GVRequiresExtraLoad is true. Some variations of PIC require
188 /// a register, but not an extra load.
189 bool GVRequiresRegister(const GlobalValue* GV, const TargetMachine& TM,
190 bool isDirectCall) const;
192 /// This function returns the name of a function which has an interface
193 /// like the non-standard bzero function, if such a function exists on
194 /// the current subtarget and it is considered prefereable over
195 /// memset with zero passed as the second argument. Otherwise it
196 /// returns null.
197 const char *getBZeroEntry() const;
199 /// getSpecialAddressLatency - For targets where it is beneficial to
200 /// backschedule instructions that compute addresses, return a value
201 /// indicating the number of scheduling cycles of backscheduling that
202 /// should be attempted.
203 unsigned getSpecialAddressLatency() const;
206 namespace X86 {
207 /// GetCpuIDAndInfo - Execute the specified cpuid and return the 4 values in
208 /// the specified arguments. If we can't run cpuid on the host, return true.
209 bool GetCpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
210 unsigned *rECX, unsigned *rEDX);
213 } // End llvm namespace
215 #endif