LLVM 19.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"
14
15namespace llvm {
16
17class MCSectionXCOFF;
18
19class MCSymbolXCOFF : public MCSymbol {
20
21 enum XCOFFSymbolFlags : uint16_t { SF_EHInfo = 0x0001 };
22
23public:
26
27 static bool classof(const MCSymbol *S) { return S->isXCOFF(); }
28
29 enum CodeModel : uint8_t { CM_Small, CM_Large };
30
32 if (Name.back() == ']') {
33 StringRef Lhs, Rhs;
34 std::tie(Lhs, Rhs) = Name.rsplit('[');
35 assert(!Rhs.empty() && "Invalid SMC format in XCOFF symbol.");
36 return Lhs;
37 }
38 return Name;
39 }
40
42 StorageClass = SC;
43 };
44
46 assert(StorageClass && "StorageClass not set on XCOFF MCSymbol.");
47 return *StorageClass;
48 }
49
51
53
55
57
59
60 bool hasRename() const { return HasRename; }
61
63 SymbolTableName = STN;
64 HasRename = true;
65 }
66
68 if (hasRename())
69 return SymbolTableName;
70 return getUnqualifiedName();
71 }
72
73 bool isEHInfo() const { return getFlags() & SF_EHInfo; }
74
75 void setEHInfo() const { modifyFlags(SF_EHInfo, SF_EHInfo); }
76
77 bool hasPerSymbolCodeModel() const { return PerSymbolCodeModel.has_value(); }
78
81 "Requested code model for symbol without one");
82 return *PerSymbolCodeModel;
83 }
84
86 PerSymbolCodeModel = Model;
87 }
88
89private:
90 std::optional<XCOFF::StorageClass> StorageClass;
91 std::optional<CodeModel> PerSymbolCodeModel;
92
93 MCSectionXCOFF *RepresentedCsect = nullptr;
95 StringRef SymbolTableName;
96 bool HasRename = false;
97};
98
99} // end namespace llvm
100
101#endif // LLVM_MC_MCSYMBOLXCOFF_H
std::string Name
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
XCOFF::VisibilityType getVisibilityType() const
Definition: MCSymbolXCOFF.h:58
static bool classof(const MCSymbol *S)
Definition: MCSymbolXCOFF.h:27
StringRef getSymbolTableName() const
Definition: MCSymbolXCOFF.h:67
XCOFF::StorageClass getStorageClass() const
Definition: MCSymbolXCOFF.h:45
bool hasPerSymbolCodeModel() const
Definition: MCSymbolXCOFF.h:77
bool hasRename() const
Definition: MCSymbolXCOFF.h:60
void setVisibilityType(XCOFF::VisibilityType SVT)
Definition: MCSymbolXCOFF.h:56
void setEHInfo() const
Definition: MCSymbolXCOFF.h:75
CodeModel getPerSymbolCodeModel() const
Definition: MCSymbolXCOFF.h:79
bool isEHInfo() const
Definition: MCSymbolXCOFF.h:73
void setRepresentedCsect(MCSectionXCOFF *C)
static StringRef getUnqualifiedName(StringRef Name)
Definition: MCSymbolXCOFF.h:31
void setSymbolTableName(StringRef STN)
Definition: MCSymbolXCOFF.h:62
MCSymbolXCOFF(const StringMapEntry< bool > *Name, bool isTemporary)
Definition: MCSymbolXCOFF.h:24
void setPerSymbolCodeModel(MCSymbolXCOFF::CodeModel Model)
Definition: MCSymbolXCOFF.h:85
void setStorageClass(XCOFF::StorageClass SC)
Definition: MCSymbolXCOFF.h:41
StringRef getUnqualifiedName() const
Definition: MCSymbolXCOFF.h:50
MCSectionXCOFF * getRepresentedCsect() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:40
void modifyFlags(uint32_t Value, uint32_t Mask) const
Modify the flags via a mask.
Definition: MCSymbol.h:431
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:422
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