Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Compiler_IR_Model.H File Reference

Reusable explicit-value IR model, validation, and deterministic dumps. More...

#include <limits>
#include <sstream>
#include <string>
#include <utility>
#include <Compiler_HIR_Model.H>
#include <ah-arena.H>
#include <ah-errors.H>
#include <tpl_dynArray.H>
Include dependency graph for Compiler_IR_Model.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Aleph::Compiler_IR_Slot
 One storage slot used by the IR. More...
 
struct  Aleph::Compiler_IR_Instruction
 One instruction producing an optional explicit result value. More...
 
struct  Aleph::Compiler_IR_Terminator
 Explicit terminator for one IR basic block. More...
 
struct  Aleph::Compiler_IR_Block
 One basic block of IR instructions. More...
 
struct  Aleph::Compiler_IR_Function
 Lowered IR for one function or top-level body. More...
 
struct  Aleph::Compiler_IR_Module
 Lowered IR module with shared global slots and functions. More...
 
class  Aleph::Compiler_IR_Context
 Arena-backed ownership context for IR nodes. More...
 
struct  Aleph::Compiler_IR_Context::Owned_Object
 
struct  Aleph::Compiler_IR_Validation_Report
 Structural validation report for one IR module or function. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::Compiler_IR_Detail
 

Typedefs

using Aleph::Compiler_IR_Value_Id = size_t
 
using Aleph::Compiler_IR_Local_Slot_Id = size_t
 
using Aleph::Compiler_IR_Global_Slot_Id = size_t
 
using Aleph::Compiler_IR_Function_Id = size_t
 
using Aleph::Compiler_IR_Block_Id = size_t
 

Enumerations

enum class  Aleph::Compiler_IR_Slot_Kind { Aleph::Parameter , Aleph::Local , Aleph::Global }
 Storage-space classification for slots. More...
 
enum class  Aleph::Compiler_IR_Instruction_Kind {
  Aleph::Constant , Aleph::Load , Aleph::Store , Aleph::Unary ,
  Aleph::Binary , Aleph::Call , Aleph::Function_Ref
}
 Instruction kinds supported by the MVP IR. More...
 
enum class  Aleph::Compiler_IR_Terminator_Kind {
  Aleph::None , Aleph::Jump , Aleph::Branch , Aleph::Return ,
  Aleph::Exit , Aleph::Unreachable
}
 Terminator kinds supported by the MVP IR. More...
 

Functions

constexpr size_t Aleph::compiler_ir_invalid_id () noexcept
 Returns the sentinel invalid IR id.
 
const char * Aleph::compiler_ir_slot_kind_name (const Compiler_IR_Slot_Kind kind) noexcept
 Stable debug name for one slot kind.
 
const char * Aleph::compiler_ir_instruction_kind_name (const Compiler_IR_Instruction_Kind kind) noexcept
 Stable debug name for one instruction kind.
 
const char * Aleph::compiler_ir_terminator_kind_name (const Compiler_IR_Terminator_Kind kind) noexcept
 Stable debug name for one terminator kind.
 
std::string Aleph::Compiler_IR_Detail::block_name (const Compiler_IR_Block_Id id)
 
bool Aleph::Compiler_IR_Detail::contains_block_id (const DynArray< Compiler_IR_Block_Id > &ids, const Compiler_IR_Block_Id id) noexcept
 
std::string Aleph::Compiler_IR_Detail::value_name (const Compiler_IR_Value_Id id)
 
std::string Aleph::Compiler_IR_Detail::local_slot_name (const Compiler_IR_Local_Slot_Id id)
 
std::string Aleph::Compiler_IR_Detail::global_slot_name (const Compiler_IR_Global_Slot_Id id)
 
std::string Aleph::Compiler_IR_Detail::function_name (const Compiler_IR_Function_Id id)
 
void Aleph::Compiler_IR_Detail::append_indented_text (std::ostream &out, const std::string &text, const size_t indent)
 
Compiler_IR_Validation_Report Aleph::validate_ir_function (const Compiler_IR_Function &function, const Compiler_IR_Module *module=nullptr)
 Validates one lowered IR function structurally.
 
Compiler_IR_Validation_Report Aleph::validate_ir_module (const Compiler_IR_Module &module)
 Validates all functions in one lowered IR module.
 
std::string Aleph::compiler_dump_ir_function (const Compiler_IR_Function *function, const Compiler_IR_Module *module=nullptr, const Compiler_Type_Context *types=nullptr)
 Dumps one lowered IR function deterministically.
 
std::string Aleph::compiler_dump_ir_module (const Compiler_IR_Module *module, const Compiler_Type_Context *types=nullptr)
 Dumps all lowered IR in one module deterministically.
 

Detailed Description

Reusable explicit-value IR model, validation, and deterministic dumps.

This header defines the stable middle-level IR node model that language frontends, optimizers, interpreters, and source-emitting backends can share without depending on the current reference frontend. It includes:

  • explicit result values (v0, v1, ...)
  • explicit storage slots for parameters, locals, and globals
  • linear instructions inside basic blocks
  • explicit control-flow terminators
  • structural validation helpers
  • deterministic textual dump helpers

Lowering from the current MVP HIR lives separately in Compiler_IR_Lowering_MVP.H.

Definition in file Compiler_IR_Model.H.