[llvm] r221619 - [NVPTX] Add an NVPTX-specific TargetTransformInfo

Jingyue Wu jingyue at google.com
Mon Nov 10 21:15:55 PST 2014


Thanks for pointing this out, Eric! r221668 cleans up the dead code.

Jingyue

On Mon Nov 10 2014 at 7:18:13 PM Eric Christopher <echristo at gmail.com>
wrote:

> You don't appear to need to cache the TargetMachine, TargetSubtargetInfo,
> or TargetLoweringInfo, can you please remove these and the associated code
> to initialize them?
>
> Thanks.
>
> -eric
>
> On Mon Nov 10 2014 at 10:33:02 AM Jingyue Wu <jingyue at google.com> wrote:
>
>> Author: jingyue
>> Date: Mon Nov 10 12:38:25 2014
>> New Revision: 221619
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=221619&view=rev
>> Log:
>> [NVPTX] Add an NVPTX-specific TargetTransformInfo
>>
>> Summary:
>> It currently only implements hasBranchDivergence, and will be extended
>> in later diffs.
>>
>> Split from D6188.
>>
>> Test Plan: make check-all
>>
>> Reviewers: jholewinski
>>
>> Reviewed By: jholewinski
>>
>> Subscribers: llvm-commits, meheff, eliben, jholewinski
>>
>> Differential Revision: http://reviews.llvm.org/D6195
>>
>> Added:
>>     llvm/trunk/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
>> Modified:
>>     llvm/trunk/lib/Target/NVPTX/CMakeLists.txt
>>     llvm/trunk/lib/Target/NVPTX/NVPTX.h
>>     llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.cpp
>>     llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.h
>>
>> Modified: llvm/trunk/lib/Target/NVPTX/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/
>> NVPTX/CMakeLists.txt?rev=221619&r1=221618&r2=221619&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/Target/NVPTX/CMakeLists.txt (original)
>> +++ llvm/trunk/lib/Target/NVPTX/CMakeLists.txt Mon Nov 10 12:38:25 2014
>> @@ -9,27 +9,28 @@ tablegen(LLVM NVPTXGenSubtargetInfo.inc
>>  add_public_tablegen_target(NVPTXCommonTableGen)
>>
>>  set(NVPTXCodeGen_sources
>> +  NVPTXAllocaHoisting.cpp
>> +  NVPTXAsmPrinter.cpp
>> +  NVPTXAssignValidGlobalNames.cpp
>>    NVPTXFavorNonGenericAddrSpaces.cpp
>>    NVPTXFrameLowering.cpp
>> -  NVPTXInstrInfo.cpp
>> +  NVPTXGenericToNVVM.cpp
>>    NVPTXISelDAGToDAG.cpp
>>    NVPTXISelLowering.cpp
>> +  NVPTXImageOptimizer.cpp
>> +  NVPTXInstrInfo.cpp
>> +  NVPTXLowerAggrCopies.cpp
>> +  NVPTXLowerStructArgs.cpp
>> +  NVPTXMCExpr.cpp
>> +  NVPTXPrologEpilogPass.cpp
>>    NVPTXRegisterInfo.cpp
>> +  NVPTXReplaceImageHandles.cpp
>>    NVPTXSubtarget.cpp
>>    NVPTXTargetMachine.cpp
>> -  NVPTXLowerAggrCopies.cpp
>> -  NVPTXutil.cpp
>> -  NVPTXAllocaHoisting.cpp
>> -  NVPTXAsmPrinter.cpp
>> +  NVPTXTargetTransformInfo.cpp
>>    NVPTXUtilities.cpp
>> +  NVPTXutil.cpp
>>    NVVMReflect.cpp
>> -  NVPTXGenericToNVVM.cpp
>> -  NVPTXAssignValidGlobalNames.cpp
>> -  NVPTXPrologEpilogPass.cpp
>> -  NVPTXMCExpr.cpp
>> -  NVPTXReplaceImageHandles.cpp
>> -  NVPTXImageOptimizer.cpp
>> -  NVPTXLowerStructArgs.cpp
>>    )
>>
>>  add_llvm_target(NVPTXCodeGen ${NVPTXCodeGen_sources})
>>
>> Modified: llvm/trunk/lib/Target/NVPTX/NVPTX.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/
>> NVPTX/NVPTX.h?rev=221619&r1=221618&r2=221619&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/Target/NVPTX/NVPTX.h (original)
>> +++ llvm/trunk/lib/Target/NVPTX/NVPTX.h Mon Nov 10 12:38:25 2014
>> @@ -59,6 +59,7 @@ inline static const char *NVPTXCondCodeT
>>    llvm_unreachable("Unknown condition code");
>>  }
>>
>> +ImmutablePass *createNVPTXTargetTransformInfoPass(const
>> NVPTXTargetMachine *TM);
>>  FunctionPass *
>>  createNVPTXISelDag(NVPTXTargetMachine &TM, llvm::CodeGenOpt::Level
>> OptLevel);
>>  ModulePass *createNVPTXAssignValidGlobalNamesPass();
>>
>> Modified: llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/
>> NVPTX/NVPTXTargetMachine.cpp?rev=221619&r1=221618&r2=221619&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.cpp (original)
>> +++ llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.cpp Mon Nov 10
>> 12:38:25 2014
>> @@ -121,6 +121,14 @@ TargetPassConfig *NVPTXTargetMachine::cr
>>    return PassConfig;
>>  }
>>
>> +void NVPTXTargetMachine::addAnalysisPasses(PassManagerBase &PM) {
>> +  // Add first the target-independent BasicTTI pass, then our NVPTX
>> pass. This
>> +  // allows the NVPTX pass to delegate to the target independent layer
>> when
>> +  // appropriate.
>> +  PM.add(createBasicTargetTransformInfoPass(this));
>> +  PM.add(createNVPTXTargetTransformInfoPass(this));
>> +}
>> +
>>  void NVPTXPassConfig::addIRPasses() {
>>    // The following passes are known to not play well with virtual regs
>> hanging
>>    // around after register allocation (which in our case, is *all*
>> registers).
>>
>> Modified: llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/
>> NVPTX/NVPTXTargetMachine.h?rev=221619&r1=221618&r2=221619&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.h (original)
>> +++ llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.h Mon Nov 10 12:38:25
>> 2014
>> @@ -49,6 +49,9 @@ public:
>>      return true;
>>    }
>>
>> +  /// \brief Register NVPTX analysis passes with a pass manager.
>> +  void addAnalysisPasses(PassManagerBase &PM) override;
>> +
>>  }; // NVPTXTargetMachine.
>>
>>  class NVPTXTargetMachine32 : public NVPTXTargetMachine {
>>
>> Added: llvm/trunk/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/
>> NVPTXTargetTransformInfo.cpp?rev=221619&view=auto
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp (added)
>> +++ llvm/trunk/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp Mon Nov 10
>> 12:38:25 2014
>> @@ -0,0 +1,90 @@
>> +//===-- NVPTXTargetTransformInfo.cpp - NVPTX specific TTI pass
>> ---------===//
>> +//
>> +//                     The LLVM Compiler Infrastructure
>> +//
>> +// This file is distributed under the University of Illinois Open Source
>> +// License. See LICENSE.TXT for details.
>> +//
>> +//===------------------------------------------------------
>> ----------------===//
>> +//
>> +// \file
>> +// This file implements a TargetTransformInfo analysis pass specific to
>> the
>> +// NVPTX target machine. It uses the target's detailed information to
>> provide
>> +// more precise answers to certain TTI queries, while letting the target
>> +// independent and default TTI implementations handle the rest.
>> +//
>> +//===------------------------------------------------------
>> ----------------===//
>> +
>> +#include "NVPTXTargetMachine.h"
>> +#include "llvm/Analysis/LoopInfo.h"
>> +#include "llvm/Analysis/TargetTransformInfo.h"
>> +#include "llvm/Analysis/ValueTracking.h"
>> +#include "llvm/Support/Debug.h"
>> +#include "llvm/Target/CostTable.h"
>> +#include "llvm/Target/TargetLowering.h"
>> +using namespace llvm;
>> +
>> +#define DEBUG_TYPE "NVPTXtti"
>> +
>> +// Declare the pass initialization routine locally as target-specific
>> passes
>> +// don't have a target-wide initialization entry point, and so we rely
>> on the
>> +// pass constructor initialization.
>> +namespace llvm {
>> +void initializeNVPTXTTIPass(PassRegistry &);
>> +}
>> +
>> +namespace {
>> +
>> +class NVPTXTTI final : public ImmutablePass, public TargetTransformInfo {
>> +  const NVPTXTargetMachine *TM;
>> +  const NVPTXSubtarget *ST;
>> +  const NVPTXTargetLowering *TLI;
>> +
>> +  /// Estimate the overhead of scalarizing an instruction. Insert and
>> Extract
>> +  /// are set if the result needs to be inserted and/or extracted from
>> vectors.
>> +  unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract)
>> const;
>> +
>> +public:
>> +  NVPTXTTI() : ImmutablePass(ID), TM(nullptr), ST(nullptr), TLI(nullptr)
>> {
>> +    llvm_unreachable("This pass cannot be directly constructed");
>> +  }
>> +
>> +  NVPTXTTI(const NVPTXTargetMachine *TM)
>> +      : ImmutablePass(ID), TM(TM), ST(TM->getSubtargetImpl()),
>> +        TLI(TM->getSubtargetImpl()->getTargetLowering()) {
>> +    initializeNVPTXTTIPass(*PassRegistry::getPassRegistry());
>> +  }
>> +
>> +  void initializePass() override { pushTTIStack(this); }
>> +
>> +  void getAnalysisUsage(AnalysisUsage &AU) const override {
>> +    TargetTransformInfo::getAnalysisUsage(AU);
>> +  }
>> +
>> +  /// Pass identification.
>> +  static char ID;
>> +
>> +  /// Provide necessary pointer adjustments for the two base classes.
>> +  void *getAdjustedAnalysisPointer(const void *ID) override {
>> +    if (ID == &TargetTransformInfo::ID)
>> +      return (TargetTransformInfo *)this;
>> +    return this;
>> +  }
>> +
>> +  bool hasBranchDivergence() const override;
>> +
>> +  /// @}
>> +};
>> +
>> +} // end anonymous namespace
>> +
>> +INITIALIZE_AG_PASS(NVPTXTTI, TargetTransformInfo, "NVPTXtti",
>> +                   "NVPTX Target Transform Info", true, true, false)
>> +char NVPTXTTI::ID = 0;
>> +
>> +ImmutablePass *
>> +llvm::createNVPTXTargetTransformInfoPass(const NVPTXTargetMachine *TM) {
>> +  return new NVPTXTTI(TM);
>> +}
>> +
>> +bool NVPTXTTI::hasBranchDivergence() const { return true; }
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141111/f3250f23/attachment.html>


More information about the llvm-commits mailing list