blob: 2c5c6bac7cdb6ab29a5485c80f51ef309b9e3d05 [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 {
23class Module;
24
25class PPCSubtarget : public TargetSubtarget {
26protected:
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.
Chris Lattner3c304a32005-08-05 22:05:03 +000029 unsigned StackAlignment;
Jim Laskey6cee6302005-11-01 20:06:59 +000030
31 /// Selected instruction itineraries (one entry per itinerary class.)
32 InstrItineraryData InstrItins;
Nate Begeman8c00f8c2005-08-04 07:12:09 +000033
34 /// Used by the ISel to turn in optimizations for POWER4-derived architectures
Chris Lattner3c304a32005-08-05 22:05:03 +000035 bool IsGigaProcessor;
Chris Lattnera7a58542006-06-16 17:34:12 +000036 bool Has64BitSupport;
37 bool Use64BitRegs;
Chris Lattner7c1fb5f2006-06-16 17:50:12 +000038 bool IsPPC64;
Jim Laskey581a8f72005-10-26 17:30:34 +000039 bool HasAltivec;
Chris Lattner1e9de3e2005-09-02 18:33:05 +000040 bool HasFSQRT;
Chris Lattnerbf751e22006-02-28 07:08:22 +000041 bool HasSTFIWX;
Chris Lattner3c304a32005-08-05 22:05:03 +000042 bool IsAIX;
43 bool IsDarwin;
Nate Begeman8c00f8c2005-08-04 07:12:09 +000044public:
45 /// This constructor initializes the data members to match that
46 /// of the specified module.
47 ///
Chris Lattner94de9a82006-06-16 01:37:27 +000048 PPCSubtarget(const Module &M, const std::string &FS, bool is64Bit);
Jim Laskey581a8f72005-10-26 17:30:34 +000049
50 /// ParseSubtargetFeatures - Parses features string setting specified
Jim Laskey2cbc2072005-10-26 18:07:50 +000051 /// subtarget options. Definition of function is auto generated by tblgen.
Jim Laskey581a8f72005-10-26 17:30:34 +000052 void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
Nate Begeman8c00f8c2005-08-04 07:12:09 +000053
54 /// getStackAlignment - Returns the minimum alignment known to hold of the
55 /// stack frame on entry to the function and which must be maintained by every
56 /// function for this subtarget.
Chris Lattner3c304a32005-08-05 22:05:03 +000057 unsigned getStackAlignment() const { return StackAlignment; }
Jim Laskey6cee6302005-11-01 20:06:59 +000058
59 /// getInstrItins - Return the instruction itineraies based on subtarget
60 /// selection.
61 const InstrItineraryData getInstrItineraryData() const { return InstrItins; }
Chris Lattner7c1fb5f2006-06-16 17:50:12 +000062
63 /// getTargetDataString - Return the pointer size and type alignment
64 /// properties of this subtarget.
Chris Lattner94de9a82006-06-16 01:37:27 +000065 const char *getTargetDataString() const {
Chris Lattner7c1fb5f2006-06-16 17:50:12 +000066 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 +000067 }
Nate Begeman8c00f8c2005-08-04 07:12:09 +000068
Chris Lattner7c1fb5f2006-06-16 17:50:12 +000069 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
70 ///
71 bool isPPC64() const { return IsPPC64; }
72
73 /// has64BitSupport - Return true if the selected CPU supports 64-bit
74 /// instructions, regardless of whether we are in 32-bit or 64-bit mode.
75 bool has64BitSupport() const { return Has64BitSupport; }
76
77 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit
78 /// registers in 32-bit mode when possible. This can only true if
79 /// has64BitSupport() returns true.
80 bool use64BitRegs() const { return Use64BitRegs; }
81
82
83 // Specific obvious features.
Chris Lattner1e9de3e2005-09-02 18:33:05 +000084 bool hasFSQRT() const { return HasFSQRT; }
Chris Lattnerbf751e22006-02-28 07:08:22 +000085 bool hasSTFIWX() const { return HasSTFIWX; }
Jim Laskey581a8f72005-10-26 17:30:34 +000086 bool hasAltivec() const { return HasAltivec; }
Chris Lattner7c1fb5f2006-06-16 17:50:12 +000087 bool isGigaProcessor() const { return IsGigaProcessor; }
Chris Lattner1e9de3e2005-09-02 18:33:05 +000088
Chris Lattner3c304a32005-08-05 22:05:03 +000089 bool isAIX() const { return IsAIX; }
90 bool isDarwin() const { return IsDarwin; }
Nate Begeman8c00f8c2005-08-04 07:12:09 +000091};
92} // End llvm namespace
93
94#endif