Eugene Zelenko | 926883e | 2017-02-01 01:22:51 +0000 | [diff] [blame] | 1 | //===- MipsTargetMachine.h - Define TargetMachine for Mips ------*- C++ -*-===// |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // 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 Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 6 | // |
Akira Hatanaka | e248912 | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 7 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 8 | // |
| 9 | // This file declares the Mips specific subclass of TargetMachine. |
| 10 | // |
Akira Hatanaka | e248912 | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 11 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 12 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 13 | #ifndef LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H |
| 14 | #define LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 15 | |
Chandler Carruth | 71f308a | 2015-02-13 09:09:03 +0000 | [diff] [blame] | 16 | #include "MCTargetDesc/MipsABIInfo.h" |
Craig Topper | b25fda9 | 2012-03-17 18:46:09 +0000 | [diff] [blame] | 17 | #include "MipsSubtarget.h" |
Eugene Zelenko | 926883e | 2017-02-01 01:22:51 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/Optional.h" |
| 19 | #include "llvm/ADT/StringMap.h" |
| 20 | #include "llvm/ADT/StringRef.h" |
| 21 | #include "llvm/Support/CodeGen.h" |
Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 22 | #include "llvm/Target/TargetMachine.h" |
Eugene Zelenko | 926883e | 2017-02-01 01:22:51 +0000 | [diff] [blame] | 23 | #include <memory> |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 24 | |
| 25 | namespace llvm { |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 26 | |
Matthias Braun | bb8507e | 2017-10-12 22:57:28 +0000 | [diff] [blame] | 27 | class MipsTargetMachine : public LLVMTargetMachine { |
Eric Christopher | a9353d1 | 2014-09-26 01:44:08 +0000 | [diff] [blame] | 28 | bool isLittle; |
Aditya Nandakumar | a271932 | 2014-11-13 09:26:31 +0000 | [diff] [blame] | 29 | std::unique_ptr<TargetLoweringObjectFile> TLOF; |
Eric Christopher | a576281 | 2015-01-26 17:33:46 +0000 | [diff] [blame] | 30 | // Selected ABI |
| 31 | MipsABIInfo ABI; |
Craig Topper | 1e413ff | 2019-04-24 06:48:31 +0000 | [diff] [blame] | 32 | const MipsSubtarget *Subtarget; |
Eric Christopher | 4e7d1e7 | 2014-07-18 23:41:32 +0000 | [diff] [blame] | 33 | MipsSubtarget DefaultSubtarget; |
| 34 | MipsSubtarget NoMips16Subtarget; |
| 35 | MipsSubtarget Mips16Subtarget; |
Bruno Cardoso Lopes | d1d9c78 | 2011-07-21 16:28:51 +0000 | [diff] [blame] | 36 | |
Eric Christopher | a9353d1 | 2014-09-26 01:44:08 +0000 | [diff] [blame] | 37 | mutable StringMap<std::unique_ptr<MipsSubtarget>> SubtargetMap; |
| 38 | |
Akira Hatanaka | 3065180 | 2012-07-31 21:39:17 +0000 | [diff] [blame] | 39 | public: |
Daniel Sanders | 3e5de88 | 2015-06-11 19:41:26 +0000 | [diff] [blame] | 40 | MipsTargetMachine(const Target &T, const Triple &TT, StringRef CPU, |
Rafael Espindola | 8c34dd8 | 2016-05-18 22:04:49 +0000 | [diff] [blame] | 41 | StringRef FS, const TargetOptions &Options, |
Rafael Espindola | 79e238a | 2017-08-03 02:16:21 +0000 | [diff] [blame] | 42 | Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, |
| 43 | CodeGenOpt::Level OL, bool JIT, bool isLittle); |
Reid Kleckner | 357600e | 2014-11-20 23:37:18 +0000 | [diff] [blame] | 44 | ~MipsTargetMachine() override; |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 45 | |
Sanjoy Das | 26d11ca | 2017-12-22 18:21:59 +0000 | [diff] [blame] | 46 | TargetTransformInfo getTargetTransformInfo(const Function &F) override; |
Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 47 | |
Eric Christopher | 4d0f35a | 2015-03-21 04:22:23 +0000 | [diff] [blame] | 48 | const MipsSubtarget *getSubtargetImpl() const { |
Eric Christopher | 4e7d1e7 | 2014-07-18 23:41:32 +0000 | [diff] [blame] | 49 | if (Subtarget) |
| 50 | return Subtarget; |
| 51 | return &DefaultSubtarget; |
| 52 | } |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 53 | |
Eric Christopher | a9353d1 | 2014-09-26 01:44:08 +0000 | [diff] [blame] | 54 | const MipsSubtarget *getSubtargetImpl(const Function &F) const override; |
| 55 | |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 56 | /// Reset the subtarget for the Mips target. |
Eric Christopher | 4e7d1e7 | 2014-07-18 23:41:32 +0000 | [diff] [blame] | 57 | void resetSubtarget(MachineFunction *MF); |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 58 | |
Akira Hatanaka | 3065180 | 2012-07-31 21:39:17 +0000 | [diff] [blame] | 59 | // Pass Pipeline Configuration |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 60 | TargetPassConfig *createPassConfig(PassManagerBase &PM) override; |
Aditya Nandakumar | a271932 | 2014-11-13 09:26:31 +0000 | [diff] [blame] | 61 | |
| 62 | TargetLoweringObjectFile *getObjFileLowering() const override { |
| 63 | return TLOF.get(); |
| 64 | } |
Eric Christopher | d20ee0a | 2015-01-06 01:12:30 +0000 | [diff] [blame] | 65 | |
| 66 | bool isLittleEndian() const { return isLittle; } |
Eric Christopher | a576281 | 2015-01-26 17:33:46 +0000 | [diff] [blame] | 67 | const MipsABIInfo &getABI() const { return ABI; } |
Akira Hatanaka | 3065180 | 2012-07-31 21:39:17 +0000 | [diff] [blame] | 68 | }; |
Dan Gohman | bb919df | 2010-05-11 17:31:57 +0000 | [diff] [blame] | 69 | |
Rafael Espindola | 38af4d6 | 2016-05-18 16:00:24 +0000 | [diff] [blame] | 70 | /// Mips32/64 big endian target machine. |
Akira Hatanaka | 3d673cc | 2011-09-21 03:00:58 +0000 | [diff] [blame] | 71 | /// |
| 72 | class MipsebTargetMachine : public MipsTargetMachine { |
David Blaikie | a379b181 | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 73 | virtual void anchor(); |
Eugene Zelenko | 926883e | 2017-02-01 01:22:51 +0000 | [diff] [blame] | 74 | |
Akira Hatanaka | 3d673cc | 2011-09-21 03:00:58 +0000 | [diff] [blame] | 75 | public: |
Daniel Sanders | 3e5de88 | 2015-06-11 19:41:26 +0000 | [diff] [blame] | 76 | MipsebTargetMachine(const Target &T, const Triple &TT, StringRef CPU, |
| 77 | StringRef FS, const TargetOptions &Options, |
Rafael Espindola | 79e238a | 2017-08-03 02:16:21 +0000 | [diff] [blame] | 78 | Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, |
| 79 | CodeGenOpt::Level OL, bool JIT); |
Akira Hatanaka | 3d673cc | 2011-09-21 03:00:58 +0000 | [diff] [blame] | 80 | }; |
| 81 | |
Rafael Espindola | 38af4d6 | 2016-05-18 16:00:24 +0000 | [diff] [blame] | 82 | /// Mips32/64 little endian target machine. |
Bruno Cardoso Lopes | 326a037 | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 83 | /// |
| 84 | class MipselTargetMachine : public MipsTargetMachine { |
David Blaikie | a379b181 | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 85 | virtual void anchor(); |
Eugene Zelenko | 926883e | 2017-02-01 01:22:51 +0000 | [diff] [blame] | 86 | |
Bruno Cardoso Lopes | 326a037 | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 87 | public: |
Daniel Sanders | 3e5de88 | 2015-06-11 19:41:26 +0000 | [diff] [blame] | 88 | MipselTargetMachine(const Target &T, const Triple &TT, StringRef CPU, |
| 89 | StringRef FS, const TargetOptions &Options, |
Rafael Espindola | 79e238a | 2017-08-03 02:16:21 +0000 | [diff] [blame] | 90 | Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, |
| 91 | CodeGenOpt::Level OL, bool JIT); |
Bruno Cardoso Lopes | 326a037 | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 92 | }; |
| 93 | |
Eugene Zelenko | 926883e | 2017-02-01 01:22:51 +0000 | [diff] [blame] | 94 | } // end namespace llvm |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 95 | |
Eugene Zelenko | 926883e | 2017-02-01 01:22:51 +0000 | [diff] [blame] | 96 | #endif // LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H |