[llvm-commits] [llvm] r78928 - in /llvm/trunk: include/llvm/Target/TargetRegistry.h lib/CodeGen/LLVMTargetMachine.cpp lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
Daniel Dunbar
daniel at zuster.org
Thu Aug 13 12:38:51 PDT 2009
Author: ddunbar
Date: Thu Aug 13 14:38:51 2009
New Revision: 78928
URL: http://llvm.org/viewvc/llvm-project?rev=78928&view=rev
Log:
TargetRegistry: Reorganize AsmPrinter construction so that clients pass in the
TargetAsmInfo. This eliminates a dependency on TargetMachine.h from
TargetRegistry.h, which technically was a layering violation.
- Clients probably can only sensibly pass in the same TargetAsmInfo as the
TargetMachine has, but there are only limited clients of this API.
Modified:
llvm/trunk/include/llvm/Target/TargetRegistry.h
llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
Modified: llvm/trunk/include/llvm/Target/TargetRegistry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegistry.h?rev=78928&r1=78927&r2=78928&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetRegistry.h (original)
+++ llvm/trunk/include/llvm/Target/TargetRegistry.h Thu Aug 13 14:38:51 2009
@@ -20,9 +20,6 @@
#define LLVM_TARGET_TARGETREGISTRY_H
#include "llvm/ADT/Triple.h"
-// FIXME: We shouldn't need this header, but we need it until there is a
-// different interface to get the TargetAsmInfo.
-#include "llvm/Target/TargetMachine.h"
#include <string>
#include <cassert>
@@ -30,6 +27,7 @@
class FunctionPass;
class MCAsmParser;
class Module;
+ class TargetAsmInfo;
class TargetAsmParser;
class TargetMachine;
class formatted_raw_ostream;
@@ -53,11 +51,12 @@
typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T,
const std::string &TT,
const std::string &Features);
- typedef FunctionPass *(*AsmPrinterCtorTy)(formatted_raw_ostream &,
- TargetMachine &,
- bool);
- typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &,
- MCAsmParser &);
+ typedef FunctionPass *(*AsmPrinterCtorTy)(formatted_raw_ostream &OS,
+ TargetMachine &TM,
+ const TargetAsmInfo *TAI,
+ bool VerboseAsm);
+ typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &T,
+ MCAsmParser &P);
private:
/// Next - The next registered target in the linked list, maintained by the
/// TargetRegistry.
@@ -141,11 +140,12 @@
/// createAsmPrinter - Create a target specific assembly printer pass.
FunctionPass *createAsmPrinter(formatted_raw_ostream &OS,
- TargetMachine &M,
+ TargetMachine &TM,
+ const TargetAsmInfo *TAI,
bool Verbose) const {
if (!AsmPrinterCtorFn)
return 0;
- return AsmPrinterCtorFn(OS, M, Verbose);
+ return AsmPrinterCtorFn(OS, TM, TAI, Verbose);
}
/// createAsmParser - Create a target specific assembly parser.
@@ -409,8 +409,9 @@
private:
static FunctionPass *Allocator(formatted_raw_ostream &OS,
TargetMachine &TM,
+ const TargetAsmInfo *TAI,
bool Verbose) {
- return new AsmPrinterImpl(OS, TM, TM.getTargetAsmInfo(), Verbose);
+ return new AsmPrinterImpl(OS, TM, TAI, Verbose);
}
};
Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=78928&r1=78927&r2=78928&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Thu Aug 13 14:38:51 2009
@@ -106,7 +106,8 @@
CodeGenOpt::Level OptLevel,
bool Verbose,
formatted_raw_ostream &Out) {
- FunctionPass *Printer = getTarget().createAsmPrinter(Out, *this, Verbose);
+ FunctionPass *Printer =
+ getTarget().createAsmPrinter(Out, *this, getTargetAsmInfo(), Verbose);
if (!Printer)
return true;
Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=78928&r1=78927&r2=78928&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Thu Aug 13 14:38:51 2009
@@ -1090,18 +1090,18 @@
/// Darwin assembler can deal with.
///
static FunctionPass *createPPCAsmPrinterPass(formatted_raw_ostream &o,
- TargetMachine &tm,
- bool verbose) {
+ TargetMachine &tm,
+ const TargetAsmInfo *tai,
+ bool verbose) {
const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>();
if (Subtarget->isDarwin())
- return new PPCDarwinAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
- return new PPCLinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
+ return new PPCDarwinAsmPrinter(o, tm, tai, verbose);
+ return new PPCLinuxAsmPrinter(o, tm, tai, verbose);
}
// Force static initialization.
extern "C" void LLVMInitializePowerPCAsmPrinter() {
TargetRegistry::RegisterAsmPrinter(ThePPC32Target, createPPCAsmPrinterPass);
-
TargetRegistry::RegisterAsmPrinter(ThePPC64Target, createPPCAsmPrinterPass);
}
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=78928&r1=78927&r2=78928&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Thu Aug 13 14:38:51 2009
@@ -27,10 +27,11 @@
///
static FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o,
TargetMachine &tm,
+ const TargetAsmInfo *tai,
bool verbose) {
if (tm.getTargetAsmInfo()->getAssemblerDialect() == 1)
- return new X86IntelAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
- return new X86ATTAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
+ return new X86IntelAsmPrinter(o, tm, tai, verbose);
+ return new X86ATTAsmPrinter(o, tm, tai, verbose);
}
// Force static initialization.
More information about the llvm-commits
mailing list