blob: 85fafadde7c4bc5a0f5cc2a770d52c59fe158eaa [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 {
Owen Andersoncb371882008-08-21 00:14:44 +000025 class raw_ostream;
26
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.
40 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
41 MipsTargetMachine &tm,
42 CodeGenOpt::Level OptLevel,
43 bool verbose);
44 static AsmPrinterCtorFn AsmPrinterCtor;
45
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000046 public:
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +000047 MipsTargetMachine(const Module &M, const std::string &FS, 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
70 static unsigned getModuleMatchQuality(const Module &M);
71
72 // Pass Pipeline Configuration
Bill Wendling98a366d2009-04-29 23:29:43 +000073 virtual bool addInstSelector(PassManagerBase &PM,
74 CodeGenOpt::Level OptLevel);
75 virtual bool addPreEmitPass(PassManagerBase &PM,
76 CodeGenOpt::Level OptLevel);
77 virtual bool addAssemblyEmitter(PassManagerBase &PM,
78 CodeGenOpt::Level OptLevel,
Evan Cheng42bf74b2009-03-25 01:47:28 +000079 bool Verbose, raw_ostream &Out);
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000080 };
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +000081
82/// MipselTargetMachine - Mipsel target machine.
83///
84class MipselTargetMachine : public MipsTargetMachine {
85public:
86 MipselTargetMachine(const Module &M, const std::string &FS);
87
88 static unsigned getModuleMatchQuality(const Module &M);
89};
90
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000091} // End llvm namespace
92
93#endif