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 | // |
| 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 | // |
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 { |
| 30 | DIR_32, |
| 31 | DIR_601, |
| 32 | DIR_602, |
| 33 | DIR_603, |
| 34 | DIR_7400, |
| 35 | DIR_750, |
| 36 | DIR_970, |
| 37 | DIR_64 |
| 38 | }; |
| 39 | } |
| 40 | |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 41 | class Module; |
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 { |
Bill Wendling | cb90099 | 2007-01-16 09:29:17 +0000 | [diff] [blame] | 46 | public: |
| 47 | enum AsmWriterFlavorTy { |
| 48 | OldMnemonic, NewMnemonic, Unset |
| 49 | }; |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 50 | protected: |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 51 | const TargetMachine &TM; |
| 52 | |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 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 Lattner | 3c304a3 | 2005-08-05 22:05:03 +0000 | [diff] [blame] | 55 | unsigned StackAlignment; |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 56 | |
| 57 | /// Selected instruction itineraries (one entry per itinerary class.) |
| 58 | InstrItineraryData InstrItins; |
Jim Laskey | c35010d | 2006-12-12 20:57:08 +0000 | [diff] [blame] | 59 | |
| 60 | /// Which cpu directive was used. |
| 61 | unsigned DarwinDirective; |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 62 | |
Bill Wendling | cb90099 | 2007-01-16 09:29:17 +0000 | [diff] [blame] | 63 | /// AsmFlavor - Which PPC asm dialect to use. |
| 64 | AsmWriterFlavorTy AsmFlavor; |
| 65 | |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 66 | /// Used by the ISel to turn in optimizations for POWER4-derived architectures |
Chris Lattner | 3c304a3 | 2005-08-05 22:05:03 +0000 | [diff] [blame] | 67 | bool IsGigaProcessor; |
Chris Lattner | a7a5854 | 2006-06-16 17:34:12 +0000 | [diff] [blame] | 68 | bool Has64BitSupport; |
| 69 | bool Use64BitRegs; |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 70 | bool IsPPC64; |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 71 | bool HasAltivec; |
Chris Lattner | 1e9de3e | 2005-09-02 18:33:05 +0000 | [diff] [blame] | 72 | bool HasFSQRT; |
Chris Lattner | bf751e2 | 2006-02-28 07:08:22 +0000 | [diff] [blame] | 73 | bool HasSTFIWX; |
Chris Lattner | 3c304a3 | 2005-08-05 22:05:03 +0000 | [diff] [blame] | 74 | bool IsDarwin; |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 75 | bool HasLazyResolverStubs; |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 76 | public: |
| 77 | /// This constructor initializes the data members to match that |
| 78 | /// of the specified module. |
| 79 | /// |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 80 | PPCSubtarget(const TargetMachine &TM, const Module &M, |
| 81 | const std::string &FS, bool is64Bit); |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 82 | |
| 83 | /// ParseSubtargetFeatures - Parses features string setting specified |
Jim Laskey | 2cbc207 | 2005-10-26 18:07:50 +0000 | [diff] [blame] | 84 | /// subtarget options. Definition of function is auto generated by tblgen. |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 85 | void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU); |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 86 | |
| 87 | /// SetJITMode - This is called to inform the subtarget info that we are |
| 88 | /// producing code for the JIT. |
| 89 | void SetJITMode(); |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 90 | |
| 91 | /// getStackAlignment - Returns the minimum alignment known to hold of the |
| 92 | /// stack frame on entry to the function and which must be maintained by every |
| 93 | /// function for this subtarget. |
Chris Lattner | 3c304a3 | 2005-08-05 22:05:03 +0000 | [diff] [blame] | 94 | unsigned getStackAlignment() const { return StackAlignment; } |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 95 | |
Jim Laskey | c35010d | 2006-12-12 20:57:08 +0000 | [diff] [blame] | 96 | /// getDarwinDirective - Returns the -m directive specified for the cpu. |
| 97 | /// |
| 98 | unsigned getDarwinDirective() const { return DarwinDirective; } |
| 99 | |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 100 | /// getInstrItins - Return the instruction itineraies based on subtarget |
| 101 | /// selection. |
Chris Lattner | 442b9a6 | 2006-12-11 21:42:55 +0000 | [diff] [blame] | 102 | const InstrItineraryData &getInstrItineraryData() const { return InstrItins; } |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 103 | |
| 104 | /// getTargetDataString - Return the pointer size and type alignment |
| 105 | /// properties of this subtarget. |
Chris Lattner | 94de9a8 | 2006-06-16 01:37:27 +0000 | [diff] [blame] | 106 | const char *getTargetDataString() const { |
Chris Lattner | d2b7cec | 2007-02-14 05:52:17 +0000 | [diff] [blame^] | 107 | return isPPC64() ? "E-p:64:64-f64:32:64-i64:32:64" |
| 108 | : "E-p:32:32-f64:32:64-i64:32:64"; |
Chris Lattner | 94de9a8 | 2006-06-16 01:37:27 +0000 | [diff] [blame] | 109 | } |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 110 | |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 111 | /// isPPC64 - Return true if we are generating code for 64-bit pointer mode. |
| 112 | /// |
| 113 | bool isPPC64() const { return IsPPC64; } |
| 114 | |
| 115 | /// has64BitSupport - Return true if the selected CPU supports 64-bit |
| 116 | /// instructions, regardless of whether we are in 32-bit or 64-bit mode. |
| 117 | bool has64BitSupport() const { return Has64BitSupport; } |
| 118 | |
| 119 | /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit |
| 120 | /// registers in 32-bit mode when possible. This can only true if |
| 121 | /// has64BitSupport() returns true. |
| 122 | bool use64BitRegs() const { return Use64BitRegs; } |
| 123 | |
Chris Lattner | 57fc62c | 2006-12-11 23:22:45 +0000 | [diff] [blame] | 124 | /// hasLazyResolverStub - Return true if accesses to the specified global have |
| 125 | /// to go through a dyld lazy resolution stub. This means that an extra load |
| 126 | /// is required to get the address of the global. |
| 127 | bool hasLazyResolverStub(const GlobalValue *GV) const; |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 128 | |
| 129 | // Specific obvious features. |
Chris Lattner | 1e9de3e | 2005-09-02 18:33:05 +0000 | [diff] [blame] | 130 | bool hasFSQRT() const { return HasFSQRT; } |
Chris Lattner | bf751e2 | 2006-02-28 07:08:22 +0000 | [diff] [blame] | 131 | bool hasSTFIWX() const { return HasSTFIWX; } |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 132 | bool hasAltivec() const { return HasAltivec; } |
Chris Lattner | 7c1fb5f | 2006-06-16 17:50:12 +0000 | [diff] [blame] | 133 | bool isGigaProcessor() const { return IsGigaProcessor; } |
Bill Wendling | cb90099 | 2007-01-16 09:29:17 +0000 | [diff] [blame] | 134 | |
Chris Lattner | 3c304a3 | 2005-08-05 22:05:03 +0000 | [diff] [blame] | 135 | bool isDarwin() const { return IsDarwin; } |
Bill Wendling | cb90099 | 2007-01-16 09:29:17 +0000 | [diff] [blame] | 136 | |
| 137 | unsigned getAsmFlavor() const { |
| 138 | return AsmFlavor != Unset ? unsigned(AsmFlavor) : 0; |
| 139 | } |
Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 140 | }; |
| 141 | } // End llvm namespace |
| 142 | |
| 143 | #endif |