feat: move allocator and slots into codegen folder

This commit is contained in:
2026-01-01 16:09:33 +01:00
parent 7995dd2bdf
commit ad17a59d65
2 changed files with 11 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include "prelude/string.hpp" #include "prelude/string.hpp"
#include "ir/slot.hpp" #include "codegen/slot.hpp"
#define AVAILABLE_REGISTERS 4 #define AVAILABLE_REGISTERS 4
#define AVAILABLE_STACK_SIZE 4096 #define AVAILABLE_STACK_SIZE 4096
@@ -10,6 +10,7 @@ class Allocator
{ {
public: public:
virtual ~Allocator() {}; virtual ~Allocator() {};
public: public:
virtual const Slot &Allocate(SlotAddr addr) = 0; virtual const Slot &Allocate(SlotAddr addr) = 0;
virtual const Slot &Resolve(SlotAddr addr) = 0; virtual const Slot &Resolve(SlotAddr addr) = 0;
@@ -20,6 +21,7 @@ class SlotAllocator : public Allocator<IR::IRSlot>
public: public:
SlotAllocator() = default; SlotAllocator() = default;
~SlotAllocator() = default; ~SlotAllocator() = default;
public: public:
const IR::IRSlot &Allocate(const StringView &addr) override const IR::IRSlot &Allocate(const StringView &addr) override
{ {
@@ -50,10 +52,13 @@ public:
assert(0 && "could not resolve stack offset for specified address"); assert(0 && "could not resolve stack offset for specified address");
} }
public: public:
View<IR::IRSlot> slots() const { return m_slots.view(); } View<IR::IRSlot> slots() const { return m_slots.view(); }
public: public:
unsigned int GetStackSize() const { return m_offset_counter; } unsigned int GetStackSize() const { return m_offset_counter; }
public: public:
int m_regs = 0; int m_regs = 0;
unsigned int m_offset_counter = 0; unsigned int m_offset_counter = 0;