Jia Liu | 31d157a | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- PPCSubtarget.h - Define Subtarget for the PPC ----------*- C++ -*--===// |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Evan Cheng | 5b1b4489 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 10 | // This file declares the PowerPC specific subclass of TargetSubtargetInfo. |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef POWERPCSUBTARGET_H |
| 15 | #define POWERPCSUBTARGET_H |
| 16 | |
Evan Cheng | ab8be96 | 2011-06-29 01:14:12 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/Triple.h" |
Chandler Carruth | a1514e2 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCInstrItineraries.h" |
| 19 | #include "llvm/Target/TargetSubtargetInfo.h" |
Jim Laskey | b1e1180 | 2005-09-01 21:38:21 +0000 | [diff] [blame] | 20 | #include <string> |
| 21 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 22 | #define GET_SUBTARGETINFO_HEADER |
Evan Cheng | 385e930 | 2011-07-01 22:36:09 +0000 | [diff] [blame] | 23 | #include "PPCGenSubtargetInfo.inc" |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 24 | |
Nick Lewycky | bd92d81 | 2007-01-19 04:36:02 +0000 | [diff] [blame] | 25 | // GCC #defines PPC on Linux but we use it as our namespace name |
| 26 | #undef PPC |
| 27 | |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 28 | namespace llvm { |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 29 | class StringRef; |
Jim Laskey | c35010d | 2006-12-12 20:57:08 +0000 | [diff] [blame] | 30 | |
| 31 | namespace PPC { |
| 32 | // -m directive values. |
| 33 | enum { |
Dale Johannesen | db01c8b | 2008-02-14 23:35:16 +0000 | [diff] [blame] | 34 | DIR_NONE, |
Jim Laskey | c35010d | 2006-12-12 20:57:08 +0000 | [diff] [blame] | 35 | DIR_32, |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 36 | DIR_440, |
| 37 | DIR_601, |
| 38 | DIR_602, |
| 39 | DIR_603, |
Jim Laskey | c35010d | 2006-12-12 20:57:08 +0000 | [diff] [blame] | 40 | DIR_7400, |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 41 | DIR_750, |
| 42 | DIR_970, |
Hal Finkel | 4d989ac | 2012-04-01 19:22:40 +0000 | [diff] [blame] | 43 | DIR_A2, |
Hal Finkel | 621b77a | 2012-08-28 16:12:39 +0000 | [diff] [blame] | 44 | DIR_E500mc, |
| 45 | DIR_E5500, |
Hal Finkel | 622382f | 2012-06-11 15:43:08 +0000 | [diff] [blame] | 46 | DIR_PWR6, |
| 47 | DIR_PWR7, |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 48 | DIR_64 |
Jim Laskey | c35010d | 2006-12-12 20:57:08 +0000 | [diff] [blame] | 49 | }; |
| 50 | } |
| 51 | |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 52 | class GlobalValue; |
| 53 | class TargetMachine; |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 54 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 55 | class PPCSubtarget : public PPCGenSubtargetInfo { |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 56 | protected: |
| 57 | /// stackAlignment - The minimum alignment known to hold of the stack frame on |
| 58 | /// entry to the function and which must be maintained by every function. |
Chris Lattner | 3c304a3 | 2005-08-05 22:05:03 +0000 | [diff] [blame] | 59 | unsigned StackAlignment; |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 60 | |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 61 | /// Selected instruction itineraries (one entry per itinerary class.) |
| 62 | InstrItineraryData InstrItins; |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 63 | |
Jim Laskey | c35010d | 2006-12-12 20:57:08 +0000 | [diff] [blame] | 64 | /// Which cpu directive was used. |
| 65 | unsigned DarwinDirective; |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 66 | |
| 67 | /// Used by the ISel to turn in optimizations for POWER4-derived architectures |
Hal Finkel | bd5cafd | 2012-06-11 19:57:01 +0000 | [diff] [blame] | 68 | bool HasMFOCRF; |
Chris Lattner | a7a5854 | 2006-06-16 17:34:12 +0000 | [diff] [blame] | 69 | bool Has64BitSupport; |
| 70 | bool Use64BitRegs; |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 71 | bool IsPPC64; |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 72 | bool HasAltivec; |
Chris Lattner | 1e9de3e | 2005-09-02 18:33:05 +0000 | [diff] [blame] | 73 | bool HasFSQRT; |
Chris Lattner | bf751e2 | 2006-02-28 07:08:22 +0000 | [diff] [blame] | 74 | bool HasSTFIWX; |
Hal Finkel | 009f7af | 2012-06-22 23:10:08 +0000 | [diff] [blame] | 75 | bool HasISEL; |
Hal Finkel | c6d08f1 | 2011-10-17 04:03:49 +0000 | [diff] [blame] | 76 | bool IsBookE; |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 77 | bool HasLazyResolverStubs; |
Torok Edwin | 0e3a1a8 | 2010-08-04 20:47:44 +0000 | [diff] [blame] | 78 | bool IsJITCodeModel; |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 79 | |
Daniel Dunbar | 869eca1 | 2011-04-19 20:54:28 +0000 | [diff] [blame] | 80 | /// TargetTriple - What processor and OS we're targeting. |
| 81 | Triple TargetTriple; |
| 82 | |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 83 | public: |
| 84 | /// This constructor initializes the data members to match that |
Daniel Dunbar | 3be0340 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 85 | /// of the specified triple. |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 86 | /// |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 87 | PPCSubtarget(const std::string &TT, const std::string &CPU, |
| 88 | const std::string &FS, bool is64Bit); |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 89 | |
| 90 | /// ParseSubtargetFeatures - Parses features string setting specified |
Jim Laskey | 2cbc207 | 2005-10-26 18:07:50 +0000 | [diff] [blame] | 91 | /// subtarget options. Definition of function is auto generated by tblgen. |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 92 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 93 | |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 94 | /// SetJITMode - This is called to inform the subtarget info that we are |
| 95 | /// producing code for the JIT. |
| 96 | void SetJITMode(); |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 97 | |
| 98 | /// getStackAlignment - Returns the minimum alignment known to hold of the |
| 99 | /// stack frame on entry to the function and which must be maintained by every |
| 100 | /// function for this subtarget. |
Chris Lattner | 3c304a3 | 2005-08-05 22:05:03 +0000 | [diff] [blame] | 101 | unsigned getStackAlignment() const { return StackAlignment; } |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 102 | |
Jim Laskey | c35010d | 2006-12-12 20:57:08 +0000 | [diff] [blame] | 103 | /// getDarwinDirective - Returns the -m directive specified for the cpu. |
| 104 | /// |
| 105 | unsigned getDarwinDirective() const { return DarwinDirective; } |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 106 | |
| 107 | /// getInstrItins - Return the instruction itineraies based on subtarget |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 108 | /// selection. |
Chris Lattner | 442b9a6 | 2006-12-11 21:42:55 +0000 | [diff] [blame] | 109 | const InstrItineraryData &getInstrItineraryData() const { return InstrItins; } |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 110 | |
Micah Villmow | 3574eca | 2012-10-08 16:38:25 +0000 | [diff] [blame] | 111 | /// getDataLayoutString - Return the pointer size and type alignment |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 112 | /// properties of this subtarget. |
Micah Villmow | 3574eca | 2012-10-08 16:38:25 +0000 | [diff] [blame] | 113 | const char *getDataLayoutString() const { |
Dale Johannesen | ded2b20 | 2009-02-27 00:56:35 +0000 | [diff] [blame] | 114 | // Note, the alignment values for f64 and i64 on ppc64 in Darwin |
| 115 | // documentation are wrong; these are correct (i.e. "what gcc does"). |
NAKAMURA Takumi | baafdea | 2012-10-29 15:51:42 +0000 | [diff] [blame] | 116 | if (isPPC64() && isSVR4ABI()) { |
Bill Schmidt | 01d013e | 2012-10-29 14:59:36 +0000 | [diff] [blame] | 117 | if (TargetTriple.getOS() == llvm::Triple::FreeBSD) |
| 118 | return "E-p:64:64-f64:64:64-i64:64:64-f128:64:64-v128:128:128-n32:64"; |
| 119 | else |
| 120 | return "E-p:64:64-f64:64:64-i64:64:64-f128:128:128-v128:128:128-n32:64"; |
NAKAMURA Takumi | baafdea | 2012-10-29 15:51:42 +0000 | [diff] [blame] | 121 | } |
Bill Schmidt | 01d013e | 2012-10-29 14:59:36 +0000 | [diff] [blame] | 122 | |
Chris Lattner | 59a9178 | 2009-11-07 19:07:32 +0000 | [diff] [blame] | 123 | return isPPC64() ? "E-p:64:64-f64:64:64-i64:64:64-f128:64:128-n32:64" |
Roman Divacky | b272332 | 2011-07-03 16:24:07 +0000 | [diff] [blame] | 124 | : "E-p:32:32-f64:64:64-i64:64:64-f128:64:128-n32"; |
Chris Lattner | 94de9a8 | 2006-06-16 01:37:27 +0000 | [diff] [blame] | 125 | } |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 126 | |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 127 | /// isPPC64 - Return true if we are generating code for 64-bit pointer mode. |
| 128 | /// |
| 129 | bool isPPC64() const { return IsPPC64; } |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 130 | |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 131 | /// has64BitSupport - Return true if the selected CPU supports 64-bit |
| 132 | /// instructions, regardless of whether we are in 32-bit or 64-bit mode. |
| 133 | bool has64BitSupport() const { return Has64BitSupport; } |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 134 | |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 135 | /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit |
| 136 | /// registers in 32-bit mode when possible. This can only true if |
| 137 | /// has64BitSupport() returns true. |
| 138 | bool use64BitRegs() const { return Use64BitRegs; } |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 139 | |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 140 | /// hasLazyResolverStub - Return true if accesses to the specified global have |
| 141 | /// to go through a dyld lazy resolution stub. This means that an extra load |
| 142 | /// is required to get the address of the global. |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 143 | bool hasLazyResolverStub(const GlobalValue *GV, |
Daniel Dunbar | 3be0340 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 144 | const TargetMachine &TM) const; |
NAKAMURA Takumi | 19ad3e2 | 2012-10-29 15:51:35 +0000 | [diff] [blame] | 145 | |
Torok Edwin | 0e3a1a8 | 2010-08-04 20:47:44 +0000 | [diff] [blame] | 146 | // isJITCodeModel - True if we're generating code for the JIT |
| 147 | bool isJITCodeModel() const { return IsJITCodeModel; } |
| 148 | |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 149 | // Specific obvious features. |
Chris Lattner | 1e9de3e | 2005-09-02 18:33:05 +0000 | [diff] [blame] | 150 | bool hasFSQRT() const { return HasFSQRT; } |
Chris Lattner | bf751e2 | 2006-02-28 07:08:22 +0000 | [diff] [blame] | 151 | bool hasSTFIWX() const { return HasSTFIWX; } |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 152 | bool hasAltivec() const { return HasAltivec; } |
Hal Finkel | bd5cafd | 2012-06-11 19:57:01 +0000 | [diff] [blame] | 153 | bool hasMFOCRF() const { return HasMFOCRF; } |
Hal Finkel | 009f7af | 2012-06-22 23:10:08 +0000 | [diff] [blame] | 154 | bool hasISEL() const { return HasISEL; } |
Hal Finkel | c6d08f1 | 2011-10-17 04:03:49 +0000 | [diff] [blame] | 155 | bool isBookE() const { return IsBookE; } |
Bill Wendling | cb90099 | 2007-01-16 09:29:17 +0000 | [diff] [blame] | 156 | |
Daniel Dunbar | 869eca1 | 2011-04-19 20:54:28 +0000 | [diff] [blame] | 157 | const Triple &getTargetTriple() const { return TargetTriple; } |
| 158 | |
Chris Lattner | 564da5d | 2008-01-02 19:35:16 +0000 | [diff] [blame] | 159 | /// isDarwin - True if this is any darwin platform. |
Daniel Dunbar | 558692f | 2011-04-20 00:14:25 +0000 | [diff] [blame] | 160 | bool isDarwin() const { return TargetTriple.isMacOSX(); } |
Hal Finkel | 70272aa | 2012-04-02 19:09:04 +0000 | [diff] [blame] | 161 | /// isBGP - True if this is a BG/P platform. |
| 162 | bool isBGP() const { return TargetTriple.getVendor() == Triple::BGP; } |
Rafael Espindola | 2f6fea9 | 2008-12-19 10:55:56 +0000 | [diff] [blame] | 163 | |
Tilmann Scheller | 6b16eff | 2009-08-15 11:54:46 +0000 | [diff] [blame] | 164 | bool isDarwinABI() const { return isDarwin(); } |
| 165 | bool isSVR4ABI() const { return !isDarwin(); } |
| 166 | |
Hal Finkel | 64c34e2 | 2011-12-02 04:58:02 +0000 | [diff] [blame] | 167 | /// enablePostRAScheduler - True at 'More' optimization. |
| 168 | bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, |
| 169 | TargetSubtargetInfo::AntiDepBreakMode& Mode, |
| 170 | RegClassVector& CriticalPathRCs) const; |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 171 | }; |
| 172 | } // End llvm namespace |
| 173 | |
| 174 | #endif |