blob: 7918c353dc1546f310174e2aa2959b2816050a4f [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- MCSymbolCOFF.h - ----------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_MC_MCSYMBOLCOFF_H
11#define LLVM_MC_MCSYMBOLCOFF_H
12
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_WeakExternal = 0x0100,
27 SF_SafeSEH = 0x0200,
28 };
29
30public:
31 MCSymbolCOFF(const StringMapEntry<bool> *Name, bool isTemporary)
32 : MCSymbol(SymbolKindCOFF, Name, isTemporary) {}
33
34 uint16_t getType() const {
35 return Type;
36 }
37 void setType(uint16_t Ty) const {
38 Type = Ty;
39 }
40
41 uint16_t getClass() const {
42 return (getFlags() & SF_ClassMask) >> SF_ClassShift;
43 }
44 void setClass(uint16_t StorageClass) const {
45 modifyFlags(StorageClass << SF_ClassShift, SF_ClassMask);
46 }
47
48 bool isWeakExternal() const {
49 return getFlags() & SF_WeakExternal;
50 }
51 void setIsWeakExternal() const {
52 modifyFlags(SF_WeakExternal, SF_WeakExternal);
53 }
54
55 bool isSafeSEH() const {
56 return getFlags() & SF_SafeSEH;
57 }
58 void setIsSafeSEH() const {
59 modifyFlags(SF_SafeSEH, SF_SafeSEH);
60 }
61
62 static bool classof(const MCSymbol *S) { return S->isCOFF(); }
63};
64
65} // end namespace llvm
66
67#endif // LLVM_MC_MCSYMBOLCOFF_H