mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-16 11:24:39 +00:00
Make TargetPassConfig an ImmutablePass so CodeGenPasses can query options
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149752 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#ifndef LLVM_CODEGEN_PASSES_H
|
||||
#define LLVM_CODEGEN_PASSES_H
|
||||
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include <string>
|
||||
|
||||
@@ -32,9 +33,12 @@ namespace llvm {
|
||||
|
||||
/// Target-Independent Code Generator Pass Configuration Options.
|
||||
///
|
||||
/// This is an ImmutablePass solely for the purpose of exposing CodeGen options
|
||||
/// to the internals of other CodeGen passes.
|
||||
///
|
||||
/// FIXME: Why are we passing the DisableVerify flags around instead of setting
|
||||
/// an options in the target machine, like all the other driver options?
|
||||
class TargetPassConfig {
|
||||
class TargetPassConfig : public ImmutablePass {
|
||||
protected:
|
||||
TargetMachine *TM;
|
||||
PassManagerBase &PM;
|
||||
@@ -43,8 +47,12 @@ protected:
|
||||
public:
|
||||
TargetPassConfig(TargetMachine *tm, PassManagerBase &pm,
|
||||
bool DisableVerifyFlag);
|
||||
// Dummy constructor.
|
||||
TargetPassConfig();
|
||||
|
||||
virtual ~TargetPassConfig() {}
|
||||
virtual ~TargetPassConfig();
|
||||
|
||||
static char ID;
|
||||
|
||||
/// Get the right type of TargetMachine for this target.
|
||||
template<typename TMC> TMC &getTM() const {
|
||||
|
@@ -228,6 +228,7 @@ void initializeStripNonDebugSymbolsPass(PassRegistry&);
|
||||
void initializeStripSymbolsPass(PassRegistry&);
|
||||
void initializeStrongPHIEliminationPass(PassRegistry&);
|
||||
void initializeTailCallElimPass(PassRegistry&);
|
||||
void initializeTargetPassConfigPass(PassRegistry&);
|
||||
void initializeTargetDataPass(PassRegistry&);
|
||||
void initializeTargetLibraryInfoPass(PassRegistry&);
|
||||
void initializeTwoAddressInstructionPassPass(PassRegistry&);
|
||||
|
@@ -49,6 +49,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
|
||||
initializeStackProtectorPass(Registry);
|
||||
initializeStackSlotColoringPass(Registry);
|
||||
initializeStrongPHIEliminationPass(Registry);
|
||||
initializeTargetPassConfigPass(Registry);
|
||||
initializeTwoAddressInstructionPassPass(Registry);
|
||||
initializeUnreachableBlockElimPass(Registry);
|
||||
initializeUnreachableMachineBlockElimPass(Registry);
|
||||
|
@@ -125,27 +125,14 @@ LLVMTargetMachine::LLVMTargetMachine(const Target &T, StringRef Triple,
|
||||
"and that InitializeAllTargetMCs() is being invoked!");
|
||||
}
|
||||
|
||||
TargetPassConfig::TargetPassConfig(TargetMachine *tm, PassManagerBase &pm,
|
||||
bool DisableVerifyFlag)
|
||||
: TM(tm), PM(pm), DisableVerify(DisableVerifyFlag) {
|
||||
// Register all target independent codegen passes to activate their PassIDs.
|
||||
initializeCodeGen(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
/// createPassConfig - Create a pass configuration object to be used by
|
||||
/// addPassToEmitX methods for generating a pipeline of CodeGen passes.
|
||||
TargetPassConfig *LLVMTargetMachine::createPassConfig(PassManagerBase &PM,
|
||||
bool DisableVerify) {
|
||||
return new TargetPassConfig(this, PM, DisableVerify);
|
||||
}
|
||||
|
||||
bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
||||
formatted_raw_ostream &Out,
|
||||
CodeGenFileType FileType,
|
||||
bool DisableVerify) {
|
||||
// Add common CodeGen passes.
|
||||
MCContext *Context = 0;
|
||||
OwningPtr<TargetPassConfig> PassConfig(createPassConfig(PM, DisableVerify));
|
||||
TargetPassConfig *PassConfig = createPassConfig(PM, DisableVerify);
|
||||
PM.add(PassConfig);
|
||||
if (PassConfig->addCodeGenPasses(Context))
|
||||
return true;
|
||||
assert(Context != 0 && "Failed to get MCContext");
|
||||
|
@@ -14,9 +14,43 @@
|
||||
|
||||
#include "llvm/CodeGen/RegAllocRegistry.h"
|
||||
#include "llvm/CodeGen/Passes.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
//===---------------------------------------------------------------------===//
|
||||
/// TargetPassConfig
|
||||
//===---------------------------------------------------------------------===//
|
||||
|
||||
INITIALIZE_PASS(TargetPassConfig, "targetpassconfig",
|
||||
"Target Pass Configuration", false, false)
|
||||
char TargetPassConfig::ID = 0;
|
||||
|
||||
// Out of line virtual method.
|
||||
TargetPassConfig::~TargetPassConfig() {}
|
||||
|
||||
TargetPassConfig::TargetPassConfig(TargetMachine *tm, PassManagerBase &pm,
|
||||
bool DisableVerifyFlag)
|
||||
: ImmutablePass(ID), TM(tm), PM(pm), DisableVerify(DisableVerifyFlag) {
|
||||
// Register all target independent codegen passes to activate their PassIDs,
|
||||
// including this pass itself.
|
||||
initializeCodeGen(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
/// createPassConfig - Create a pass configuration object to be used by
|
||||
/// addPassToEmitX methods for generating a pipeline of CodeGen passes.
|
||||
///
|
||||
/// Targets may override this to extend TargetPassConfig.
|
||||
TargetPassConfig *LLVMTargetMachine::createPassConfig(PassManagerBase &PM,
|
||||
bool DisableVerify) {
|
||||
return new TargetPassConfig(this, PM, DisableVerify);
|
||||
}
|
||||
|
||||
TargetPassConfig::TargetPassConfig()
|
||||
: ImmutablePass(ID), PM(*(PassManagerBase*)0) {
|
||||
llvm_unreachable("TargetPassConfig should not be constructed on-the-fly");
|
||||
}
|
||||
|
||||
//===---------------------------------------------------------------------===//
|
||||
///
|
||||
/// RegisterRegAlloc class - Track the registration of register allocators.
|
||||
|
Reference in New Issue
Block a user