blob: 7dd8d2befa018f7d342644b479a17e603dc1db81 [file] [log] [blame]
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00001//===-- MipsTargetMachine.h - Define TargetMachine for Mips -00--*- C++ -*-===//
2//
3// 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.
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file declares the Mips specific subclass of TargetMachine.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MIPSTARGETMACHINE_H
15#define MIPSTARGETMACHINE_H
16
17#include "MipsSubtarget.h"
18#include "MipsInstrInfo.h"
19#include "MipsISelLowering.h"
20#include "llvm/Target/TargetMachine.h"
21#include "llvm/Target/TargetData.h"
22#include "llvm/Target/TargetFrameInfo.h"
23
24namespace llvm {
David Greene71847812009-07-14 20:18:05 +000025 class formatted_raw_ostream;
Owen Andersoncb371882008-08-21 00:14:44 +000026
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000027 class MipsTargetMachine : public LLVMTargetMachine {
28 MipsSubtarget Subtarget;
29 const TargetData DataLayout; // Calculates type size & alignment
30 MipsInstrInfo InstrInfo;
31 TargetFrameInfo FrameInfo;
32 MipsTargetLowering TLInfo;
33
34 protected:
35 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Chris Lattnere8f10182009-06-16 22:38:04 +000036 protected:
37 // To avoid having target depend on the asmprinter stuff libraries,
38 // asmprinter set this functions to ctor pointer at startup time if they are
39 // linked in.
David Greene71847812009-07-14 20:18:05 +000040 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
Stuart Hastings2286f8d2009-07-15 17:27:11 +000041 MipsTargetMachine &tm,
Chris Lattnere8f10182009-06-16 22:38:04 +000042 bool verbose);
43 static AsmPrinterCtorFn AsmPrinterCtor;
44
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000045 public:
Stuart Hastings2286f8d2009-07-15 17:27:11 +000046 MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle);
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000047
Chris Lattnere8f10182009-06-16 22:38:04 +000048 static void registerAsmPrinter(AsmPrinterCtorFn F) {
49 AsmPrinterCtor = F;
50 }
51
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000052 virtual const MipsInstrInfo *getInstrInfo() const
53 { return &InstrInfo; }
54 virtual const TargetFrameInfo *getFrameInfo() const
55 { return &FrameInfo; }
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000056 virtual const MipsSubtarget *getSubtargetImpl() const
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000057 { return &Subtarget; }
58 virtual const TargetData *getTargetData() const
59 { return &DataLayout;}
60
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000061 virtual const MipsRegisterInfo *getRegisterInfo() const {
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000062 return &InstrInfo.getRegisterInfo();
63 }
64
65 virtual MipsTargetLowering *getTargetLowering() const {
66 return const_cast<MipsTargetLowering*>(&TLInfo);
67 }
68
Stuart Hastings2286f8d2009-07-15 17:27:11 +000069 static unsigned getModuleMatchQuality(const Module &M);
70
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000071 // Pass Pipeline Configuration
Bill Wendling98a366d2009-04-29 23:29:43 +000072 virtual bool addInstSelector(PassManagerBase &PM,
73 CodeGenOpt::Level OptLevel);
74 virtual bool addPreEmitPass(PassManagerBase &PM,
75 CodeGenOpt::Level OptLevel);
76 virtual bool addAssemblyEmitter(PassManagerBase &PM,
77 CodeGenOpt::Level OptLevel,
David Greene71847812009-07-14 20:18:05 +000078 bool Verbose, formatted_raw_ostream &Out);
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000079 };
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +000080
81/// MipselTargetMachine - Mipsel target machine.
82///
83class MipselTargetMachine : public MipsTargetMachine {
84public:
Stuart Hastings2286f8d2009-07-15 17:27:11 +000085 MipselTargetMachine(const Module &M, const std::string &FS);
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +000086
87 static unsigned getModuleMatchQuality(const Module &M);
88};
89
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000090} // End llvm namespace
91
92#endif