NVPTX: move NVPTXAllocaHoisting into the cpp file

Also initialize without using static initialization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231822 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2015-03-10 19:20:52 +00:00
parent 73dff35fac
commit f0d37a472f
3 changed files with 35 additions and 34 deletions

View File

@ -12,11 +12,33 @@
//===----------------------------------------------------------------------===//
#include "NVPTXAllocaHoisting.h"
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
#include "llvm/CodeGen/StackProtector.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
using namespace llvm;
namespace llvm {
namespace {
// Hoisting the alloca instructions in the non-entry blocks to the entry
// block.
class NVPTXAllocaHoisting : public FunctionPass {
public:
static char ID; // Pass ID
NVPTXAllocaHoisting() : FunctionPass(ID) {}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addPreserved<MachineFunctionAnalysis>();
AU.addPreserved<StackProtector>();
}
const char *getPassName() const override {
return "NVPTX specific alloca hoisting";
}
bool runOnFunction(Function &function) override;
};
} // namespace
bool NVPTXAllocaHoisting::runOnFunction(Function &function) {
bool functionModified = false;
@ -36,11 +58,15 @@ bool NVPTXAllocaHoisting::runOnFunction(Function &function) {
return functionModified;
}
char NVPTXAllocaHoisting::ID = 1;
static RegisterPass<NVPTXAllocaHoisting>
X("alloca-hoisting", "Hoisting alloca instructions in non-entry "
"blocks to the entry block");
char NVPTXAllocaHoisting::ID = 0;
FunctionPass *createAllocaHoisting() { return new NVPTXAllocaHoisting(); }
namespace llvm {
void initializeNVPTXAllocaHoistingPass(PassRegistry &);
}
} // end namespace llvm
INITIALIZE_PASS(
NVPTXAllocaHoisting, "alloca-hoisting",
"Hoisting alloca instructions in non-entry blocks to the entry block",
false, false)
FunctionPass *llvm::createAllocaHoisting() { return new NVPTXAllocaHoisting; }

View File

@ -14,37 +14,10 @@
#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXALLOCAHOISTING_H
#define LLVM_LIB_TARGET_NVPTX_NVPTXALLOCAHOISTING_H
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
#include "llvm/CodeGen/StackProtector.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/Pass.h"
namespace llvm {
class FunctionPass;
class Function;
// Hoisting the alloca instructions in the non-entry blocks to the entry
// block.
class NVPTXAllocaHoisting : public FunctionPass {
public:
static char ID; // Pass ID
NVPTXAllocaHoisting() : FunctionPass(ID) {}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addPreserved<MachineFunctionAnalysis>();
AU.addPreserved<StackProtector>();
}
const char *getPassName() const override {
return "NVPTX specific alloca hoisting";
}
bool runOnFunction(Function &function) override;
};
extern FunctionPass *createAllocaHoisting();
} // end namespace llvm
#endif

View File

@ -50,6 +50,7 @@ using namespace llvm;
namespace llvm {
void initializeNVVMReflectPass(PassRegistry&);
void initializeGenericToNVVMPass(PassRegistry&);
void initializeNVPTXAllocaHoistingPass(PassRegistry &);
void initializeNVPTXAssignValidGlobalNamesPass(PassRegistry&);
void initializeNVPTXFavorNonGenericAddrSpacesPass(PassRegistry &);
void initializeNVPTXLowerStructArgsPass(PassRegistry &);
@ -64,6 +65,7 @@ extern "C" void LLVMInitializeNVPTXTarget() {
// but it's very NVPTX-specific.
initializeNVVMReflectPass(*PassRegistry::getPassRegistry());
initializeGenericToNVVMPass(*PassRegistry::getPassRegistry());
initializeNVPTXAllocaHoistingPass(*PassRegistry::getPassRegistry());
initializeNVPTXAssignValidGlobalNamesPass(*PassRegistry::getPassRegistry());
initializeNVPTXFavorNonGenericAddrSpacesPass(
*PassRegistry::getPassRegistry());