LLVM  10.0.0
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/Optional.h"
12 #include "llvm/ADT/StringRef.h"
14 #include "llvm/MC/MCSymbol.h"
15 
16 namespace llvm {
17 
18 class MCSectionXCOFF;
19 
20 class MCSymbolXCOFF : public MCSymbol {
21 public:
23  : MCSymbol(SymbolKindXCOFF, Name, isTemporary) {}
24 
25  static bool classof(const MCSymbol *S) { return S->isXCOFF(); }
26 
28  assert((!StorageClass.hasValue() || StorageClass.getValue() == SC) &&
29  "Redefining StorageClass of XCOFF MCSymbol.");
30  StorageClass = SC;
31  };
32 
34  assert(StorageClass.hasValue() &&
35  "StorageClass not set on XCOFF MCSymbol.");
36  return StorageClass.getValue();
37  }
38 
40  assert((!ContainingCsect || ContainingCsect == C) &&
41  "Trying to set a containing csect that doesn't match the one that"
42  "this symbol is already mapped to.");
43  ContainingCsect = C;
44  }
45 
47  assert(ContainingCsect &&
48  "Trying to get containing csect but none was set.");
49  return ContainingCsect;
50  }
51 
52  bool hasContainingCsect() const { return ContainingCsect != nullptr; }
53 
55  const StringRef name = getName();
56  if (name.back() == ']') {
57  StringRef lhs, rhs;
58  std::tie(lhs, rhs) = name.rsplit('[');
59  assert(!rhs.empty() && "Invalid SMC format in XCOFF symbol.");
60  return lhs;
61  }
62  return name;
63  }
64 
65 private:
66  Optional<XCOFF::StorageClass> StorageClass;
67  MCSectionXCOFF *ContainingCsect = nullptr;
68 };
69 
70 } // end namespace llvm
71 
72 #endif // LLVM_MC_MCSYMBOLXCOFF_H
uint64_t CallInst * C
static const char * name
This class represents lattice values for constants.
Definition: AllocatorList.h:23
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMap.h:158
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
LLVM_NODISCARD std::pair< StringRef, StringRef > rsplit(StringRef Separator) const
Split into two substrings around the last occurrence of a separator string.
Definition: StringRef.h:751
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:147
StringRef getUnqualifiedName() const
Definition: MCSymbolXCOFF.h:54
StorageClass
Definition: XCOFF.h:77
static bool classof(const MCSymbol *S)
Definition: MCSymbolXCOFF.h:25
const T & getValue() const LLVM_LVALUE_FUNCTION
Definition: Optional.h:255
MCSymbolXCOFF(const StringMapEntry< bool > *Name, bool isTemporary)
Definition: MCSymbolXCOFF.h:22
bool isXCOFF() const
Definition: MCSymbol.h:282
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
Definition: MCSymbol.h:213
MCSectionXCOFF * getContainingCsect() const
Definition: MCSymbolXCOFF.h:46
void setStorageClass(XCOFF::StorageClass SC)
Definition: MCSymbolXCOFF.h:27
LLVM_NODISCARD char back() const
back - Get the last character in the string.
Definition: StringRef.h:162
CHAIN = SC CHAIN, Imm128 - System call.
bool hasContainingCsect() const
Definition: MCSymbolXCOFF.h:52
bool hasValue() const
Definition: Optional.h:259
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:196
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
XCOFF::StorageClass getStorageClass() const
Definition: MCSymbolXCOFF.h:33
void setContainingCsect(MCSectionXCOFF *C)
Definition: MCSymbolXCOFF.h:39
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:54