blob: 25300504a02dc5be4a094faf01969c5a463e84ce [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//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +00006//
Akira Hatanakae2489122011-04-15 21:51:11 +00007//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +00008//
9// This file declares the Mips specific subclass of TargetMachine.
10//
Akira Hatanakae2489122011-04-15 21:51:11 +000011//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000012
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000013#ifndef LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H
14#define LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000015
Chandler Carruth71f308a2015-02-13 09:09:03 +000016#include "MCTargetDesc/MipsABIInfo.h"
Craig Topperb25fda92012-03-17 18:46:09 +000017#include "MipsSubtarget.h"
Eugene Zelenko926883e2017-02-01 01:22:51 +000018#include "llvm/ADT/Optional.h"
19#include "llvm/ADT/StringMap.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/Support/CodeGen.h"
Chandler Carruth802d7552012-12-04 07:12:27 +000022#include "llvm/Target/TargetMachine.h"
Eugene Zelenko926883e2017-02-01 01:22:51 +000023#include <memory>
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000024
25namespace llvm {
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000026
Matthias Braunbb8507e2017-10-12 22:57:28 +000027class MipsTargetMachine : public LLVMTargetMachine {
Eric Christophera9353d12014-09-26 01:44:08 +000028 bool isLittle;
Aditya Nandakumara2719322014-11-13 09:26:31 +000029 std::unique_ptr<TargetLoweringObjectFile> TLOF;
Eric Christophera5762812015-01-26 17:33:46 +000030 // Selected ABI
31 MipsABIInfo ABI;
Craig Topper1e413ff2019-04-24 06:48:31 +000032 const MipsSubtarget *Subtarget;
Eric Christopher4e7d1e72014-07-18 23:41:32 +000033 MipsSubtarget DefaultSubtarget;
34 MipsSubtarget NoMips16Subtarget;
35 MipsSubtarget Mips16Subtarget;
Bruno Cardoso Lopesd1d9c782011-07-21 16:28:51 +000036
Eric Christophera9353d12014-09-26 01:44:08 +000037 mutable StringMap<std::unique_ptr<MipsSubtarget>> SubtargetMap;
38
Akira Hatanaka30651802012-07-31 21:39:17 +000039public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000040 MipsTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
Rafael Espindola8c34dd82016-05-18 22:04:49 +000041 StringRef FS, const TargetOptions &Options,
Rafael Espindola79e238a2017-08-03 02:16:21 +000042 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
43 CodeGenOpt::Level OL, bool JIT, bool isLittle);
Reid Kleckner357600e2014-11-20 23:37:18 +000044 ~MipsTargetMachine() override;
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000045
Sanjoy Das26d11ca2017-12-22 18:21:59 +000046 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
Reed Kotler1595f362013-04-09 19:46:01 +000047
Eric Christopher4d0f35a2015-03-21 04:22:23 +000048 const MipsSubtarget *getSubtargetImpl() const {
Eric Christopher4e7d1e72014-07-18 23:41:32 +000049 if (Subtarget)
50 return Subtarget;
51 return &DefaultSubtarget;
52 }
Eric Christopherd9134482014-08-04 21:25:23 +000053
Eric Christophera9353d12014-09-26 01:44:08 +000054 const MipsSubtarget *getSubtargetImpl(const Function &F) const override;
55
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000056 /// Reset the subtarget for the Mips target.
Eric Christopher4e7d1e72014-07-18 23:41:32 +000057 void resetSubtarget(MachineFunction *MF);
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000058
Akira Hatanaka30651802012-07-31 21:39:17 +000059 // Pass Pipeline Configuration
Craig Topper56c590a2014-04-29 07:58:02 +000060 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
Aditya Nandakumara2719322014-11-13 09:26:31 +000061
62 TargetLoweringObjectFile *getObjFileLowering() const override {
63 return TLOF.get();
64 }
Eric Christopherd20ee0a2015-01-06 01:12:30 +000065
66 bool isLittleEndian() const { return isLittle; }
Eric Christophera5762812015-01-26 17:33:46 +000067 const MipsABIInfo &getABI() const { return ABI; }
Akira Hatanaka30651802012-07-31 21:39:17 +000068};
Dan Gohmanbb919df2010-05-11 17:31:57 +000069
Rafael Espindola38af4d62016-05-18 16:00:24 +000070/// Mips32/64 big endian target machine.
Akira Hatanaka3d673cc2011-09-21 03:00:58 +000071///
72class MipsebTargetMachine : public MipsTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000073 virtual void anchor();
Eugene Zelenko926883e2017-02-01 01:22:51 +000074
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,
Rafael Espindola79e238a2017-08-03 02:16:21 +000078 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
79 CodeGenOpt::Level OL, bool JIT);
Akira Hatanaka3d673cc2011-09-21 03:00:58 +000080};
81
Rafael Espindola38af4d62016-05-18 16:00:24 +000082/// 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();
Eugene Zelenko926883e2017-02-01 01:22:51 +000086
Bruno Cardoso Lopes326a0372008-06-04 01:45:25 +000087public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000088 MipselTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
89 StringRef FS, const TargetOptions &Options,
Rafael Espindola79e238a2017-08-03 02:16:21 +000090 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
91 CodeGenOpt::Level OL, bool JIT);
Bruno Cardoso Lopes326a0372008-06-04 01:45:25 +000092};
93
Eugene Zelenko926883e2017-02-01 01:22:51 +000094} // end namespace llvm
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000095
Eugene Zelenko926883e2017-02-01 01:22:51 +000096#endif // LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H