feat: first prototype of optimizers + alloca optimizer

This commit is contained in:
2026-01-01 22:08:43 +01:00
parent 8a2d98e69e
commit 0b9cb7e7d9
12 changed files with 274 additions and 40 deletions

View File

@@ -1,4 +1,5 @@
#pragma once
#include <cstdint>
#include "prelude/string.hpp"
namespace IR
@@ -104,8 +105,8 @@ namespace IR
class Pointer : public ValueHandle
{
public:
Pointer(unsigned int id)
: ValueHandle(id)
Pointer(unsigned int id, const Type* value_typ)
: ValueHandle(id), m_value_typ(new Type(value_typ))
{
m_type = new Type{Type::Kind::Ptr};
}
@@ -120,16 +121,19 @@ namespace IR
return sb.view();
}
public:
const Type *GetValueType() const { return m_value_typ; }
private:
Type *m_type;
Type *m_value_typ;
};
// TODO: Remove void value and use void type only
class Void : public ValueHandle
{
public:
Void(unsigned int id)
: ValueHandle(id)
Void()
: ValueHandle()
{
m_type = new Type{Type::Kind::Void};
}