Nate Begeman | 21e463b | 2005-10-16 05:39:50 +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 | // |
Andrew Lenharth | 68fd486 | 2005-09-29 21:11:57 +0000 | [diff] [blame] | 10 | // This file declares the PowerPC specific subclass of TargetSubtarget. |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef POWERPCSUBTARGET_H |
| 15 | #define POWERPCSUBTARGET_H |
| 16 | |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 17 | #include "llvm/Target/TargetInstrItineraries.h" |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetSubtarget.h" |
| 19 | |
Jim Laskey | b1e1180 | 2005-09-01 21:38:21 +0000 | [diff] [blame] | 20 | #include <string> |
| 21 | |
Nick Lewycky | bd92d81 | 2007-01-19 04:36:02 +0000 | [diff] [blame] | 22 | // GCC #defines PPC on Linux but we use it as our namespace name |
| 23 | #undef PPC |
| 24 | |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 25 | namespace llvm { |
Jim Laskey | c35010d | 2006-12-12 20:57:08 +0000 | [diff] [blame] | 26 | |
| 27 | namespace PPC { |
| 28 | // -m directive values. |
| 29 | enum { |
Dale Johannesen | db01c8b | 2008-02-14 23:35:16 +0000 | [diff] [blame] | 30 | DIR_NONE, |
Jim Laskey | c35010d | 2006-12-12 20:57:08 +0000 | [diff] [blame] | 31 | DIR_32, |
| 32 | DIR_601, |
| 33 | DIR_602, |
| 34 | DIR_603, |
| 35 | DIR_7400, |
| 36 | DIR_750, |
| 37 | DIR_970, |
| 38 | DIR_64 |
| 39 | }; |
| 40 | } |
| 41 | |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 42 | class GlobalValue; |
| 43 | class TargetMachine; |
| 44 | |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 45 | class PPCSubtarget : public TargetSubtarget { |
| 46 | protected: |
| 47 | /// stackAlignment - The minimum alignment known to hold of the stack frame on |
| 48 | /// entry to the function and which must be maintained by every function. |
Chris Lattner | 3c304a3 | 2005-08-05 22:05:03 +0000 | [diff] [blame] | 49 | unsigned StackAlignment; |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 50 | |
| 51 | /// Selected instruction itineraries (one entry per itinerary class.) |
| 52 | InstrItineraryData InstrItins; |
Jim Laskey | c35010d | 2006-12-12 20:57:08 +0000 | [diff] [blame] | 53 | |
| 54 | /// Which cpu directive was used. |
| 55 | unsigned DarwinDirective; |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 56 | |
| 57 | /// Used by the ISel to turn in optimizations for POWER4-derived architectures |
Chris Lattner | 3c304a3 | 2005-08-05 22:05:03 +0000 | [diff] [blame] | 58 | bool IsGigaProcessor; |
Chris Lattner | a7a5854 | 2006-06-16 17:34:12 +0000 | [diff] [blame] | 59 | bool Has64BitSupport; |
| 60 | bool Use64BitRegs; |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 61 | bool IsPPC64; |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 62 | bool HasAltivec; |
Chris Lattner | 1e9de3e | 2005-09-02 18:33:05 +0000 | [diff] [blame] | 63 | bool HasFSQRT; |
Chris Lattner | bf751e2 | 2006-02-28 07:08:22 +0000 | [diff] [blame] | 64 | bool HasSTFIWX; |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 65 | bool HasLazyResolverStubs; |
Chris Lattner | 564da5d | 2008-01-02 19:35:16 +0000 | [diff] [blame] | 66 | |
| 67 | /// DarwinVers - Nonzero if this is a darwin platform. Otherwise, the numeric |
| 68 | /// version of the platform, e.g. 8 = 10.4 (Tiger), 9 = 10.5 (Leopard), etc. |
| 69 | unsigned char DarwinVers; // Is any darwin-ppc platform. |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 70 | public: |
| 71 | /// This constructor initializes the data members to match that |
Daniel Dunbar | 3be0340 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 72 | /// of the specified triple. |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 73 | /// |
Daniel Dunbar | 3be0340 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 74 | PPCSubtarget(const std::string &TT, const std::string &FS, bool is64Bit); |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 75 | |
| 76 | /// ParseSubtargetFeatures - Parses features string setting specified |
Jim Laskey | 2cbc207 | 2005-10-26 18:07:50 +0000 | [diff] [blame] | 77 | /// subtarget options. Definition of function is auto generated by tblgen. |
Anton Korobeynikov | 41a0243 | 2009-05-23 19:50:50 +0000 | [diff] [blame] | 78 | std::string ParseSubtargetFeatures(const std::string &FS, |
| 79 | const std::string &CPU); |
| 80 | |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 81 | |
| 82 | /// SetJITMode - This is called to inform the subtarget info that we are |
| 83 | /// producing code for the JIT. |
| 84 | void SetJITMode(); |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 85 | |
| 86 | /// getStackAlignment - Returns the minimum alignment known to hold of the |
| 87 | /// stack frame on entry to the function and which must be maintained by every |
| 88 | /// function for this subtarget. |
Chris Lattner | 3c304a3 | 2005-08-05 22:05:03 +0000 | [diff] [blame] | 89 | unsigned getStackAlignment() const { return StackAlignment; } |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 90 | |
Jim Laskey | c35010d | 2006-12-12 20:57:08 +0000 | [diff] [blame] | 91 | /// getDarwinDirective - Returns the -m directive specified for the cpu. |
| 92 | /// |
| 93 | unsigned getDarwinDirective() const { return DarwinDirective; } |
| 94 | |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 95 | /// getInstrItins - Return the instruction itineraies based on subtarget |
| 96 | /// selection. |
Chris Lattner | 442b9a6 | 2006-12-11 21:42:55 +0000 | [diff] [blame] | 97 | const InstrItineraryData &getInstrItineraryData() const { return InstrItins; } |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 98 | |
| 99 | /// getTargetDataString - Return the pointer size and type alignment |
| 100 | /// properties of this subtarget. |
Chris Lattner | 94de9a8 | 2006-06-16 01:37:27 +0000 | [diff] [blame] | 101 | const char *getTargetDataString() const { |
Dale Johannesen | ded2b20 | 2009-02-27 00:56:35 +0000 | [diff] [blame] | 102 | // Note, the alignment values for f64 and i64 on ppc64 in Darwin |
| 103 | // documentation are wrong; these are correct (i.e. "what gcc does"). |
Chris Lattner | 59a9178 | 2009-11-07 19:07:32 +0000 | [diff] [blame] | 104 | return isPPC64() ? "E-p:64:64-f64:64:64-i64:64:64-f128:64:128-n32:64" |
| 105 | : "E-p:32:32-f64:32:64-i64:32:64-f128:64:128-n32"; |
Chris Lattner | 94de9a8 | 2006-06-16 01:37:27 +0000 | [diff] [blame] | 106 | } |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 107 | |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 108 | /// isPPC64 - Return true if we are generating code for 64-bit pointer mode. |
| 109 | /// |
| 110 | bool isPPC64() const { return IsPPC64; } |
| 111 | |
| 112 | /// has64BitSupport - Return true if the selected CPU supports 64-bit |
| 113 | /// instructions, regardless of whether we are in 32-bit or 64-bit mode. |
| 114 | bool has64BitSupport() const { return Has64BitSupport; } |
| 115 | |
| 116 | /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit |
| 117 | /// registers in 32-bit mode when possible. This can only true if |
| 118 | /// has64BitSupport() returns true. |
| 119 | bool use64BitRegs() const { return Use64BitRegs; } |
| 120 | |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 121 | /// hasLazyResolverStub - Return true if accesses to the specified global have |
| 122 | /// to go through a dyld lazy resolution stub. This means that an extra load |
| 123 | /// is required to get the address of the global. |
Daniel Dunbar | 3be0340 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 124 | bool hasLazyResolverStub(const GlobalValue *GV, |
| 125 | const TargetMachine &TM) const; |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 126 | |
| 127 | // Specific obvious features. |
Chris Lattner | 1e9de3e | 2005-09-02 18:33:05 +0000 | [diff] [blame] | 128 | bool hasFSQRT() const { return HasFSQRT; } |
Chris Lattner | bf751e2 | 2006-02-28 07:08:22 +0000 | [diff] [blame] | 129 | bool hasSTFIWX() const { return HasSTFIWX; } |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 130 | bool hasAltivec() const { return HasAltivec; } |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 131 | bool isGigaProcessor() const { return IsGigaProcessor; } |
Bill Wendling | cb90099 | 2007-01-16 09:29:17 +0000 | [diff] [blame] | 132 | |
Chris Lattner | 564da5d | 2008-01-02 19:35:16 +0000 | [diff] [blame] | 133 | /// isDarwin - True if this is any darwin platform. |
| 134 | bool isDarwin() const { return DarwinVers != 0; } |
| 135 | /// isDarwin - True if this is darwin9 (leopard, 10.5) or above. |
| 136 | bool isDarwin9() const { return DarwinVers >= 9; } |
Bill Wendling | cb90099 | 2007-01-16 09:29:17 +0000 | [diff] [blame] | 137 | |
Rafael Espindola | 2f6fea9 | 2008-12-19 10:55:56 +0000 | [diff] [blame] | 138 | /// getDarwinVers - Return the darwin version number, 8 = tiger, 9 = leopard. |
| 139 | unsigned getDarwinVers() const { return DarwinVers; } |
| 140 | |
Tilmann Scheller | 6b16eff | 2009-08-15 11:54:46 +0000 | [diff] [blame] | 141 | bool isDarwinABI() const { return isDarwin(); } |
| 142 | bool isSVR4ABI() const { return !isDarwin(); } |
| 143 | |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 144 | }; |
| 145 | } // End llvm namespace |
| 146 | |
| 147 | #endif |