aboutsummaryrefslogtreecommitdiff
path: root/backend/include/rcc/MC/MCSymbol.h
diff options
context:
space:
mode:
Diffstat (limited to 'backend/include/rcc/MC/MCSymbol.h')
-rw-r--r--backend/include/rcc/MC/MCSymbol.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/backend/include/rcc/MC/MCSymbol.h b/backend/include/rcc/MC/MCSymbol.h
new file mode 100644
index 0000000..1b7b878
--- /dev/null
+++ b/backend/include/rcc/MC/MCSymbol.h
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#ifndef RCC_MC_MCSYMBOL_H
+#define RCC_MC_MCSYMBOL_H
+
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <string_view>
+
+namespace rcc::mc {
+
+class MCContext;
+
+enum class MCSymbolKind : std::uint8_t {
+ Generic,
+ Function,
+ Object,
+ BasicBlock,
+ ConstantPool,
+ JumpTable,
+ LiteralIsland,
+ Section,
+ Temporary,
+};
+
+class MCSymbol final {
+public:
+ [[nodiscard]] std::string_view name() const noexcept {
+ return Name;
+ }
+
+ [[nodiscard]] MCSymbolKind kind() const noexcept {
+ return Kind;
+ }
+
+ [[nodiscard]] bool isTemporary() const noexcept {
+ return Kind == MCSymbolKind::Temporary || Kind == MCSymbolKind::BasicBlock ||
+ Kind == MCSymbolKind::ConstantPool || Kind == MCSymbolKind::JumpTable ||
+ Kind == MCSymbolKind::LiteralIsland;
+ }
+
+private:
+ MCSymbol(std::string Name, MCSymbolKind Kind) : Name(std::move(Name)), Kind(Kind) {}
+
+ std::string Name;
+ MCSymbolKind Kind;
+
+ friend class MCContext;
+};
+
+using MCSymbolRef = std::shared_ptr<const MCSymbol>;
+
+} // namespace rcc::mc
+
+#endif // RCC_MC_MCSYMBOL_H