llvm.org GIT mirror llvm / 67d894e
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78928 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 10 years ago
4 changed file(s) with 22 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
1919 #define LLVM_TARGET_TARGETREGISTRY_H
2020
2121 #include "llvm/ADT/Triple.h"
22 // FIXME: We shouldn't need this header, but we need it until there is a
23 // different interface to get the TargetAsmInfo.
24 #include "llvm/Target/TargetMachine.h"
2522 #include
2623 #include
2724
2926 class FunctionPass;
3027 class MCAsmParser;
3128 class Module;
29 class TargetAsmInfo;
3230 class TargetAsmParser;
3331 class TargetMachine;
3432 class formatted_raw_ostream;
5250 typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T,
5351 const std::string &TT,
5452 const std::string &Features);
55 typedef FunctionPass *(*AsmPrinterCtorTy)(formatted_raw_ostream &,
56 TargetMachine &,
57 bool);
58 typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &,
59 MCAsmParser &);
53 typedef FunctionPass *(*AsmPrinterCtorTy)(formatted_raw_ostream &OS,
54 TargetMachine &TM,
55 const TargetAsmInfo *TAI,
56 bool VerboseAsm);
57 typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &T,
58 MCAsmParser &P);
6059 private:
6160 /// Next - The next registered target in the linked list, maintained by the
6261 /// TargetRegistry.
140139
141140 /// createAsmPrinter - Create a target specific assembly printer pass.
142141 FunctionPass *createAsmPrinter(formatted_raw_ostream &OS,
143 TargetMachine &M,
142 TargetMachine &TM,
143 const TargetAsmInfo *TAI,
144144 bool Verbose) const {
145145 if (!AsmPrinterCtorFn)
146146 return 0;
147 return AsmPrinterCtorFn(OS, M, Verbose);
147 return AsmPrinterCtorFn(OS, TM, TAI, Verbose);
148148 }
149149
150150 /// createAsmParser - Create a target specific assembly parser.
408408 private:
409409 static FunctionPass *Allocator(formatted_raw_ostream &OS,
410410 TargetMachine &TM,
411 const TargetAsmInfo *TAI,
411412 bool Verbose) {
412 return new AsmPrinterImpl(OS, TM, TM.getTargetAsmInfo(), Verbose);
413 return new AsmPrinterImpl(OS, TM, TAI, Verbose);
413414 }
414415 };
415416
105105 CodeGenOpt::Level OptLevel,
106106 bool Verbose,
107107 formatted_raw_ostream &Out) {
108 FunctionPass *Printer = getTarget().createAsmPrinter(Out, *this, Verbose);
108 FunctionPass *Printer =
109 getTarget().createAsmPrinter(Out, *this, getTargetAsmInfo(), Verbose);
109110 if (!Printer)
110111 return true;
111112
10891089 /// Darwin assembler can deal with.
10901090 ///
10911091 static FunctionPass *createPPCAsmPrinterPass(formatted_raw_ostream &o,
1092 TargetMachine &tm,
1093 bool verbose) {
1092 TargetMachine &tm,
1093 const TargetAsmInfo *tai,
1094 bool verbose) {
10941095 const PPCSubtarget *Subtarget = &tm.getSubtarget();
10951096
10961097 if (Subtarget->isDarwin())
1097 return new PPCDarwinAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
1098 return new PPCLinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
1098 return new PPCDarwinAsmPrinter(o, tm, tai, verbose);
1099 return new PPCLinuxAsmPrinter(o, tm, tai, verbose);
10991100 }
11001101
11011102 // Force static initialization.
11021103 extern "C" void LLVMInitializePowerPCAsmPrinter() {
11031104 TargetRegistry::RegisterAsmPrinter(ThePPC32Target, createPPCAsmPrinterPass);
1104
11051105 TargetRegistry::RegisterAsmPrinter(ThePPC64Target, createPPCAsmPrinterPass);
11061106 }
2626 ///
2727 static FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o,
2828 TargetMachine &tm,
29 const TargetAsmInfo *tai,
2930 bool verbose) {
3031 if (tm.getTargetAsmInfo()->getAssemblerDialect() == 1)
31 return new X86IntelAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
32 return new X86ATTAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
32 return new X86IntelAsmPrinter(o, tm, tai, verbose);
33 return new X86ATTAsmPrinter(o, tm, tai, verbose);
3334 }
3435
3536 // Force static initialization.