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