[SampleProfileLoader] Fix integer overflow in generateMDProfMetadata (#90217)
[llvm-project.git] / llvm / lib / Target / AArch64 / AArch64TargetMachine.h
blob8fb68b06f137803c213fbc957b73b1df20fe4d06
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.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64TARGETMACHINE_H
14 #define LLVM_LIB_TARGET_AARCH64_AARCH64TARGETMACHINE_H
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>
23 namespace llvm {
25 class AArch64TargetMachine : public LLVMTargetMachine {
26 protected:
27 std::unique_ptr<TargetLoweringObjectFile> TLOF;
28 mutable StringMap<std::unique_ptr<AArch64Subtarget>> SubtargetMap;
30 public:
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);
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;
44 // Pass Pipeline Configuration
45 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
47 void registerPassBuilderCallbacks(PassBuilder &PB,
48 bool PopulateClassToPassNames) override;
50 TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
52 TargetLoweringObjectFile* getObjFileLowering() const override {
53 return TLOF.get();
56 MachineFunctionInfo *
57 createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
58 const TargetSubtargetInfo *STI) const override;
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;
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;
74 private:
75 bool isLittle;
78 // AArch64 little endian target machine.
80 class AArch64leTargetMachine : public AArch64TargetMachine {
81 virtual void anchor();
83 public:
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);
91 // AArch64 big endian target machine.
93 class AArch64beTargetMachine : public AArch64TargetMachine {
94 virtual void anchor();
96 public:
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);
104 } // end namespace llvm
106 #endif