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