llvm.org GIT mirror llvm / 0a1aae8
Revert "Expose a TargetMachine::getTargetTransformInfo function" This reverts commit r321234. It breaks the -DBUILD_SHARED_LIBS=ON build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321243 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjoy Das 2 years ago
29 changed file(s) with 92 addition(s) and 87 deletion(s). Raw diff Collapse all Expand all
2323
2424 namespace llvm {
2525
26 class Function;
2726 class GlobalValue;
2827 class MachineModuleInfo;
2928 class Mangler;
3837 class Target;
3938 class TargetIntrinsicInfo;
4039 class TargetIRAnalysis;
41 class TargetTransformInfo;
4240 class TargetLoweringObjectFile;
4341 class TargetPassConfig;
4442 class TargetSubtargetInfo;
205203 /// This is used to construct the new pass manager's target IR analysis pass,
206204 /// set up appropriately for this target machine. Even the old pass manager
207205 /// uses this to answer queries about the IR.
208 TargetIRAnalysis getTargetIRAnalysis();
209
210 /// \brief Return a TargetTransformInfo for a given function.
211 ///
212 /// The returned TargetTransformInfo is specialized to the subtarget
213 /// corresponding to \p F.
214 virtual TargetTransformInfo getTargetTransformInfo(const Function &F);
206 virtual TargetIRAnalysis getTargetIRAnalysis();
215207
216208 /// Allow the target to modify the pass manager, e.g. by calling
217209 /// PassManagerBuilder::addExtension.
287279 void initAsmInfo();
288280
289281 public:
290 /// \brief Get a TargetTransformInfo implementation for the target.
291 ///
292 /// The TTI returned uses the common code generator to answer queries about
293 /// the IR.
294 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
282 /// \brief Get a TargetIRAnalysis implementation for the target.
283 ///
284 /// This analysis will produce a TTI result which uses the common code
285 /// generator to answer queries about the IR.
286 TargetIRAnalysis getTargetIRAnalysis() override;
295287
296288 /// Create a pass configuration object to be used by addPassToEmitX methods
297289 /// for generating a pipeline of CodeGen passes.
8080 this->OptLevel = OL;
8181 }
8282
83 TargetTransformInfo
84 LLVMTargetMachine::getTargetTransformInfo(const Function &F) {
85 return TargetTransformInfo(BasicTTIImpl(this, F));
83 TargetIRAnalysis LLVMTargetMachine::getTargetIRAnalysis() {
84 return TargetIRAnalysis([this](const Function &F) {
85 return TargetTransformInfo(BasicTTIImpl(this, F));
86 });
8687 }
8788
8889 /// addPassesToX helper drives creation and initialization of TargetPassConfig.
345345
346346 } // end anonymous namespace
347347
348 TargetTransformInfo
349 AArch64TargetMachine::getTargetTransformInfo(const Function &F) {
350 return TargetTransformInfo(AArch64TTIImpl(this, F));
348 TargetIRAnalysis AArch64TargetMachine::getTargetIRAnalysis() {
349 return TargetIRAnalysis([this](const Function &F) {
350 return TargetTransformInfo(AArch64TTIImpl(this, F));
351 });
351352 }
352353
353354 TargetPassConfig *AArch64TargetMachine::createPassConfig(PassManagerBase &PM) {
4343 // Pass Pipeline Configuration
4444 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
4545
46 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
46 /// \brief Get the TargetIRAnalysis for this target.
47 TargetIRAnalysis getTargetIRAnalysis() override;
4748
4849 TargetLoweringObjectFile* getObjFileLowering() const override {
4950 return TLOF.get();
570570
571571 } // end anonymous namespace
572572
573 TargetTransformInfo
574 AMDGPUTargetMachine::getTargetTransformInfo(const Function &F) {
575 return TargetTransformInfo(AMDGPUTTIImpl(this, F));
573 TargetIRAnalysis AMDGPUTargetMachine::getTargetIRAnalysis() {
574 return TargetIRAnalysis([this](const Function &F) {
575 return TargetTransformInfo(AMDGPUTTIImpl(this, F));
576 });
576577 }
577578
578579 void AMDGPUPassConfig::addEarlyCSEOrGVNPass() {
896897 TargetPassConfig *GCNTargetMachine::createPassConfig(PassManagerBase &PM) {
897898 return new GCNPassConfig(*this, PM);
898899 }
900
5454 const AMDGPUIntrinsicInfo *getIntrinsicInfo() const override {
5555 return &IntrinsicInfo;
5656 }
57 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
57 TargetIRAnalysis getTargetIRAnalysis() override;
5858
5959 TargetLoweringObjectFile *getObjFileLowering() const override {
6060 return TLOF.get();
8787 RegisterTargetMachine X(getTheARCTarget());
8888 }
8989
90 TargetTransformInfo
91 ARCTargetMachine::getTargetTransformInfo(const Function &F) {
92 return TargetTransformInfo(ARCTTIImpl(this, F));
90 TargetIRAnalysis ARCTargetMachine::getTargetIRAnalysis() {
91 return TargetIRAnalysis([this](const Function &F) {
92 return TargetTransformInfo(ARCTTIImpl(this, F));
93 });
9394 }
3939 // Pass Pipeline Configuration
4040 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
4141
42 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
42 TargetIRAnalysis getTargetIRAnalysis() override;
4343 TargetLoweringObjectFile *getObjFileLowering() const override {
4444 return TLOF.get();
4545 }
282282 return I.get();
283283 }
284284
285 TargetTransformInfo
286 ARMBaseTargetMachine::getTargetTransformInfo(const Function &F) {
287 return TargetTransformInfo(ARMTTIImpl(this, F));
285 TargetIRAnalysis ARMBaseTargetMachine::getTargetIRAnalysis() {
286 return TargetIRAnalysis([this](const Function &F) {
287 return TargetTransformInfo(ARMTTIImpl(this, F));
288 });
288289 }
289290
290291 ARMLETargetMachine::ARMLETargetMachine(const Target &T, const Triple &TT,
5252 const ARMSubtarget *getSubtargetImpl() const = delete;
5353 bool isLittleEndian() const { return isLittle; }
5454
55 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
55 /// \brief Get the TargetIRAnalysis for this target.
56 TargetIRAnalysis getTargetIRAnalysis() override;
5657
5758 // Pass Pipeline Configuration
5859 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
257257 });
258258 }
259259
260 TargetTransformInfo
261 HexagonTargetMachine::getTargetTransformInfo(const Function &F) {
262 return TargetTransformInfo(HexagonTTIImpl(this, F));
260 TargetIRAnalysis HexagonTargetMachine::getTargetIRAnalysis() {
261 return TargetIRAnalysis([this](const Function &F) {
262 return TargetTransformInfo(HexagonTTIImpl(this, F));
263 });
263264 }
264265
265266
3838
3939 void adjustPassManager(PassManagerBuilder &PMB) override;
4040 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
41 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
41 TargetIRAnalysis getTargetIRAnalysis() override;
4242
4343 HexagonTargetObjectFile *getObjFileLowering() const override {
4444 return static_cast(TLOF.get());
7373 initAsmInfo();
7474 }
7575
76 TargetTransformInfo
77 LanaiTargetMachine::getTargetTransformInfo(const Function &F) {
78 return TargetTransformInfo(LanaiTTIImpl(this, F));
76 TargetIRAnalysis LanaiTargetMachine::getTargetIRAnalysis() {
77 return TargetIRAnalysis([this](const Function &F) {
78 return TargetTransformInfo(LanaiTTIImpl(this, F));
79 });
7980 }
8081
8182 namespace {
4141 return &Subtarget;
4242 }
4343
44 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
44 TargetIRAnalysis getTargetIRAnalysis() override;
4545
4646 // Pass Pipeline Configuration
4747 TargetPassConfig *createPassConfig(PassManagerBase &pass_manager) override;
258258 addPass(createMipsOptimizePICCallPass());
259259 }
260260
261 TargetTransformInfo
262 MipsTargetMachine::getTargetTransformInfo(const Function &F) {
263 if (Subtarget->allowMixed16_32()) {
264 DEBUG(errs() << "No Target Transform Info Pass Added\n");
265 // FIXME: This is no longer necessary as the TTI returned is per-function.
266 return TargetTransformInfo(F.getParent()->getDataLayout());
267 }
268
269 DEBUG(errs() << "Target Transform Info Pass Added\n");
270 return TargetTransformInfo(BasicTTIImpl(this, F));
261 TargetIRAnalysis MipsTargetMachine::getTargetIRAnalysis() {
262 return TargetIRAnalysis([this](const Function &F) {
263 if (Subtarget->allowMixed16_32()) {
264 DEBUG(errs() << "No Target Transform Info Pass Added\n");
265 // FIXME: This is no longer necessary as the TTI returned is per-function.
266 return TargetTransformInfo(F.getParent()->getDataLayout());
267 }
268
269 DEBUG(errs() << "Target Transform Info Pass Added\n");
270 return TargetTransformInfo(BasicTTIImpl(this, F));
271 });
271272 }
272273
273274 // Implemented by targets that want to run passes immediately before
4343 CodeGenOpt::Level OL, bool JIT, bool isLittle);
4444 ~MipsTargetMachine() override;
4545
46 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
46 TargetIRAnalysis getTargetIRAnalysis() override;
4747
4848 const MipsSubtarget *getSubtargetImpl() const {
4949 if (Subtarget)
179179 });
180180 }
181181
182 TargetTransformInfo
183 NVPTXTargetMachine::getTargetTransformInfo(const Function &F) {
184 return TargetTransformInfo(NVPTXTTIImpl(this, F));
182 TargetIRAnalysis NVPTXTargetMachine::getTargetIRAnalysis() {
183 return TargetIRAnalysis([this](const Function &F) {
184 return TargetTransformInfo(NVPTXTTIImpl(this, F));
185 });
185186 }
186187
187188 void NVPTXPassConfig::addEarlyCSEOrGVNPass() {
6262
6363 void adjustPassManager(PassManagerBuilder &) override;
6464
65 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
65 TargetIRAnalysis getTargetIRAnalysis() override;
6666
6767 bool isMachineVerifierClean() const override {
6868 return false;
450450 addPass(createPPCBranchSelectionPass(), false);
451451 }
452452
453 TargetTransformInfo
454 PPCTargetMachine::getTargetTransformInfo(const Function &F) {
455 return TargetTransformInfo(PPCTTIImpl(this, F));
456 }
453 TargetIRAnalysis PPCTargetMachine::getTargetIRAnalysis() {
454 return TargetIRAnalysis([this](const Function &F) {
455 return TargetTransformInfo(PPCTTIImpl(this, F));
456 });
457 }
4848 // Pass Pipeline Configuration
4949 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
5050
51 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
51 TargetIRAnalysis getTargetIRAnalysis() override;
5252
5353 TargetLoweringObjectFile *getObjFileLowering() const override {
5454 return TLOF.get();
256256 return new SystemZPassConfig(*this, PM);
257257 }
258258
259 TargetTransformInfo
260 SystemZTargetMachine::getTargetTransformInfo(const Function &F) {
261 return TargetTransformInfo(SystemZTTIImpl(this, F));
262 }
259 TargetIRAnalysis SystemZTargetMachine::getTargetIRAnalysis() {
260 return TargetIRAnalysis([this](const Function &F) {
261 return TargetTransformInfo(SystemZTTIImpl(this, F));
262 });
263 }
4343
4444 // Override LLVMTargetMachine
4545 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
46 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
46 TargetIRAnalysis getTargetIRAnalysis() override;
4747
4848 TargetLoweringObjectFile *getObjFileLowering() const override {
4949 return TLOF.get();
218218
219219 void TargetMachine::setOptLevel(CodeGenOpt::Level Level) { OptLevel = Level; }
220220
221 TargetTransformInfo TargetMachine::getTargetTransformInfo(const Function &F) {
222 return TargetTransformInfo(F.getParent()->getDataLayout());
221 TargetIRAnalysis TargetMachine::getTargetIRAnalysis() {
222 return TargetIRAnalysis([](const Function &F) {
223 return TargetTransformInfo(F.getParent()->getDataLayout());
224 });
223225 }
224226
225227 void TargetMachine::getNameWithPrefix(SmallVectorImpl &Name,
241243 getNameWithPrefix(NameStr, GV, TLOF->getMangler());
242244 return TLOF->getContext().getOrCreateSymbol(NameStr);
243245 }
244
245 TargetIRAnalysis TargetMachine::getTargetIRAnalysis() {
246 // Since Analysis can't depend on Target, use a std::function to invert the
247 // dependency.
248 return TargetIRAnalysis(
249 [this](const Function &F) { return this->getTargetTransformInfo(F); });
250 }
145145 };
146146 } // end anonymous namespace
147147
148 TargetTransformInfo
149 WebAssemblyTargetMachine::getTargetTransformInfo(const Function &F) {
150 return TargetTransformInfo(WebAssemblyTTIImpl(this, F));
148 TargetIRAnalysis WebAssemblyTargetMachine::getTargetIRAnalysis() {
149 return TargetIRAnalysis([this](const Function &F) {
150 return TargetTransformInfo(WebAssemblyTTIImpl(this, F));
151 });
151152 }
152153
153154 TargetPassConfig *
4242 return TLOF.get();
4343 }
4444
45 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
45 /// \brief Get the TargetIRAnalysis for this target.
46 TargetIRAnalysis getTargetIRAnalysis() override;
4647
4748 bool usesPhysRegsForPEI() const override { return false; }
4849 };
280280 // X86 TTI query.
281281 //===----------------------------------------------------------------------===//
282282
283 TargetTransformInfo
284 X86TargetMachine::getTargetTransformInfo(const Function &F) {
285 return TargetTransformInfo(X86TTIImpl(this, F));
283 TargetIRAnalysis X86TargetMachine::getTargetIRAnalysis() {
284 return TargetIRAnalysis([this](const Function &F) {
285 return TargetTransformInfo(X86TTIImpl(this, F));
286 });
286287 }
287288
288289 //===----------------------------------------------------------------------===//
4444 // attributes of each function.
4545 const X86Subtarget *getSubtargetImpl() const = delete;
4646
47 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
47 TargetIRAnalysis getTargetIRAnalysis() override;
4848
4949 // Set up the pass pipeline.
5050 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
107107 RegisterTargetMachine X(getTheXCoreTarget());
108108 }
109109
110 TargetTransformInfo
111 XCoreTargetMachine::getTargetTransformInfo(const Function &F) {
112 return TargetTransformInfo(XCoreTTIImpl(this, F));
110 TargetIRAnalysis XCoreTargetMachine::getTargetIRAnalysis() {
111 return TargetIRAnalysis([this](const Function &F) {
112 return TargetTransformInfo(XCoreTTIImpl(this, F));
113 });
113114 }
4242 // Pass Pipeline Configuration
4343 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
4444
45 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
45 TargetIRAnalysis getTargetIRAnalysis() override;
4646
4747 TargetLoweringObjectFile *getObjFileLowering() const override {
4848 return TLOF.get();