blob: c874675445e46a077bb11b7dd4b9de3bb3da5839 [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 {
25protected:
Evan Cheng559806f2006-01-27 08:10:46 +000026 enum X86SSEEnum {
27 NoMMXSSE, MMX, SSE, SSE2, SSE3
28 };
29
30 enum X863DNowEnum {
31 NoThreeDNow, ThreeDNow, ThreeDNowA
32 };
33
34 /// X86SSELevel - MMX, SSE, SSE2, SSE3, or none supported.
35 X86SSEEnum X86SSELevel;
36
37 /// X863DNowLevel - 3DNow or 3DNow Athlon, or none supported.
38 X863DNowEnum X863DNowLevel;
39
40 /// Is64Bit - True if the processor supports Em64T.
41 bool Is64Bit;
42
Chris Lattnerb151aca2005-07-12 02:36:10 +000043 /// stackAlignment - The minimum alignment known to hold of the stack frame on
44 /// entry to the function and which must be maintained by every function.
Nate Begemanfb5792f2005-07-12 01:41:54 +000045 unsigned stackAlignment;
Jeff Cohen9eb59ec2005-07-27 05:53:44 +000046
Nate Begemanfb5792f2005-07-12 01:41:54 +000047 /// Used by instruction selector
48 bool indirectExternAndWeakGlobals;
Jeff Cohen9eb59ec2005-07-27 05:53:44 +000049
Nate Begemanfb5792f2005-07-12 01:41:54 +000050public:
Chris Lattnere5600e52005-11-21 22:31:58 +000051 enum {
52 isELF, isCygwin, isDarwin, isWindows
53 } TargetType;
54
Jeff Cohen9eb59ec2005-07-27 05:53:44 +000055 /// This constructor initializes the data members to match that
Nate Begemanfb5792f2005-07-12 01:41:54 +000056 /// of the specified module.
57 ///
Jim Laskeyb1e11802005-09-01 21:38:21 +000058 X86Subtarget(const Module &M, const std::string &FS);
Chris Lattnerb151aca2005-07-12 02:36:10 +000059
60 /// getStackAlignment - Returns the minimum alignment known to hold of the
61 /// stack frame on entry to the function and which must be maintained by every
62 /// function for this subtarget.
Nate Begemanfb5792f2005-07-12 01:41:54 +000063 unsigned getStackAlignment() const { return stackAlignment; }
Jeff Cohen9eb59ec2005-07-27 05:53:44 +000064
Nate Begemanfb5792f2005-07-12 01:41:54 +000065 /// Returns true if the instruction selector should treat global values
Jeff Cohen9eb59ec2005-07-27 05:53:44 +000066 /// referencing external or weak symbols as indirect rather than direct
Nate Begemanfb5792f2005-07-12 01:41:54 +000067 /// references.
Chris Lattnerb151aca2005-07-12 02:36:10 +000068 bool getIndirectExternAndWeakGlobals() const {
69 return indirectExternAndWeakGlobals;
70 }
Evan Cheng97c7fc32006-01-26 09:53:06 +000071
72 /// ParseSubtargetFeatures - Parses features string setting specified
73 /// subtarget options. Definition of function is auto generated by tblgen.
74 void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
75
76 bool is64Bit() const { return Is64Bit; }
77
Evan Cheng559806f2006-01-27 08:10:46 +000078 bool hasMMX() const { return X86SSELevel >= MMX; }
79 bool hasSSE() const { return X86SSELevel >= SSE; }
80 bool hasSSE2() const { return X86SSELevel >= SSE2; }
81 bool hasSSE3() const { return X86SSELevel >= SSE3; }
82 bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
83 bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
Nate Begemanfb5792f2005-07-12 01:41:54 +000084};
85} // End llvm namespace
86
87#endif