17330f729Sjoerg //===- MipsTargetMachine.h - Define TargetMachine for Mips ------*- C++ -*-===// 27330f729Sjoerg // 37330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 47330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information. 57330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 67330f729Sjoerg // 77330f729Sjoerg //===----------------------------------------------------------------------===// 87330f729Sjoerg // 97330f729Sjoerg // This file declares the Mips specific subclass of TargetMachine. 107330f729Sjoerg // 117330f729Sjoerg //===----------------------------------------------------------------------===// 127330f729Sjoerg 137330f729Sjoerg #ifndef LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H 147330f729Sjoerg #define LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H 157330f729Sjoerg 167330f729Sjoerg #include "MCTargetDesc/MipsABIInfo.h" 177330f729Sjoerg #include "MipsSubtarget.h" 187330f729Sjoerg #include "llvm/ADT/Optional.h" 197330f729Sjoerg #include "llvm/ADT/StringMap.h" 207330f729Sjoerg #include "llvm/ADT/StringRef.h" 217330f729Sjoerg #include "llvm/Support/CodeGen.h" 227330f729Sjoerg #include "llvm/Target/TargetMachine.h" 237330f729Sjoerg #include <memory> 247330f729Sjoerg 257330f729Sjoerg namespace llvm { 267330f729Sjoerg 277330f729Sjoerg class MipsTargetMachine : public LLVMTargetMachine { 287330f729Sjoerg bool isLittle; 297330f729Sjoerg std::unique_ptr<TargetLoweringObjectFile> TLOF; 307330f729Sjoerg // Selected ABI 317330f729Sjoerg MipsABIInfo ABI; 327330f729Sjoerg const MipsSubtarget *Subtarget; 337330f729Sjoerg MipsSubtarget DefaultSubtarget; 347330f729Sjoerg MipsSubtarget NoMips16Subtarget; 357330f729Sjoerg MipsSubtarget Mips16Subtarget; 367330f729Sjoerg 377330f729Sjoerg mutable StringMap<std::unique_ptr<MipsSubtarget>> SubtargetMap; 387330f729Sjoerg 397330f729Sjoerg public: 407330f729Sjoerg MipsTargetMachine(const Target &T, const Triple &TT, StringRef CPU, 417330f729Sjoerg StringRef FS, const TargetOptions &Options, 427330f729Sjoerg Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, 437330f729Sjoerg CodeGenOpt::Level OL, bool JIT, bool isLittle); 447330f729Sjoerg ~MipsTargetMachine() override; 457330f729Sjoerg 467330f729Sjoerg TargetTransformInfo getTargetTransformInfo(const Function &F) override; 477330f729Sjoerg getSubtargetImpl()487330f729Sjoerg const MipsSubtarget *getSubtargetImpl() const { 497330f729Sjoerg if (Subtarget) 507330f729Sjoerg return Subtarget; 517330f729Sjoerg return &DefaultSubtarget; 527330f729Sjoerg } 537330f729Sjoerg 547330f729Sjoerg const MipsSubtarget *getSubtargetImpl(const Function &F) const override; 557330f729Sjoerg 567330f729Sjoerg /// Reset the subtarget for the Mips target. 577330f729Sjoerg void resetSubtarget(MachineFunction *MF); 587330f729Sjoerg 597330f729Sjoerg // Pass Pipeline Configuration 607330f729Sjoerg TargetPassConfig *createPassConfig(PassManagerBase &PM) override; 617330f729Sjoerg getObjFileLowering()627330f729Sjoerg TargetLoweringObjectFile *getObjFileLowering() const override { 637330f729Sjoerg return TLOF.get(); 647330f729Sjoerg } 657330f729Sjoerg 66*82d56013Sjoerg /// Returns true if a cast between SrcAS and DestAS is a noop. isNoopAddrSpaceCast(unsigned SrcAS,unsigned DestAS)67*82d56013Sjoerg bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override { 68*82d56013Sjoerg // Mips doesn't have any special address spaces so we just reserve 69*82d56013Sjoerg // the first 256 for software use (e.g. OpenCL) and treat casts 70*82d56013Sjoerg // between them as noops. 71*82d56013Sjoerg return SrcAS < 256 && DestAS < 256; 72*82d56013Sjoerg } 73*82d56013Sjoerg isLittleEndian()747330f729Sjoerg bool isLittleEndian() const { return isLittle; } getABI()757330f729Sjoerg const MipsABIInfo &getABI() const { return ABI; } 767330f729Sjoerg }; 777330f729Sjoerg 787330f729Sjoerg /// Mips32/64 big endian target machine. 797330f729Sjoerg /// 807330f729Sjoerg class MipsebTargetMachine : public MipsTargetMachine { 817330f729Sjoerg virtual void anchor(); 827330f729Sjoerg 837330f729Sjoerg public: 847330f729Sjoerg MipsebTargetMachine(const Target &T, const Triple &TT, StringRef CPU, 857330f729Sjoerg StringRef FS, const TargetOptions &Options, 867330f729Sjoerg Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, 877330f729Sjoerg CodeGenOpt::Level OL, bool JIT); 887330f729Sjoerg }; 897330f729Sjoerg 907330f729Sjoerg /// Mips32/64 little endian target machine. 917330f729Sjoerg /// 927330f729Sjoerg class MipselTargetMachine : public MipsTargetMachine { 937330f729Sjoerg virtual void anchor(); 947330f729Sjoerg 957330f729Sjoerg public: 967330f729Sjoerg MipselTargetMachine(const Target &T, const Triple &TT, StringRef CPU, 977330f729Sjoerg StringRef FS, const TargetOptions &Options, 987330f729Sjoerg Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, 997330f729Sjoerg CodeGenOpt::Level OL, bool JIT); 1007330f729Sjoerg }; 1017330f729Sjoerg 1027330f729Sjoerg } // end namespace llvm 1037330f729Sjoerg 1047330f729Sjoerg #endif // LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H 105