LLVM API Documentation

PPCSubtarget.h

Go to the documentation of this file.
00001 //=====-- PPCSubtarget.h - Define Subtarget for the PPC -------*- C++ -*--====//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by Nate Begeman and is distributed under the
00006 // University of Illinois Open Source License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file declares the PowerPC specific subclass of TargetSubtarget.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef POWERPCSUBTARGET_H
00015 #define POWERPCSUBTARGET_H
00016 
00017 #include "llvm/Target/TargetInstrItineraries.h"
00018 #include "llvm/Target/TargetSubtarget.h"
00019 
00020 #include <string>
00021 
00022 namespace llvm {
00023 class Module;
00024 
00025 class PPCSubtarget : public TargetSubtarget {
00026 protected:
00027   /// stackAlignment - The minimum alignment known to hold of the stack frame on
00028   /// entry to the function and which must be maintained by every function.
00029   unsigned StackAlignment;
00030   
00031   /// Selected instruction itineraries (one entry per itinerary class.)
00032   InstrItineraryData InstrItins;
00033 
00034   /// Used by the ISel to turn in optimizations for POWER4-derived architectures
00035   bool IsGigaProcessor;
00036   bool Has64BitSupport;
00037   bool Use64BitRegs;
00038   bool IsPPC64;
00039   bool HasAltivec;
00040   bool HasFSQRT;
00041   bool HasSTFIWX;
00042   bool IsDarwin;
00043 public:
00044   /// This constructor initializes the data members to match that
00045   /// of the specified module.
00046   ///
00047   PPCSubtarget(const Module &M, const std::string &FS, bool is64Bit);
00048   
00049   /// ParseSubtargetFeatures - Parses features string setting specified 
00050   /// subtarget options.  Definition of function is auto generated by tblgen.
00051   void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
00052 
00053   /// getStackAlignment - Returns the minimum alignment known to hold of the
00054   /// stack frame on entry to the function and which must be maintained by every
00055   /// function for this subtarget.
00056   unsigned getStackAlignment() const { return StackAlignment; }
00057   
00058   /// getInstrItins - Return the instruction itineraies based on subtarget 
00059   /// selection.
00060   const InstrItineraryData getInstrItineraryData() const { return InstrItins; }
00061 
00062   /// getTargetDataString - Return the pointer size and type alignment
00063   /// properties of this subtarget.
00064   const char *getTargetDataString() const {
00065     return isPPC64() ? "E-p:64:64-d:32-l:32" : "E-p:32:32-d:32-l:32";
00066   }
00067 
00068   /// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
00069   ///
00070   bool isPPC64() const { return IsPPC64; }
00071   
00072   /// has64BitSupport - Return true if the selected CPU supports 64-bit
00073   /// instructions, regardless of whether we are in 32-bit or 64-bit mode.
00074   bool has64BitSupport() const { return Has64BitSupport; }
00075   
00076   /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit
00077   /// registers in 32-bit mode when possible.  This can only true if
00078   /// has64BitSupport() returns true.
00079   bool use64BitRegs() const { return Use64BitRegs; }
00080   
00081   
00082   // Specific obvious features.
00083   bool hasFSQRT() const { return HasFSQRT; }
00084   bool hasSTFIWX() const { return HasSTFIWX; }
00085   bool hasAltivec() const { return HasAltivec; }
00086   bool isGigaProcessor() const { return IsGigaProcessor; }
00087   
00088   bool isDarwin() const { return IsDarwin; }
00089 };
00090 } // End llvm namespace
00091 
00092 #endif