mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
Move ARM to pluggable asmprinter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54889 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
676fa7df9c
commit
0bd89712c0
@ -31,6 +31,9 @@ static cl::opt<bool> DisableIfConversion("disable-arm-if-conversion",cl::Hidden,
|
||||
static RegisterTarget<ARMTargetMachine> X("arm", " ARM");
|
||||
static RegisterTarget<ThumbTargetMachine> Y("thumb", " Thumb");
|
||||
|
||||
// No assembler printer by default
|
||||
ARMTargetMachine::AsmPrinterCtorFn ARMTargetMachine::AsmPrinterCtor = 0;
|
||||
|
||||
/// ThumbTargetMachine - Create an Thumb architecture model.
|
||||
///
|
||||
unsigned ThumbTargetMachine::getJITMatchQuality() {
|
||||
@ -142,7 +145,10 @@ bool ARMTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
|
||||
bool ARMTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||
std::ostream &Out) {
|
||||
// Output assembly language.
|
||||
PM.add(createARMCodePrinterPass(Out, *this));
|
||||
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
||||
if (AsmPrinterCtor)
|
||||
PM.add(AsmPrinterCtor(Out, *this));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -154,8 +160,12 @@ bool ARMTargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
|
||||
|
||||
// Machine code emitter pass for ARM.
|
||||
PM.add(createARMCodeEmitterPass(*this, MCE));
|
||||
if (DumpAsm)
|
||||
PM.add(createARMCodePrinterPass(*cerr.stream(), *this));
|
||||
if (DumpAsm) {
|
||||
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
||||
if (AsmPrinterCtor)
|
||||
PM.add(AsmPrinterCtor(*cerr.stream(), *this));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -163,7 +173,11 @@ bool ARMTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
|
||||
bool DumpAsm, MachineCodeEmitter &MCE) {
|
||||
// Machine code emitter pass for ARM.
|
||||
PM.add(createARMCodeEmitterPass(*this, MCE));
|
||||
if (DumpAsm)
|
||||
PM.add(createARMCodePrinterPass(*cerr.stream(), *this));
|
||||
if (DumpAsm) {
|
||||
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
||||
if (AsmPrinterCtor)
|
||||
PM.add(AsmPrinterCtor(*cerr.stream(), *this));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -35,6 +35,13 @@ class ARMTargetMachine : public LLVMTargetMachine {
|
||||
ARMJITInfo JITInfo;
|
||||
ARMTargetLowering TLInfo;
|
||||
|
||||
protected:
|
||||
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
|
||||
// set this functions to ctor pointer at startup time if they are linked in.
|
||||
typedef FunctionPass *(*AsmPrinterCtorFn)(std::ostream &o,
|
||||
ARMTargetMachine &tm);
|
||||
static AsmPrinterCtorFn AsmPrinterCtor;
|
||||
|
||||
public:
|
||||
ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false);
|
||||
|
||||
@ -46,18 +53,23 @@ public:
|
||||
}
|
||||
virtual const TargetData *getTargetData() const { return &DataLayout; }
|
||||
virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
|
||||
virtual ARMTargetLowering *getTargetLowering() const {
|
||||
return const_cast<ARMTargetLowering*>(&TLInfo);
|
||||
virtual ARMTargetLowering *getTargetLowering() const {
|
||||
return const_cast<ARMTargetLowering*>(&TLInfo);
|
||||
}
|
||||
|
||||
static void registerAsmPrinter(AsmPrinterCtorFn F) {
|
||||
AsmPrinterCtor = F;
|
||||
}
|
||||
|
||||
static unsigned getModuleMatchQuality(const Module &M);
|
||||
static unsigned getJITMatchQuality();
|
||||
|
||||
virtual const TargetAsmInfo *createTargetAsmInfo() const;
|
||||
|
||||
|
||||
// Pass Pipeline Configuration
|
||||
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
||||
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
||||
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||
std::ostream &Out);
|
||||
virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
|
||||
bool DumpAsm, MachineCodeEmitter &MCE);
|
||||
|
@ -174,16 +174,6 @@ namespace {
|
||||
|
||||
#include "ARMGenAsmWriter.inc"
|
||||
|
||||
/// createARMCodePrinterPass - Returns a pass that prints the ARM
|
||||
/// assembly code for a MachineFunction to the given output stream,
|
||||
/// using the given target machine description. This should work
|
||||
/// regardless of whether the function is in SSA form.
|
||||
///
|
||||
FunctionPass *llvm::createARMCodePrinterPass(std::ostream &o,
|
||||
ARMTargetMachine &tm) {
|
||||
return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||
}
|
||||
|
||||
// Substitute old hook with new one temporary
|
||||
std::string ARMAsmPrinter::getSectionForFunction(const Function &F) const {
|
||||
return TAI->SectionForGlobal(&F);
|
||||
@ -1028,3 +1018,21 @@ bool ARMAsmPrinter::doFinalization(Module &M) {
|
||||
|
||||
return AsmPrinter::doFinalization(M);
|
||||
}
|
||||
|
||||
/// createARMCodePrinterPass - Returns a pass that prints the ARM
|
||||
/// assembly code for a MachineFunction to the given output stream,
|
||||
/// using the given target machine description. This should work
|
||||
/// regardless of whether the function is in SSA form.
|
||||
///
|
||||
FunctionPass *llvm::createARMCodePrinterPass(std::ostream &o,
|
||||
ARMTargetMachine &tm) {
|
||||
return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||
}
|
||||
|
||||
namespace {
|
||||
static struct Register {
|
||||
Register() {
|
||||
ARMTargetMachine::registerAsmPrinter(createARMCodePrinterPass);
|
||||
}
|
||||
} Registrator;
|
||||
}
|
15
lib/Target/ARM/AsmPrinter/Makefile
Normal file
15
lib/Target/ARM/AsmPrinter/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
##===- lib/Target/X86/Makefile -----------------------------*- Makefile -*-===##
|
||||
#
|
||||
# The LLVM Compiler Infrastructure
|
||||
#
|
||||
# This file is distributed under the University of Illinois Open Source
|
||||
# License. See LICENSE.TXT for details.
|
||||
#
|
||||
##===----------------------------------------------------------------------===##
|
||||
LEVEL = ../../../..
|
||||
LIBRARYNAME = LLVMARMAsmPrinter
|
||||
|
||||
# Hack: we need to include 'main' x86 target directory to grab private headers
|
||||
CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
@ -8,7 +8,7 @@
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
LEVEL = ../../..
|
||||
LIBRARYNAME = LLVMARM
|
||||
LIBRARYNAME = LLVMARMCodeGen
|
||||
TARGET = ARM
|
||||
|
||||
# Make sure that tblgen is run, first thing.
|
||||
@ -17,4 +17,6 @@ BUILT_SOURCES = ARMGenRegisterInfo.h.inc ARMGenRegisterNames.inc \
|
||||
ARMGenInstrInfo.inc ARMGenAsmWriter.inc \
|
||||
ARMGenDAGISel.inc ARMGenSubtarget.inc
|
||||
|
||||
DIRS = AsmPrinter
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
Loading…
Reference in New Issue
Block a user