Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===- MCSymbolCOFF.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 #ifndef LLVM_MC_MCSYMBOLCOFF_H
0010 #define LLVM_MC_MCSYMBOLCOFF_H
0011 
0012 #include "llvm/BinaryFormat/COFF.h"
0013 #include "llvm/MC/MCSymbol.h"
0014 #include "llvm/MC/MCSymbolTableEntry.h"
0015 #include <cstdint>
0016 
0017 namespace llvm {
0018 
0019 class MCSymbolCOFF : public MCSymbol {
0020   /// This corresponds to the e_type field of the COFF symbol.
0021   mutable uint16_t Type = 0;
0022 
0023   enum SymbolFlags : uint16_t {
0024     SF_ClassMask = 0x00FF,
0025     SF_ClassShift = 0,
0026 
0027     SF_SafeSEH = 0x0100,
0028     SF_WeakExternalCharacteristicsMask = 0x0E00,
0029     SF_WeakExternalCharacteristicsShift = 9,
0030   };
0031 
0032 public:
0033   MCSymbolCOFF(const MCSymbolTableEntry *Name, bool isTemporary)
0034       : MCSymbol(SymbolKindCOFF, Name, isTemporary) {}
0035 
0036   uint16_t getType() const {
0037     return Type;
0038   }
0039   void setType(uint16_t Ty) const {
0040     Type = Ty;
0041   }
0042 
0043   uint16_t getClass() const {
0044     return (getFlags() & SF_ClassMask) >> SF_ClassShift;
0045   }
0046   void setClass(uint16_t StorageClass) const {
0047     modifyFlags(StorageClass << SF_ClassShift, SF_ClassMask);
0048   }
0049 
0050   COFF::WeakExternalCharacteristics getWeakExternalCharacteristics() const {
0051     return static_cast<COFF::WeakExternalCharacteristics>((getFlags() & SF_WeakExternalCharacteristicsMask) >>
0052            SF_WeakExternalCharacteristicsShift);
0053   }
0054   void setWeakExternalCharacteristics(COFF::WeakExternalCharacteristics Characteristics) const {
0055     modifyFlags(Characteristics << SF_WeakExternalCharacteristicsShift,
0056                 SF_WeakExternalCharacteristicsMask);
0057   }
0058   void setIsWeakExternal(bool WeakExt) const {
0059     IsWeakExternal = WeakExt;
0060   }
0061 
0062   bool isSafeSEH() const {
0063     return getFlags() & SF_SafeSEH;
0064   }
0065   void setIsSafeSEH() const {
0066     modifyFlags(SF_SafeSEH, SF_SafeSEH);
0067   }
0068 
0069   static bool classof(const MCSymbol *S) { return S->isCOFF(); }
0070 };
0071 
0072 } // end namespace llvm
0073 
0074 #endif // LLVM_MC_MCSYMBOLCOFF_H