1 //===-- SystemZSubtarget.h - SystemZ subtarget information -----*- C++ -*--===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the SystemZ specific subclass of TargetSubtargetInfo.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZSUBTARGET_H
14 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZSUBTARGET_H
15 
16 #include "SystemZFrameLowering.h"
17 #include "SystemZISelLowering.h"
18 #include "SystemZInstrInfo.h"
19 #include "SystemZRegisterInfo.h"
20 #include "SystemZSelectionDAGInfo.h"
21 #include "llvm/ADT/Triple.h"
22 #include "llvm/CodeGen/TargetSubtargetInfo.h"
23 #include "llvm/IR/DataLayout.h"
24 #include <string>
25 
26 #define GET_SUBTARGETINFO_HEADER
27 #include "SystemZGenSubtargetInfo.inc"
28 
29 namespace llvm {
30 class GlobalValue;
31 class StringRef;
32 
33 class SystemZSubtarget : public SystemZGenSubtargetInfo {
34   virtual void anchor();
35 protected:
36   bool HasDistinctOps;
37   bool HasLoadStoreOnCond;
38   bool HasHighWord;
39   bool HasFPExtension;
40   bool HasPopulationCount;
41   bool HasMessageSecurityAssist3;
42   bool HasMessageSecurityAssist4;
43   bool HasResetReferenceBitsMultiple;
44   bool HasFastSerialization;
45   bool HasInterlockedAccess1;
46   bool HasMiscellaneousExtensions;
47   bool HasExecutionHint;
48   bool HasLoadAndTrap;
49   bool HasTransactionalExecution;
50   bool HasProcessorAssist;
51   bool HasDFPZonedConversion;
52   bool HasEnhancedDAT2;
53   bool HasVector;
54   bool HasLoadStoreOnCond2;
55   bool HasLoadAndZeroRightmostByte;
56   bool HasMessageSecurityAssist5;
57   bool HasDFPPackedConversion;
58   bool HasMiscellaneousExtensions2;
59   bool HasGuardedStorage;
60   bool HasMessageSecurityAssist7;
61   bool HasMessageSecurityAssist8;
62   bool HasVectorEnhancements1;
63   bool HasVectorPackedDecimal;
64   bool HasInsertReferenceBitsMultiple;
65   bool HasMiscellaneousExtensions3;
66   bool HasMessageSecurityAssist9;
67   bool HasVectorEnhancements2;
68   bool HasVectorPackedDecimalEnhancement;
69   bool HasEnhancedSort;
70   bool HasDeflateConversion;
71   bool HasVectorPackedDecimalEnhancement2;
72   bool HasNNPAssist;
73   bool HasBEAREnhancement;
74   bool HasResetDATProtection;
75   bool HasProcessorActivityInstrumentation;
76   bool HasSoftFloat;
77 
78 private:
79   Triple TargetTriple;
80   std::unique_ptr<SystemZCallingConventionRegisters> SpecialRegisters;
81   SystemZInstrInfo InstrInfo;
82   SystemZTargetLowering TLInfo;
83   SystemZSelectionDAGInfo TSInfo;
84   std::unique_ptr<const SystemZFrameLowering> FrameLowering;
85 
86   SystemZSubtarget &initializeSubtargetDependencies(StringRef CPU,
87                                                     StringRef FS);
88   SystemZCallingConventionRegisters *initializeSpecialRegisters(void);
89 
90 public:
91   SystemZSubtarget(const Triple &TT, const std::string &CPU,
92                    const std::string &FS, const TargetMachine &TM);
93 
getSpecialRegisters()94   SystemZCallingConventionRegisters *getSpecialRegisters() const {
95     assert(SpecialRegisters && "Unsupported SystemZ calling convention");
96     return SpecialRegisters.get();
97   }
98 
getFrameLowering()99   const TargetFrameLowering *getFrameLowering() const override {
100     return FrameLowering.get();
101   }
102 
getFrameLowering()103   template <class TFL> const TFL *getFrameLowering() const {
104     return static_cast<const TFL *>(getFrameLowering());
105   }
106 
getInstrInfo()107   const SystemZInstrInfo *getInstrInfo() const override { return &InstrInfo; }
getRegisterInfo()108   const SystemZRegisterInfo *getRegisterInfo() const override {
109     return &InstrInfo.getRegisterInfo();
110   }
getTargetLowering()111   const SystemZTargetLowering *getTargetLowering() const override {
112     return &TLInfo;
113   }
getSelectionDAGInfo()114   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
115     return &TSInfo;
116   }
117 
118   // True if the subtarget should run MachineScheduler after aggressive
119   // coalescing. This currently replaces the SelectionDAG scheduler with the
120   // "source" order scheduler.
enableMachineScheduler()121   bool enableMachineScheduler() const override { return true; }
122 
123   // This is important for reducing register pressure in vector code.
useAA()124   bool useAA() const override { return true; }
125 
126   // Always enable the early if-conversion pass.
enableEarlyIfConversion()127   bool enableEarlyIfConversion() const override { return true; }
128 
129   // Enable tracking of subregister liveness in register allocator.
130   bool enableSubRegLiveness() const override;
131 
132   // Automatically generated by tblgen.
133   void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
134 
135   // Return true if the target has the distinct-operands facility.
hasDistinctOps()136   bool hasDistinctOps() const { return HasDistinctOps; }
137 
138   // Return true if the target has the load/store-on-condition facility.
hasLoadStoreOnCond()139   bool hasLoadStoreOnCond() const { return HasLoadStoreOnCond; }
140 
141   // Return true if the target has the load/store-on-condition facility 2.
hasLoadStoreOnCond2()142   bool hasLoadStoreOnCond2() const { return HasLoadStoreOnCond2; }
143 
144   // Return true if the target has the high-word facility.
hasHighWord()145   bool hasHighWord() const { return HasHighWord; }
146 
147   // Return true if the target has the floating-point extension facility.
hasFPExtension()148   bool hasFPExtension() const { return HasFPExtension; }
149 
150   // Return true if the target has the population-count facility.
hasPopulationCount()151   bool hasPopulationCount() const { return HasPopulationCount; }
152 
153   // Return true if the target has the message-security-assist
154   // extension facility 3.
hasMessageSecurityAssist3()155   bool hasMessageSecurityAssist3() const { return HasMessageSecurityAssist3; }
156 
157   // Return true if the target has the message-security-assist
158   // extension facility 4.
hasMessageSecurityAssist4()159   bool hasMessageSecurityAssist4() const { return HasMessageSecurityAssist4; }
160 
161   // Return true if the target has the reset-reference-bits-multiple facility.
hasResetReferenceBitsMultiple()162   bool hasResetReferenceBitsMultiple() const {
163     return HasResetReferenceBitsMultiple;
164   }
165 
166   // Return true if the target has the fast-serialization facility.
hasFastSerialization()167   bool hasFastSerialization() const { return HasFastSerialization; }
168 
169   // Return true if the target has interlocked-access facility 1.
hasInterlockedAccess1()170   bool hasInterlockedAccess1() const { return HasInterlockedAccess1; }
171 
172   // Return true if the target has the miscellaneous-extensions facility.
hasMiscellaneousExtensions()173   bool hasMiscellaneousExtensions() const {
174     return HasMiscellaneousExtensions;
175   }
176 
177   // Return true if the target has the execution-hint facility.
hasExecutionHint()178   bool hasExecutionHint() const { return HasExecutionHint; }
179 
180   // Return true if the target has the load-and-trap facility.
hasLoadAndTrap()181   bool hasLoadAndTrap() const { return HasLoadAndTrap; }
182 
183   // Return true if the target has the transactional-execution facility.
hasTransactionalExecution()184   bool hasTransactionalExecution() const { return HasTransactionalExecution; }
185 
186   // Return true if the target has the processor-assist facility.
hasProcessorAssist()187   bool hasProcessorAssist() const { return HasProcessorAssist; }
188 
189   // Return true if the target has the DFP zoned-conversion facility.
hasDFPZonedConversion()190   bool hasDFPZonedConversion() const { return HasDFPZonedConversion; }
191 
192   // Return true if the target has the enhanced-DAT facility 2.
hasEnhancedDAT2()193   bool hasEnhancedDAT2() const { return HasEnhancedDAT2; }
194 
195   // Return true if the target has the load-and-zero-rightmost-byte facility.
hasLoadAndZeroRightmostByte()196   bool hasLoadAndZeroRightmostByte() const {
197     return HasLoadAndZeroRightmostByte;
198   }
199 
200   // Return true if the target has the message-security-assist
201   // extension facility 5.
hasMessageSecurityAssist5()202   bool hasMessageSecurityAssist5() const { return HasMessageSecurityAssist5; }
203 
204   // Return true if the target has the DFP packed-conversion facility.
hasDFPPackedConversion()205   bool hasDFPPackedConversion() const { return HasDFPPackedConversion; }
206 
207   // Return true if the target has the vector facility.
hasVector()208   bool hasVector() const { return HasVector; }
209 
210   // Return true if the target has the miscellaneous-extensions facility 2.
hasMiscellaneousExtensions2()211   bool hasMiscellaneousExtensions2() const {
212     return HasMiscellaneousExtensions2;
213   }
214 
215   // Return true if the target has the guarded-storage facility.
hasGuardedStorage()216   bool hasGuardedStorage() const { return HasGuardedStorage; }
217 
218   // Return true if the target has the message-security-assist
219   // extension facility 7.
hasMessageSecurityAssist7()220   bool hasMessageSecurityAssist7() const { return HasMessageSecurityAssist7; }
221 
222   // Return true if the target has the message-security-assist
223   // extension facility 8.
hasMessageSecurityAssist8()224   bool hasMessageSecurityAssist8() const { return HasMessageSecurityAssist8; }
225 
226   // Return true if the target has the vector-enhancements facility 1.
hasVectorEnhancements1()227   bool hasVectorEnhancements1() const { return HasVectorEnhancements1; }
228 
229   // Return true if the target has the vector-packed-decimal facility.
hasVectorPackedDecimal()230   bool hasVectorPackedDecimal() const { return HasVectorPackedDecimal; }
231 
232   // Return true if the target has the insert-reference-bits-multiple facility.
hasInsertReferenceBitsMultiple()233   bool hasInsertReferenceBitsMultiple() const {
234     return HasInsertReferenceBitsMultiple;
235   }
236 
237   // Return true if the target has the miscellaneous-extensions facility 3.
hasMiscellaneousExtensions3()238   bool hasMiscellaneousExtensions3() const {
239     return HasMiscellaneousExtensions3;
240   }
241 
242   // Return true if the target has the message-security-assist
243   // extension facility 9.
hasMessageSecurityAssist9()244   bool hasMessageSecurityAssist9() const { return HasMessageSecurityAssist9; }
245 
246   // Return true if the target has the vector-enhancements facility 2.
hasVectorEnhancements2()247   bool hasVectorEnhancements2() const { return HasVectorEnhancements2; }
248 
249   // Return true if the target has the vector-packed-decimal
250   // enhancement facility.
hasVectorPackedDecimalEnhancement()251   bool hasVectorPackedDecimalEnhancement() const {
252     return HasVectorPackedDecimalEnhancement;
253   }
254 
255   // Return true if the target has the enhanced-sort facility.
hasEnhancedSort()256   bool hasEnhancedSort() const { return HasEnhancedSort; }
257 
258   // Return true if the target has the deflate-conversion facility.
hasDeflateConversion()259   bool hasDeflateConversion() const { return HasDeflateConversion; }
260 
261   // Return true if the target has the vector-packed-decimal
262   // enhancement facility 2.
hasVectorPackedDecimalEnhancement2()263   bool hasVectorPackedDecimalEnhancement2() const {
264     return HasVectorPackedDecimalEnhancement2;
265   }
266 
267   // Return true if the target has the NNP-assist facility.
hasNNPAssist()268   bool hasNNPAssist() const { return HasNNPAssist; }
269 
270   // Return true if the target has the BEAR-enhancement facility.
hasBEAREnhancement()271   bool hasBEAREnhancement() const { return HasBEAREnhancement; }
272 
273   // Return true if the target has the reset-DAT-protection facility.
hasResetDATProtection()274   bool hasResetDATProtection() const { return HasResetDATProtection; }
275 
276   // Return true if the target has the processor-activity-instrumentation
277   // facility.
hasProcessorActivityInstrumentation()278   bool hasProcessorActivityInstrumentation() const {
279     return HasProcessorActivityInstrumentation;
280   }
281 
282   // Return true if soft float should be used.
hasSoftFloat()283   bool hasSoftFloat() const { return HasSoftFloat; }
284 
285   // Return true if GV can be accessed using LARL for reloc model RM
286   // and code model CM.
287   bool isPC32DBLSymbol(const GlobalValue *GV, CodeModel::Model CM) const;
288 
isTargetELF()289   bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
290 
291   // Returns TRUE if we are generating GOFF object code
isTargetGOFF()292   bool isTargetGOFF() const { return TargetTriple.isOSBinFormatGOFF(); }
293 
294   // Returns TRUE if we are using XPLINK64 linkage convention
isTargetXPLINK64()295   bool isTargetXPLINK64() const { return (isTargetGOFF() && isTargetzOS()); }
296 
297   // Returns TRUE if we are generating code for a s390x machine running zOS
isTargetzOS()298   bool isTargetzOS() const { return TargetTriple.isOSzOS(); }
299 };
300 } // end namespace llvm
301 
302 #endif
303