blob: 07dfdc3e69e1a9f34108314944b9030a7fd90def [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
Craig Topperb25fda92012-03-17 18:46:09 +000017#include "MipsSubtarget.h"
Chandler Carruth8b04c0d2015-02-01 13:20:00 +000018#include "llvm/CodeGen/BasicTTIImpl.h"
Reed Kotler1595f362013-04-09 19:46:01 +000019#include "llvm/CodeGen/Passes.h"
20#include "llvm/CodeGen/SelectionDAGISel.h"
Anton Korobeynikov2f931282011-01-10 12:39:04 +000021#include "llvm/Target/TargetFrameLowering.h"
Chandler Carruth802d7552012-12-04 07:12:27 +000022#include "llvm/Target/TargetMachine.h"
Eric Christophera5762812015-01-26 17:33:46 +000023#include "MCTargetDesc/MipsABIInfo.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 Christopher8b770652015-01-26 19:03:15 +000034 const DataLayout DL; // Calculates type size & alignment
Eric Christopher4e7d1e72014-07-18 23:41:32 +000035 MipsSubtarget *Subtarget;
36 MipsSubtarget DefaultSubtarget;
37 MipsSubtarget NoMips16Subtarget;
38 MipsSubtarget Mips16Subtarget;
Bruno Cardoso Lopesd1d9c782011-07-21 16:28:51 +000039
Eric Christophera9353d12014-09-26 01:44:08 +000040 mutable StringMap<std::unique_ptr<MipsSubtarget>> SubtargetMap;
41
Akira Hatanaka30651802012-07-31 21:39:17 +000042public:
Eric Christopherdaa9dbb2014-07-03 00:10:24 +000043 MipsTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
44 const TargetOptions &Options, Reloc::Model RM,
45 CodeModel::Model CM, CodeGenOpt::Level OL, bool isLittle);
Reid Kleckner357600e2014-11-20 23:37:18 +000046 ~MipsTargetMachine() override;
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000047
Chandler Carruth8b04c0d2015-02-01 13:20:00 +000048 TargetIRAnalysis getTargetIRAnalysis() override;
Reed Kotler1595f362013-04-09 19:46:01 +000049
Eric Christopher8b770652015-01-26 19:03:15 +000050 const DataLayout *getDataLayout() const override { return &DL; }
Eric Christopher4e7d1e72014-07-18 23:41:32 +000051 const MipsSubtarget *getSubtargetImpl() const override {
52 if (Subtarget)
53 return Subtarget;
54 return &DefaultSubtarget;
55 }
Eric Christopherd9134482014-08-04 21:25:23 +000056
Eric Christophera9353d12014-09-26 01:44:08 +000057 const MipsSubtarget *getSubtargetImpl(const Function &F) const override;
58
Eric Christopher4e7d1e72014-07-18 23:41:32 +000059 /// \brief Reset the subtarget for the Mips target.
60 void resetSubtarget(MachineFunction *MF);
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000061
Akira Hatanaka30651802012-07-31 21:39:17 +000062 // Pass Pipeline Configuration
Craig Topper56c590a2014-04-29 07:58:02 +000063 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
Aditya Nandakumara2719322014-11-13 09:26:31 +000064
65 TargetLoweringObjectFile *getObjFileLowering() const override {
66 return TLOF.get();
67 }
Eric Christopherd20ee0a2015-01-06 01:12:30 +000068
69 bool isLittleEndian() const { return isLittle; }
Eric Christophera5762812015-01-26 17:33:46 +000070 const MipsABIInfo &getABI() const { return ABI; }
Akira Hatanaka30651802012-07-31 21:39:17 +000071};
Dan Gohmanbb919df2010-05-11 17:31:57 +000072
Akira Hatanaka30651802012-07-31 21:39:17 +000073/// MipsebTargetMachine - Mips32/64 big endian target machine.
Akira Hatanaka3d673cc2011-09-21 03:00:58 +000074///
75class MipsebTargetMachine : public MipsTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000076 virtual void anchor();
Akira Hatanaka3d673cc2011-09-21 03:00:58 +000077public:
78 MipsebTargetMachine(const Target &T, StringRef TT,
Nick Lewycky50f02cb2011-12-02 22:16:29 +000079 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Chengecb29082011-11-16 08:38:26 +000080 Reloc::Model RM, CodeModel::Model CM,
81 CodeGenOpt::Level OL);
Akira Hatanaka3d673cc2011-09-21 03:00:58 +000082};
83
Akira Hatanaka30651802012-07-31 21:39:17 +000084/// MipselTargetMachine - Mips32/64 little endian target machine.
Bruno Cardoso Lopes326a0372008-06-04 01:45:25 +000085///
86class MipselTargetMachine : public MipsTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000087 virtual void anchor();
Bruno Cardoso Lopes326a0372008-06-04 01:45:25 +000088public:
Evan Cheng2129f592011-07-19 06:37:02 +000089 MipselTargetMachine(const Target &T, StringRef TT,
Nick Lewycky50f02cb2011-12-02 22:16:29 +000090 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Chengecb29082011-11-16 08:38:26 +000091 Reloc::Model RM, CodeModel::Model CM,
92 CodeGenOpt::Level OL);
Bruno Cardoso Lopes326a0372008-06-04 01:45:25 +000093};
94
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000095} // End llvm namespace
96
97#endif