1 //===-- PPCTargetMachine.cpp - Define TargetMachine for PowerPC -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Top-level implementation for the PowerPC target.
12 //===----------------------------------------------------------------------===//
15 #include "PPCTargetMachine.h"
16 #include "llvm/PassManager.h"
17 #include "llvm/MC/MCStreamer.h"
18 #include "llvm/Target/TargetOptions.h"
19 #include "llvm/Support/FormattedStream.h"
20 #include "llvm/Support/TargetRegistry.h"
23 extern "C" void LLVMInitializePowerPCTarget() {
24 // Register the targets
25 RegisterTargetMachine<PPC32TargetMachine> A(ThePPC32Target);
26 RegisterTargetMachine<PPC64TargetMachine> B(ThePPC64Target);
29 PPCTargetMachine::PPCTargetMachine(const Target &T, StringRef TT,
30 StringRef CPU, StringRef FS,
31 Reloc::Model RM, CodeModel::Model CM,
34 : LLVMTargetMachine(T, TT, CPU, FS, RM, CM, OL),
35 Subtarget(TT, CPU, FS, is64Bit),
36 DataLayout(Subtarget.getTargetDataString()), InstrInfo(*this),
37 FrameLowering(Subtarget), JITInfo(*this, is64Bit),
38 TLInfo(*this), TSInfo(*this),
39 InstrItins(Subtarget.getInstrItineraryData()) {
42 /// Override this for PowerPC. Tail merging happily breaks up instruction issue
43 /// groups, which typically degrades performance.
44 bool PPCTargetMachine::getEnableTailMergeDefault() const { return false; }
46 PPC32TargetMachine::PPC32TargetMachine(const Target &T, StringRef TT,
47 StringRef CPU, StringRef FS,
48 Reloc::Model RM, CodeModel::Model CM,
50 : PPCTargetMachine(T, TT, CPU, FS, RM, CM, OL, false) {
54 PPC64TargetMachine::PPC64TargetMachine(const Target &T, StringRef TT,
55 StringRef CPU, StringRef FS,
56 Reloc::Model RM, CodeModel::Model CM,
58 : PPCTargetMachine(T, TT, CPU, FS, RM, CM, OL, true) {
62 //===----------------------------------------------------------------------===//
63 // Pass Pipeline Configuration
64 //===----------------------------------------------------------------------===//
66 bool PPCTargetMachine::addInstSelector(PassManagerBase &PM) {
67 // Install an instruction selector.
68 PM.add(createPPCISelDag(*this));
72 bool PPCTargetMachine::addPreEmitPass(PassManagerBase &PM) {
73 // Must run branch selection immediately preceding the asm printer.
74 PM.add(createPPCBranchSelectionPass());
78 bool PPCTargetMachine::addCodeEmitter(PassManagerBase &PM,
79 JITCodeEmitter &JCE) {
80 // FIXME: This should be moved to TargetJITInfo!!
81 if (Subtarget.isPPC64())
82 // Temporary workaround for the inability of PPC64 JIT to handle jump
84 DisableJumpTables = true;
86 // Inform the subtarget that we are in JIT mode. FIXME: does this break macho
88 Subtarget.SetJITMode();
90 // Machine code emitter pass for PowerPC.
91 PM.add(createPPCJITCodeEmitterPass(*this, JCE));