diff options
author | Chris Lattner <sabre@nondot.org> | 2006-09-04 04:14:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-09-04 04:14:57 +0000 |
commit | 1911fd4f85aebcd4d7b8f27313c5a363eebf49cb (patch) | |
tree | 56477a21ba8925f2c2f1868f0e1ec2229349a50b /lib/Target/X86/X86TargetMachine.cpp | |
parent | dd842e12e1a054256314d36f3cab3d59da39fc68 (diff) | |
download | external_llvm-1911fd4f85aebcd4d7b8f27313c5a363eebf49cb.zip external_llvm-1911fd4f85aebcd4d7b8f27313c5a363eebf49cb.tar.gz external_llvm-1911fd4f85aebcd4d7b8f27313c5a363eebf49cb.tar.bz2 |
Completely rearchitect the interface between targets and the pass manager.
This pass:
1. Splits TargetMachine into TargetMachine (generic targets, can be implemented
any way, like the CBE) and LLVMTargetMachine (subclass of TM that is used by
things using libcodegen and other support).
2. Instead of having each target fully populate the passmgr for file or JIT
output, move all this to common code, and give targets hooks they can
implement.
3. Commonalize the target population stuff between file emission and JIT
emission.
4. All (native code) codegen stuff now happens in a FunctionPassManager, which
paves the way for "fast -O0" stuff in the CFE later, and now LLC could
lazily stream .bc files from disk to use less memory.
5. There are now many fewer #includes and the targets don't depend on the
scalar xforms or libanalysis anymore (but codegen does).
6. Changing common code generator pass ordering stuff no longer requires
touching all targets.
7. The JIT now has the option of "-fast" codegen or normal optimized codegen,
which is now orthogonal to the fact that JIT'ing is being done.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30081 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86TargetMachine.cpp')
-rw-r--r-- | lib/Target/X86/X86TargetMachine.cpp | 132 |
1 files changed, 22 insertions, 110 deletions
diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp index d12e964..83af172 100644 --- a/lib/Target/X86/X86TargetMachine.cpp +++ b/lib/Target/X86/X86TargetMachine.cpp @@ -20,8 +20,6 @@ #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Transforms/Scalar.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/ADT/Statistic.h" #include <iostream> using namespace llvm; @@ -33,9 +31,6 @@ extern "C" int X86TargetMachineModule; int X86TargetMachineModule = 0; namespace { - cl::opt<bool> DisableOutput("disable-x86-llc-output", cl::Hidden, - cl::desc("Disable the X86 asm printer, for use " - "when profiling the code generator.")); // Register the target. RegisterTarget<X86TargetMachine> X("x86", " IA-32 (Pentium and above)"); } @@ -79,121 +74,38 @@ X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS) setRelocationModel(Reloc::PIC_); } +//===----------------------------------------------------------------------===// +// Pass Pipeline Configuration +//===----------------------------------------------------------------------===// -// addPassesToEmitFile - We currently use all of the same passes as the JIT -// does to emit statically compiled machine code. -bool X86TargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out, - CodeGenFileType FileType, - bool Fast) { - if (FileType != TargetMachine::AssemblyFile && - FileType != TargetMachine::ObjectFile) return true; - - // Run loop strength reduction before anything else. - if (!Fast) PM.add(createLoopStrengthReducePass(&TLInfo)); - - // FIXME: Implement efficient support for garbage collection intrinsics. - PM.add(createLowerGCPass()); - - // FIXME: Implement the invoke/unwind instructions! - PM.add(createLowerInvokePass()); - - // Make sure that no unreachable blocks are instruction selected. - PM.add(createUnreachableBlockEliminationPass()); - +bool X86TargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) { // Install an instruction selector. PM.add(createX86ISelDag(*this, Fast)); - - // Print the instruction selected machine code... - if (PrintMachineCode) - PM.add(createMachineFunctionPrinterPass(&std::cerr)); - - // Perform register allocation to convert to a concrete x86 representation - PM.add(createRegisterAllocator()); - - if (PrintMachineCode) - PM.add(createMachineFunctionPrinterPass(&std::cerr)); - - PM.add(createX86FloatingPointStackifierPass()); - - if (PrintMachineCode) - PM.add(createMachineFunctionPrinterPass(&std::cerr)); - - // Insert prolog/epilog code. Eliminate abstract frame index references... - PM.add(createPrologEpilogCodeInserter()); - - if (PrintMachineCode) // Print the register-allocated code - PM.add(createX86CodePrinterPass(std::cerr, *this)); - - if (!DisableOutput) - switch (FileType) { - default: - assert(0 && "Unexpected filetype here!"); - case TargetMachine::AssemblyFile: - PM.add(createX86CodePrinterPass(Out, *this)); - break; - case TargetMachine::ObjectFile: - // FIXME: We only support emission of ELF files for now, this should check - // the target triple and decide on the format to write (e.g. COFF on - // win32 or Mach-O on darwin). - addX86ELFObjectWriterPass(PM, Out, *this); - break; - } - - // Delete machine code for this function - PM.add(createMachineCodeDeleter()); - - return false; // success! + return false; } -/// addPassesToJITCompile - Add passes to the specified pass manager to -/// implement a fast dynamic compiler for this target. Return true if this is -/// not supported for this target. -/// -void X86JITInfo::addPassesToJITCompile(FunctionPassManager &PM) { - // The JIT should use static relocation model. - TM.setRelocationModel(Reloc::Static); - - // Run loop strength reduction before anything else. - PM.add(createLoopStrengthReducePass(TM.getTargetLowering())); - - // FIXME: Implement efficient support for garbage collection intrinsics. - PM.add(createLowerGCPass()); - - // FIXME: Implement the invoke/unwind instructions! - PM.add(createLowerInvokePass()); - - // Make sure that no unreachable blocks are instruction selected. - PM.add(createUnreachableBlockEliminationPass()); - - // Install an instruction selector. - PM.add(createX86ISelDag(TM, false)); - - // Print the instruction selected machine code... - if (PrintMachineCode) - PM.add(createMachineFunctionPrinterPass(&std::cerr)); - - // Perform register allocation to convert to a concrete x86 representation - PM.add(createRegisterAllocator()); - - if (PrintMachineCode) - PM.add(createMachineFunctionPrinterPass(&std::cerr)); - +bool X86TargetMachine::addPostRegAlloc(FunctionPassManager &PM, bool Fast) { PM.add(createX86FloatingPointStackifierPass()); + return true; // -print-machineinstr should print after this. +} - if (PrintMachineCode) - PM.add(createMachineFunctionPrinterPass(&std::cerr)); - - // Insert prolog/epilog code. Eliminate abstract frame index references... - PM.add(createPrologEpilogCodeInserter()); +bool X86TargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast, + std::ostream &Out) { + PM.add(createX86CodePrinterPass(Out, *this)); + return false; +} - if (PrintMachineCode) // Print the register-allocated code - PM.add(createX86CodePrinterPass(std::cerr, TM)); +bool X86TargetMachine::addObjectWriter(FunctionPassManager &PM, bool Fast, + std::ostream &Out) { + if (Subtarget.isTargetELF()) { + addX86ELFObjectWriterPass(PM, Out, *this); + return false; + } + return true; } -bool X86TargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM, - MachineCodeEmitter &MCE) { +bool X86TargetMachine::addCodeEmitter(FunctionPassManager &PM, bool Fast, + MachineCodeEmitter &MCE) { PM.add(createX86CodeEmitterPass(*this, MCE)); - // Delete machine code for this function - PM.add(createMachineCodeDeleter()); return false; } |