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