blob: 38b2ecff7d7f1b1906bf8a03096798bf33e044a1 [file] [log] [blame]
Jia Liudd6c1cd2012-02-17 01:23:50 +00001//===-- MipsTargetMachine.h - Define TargetMachine for Mips -----*- C++ -*-===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +00002//
3// 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.
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +00007//
Akira Hatanakae2489122011-04-15 21:51:11 +00008//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +00009//
10// This file declares the Mips specific subclass of TargetMachine.
11//
Akira Hatanakae2489122011-04-15 21:51:11 +000012//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000013
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H
15#define LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000016
Chandler Carruth71f308a2015-02-13 09:09:03 +000017#include "MCTargetDesc/MipsABIInfo.h"
Craig Topperb25fda92012-03-17 18:46:09 +000018#include "MipsSubtarget.h"
Chandler Carruth8b04c0d2015-02-01 13:20:00 +000019#include "llvm/CodeGen/BasicTTIImpl.h"
Reed Kotler1595f362013-04-09 19:46:01 +000020#include "llvm/CodeGen/Passes.h"
21#include "llvm/CodeGen/SelectionDAGISel.h"
Anton Korobeynikov2f931282011-01-10 12:39:04 +000022#include "llvm/Target/TargetFrameLowering.h"
Chandler Carruth802d7552012-12-04 07:12:27 +000023#include "llvm/Target/TargetMachine.h"
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000024
25namespace llvm {
Akira Hatanakab7fa3c92012-07-31 21:49:49 +000026class formatted_raw_ostream;
27class MipsRegisterInfo;
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000028
Akira Hatanaka30651802012-07-31 21:39:17 +000029class MipsTargetMachine : public LLVMTargetMachine {
Eric Christophera9353d12014-09-26 01:44:08 +000030 bool isLittle;
Aditya Nandakumara2719322014-11-13 09:26:31 +000031 std::unique_ptr<TargetLoweringObjectFile> TLOF;
Eric Christophera5762812015-01-26 17:33:46 +000032 // Selected ABI
33 MipsABIInfo ABI;
Eric Christopher4e7d1e72014-07-18 23:41:32 +000034 MipsSubtarget *Subtarget;
35 MipsSubtarget DefaultSubtarget;
36 MipsSubtarget NoMips16Subtarget;
37 MipsSubtarget Mips16Subtarget;
Bruno Cardoso Lopesd1d9c782011-07-21 16:28:51 +000038
Eric Christophera9353d12014-09-26 01:44:08 +000039 mutable StringMap<std::unique_ptr<MipsSubtarget>> SubtargetMap;
40
Akira Hatanaka30651802012-07-31 21:39:17 +000041public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000042 MipsTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
43 StringRef FS, const TargetOptions &Options, Reloc::Model RM,
Eric Christopherdaa9dbb2014-07-03 00:10:24 +000044 CodeModel::Model CM, CodeGenOpt::Level OL, bool isLittle);
Reid Kleckner357600e2014-11-20 23:37:18 +000045 ~MipsTargetMachine() override;
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000046
Chandler Carruth8b04c0d2015-02-01 13:20:00 +000047 TargetIRAnalysis getTargetIRAnalysis() override;
Reed Kotler1595f362013-04-09 19:46:01 +000048
Eric Christopher4d0f35a2015-03-21 04:22:23 +000049 const MipsSubtarget *getSubtargetImpl() const {
Eric Christopher4e7d1e72014-07-18 23:41:32 +000050 if (Subtarget)
51 return Subtarget;
52 return &DefaultSubtarget;
53 }
Eric Christopherd9134482014-08-04 21:25:23 +000054
Eric Christophera9353d12014-09-26 01:44:08 +000055 const MipsSubtarget *getSubtargetImpl(const Function &F) const override;
56
Eric Christopher4e7d1e72014-07-18 23:41:32 +000057 /// \brief Reset the subtarget for the Mips target.
58 void resetSubtarget(MachineFunction *MF);
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000059
Akira Hatanaka30651802012-07-31 21:39:17 +000060 // Pass Pipeline Configuration
Craig Topper56c590a2014-04-29 07:58:02 +000061 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
Aditya Nandakumara2719322014-11-13 09:26:31 +000062
63 TargetLoweringObjectFile *getObjFileLowering() const override {
64 return TLOF.get();
65 }
Eric Christopherd20ee0a2015-01-06 01:12:30 +000066
67 bool isLittleEndian() const { return isLittle; }
Eric Christophera5762812015-01-26 17:33:46 +000068 const MipsABIInfo &getABI() const { return ABI; }
Akira Hatanaka30651802012-07-31 21:39:17 +000069};
Dan Gohmanbb919df2010-05-11 17:31:57 +000070
Akira Hatanaka30651802012-07-31 21:39:17 +000071/// MipsebTargetMachine - Mips32/64 big endian target machine.
Akira Hatanaka3d673cc2011-09-21 03:00:58 +000072///
73class MipsebTargetMachine : public MipsTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000074 virtual void anchor();
Akira Hatanaka3d673cc2011-09-21 03:00:58 +000075public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000076 MipsebTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
77 StringRef FS, const TargetOptions &Options,
Evan Chengecb29082011-11-16 08:38:26 +000078 Reloc::Model RM, CodeModel::Model CM,
79 CodeGenOpt::Level OL);
Akira Hatanaka3d673cc2011-09-21 03:00:58 +000080};
81
Akira Hatanaka30651802012-07-31 21:39:17 +000082/// MipselTargetMachine - Mips32/64 little endian target machine.
Bruno Cardoso Lopes326a0372008-06-04 01:45:25 +000083///
84class MipselTargetMachine : public MipsTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000085 virtual void anchor();
Bruno Cardoso Lopes326a0372008-06-04 01:45:25 +000086public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000087 MipselTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
88 StringRef FS, const TargetOptions &Options,
Evan Chengecb29082011-11-16 08:38:26 +000089 Reloc::Model RM, CodeModel::Model CM,
90 CodeGenOpt::Level OL);
Bruno Cardoso Lopes326a0372008-06-04 01:45:25 +000091};
92
Alexander Kornienkof00654e2015-06-23 09:49:53 +000093} // End llvm namespace
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000094
95#endif