1 //===-- ARMTargetMachine.h - Define TargetMachine for ARM -------*- 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 ARM specific subclass of TargetMachine.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H
14 #define LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H
16 #include "ARMSubtarget.h"
17 #include "llvm/ADT/StringMap.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Analysis/TargetTransformInfo.h"
20 #include "llvm/CodeGen/CodeGenTargetMachineImpl.h"
21 #include "llvm/Support/CodeGen.h"
22 #include "llvm/Target/TargetMachine.h"
28 class ARMBaseTargetMachine
: public CodeGenTargetMachineImpl
{
33 ARM_ABI_AAPCS
, // ARM EABI
38 std::unique_ptr
<TargetLoweringObjectFile
> TLOF
;
40 mutable StringMap
<std::unique_ptr
<ARMSubtarget
>> SubtargetMap
;
42 /// Reset internal state.
43 void reset() override
;
46 ARMBaseTargetMachine(const Target
&T
, const Triple
&TT
, StringRef CPU
,
47 StringRef FS
, const TargetOptions
&Options
,
48 std::optional
<Reloc::Model
> RM
,
49 std::optional
<CodeModel::Model
> CM
, CodeGenOptLevel OL
,
51 ~ARMBaseTargetMachine() override
;
53 const ARMSubtarget
*getSubtargetImpl(const Function
&F
) const override
;
54 // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget,
55 // subtargets are per-function entities based on the target-specific
56 // attributes of each function.
57 const ARMSubtarget
*getSubtargetImpl() const = delete;
58 bool isLittleEndian() const { return isLittle
; }
60 TargetTransformInfo
getTargetTransformInfo(const Function
&F
) const override
;
62 // Pass Pipeline Configuration
63 TargetPassConfig
*createPassConfig(PassManagerBase
&PM
) override
;
65 TargetLoweringObjectFile
*getObjFileLowering() const override
{
69 bool isTargetHardFloat() const {
70 return TargetTriple
.getEnvironment() == Triple::GNUEABIHF
||
71 TargetTriple
.getEnvironment() == Triple::GNUEABIHFT64
||
72 TargetTriple
.getEnvironment() == Triple::MuslEABIHF
||
73 TargetTriple
.getEnvironment() == Triple::EABIHF
||
74 (TargetTriple
.isOSBinFormatMachO() &&
75 TargetTriple
.getSubArch() == Triple::ARMSubArch_v7em
) ||
76 TargetTriple
.isOSWindows() ||
77 TargetABI
== ARMBaseTargetMachine::ARM_ABI_AAPCS16
;
80 bool targetSchedulesPostRAScheduling() const override
{ return true; };
83 createMachineFunctionInfo(BumpPtrAllocator
&Allocator
, const Function
&F
,
84 const TargetSubtargetInfo
*STI
) const override
;
86 /// Returns true if a cast between SrcAS and DestAS is a noop.
87 bool isNoopAddrSpaceCast(unsigned SrcAS
, unsigned DestAS
) const override
{
88 // Addrspacecasts are always noops.
92 yaml::MachineFunctionInfo
*createDefaultFuncInfoYAML() const override
;
93 yaml::MachineFunctionInfo
*
94 convertFuncInfoToYAML(const MachineFunction
&MF
) const override
;
95 bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo
&,
96 PerFunctionMIParsingState
&PFS
,
98 SMRange
&SourceRange
) const override
;
101 /// ARM/Thumb little endian target machine.
103 class ARMLETargetMachine
: public ARMBaseTargetMachine
{
105 ARMLETargetMachine(const Target
&T
, const Triple
&TT
, StringRef CPU
,
106 StringRef FS
, const TargetOptions
&Options
,
107 std::optional
<Reloc::Model
> RM
,
108 std::optional
<CodeModel::Model
> CM
, CodeGenOptLevel OL
,
112 /// ARM/Thumb big endian target machine.
114 class ARMBETargetMachine
: public ARMBaseTargetMachine
{
116 ARMBETargetMachine(const Target
&T
, const Triple
&TT
, StringRef CPU
,
117 StringRef FS
, const TargetOptions
&Options
,
118 std::optional
<Reloc::Model
> RM
,
119 std::optional
<CodeModel::Model
> CM
, CodeGenOptLevel OL
,
123 } // end namespace llvm
125 #endif // LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H