blob: cb8650d8139becf5c5c224ccb152e88b1288361e [file] [log] [blame]
Rafael Espindolaffdc24b2006-05-14 22:18:28 +00001//===-- ARMTargetMachine.h - Define TargetMachine for ARM -------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Rafael Espindolaffdc24b2006-05-14 22:18:28 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the ARM specific subclass of TargetMachine.
10//
11//===----------------------------------------------------------------------===//
12
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000013#ifndef LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H
14#define LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H
Rafael Espindolaffdc24b2006-05-14 22:18:28 +000015
Chandler Carruth802d7552012-12-04 07:12:27 +000016#include "ARMSubtarget.h"
Eugene Zelenko342257e2017-01-31 00:56:17 +000017#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"
Chandler Carruth802d7552012-12-04 07:12:27 +000022#include "llvm/Target/TargetMachine.h"
Eugene Zelenko342257e2017-01-31 00:56:17 +000023#include <memory>
Rafael Espindolaffdc24b2006-05-14 22:18:28 +000024
25namespace llvm {
26
Matthias Braunbb8507e2017-10-12 22:57:28 +000027class ARMBaseTargetMachine : public LLVMTargetMachine {
Eric Christopher661f2d12014-12-18 02:20:58 +000028public:
29 enum ARMABI {
30 ARM_ABI_UNKNOWN,
31 ARM_ABI_APCS,
Tim Northovere0ccdc62015-10-28 22:46:43 +000032 ARM_ABI_AAPCS, // ARM EABI
33 ARM_ABI_AAPCS16
Eric Christopher661f2d12014-12-18 02:20:58 +000034 } TargetABI;
35
Anton Korobeynikov99152f32009-06-26 21:28:53 +000036protected:
Aditya Nandakumara2719322014-11-13 09:26:31 +000037 std::unique_ptr<TargetLoweringObjectFile> TLOF;
Eric Christopher3faf2f12014-10-06 06:45:36 +000038 bool isLittle;
39 mutable StringMap<std::unique_ptr<ARMSubtarget>> SubtargetMap;
40
Rafael Espindolaffdc24b2006-05-14 22:18:28 +000041public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000042 ARMBaseTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
43 StringRef FS, const TargetOptions &Options,
Rafael Espindola79e238a2017-08-03 02:16:21 +000044 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
Daniel Sanders3e5de882015-06-11 19:41:26 +000045 CodeGenOpt::Level OL, bool isLittle);
Reid Kleckner357600e2014-11-20 23:37:18 +000046 ~ARMBaseTargetMachine() override;
Rafael Espindolaffdc24b2006-05-14 22:18:28 +000047
Eric Christopher3faf2f12014-10-06 06:45:36 +000048 const ARMSubtarget *getSubtargetImpl(const Function &F) const override;
Eric Christopher97ae58682017-07-25 22:21:08 +000049 // 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.
Eric Christopher3df231a2017-07-01 03:41:53 +000052 const ARMSubtarget *getSubtargetImpl() const = delete;
Eric Christophera49d68e2015-02-17 20:02:32 +000053 bool isLittleEndian() const { return isLittle; }
Eric Christopher3d19f132014-06-18 22:48:09 +000054
Sanjoy Das26d11ca2017-12-22 18:21:59 +000055 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
Chandler Carruth664e3542013-01-07 01:37:14 +000056
Chris Lattner12e97302006-09-04 04:14:57 +000057 // Pass Pipeline Configuration
Craig Topper6bc27bf2014-03-10 02:09:33 +000058 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
Aditya Nandakumara2719322014-11-13 09:26:31 +000059
60 TargetLoweringObjectFile *getObjFileLowering() const override {
61 return TLOF.get();
62 }
Tim Northover097a3e32018-07-18 12:36:25 +000063
64 bool isTargetHardFloat() const {
65 return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
66 TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
67 TargetTriple.getEnvironment() == Triple::EABIHF ||
Tim Northovera7c18ee2018-07-19 12:44:51 +000068 (TargetTriple.isOSBinFormatMachO() &&
69 TargetTriple.getSubArch() == Triple::ARMSubArch_v7em) ||
Tim Northover097a3e32018-07-18 12:36:25 +000070 TargetTriple.isOSWindows() ||
71 TargetABI == ARMBaseTargetMachine::ARM_ABI_AAPCS16;
72 }
Rafael Espindolaffdc24b2006-05-14 22:18:28 +000073};
74
Florian Hahnd211fe72017-05-24 10:18:57 +000075/// ARM/Thumb little endian target machine.
Anton Korobeynikov99152f32009-06-26 21:28:53 +000076///
Florian Hahnd211fe72017-05-24 10:18:57 +000077class ARMLETargetMachine : public ARMBaseTargetMachine {
Christian Pirker2a111602014-03-28 14:35:30 +000078public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000079 ARMLETargetMachine(const Target &T, const Triple &TT, StringRef CPU,
80 StringRef FS, const TargetOptions &Options,
Rafael Espindola79e238a2017-08-03 02:16:21 +000081 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
82 CodeGenOpt::Level OL, bool JIT);
Christian Pirker2a111602014-03-28 14:35:30 +000083};
84
Florian Hahnd211fe72017-05-24 10:18:57 +000085/// ARM/Thumb big endian target machine.
Christian Pirker2a111602014-03-28 14:35:30 +000086///
Florian Hahnd211fe72017-05-24 10:18:57 +000087class ARMBETargetMachine : public ARMBaseTargetMachine {
Christian Pirker2a111602014-03-28 14:35:30 +000088public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000089 ARMBETargetMachine(const Target &T, const Triple &TT, StringRef CPU,
90 StringRef FS, const TargetOptions &Options,
Rafael Espindola79e238a2017-08-03 02:16:21 +000091 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
92 CodeGenOpt::Level OL, bool JIT);
Christian Pirker2a111602014-03-28 14:35:30 +000093};
94
Rafael Espindolaffdc24b2006-05-14 22:18:28 +000095} // end namespace llvm
96
Eugene Zelenko342257e2017-01-31 00:56:17 +000097#endif // LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H