Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | pmbaty | 1 | //===- MCSymbolXCOFF.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 | #ifndef LLVM_MC_MCSYMBOLXCOFF_H |
||
9 | #define LLVM_MC_MCSYMBOLXCOFF_H |
||
10 | |||
11 | #include "llvm/ADT/StringRef.h" |
||
12 | #include "llvm/BinaryFormat/XCOFF.h" |
||
13 | #include "llvm/MC/MCSymbol.h" |
||
14 | |||
15 | namespace llvm { |
||
16 | |||
17 | class MCSectionXCOFF; |
||
18 | |||
19 | class MCSymbolXCOFF : public MCSymbol { |
||
20 | public: |
||
21 | MCSymbolXCOFF(const StringMapEntry<bool> *Name, bool isTemporary) |
||
22 | : MCSymbol(SymbolKindXCOFF, Name, isTemporary) {} |
||
23 | |||
24 | static bool classof(const MCSymbol *S) { return S->isXCOFF(); } |
||
25 | |||
26 | static StringRef getUnqualifiedName(StringRef Name) { |
||
27 | if (Name.back() == ']') { |
||
28 | StringRef Lhs, Rhs; |
||
29 | std::tie(Lhs, Rhs) = Name.rsplit('['); |
||
30 | assert(!Rhs.empty() && "Invalid SMC format in XCOFF symbol."); |
||
31 | return Lhs; |
||
32 | } |
||
33 | return Name; |
||
34 | } |
||
35 | |||
36 | void setStorageClass(XCOFF::StorageClass SC) { |
||
37 | StorageClass = SC; |
||
38 | }; |
||
39 | |||
40 | XCOFF::StorageClass getStorageClass() const { |
||
41 | assert(StorageClass && "StorageClass not set on XCOFF MCSymbol."); |
||
42 | return *StorageClass; |
||
43 | } |
||
44 | |||
45 | StringRef getUnqualifiedName() const { return getUnqualifiedName(getName()); } |
||
46 | |||
47 | MCSectionXCOFF *getRepresentedCsect() const; |
||
48 | |||
49 | void setRepresentedCsect(MCSectionXCOFF *C); |
||
50 | |||
51 | void setVisibilityType(XCOFF::VisibilityType SVT) { VisibilityType = SVT; }; |
||
52 | |||
53 | XCOFF::VisibilityType getVisibilityType() const { return VisibilityType; } |
||
54 | |||
55 | bool hasRename() const { return !SymbolTableName.empty(); } |
||
56 | |||
57 | void setSymbolTableName(StringRef STN) { SymbolTableName = STN; } |
||
58 | |||
59 | StringRef getSymbolTableName() const { |
||
60 | if (hasRename()) |
||
61 | return SymbolTableName; |
||
62 | return getUnqualifiedName(); |
||
63 | } |
||
64 | |||
65 | private: |
||
66 | std::optional<XCOFF::StorageClass> StorageClass; |
||
67 | MCSectionXCOFF *RepresentedCsect = nullptr; |
||
68 | XCOFF::VisibilityType VisibilityType = XCOFF::SYM_V_UNSPECIFIED; |
||
69 | StringRef SymbolTableName; |
||
70 | }; |
||
71 | |||
72 | } // end namespace llvm |
||
73 | |||
74 | #endif // LLVM_MC_MCSYMBOLXCOFF_H |