blob: e6f61029f3b20c8c779e7b12e09d40aae962011e [file] [log] [blame]
Nate Begeman6cca84e2005-10-16 05:39:50 +00001//===-- PPCTargetMachine.h - Define TargetMachine for PowerPC -----*- C++ -*-=//
Misha Brukmanb4402432005-04-21 23:30:14 +00002//
Misha Brukmand022a5a2004-08-11 00:09:42 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Brukmanb4402432005-04-21 23:30:14 +00007//
Misha Brukmand022a5a2004-08-11 00:09:42 +00008//===----------------------------------------------------------------------===//
Misha Brukmanb4402432005-04-21 23:30:14 +00009//
Misha Brukman116f9272004-08-17 04:55:41 +000010// This file declares the PowerPC specific subclass of TargetMachine.
Misha Brukmand022a5a2004-08-11 00:09:42 +000011//
12//===----------------------------------------------------------------------===//
13
Nate Begeman6cca84e2005-10-16 05:39:50 +000014#ifndef PPC_TARGETMACHINE_H
15#define PPC_TARGETMACHINE_H
Misha Brukmand022a5a2004-08-11 00:09:42 +000016
Chris Lattnerbfca1ab2005-10-14 23:51:18 +000017#include "PPCFrameInfo.h"
18#include "PPCSubtarget.h"
Chris Lattner0aa794b2005-10-14 23:53:41 +000019#include "PPCJITInfo.h"
Chris Lattner6f3b9542005-10-14 23:59:06 +000020#include "PPCInstrInfo.h"
Evan Cheng2dd2c652006-03-13 23:20:37 +000021#include "PPCISelLowering.h"
Bill Wendling40cb8112007-01-24 03:41:36 +000022#include "PPCMachOWriterInfo.h"
Chris Lattner2ed745a2005-10-14 23:44:05 +000023#include "llvm/Target/TargetMachine.h"
Owen Anderson8c2c1e92006-05-12 06:33:49 +000024#include "llvm/Target/TargetData.h"
Misha Brukmand022a5a2004-08-11 00:09:42 +000025
26namespace llvm {
Chris Lattner03354282005-10-15 21:58:54 +000027class PassManager;
Chris Lattner2ed745a2005-10-14 23:44:05 +000028class GlobalValue;
Misha Brukmand022a5a2004-08-11 00:09:42 +000029
Chris Lattner0c4aa142006-06-16 01:37:27 +000030/// PPCTargetMachine - Common code between 32-bit and 64-bit PowerPC targets.
31///
Chris Lattner12e97302006-09-04 04:14:57 +000032class PPCTargetMachine : public LLVMTargetMachine {
Chris Lattner0c4aa142006-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 Wendling40cb8112007-01-24 03:41:36 +000040 PPCMachOWriterInfo MachOWriterInfo;
41
Jim Laskeyae92ce82006-09-07 23:39:26 +000042protected:
43 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikov28dc9d02008-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.
David Greenea31f96c2009-07-14 20:18:05 +000047 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
Bill Wendlingc5437ea2009-02-24 08:30:20 +000048 PPCTargetMachine &tm,
Bill Wendling026e5d72009-04-29 23:29:43 +000049 bool verbose);
Anton Korobeynikov28dc9d02008-08-17 13:54:28 +000050 static AsmPrinterCtorFn AsmPrinterCtor;
51
Chris Lattner2ed745a2005-10-14 23:44:05 +000052public:
Chris Lattner0c4aa142006-06-16 01:37:27 +000053 PPCTargetMachine(const Module &M, const std::string &FS, bool is64Bit);
Nate Begeman6cca84e2005-10-16 05:39:50 +000054
55 virtual const PPCInstrInfo *getInstrInfo() const { return &InstrInfo; }
Dan Gohmaneabd6472008-05-14 01:58:56 +000056 virtual const PPCFrameInfo *getFrameInfo() const { return &FrameInfo; }
57 virtual PPCJITInfo *getJITInfo() { return &JITInfo; }
Chris Lattnerae48a892006-05-12 21:09:57 +000058 virtual PPCTargetLowering *getTargetLowering() const {
59 return const_cast<PPCTargetLowering*>(&TLInfo);
60 }
Dan Gohmaneabd6472008-05-14 01:58:56 +000061 virtual const PPCRegisterInfo *getRegisterInfo() const {
Misha Brukman116f9272004-08-17 04:55:41 +000062 return &InstrInfo.getRegisterInfo();
63 }
Chris Lattner0c4aa142006-06-16 01:37:27 +000064
65 virtual const TargetData *getTargetData() const { return &DataLayout; }
66 virtual const PPCSubtarget *getSubtargetImpl() const { return &Subtarget; }
Jim Laskey802748c2005-11-01 20:06:59 +000067 virtual const InstrItineraryData getInstrItineraryData() const {
68 return InstrItins;
69 }
Bill Wendling40cb8112007-01-24 03:41:36 +000070 virtual const PPCMachOWriterInfo *getMachOWriterInfo() const {
71 return &MachOWriterInfo;
72 }
Anton Korobeynikov28dc9d02008-08-17 13:54:28 +000073
74 static void registerAsmPrinter(AsmPrinterCtorFn F) {
75 AsmPrinterCtor = F;
76 }
77
Chris Lattner12e97302006-09-04 04:14:57 +000078 // Pass Pipeline Configuration
Bill Wendling026e5d72009-04-29 23:29:43 +000079 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
80 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
81 virtual bool addAssemblyEmitter(PassManagerBase &PM,
82 CodeGenOpt::Level OptLevel,
David Greenea31f96c2009-07-14 20:18:05 +000083 bool Verbose, formatted_raw_ostream &Out);
Bill Wendling026e5d72009-04-29 23:29:43 +000084 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
Evan Cheng9d5df0a2007-07-20 21:56:13 +000085 bool DumpAsm, MachineCodeEmitter &MCE);
Bruno Cardoso Lopesa194c3a2009-05-30 20:51:52 +000086 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
87 bool DumpAsm, JITCodeEmitter &JCE);
Bruno Cardoso Lopes5661ea62009-07-06 05:09:34 +000088 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
89 bool DumpAsm, ObjectCodeEmitter &OCE);
Bill Wendling026e5d72009-04-29 23:29:43 +000090 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
91 CodeGenOpt::Level OptLevel,
Evan Cheng9d5df0a2007-07-20 21:56:13 +000092 bool DumpAsm, MachineCodeEmitter &MCE);
Bruno Cardoso Lopesa194c3a2009-05-30 20:51:52 +000093 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
94 CodeGenOpt::Level OptLevel,
95 bool DumpAsm, JITCodeEmitter &JCE);
Bruno Cardoso Lopes5661ea62009-07-06 05:09:34 +000096 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
97 CodeGenOpt::Level OptLevel,
98 bool DumpAsm, ObjectCodeEmitter &OCE);
Dan Gohmanaad83c82007-11-19 20:46:23 +000099 virtual bool getEnableTailMergeDefault() const;
Misha Brukmand022a5a2004-08-11 00:09:42 +0000100};
Chris Lattner0c4aa142006-06-16 01:37:27 +0000101
102/// PPC32TargetMachine - PowerPC 32-bit target machine.
103///
104class PPC32TargetMachine : public PPCTargetMachine {
105public:
106 PPC32TargetMachine(const Module &M, const std::string &FS);
Nate Begeman6cca84e2005-10-16 05:39:50 +0000107
Chris Lattner0c4aa142006-06-16 01:37:27 +0000108 static unsigned getJITMatchQuality();
109 static unsigned getModuleMatchQuality(const Module &M);
110};
111
112/// PPC64TargetMachine - PowerPC 64-bit target machine.
113///
114class PPC64TargetMachine : public PPCTargetMachine {
115public:
116 PPC64TargetMachine(const Module &M, const std::string &FS);
117
118 static unsigned getJITMatchQuality();
119 static unsigned getModuleMatchQuality(const Module &M);
120};
121
Misha Brukmand022a5a2004-08-11 00:09:42 +0000122} // end namespace llvm
123
124#endif