LLVM 22.0.0git
MCSymbolXCOFF.h
Go to the documentation of this file.
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"
13#include "llvm/MC/MCSymbol.h"
15
16namespace llvm {
17
18class MCSectionXCOFF;
19
20class MCSymbolXCOFF : public MCSymbol {
21
22 enum XCOFFSymbolFlags : uint16_t { SF_EHInfo = 0x0001 };
23
24public:
27
29
31 if (Name.back() == ']') {
32 StringRef Lhs, Rhs;
33 std::tie(Lhs, Rhs) = Name.rsplit('[');
34 assert(!Rhs.empty() && "Invalid SMC format in XCOFF symbol.");
35 return Lhs;
36 }
37 return Name;
38 }
39
40 bool isExternal() const { return IsExternal; }
41 void setExternal(bool Value) const { IsExternal = Value; }
43 StorageClass = SC;
44 };
45
47 assert(StorageClass && "StorageClass not set on XCOFF MCSymbol.");
48 return *StorageClass;
49 }
50
52
54
56
57 void setVisibilityType(XCOFF::VisibilityType SVT) { VisibilityType = SVT; };
58
59 XCOFF::VisibilityType getVisibilityType() const { return VisibilityType; }
60
61 bool hasRename() const { return HasRename; }
62
64 SymbolTableName = STN;
65 HasRename = true;
66 }
67
69 if (hasRename())
70 return SymbolTableName;
71 return getUnqualifiedName();
72 }
73
74 bool isEHInfo() const { return getFlags() & SF_EHInfo; }
75
76 void setEHInfo() const { modifyFlags(SF_EHInfo, SF_EHInfo); }
77
78 bool hasPerSymbolCodeModel() const { return PerSymbolCodeModel.has_value(); }
79
82 "Requested code model for symbol without one");
83 return *PerSymbolCodeModel;
84 }
85
87 PerSymbolCodeModel = Model;
88 }
89
90private:
91 std::optional<XCOFF::StorageClass> StorageClass;
92 std::optional<CodeModel> PerSymbolCodeModel;
93
94 MCSectionXCOFF *RepresentedCsect = nullptr;
96 StringRef SymbolTableName;
97 bool HasRename = false;
98};
99
100} // end namespace llvm
101
102#endif // LLVM_MC_MCSYMBOLXCOFF_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
XCOFF::VisibilityType getVisibilityType() const
void setExternal(bool Value) const
StringRef getSymbolTableName() const
bool isExternal() const
MCSymbolXCOFF(const MCSymbolTableEntry *Name, bool isTemporary)
XCOFF::StorageClass getStorageClass() const
bool hasPerSymbolCodeModel() const
bool hasRename() const
void setVisibilityType(XCOFF::VisibilityType SVT)
void setEHInfo() const
CodeModel getPerSymbolCodeModel() const
bool isEHInfo() const
void setRepresentedCsect(MCSectionXCOFF *C)
static StringRef getUnqualifiedName(StringRef Name)
void setSymbolTableName(StringRef STN)
void setPerSymbolCodeModel(MCSymbolXCOFF::CodeModel Model)
void setStorageClass(XCOFF::StorageClass SC)
StringRef getUnqualifiedName() const
MCSectionXCOFF * getRepresentedCsect() const
MCSymbol(const MCSymbolTableEntry *Name, bool isTemporary)
Definition MCSymbol.h:146
void modifyFlags(uint32_t Value, uint32_t Mask) const
Modify the flags via a mask.
Definition MCSymbol.h:375
StringRef getName() const
getName - Get the symbol name.
Definition MCSymbol.h:188
uint32_t getFlags() const
Get the (implementation defined) symbol flags.
Definition MCSymbol.h:366
unsigned IsExternal
True if this symbol is visible outside this translation unit.
Definition MCSymbol.h:87
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
Definition MCSymbol.h:205
const MCExpr * Value
If non-null, the value for a variable symbol.
Definition MCSymbol.h:130
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
constexpr bool empty() const
empty - Check if the string is empty.
Definition StringRef.h:151
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
VisibilityType
Values for visibility as they would appear when encoded in the high 4 bits of the 16-bit unsigned n_t...
Definition XCOFF.h:252
@ SYM_V_UNSPECIFIED
Definition XCOFF.h:253
This is an optimization pass for GlobalISel generic memory operations.
StringMapEntry< MCSymbolTableValue > MCSymbolTableEntry
MCContext stores MCSymbolTableValue in a string map (see MCSymbol::operator new).