2005-08-04 07:12:09 +00:00
|
|
|
//=====---- X86Subtarget.h - Define Subtarget for the X86 -----*- C++ -*--====//
|
2005-07-12 01:41:54 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-07-12 01:41:54 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the X86 specific subclass of TargetSubtarget.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef X86SUBTARGET_H
|
|
|
|
#define X86SUBTARGET_H
|
|
|
|
|
2010-07-05 19:26:33 +00:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2005-07-12 01:41:54 +00:00
|
|
|
#include "llvm/Target/TargetSubtarget.h"
|
2010-05-27 18:43:40 +00:00
|
|
|
#include "llvm/CallingConv.h"
|
2005-09-01 21:38:21 +00:00
|
|
|
#include <string>
|
|
|
|
|
2005-07-12 01:41:54 +00:00
|
|
|
namespace llvm {
|
2006-11-30 22:42:55 +00:00
|
|
|
class GlobalValue;
|
2006-12-22 22:29:05 +00:00
|
|
|
class TargetMachine;
|
2010-02-28 22:54:30 +00:00
|
|
|
|
2009-07-09 03:15:51 +00:00
|
|
|
/// PICStyles - The X86 backend supports a number of different styles of PIC.
|
2010-02-28 22:54:30 +00:00
|
|
|
///
|
2008-11-28 09:29:37 +00:00
|
|
|
namespace PICStyles {
|
2007-01-12 19:20:47 +00:00
|
|
|
enum Style {
|
2009-07-10 20:58:47 +00: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 19:20:47 +00:00
|
|
|
};
|
|
|
|
}
|
2005-07-12 01:41:54 +00:00
|
|
|
|
|
|
|
class X86Subtarget : public TargetSubtarget {
|
|
|
|
protected:
|
2006-01-27 08:10:46 +00:00
|
|
|
enum X86SSEEnum {
|
2008-02-03 07:18:54 +00:00
|
|
|
NoMMXSSE, MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42
|
2006-01-27 08:10:46 +00:00
|
|
|
};
|
|
|
|
|
2006-10-06 09:17:41 +00:00
|
|
|
enum X863DNowEnum {
|
|
|
|
NoThreeDNow, ThreeDNow, ThreeDNowA
|
|
|
|
};
|
|
|
|
|
2007-01-12 19:20:47 +00:00
|
|
|
/// PICStyle - Which PIC style to use
|
2007-08-01 23:45:51 +00:00
|
|
|
///
|
2008-11-28 09:29:37 +00:00
|
|
|
PICStyles::Style PICStyle;
|
2010-02-28 22:54:30 +00:00
|
|
|
|
2008-02-12 07:59:55 +00:00
|
|
|
/// X86SSELevel - MMX, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, or
|
|
|
|
/// none supported.
|
2006-01-27 08:10:46 +00:00
|
|
|
X86SSEEnum X86SSELevel;
|
|
|
|
|
2006-10-06 09:17:41 +00:00
|
|
|
/// X863DNowLevel - 3DNow or 3DNow Athlon, or none supported.
|
2007-08-01 23:45:51 +00:00
|
|
|
///
|
2006-10-06 09:17:41 +00:00
|
|
|
X863DNowEnum X863DNowLevel;
|
|
|
|
|
2009-09-02 05:53:04 +00:00
|
|
|
/// HasCMov - True if this processor has conditional move instructions
|
|
|
|
/// (generally pentium pro+).
|
|
|
|
bool HasCMov;
|
2010-02-28 22:54:30 +00:00
|
|
|
|
2006-09-08 06:48:29 +00:00
|
|
|
/// HasX86_64 - True if the processor supports X86-64 instructions.
|
2007-08-01 23:45:51 +00:00
|
|
|
///
|
2006-09-08 06:48:29 +00:00
|
|
|
bool HasX86_64;
|
2009-01-02 05:35:45 +00:00
|
|
|
|
2010-12-04 20:32:23 +00:00
|
|
|
/// HasPOPCNT - True if the processor supports POPCNT.
|
|
|
|
bool HasPOPCNT;
|
|
|
|
|
2009-05-26 21:04:35 +00:00
|
|
|
/// HasSSE4A - True if the processor supports SSE4A instructions.
|
|
|
|
bool HasSSE4A;
|
|
|
|
|
2009-06-26 22:46:54 +00:00
|
|
|
/// HasAVX - Target has AVX instructions
|
|
|
|
bool HasAVX;
|
|
|
|
|
2010-04-02 21:54:27 +00:00
|
|
|
/// HasAES - Target has AES instructions
|
|
|
|
bool HasAES;
|
|
|
|
|
2010-07-23 01:17:51 +00:00
|
|
|
/// HasCLMUL - Target has carry-less multiplication
|
|
|
|
bool HasCLMUL;
|
|
|
|
|
2009-06-26 22:46:54 +00: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 07:40:29 +00:00
|
|
|
|
2010-04-01 05:58:17 +00:00
|
|
|
/// IsUAMemFast - True if unaligned memory access is fast.
|
|
|
|
bool IsUAMemFast;
|
|
|
|
|
2010-02-28 22:54:30 +00:00
|
|
|
/// HasVectorUAMem - True if SIMD operations can have unaligned memory
|
2010-04-21 01:47:12 +00:00
|
|
|
/// operands. This may require setting a feature bit in the processor.
|
2010-01-11 16:29:42 +00:00
|
|
|
bool HasVectorUAMem;
|
|
|
|
|
2005-07-12 02:36:10 +00: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 01:41:54 +00:00
|
|
|
unsigned stackAlignment;
|
2005-07-27 05:53:44 +00:00
|
|
|
|
2007-10-31 11:52:06 +00:00
|
|
|
/// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops.
|
2007-08-01 23:45:51 +00:00
|
|
|
///
|
2007-10-31 11:52:06 +00:00
|
|
|
unsigned MaxInlineSizeThreshold;
|
2010-07-05 19:26:33 +00:00
|
|
|
|
|
|
|
/// TargetTriple - What processor and OS we're targeting.
|
|
|
|
Triple TargetTriple;
|
2006-02-16 00:21:07 +00:00
|
|
|
|
2006-09-08 06:48:29 +00:00
|
|
|
private:
|
2009-08-02 22:11:08 +00:00
|
|
|
/// Is64Bit - True if the processor supports 64-bit instructions and
|
2006-09-08 06:48:29 +00:00
|
|
|
/// pointer size is 64 bit.
|
|
|
|
bool Is64Bit;
|
|
|
|
|
2005-07-12 01:41:54 +00:00
|
|
|
public:
|
2006-11-21 00:01:06 +00:00
|
|
|
|
2005-07-27 05:53:44 +00:00
|
|
|
/// This constructor initializes the data members to match that
|
2009-08-02 22:11:08 +00:00
|
|
|
/// of the specified triple.
|
2005-07-12 01:41:54 +00:00
|
|
|
///
|
2009-08-02 22:11:08 +00:00
|
|
|
X86Subtarget(const std::string &TT, const std::string &FS, bool is64Bit);
|
2005-07-12 02:36:10 +00: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 01:41:54 +00:00
|
|
|
unsigned getStackAlignment() const { return stackAlignment; }
|
2005-07-27 05:53:44 +00:00
|
|
|
|
2007-10-31 11:52:06 +00: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 00:01:06 +00:00
|
|
|
|
|
|
|
/// ParseSubtargetFeatures - Parses features string setting specified
|
2006-10-06 09:17:41 +00:00
|
|
|
/// subtarget options. Definition of function is auto generated by tblgen.
|
2009-05-23 19:50:50 +00:00
|
|
|
std::string ParseSubtargetFeatures(const std::string &FS,
|
|
|
|
const std::string &CPU);
|
2006-10-06 09:17:41 +00:00
|
|
|
|
|
|
|
/// AutoDetectSubtargetFeatures - Auto-detect CPU features using CPUID
|
|
|
|
/// instruction.
|
|
|
|
void AutoDetectSubtargetFeatures();
|
2006-01-26 09:53:06 +00:00
|
|
|
|
|
|
|
bool is64Bit() const { return Is64Bit; }
|
|
|
|
|
2008-11-28 09:29:37 +00:00
|
|
|
PICStyles::Style getPICStyle() const { return PICStyle; }
|
|
|
|
void setPICStyle(PICStyles::Style Style) { PICStyle = Style; }
|
2007-01-12 19:20:47 +00:00
|
|
|
|
2010-03-14 18:31:44 +00:00
|
|
|
bool hasCMov() const { return HasCMov; }
|
2006-01-27 08:10:46 +00:00
|
|
|
bool hasMMX() const { return X86SSELevel >= MMX; }
|
2006-01-31 19:43:35 +00:00
|
|
|
bool hasSSE1() const { return X86SSELevel >= SSE1; }
|
2006-01-27 08:10:46 +00:00
|
|
|
bool hasSSE2() const { return X86SSELevel >= SSE2; }
|
|
|
|
bool hasSSE3() const { return X86SSELevel >= SSE3; }
|
2007-04-10 22:10:25 +00:00
|
|
|
bool hasSSSE3() const { return X86SSELevel >= SSSE3; }
|
2008-04-03 08:53:29 +00:00
|
|
|
bool hasSSE41() const { return X86SSELevel >= SSE41; }
|
|
|
|
bool hasSSE42() const { return X86SSELevel >= SSE42; }
|
2009-05-26 21:04:35 +00:00
|
|
|
bool hasSSE4A() const { return HasSSE4A; }
|
2006-10-06 09:17:41 +00:00
|
|
|
bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
|
|
|
|
bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
|
2010-12-04 20:32:23 +00:00
|
|
|
bool hasPOPCNT() const { return HasPOPCNT; }
|
2009-06-29 16:51:01 +00:00
|
|
|
bool hasAVX() const { return HasAVX; }
|
2010-12-10 00:26:57 +00:00
|
|
|
bool hasXMM() const { return hasSSE1() || hasAVX(); }
|
|
|
|
bool hasXMMInt() const { return hasSSE2() || hasAVX(); }
|
2010-04-02 21:54:27 +00:00
|
|
|
bool hasAES() const { return HasAES; }
|
2010-07-23 01:17:51 +00:00
|
|
|
bool hasCLMUL() const { return HasCLMUL; }
|
2009-06-26 22:46:54 +00:00
|
|
|
bool hasFMA3() const { return HasFMA3; }
|
|
|
|
bool hasFMA4() const { return HasFMA4; }
|
2009-01-02 05:35:45 +00:00
|
|
|
bool isBTMemSlow() const { return IsBTMemSlow; }
|
2010-04-01 05:58:17 +00:00
|
|
|
bool isUnalignedMemAccessFast() const { return IsUAMemFast; }
|
2010-01-11 16:29:42 +00:00
|
|
|
bool hasVectorUAMem() const { return HasVectorUAMem; }
|
2009-01-02 05:35:45 +00:00
|
|
|
|
2010-07-05 19:26:33 +00:00
|
|
|
bool isTargetDarwin() const { return TargetTriple.getOS() == Triple::Darwin; }
|
|
|
|
|
|
|
|
// ELF is a reasonably sane default and the only other X86 targets we
|
|
|
|
// support are Darwin and Windows. Just use "not those".
|
|
|
|
bool isTargetELF() const {
|
|
|
|
return !isTargetDarwin() && !isTargetWindows() && !isTargetCygMing();
|
|
|
|
}
|
|
|
|
bool isTargetLinux() const { return TargetTriple.getOS() == Triple::Linux; }
|
2010-02-28 22:54:30 +00:00
|
|
|
|
2010-07-05 19:26:33 +00:00
|
|
|
bool isTargetWindows() const { return TargetTriple.getOS() == Triple::Win32; }
|
|
|
|
bool isTargetMingw() const {
|
|
|
|
return TargetTriple.getOS() == Triple::MinGW32 ||
|
|
|
|
TargetTriple.getOS() == Triple::MinGW64; }
|
|
|
|
bool isTargetCygwin() const { return TargetTriple.getOS() == Triple::Cygwin; }
|
2009-07-10 07:20:05 +00:00
|
|
|
bool isTargetCygMing() const {
|
2010-07-05 19:26:33 +00:00
|
|
|
return isTargetMingw() || isTargetCygwin();
|
2009-07-10 07:20:05 +00:00
|
|
|
}
|
2010-07-05 19:26:33 +00:00
|
|
|
|
2009-09-16 05:20:33 +00:00
|
|
|
/// isTargetCOFF - Return true if this is any COFF/Windows target variant.
|
|
|
|
bool isTargetCOFF() const {
|
2010-07-05 19:26:33 +00:00
|
|
|
return isTargetMingw() || isTargetCygwin() || isTargetWindows();
|
2009-09-16 05:20:33 +00:00
|
|
|
}
|
2010-02-28 22:54:30 +00:00
|
|
|
|
2008-03-22 20:57:27 +00:00
|
|
|
bool isTargetWin64() const {
|
2010-07-05 19:26:33 +00:00
|
|
|
return Is64Bit && (isTargetMingw() || isTargetWindows());
|
2008-03-22 20:57:27 +00:00
|
|
|
}
|
2006-11-21 00:01:06 +00:00
|
|
|
|
2011-02-01 01:14:13 +00:00
|
|
|
bool isTargetEnvMacho() const {
|
|
|
|
return isTargetDarwin() || (TargetTriple.getEnvironment() == Triple::MachO);
|
|
|
|
}
|
|
|
|
|
2010-09-02 23:03:46 +00:00
|
|
|
bool isTargetWin32() const {
|
|
|
|
return !Is64Bit && (isTargetMingw() || isTargetWindows());
|
|
|
|
}
|
|
|
|
|
2008-11-28 09:29:37 +00: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 20:47:30 +00:00
|
|
|
|
2009-07-10 21:00:45 +00:00
|
|
|
bool isPICStyleStubPIC() const {
|
2009-07-10 20:58:47 +00:00
|
|
|
return PICStyle == PICStyles::StubPIC;
|
|
|
|
}
|
|
|
|
|
2009-07-10 21:00:45 +00:00
|
|
|
bool isPICStyleStubNoDynamic() const {
|
2009-07-10 20:58:47 +00:00
|
|
|
return PICStyle == PICStyles::StubDynamicNoPIC;
|
|
|
|
}
|
|
|
|
bool isPICStyleStubAny() const {
|
|
|
|
return PICStyle == PICStyles::StubDynamicNoPIC ||
|
|
|
|
PICStyle == PICStyles::StubPIC; }
|
2010-02-28 22:54:30 +00:00
|
|
|
|
2009-07-10 20:47:30 +00:00
|
|
|
/// getDarwinVers - Return the darwin version number, 8 = Tiger, 9 = Leopard,
|
|
|
|
/// 10 = Snow Leopard, etc.
|
2010-07-05 19:26:33 +00:00
|
|
|
unsigned getDarwinVers() const {
|
|
|
|
if (isTargetDarwin()) return TargetTriple.getDarwinMajorNumber();
|
|
|
|
return 0;
|
|
|
|
}
|
2010-02-28 22:54:30 +00:00
|
|
|
|
2009-07-10 07:20:05 +00: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 01:03:20 +00:00
|
|
|
|
2009-11-20 23:18:13 +00: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 04:53:57 +00:00
|
|
|
/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
|
|
|
|
/// to immediate address.
|
|
|
|
bool IsLegalToCallImmediateAddr(const TargetMachine &TM) const;
|
|
|
|
|
2008-04-01 20:38:36 +00: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-09-30 22:05:33 +00:00
|
|
|
const char *getBZeroEntry() const;
|
2008-12-16 03:35:01 +00: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 18:43:40 +00:00
|
|
|
|
|
|
|
/// IsCalleePop - Test whether a function should pop its own arguments.
|
|
|
|
bool IsCalleePop(bool isVarArg, CallingConv::ID CallConv) const;
|
2009-09-03 04:37:05 +00:00
|
|
|
};
|
2006-10-16 21:00:37 +00:00
|
|
|
|
2005-07-12 01:41:54 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|