blob: 086d2f4cf81d602d912a5df1e98dc19fa6acbe0a [file] [log] [blame]
Nate Begeman21e463b2005-10-16 05:39:50 +00001//===-- PPCTargetMachine.h - Define TargetMachine for PowerPC -----*- C++ -*-=//
Misha Brukmanb5f662f2005-04-21 23:30:14 +00002//
Misha Brukman3d9a6c22004-08-11 00:09:42 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmanb5f662f2005-04-21 23:30:14 +00007//
Misha Brukman3d9a6c22004-08-11 00:09:42 +00008//===----------------------------------------------------------------------===//
Misha Brukmanb5f662f2005-04-21 23:30:14 +00009//
Misha Brukmanf2ccb772004-08-17 04:55:41 +000010// This file declares the PowerPC specific subclass of TargetMachine.
Misha Brukman3d9a6c22004-08-11 00:09:42 +000011//
12//===----------------------------------------------------------------------===//
13
Nate Begeman21e463b2005-10-16 05:39:50 +000014#ifndef PPC_TARGETMACHINE_H
15#define PPC_TARGETMACHINE_H
Misha Brukman3d9a6c22004-08-11 00:09:42 +000016
Chris Lattner26689592005-10-14 23:51:18 +000017#include "PPCFrameInfo.h"
18#include "PPCSubtarget.h"
Chris Lattnerb9459b72005-10-14 23:53:41 +000019#include "PPCJITInfo.h"
Chris Lattner16e71f22005-10-14 23:59:06 +000020#include "PPCInstrInfo.h"
Evan Chengc4c62572006-03-13 23:20:37 +000021#include "PPCISelLowering.h"
Bill Wendling0ea18ff2007-01-24 03:41:36 +000022#include "PPCMachOWriterInfo.h"
Chris Lattnerec4b73c2005-10-14 23:44:05 +000023#include "llvm/Target/TargetMachine.h"
Owen Anderson07000c62006-05-12 06:33:49 +000024#include "llvm/Target/TargetData.h"
Misha Brukman3d9a6c22004-08-11 00:09:42 +000025
26namespace llvm {
Chris Lattnerde123822005-10-15 21:58:54 +000027class PassManager;
Chris Lattnerec4b73c2005-10-14 23:44:05 +000028class GlobalValue;
Misha Brukman3d9a6c22004-08-11 00:09:42 +000029
Chris Lattner94de9a82006-06-16 01:37:27 +000030/// PPCTargetMachine - Common code between 32-bit and 64-bit PowerPC targets.
31///
Chris Lattner1911fd42006-09-04 04:14:57 +000032class PPCTargetMachine : public LLVMTargetMachine {
Chris Lattner94de9a82006-06-16 01:37:27 +000033 PPCSubtarget Subtarget;
34 const TargetData DataLayout; // Calculates type size & alignment
35 PPCInstrInfo InstrInfo;
36 PPCFrameInfo FrameInfo;
37 PPCJITInfo JITInfo;
38 PPCTargetLowering TLInfo;
39 InstrItineraryData InstrItins;
Bill Wendling0ea18ff2007-01-24 03:41:36 +000040 PPCMachOWriterInfo MachOWriterInfo;
41
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000042protected:
43 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikov06be9972008-08-17 13:54:28 +000044
45 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
46 // set this functions to ctor pointer at startup time if they are linked in.
Owen Andersoncb371882008-08-21 00:14:44 +000047 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
Bill Wendling57f0db82009-02-24 08:30:20 +000048 PPCTargetMachine &tm,
Bill Wendling98a366d2009-04-29 23:29:43 +000049 CodeGenOpt::Level OptLevel,
50 bool verbose);
Anton Korobeynikov06be9972008-08-17 13:54:28 +000051 static AsmPrinterCtorFn AsmPrinterCtor;
52
Chris Lattnerec4b73c2005-10-14 23:44:05 +000053public:
Chris Lattner94de9a82006-06-16 01:37:27 +000054 PPCTargetMachine(const Module &M, const std::string &FS, bool is64Bit);
Nate Begeman21e463b2005-10-16 05:39:50 +000055
56 virtual const PPCInstrInfo *getInstrInfo() const { return &InstrInfo; }
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000057 virtual const PPCFrameInfo *getFrameInfo() const { return &FrameInfo; }
58 virtual PPCJITInfo *getJITInfo() { return &JITInfo; }
Chris Lattnerb65e7252006-05-12 21:09:57 +000059 virtual PPCTargetLowering *getTargetLowering() const {
60 return const_cast<PPCTargetLowering*>(&TLInfo);
61 }
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000062 virtual const PPCRegisterInfo *getRegisterInfo() const {
Misha Brukmanf2ccb772004-08-17 04:55:41 +000063 return &InstrInfo.getRegisterInfo();
64 }
Chris Lattner94de9a82006-06-16 01:37:27 +000065
66 virtual const TargetData *getTargetData() const { return &DataLayout; }
67 virtual const PPCSubtarget *getSubtargetImpl() const { return &Subtarget; }
Jim Laskey6cee6302005-11-01 20:06:59 +000068 virtual const InstrItineraryData getInstrItineraryData() const {
69 return InstrItins;
70 }
Bill Wendling0ea18ff2007-01-24 03:41:36 +000071 virtual const PPCMachOWriterInfo *getMachOWriterInfo() const {
72 return &MachOWriterInfo;
73 }
Anton Korobeynikov06be9972008-08-17 13:54:28 +000074
75 static void registerAsmPrinter(AsmPrinterCtorFn F) {
76 AsmPrinterCtor = F;
77 }
78
Chris Lattner1911fd42006-09-04 04:14:57 +000079 // Pass Pipeline Configuration
Bill Wendling98a366d2009-04-29 23:29:43 +000080 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
81 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
82 virtual bool addAssemblyEmitter(PassManagerBase &PM,
83 CodeGenOpt::Level OptLevel,
Evan Cheng42bf74b2009-03-25 01:47:28 +000084 bool Verbose, raw_ostream &Out);
Bill Wendling98a366d2009-04-29 23:29:43 +000085 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
Evan Cheng8bd60352007-07-20 21:56:13 +000086 bool DumpAsm, MachineCodeEmitter &MCE);
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000087 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
88 bool DumpAsm, JITCodeEmitter &JCE);
Bill Wendling98a366d2009-04-29 23:29:43 +000089 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
90 CodeGenOpt::Level OptLevel,
Evan Cheng8bd60352007-07-20 21:56:13 +000091 bool DumpAsm, MachineCodeEmitter &MCE);
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000092 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
93 CodeGenOpt::Level OptLevel,
94 bool DumpAsm, JITCodeEmitter &JCE);
Dan Gohman50cdabc2007-11-19 20:46:23 +000095 virtual bool getEnableTailMergeDefault() const;
Misha Brukman3d9a6c22004-08-11 00:09:42 +000096};
Chris Lattner94de9a82006-06-16 01:37:27 +000097
98/// PPC32TargetMachine - PowerPC 32-bit target machine.
99///
100class PPC32TargetMachine : public PPCTargetMachine {
101public:
102 PPC32TargetMachine(const Module &M, const std::string &FS);
Nate Begeman21e463b2005-10-16 05:39:50 +0000103
Chris Lattner94de9a82006-06-16 01:37:27 +0000104 static unsigned getJITMatchQuality();
105 static unsigned getModuleMatchQuality(const Module &M);
106};
107
108/// PPC64TargetMachine - PowerPC 64-bit target machine.
109///
110class PPC64TargetMachine : public PPCTargetMachine {
111public:
112 PPC64TargetMachine(const Module &M, const std::string &FS);
113
114 static unsigned getJITMatchQuality();
115 static unsigned getModuleMatchQuality(const Module &M);
116};
117
Misha Brukman3d9a6c22004-08-11 00:09:42 +0000118} // end namespace llvm
119
120#endif