1 //===-- ARMTargetMachine.h - Define TargetMachine for ARM -------*- C++ -*-===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file declares the ARM specific subclass of TargetMachine. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H 14 #define LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H 15 16 #include "ARMSubtarget.h" 17 #include "llvm/ADT/Optional.h" 18 #include "llvm/ADT/StringMap.h" 19 #include "llvm/ADT/StringRef.h" 20 #include "llvm/Analysis/TargetTransformInfo.h" 21 #include "llvm/Support/CodeGen.h" 22 #include "llvm/Target/TargetMachine.h" 23 #include <memory> 24 25 namespace llvm { 26 27 class ARMBaseTargetMachine : public LLVMTargetMachine { 28 public: 29 enum ARMABI { 30 ARM_ABI_UNKNOWN, 31 ARM_ABI_APCS, 32 ARM_ABI_AAPCS, // ARM EABI 33 ARM_ABI_AAPCS16 34 } TargetABI; 35 36 protected: 37 std::unique_ptr<TargetLoweringObjectFile> TLOF; 38 bool isLittle; 39 mutable StringMap<std::unique_ptr<ARMSubtarget>> SubtargetMap; 40 41 public: 42 ARMBaseTargetMachine(const Target &T, const Triple &TT, StringRef CPU, 43 StringRef FS, const TargetOptions &Options, 44 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, 45 CodeGenOpt::Level OL, bool isLittle); 46 ~ARMBaseTargetMachine() override; 47 48 const ARMSubtarget *getSubtargetImpl(const Function &F) const override; 49 // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget, 50 // subtargets are per-function entities based on the target-specific 51 // attributes of each function. 52 const ARMSubtarget *getSubtargetImpl() const = delete; 53 bool isLittleEndian() const { return isLittle; } 54 55 TargetTransformInfo getTargetTransformInfo(const Function &F) override; 56 57 // Pass Pipeline Configuration 58 TargetPassConfig *createPassConfig(PassManagerBase &PM) override; 59 60 TargetLoweringObjectFile *getObjFileLowering() const override { 61 return TLOF.get(); 62 } 63 64 bool isTargetHardFloat() const { 65 return TargetTriple.getEnvironment() == Triple::GNUEABIHF || 66 TargetTriple.getEnvironment() == Triple::MuslEABIHF || 67 TargetTriple.getEnvironment() == Triple::EABIHF || 68 (TargetTriple.isOSBinFormatMachO() && 69 TargetTriple.getSubArch() == Triple::ARMSubArch_v7em) || 70 TargetTriple.isOSWindows() || 71 TargetABI == ARMBaseTargetMachine::ARM_ABI_AAPCS16; 72 } 73 }; 74 75 /// ARM/Thumb little endian target machine. 76 /// 77 class ARMLETargetMachine : public ARMBaseTargetMachine { 78 public: 79 ARMLETargetMachine(const Target &T, const Triple &TT, StringRef CPU, 80 StringRef FS, const TargetOptions &Options, 81 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, 82 CodeGenOpt::Level OL, bool JIT); 83 }; 84 85 /// ARM/Thumb big endian target machine. 86 /// 87 class ARMBETargetMachine : public ARMBaseTargetMachine { 88 public: 89 ARMBETargetMachine(const Target &T, const Triple &TT, StringRef CPU, 90 StringRef FS, const TargetOptions &Options, 91 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, 92 CodeGenOpt::Level OL, bool JIT); 93 }; 94 95 } // end namespace llvm 96 97 #endif // LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H 98