1 //===- MipsTargetMachine.h - Define TargetMachine for Mips ------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file declares the Mips specific subclass of TargetMachine.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H
14 #define LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H
16 #include "MCTargetDesc/MipsABIInfo.h"
17 #include "MipsSubtarget.h"
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/Support/CodeGen.h"
22 #include "llvm/Target/TargetMachine.h"
27 class MipsTargetMachine
: public LLVMTargetMachine
{
29 std::unique_ptr
<TargetLoweringObjectFile
> TLOF
;
32 const MipsSubtarget
*Subtarget
;
33 MipsSubtarget DefaultSubtarget
;
34 MipsSubtarget NoMips16Subtarget
;
35 MipsSubtarget Mips16Subtarget
;
37 mutable StringMap
<std::unique_ptr
<MipsSubtarget
>> SubtargetMap
;
40 MipsTargetMachine(const Target
&T
, const Triple
&TT
, StringRef CPU
,
41 StringRef FS
, const TargetOptions
&Options
,
42 Optional
<Reloc::Model
> RM
, Optional
<CodeModel::Model
> CM
,
43 CodeGenOpt::Level OL
, bool JIT
, bool isLittle
);
44 ~MipsTargetMachine() override
;
46 TargetTransformInfo
getTargetTransformInfo(const Function
&F
) override
;
48 const MipsSubtarget
*getSubtargetImpl() const {
51 return &DefaultSubtarget
;
54 const MipsSubtarget
*getSubtargetImpl(const Function
&F
) const override
;
56 /// Reset the subtarget for the Mips target.
57 void resetSubtarget(MachineFunction
*MF
);
59 // Pass Pipeline Configuration
60 TargetPassConfig
*createPassConfig(PassManagerBase
&PM
) override
;
62 TargetLoweringObjectFile
*getObjFileLowering() const override
{
66 bool isLittleEndian() const { return isLittle
; }
67 const MipsABIInfo
&getABI() const { return ABI
; }
70 /// Mips32/64 big endian target machine.
72 class MipsebTargetMachine
: public MipsTargetMachine
{
73 virtual void anchor();
76 MipsebTargetMachine(const Target
&T
, const Triple
&TT
, StringRef CPU
,
77 StringRef FS
, const TargetOptions
&Options
,
78 Optional
<Reloc::Model
> RM
, Optional
<CodeModel::Model
> CM
,
79 CodeGenOpt::Level OL
, bool JIT
);
82 /// Mips32/64 little endian target machine.
84 class MipselTargetMachine
: public MipsTargetMachine
{
85 virtual void anchor();
88 MipselTargetMachine(const Target
&T
, const Triple
&TT
, StringRef CPU
,
89 StringRef FS
, const TargetOptions
&Options
,
90 Optional
<Reloc::Model
> RM
, Optional
<CodeModel::Model
> CM
,
91 CodeGenOpt::Level OL
, bool JIT
);
94 } // end namespace llvm
96 #endif // LLVM_LIB_TARGET_MIPS_MIPSTARGETMACHINE_H