Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:15

0001 //===- MCSymbolXCOFF.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 #ifndef LLVM_MC_MCSYMBOLXCOFF_H
0009 #define LLVM_MC_MCSYMBOLXCOFF_H
0010 
0011 #include "llvm/ADT/StringRef.h"
0012 #include "llvm/BinaryFormat/XCOFF.h"
0013 #include "llvm/MC/MCSymbol.h"
0014 #include "llvm/MC/MCSymbolTableEntry.h"
0015 
0016 namespace llvm {
0017 
0018 class MCSectionXCOFF;
0019 
0020 class MCSymbolXCOFF : public MCSymbol {
0021 
0022   enum XCOFFSymbolFlags : uint16_t { SF_EHInfo = 0x0001 };
0023 
0024 public:
0025   MCSymbolXCOFF(const MCSymbolTableEntry *Name, bool isTemporary)
0026       : MCSymbol(SymbolKindXCOFF, Name, isTemporary) {}
0027 
0028   static bool classof(const MCSymbol *S) { return S->isXCOFF(); }
0029 
0030   enum CodeModel : uint8_t { CM_Small, CM_Large };
0031 
0032   static StringRef getUnqualifiedName(StringRef Name) {
0033     if (Name.back() == ']') {
0034       StringRef Lhs, Rhs;
0035       std::tie(Lhs, Rhs) = Name.rsplit('[');
0036       assert(!Rhs.empty() && "Invalid SMC format in XCOFF symbol.");
0037       return Lhs;
0038     }
0039     return Name;
0040   }
0041 
0042   void setStorageClass(XCOFF::StorageClass SC) {
0043     StorageClass = SC;
0044   };
0045 
0046   XCOFF::StorageClass getStorageClass() const {
0047     assert(StorageClass && "StorageClass not set on XCOFF MCSymbol.");
0048     return *StorageClass;
0049   }
0050 
0051   StringRef getUnqualifiedName() const { return getUnqualifiedName(getName()); }
0052 
0053   MCSectionXCOFF *getRepresentedCsect() const;
0054 
0055   void setRepresentedCsect(MCSectionXCOFF *C);
0056 
0057   void setVisibilityType(XCOFF::VisibilityType SVT) { VisibilityType = SVT; };
0058 
0059   XCOFF::VisibilityType getVisibilityType() const { return VisibilityType; }
0060 
0061   bool hasRename() const { return HasRename; }
0062 
0063   void setSymbolTableName(StringRef STN) {
0064     SymbolTableName = STN;
0065     HasRename = true;
0066   }
0067 
0068   StringRef getSymbolTableName() const {
0069     if (hasRename())
0070       return SymbolTableName;
0071     return getUnqualifiedName();
0072   }
0073 
0074   bool isEHInfo() const { return getFlags() & SF_EHInfo; }
0075 
0076   void setEHInfo() const { modifyFlags(SF_EHInfo, SF_EHInfo); }
0077 
0078   bool hasPerSymbolCodeModel() const { return PerSymbolCodeModel.has_value(); }
0079 
0080   CodeModel getPerSymbolCodeModel() const {
0081     assert(hasPerSymbolCodeModel() &&
0082            "Requested code model for symbol without one");
0083     return *PerSymbolCodeModel;
0084   }
0085 
0086   void setPerSymbolCodeModel(MCSymbolXCOFF::CodeModel Model) {
0087     PerSymbolCodeModel = Model;
0088   }
0089 
0090 private:
0091   std::optional<XCOFF::StorageClass> StorageClass;
0092   std::optional<CodeModel> PerSymbolCodeModel;
0093 
0094   MCSectionXCOFF *RepresentedCsect = nullptr;
0095   XCOFF::VisibilityType VisibilityType = XCOFF::SYM_V_UNSPECIFIED;
0096   StringRef SymbolTableName;
0097   bool HasRename = false;
0098 };
0099 
0100 } // end namespace llvm
0101 
0102 #endif // LLVM_MC_MCSYMBOLXCOFF_H