2005-08-04 09:12:09 +02:00
|
|
|
//=====---- X86Subtarget.h - Define Subtarget for the X86 -----*- C++ -*--====//
|
2005-07-12 03:41:54 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-07-12 03:41:54 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the X86 specific subclass of TargetSubtarget.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef X86SUBTARGET_H
|
|
|
|
#define X86SUBTARGET_H
|
|
|
|
|
|
|
|
#include "llvm/Target/TargetSubtarget.h"
|
2010-05-27 20:43:40 +02:00
|
|
|
#include "llvm/CallingConv.h"
|
2005-09-01 23:38:21 +02:00
|
|
|
#include <string>
|
|
|
|
|
2005-07-12 03:41:54 +02:00
|
|
|
namespace llvm {
|
2006-11-30 23:42:55 +01:00
|
|
|
class GlobalValue;
|
2006-12-22 23:29:05 +01:00
|
|
|
class TargetMachine;
|
2010-02-28 23:54:30 +01:00
|
|
|
|
2009-07-09 05:15:51 +02:00
|
|
|
/// PICStyles - The X86 backend supports a number of different styles of PIC.
|
2010-02-28 23:54:30 +01:00
|
|
|
///
|
2008-11-28 10:29:37 +01:00
|
|
|
namespace PICStyles {
|
2007-01-12 20:20:47 +01:00
|
|
|
enum Style {
|
2009-07-10 22:58:47 +02: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-12 20:20:47 +01:00
|
|
|
};
|
|
|
|
}
|
2005-07-12 03:41:54 +02:00
|
|
|
|
|
|
|
class X86Subtarget : public TargetSubtarget {
|
|
|
|
protected:
|
2006-01-27 09:10:46 +01:00
|
|
|
enum X86SSEEnum {
|
2008-02-03 08:18:54 +01:00
|
|
|
NoMMXSSE, MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42
|
2006-01-27 09:10:46 +01:00
|
|
|
};
|
|
|
|
|
2006-10-06 11:17:41 +02:00
|
|
|
enum X863DNowEnum {
|
|
|
|
NoThreeDNow, ThreeDNow, ThreeDNowA
|
|
|
|
};
|
|
|
|
|
2007-01-12 20:20:47 +01:00
|
|
|
/// PICStyle - Which PIC style to use
|
2007-08-02 01:45:51 +02:00
|
|
|
///
|
2008-11-28 10:29:37 +01:00
|
|
|
PICStyles::Style PICStyle;
|
2010-02-28 23:54:30 +01:00
|
|
|
|
2008-02-12 08:59:55 +01:00
|
|
|
/// X86SSELevel - MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, or
|
|
|
|
/// none supported.
|
2006-01-27 09:10:46 +01:00
|
|
|
X86SSEEnum X86SSELevel;
|
|
|
|
|
2006-10-06 11:17:41 +02:00
|
|
|
/// X863DNowLevel - 3DNow or 3DNow Athlon, or none supported.
|
2007-08-02 01:45:51 +02:00
|
|
|
///
|
2006-10-06 11:17:41 +02:00
|
|
|
X863DNowEnum X863DNowLevel;
|
|
|
|
|
2009-09-02 07:53:04 +02:00
|
|
|
/// HasCMov - True if this processor has conditional move instructions
|
|
|
|
/// (generally pentium pro+).
|
|
|
|
bool HasCMov;
|
2010-02-28 23:54:30 +01:00
|
|
|
|
2006-09-08 08:48:29 +02:00
|
|
|
/// HasX86_64 - True if the processor supports X86-64 instructions.
|
2007-08-02 01:45:51 +02:00
|
|
|
///
|
2006-09-08 08:48:29 +02:00
|
|
|
bool HasX86_64;
|
2009-01-02 06:35:45 +01:00
|
|
|
|
2009-05-26 23:04:35 +02:00
|
|
|
/// HasSSE4A - True if the processor supports SSE4A instructions.
|
|
|
|
bool HasSSE4A;
|
|
|
|
|
2009-06-27 00:46:54 +02:00
|
|
|
/// HasAVX - Target has AVX instructions
|
|
|
|
bool HasAVX;
|
|
|
|
|
2010-04-02 23:54:27 +02:00
|
|
|
/// HasAES - Target has AES instructions
|
|
|
|
bool HasAES;
|
|
|
|
|
2009-06-27 00:46:54 +02:00
|
|
|
/// 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;
|
2009-12-18 08:40:29 +01:00
|
|
|
|
2010-04-01 07:58:17 +02:00
|
|
|
/// IsUAMemFast - True if unaligned memory access is fast.
|
|
|
|
bool IsUAMemFast;
|
|
|
|
|
2010-02-28 23:54:30 +01:00
|
|
|
/// HasVectorUAMem - True if SIMD operations can have unaligned memory
|
2010-04-21 03:47:12 +02:00
|
|
|
/// operands. This may require setting a feature bit in the processor.
|
2010-01-11 17:29:42 +01:00
|
|
|
bool HasVectorUAMem;
|
|
|
|
|
2008-01-02 20:44:55 +01: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-05 18:11:31 +02:00
|
|
|
unsigned char DarwinVers; // Is any darwin-x86 platform.
|
|
|
|
|
2005-07-12 04:36:10 +02: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 03:41:54 +02:00
|
|
|
unsigned stackAlignment;
|
2005-07-27 07:53:44 +02:00
|
|
|
|
2007-10-31 12:52:06 +01:00
|
|
|
/// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops.
|
2007-08-02 01:45:51 +02:00
|
|
|
///
|
2007-10-31 12:52:06 +01:00
|
|
|
unsigned MaxInlineSizeThreshold;
|
2006-02-16 01:21:07 +01:00
|
|
|
|
2006-09-08 08:48:29 +02:00
|
|
|
private:
|
2009-08-03 00:11:08 +02:00
|
|
|
/// Is64Bit - True if the processor supports 64-bit instructions and
|
2006-09-08 08:48:29 +02:00
|
|
|
/// pointer size is 64 bit.
|
|
|
|
bool Is64Bit;
|
|
|
|
|
2005-07-12 03:41:54 +02:00
|
|
|
public:
|
2005-11-21 23:31:58 +01:00
|
|
|
enum {
|
2008-05-05 18:11:31 +02:00
|
|
|
isELF, isCygwin, isDarwin, isWindows, isMingw
|
2005-11-21 23:31:58 +01:00
|
|
|
} TargetType;
|
2006-11-21 01:01:06 +01:00
|
|
|
|
2005-07-27 07:53:44 +02:00
|
|
|
/// This constructor initializes the data members to match that
|
2009-08-03 00:11:08 +02:00
|
|
|
/// of the specified triple.
|
2005-07-12 03:41:54 +02:00
|
|
|
///
|
2009-08-03 00:11:08 +02:00
|
|
|
X86Subtarget(const std::string &TT, const std::string &FS, bool is64Bit);
|
2005-07-12 04:36:10 +02: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 03:41:54 +02:00
|
|
|
unsigned getStackAlignment() const { return stackAlignment; }
|
2005-07-27 07:53:44 +02:00
|
|
|
|
2007-10-31 12:52:06 +01: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 01:01:06 +01:00
|
|
|
|
|
|
|
/// ParseSubtargetFeatures - Parses features string setting specified
|
2006-10-06 11:17:41 +02:00
|
|
|
/// subtarget options. Definition of function is auto generated by tblgen.
|
2009-05-23 21:50:50 +02:00
|
|
|
std::string ParseSubtargetFeatures(const std::string &FS,
|
|
|
|
const std::string &CPU);
|
2006-10-06 11:17:41 +02:00
|
|
|
|
|
|
|
/// AutoDetectSubtargetFeatures - Auto-detect CPU features using CPUID
|
|
|
|
/// instruction.
|
|
|
|
void AutoDetectSubtargetFeatures();
|
2006-01-26 10:53:06 +01:00
|
|
|
|
|
|
|
bool is64Bit() const { return Is64Bit; }
|
|
|
|
|
2008-11-28 10:29:37 +01:00
|
|
|
PICStyles::Style getPICStyle() const { return PICStyle; }
|
|
|
|
void setPICStyle(PICStyles::Style Style) { PICStyle = Style; }
|
2007-01-12 20:20:47 +01:00
|
|
|
|
2010-03-14 19:31:44 +01:00
|
|
|
bool hasCMov() const { return HasCMov; }
|
2006-01-27 09:10:46 +01:00
|
|
|
bool hasMMX() const { return X86SSELevel >= MMX; }
|
2006-01-31 20:43:35 +01:00
|
|
|
bool hasSSE1() const { return X86SSELevel >= SSE1; }
|
2006-01-27 09:10:46 +01:00
|
|
|
bool hasSSE2() const { return X86SSELevel >= SSE2; }
|
|
|
|
bool hasSSE3() const { return X86SSELevel >= SSE3; }
|
2007-04-11 00:10:25 +02:00
|
|
|
bool hasSSSE3() const { return X86SSELevel >= SSSE3; }
|
2008-04-03 10:53:29 +02:00
|
|
|
bool hasSSE41() const { return X86SSELevel >= SSE41; }
|
|
|
|
bool hasSSE42() const { return X86SSELevel >= SSE42; }
|
2009-05-26 23:04:35 +02:00
|
|
|
bool hasSSE4A() const { return HasSSE4A; }
|
2006-10-06 11:17:41 +02:00
|
|
|
bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
|
|
|
|
bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
|
2009-06-29 18:51:01 +02:00
|
|
|
bool hasAVX() const { return HasAVX; }
|
2010-04-02 23:54:27 +02:00
|
|
|
bool hasAES() const { return HasAES; }
|
2009-06-27 00:46:54 +02:00
|
|
|
bool hasFMA3() const { return HasFMA3; }
|
|
|
|
bool hasFMA4() const { return HasFMA4; }
|
2009-01-02 06:35:45 +01:00
|
|
|
bool isBTMemSlow() const { return IsBTMemSlow; }
|
2010-04-01 07:58:17 +02:00
|
|
|
bool isUnalignedMemAccessFast() const { return IsUAMemFast; }
|
2010-01-11 17:29:42 +01:00
|
|
|
bool hasVectorUAMem() const { return HasVectorUAMem; }
|
2009-01-02 06:35:45 +01:00
|
|
|
|
2006-02-18 01:15:05 +01:00
|
|
|
bool isTargetDarwin() const { return TargetType == isDarwin; }
|
2009-07-10 09:20:05 +02:00
|
|
|
bool isTargetELF() const { return TargetType == isELF; }
|
2010-02-28 23:54:30 +01:00
|
|
|
|
2006-09-14 20:23:27 +02:00
|
|
|
bool isTargetWindows() const { return TargetType == isWindows; }
|
2007-01-03 12:43:14 +01:00
|
|
|
bool isTargetMingw() const { return TargetType == isMingw; }
|
2009-09-16 07:20:33 +02:00
|
|
|
bool isTargetCygwin() const { return TargetType == isCygwin; }
|
2009-07-10 09:20:05 +02:00
|
|
|
bool isTargetCygMing() const {
|
|
|
|
return TargetType == isMingw || TargetType == isCygwin;
|
|
|
|
}
|
2010-02-28 23:54:30 +01:00
|
|
|
|
2009-09-16 07:20:33 +02:00
|
|
|
/// isTargetCOFF - Return true if this is any COFF/Windows target variant.
|
|
|
|
bool isTargetCOFF() const {
|
|
|
|
return TargetType == isMingw || TargetType == isCygwin ||
|
|
|
|
TargetType == isWindows;
|
|
|
|
}
|
2010-02-28 23:54:30 +01:00
|
|
|
|
2008-03-22 21:57:27 +01:00
|
|
|
bool isTargetWin64() const {
|
2009-07-10 09:20:05 +02:00
|
|
|
return Is64Bit && (TargetType == isMingw || TargetType == isWindows);
|
2008-03-22 21:57:27 +01:00
|
|
|
}
|
2006-11-21 01:01:06 +01:00
|
|
|
|
2007-08-07 00:10:35 +02:00
|
|
|
std::string getDataLayout() const {
|
|
|
|
const char *p;
|
2007-09-04 18:44:41 +02:00
|
|
|
if (is64Bit())
|
2009-11-07 20:07:32 +01:00
|
|
|
p = "e-p:64:64-s:64-f64:64:64-i64:64:64-f80:128:128-n8:16:32:64";
|
2009-07-10 09:20:05 +02:00
|
|
|
else if (isTargetDarwin())
|
2009-11-07 20:07:32 +01:00
|
|
|
p = "e-p:32:32-f64:32:64-i64:32:64-f80:128:128-n8:16:32";
|
2010-01-12 09:30:46 +01:00
|
|
|
else if (isTargetMingw() || isTargetWindows())
|
2010-02-12 16:28:56 +01:00
|
|
|
p = "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32";
|
2009-07-10 09:20:05 +02:00
|
|
|
else
|
2009-11-07 20:07:32 +01:00
|
|
|
p = "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32";
|
2009-12-19 03:04:23 +01:00
|
|
|
|
2007-08-07 00:10:35 +02:00
|
|
|
return std::string(p);
|
|
|
|
}
|
2007-08-06 23:48:35 +02:00
|
|
|
|
2008-11-28 10:29:37 +01:00
|
|
|
bool isPICStyleSet() const { return PICStyle != PICStyles::None; }
|
|
|
|
bool isPICStyleGOT() const { return PICStyle == PICStyles::GOT; }
|
|
|
|
bool isPICStyleRIPRel() const { return PICStyle == PICStyles::RIPRel; }
|
2009-07-10 22:47:30 +02:00
|
|
|
|
2009-07-10 23:00:45 +02:00
|
|
|
bool isPICStyleStubPIC() const {
|
2009-07-10 22:58:47 +02:00
|
|
|
return PICStyle == PICStyles::StubPIC;
|
|
|
|
}
|
|
|
|
|
2009-07-10 23:00:45 +02:00
|
|
|
bool isPICStyleStubNoDynamic() const {
|
2009-07-10 22:58:47 +02:00
|
|
|
return PICStyle == PICStyles::StubDynamicNoPIC;
|
|
|
|
}
|
|
|
|
bool isPICStyleStubAny() const {
|
|
|
|
return PICStyle == PICStyles::StubDynamicNoPIC ||
|
|
|
|
PICStyle == PICStyles::StubPIC; }
|
2010-02-28 23:54:30 +01:00
|
|
|
|
2009-07-10 22:47:30 +02:00
|
|
|
/// getDarwinVers - Return the darwin version number, 8 = Tiger, 9 = Leopard,
|
|
|
|
/// 10 = Snow Leopard, etc.
|
2008-01-02 20:44:55 +01:00
|
|
|
unsigned getDarwinVers() const { return DarwinVers; }
|
2010-02-28 23:54:30 +01:00
|
|
|
|
2009-07-10 09:20:05 +02: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 02:03:20 +01:00
|
|
|
|
2009-11-21 00:18:13 +01:00
|
|
|
/// ClassifyBlockAddressReference - Classify a blockaddress reference for the
|
|
|
|
/// current subtarget according to how we should reference it in a non-pcrel
|
|
|
|
/// context.
|
|
|
|
unsigned char ClassifyBlockAddressReference() const;
|
|
|
|
|
2009-05-20 06:53:57 +02:00
|
|
|
/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
|
|
|
|
/// to immediate address.
|
|
|
|
bool IsLegalToCallImmediateAddr(const TargetMachine &TM) const;
|
|
|
|
|
2008-04-01 22:38:36 +02: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 00:05:33 +02:00
|
|
|
const char *getBZeroEntry() const;
|
2008-12-16 04:35:01 +01: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;
|
2010-05-27 20:43:40 +02:00
|
|
|
|
|
|
|
/// IsCalleePop - Test whether a function should pop its own arguments.
|
|
|
|
bool IsCalleePop(bool isVarArg, CallingConv::ID CallConv) const;
|
2009-09-03 06:37:05 +02:00
|
|
|
};
|
2006-10-16 23:00:37 +02:00
|
|
|
|
2005-07-12 03:41:54 +02:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|