blob: fbd97de16a62b1fb58c3c4f29c9f4320f944d2b7 [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//===-- PPCSubtarget.h - Define Subtarget for the PPC ----------*- C++ -*--===//
Nate Begeman8c00f8c2005-08-04 07:12:09 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Nate Begeman8c00f8c2005-08-04 07:12:09 +00007//
8//===----------------------------------------------------------------------===//
9//
Evan Cheng5b1b44892011-07-01 21:01:15 +000010// This file declares the PowerPC specific subclass of TargetSubtargetInfo.
Nate Begeman8c00f8c2005-08-04 07:12:09 +000011//
12//===----------------------------------------------------------------------===//
13
14#ifndef POWERPCSUBTARGET_H
15#define POWERPCSUBTARGET_H
16
Evan Cheng5b1b44892011-07-01 21:01:15 +000017#include "llvm/Target/TargetSubtargetInfo.h"
Evan Chengab8be962011-06-29 01:14:12 +000018#include "llvm/MC/MCInstrItineraries.h"
19#include "llvm/ADT/Triple.h"
Jim Laskeyb1e11802005-09-01 21:38:21 +000020#include <string>
21
Evan Cheng94214702011-07-01 20:45:01 +000022#define GET_SUBTARGETINFO_HEADER
Evan Cheng385e9302011-07-01 22:36:09 +000023#include "PPCGenSubtargetInfo.inc"
Evan Cheng94214702011-07-01 20:45:01 +000024
Nick Lewyckybd92d812007-01-19 04:36:02 +000025// GCC #defines PPC on Linux but we use it as our namespace name
26#undef PPC
27
Nate Begeman8c00f8c2005-08-04 07:12:09 +000028namespace llvm {
Evan Cheng0ddff1b2011-07-07 07:07:08 +000029class StringRef;
Jim Laskeyc35010d2006-12-12 20:57:08 +000030
31namespace PPC {
32 // -m directive values.
33 enum {
Dale Johannesendb01c8b2008-02-14 23:35:16 +000034 DIR_NONE,
Jim Laskeyc35010d2006-12-12 20:57:08 +000035 DIR_32,
Hal Finkelc6d08f12011-10-17 04:03:49 +000036 DIR_440,
Jim Laskeyc35010d2006-12-12 20:57:08 +000037 DIR_601,
38 DIR_602,
39 DIR_603,
40 DIR_7400,
41 DIR_750,
42 DIR_970,
Hal Finkel4d989ac2012-04-01 19:22:40 +000043 DIR_A2,
Jim Laskeyc35010d2006-12-12 20:57:08 +000044 DIR_64
45 };
46}
47
Chris Lattner57fc62c2006-12-11 23:22:45 +000048class GlobalValue;
49class TargetMachine;
50
Evan Cheng94214702011-07-01 20:45:01 +000051class PPCSubtarget : public PPCGenSubtargetInfo {
Nate Begeman8c00f8c2005-08-04 07:12:09 +000052protected:
53 /// stackAlignment - The minimum alignment known to hold of the stack frame on
54 /// entry to the function and which must be maintained by every function.
Chris Lattner3c304a32005-08-05 22:05:03 +000055 unsigned StackAlignment;
Jim Laskey6cee6302005-11-01 20:06:59 +000056
57 /// Selected instruction itineraries (one entry per itinerary class.)
58 InstrItineraryData InstrItins;
Jim Laskeyc35010d2006-12-12 20:57:08 +000059
60 /// Which cpu directive was used.
61 unsigned DarwinDirective;
Nate Begeman8c00f8c2005-08-04 07:12:09 +000062
63 /// Used by the ISel to turn in optimizations for POWER4-derived architectures
Chris Lattner3c304a32005-08-05 22:05:03 +000064 bool IsGigaProcessor;
Chris Lattnera7a58542006-06-16 17:34:12 +000065 bool Has64BitSupport;
66 bool Use64BitRegs;
Chris Lattner7c1fb5f2006-06-16 17:50:12 +000067 bool IsPPC64;
Jim Laskey581a8f72005-10-26 17:30:34 +000068 bool HasAltivec;
Chris Lattner1e9de3e2005-09-02 18:33:05 +000069 bool HasFSQRT;
Chris Lattnerbf751e22006-02-28 07:08:22 +000070 bool HasSTFIWX;
Hal Finkelc6d08f12011-10-17 04:03:49 +000071 bool IsBookE;
Chris Lattner57fc62c2006-12-11 23:22:45 +000072 bool HasLazyResolverStubs;
Torok Edwin0e3a1a82010-08-04 20:47:44 +000073 bool IsJITCodeModel;
Chris Lattner564da5d2008-01-02 19:35:16 +000074
Daniel Dunbar869eca12011-04-19 20:54:28 +000075 /// TargetTriple - What processor and OS we're targeting.
76 Triple TargetTriple;
77
Nate Begeman8c00f8c2005-08-04 07:12:09 +000078public:
79 /// This constructor initializes the data members to match that
Daniel Dunbar3be03402009-08-02 22:11:08 +000080 /// of the specified triple.
Nate Begeman8c00f8c2005-08-04 07:12:09 +000081 ///
Evan Cheng276365d2011-06-30 01:53:36 +000082 PPCSubtarget(const std::string &TT, const std::string &CPU,
83 const std::string &FS, bool is64Bit);
Jim Laskey581a8f72005-10-26 17:30:34 +000084
85 /// ParseSubtargetFeatures - Parses features string setting specified
Jim Laskey2cbc2072005-10-26 18:07:50 +000086 /// subtarget options. Definition of function is auto generated by tblgen.
Evan Cheng0ddff1b2011-07-07 07:07:08 +000087 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Chris Lattner57fc62c2006-12-11 23:22:45 +000088
89 /// SetJITMode - This is called to inform the subtarget info that we are
90 /// producing code for the JIT.
91 void SetJITMode();
Nate Begeman8c00f8c2005-08-04 07:12:09 +000092
93 /// getStackAlignment - Returns the minimum alignment known to hold of the
94 /// stack frame on entry to the function and which must be maintained by every
95 /// function for this subtarget.
Chris Lattner3c304a32005-08-05 22:05:03 +000096 unsigned getStackAlignment() const { return StackAlignment; }
Jim Laskey6cee6302005-11-01 20:06:59 +000097
Jim Laskeyc35010d2006-12-12 20:57:08 +000098 /// getDarwinDirective - Returns the -m directive specified for the cpu.
99 ///
100 unsigned getDarwinDirective() const { return DarwinDirective; }
101
Jim Laskey6cee6302005-11-01 20:06:59 +0000102 /// getInstrItins - Return the instruction itineraies based on subtarget
103 /// selection.
Chris Lattner442b9a62006-12-11 21:42:55 +0000104 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
Chris Lattner7c1fb5f2006-06-16 17:50:12 +0000105
106 /// getTargetDataString - Return the pointer size and type alignment
107 /// properties of this subtarget.
Chris Lattner94de9a82006-06-16 01:37:27 +0000108 const char *getTargetDataString() const {
Dale Johannesended2b202009-02-27 00:56:35 +0000109 // Note, the alignment values for f64 and i64 on ppc64 in Darwin
110 // documentation are wrong; these are correct (i.e. "what gcc does").
Chris Lattner59a91782009-11-07 19:07:32 +0000111 return isPPC64() ? "E-p:64:64-f64:64:64-i64:64:64-f128:64:128-n32:64"
Roman Divackyb2723322011-07-03 16:24:07 +0000112 : "E-p:32:32-f64:64:64-i64:64:64-f128:64:128-n32";
Chris Lattner94de9a82006-06-16 01:37:27 +0000113 }
Nate Begeman8c00f8c2005-08-04 07:12:09 +0000114
Chris Lattner7c1fb5f2006-06-16 17:50:12 +0000115 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
116 ///
117 bool isPPC64() const { return IsPPC64; }
118
119 /// has64BitSupport - Return true if the selected CPU supports 64-bit
120 /// instructions, regardless of whether we are in 32-bit or 64-bit mode.
121 bool has64BitSupport() const { return Has64BitSupport; }
122
123 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit
124 /// registers in 32-bit mode when possible. This can only true if
125 /// has64BitSupport() returns true.
126 bool use64BitRegs() const { return Use64BitRegs; }
127
Chris Lattner57fc62c2006-12-11 23:22:45 +0000128 /// hasLazyResolverStub - Return true if accesses to the specified global have
129 /// to go through a dyld lazy resolution stub. This means that an extra load
130 /// is required to get the address of the global.
Daniel Dunbar3be03402009-08-02 22:11:08 +0000131 bool hasLazyResolverStub(const GlobalValue *GV,
132 const TargetMachine &TM) const;
Chris Lattner7c1fb5f2006-06-16 17:50:12 +0000133
Torok Edwin0e3a1a82010-08-04 20:47:44 +0000134 // isJITCodeModel - True if we're generating code for the JIT
135 bool isJITCodeModel() const { return IsJITCodeModel; }
136
Chris Lattner7c1fb5f2006-06-16 17:50:12 +0000137 // Specific obvious features.
Chris Lattner1e9de3e2005-09-02 18:33:05 +0000138 bool hasFSQRT() const { return HasFSQRT; }
Chris Lattnerbf751e22006-02-28 07:08:22 +0000139 bool hasSTFIWX() const { return HasSTFIWX; }
Jim Laskey581a8f72005-10-26 17:30:34 +0000140 bool hasAltivec() const { return HasAltivec; }
Chris Lattner7c1fb5f2006-06-16 17:50:12 +0000141 bool isGigaProcessor() const { return IsGigaProcessor; }
Hal Finkelc6d08f12011-10-17 04:03:49 +0000142 bool isBookE() const { return IsBookE; }
Bill Wendlingcb900992007-01-16 09:29:17 +0000143
Daniel Dunbar869eca12011-04-19 20:54:28 +0000144 const Triple &getTargetTriple() const { return TargetTriple; }
145
Chris Lattner564da5d2008-01-02 19:35:16 +0000146 /// isDarwin - True if this is any darwin platform.
Daniel Dunbar558692f2011-04-20 00:14:25 +0000147 bool isDarwin() const { return TargetTriple.isMacOSX(); }
Rafael Espindola2f6fea92008-12-19 10:55:56 +0000148
Tilmann Scheller6b16eff2009-08-15 11:54:46 +0000149 bool isDarwinABI() const { return isDarwin(); }
150 bool isSVR4ABI() const { return !isDarwin(); }
151
Hal Finkel64c34e22011-12-02 04:58:02 +0000152 /// enablePostRAScheduler - True at 'More' optimization.
153 bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
154 TargetSubtargetInfo::AntiDepBreakMode& Mode,
155 RegClassVector& CriticalPathRCs) const;
Nate Begeman8c00f8c2005-08-04 07:12:09 +0000156};
157} // End llvm namespace
158
159#endif