blob: ee557084fbbff89ddd025dbe0c700d72b5de90e5 [file] [log] [blame]
Jia Liu8f5e8c12012-02-17 01:23:50 +00001//===-- MipsTargetMachine.h - Define TargetMachine for Mips -----*- C++ -*-===//
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00002//
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//
Akira Hatanaka4552c9a2011-04-15 21:51:11 +00008//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00009//
10// This file declares the Mips specific subclass of TargetMachine.
11//
Akira Hatanaka4552c9a2011-04-15 21:51:11 +000012//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000013
14#ifndef MIPSTARGETMACHINE_H
15#define MIPSTARGETMACHINE_H
16
Craig Topper79aa3412012-03-17 18:46:09 +000017#include "MipsFrameLowering.h"
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000018#include "MipsISelLowering.h"
Chandler Carrutha1514e22012-12-04 07:12:27 +000019#include "MipsInstrInfo.h"
Craig Topper79aa3412012-03-17 18:46:09 +000020#include "MipsJITInfo.h"
Dan Gohmanff7a5622010-05-11 17:31:57 +000021#include "MipsSelectionDAGInfo.h"
Craig Topper79aa3412012-03-17 18:46:09 +000022#include "MipsSubtarget.h"
Akira Hatanakade999932012-12-12 20:09:58 +000023#include "llvm/ADT/OwningPtr.h"
Reed Kotlera430cb62013-04-09 19:46:01 +000024#include "llvm/CodeGen/Passes.h"
25#include "llvm/CodeGen/SelectionDAGISel.h"
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000026#include "llvm/IR/DataLayout.h"
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000027#include "llvm/Target/TargetFrameLowering.h"
Chandler Carrutha1514e22012-12-04 07:12:27 +000028#include "llvm/Target/TargetMachine.h"
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000029
30namespace llvm {
Akira Hatanaka0bc1adb2012-07-31 21:49:49 +000031class formatted_raw_ostream;
32class MipsRegisterInfo;
Anton Korobeynikov33464912010-11-15 00:06:54 +000033
Akira Hatanakab4f921b2012-07-31 21:39:17 +000034class MipsTargetMachine : public LLVMTargetMachine {
35 MipsSubtarget Subtarget;
Micah Villmow3574eca2012-10-08 16:38:25 +000036 const DataLayout DL; // Calculates type size & alignment
Akira Hatanakade999932012-12-12 20:09:58 +000037 OwningPtr<const MipsInstrInfo> InstrInfo;
38 OwningPtr<const MipsFrameLowering> FrameLowering;
Akira Hatanaka5ac065a2013-03-13 00:54:29 +000039 OwningPtr<const MipsTargetLowering> TLInfo;
Reed Kotlera430cb62013-04-09 19:46:01 +000040 OwningPtr<const MipsInstrInfo> InstrInfo16;
41 OwningPtr<const MipsFrameLowering> FrameLowering16;
42 OwningPtr<const MipsTargetLowering> TLInfo16;
43 OwningPtr<const MipsInstrInfo> InstrInfoSE;
44 OwningPtr<const MipsFrameLowering> FrameLoweringSE;
45 OwningPtr<const MipsTargetLowering> TLInfoSE;
Akira Hatanakab4f921b2012-07-31 21:39:17 +000046 MipsSelectionDAGInfo TSInfo;
47 MipsJITInfo JITInfo;
Bruno Cardoso Lopesdca6cdd2011-07-21 16:28:51 +000048
Akira Hatanakab4f921b2012-07-31 21:39:17 +000049public:
50 MipsTargetMachine(const Target &T, StringRef TT,
51 StringRef CPU, StringRef FS, const TargetOptions &Options,
52 Reloc::Model RM, CodeModel::Model CM,
53 CodeGenOpt::Level OL,
54 bool isLittle);
Anton Korobeynikov33464912010-11-15 00:06:54 +000055
Akira Hatanakade999932012-12-12 20:09:58 +000056 virtual ~MipsTargetMachine() {}
Akira Hatanaka0bc1adb2012-07-31 21:49:49 +000057
Reed Kotlera430cb62013-04-09 19:46:01 +000058 virtual void addAnalysisPasses(PassManagerBase &PM);
59
Akira Hatanakab4f921b2012-07-31 21:39:17 +000060 virtual const MipsInstrInfo *getInstrInfo() const
Akira Hatanakade999932012-12-12 20:09:58 +000061 { return InstrInfo.get(); }
Akira Hatanakab4f921b2012-07-31 21:39:17 +000062 virtual const TargetFrameLowering *getFrameLowering() const
Akira Hatanakade999932012-12-12 20:09:58 +000063 { return FrameLowering.get(); }
Akira Hatanakab4f921b2012-07-31 21:39:17 +000064 virtual const MipsSubtarget *getSubtargetImpl() const
65 { return &Subtarget; }
Micah Villmow3574eca2012-10-08 16:38:25 +000066 virtual const DataLayout *getDataLayout() const
67 { return &DL;}
Akira Hatanakab4f921b2012-07-31 21:39:17 +000068 virtual MipsJITInfo *getJITInfo()
69 { return &JITInfo; }
Bruno Cardoso Lopesdca6cdd2011-07-21 16:28:51 +000070
Akira Hatanakab4f921b2012-07-31 21:39:17 +000071 virtual const MipsRegisterInfo *getRegisterInfo() const {
Akira Hatanaka0bc1adb2012-07-31 21:49:49 +000072 return &InstrInfo->getRegisterInfo();
Akira Hatanakab4f921b2012-07-31 21:39:17 +000073 }
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000074
Akira Hatanakab4f921b2012-07-31 21:39:17 +000075 virtual const MipsTargetLowering *getTargetLowering() const {
Akira Hatanaka5ac065a2013-03-13 00:54:29 +000076 return TLInfo.get();
Akira Hatanakab4f921b2012-07-31 21:39:17 +000077 }
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000078
Akira Hatanakab4f921b2012-07-31 21:39:17 +000079 virtual const MipsSelectionDAGInfo* getSelectionDAGInfo() const {
80 return &TSInfo;
81 }
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000082
Akira Hatanakab4f921b2012-07-31 21:39:17 +000083 // Pass Pipeline Configuration
84 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
85 virtual bool addCodeEmitter(PassManagerBase &PM, JITCodeEmitter &JCE);
Reed Kotlera430cb62013-04-09 19:46:01 +000086
87 // Set helper classes
88 void setHelperClassesMips16();
89
90 void setHelperClassesMipsSE();
91
92
Akira Hatanakab4f921b2012-07-31 21:39:17 +000093};
Dan Gohmanff7a5622010-05-11 17:31:57 +000094
Akira Hatanakab4f921b2012-07-31 21:39:17 +000095/// MipsebTargetMachine - Mips32/64 big endian target machine.
Akira Hatanaka24648102011-09-21 03:00:58 +000096///
97class MipsebTargetMachine : public MipsTargetMachine {
David Blaikie2d24e2a2011-12-20 02:50:00 +000098 virtual void anchor();
Akira Hatanaka24648102011-09-21 03:00:58 +000099public:
100 MipsebTargetMachine(const Target &T, StringRef TT,
Nick Lewycky8a8d4792011-12-02 22:16:29 +0000101 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Chengb95fc312011-11-16 08:38:26 +0000102 Reloc::Model RM, CodeModel::Model CM,
103 CodeGenOpt::Level OL);
Akira Hatanaka24648102011-09-21 03:00:58 +0000104};
105
Akira Hatanakab4f921b2012-07-31 21:39:17 +0000106/// MipselTargetMachine - Mips32/64 little endian target machine.
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +0000107///
108class MipselTargetMachine : public MipsTargetMachine {
David Blaikie2d24e2a2011-12-20 02:50:00 +0000109 virtual void anchor();
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +0000110public:
Evan Cheng43966132011-07-19 06:37:02 +0000111 MipselTargetMachine(const Target &T, StringRef TT,
Nick Lewycky8a8d4792011-12-02 22:16:29 +0000112 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Chengb95fc312011-11-16 08:38:26 +0000113 Reloc::Model RM, CodeModel::Model CM,
114 CodeGenOpt::Level OL);
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +0000115};
116
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000117} // End llvm namespace
118
119#endif