blob: ccfc9a938d9c2424e78d675e2ef833b2a957eae5 [file] [log] [blame]
Eugene Zelenko926883e2017-02-01 01:22:51 +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"
Eugene Zelenko926883e2017-02-01 01:22:51 +000019#include "llvm/ADT/Optional.h"
20#include "llvm/ADT/StringMap.h"
21#include "llvm/ADT/StringRef.h"
22#include "llvm/Support/CodeGen.h"
Chandler Carruth802d7552012-12-04 07:12:27 +000023#include "llvm/Target/TargetMachine.h"
Eugene Zelenko926883e2017-02-01 01:22:51 +000024#include <memory>
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000025
26namespace llvm {
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000027
Matthias Braunbb8507e2017-10-12 22:57:28 +000028class MipsTargetMachine : public LLVMTargetMachine {
Eric Christophera9353d12014-09-26 01:44:08 +000029 bool isLittle;
Aditya Nandakumara2719322014-11-13 09:26:31 +000030 std::unique_ptr<TargetLoweringObjectFile> TLOF;
Eric Christophera5762812015-01-26 17:33:46 +000031 // Selected ABI
32 MipsABIInfo ABI;
Eric Christopher4e7d1e72014-07-18 23:41:32 +000033 MipsSubtarget *Subtarget;
34 MipsSubtarget DefaultSubtarget;
35 MipsSubtarget NoMips16Subtarget;
36 MipsSubtarget Mips16Subtarget;
Bruno Cardoso Lopesd1d9c782011-07-21 16:28:51 +000037
Eric Christophera9353d12014-09-26 01:44:08 +000038 mutable StringMap<std::unique_ptr<MipsSubtarget>> SubtargetMap;
39
Akira Hatanaka30651802012-07-31 21:39:17 +000040public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000041 MipsTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
Rafael Espindola8c34dd82016-05-18 22:04:49 +000042 StringRef FS, const TargetOptions &Options,
Rafael Espindola79e238a2017-08-03 02:16:21 +000043 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
44 CodeGenOpt::Level OL, bool JIT, 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; }
Matthias Braund6a36ae2017-05-31 18:41:23 +000069
70 bool isMachineVerifierClean() const override {
71 return false;
72 }
Akira Hatanaka30651802012-07-31 21:39:17 +000073};
Dan Gohmanbb919df2010-05-11 17:31:57 +000074
Rafael Espindola38af4d62016-05-18 16:00:24 +000075/// Mips32/64 big endian target machine.
Akira Hatanaka3d673cc2011-09-21 03:00:58 +000076///
77class MipsebTargetMachine : public MipsTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000078 virtual void anchor();
Eugene Zelenko926883e2017-02-01 01:22:51 +000079
Akira Hatanaka3d673cc2011-09-21 03:00:58 +000080public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000081 MipsebTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
82 StringRef FS, const TargetOptions &Options,
Rafael Espindola79e238a2017-08-03 02:16:21 +000083 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
84 CodeGenOpt::Level OL, bool JIT);
Akira Hatanaka3d673cc2011-09-21 03:00:58 +000085};
86
Rafael Espindola38af4d62016-05-18 16:00:24 +000087/// Mips32/64 little endian target machine.
Bruno Cardoso Lopes326a0372008-06-04 01:45:25 +000088///
89class MipselTargetMachine : public MipsTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000090 virtual void anchor();
Eugene Zelenko926883e2017-02-01 01:22:51 +000091
Bruno Cardoso Lopes326a0372008-06-04 01:45:25 +000092public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000093 MipselTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
94 StringRef FS, const TargetOptions &Options,
Rafael Espindola79e238a2017-08-03 02:16:21 +000095 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
96 CodeGenOpt::Level OL, bool JIT);
Bruno Cardoso Lopes326a0372008-06-04 01:45:25 +000097};
98
Eugene Zelenko926883e2017-02-01 01:22:51 +000099} // end namespace llvm
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000100
Eugene Zelenko926883e2017-02-01 01:22:51 +0000101#endif // LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H