1 //===-- SystemZSubtarget.h - SystemZ subtarget information -----*- C++ -*--===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the SystemZ specific subclass of TargetSubtargetInfo.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZSUBTARGET_H
15 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZSUBTARGET_H
16 
17 #include "SystemZFrameLowering.h"
18 #include "SystemZISelLowering.h"
19 #include "SystemZInstrInfo.h"
20 #include "SystemZRegisterInfo.h"
21 #include "SystemZSelectionDAGInfo.h"
22 #include "llvm/ADT/Triple.h"
23 #include "llvm/IR/DataLayout.h"
24 #include "llvm/Target/TargetSubtargetInfo.h"
25 #include <string>
26 
27 #define GET_SUBTARGETINFO_HEADER
28 #include "SystemZGenSubtargetInfo.inc"
29 
30 namespace llvm {
31 class GlobalValue;
32 class StringRef;
33 
34 class SystemZSubtarget : public SystemZGenSubtargetInfo {
35   virtual void anchor();
36 protected:
37   bool HasDistinctOps;
38   bool HasLoadStoreOnCond;
39   bool HasHighWord;
40   bool HasFPExtension;
41   bool HasPopulationCount;
42   bool HasMessageSecurityAssist3;
43   bool HasMessageSecurityAssist4;
44   bool HasResetReferenceBitsMultiple;
45   bool HasFastSerialization;
46   bool HasInterlockedAccess1;
47   bool HasMiscellaneousExtensions;
48   bool HasExecutionHint;
49   bool HasLoadAndTrap;
50   bool HasTransactionalExecution;
51   bool HasProcessorAssist;
52   bool HasDFPZonedConversion;
53   bool HasEnhancedDAT2;
54   bool HasVector;
55   bool HasLoadStoreOnCond2;
56   bool HasLoadAndZeroRightmostByte;
57   bool HasMessageSecurityAssist5;
58   bool HasDFPPackedConversion;
59 
60 private:
61   Triple TargetTriple;
62   SystemZInstrInfo InstrInfo;
63   SystemZTargetLowering TLInfo;
64   SystemZSelectionDAGInfo TSInfo;
65   SystemZFrameLowering FrameLowering;
66 
67   SystemZSubtarget &initializeSubtargetDependencies(StringRef CPU,
68                                                     StringRef FS);
69 public:
70   SystemZSubtarget(const Triple &TT, const std::string &CPU,
71                    const std::string &FS, const TargetMachine &TM);
72 
73   const TargetFrameLowering *getFrameLowering() const override {
74     return &FrameLowering;
75   }
76   const SystemZInstrInfo *getInstrInfo() const override { return &InstrInfo; }
77   const SystemZRegisterInfo *getRegisterInfo() const override {
78     return &InstrInfo.getRegisterInfo();
79   }
80   const SystemZTargetLowering *getTargetLowering() const override {
81     return &TLInfo;
82   }
83   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
84     return &TSInfo;
85   }
86 
87   // This is important for reducing register pressure in vector code.
88   bool useAA() const override { return true; }
89 
90   // Always enable the early if-conversion pass.
91   bool enableEarlyIfConversion() const override { return true; }
92 
93   // Automatically generated by tblgen.
94   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
95 
96   // Return true if the target has the distinct-operands facility.
97   bool hasDistinctOps() const { return HasDistinctOps; }
98 
99   // Return true if the target has the load/store-on-condition facility.
100   bool hasLoadStoreOnCond() const { return HasLoadStoreOnCond; }
101 
102   // Return true if the target has the load/store-on-condition facility 2.
103   bool hasLoadStoreOnCond2() const { return HasLoadStoreOnCond2; }
104 
105   // Return true if the target has the high-word facility.
106   bool hasHighWord() const { return HasHighWord; }
107 
108   // Return true if the target has the floating-point extension facility.
109   bool hasFPExtension() const { return HasFPExtension; }
110 
111   // Return true if the target has the population-count facility.
112   bool hasPopulationCount() const { return HasPopulationCount; }
113 
114   // Return true if the target has the message-security-assist
115   // extension facility 3.
116   bool hasMessageSecurityAssist3() const { return HasMessageSecurityAssist3; }
117 
118   // Return true if the target has the message-security-assist
119   // extension facility 4.
120   bool hasMessageSecurityAssist4() const { return HasMessageSecurityAssist4; }
121 
122   // Return true if the target has the reset-reference-bits-multiple facility.
123   bool hasResetReferenceBitsMultiple() const {
124     return HasResetReferenceBitsMultiple;
125   }
126 
127   // Return true if the target has the fast-serialization facility.
128   bool hasFastSerialization() const { return HasFastSerialization; }
129 
130   // Return true if the target has interlocked-access facility 1.
131   bool hasInterlockedAccess1() const { return HasInterlockedAccess1; }
132 
133   // Return true if the target has the miscellaneous-extensions facility.
134   bool hasMiscellaneousExtensions() const {
135     return HasMiscellaneousExtensions;
136   }
137 
138   // Return true if the target has the execution-hint facility.
139   bool hasExecutionHint() const { return HasExecutionHint; }
140 
141   // Return true if the target has the load-and-trap facility.
142   bool hasLoadAndTrap() const { return HasLoadAndTrap; }
143 
144   // Return true if the target has the transactional-execution facility.
145   bool hasTransactionalExecution() const { return HasTransactionalExecution; }
146 
147   // Return true if the target has the processor-assist facility.
148   bool hasProcessorAssist() const { return HasProcessorAssist; }
149 
150   // Return true if the target has the DFP zoned-conversion facility.
151   bool hasDFPZonedConversion() const { return HasDFPZonedConversion; }
152 
153   // Return true if the target has the enhanced-DAT facility 2.
154   bool hasEnhancedDAT2() const { return HasEnhancedDAT2; }
155 
156   // Return true if the target has the load-and-zero-rightmost-byte facility.
157   bool hasLoadAndZeroRightmostByte() const {
158     return HasLoadAndZeroRightmostByte;
159   }
160 
161   // Return true if the target has the message-security-assist
162   // extension facility 5.
163   bool hasMessageSecurityAssist5() const { return HasMessageSecurityAssist5; }
164 
165   // Return true if the target has the DFP packed-conversion facility.
166   bool hasDFPPackedConversion() const { return HasDFPPackedConversion; }
167 
168   // Return true if the target has the vector facility.
169   bool hasVector() const { return HasVector; }
170 
171   // Return true if GV can be accessed using LARL for reloc model RM
172   // and code model CM.
173   bool isPC32DBLSymbol(const GlobalValue *GV, CodeModel::Model CM) const;
174 
175   bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
176 };
177 } // end namespace llvm
178 
179 #endif
180