blob: 6e2562a312e03b5992022b88577489f0cc79af3f [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,
Daniel Dunbar51b198a2009-07-15 20:24:03 +000041 TargetMachine &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:
Daniel Dunbar51b198a2009-07-15 20:24:03 +000046 MipsTargetMachine(const Target &T, const Module &M, const std::string &FS,
47 bool isLittle);
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000048
Chris Lattnere8f10182009-06-16 22:38:04 +000049 static void registerAsmPrinter(AsmPrinterCtorFn F) {
50 AsmPrinterCtor = F;
51 }
52
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000053 virtual const MipsInstrInfo *getInstrInfo() const
54 { return &InstrInfo; }
55 virtual const TargetFrameInfo *getFrameInfo() const
56 { return &FrameInfo; }
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000057 virtual const MipsSubtarget *getSubtargetImpl() const
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000058 { return &Subtarget; }
59 virtual const TargetData *getTargetData() const
60 { return &DataLayout;}
61
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000062 virtual const MipsRegisterInfo *getRegisterInfo() const {
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000063 return &InstrInfo.getRegisterInfo();
64 }
65
66 virtual MipsTargetLowering *getTargetLowering() const {
67 return const_cast<MipsTargetLowering*>(&TLInfo);
68 }
69
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000070 // Pass Pipeline Configuration
Bill Wendling98a366d2009-04-29 23:29:43 +000071 virtual bool addInstSelector(PassManagerBase &PM,
72 CodeGenOpt::Level OptLevel);
73 virtual bool addPreEmitPass(PassManagerBase &PM,
74 CodeGenOpt::Level OptLevel);
75 virtual bool addAssemblyEmitter(PassManagerBase &PM,
76 CodeGenOpt::Level OptLevel,
David Greene71847812009-07-14 20:18:05 +000077 bool Verbose, formatted_raw_ostream &Out);
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000078 };
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +000079
80/// MipselTargetMachine - Mipsel target machine.
81///
82class MipselTargetMachine : public MipsTargetMachine {
83public:
Daniel Dunbar51b198a2009-07-15 20:24:03 +000084 MipselTargetMachine(const Target &T, const Module &M, const std::string &FS);
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +000085
86 static unsigned getModuleMatchQuality(const Module &M);
87};
88
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000089} // End llvm namespace
90
91#endif