1//==-- AArch64TargetMachine.h - Define TargetMachine for AArch64 -*- 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 AArch64 specific subclass of TargetMachine.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64TARGETMACHINE_H
14#define LLVM_LIB_TARGET_AARCH64_AARCH64TARGETMACHINE_H
15
16#include "AArch64InstrInfo.h"
17#include "AArch64LoopIdiomTransform.h"
18#include "AArch64Subtarget.h"
19#include "llvm/IR/DataLayout.h"
20#include "llvm/Target/TargetMachine.h"
21#include <optional>
22
23namespace llvm {
24
25class AArch64TargetMachine : public LLVMTargetMachine {
26protected:
27 std::unique_ptr<TargetLoweringObjectFile> TLOF;
28 mutable StringMap<std::unique_ptr<AArch64Subtarget>> SubtargetMap;
29
30public:
31 AArch64TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
32 StringRef FS, const TargetOptions &Options,
33 std::optional<Reloc::Model> RM,
34 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL,
35 bool JIT, bool IsLittleEndian);
36
37 ~AArch64TargetMachine() override;
38 const AArch64Subtarget *getSubtargetImpl(const Function &F) const override;
39 // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget,
40 // subtargets are per-function entities based on the target-specific
41 // attributes of each function.
42 const AArch64Subtarget *getSubtargetImpl() const = delete;
43
44 // Pass Pipeline Configuration
45 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
46
47 void registerPassBuilderCallbacks(PassBuilder &PB,
48 bool PopulateClassToPassNames) override;
49
50 TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
51
52 TargetLoweringObjectFile* getObjFileLowering() const override {
53 return TLOF.get();
54 }
55
56 MachineFunctionInfo *
57 createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
58 const TargetSubtargetInfo *STI) const override;
59
60 yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override;
61 yaml::MachineFunctionInfo *
62 convertFuncInfoToYAML(const MachineFunction &MF) const override;
63 bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &,
64 PerFunctionMIParsingState &PFS,
65 SMDiagnostic &Error,
66 SMRange &SourceRange) const override;
67
68 /// Returns true if a cast between SrcAS and DestAS is a noop.
69 bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
70 // Addrspacecasts are always noops.
71 return true;
72 }
73
74private:
75 bool isLittle;
76};
77
78// AArch64 little endian target machine.
79//
80class AArch64leTargetMachine : public AArch64TargetMachine {
81 virtual void anchor();
82
83public:
84 AArch64leTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
85 StringRef FS, const TargetOptions &Options,
86 std::optional<Reloc::Model> RM,
87 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL,
88 bool JIT);
89};
90
91// AArch64 big endian target machine.
92//
93class AArch64beTargetMachine : public AArch64TargetMachine {
94 virtual void anchor();
95
96public:
97 AArch64beTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
98 StringRef FS, const TargetOptions &Options,
99 std::optional<Reloc::Model> RM,
100 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL,
101 bool JIT);
102};
103
104} // end namespace llvm
105
106#endif
107

source code of llvm/lib/Target/AArch64/AArch64TargetMachine.h