blob: 649ffc1abeaaf6b7da6bdf77c1aa4939e1576096 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- PPC.td - Describe the PowerPC Target Machine -------*- tablegen -*-===//
2//
Chris Lattner0921e3b2005-10-14 23:37:35 +00003// 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.
Jia Liub22310f2012-02-18 12:03:15 +00007//
Chris Lattner0921e3b2005-10-14 23:37:35 +00008//===----------------------------------------------------------------------===//
9//
10// This is the top level entry point for the PowerPC target.
11//
12//===----------------------------------------------------------------------===//
13
14// Get the target-independent interfaces which we are implementing.
15//
Evan Cheng977e7be2008-11-24 07:34:46 +000016include "llvm/Target/Target.td"
Chris Lattner0921e3b2005-10-14 23:37:35 +000017
18//===----------------------------------------------------------------------===//
Jim Laskey13a19452005-10-22 08:04:24 +000019// PowerPC Subtarget features.
Jim Laskey74ab9962005-10-19 19:51:16 +000020//
21
Jim Laskey59e7a772006-12-12 20:57:08 +000022//===----------------------------------------------------------------------===//
23// CPU Directives //
24//===----------------------------------------------------------------------===//
25
Hal Finkel6fa56972011-10-17 04:03:49 +000026def Directive440 : SubtargetFeature<"", "DarwinDirective", "PPC::DIR_440", "">;
Jim Laskey59e7a772006-12-12 20:57:08 +000027def Directive601 : SubtargetFeature<"", "DarwinDirective", "PPC::DIR_601", "">;
28def Directive602 : SubtargetFeature<"", "DarwinDirective", "PPC::DIR_602", "">;
29def Directive603 : SubtargetFeature<"", "DarwinDirective", "PPC::DIR_603", "">;
30def Directive604 : SubtargetFeature<"", "DarwinDirective", "PPC::DIR_603", "">;
31def Directive620 : SubtargetFeature<"", "DarwinDirective", "PPC::DIR_603", "">;
32def Directive7400: SubtargetFeature<"", "DarwinDirective", "PPC::DIR_7400", "">;
33def Directive750 : SubtargetFeature<"", "DarwinDirective", "PPC::DIR_750", "">;
34def Directive970 : SubtargetFeature<"", "DarwinDirective", "PPC::DIR_970", "">;
35def Directive32 : SubtargetFeature<"", "DarwinDirective", "PPC::DIR_32", "">;
36def Directive64 : SubtargetFeature<"", "DarwinDirective", "PPC::DIR_64", "">;
Hal Finkel9f9f8922012-04-01 19:22:40 +000037def DirectiveA2 : SubtargetFeature<"", "DarwinDirective", "PPC::DIR_A2", "">;
Hal Finkel742b5352012-08-28 16:12:39 +000038def DirectiveE500mc : SubtargetFeature<"", "DarwinDirective",
39 "PPC::DIR_E500mc", "">;
40def DirectiveE5500 : SubtargetFeature<"", "DarwinDirective",
41 "PPC::DIR_E5500", "">;
Bill Schmidt52742c22013-02-01 22:59:51 +000042def DirectivePwr3: SubtargetFeature<"", "DarwinDirective", "PPC::DIR_PWR3", "">;
43def DirectivePwr4: SubtargetFeature<"", "DarwinDirective", "PPC::DIR_PWR4", "">;
44def DirectivePwr5: SubtargetFeature<"", "DarwinDirective", "PPC::DIR_PWR5", "">;
45def DirectivePwr5x: SubtargetFeature<"", "DarwinDirective", "PPC::DIR_PWR5X", "">;
Hal Finkelf2b9c382012-06-11 15:43:08 +000046def DirectivePwr6: SubtargetFeature<"", "DarwinDirective", "PPC::DIR_PWR6", "">;
Bill Schmidt52742c22013-02-01 22:59:51 +000047def DirectivePwr6x: SubtargetFeature<"", "DarwinDirective", "PPC::DIR_PWR6X", "">;
Hal Finkelf2b9c382012-06-11 15:43:08 +000048def DirectivePwr7: SubtargetFeature<"", "DarwinDirective", "PPC::DIR_PWR7", "">;
Jim Laskey59e7a772006-12-12 20:57:08 +000049
Chris Lattnera35f3062006-06-16 17:34:12 +000050def Feature64Bit : SubtargetFeature<"64bit","Has64BitSupport", "true",
Chris Lattner0d4923b2005-10-23 05:28:51 +000051 "Enable 64-bit instructions">;
Chris Lattnera35f3062006-06-16 17:34:12 +000052def Feature64BitRegs : SubtargetFeature<"64bitregs","Use64BitRegs", "true",
53 "Enable 64-bit registers usage for ppc32 [beta]">;
Evan Chengd98701c2006-01-27 08:09:42 +000054def FeatureAltivec : SubtargetFeature<"altivec","HasAltivec", "true",
Chris Lattner0d4923b2005-10-23 05:28:51 +000055 "Enable Altivec instructions">;
Hal Finkelbfd3d082012-06-11 19:57:01 +000056def FeatureMFOCRF : SubtargetFeature<"mfocrf","HasMFOCRF", "true",
57 "Enable the MFOCRF instruction">;
Evan Chengd98701c2006-01-27 08:09:42 +000058def FeatureFSqrt : SubtargetFeature<"fsqrt","HasFSQRT", "true",
Hal Finkel49033792011-10-14 18:54:13 +000059 "Enable the fsqrt instruction">;
Hal Finkel2e103312013-04-03 04:01:11 +000060def FeatureFRE : SubtargetFeature<"fre", "HasFRE", "true",
61 "Enable the fre instruction">;
62def FeatureFRES : SubtargetFeature<"fres", "HasFRES", "true",
63 "Enable the fres instruction">;
64def FeatureFRSQRTE : SubtargetFeature<"frsqrte", "HasFRSQRTE", "true",
65 "Enable the frsqrte instruction">;
66def FeatureFRSQRTES : SubtargetFeature<"frsqrtes", "HasFRSQRTES", "true",
67 "Enable the frsqrtes instruction">;
68def FeatureRecipPrec : SubtargetFeature<"recipprec", "HasRecipPrec", "true",
69 "Assume higher precision reciprocal estimates">;
Chris Lattnerb9f35f02006-02-28 07:08:22 +000070def FeatureSTFIWX : SubtargetFeature<"stfiwx","HasSTFIWX", "true",
Hal Finkel49033792011-10-14 18:54:13 +000071 "Enable the stfiwx instruction">;
Hal Finkelbeb296b2013-03-31 10:12:51 +000072def FeatureLFIWAX : SubtargetFeature<"lfiwax","HasLFIWAX", "true",
73 "Enable the lfiwax instruction">;
Hal Finkelc20a08d2013-03-29 08:57:48 +000074def FeatureFPRND : SubtargetFeature<"fprnd", "HasFPRND", "true",
75 "Enable the fri[mnpz] instructions">;
Hal Finkelf6d45f22013-04-01 17:52:07 +000076def FeatureFPCVT : SubtargetFeature<"fpcvt", "HasFPCVT", "true",
77 "Enable fc[ft]* (unsigned and single-precision) and lfiwzx instructions">;
Hal Finkel460e94d2012-06-22 23:10:08 +000078def FeatureISEL : SubtargetFeature<"isel","HasISEL", "true",
79 "Enable the isel instruction">;
Hal Finkela4d07482013-03-28 13:29:47 +000080def FeaturePOPCNTD : SubtargetFeature<"popcntd","HasPOPCNTD", "true",
81 "Enable the popcnt[dw] instructions">;
Hal Finkel31d29562013-03-28 19:25:55 +000082def FeatureLDBRX : SubtargetFeature<"ldbrx","HasLDBRX", "true",
83 "Enable the ldbrx instruction">;
Hal Finkel6fa56972011-10-17 04:03:49 +000084def FeatureBookE : SubtargetFeature<"booke", "IsBookE", "true",
85 "Enable Book E instructions">;
Hal Finkelefb305e2013-01-30 21:17:42 +000086def FeatureQPX : SubtargetFeature<"qpx","HasQPX", "true",
87 "Enable QPX instructions">;
Jim Laskey74ab9962005-10-19 19:51:16 +000088
Bill Schmidtcc99a2f2013-02-01 23:10:09 +000089// Note: Future features to add when support is extended to more
90// recent ISA levels:
91//
92// CMPB p6, p6x, p7 cmpb
93// DFP p6, p6x, p7 decimal floating-point instructions
Bill Schmidtcc99a2f2013-02-01 23:10:09 +000094// POPCNTB p5 through p7 popcntb and related instructions
Bill Schmidtcc99a2f2013-02-01 23:10:09 +000095// VSX p7 vector-scalar instruction set
96
Jim Laskey74ab9962005-10-19 19:51:16 +000097//===----------------------------------------------------------------------===//
Hal Finkel654d43b2013-04-12 02:18:09 +000098// Classes used for relation maps.
99//===----------------------------------------------------------------------===//
100// RecFormRel - Filter class used to relate non-record-form instructions with
101// their record-form variants.
102class RecFormRel;
103
104//===----------------------------------------------------------------------===//
105// Relation Map Definitions.
106//===----------------------------------------------------------------------===//
107
108def getRecordFormOpcode : InstrMapping {
109 let FilterClass = "RecFormRel";
110 // Instructions with the same BaseName and Interpretation64Bit values
111 // form a row.
112 let RowFields = ["BaseName", "Interpretation64Bit"];
113 // Instructions with the same RC value form a column.
114 let ColFields = ["RC"];
115 // The key column are the non-record-form instructions.
116 let KeyCol = ["0"];
117 // Value columns RC=1
118 let ValueCols = [["1"]];
119}
120
121def getNonRecordFormOpcode : InstrMapping {
122 let FilterClass = "RecFormRel";
123 // Instructions with the same BaseName and Interpretation64Bit values
124 // form a row.
125 let RowFields = ["BaseName", "Interpretation64Bit"];
126 // Instructions with the same RC value form a column.
127 let ColFields = ["RC"];
128 // The key column are the record-form instructions.
129 let KeyCol = ["1"];
130 // Value columns are RC=0
131 let ValueCols = [["0"]];
132}
133
134//===----------------------------------------------------------------------===//
Chris Lattnera389f0d2005-10-23 22:08:13 +0000135// Register File Description
136//===----------------------------------------------------------------------===//
137
138include "PPCRegisterInfo.td"
139include "PPCSchedule.td"
140include "PPCInstrInfo.td"
141
142//===----------------------------------------------------------------------===//
143// PowerPC processors supported.
Jim Laskey74ab9962005-10-19 19:51:16 +0000144//
145
Jim Laskey59e7a772006-12-12 20:57:08 +0000146def : Processor<"generic", G3Itineraries, [Directive32]>;
Hal Finkel460e94d2012-06-22 23:10:08 +0000147def : Processor<"440", PPC440Itineraries, [Directive440, FeatureISEL,
Hal Finkel2e103312013-04-03 04:01:11 +0000148 FeatureFRES, FeatureFRSQRTE,
Hal Finkel460e94d2012-06-22 23:10:08 +0000149 FeatureBookE]>;
150def : Processor<"450", PPC440Itineraries, [Directive440, FeatureISEL,
Hal Finkel2e103312013-04-03 04:01:11 +0000151 FeatureFRES, FeatureFRSQRTE,
Hal Finkel460e94d2012-06-22 23:10:08 +0000152 FeatureBookE]>;
Jim Laskey59e7a772006-12-12 20:57:08 +0000153def : Processor<"601", G3Itineraries, [Directive601]>;
154def : Processor<"602", G3Itineraries, [Directive602]>;
Hal Finkel2e103312013-04-03 04:01:11 +0000155def : Processor<"603", G3Itineraries, [Directive603,
156 FeatureFRES, FeatureFRSQRTE]>;
157def : Processor<"603e", G3Itineraries, [Directive603,
158 FeatureFRES, FeatureFRSQRTE]>;
159def : Processor<"603ev", G3Itineraries, [Directive603,
160 FeatureFRES, FeatureFRSQRTE]>;
161def : Processor<"604", G3Itineraries, [Directive604,
162 FeatureFRES, FeatureFRSQRTE]>;
163def : Processor<"604e", G3Itineraries, [Directive604,
164 FeatureFRES, FeatureFRSQRTE]>;
165def : Processor<"620", G3Itineraries, [Directive620,
166 FeatureFRES, FeatureFRSQRTE]>;
167def : Processor<"750", G4Itineraries, [Directive750,
168 FeatureFRES, FeatureFRSQRTE]>;
169def : Processor<"g3", G3Itineraries, [Directive750,
170 FeatureFRES, FeatureFRSQRTE]>;
171def : Processor<"7400", G4Itineraries, [Directive7400, FeatureAltivec,
172 FeatureFRES, FeatureFRSQRTE]>;
173def : Processor<"g4", G4Itineraries, [Directive7400, FeatureAltivec,
174 FeatureFRES, FeatureFRSQRTE]>;
175def : Processor<"7450", G4PlusItineraries, [Directive7400, FeatureAltivec,
176 FeatureFRES, FeatureFRSQRTE]>;
177def : Processor<"g4+", G4PlusItineraries, [Directive7400, FeatureAltivec,
178 FeatureFRES, FeatureFRSQRTE]>;
Hal Finkel1a958cf2013-04-05 05:49:18 +0000179def : ProcessorModel<"970", G5Model,
Jim Laskey59e7a772006-12-12 20:57:08 +0000180 [Directive970, FeatureAltivec,
Hal Finkel2e103312013-04-03 04:01:11 +0000181 FeatureMFOCRF, FeatureFSqrt,
182 FeatureFRES, FeatureFRSQRTE, FeatureSTFIWX,
Jim Laskey13a19452005-10-22 08:04:24 +0000183 Feature64Bit /*, Feature64BitRegs */]>;
Hal Finkel1a958cf2013-04-05 05:49:18 +0000184def : ProcessorModel<"g5", G5Model,
Jim Laskey59e7a772006-12-12 20:57:08 +0000185 [Directive970, FeatureAltivec,
Hal Finkelbfd3d082012-06-11 19:57:01 +0000186 FeatureMFOCRF, FeatureFSqrt, FeatureSTFIWX,
Hal Finkel2e103312013-04-03 04:01:11 +0000187 FeatureFRES, FeatureFRSQRTE,
Jim Laskey59e7a772006-12-12 20:57:08 +0000188 Feature64Bit /*, Feature64BitRegs */]>;
Hal Finkel742b5352012-08-28 16:12:39 +0000189def : ProcessorModel<"e500mc", PPCE500mcModel,
190 [DirectiveE500mc, FeatureMFOCRF,
191 FeatureSTFIWX, FeatureBookE, FeatureISEL]>;
192def : ProcessorModel<"e5500", PPCE5500Model,
193 [DirectiveE5500, FeatureMFOCRF, Feature64Bit,
194 FeatureSTFIWX, FeatureBookE, FeatureISEL]>;
Hal Finkel5fde1b02013-04-05 05:34:08 +0000195def : ProcessorModel<"a2", PPCA2Model,
Hal Finkel31d29562013-03-28 19:25:55 +0000196 [DirectiveA2, FeatureBookE, FeatureMFOCRF,
Hal Finkel2e103312013-04-03 04:01:11 +0000197 FeatureFSqrt, FeatureFRE, FeatureFRES,
198 FeatureFRSQRTE, FeatureFRSQRTES, FeatureRecipPrec,
199 FeatureSTFIWX, FeatureLFIWAX,
Hal Finkelf6d45f22013-04-01 17:52:07 +0000200 FeatureFPRND, FeatureFPCVT, FeatureISEL,
201 FeaturePOPCNTD, FeatureLDBRX, Feature64Bit
202 /*, Feature64BitRegs */]>;
Hal Finkel5fde1b02013-04-05 05:34:08 +0000203def : ProcessorModel<"a2q", PPCA2Model,
Hal Finkel31d29562013-03-28 19:25:55 +0000204 [DirectiveA2, FeatureBookE, FeatureMFOCRF,
Hal Finkel2e103312013-04-03 04:01:11 +0000205 FeatureFSqrt, FeatureFRE, FeatureFRES,
206 FeatureFRSQRTE, FeatureFRSQRTES, FeatureRecipPrec,
207 FeatureSTFIWX, FeatureLFIWAX,
Hal Finkelf6d45f22013-04-01 17:52:07 +0000208 FeatureFPRND, FeatureFPCVT, FeatureISEL,
209 FeaturePOPCNTD, FeatureLDBRX, Feature64Bit
210 /*, Feature64BitRegs */, FeatureQPX]>;
Hal Finkel1a958cf2013-04-05 05:49:18 +0000211def : ProcessorModel<"pwr3", G5Model,
Hal Finkel2e103312013-04-03 04:01:11 +0000212 [DirectivePwr3, FeatureAltivec,
213 FeatureFRES, FeatureFRSQRTE, FeatureMFOCRF,
Bill Schmidt52742c22013-02-01 22:59:51 +0000214 FeatureSTFIWX, Feature64Bit]>;
Hal Finkel1a958cf2013-04-05 05:49:18 +0000215def : ProcessorModel<"pwr4", G5Model,
Bill Schmidt52742c22013-02-01 22:59:51 +0000216 [DirectivePwr4, FeatureAltivec, FeatureMFOCRF,
Hal Finkel2e103312013-04-03 04:01:11 +0000217 FeatureFSqrt, FeatureFRES, FeatureFRSQRTE,
218 FeatureSTFIWX, Feature64Bit]>;
Hal Finkel1a958cf2013-04-05 05:49:18 +0000219def : ProcessorModel<"pwr5", G5Model,
Bill Schmidt52742c22013-02-01 22:59:51 +0000220 [DirectivePwr5, FeatureAltivec, FeatureMFOCRF,
Hal Finkel2e103312013-04-03 04:01:11 +0000221 FeatureFSqrt, FeatureFRE, FeatureFRES,
222 FeatureFRSQRTE, FeatureFRSQRTES,
223 FeatureSTFIWX, Feature64Bit]>;
Hal Finkel1a958cf2013-04-05 05:49:18 +0000224def : ProcessorModel<"pwr5x", G5Model,
Bill Schmidt52742c22013-02-01 22:59:51 +0000225 [DirectivePwr5x, FeatureAltivec, FeatureMFOCRF,
Hal Finkel2e103312013-04-03 04:01:11 +0000226 FeatureFSqrt, FeatureFRE, FeatureFRES,
227 FeatureFRSQRTE, FeatureFRSQRTES,
228 FeatureSTFIWX, FeatureFPRND, Feature64Bit]>;
Hal Finkel1a958cf2013-04-05 05:49:18 +0000229def : ProcessorModel<"pwr6", G5Model,
Hal Finkelf2b9c382012-06-11 15:43:08 +0000230 [DirectivePwr6, FeatureAltivec,
Hal Finkel2e103312013-04-03 04:01:11 +0000231 FeatureMFOCRF, FeatureFSqrt, FeatureFRE,
232 FeatureFRES, FeatureFRSQRTE, FeatureFRSQRTES,
233 FeatureRecipPrec, FeatureSTFIWX, FeatureLFIWAX,
234 FeatureFPRND, Feature64Bit /*, Feature64BitRegs */]>;
Hal Finkel1a958cf2013-04-05 05:49:18 +0000235def : ProcessorModel<"pwr6x", G5Model,
Bill Schmidt52742c22013-02-01 22:59:51 +0000236 [DirectivePwr5x, FeatureAltivec, FeatureMFOCRF,
Hal Finkel2e103312013-04-03 04:01:11 +0000237 FeatureFSqrt, FeatureFRE, FeatureFRES,
238 FeatureFRSQRTE, FeatureFRSQRTES, FeatureRecipPrec,
239 FeatureSTFIWX, FeatureLFIWAX,
Hal Finkelbeb296b2013-03-31 10:12:51 +0000240 FeatureFPRND, Feature64Bit]>;
Hal Finkel1a958cf2013-04-05 05:49:18 +0000241def : ProcessorModel<"pwr7", G5Model,
Hal Finkelf2b9c382012-06-11 15:43:08 +0000242 [DirectivePwr7, FeatureAltivec,
Hal Finkel2e103312013-04-03 04:01:11 +0000243 FeatureMFOCRF, FeatureFSqrt, FeatureFRE,
244 FeatureFRES, FeatureFRSQRTE, FeatureFRSQRTES,
245 FeatureRecipPrec, FeatureSTFIWX, FeatureLFIWAX,
246 FeatureFPRND, FeatureFPCVT, FeatureISEL,
247 FeaturePOPCNTD, FeatureLDBRX,
Hal Finkelf6d45f22013-04-01 17:52:07 +0000248 Feature64Bit /*, Feature64BitRegs */]>;
Jim Laskey59e7a772006-12-12 20:57:08 +0000249def : Processor<"ppc", G3Itineraries, [Directive32]>;
Hal Finkel1a958cf2013-04-05 05:49:18 +0000250def : ProcessorModel<"ppc64", G5Model,
Jim Laskey59e7a772006-12-12 20:57:08 +0000251 [Directive64, FeatureAltivec,
Hal Finkel7ac45922013-04-03 14:40:18 +0000252 FeatureMFOCRF, FeatureFSqrt, FeatureFRES,
253 FeatureFRSQRTE, FeatureSTFIWX,
Jim Laskey13a19452005-10-22 08:04:24 +0000254 Feature64Bit /*, Feature64BitRegs */]>;
Jim Laskey74ab9962005-10-19 19:51:16 +0000255
Chris Lattner4f2e4e02007-03-06 00:59:59 +0000256//===----------------------------------------------------------------------===//
257// Calling Conventions
258//===----------------------------------------------------------------------===//
259
260include "PPCCallingConv.td"
261
Chris Lattner51348c52006-03-12 09:13:49 +0000262def PPCInstrInfo : InstrInfo {
Chris Lattner51348c52006-03-12 09:13:49 +0000263 let isLittleEndianEncoding = 1;
264}
265
Chris Lattner045e04d2010-11-15 03:53:53 +0000266def PPCAsmWriter : AsmWriter {
267 string AsmWriterClassName = "InstPrinter";
268 bit isMCAsmWriter = 1;
269}
Chris Lattner51348c52006-03-12 09:13:49 +0000270
Chris Lattner0921e3b2005-10-14 23:37:35 +0000271def PPC : Target {
Chris Lattner51348c52006-03-12 09:13:49 +0000272 // Information about the instructions.
273 let InstructionSet = PPCInstrInfo;
Chris Lattner045e04d2010-11-15 03:53:53 +0000274
275 let AssemblyWriters = [PPCAsmWriter];
Chris Lattner0921e3b2005-10-14 23:37:35 +0000276}