blob: c89f922a5b653247d7c2551a65c84554288d3e50 [file] [log] [blame]
Nate Begeman6cca84e2005-10-16 05:39:50 +00001//=====-- PPCSubtarget.h - Define Subtarget for the PPC -------*- C++ -*--====//
Nate Begeman3bcfcd92005-08-04 07:12:09 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Nate Begeman3bcfcd92005-08-04 07:12:09 +00007//
8//===----------------------------------------------------------------------===//
9//
Evan Cheng0d639a22011-07-01 21:01:15 +000010// This file declares the PowerPC specific subclass of TargetSubtargetInfo.
Nate Begeman3bcfcd92005-08-04 07:12:09 +000011//
12//===----------------------------------------------------------------------===//
13
14#ifndef POWERPCSUBTARGET_H
15#define POWERPCSUBTARGET_H
16
Evan Cheng0d639a22011-07-01 21:01:15 +000017#include "llvm/Target/TargetSubtargetInfo.h"
Evan Cheng8264e272011-06-29 01:14:12 +000018#include "llvm/MC/MCInstrItineraries.h"
19#include "llvm/ADT/Triple.h"
Jim Laskey19058c32005-09-01 21:38:21 +000020#include <string>
21
Evan Cheng54b68e32011-07-01 20:45:01 +000022#define GET_SUBTARGETINFO_HEADER
Evan Chengc9c090d2011-07-01 22:36:09 +000023#include "PPCGenSubtargetInfo.inc"
Evan Cheng54b68e32011-07-01 20:45:01 +000024
Nick Lewycky28c5b862007-01-19 04:36:02 +000025// GCC #defines PPC on Linux but we use it as our namespace name
26#undef PPC
27
Nate Begeman3bcfcd92005-08-04 07:12:09 +000028namespace llvm {
Jim Laskey59e7a772006-12-12 20:57:08 +000029
30namespace PPC {
31 // -m directive values.
32 enum {
Dale Johannesen6ca3ccf2008-02-14 23:35:16 +000033 DIR_NONE,
Jim Laskey59e7a772006-12-12 20:57:08 +000034 DIR_32,
35 DIR_601,
36 DIR_602,
37 DIR_603,
38 DIR_7400,
39 DIR_750,
40 DIR_970,
41 DIR_64
42 };
43}
44
Chris Lattnerf4646a72006-12-11 23:22:45 +000045class GlobalValue;
46class TargetMachine;
47
Evan Cheng54b68e32011-07-01 20:45:01 +000048class PPCSubtarget : public PPCGenSubtargetInfo {
Nate Begeman3bcfcd92005-08-04 07:12:09 +000049protected:
50 /// 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 Lattner983a4152005-08-05 22:05:03 +000052 unsigned StackAlignment;
Jim Laskey802748c2005-11-01 20:06:59 +000053
54 /// Selected instruction itineraries (one entry per itinerary class.)
55 InstrItineraryData InstrItins;
Jim Laskey59e7a772006-12-12 20:57:08 +000056
57 /// Which cpu directive was used.
58 unsigned DarwinDirective;
Nate Begeman3bcfcd92005-08-04 07:12:09 +000059
60 /// Used by the ISel to turn in optimizations for POWER4-derived architectures
Chris Lattner983a4152005-08-05 22:05:03 +000061 bool IsGigaProcessor;
Chris Lattnera35f3062006-06-16 17:34:12 +000062 bool Has64BitSupport;
63 bool Use64BitRegs;
Chris Lattner16682ff2006-06-16 17:50:12 +000064 bool IsPPC64;
Jim Laskeya2b52352005-10-26 17:30:34 +000065 bool HasAltivec;
Chris Lattneraa3b1fc2005-09-02 18:33:05 +000066 bool HasFSQRT;
Chris Lattnerb9f35f02006-02-28 07:08:22 +000067 bool HasSTFIWX;
Chris Lattnerf4646a72006-12-11 23:22:45 +000068 bool HasLazyResolverStubs;
Torok Edwin31e90d22010-08-04 20:47:44 +000069 bool IsJITCodeModel;
Chris Lattnerdcbc0f32008-01-02 19:35:16 +000070
Daniel Dunbara37aab22011-04-19 20:54:28 +000071 /// TargetTriple - What processor and OS we're targeting.
72 Triple TargetTriple;
73
Nate Begeman3bcfcd92005-08-04 07:12:09 +000074public:
75 /// This constructor initializes the data members to match that
Daniel Dunbar31b44e82009-08-02 22:11:08 +000076 /// of the specified triple.
Nate Begeman3bcfcd92005-08-04 07:12:09 +000077 ///
Evan Chengfe6e4052011-06-30 01:53:36 +000078 PPCSubtarget(const std::string &TT, const std::string &CPU,
79 const std::string &FS, bool is64Bit);
Jim Laskeya2b52352005-10-26 17:30:34 +000080
81 /// ParseSubtargetFeatures - Parses features string setting specified
Jim Laskey75eab3c2005-10-26 18:07:50 +000082 /// subtarget options. Definition of function is auto generated by tblgen.
Evan Chengfe6e4052011-06-30 01:53:36 +000083 void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
Anton Korobeynikov08bf4c02009-05-23 19:50:50 +000084
Chris Lattnerf4646a72006-12-11 23:22:45 +000085
86 /// SetJITMode - This is called to inform the subtarget info that we are
87 /// producing code for the JIT.
88 void SetJITMode();
Nate Begeman3bcfcd92005-08-04 07:12:09 +000089
90 /// getStackAlignment - Returns the minimum alignment known to hold of the
91 /// stack frame on entry to the function and which must be maintained by every
92 /// function for this subtarget.
Chris Lattner983a4152005-08-05 22:05:03 +000093 unsigned getStackAlignment() const { return StackAlignment; }
Jim Laskey802748c2005-11-01 20:06:59 +000094
Jim Laskey59e7a772006-12-12 20:57:08 +000095 /// getDarwinDirective - Returns the -m directive specified for the cpu.
96 ///
97 unsigned getDarwinDirective() const { return DarwinDirective; }
98
Jim Laskey802748c2005-11-01 20:06:59 +000099 /// getInstrItins - Return the instruction itineraies based on subtarget
100 /// selection.
Chris Lattnerb1f31572006-12-11 21:42:55 +0000101 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
Chris Lattner16682ff2006-06-16 17:50:12 +0000102
103 /// getTargetDataString - Return the pointer size and type alignment
104 /// properties of this subtarget.
Chris Lattner0c4aa142006-06-16 01:37:27 +0000105 const char *getTargetDataString() const {
Dale Johannesen4609dbe2009-02-27 00:56:35 +0000106 // Note, the alignment values for f64 and i64 on ppc64 in Darwin
107 // documentation are wrong; these are correct (i.e. "what gcc does").
Chris Lattner87143482009-11-07 19:07:32 +0000108 return isPPC64() ? "E-p:64:64-f64:64:64-i64:64:64-f128:64:128-n32:64"
Roman Divacky075491f2011-07-03 16:24:07 +0000109 : "E-p:32:32-f64:64:64-i64:64:64-f128:64:128-n32";
Chris Lattner0c4aa142006-06-16 01:37:27 +0000110 }
Nate Begeman3bcfcd92005-08-04 07:12:09 +0000111
Chris Lattner16682ff2006-06-16 17:50:12 +0000112 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
113 ///
114 bool isPPC64() const { return IsPPC64; }
115
116 /// has64BitSupport - Return true if the selected CPU supports 64-bit
117 /// instructions, regardless of whether we are in 32-bit or 64-bit mode.
118 bool has64BitSupport() const { return Has64BitSupport; }
119
120 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit
121 /// registers in 32-bit mode when possible. This can only true if
122 /// has64BitSupport() returns true.
123 bool use64BitRegs() const { return Use64BitRegs; }
124
Chris Lattnerf4646a72006-12-11 23:22:45 +0000125 /// hasLazyResolverStub - Return true if accesses to the specified global have
126 /// to go through a dyld lazy resolution stub. This means that an extra load
127 /// is required to get the address of the global.
Daniel Dunbar31b44e82009-08-02 22:11:08 +0000128 bool hasLazyResolverStub(const GlobalValue *GV,
129 const TargetMachine &TM) const;
Chris Lattner16682ff2006-06-16 17:50:12 +0000130
Torok Edwin31e90d22010-08-04 20:47:44 +0000131 // isJITCodeModel - True if we're generating code for the JIT
132 bool isJITCodeModel() const { return IsJITCodeModel; }
133
Chris Lattner16682ff2006-06-16 17:50:12 +0000134 // Specific obvious features.
Chris Lattneraa3b1fc2005-09-02 18:33:05 +0000135 bool hasFSQRT() const { return HasFSQRT; }
Chris Lattnerb9f35f02006-02-28 07:08:22 +0000136 bool hasSTFIWX() const { return HasSTFIWX; }
Jim Laskeya2b52352005-10-26 17:30:34 +0000137 bool hasAltivec() const { return HasAltivec; }
Chris Lattner16682ff2006-06-16 17:50:12 +0000138 bool isGigaProcessor() const { return IsGigaProcessor; }
Bill Wendlingc7b2ab92007-01-16 09:29:17 +0000139
Daniel Dunbara37aab22011-04-19 20:54:28 +0000140 const Triple &getTargetTriple() const { return TargetTriple; }
141
Chris Lattnerdcbc0f32008-01-02 19:35:16 +0000142 /// isDarwin - True if this is any darwin platform.
Daniel Dunbarcd01ed52011-04-20 00:14:25 +0000143 bool isDarwin() const { return TargetTriple.isMacOSX(); }
Rafael Espindola770b4b82008-12-19 10:55:56 +0000144
Tilmann Schellerd1aaa322009-08-15 11:54:46 +0000145 bool isDarwinABI() const { return isDarwin(); }
146 bool isSVR4ABI() const { return !isDarwin(); }
147
Nate Begeman3bcfcd92005-08-04 07:12:09 +0000148};
149} // End llvm namespace
150
151#endif