2005-08-04 15:12:09 +08:00
|
|
|
//=====---- X86Subtarget.h - Define Subtarget for the X86 -----*- C++ -*--====//
|
2005-07-12 09:41:54 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-07-12 09:41:54 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the X86 specific subclass of TargetSubtarget.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef X86SUBTARGET_H
|
|
|
|
#define X86SUBTARGET_H
|
|
|
|
|
|
|
|
#include "llvm/Target/TargetSubtarget.h"
|
2005-09-02 05:38:21 +08:00
|
|
|
#include <string>
|
|
|
|
|
2005-07-12 09:41:54 +08:00
|
|
|
namespace llvm {
|
2006-12-01 06:42:55 +08:00
|
|
|
class GlobalValue;
|
2006-12-23 06:29:05 +08:00
|
|
|
class TargetMachine;
|
2007-01-13 03:20:47 +08:00
|
|
|
|
2009-07-09 11:15:51 +08:00
|
|
|
/// PICStyles - The X86 backend supports a number of different styles of PIC.
|
|
|
|
///
|
2008-11-28 17:29:37 +08:00
|
|
|
namespace PICStyles {
|
2007-01-13 03:20:47 +08:00
|
|
|
enum Style {
|
2009-07-11 04:58:47 +08:00
|
|
|
StubPIC, // Used on i386-darwin in -fPIC mode.
|
|
|
|
StubDynamicNoPIC, // Used on i386-darwin in -mdynamic-no-pic mode.
|
|
|
|
GOT, // Used on many 32-bit unices in -fPIC mode.
|
|
|
|
RIPRel, // Used on X86-64 when not in -static mode.
|
|
|
|
None // Set when in -static mode (not PIC or DynamicNoPIC mode).
|
2007-01-13 03:20:47 +08:00
|
|
|
};
|
|
|
|
}
|
2005-07-12 09:41:54 +08:00
|
|
|
|
|
|
|
class X86Subtarget : public TargetSubtarget {
|
|
|
|
protected:
|
2006-01-27 16:10:46 +08:00
|
|
|
enum X86SSEEnum {
|
2008-02-03 15:18:54 +08:00
|
|
|
NoMMXSSE, MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42
|
2006-01-27 16:10:46 +08:00
|
|
|
};
|
|
|
|
|
2006-10-06 17:17:41 +08:00
|
|
|
enum X863DNowEnum {
|
|
|
|
NoThreeDNow, ThreeDNow, ThreeDNowA
|
|
|
|
};
|
|
|
|
|
2007-01-13 03:20:47 +08:00
|
|
|
/// PICStyle - Which PIC style to use
|
2007-08-02 07:45:51 +08:00
|
|
|
///
|
2008-11-28 17:29:37 +08:00
|
|
|
PICStyles::Style PICStyle;
|
2007-01-13 03:20:47 +08:00
|
|
|
|
2008-02-12 15:59:55 +08:00
|
|
|
/// X86SSELevel - MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, or
|
|
|
|
/// none supported.
|
2006-01-27 16:10:46 +08:00
|
|
|
X86SSEEnum X86SSELevel;
|
|
|
|
|
2006-10-06 17:17:41 +08:00
|
|
|
/// X863DNowLevel - 3DNow or 3DNow Athlon, or none supported.
|
2007-08-02 07:45:51 +08:00
|
|
|
///
|
2006-10-06 17:17:41 +08:00
|
|
|
X863DNowEnum X863DNowLevel;
|
|
|
|
|
2009-09-02 13:53:04 +08:00
|
|
|
/// HasCMov - True if this processor has conditional move instructions
|
|
|
|
/// (generally pentium pro+).
|
|
|
|
bool HasCMov;
|
|
|
|
|
2006-09-08 14:48:29 +08:00
|
|
|
/// HasX86_64 - True if the processor supports X86-64 instructions.
|
2007-08-02 07:45:51 +08:00
|
|
|
///
|
2006-09-08 14:48:29 +08:00
|
|
|
bool HasX86_64;
|
2009-01-02 13:35:45 +08:00
|
|
|
|
2009-05-27 05:04:35 +08:00
|
|
|
/// HasSSE4A - True if the processor supports SSE4A instructions.
|
|
|
|
bool HasSSE4A;
|
|
|
|
|
2009-06-27 06:46:54 +08:00
|
|
|
/// HasAVX - Target has AVX instructions
|
|
|
|
bool HasAVX;
|
|
|
|
|
|
|
|
/// HasFMA3 - Target has 3-operand fused multiply-add
|
|
|
|
bool HasFMA3;
|
|
|
|
|
|
|
|
/// HasFMA4 - Target has 4-operand fused multiply-add
|
|
|
|
bool HasFMA4;
|
|
|
|
|
|
|
|
/// IsBTMemSlow - True if BT (bit test) of memory instructions are slow.
|
|
|
|
bool IsBTMemSlow;
|
|
|
|
|
2008-01-03 03:44:55 +08:00
|
|
|
/// DarwinVers - Nonzero if this is a darwin platform: the numeric
|
|
|
|
/// version of the platform, e.g. 8 = 10.4 (Tiger), 9 = 10.5 (Leopard), etc.
|
2008-05-06 00:11:31 +08:00
|
|
|
unsigned char DarwinVers; // Is any darwin-x86 platform.
|
|
|
|
|
2005-07-12 10:36:10 +08:00
|
|
|
/// stackAlignment - The minimum alignment known to hold of the stack frame on
|
|
|
|
/// entry to the function and which must be maintained by every function.
|
2005-07-12 09:41:54 +08:00
|
|
|
unsigned stackAlignment;
|
2005-07-27 13:53:44 +08:00
|
|
|
|
2007-10-31 19:52:06 +08:00
|
|
|
/// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops.
|
2007-08-02 07:45:51 +08:00
|
|
|
///
|
2007-10-31 19:52:06 +08:00
|
|
|
unsigned MaxInlineSizeThreshold;
|
2006-02-16 08:21:07 +08:00
|
|
|
|
2006-09-08 14:48:29 +08:00
|
|
|
private:
|
2009-08-03 06:11:08 +08:00
|
|
|
/// Is64Bit - True if the processor supports 64-bit instructions and
|
2006-09-08 14:48:29 +08:00
|
|
|
/// pointer size is 64 bit.
|
|
|
|
bool Is64Bit;
|
|
|
|
|
2005-07-12 09:41:54 +08:00
|
|
|
public:
|
2005-11-22 06:31:58 +08:00
|
|
|
enum {
|
2008-05-06 00:11:31 +08:00
|
|
|
isELF, isCygwin, isDarwin, isWindows, isMingw
|
2005-11-22 06:31:58 +08:00
|
|
|
} TargetType;
|
2006-11-21 08:01:06 +08:00
|
|
|
|
2005-07-27 13:53:44 +08:00
|
|
|
/// This constructor initializes the data members to match that
|
2009-08-03 06:11:08 +08:00
|
|
|
/// of the specified triple.
|
2005-07-12 09:41:54 +08:00
|
|
|
///
|
2009-08-03 06:11:08 +08:00
|
|
|
X86Subtarget(const std::string &TT, const std::string &FS, bool is64Bit);
|
2005-07-12 10:36:10 +08:00
|
|
|
|
|
|
|
/// getStackAlignment - Returns the minimum alignment known to hold of the
|
|
|
|
/// stack frame on entry to the function and which must be maintained by every
|
|
|
|
/// function for this subtarget.
|
2005-07-12 09:41:54 +08:00
|
|
|
unsigned getStackAlignment() const { return stackAlignment; }
|
2005-07-27 13:53:44 +08:00
|
|
|
|
2007-10-31 19:52:06 +08:00
|
|
|
/// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
|
|
|
|
/// that still makes it profitable to inline the call.
|
|
|
|
unsigned getMaxInlineSizeThreshold() const { return MaxInlineSizeThreshold; }
|
2006-11-21 08:01:06 +08:00
|
|
|
|
|
|
|
/// ParseSubtargetFeatures - Parses features string setting specified
|
2006-10-06 17:17:41 +08:00
|
|
|
/// subtarget options. Definition of function is auto generated by tblgen.
|
2009-05-24 03:50:50 +08:00
|
|
|
std::string ParseSubtargetFeatures(const std::string &FS,
|
|
|
|
const std::string &CPU);
|
2006-10-06 17:17:41 +08:00
|
|
|
|
|
|
|
/// AutoDetectSubtargetFeatures - Auto-detect CPU features using CPUID
|
|
|
|
/// instruction.
|
|
|
|
void AutoDetectSubtargetFeatures();
|
2006-01-26 17:53:06 +08:00
|
|
|
|
|
|
|
bool is64Bit() const { return Is64Bit; }
|
|
|
|
|
2008-11-28 17:29:37 +08:00
|
|
|
PICStyles::Style getPICStyle() const { return PICStyle; }
|
|
|
|
void setPICStyle(PICStyles::Style Style) { PICStyle = Style; }
|
2007-01-13 03:20:47 +08:00
|
|
|
|
2006-01-27 16:10:46 +08:00
|
|
|
bool hasMMX() const { return X86SSELevel >= MMX; }
|
2006-02-01 03:43:35 +08:00
|
|
|
bool hasSSE1() const { return X86SSELevel >= SSE1; }
|
2006-01-27 16:10:46 +08:00
|
|
|
bool hasSSE2() const { return X86SSELevel >= SSE2; }
|
|
|
|
bool hasSSE3() const { return X86SSELevel >= SSE3; }
|
2007-04-11 06:10:25 +08:00
|
|
|
bool hasSSSE3() const { return X86SSELevel >= SSSE3; }
|
2008-04-03 16:53:29 +08:00
|
|
|
bool hasSSE41() const { return X86SSELevel >= SSE41; }
|
|
|
|
bool hasSSE42() const { return X86SSELevel >= SSE42; }
|
2009-05-27 05:04:35 +08:00
|
|
|
bool hasSSE4A() const { return HasSSE4A; }
|
2006-10-06 17:17:41 +08:00
|
|
|
bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
|
|
|
|
bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
|
2009-06-30 00:51:01 +08:00
|
|
|
bool hasAVX() const { return HasAVX; }
|
2009-06-27 06:46:54 +08:00
|
|
|
bool hasFMA3() const { return HasFMA3; }
|
|
|
|
bool hasFMA4() const { return HasFMA4; }
|
2009-01-02 13:35:45 +08:00
|
|
|
bool isBTMemSlow() const { return IsBTMemSlow; }
|
|
|
|
|
2006-02-18 08:15:05 +08:00
|
|
|
bool isTargetDarwin() const { return TargetType == isDarwin; }
|
2009-07-10 15:20:05 +08:00
|
|
|
bool isTargetELF() const { return TargetType == isELF; }
|
2009-09-16 13:20:33 +08:00
|
|
|
|
2006-09-15 02:23:27 +08:00
|
|
|
bool isTargetWindows() const { return TargetType == isWindows; }
|
2007-01-03 19:43:14 +08:00
|
|
|
bool isTargetMingw() const { return TargetType == isMingw; }
|
2009-09-16 13:20:33 +08:00
|
|
|
bool isTargetCygwin() const { return TargetType == isCygwin; }
|
2009-07-10 15:20:05 +08:00
|
|
|
bool isTargetCygMing() const {
|
|
|
|
return TargetType == isMingw || TargetType == isCygwin;
|
|
|
|
}
|
2009-09-16 13:20:33 +08:00
|
|
|
|
|
|
|
/// isTargetCOFF - Return true if this is any COFF/Windows target variant.
|
|
|
|
bool isTargetCOFF() const {
|
|
|
|
return TargetType == isMingw || TargetType == isCygwin ||
|
|
|
|
TargetType == isWindows;
|
|
|
|
}
|
|
|
|
|
2008-03-23 04:57:27 +08:00
|
|
|
bool isTargetWin64() const {
|
2009-07-10 15:20:05 +08:00
|
|
|
return Is64Bit && (TargetType == isMingw || TargetType == isWindows);
|
2008-03-23 04:57:27 +08:00
|
|
|
}
|
2006-11-21 08:01:06 +08:00
|
|
|
|
2007-08-07 06:10:35 +08:00
|
|
|
std::string getDataLayout() const {
|
|
|
|
const char *p;
|
2007-09-05 00:44:41 +08:00
|
|
|
if (is64Bit())
|
2009-11-08 03:07:32 +08:00
|
|
|
p = "e-p:64:64-s:64-f64:64:64-i64:64:64-f80:128:128-n8:16:32:64";
|
2009-07-10 15:20:05 +08:00
|
|
|
else if (isTargetDarwin())
|
2009-11-08 03:07:32 +08:00
|
|
|
p = "e-p:32:32-f64:32:64-i64:32:64-f80:128:128-n8:16:32";
|
2009-07-10 15:20:05 +08:00
|
|
|
else
|
2009-11-08 03:07:32 +08:00
|
|
|
p = "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32";
|
2007-08-07 06:10:35 +08:00
|
|
|
return std::string(p);
|
|
|
|
}
|
2007-08-07 05:48:35 +08:00
|
|
|
|
2008-11-28 17:29:37 +08:00
|
|
|
bool isPICStyleSet() const { return PICStyle != PICStyles::None; }
|
|
|
|
bool isPICStyleGOT() const { return PICStyle == PICStyles::GOT; }
|
|
|
|
bool isPICStyleRIPRel() const { return PICStyle == PICStyles::RIPRel; }
|
2009-07-11 04:47:30 +08:00
|
|
|
|
2009-07-11 05:00:45 +08:00
|
|
|
bool isPICStyleStubPIC() const {
|
2009-07-11 04:58:47 +08:00
|
|
|
return PICStyle == PICStyles::StubPIC;
|
|
|
|
}
|
|
|
|
|
2009-07-11 05:00:45 +08:00
|
|
|
bool isPICStyleStubNoDynamic() const {
|
2009-07-11 04:58:47 +08:00
|
|
|
return PICStyle == PICStyles::StubDynamicNoPIC;
|
|
|
|
}
|
|
|
|
bool isPICStyleStubAny() const {
|
|
|
|
return PICStyle == PICStyles::StubDynamicNoPIC ||
|
|
|
|
PICStyle == PICStyles::StubPIC; }
|
2008-01-03 03:44:55 +08:00
|
|
|
|
2009-07-11 04:47:30 +08:00
|
|
|
/// getDarwinVers - Return the darwin version number, 8 = Tiger, 9 = Leopard,
|
|
|
|
/// 10 = Snow Leopard, etc.
|
2008-01-03 03:44:55 +08:00
|
|
|
unsigned getDarwinVers() const { return DarwinVers; }
|
2009-10-16 04:23:21 +08:00
|
|
|
|
2009-07-10 15:20:05 +08:00
|
|
|
/// ClassifyGlobalReference - Classify a global variable reference for the
|
|
|
|
/// current subtarget according to how we should reference it in a non-pcrel
|
|
|
|
/// context.
|
|
|
|
unsigned char ClassifyGlobalReference(const GlobalValue *GV,
|
|
|
|
const TargetMachine &TM)const;
|
2006-12-20 09:03:20 +08:00
|
|
|
|
2009-05-20 12:53:57 +08:00
|
|
|
/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
|
|
|
|
/// to immediate address.
|
|
|
|
bool IsLegalToCallImmediateAddr(const TargetMachine &TM) const;
|
|
|
|
|
2008-04-02 04:38:36 +08:00
|
|
|
/// This function returns the name of a function which has an interface
|
|
|
|
/// like the non-standard bzero function, if such a function exists on
|
|
|
|
/// the current subtarget and it is considered prefereable over
|
|
|
|
/// memset with zero passed as the second argument. Otherwise it
|
|
|
|
/// returns null.
|
2008-10-01 06:05:33 +08:00
|
|
|
const char *getBZeroEntry() const;
|
2008-12-16 11:35:01 +08:00
|
|
|
|
|
|
|
/// getSpecialAddressLatency - For targets where it is beneficial to
|
|
|
|
/// backschedule instructions that compute addresses, return a value
|
|
|
|
/// indicating the number of scheduling cycles of backscheduling that
|
|
|
|
/// should be attempted.
|
|
|
|
unsigned getSpecialAddressLatency() const;
|
2009-10-17 05:06:15 +08:00
|
|
|
|
|
|
|
/// enablePostRAScheduler - X86 target is enabling post-alloc scheduling
|
|
|
|
/// at 'More' optimization level.
|
2009-10-23 07:19:17 +08:00
|
|
|
bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
|
2009-11-10 08:15:47 +08:00
|
|
|
TargetSubtarget::AntiDepBreakMode& Mode,
|
2009-11-14 03:52:48 +08:00
|
|
|
RegClassVector& CriticalPathRCs) const;
|
2009-09-03 12:37:05 +08:00
|
|
|
};
|
2006-10-17 05:00:37 +08:00
|
|
|
|
2005-07-12 09:41:54 +08:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|