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"
25 class PPCSubtarget : public TargetSubtarget {
27 /// stackAlignment - The minimum alignment known to hold of the stack frame on
28 /// entry to the function and which must be maintained by every function.
29 unsigned StackAlignment;
31 /// Selected instruction itineraries (one entry per itinerary class.)
32 InstrItineraryData InstrItins;
34 /// Used by the ISel to turn in optimizations for POWER4-derived architectures
44 /// This constructor initializes the data members to match that
45 /// of the specified module.
47 PPCSubtarget(const Module &M, const std::string &FS, bool is64Bit);
49 /// ParseSubtargetFeatures - Parses features string setting specified
50 /// subtarget options. Definition of function is auto generated by tblgen.
51 void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
53 /// getStackAlignment - Returns the minimum alignment known to hold of the
54 /// stack frame on entry to the function and which must be maintained by every
55 /// function for this subtarget.
56 unsigned getStackAlignment() const { return StackAlignment; }
58 /// getInstrItins - Return the instruction itineraies based on subtarget
60 const InstrItineraryData getInstrItineraryData() const { return InstrItins; }
62 /// getTargetDataString - Return the pointer size and type alignment
63 /// properties of this subtarget.
64 const char *getTargetDataString() const {
65 return isPPC64() ? "E-p:64:64-d:32-l:32" : "E-p:32:32-d:32-l:32";
68 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
70 bool isPPC64() const { return IsPPC64; }
72 /// has64BitSupport - Return true if the selected CPU supports 64-bit
73 /// instructions, regardless of whether we are in 32-bit or 64-bit mode.
74 bool has64BitSupport() const { return Has64BitSupport; }
76 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit
77 /// registers in 32-bit mode when possible. This can only true if
78 /// has64BitSupport() returns true.
79 bool use64BitRegs() const { return Use64BitRegs; }
82 // Specific obvious features.
83 bool hasFSQRT() const { return HasFSQRT; }
84 bool hasSTFIWX() const { return HasSTFIWX; }
85 bool hasAltivec() const { return HasAltivec; }
86 bool isGigaProcessor() const { return IsGigaProcessor; }
88 bool isDarwin() const { return IsDarwin; }
90 } // End llvm namespace