LLVM API Documentation
00001 //=====---- X86Subtarget.h - Define Subtarget for the X86 -----*- C++ -*--====// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by Nate Begeman and is distributed under the 00006 // University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file declares the X86 specific subclass of TargetSubtarget. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef X86SUBTARGET_H 00015 #define X86SUBTARGET_H 00016 00017 #include "llvm/Target/TargetSubtarget.h" 00018 00019 #include <string> 00020 00021 namespace llvm { 00022 class Module; 00023 00024 class X86Subtarget : public TargetSubtarget { 00025 protected: 00026 enum X86SSEEnum { 00027 NoMMXSSE, MMX, SSE1, SSE2, SSE3 00028 }; 00029 00030 enum X863DNowEnum { 00031 NoThreeDNow, ThreeDNow, ThreeDNowA 00032 }; 00033 00034 /// X86SSELevel - MMX, SSE1, SSE2, SSE3, or none supported. 00035 X86SSEEnum X86SSELevel; 00036 00037 /// X863DNowLevel - 3DNow or 3DNow Athlon, or none supported. 00038 X863DNowEnum X863DNowLevel; 00039 00040 /// Is64Bit - True if the processor supports Em64T. 00041 bool Is64Bit; 00042 00043 /// stackAlignment - The minimum alignment known to hold of the stack frame on 00044 /// entry to the function and which must be maintained by every function. 00045 unsigned stackAlignment; 00046 00047 /// Min. memset / memcpy size that is turned into rep/movs, rep/stos ops. 00048 unsigned MinRepStrSizeThreshold; 00049 00050 public: 00051 enum { 00052 isELF, isCygwin, isDarwin, isWindows 00053 } TargetType; 00054 00055 /// This constructor initializes the data members to match that 00056 /// of the specified module. 00057 /// 00058 X86Subtarget(const Module &M, const std::string &FS); 00059 00060 /// getStackAlignment - Returns the minimum alignment known to hold of the 00061 /// stack frame on entry to the function and which must be maintained by every 00062 /// function for this subtarget. 00063 unsigned getStackAlignment() const { return stackAlignment; } 00064 00065 /// getMinRepStrSizeThreshold - Returns the minimum memset / memcpy size 00066 /// required to turn the operation into a X86 rep/movs or rep/stos 00067 /// instruction. This is only used if the src / dst alignment is not DWORD 00068 /// aligned. 00069 unsigned getMinRepStrSizeThreshold() const { return MinRepStrSizeThreshold; } 00070 00071 /// ParseSubtargetFeatures - Parses features string setting specified 00072 /// subtarget options. Definition of function is auto generated by tblgen. 00073 void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU); 00074 00075 bool is64Bit() const { return Is64Bit; } 00076 00077 bool hasMMX() const { return X86SSELevel >= MMX; } 00078 bool hasSSE1() const { return X86SSELevel >= SSE1; } 00079 bool hasSSE2() const { return X86SSELevel >= SSE2; } 00080 bool hasSSE3() const { return X86SSELevel >= SSE3; } 00081 bool has3DNow() const { return X863DNowLevel >= ThreeDNow; } 00082 bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; } 00083 00084 bool isTargetDarwin() const { return TargetType == isDarwin; } 00085 }; 00086 } // End llvm namespace 00087 00088 #endif