Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:31

0001 //===- llvm/CodeGen/MachineModuleInfoImpls.h --------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines object-file format specific implementations of
0010 // MachineModuleInfoImpl.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
0015 #define LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
0016 
0017 #include "llvm/ADT/DenseMap.h"
0018 #include "llvm/ADT/SetVector.h"
0019 #include "llvm/CodeGen/MachineModuleInfo.h"
0020 #include <cassert>
0021 
0022 namespace llvm {
0023 
0024 class MCSymbol;
0025 
0026 /// MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation
0027 /// for MachO targets.
0028 class MachineModuleInfoMachO : public MachineModuleInfoImpl {
0029   /// GVStubs - Darwin '$non_lazy_ptr' stubs.  The key is something like
0030   /// "Lfoo$non_lazy_ptr", the value is something like "_foo". The extra bit
0031   /// is true if this GV is external.
0032   DenseMap<MCSymbol *, StubValueTy> GVStubs;
0033 
0034   /// ThreadLocalGVStubs - Darwin '$non_lazy_ptr' stubs.  The key is something
0035   /// like "Lfoo$non_lazy_ptr", the value is something like "_foo". The extra
0036   /// bit is true if this GV is external.
0037   DenseMap<MCSymbol *, StubValueTy> ThreadLocalGVStubs;
0038 
0039   /// Darwin '$auth_ptr' stubs.  The key is the stub symbol, like
0040   /// "Lfoo$auth_ptr$ib$12".  The value is the MCExpr representing that
0041   /// signed pointer, something like "_foo@AUTH(ib, 12)".
0042   DenseMap<MCSymbol *, const MCExpr *> AuthPtrStubs;
0043 
0044   virtual void anchor(); // Out of line virtual method.
0045 
0046 public:
0047   MachineModuleInfoMachO(const MachineModuleInfo &) {}
0048 
0049   StubValueTy &getGVStubEntry(MCSymbol *Sym) {
0050     assert(Sym && "Key cannot be null");
0051     return GVStubs[Sym];
0052   }
0053 
0054   StubValueTy &getThreadLocalGVStubEntry(MCSymbol *Sym) {
0055     assert(Sym && "Key cannot be null");
0056     return ThreadLocalGVStubs[Sym];
0057   }
0058 
0059   const MCExpr *&getAuthPtrStubEntry(MCSymbol *Sym) {
0060     assert(Sym && "Key cannot be null");
0061     return AuthPtrStubs[Sym];
0062   }
0063 
0064   /// Accessor methods to return the set of stubs in sorted order.
0065   SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); }
0066   SymbolListTy GetThreadLocalGVStubList() {
0067     return getSortedStubs(ThreadLocalGVStubs);
0068   }
0069 
0070   ExprStubListTy getAuthGVStubList() {
0071     return getSortedExprStubs(AuthPtrStubs);
0072   }
0073 };
0074 
0075 /// MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation
0076 /// for ELF targets.
0077 class MachineModuleInfoELF : public MachineModuleInfoImpl {
0078   /// GVStubs - These stubs are used to materialize global addresses in PIC
0079   /// mode.
0080   DenseMap<MCSymbol *, StubValueTy> GVStubs;
0081 
0082   /// AuthPtrStubs - These stubs are used to materialize signed addresses for
0083   /// extern_weak symbols.
0084   DenseMap<MCSymbol *, const MCExpr *> AuthPtrStubs;
0085 
0086   /// HasSignedPersonality is true if the corresponding IR module has the
0087   /// "ptrauth-sign-personality" flag set to 1.
0088   bool HasSignedPersonality = false;
0089 
0090   virtual void anchor(); // Out of line virtual method.
0091 
0092 public:
0093   MachineModuleInfoELF(const MachineModuleInfo &);
0094 
0095   StubValueTy &getGVStubEntry(MCSymbol *Sym) {
0096     assert(Sym && "Key cannot be null");
0097     return GVStubs[Sym];
0098   }
0099 
0100   const MCExpr *&getAuthPtrStubEntry(MCSymbol *Sym) {
0101     assert(Sym && "Key cannot be null");
0102     return AuthPtrStubs[Sym];
0103   }
0104 
0105   /// Accessor methods to return the set of stubs in sorted order.
0106 
0107   SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); }
0108 
0109   ExprStubListTy getAuthGVStubList() {
0110     return getSortedExprStubs(AuthPtrStubs);
0111   }
0112 
0113   bool hasSignedPersonality() const { return HasSignedPersonality; }
0114 };
0115 
0116 /// MachineModuleInfoCOFF - This is a MachineModuleInfoImpl implementation
0117 /// for COFF targets.
0118 class MachineModuleInfoCOFF : public MachineModuleInfoImpl {
0119   /// GVStubs - These stubs are used to materialize global addresses in PIC
0120   /// mode.
0121   DenseMap<MCSymbol *, StubValueTy> GVStubs;
0122 
0123   virtual void anchor(); // Out of line virtual method.
0124 
0125 public:
0126   MachineModuleInfoCOFF(const MachineModuleInfo &) {}
0127 
0128   StubValueTy &getGVStubEntry(MCSymbol *Sym) {
0129     assert(Sym && "Key cannot be null");
0130     return GVStubs[Sym];
0131   }
0132 
0133   /// Accessor methods to return the set of stubs in sorted order.
0134 
0135   SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); }
0136 };
0137 
0138 /// MachineModuleInfoWasm - This is a MachineModuleInfoImpl implementation
0139 /// for Wasm targets.
0140 class MachineModuleInfoWasm : public MachineModuleInfoImpl {
0141   virtual void anchor(); // Out of line virtual method.
0142 
0143 public:
0144   MachineModuleInfoWasm(const MachineModuleInfo &) {}
0145 
0146   SetVector<StringRef> MachineSymbolsUsed;
0147 };
0148 
0149 } // end namespace llvm
0150 
0151 #endif // LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H