MCSymbolCOFF.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- MCSymbolCOFF.h - ----------------------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_MC_MCSYMBOLCOFF_H
  14. #define LLVM_MC_MCSYMBOLCOFF_H
  15. #include "llvm/MC/MCSymbol.h"
  16. #include <cstdint>
  17. namespace llvm {
  18. class MCSymbolCOFF : public MCSymbol {
  19. /// This corresponds to the e_type field of the COFF symbol.
  20. mutable uint16_t Type = 0;
  21. enum SymbolFlags : uint16_t {
  22. SF_ClassMask = 0x00FF,
  23. SF_ClassShift = 0,
  24. SF_WeakExternal = 0x0100,
  25. SF_SafeSEH = 0x0200,
  26. };
  27. public:
  28. MCSymbolCOFF(const StringMapEntry<bool> *Name, bool isTemporary)
  29. : MCSymbol(SymbolKindCOFF, Name, isTemporary) {}
  30. uint16_t getType() const {
  31. return Type;
  32. }
  33. void setType(uint16_t Ty) const {
  34. Type = Ty;
  35. }
  36. uint16_t getClass() const {
  37. return (getFlags() & SF_ClassMask) >> SF_ClassShift;
  38. }
  39. void setClass(uint16_t StorageClass) const {
  40. modifyFlags(StorageClass << SF_ClassShift, SF_ClassMask);
  41. }
  42. bool isWeakExternal() const {
  43. return getFlags() & SF_WeakExternal;
  44. }
  45. void setIsWeakExternal() const {
  46. modifyFlags(SF_WeakExternal, SF_WeakExternal);
  47. }
  48. bool isSafeSEH() const {
  49. return getFlags() & SF_SafeSEH;
  50. }
  51. void setIsSafeSEH() const {
  52. modifyFlags(SF_SafeSEH, SF_SafeSEH);
  53. }
  54. static bool classof(const MCSymbol *S) { return S->isCOFF(); }
  55. };
  56. } // end namespace llvm
  57. #endif // LLVM_MC_MCSYMBOLCOFF_H
  58. #ifdef __GNUC__
  59. #pragma GCC diagnostic pop
  60. #endif