blob: e781d9527c8aec11e5c62a8d2658af2cf06b3c2d [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
Jim Laskey05a059d2006-09-07 12:23:47 +000035 /// AsmFlavor - Which x86 asm dialect to use.
36 AsmWriterFlavorTy AsmFlavor;
37
Chris Lattner259e97c2006-01-31 19:43:35 +000038 /// X86SSELevel - MMX, SSE1, SSE2, SSE3, or none supported.
Evan Cheng559806f2006-01-27 08:10:46 +000039 X86SSEEnum X86SSELevel;
40
Evan Cheng25ab6902006-09-08 06:48:29 +000041 /// HasX86_64 - True if the processor supports X86-64 instructions.
42 bool HasX86_64;
Evan Cheng559806f2006-01-27 08:10:46 +000043
Chris Lattnerb151aca2005-07-12 02:36:10 +000044 /// stackAlignment - The minimum alignment known to hold of the stack frame on
45 /// entry to the function and which must be maintained by every function.
Nate Begemanfb5792f2005-07-12 01:41:54 +000046 unsigned stackAlignment;
Jeff Cohen9eb59ec2005-07-27 05:53:44 +000047
Evan Cheng18a84522006-02-16 00:21:07 +000048 /// Min. memset / memcpy size that is turned into rep/movs, rep/stos ops.
49 unsigned MinRepStrSizeThreshold;
50
Evan Cheng25ab6902006-09-08 06:48:29 +000051private:
52 /// Is64Bit - True if the processor supports 64-bit instructions and module
53 /// pointer size is 64 bit.
54 bool Is64Bit;
55
Nate Begemanfb5792f2005-07-12 01:41:54 +000056public:
Chris Lattnere5600e52005-11-21 22:31:58 +000057 enum {
58 isELF, isCygwin, isDarwin, isWindows
59 } TargetType;
60
Jeff Cohen9eb59ec2005-07-27 05:53:44 +000061 /// This constructor initializes the data members to match that
Nate Begemanfb5792f2005-07-12 01:41:54 +000062 /// of the specified module.
63 ///
Evan Cheng25ab6902006-09-08 06:48:29 +000064 X86Subtarget(const Module &M, const std::string &FS, bool is64Bit);
Chris Lattnerb151aca2005-07-12 02:36:10 +000065
66 /// getStackAlignment - Returns the minimum alignment known to hold of the
67 /// stack frame on entry to the function and which must be maintained by every
68 /// function for this subtarget.
Nate Begemanfb5792f2005-07-12 01:41:54 +000069 unsigned getStackAlignment() const { return stackAlignment; }
Jeff Cohen9eb59ec2005-07-27 05:53:44 +000070
Evan Cheng18a84522006-02-16 00:21:07 +000071 /// getMinRepStrSizeThreshold - Returns the minimum memset / memcpy size
72 /// required to turn the operation into a X86 rep/movs or rep/stos
73 /// instruction. This is only used if the src / dst alignment is not DWORD
74 /// aligned.
75 unsigned getMinRepStrSizeThreshold() const { return MinRepStrSizeThreshold; }
76
Evan Chengabc346c2006-10-06 08:21:07 +000077 /// DetectSubtargetFeatures - Auto-detect CPU features using CPUID instruction.
78 ///
79 void DetectSubtargetFeatures();
Evan Cheng97c7fc32006-01-26 09:53:06 +000080
81 bool is64Bit() const { return Is64Bit; }
82
Evan Cheng559806f2006-01-27 08:10:46 +000083 bool hasMMX() const { return X86SSELevel >= MMX; }
Chris Lattner259e97c2006-01-31 19:43:35 +000084 bool hasSSE1() const { return X86SSELevel >= SSE1; }
Evan Cheng559806f2006-01-27 08:10:46 +000085 bool hasSSE2() const { return X86SSELevel >= SSE2; }
86 bool hasSSE3() const { return X86SSELevel >= SSE3; }
Jim Laskey05a059d2006-09-07 12:23:47 +000087
88 bool isFlavorAtt() const { return AsmFlavor == att; }
89 bool isFlavorIntel() const { return AsmFlavor == intel; }
Evan Cheng7ccced62006-02-18 00:15:05 +000090
91 bool isTargetDarwin() const { return TargetType == isDarwin; }
Chris Lattnerdd842e12006-09-04 04:08:58 +000092 bool isTargetELF() const { return TargetType == isELF; }
Anton Korobeynikovb74ed072006-09-14 18:23:27 +000093 bool isTargetWindows() const { return TargetType == isWindows; }
94 bool isTargetCygwin() const { return TargetType == isCygwin; }
Nate Begemanfb5792f2005-07-12 01:41:54 +000095};
96} // End llvm namespace
97
98#endif