blob: 63efe9e96361cd49c39321c538da7294b3c453d0 [file] [log] [blame]
Nate Begeman21e463b2005-10-16 05:39:50 +00001//=====-- PPCSubtarget.h - Define Subtarget for the PPC -------*- C++ -*--====//
Nate Begeman8c00f8c2005-08-04 07:12:09 +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//
Andrew Lenharth68fd4862005-09-29 21:11:57 +000010// This file declares the PowerPC specific subclass of TargetSubtarget.
Nate Begeman8c00f8c2005-08-04 07:12:09 +000011//
12//===----------------------------------------------------------------------===//
13
14#ifndef POWERPCSUBTARGET_H
15#define POWERPCSUBTARGET_H
16
Jim Laskey6cee6302005-11-01 20:06:59 +000017#include "llvm/Target/TargetInstrItineraries.h"
Nate Begeman8c00f8c2005-08-04 07:12:09 +000018#include "llvm/Target/TargetSubtarget.h"
19
Jim Laskeyb1e11802005-09-01 21:38:21 +000020#include <string>
21
Nate Begeman8c00f8c2005-08-04 07:12:09 +000022namespace llvm {
Jim Laskeyc35010d2006-12-12 20:57:08 +000023
24namespace PPC {
25 // -m directive values.
26 enum {
27 DIR_32,
28 DIR_601,
29 DIR_602,
30 DIR_603,
31 DIR_7400,
32 DIR_750,
33 DIR_970,
34 DIR_64
35 };
36}
37
Nate Begeman8c00f8c2005-08-04 07:12:09 +000038class Module;
Chris Lattner57fc62c2006-12-11 23:22:45 +000039class GlobalValue;
40class TargetMachine;
41
Nate Begeman8c00f8c2005-08-04 07:12:09 +000042class PPCSubtarget : public TargetSubtarget {
Bill Wendlingcb900992007-01-16 09:29:17 +000043public:
44 enum AsmWriterFlavorTy {
45 OldMnemonic, NewMnemonic, Unset
46 };
Nate Begeman8c00f8c2005-08-04 07:12:09 +000047protected:
Chris Lattner57fc62c2006-12-11 23:22:45 +000048 const TargetMachine &TM;
49
Nate Begeman8c00f8c2005-08-04 07:12:09 +000050 /// stackAlignment - The minimum alignment known to hold of the stack frame on
51 /// entry to the function and which must be maintained by every function.
Chris Lattner3c304a32005-08-05 22:05:03 +000052 unsigned StackAlignment;
Jim Laskey6cee6302005-11-01 20:06:59 +000053
54 /// Selected instruction itineraries (one entry per itinerary class.)
55 InstrItineraryData InstrItins;
Jim Laskeyc35010d2006-12-12 20:57:08 +000056
57 /// Which cpu directive was used.
58 unsigned DarwinDirective;
Nate Begeman8c00f8c2005-08-04 07:12:09 +000059
Bill Wendlingcb900992007-01-16 09:29:17 +000060 /// AsmFlavor - Which PPC asm dialect to use.
61 AsmWriterFlavorTy AsmFlavor;
62
Nate Begeman8c00f8c2005-08-04 07:12:09 +000063 /// 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;
Chris Lattner3c304a32005-08-05 22:05:03 +000071 bool IsDarwin;
Chris Lattner57fc62c2006-12-11 23:22:45 +000072 bool HasLazyResolverStubs;
Nate Begeman8c00f8c2005-08-04 07:12:09 +000073public:
74 /// This constructor initializes the data members to match that
75 /// of the specified module.
76 ///
Chris Lattner57fc62c2006-12-11 23:22:45 +000077 PPCSubtarget(const TargetMachine &TM, const Module &M,
78 const std::string &FS, bool is64Bit);
Jim Laskey581a8f72005-10-26 17:30:34 +000079
80 /// ParseSubtargetFeatures - Parses features string setting specified
Jim Laskey2cbc2072005-10-26 18:07:50 +000081 /// subtarget options. Definition of function is auto generated by tblgen.
Jim Laskey581a8f72005-10-26 17:30:34 +000082 void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
Chris Lattner57fc62c2006-12-11 23:22:45 +000083
84 /// SetJITMode - This is called to inform the subtarget info that we are
85 /// producing code for the JIT.
86 void SetJITMode();
Nate Begeman8c00f8c2005-08-04 07:12:09 +000087
88 /// getStackAlignment - Returns the minimum alignment known to hold of the
89 /// stack frame on entry to the function and which must be maintained by every
90 /// function for this subtarget.
Chris Lattner3c304a32005-08-05 22:05:03 +000091 unsigned getStackAlignment() const { return StackAlignment; }
Jim Laskey6cee6302005-11-01 20:06:59 +000092
Jim Laskeyc35010d2006-12-12 20:57:08 +000093 /// getDarwinDirective - Returns the -m directive specified for the cpu.
94 ///
95 unsigned getDarwinDirective() const { return DarwinDirective; }
96
Jim Laskey6cee6302005-11-01 20:06:59 +000097 /// getInstrItins - Return the instruction itineraies based on subtarget
98 /// selection.
Chris Lattner442b9a62006-12-11 21:42:55 +000099 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
Chris Lattner7c1fb5f2006-06-16 17:50:12 +0000100
101 /// getTargetDataString - Return the pointer size and type alignment
102 /// properties of this subtarget.
Chris Lattner94de9a82006-06-16 01:37:27 +0000103 const char *getTargetDataString() const {
Chris Lattner7c1fb5f2006-06-16 17:50:12 +0000104 return isPPC64() ? "E-p:64:64-d:32-l:32" : "E-p:32:32-d:32-l:32";
Chris Lattner94de9a82006-06-16 01:37:27 +0000105 }
Nate Begeman8c00f8c2005-08-04 07:12:09 +0000106
Chris Lattner7c1fb5f2006-06-16 17:50:12 +0000107 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
108 ///
109 bool isPPC64() const { return IsPPC64; }
110
111 /// has64BitSupport - Return true if the selected CPU supports 64-bit
112 /// instructions, regardless of whether we are in 32-bit or 64-bit mode.
113 bool has64BitSupport() const { return Has64BitSupport; }
114
115 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit
116 /// registers in 32-bit mode when possible. This can only true if
117 /// has64BitSupport() returns true.
118 bool use64BitRegs() const { return Use64BitRegs; }
119
Chris Lattner57fc62c2006-12-11 23:22:45 +0000120 /// hasLazyResolverStub - Return true if accesses to the specified global have
121 /// to go through a dyld lazy resolution stub. This means that an extra load
122 /// is required to get the address of the global.
123 bool hasLazyResolverStub(const GlobalValue *GV) const;
Chris Lattner7c1fb5f2006-06-16 17:50:12 +0000124
125 // Specific obvious features.
Chris Lattner1e9de3e2005-09-02 18:33:05 +0000126 bool hasFSQRT() const { return HasFSQRT; }
Chris Lattnerbf751e22006-02-28 07:08:22 +0000127 bool hasSTFIWX() const { return HasSTFIWX; }
Jim Laskey581a8f72005-10-26 17:30:34 +0000128 bool hasAltivec() const { return HasAltivec; }
Chris Lattner7c1fb5f2006-06-16 17:50:12 +0000129 bool isGigaProcessor() const { return IsGigaProcessor; }
Bill Wendlingcb900992007-01-16 09:29:17 +0000130
Chris Lattner3c304a32005-08-05 22:05:03 +0000131 bool isDarwin() const { return IsDarwin; }
Bill Wendlingcb900992007-01-16 09:29:17 +0000132
133 unsigned getAsmFlavor() const {
134 return AsmFlavor != Unset ? unsigned(AsmFlavor) : 0;
135 }
Nate Begeman8c00f8c2005-08-04 07:12:09 +0000136};
137} // End llvm namespace
138
139#endif