1//===- MCSymbolCOFF.h - ----------------------------------------*- 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#ifndef LLVM_MC_MCSYMBOLCOFF_H
10#define LLVM_MC_MCSYMBOLCOFF_H
11
12#include "llvm/BinaryFormat/COFF.h"
13#include "llvm/MC/MCSymbol.h"
14#include <cstdint>
15
16namespace llvm {
17
18class MCSymbolCOFF : public MCSymbol {
19 /// This corresponds to the e_type field of the COFF symbol.
20 mutable uint16_t Type = 0;
21
22 enum SymbolFlags : uint16_t {
23 SF_ClassMask = 0x00FF,
24 SF_ClassShift = 0,
25
26 SF_SafeSEH = 0x0100,
27 SF_WeakExternalCharacteristicsMask = 0x0E00,
28 SF_WeakExternalCharacteristicsShift = 9,
29 };
30
31public:
32 MCSymbolCOFF(const StringMapEntry<bool> *Name, bool isTemporary)
33 : MCSymbol(SymbolKindCOFF, Name, isTemporary) {}
34
35 uint16_t getType() const {
36 return Type;
37 }
38 void setType(uint16_t Ty) const {
39 Type = Ty;
40 }
41
42 uint16_t getClass() const {
43 return (getFlags() & SF_ClassMask) >> SF_ClassShift;
44 }
45 void setClass(uint16_t StorageClass) const {
46 modifyFlags(Value: StorageClass << SF_ClassShift, Mask: SF_ClassMask);
47 }
48
49 COFF::WeakExternalCharacteristics getWeakExternalCharacteristics() const {
50 return static_cast<COFF::WeakExternalCharacteristics>((getFlags() & SF_WeakExternalCharacteristicsMask) >>
51 SF_WeakExternalCharacteristicsShift);
52 }
53 void setWeakExternalCharacteristics(COFF::WeakExternalCharacteristics Characteristics) const {
54 modifyFlags(Value: Characteristics << SF_WeakExternalCharacteristicsShift,
55 Mask: SF_WeakExternalCharacteristicsMask);
56 }
57 void setIsWeakExternal(bool WeakExt) const {
58 IsWeakExternal = WeakExt;
59 }
60
61 bool isSafeSEH() const {
62 return getFlags() & SF_SafeSEH;
63 }
64 void setIsSafeSEH() const {
65 modifyFlags(Value: SF_SafeSEH, Mask: SF_SafeSEH);
66 }
67
68 static bool classof(const MCSymbol *S) { return S->isCOFF(); }
69};
70
71} // end namespace llvm
72
73#endif // LLVM_MC_MCSYMBOLCOFF_H
74

source code of llvm/include/llvm/MC/MCSymbolCOFF.h