LLVM 20.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
28 static bool classof(const MCSymbol *S) { return S->isXCOFF(); }
29
30 enum CodeModel : uint8_t { CM_Small, CM_Large };
31
33 if (Name.back() == ']') {
34 StringRef Lhs, Rhs;
35 std::tie(Lhs, Rhs) = Name.rsplit('[');
36 assert(!Rhs.empty() && "Invalid SMC format in XCOFF symbol.");
37 return Lhs;
38 }
39 return Name;
40 }
41
43 StorageClass = SC;
44 };
45
47 assert(StorageClass && "StorageClass not set on XCOFF MCSymbol.");
48 return *StorageClass;
49 }
50
52
54
56
58
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
std::string Name
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
XCOFF::VisibilityType getVisibilityType() const
Definition: MCSymbolXCOFF.h:59
static bool classof(const MCSymbol *S)
Definition: MCSymbolXCOFF.h:28
StringRef getSymbolTableName() const
Definition: MCSymbolXCOFF.h:68
MCSymbolXCOFF(const MCSymbolTableEntry *Name, bool isTemporary)
Definition: MCSymbolXCOFF.h:25
XCOFF::StorageClass getStorageClass() const
Definition: MCSymbolXCOFF.h:46
bool hasPerSymbolCodeModel() const
Definition: MCSymbolXCOFF.h:78
bool hasRename() const
Definition: MCSymbolXCOFF.h:61
void setVisibilityType(XCOFF::VisibilityType SVT)
Definition: MCSymbolXCOFF.h:57
void setEHInfo() const
Definition: MCSymbolXCOFF.h:76
CodeModel getPerSymbolCodeModel() const
Definition: MCSymbolXCOFF.h:80
bool isEHInfo() const
Definition: MCSymbolXCOFF.h:74
void setRepresentedCsect(MCSectionXCOFF *C)
static StringRef getUnqualifiedName(StringRef Name)
Definition: MCSymbolXCOFF.h:32
void setSymbolTableName(StringRef STN)
Definition: MCSymbolXCOFF.h:63
void setPerSymbolCodeModel(MCSymbolXCOFF::CodeModel Model)
Definition: MCSymbolXCOFF.h:86
void setStorageClass(XCOFF::StorageClass SC)
Definition: MCSymbolXCOFF.h:42
StringRef getUnqualifiedName() const
Definition: MCSymbolXCOFF.h:51
MCSectionXCOFF * getRepresentedCsect() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
void modifyFlags(uint32_t Value, uint32_t Mask) const
Modify the flags via a mask.
Definition: MCSymbol.h:430
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:205
uint32_t getFlags() const
Get the (implementation defined) symbol flags.
Definition: MCSymbol.h:421
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
Definition: MCSymbol.h:222
bool isXCOFF() const
Definition: MCSymbol.h:293
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
@ 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:251
@ SYM_V_UNSPECIFIED
Definition: XCOFF.h:252
StorageClass
Definition: XCOFF.h:170
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18