1 //=====-- PPCSubtarget.h - Define Subtarget for the PPC -------*- C++ -*--====//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file declares the PowerPC specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #ifndef POWERPCSUBTARGET_H
15 #define POWERPCSUBTARGET_H
17 #include "llvm/Target/TargetInstrItineraries.h"
18 #include "llvm/Target/TargetSubtarget.h"
27 class PPCSubtarget : public TargetSubtarget {
29 const TargetMachine &TM;
31 /// stackAlignment - The minimum alignment known to hold of the stack frame on
32 /// entry to the function and which must be maintained by every function.
33 unsigned StackAlignment;
35 /// Selected instruction itineraries (one entry per itinerary class.)
36 InstrItineraryData InstrItins;
38 /// Used by the ISel to turn in optimizations for POWER4-derived architectures
47 bool HasLazyResolverStubs;
49 /// This constructor initializes the data members to match that
50 /// of the specified module.
52 PPCSubtarget(const TargetMachine &TM, const Module &M,
53 const std::string &FS, bool is64Bit);
55 /// ParseSubtargetFeatures - Parses features string setting specified
56 /// subtarget options. Definition of function is auto generated by tblgen.
57 void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
59 /// SetJITMode - This is called to inform the subtarget info that we are
60 /// producing code for the JIT.
63 /// getStackAlignment - Returns the minimum alignment known to hold of the
64 /// stack frame on entry to the function and which must be maintained by every
65 /// function for this subtarget.
66 unsigned getStackAlignment() const { return StackAlignment; }
68 /// getInstrItins - Return the instruction itineraies based on subtarget
70 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
72 /// getTargetDataString - Return the pointer size and type alignment
73 /// properties of this subtarget.
74 const char *getTargetDataString() const {
75 return isPPC64() ? "E-p:64:64-d:32-l:32" : "E-p:32:32-d:32-l:32";
78 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
80 bool isPPC64() const { return IsPPC64; }
82 /// has64BitSupport - Return true if the selected CPU supports 64-bit
83 /// instructions, regardless of whether we are in 32-bit or 64-bit mode.
84 bool has64BitSupport() const { return Has64BitSupport; }
86 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit
87 /// registers in 32-bit mode when possible. This can only true if
88 /// has64BitSupport() returns true.
89 bool use64BitRegs() const { return Use64BitRegs; }
91 /// hasLazyResolverStub - Return true if accesses to the specified global have
92 /// to go through a dyld lazy resolution stub. This means that an extra load
93 /// is required to get the address of the global.
94 bool hasLazyResolverStub(const GlobalValue *GV) const;
96 // Specific obvious features.
97 bool hasFSQRT() const { return HasFSQRT; }
98 bool hasSTFIWX() const { return HasSTFIWX; }
99 bool hasAltivec() const { return HasAltivec; }
100 bool isGigaProcessor() const { return IsGigaProcessor; }
102 bool isDarwin() const { return IsDarwin; }
104 } // End llvm namespace