blob: 6e0d1dbae6e1df9ef7d05340026a316ee2f41e24 [file] [log] [blame]
Nate Begeman8c00f8c2005-08-04 07:12:09 +00001//=====---- X86Subtarget.h - Define Subtarget for the X86 -----*- C++ -*--====//
Nate Begemanfb5792f2005-07-12 01:41:54 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Nate Begeman and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file declares the X86 specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef X86SUBTARGET_H
15#define X86SUBTARGET_H
16
17#include "llvm/Target/TargetSubtarget.h"
18
Jim Laskeyb1e11802005-09-01 21:38:21 +000019#include <string>
20
Nate Begemanfb5792f2005-07-12 01:41:54 +000021namespace llvm {
22class Module;
23
24class X86Subtarget : public TargetSubtarget {
Jim Laskey05a059d2006-09-07 12:23:47 +000025public:
26 enum AsmWriterFlavorTy {
Chris Lattner2dd538c2006-09-07 22:32:28 +000027 att, intel, unset
Jim Laskey05a059d2006-09-07 12:23:47 +000028 };
29
Nate Begemanfb5792f2005-07-12 01:41:54 +000030protected:
Evan Cheng559806f2006-01-27 08:10:46 +000031 enum X86SSEEnum {
Chris Lattner259e97c2006-01-31 19:43:35 +000032 NoMMXSSE, MMX, SSE1, SSE2, SSE3
Evan Cheng559806f2006-01-27 08:10:46 +000033 };
34
35 enum X863DNowEnum {
36 NoThreeDNow, ThreeDNow, ThreeDNowA
37 };
38
Jim Laskey05a059d2006-09-07 12:23:47 +000039 /// AsmFlavor - Which x86 asm dialect to use.
40 AsmWriterFlavorTy AsmFlavor;
41
Chris Lattner259e97c2006-01-31 19:43:35 +000042 /// X86SSELevel - MMX, SSE1, SSE2, SSE3, or none supported.
Evan Cheng559806f2006-01-27 08:10:46 +000043 X86SSEEnum X86SSELevel;
44
45 /// X863DNowLevel - 3DNow or 3DNow Athlon, or none supported.
46 X863DNowEnum X863DNowLevel;
Evan Cheng25ab6902006-09-08 06:48:29 +000047
48 /// HasX86_64 - True if the processor supports X86-64 instructions.
49 bool HasX86_64;
Evan Cheng559806f2006-01-27 08:10:46 +000050
Chris Lattnerb151aca2005-07-12 02:36:10 +000051 /// stackAlignment - The minimum alignment known to hold of the stack frame on
52 /// entry to the function and which must be maintained by every function.
Nate Begemanfb5792f2005-07-12 01:41:54 +000053 unsigned stackAlignment;
Jeff Cohen9eb59ec2005-07-27 05:53:44 +000054
Evan Cheng18a84522006-02-16 00:21:07 +000055 /// Min. memset / memcpy size that is turned into rep/movs, rep/stos ops.
56 unsigned MinRepStrSizeThreshold;
57
Evan Cheng25ab6902006-09-08 06:48:29 +000058private:
59 /// Is64Bit - True if the processor supports 64-bit instructions and module
60 /// pointer size is 64 bit.
61 bool Is64Bit;
62
Nate Begemanfb5792f2005-07-12 01:41:54 +000063public:
Chris Lattnere5600e52005-11-21 22:31:58 +000064 enum {
65 isELF, isCygwin, isDarwin, isWindows
66 } TargetType;
67
Jeff Cohen9eb59ec2005-07-27 05:53:44 +000068 /// This constructor initializes the data members to match that
Nate Begemanfb5792f2005-07-12 01:41:54 +000069 /// of the specified module.
70 ///
Evan Cheng25ab6902006-09-08 06:48:29 +000071 X86Subtarget(const Module &M, const std::string &FS, bool is64Bit);
Chris Lattnerb151aca2005-07-12 02:36:10 +000072
73 /// getStackAlignment - Returns the minimum alignment known to hold of the
74 /// stack frame on entry to the function and which must be maintained by every
75 /// function for this subtarget.
Nate Begemanfb5792f2005-07-12 01:41:54 +000076 unsigned getStackAlignment() const { return stackAlignment; }
Jeff Cohen9eb59ec2005-07-27 05:53:44 +000077
Evan Cheng18a84522006-02-16 00:21:07 +000078 /// getMinRepStrSizeThreshold - Returns the minimum memset / memcpy size
79 /// required to turn the operation into a X86 rep/movs or rep/stos
80 /// instruction. This is only used if the src / dst alignment is not DWORD
81 /// aligned.
82 unsigned getMinRepStrSizeThreshold() const { return MinRepStrSizeThreshold; }
83
Evan Cheng97c7fc32006-01-26 09:53:06 +000084 /// ParseSubtargetFeatures - Parses features string setting specified
85 /// subtarget options. Definition of function is auto generated by tblgen.
86 void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
87
88 bool is64Bit() const { return Is64Bit; }
89
Evan Cheng559806f2006-01-27 08:10:46 +000090 bool hasMMX() const { return X86SSELevel >= MMX; }
Chris Lattner259e97c2006-01-31 19:43:35 +000091 bool hasSSE1() const { return X86SSELevel >= SSE1; }
Evan Cheng559806f2006-01-27 08:10:46 +000092 bool hasSSE2() const { return X86SSELevel >= SSE2; }
93 bool hasSSE3() const { return X86SSELevel >= SSE3; }
94 bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
95 bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
Jim Laskey05a059d2006-09-07 12:23:47 +000096
97 bool isFlavorAtt() const { return AsmFlavor == att; }
98 bool isFlavorIntel() const { return AsmFlavor == intel; }
Evan Cheng7ccced62006-02-18 00:15:05 +000099
100 bool isTargetDarwin() const { return TargetType == isDarwin; }
Chris Lattnerdd842e12006-09-04 04:08:58 +0000101 bool isTargetELF() const { return TargetType == isELF; }
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000102 bool isTargetWindows() const { return TargetType == isWindows; }
103 bool isTargetCygwin() const { return TargetType == isCygwin; }
Nate Begemanfb5792f2005-07-12 01:41:54 +0000104};
105} // End llvm namespace
106
107#endif