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

Reusable dataflow analyses and dead-code elimination over Compiler_IR_Model.H. More...

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

Go to the source code of this file.

Classes

struct  Aleph::Compiler_Dataflow_Bit_Set
 Small reusable bit-set for slot-domain dataflow analyses. More...
 
struct  Aleph::Compiler_Dataflow_Constant
 One propagated constant value in the local-slot lattice. More...
 
struct  Aleph::Compiler_Dataflow_Uninitialized_Read
 One definite-assignment finding for an uninitialized local read. More...
 
struct  Aleph::Compiler_Dataflow_Function_Analysis
 Full dataflow result for one IR function or top-level body. More...
 
struct  Aleph::Compiler_Dataflow_Validation_Report
 Validation report for analysis and optimization passes. More...
 
struct  Aleph::Compiler_Dead_Code_Elimination_Result
 Result of applying dead-code elimination to one IR function. More...
 
struct  Aleph::Compiler_Dataflow_Detail::Block_Use_Def
 
struct  Aleph::Compiler_Dataflow_Detail::Block_Simulation
 

Namespaces

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

Enumerations

enum class  Aleph::Compiler_Dataflow_Constant_Kind {
  Aleph::Unknown , Aleph::Undefined , Aleph::Integer , Aleph::Boolean ,
  Aleph::Unit
}
 Constant-lattice states used by local constant propagation. More...
 

Functions

const char * Aleph::compiler_dataflow_constant_kind_name (const Compiler_Dataflow_Constant_Kind kind) noexcept
 Returns a stable debug name for one constant-lattice kind.
 
Compiler_Dataflow_Constant Aleph::Compiler_Dataflow_Detail::unknown_constant ()
 
Compiler_Dataflow_Constant Aleph::Compiler_Dataflow_Detail::undefined_constant ()
 
Compiler_Dataflow_Constant Aleph::Compiler_Dataflow_Detail::integer_constant (const long long value)
 
Compiler_Dataflow_Constant Aleph::Compiler_Dataflow_Detail::boolean_constant (const bool value)
 
Compiler_Dataflow_Constant Aleph::Compiler_Dataflow_Detail::unit_constant ()
 
bool Aleph::Compiler_Dataflow_Detail::same_constant (const Compiler_Dataflow_Constant &lhs, const Compiler_Dataflow_Constant &rhs) noexcept
 
std::string Aleph::Compiler_Dataflow_Detail::constant_to_string (const Compiler_Dataflow_Constant &constant)
 
bool Aleph::Compiler_Dataflow_Detail::parse_integer_constant (const std::string &text, long long &value) noexcept
 
Compiler_Dataflow_Constant Aleph::Compiler_Dataflow_Detail::constant_from_instruction (const Compiler_IR_Instruction &inst)
 
Compiler_Dataflow_Constant Aleph::Compiler_Dataflow_Detail::meet_constants (const Compiler_Dataflow_Constant &lhs, const Compiler_Dataflow_Constant &rhs)
 
Compiler_Dataflow_Bit_Set Aleph::Compiler_Dataflow_Detail::make_bit_set (const size_t count, const bool value=false)
 
DynArray< Compiler_Dataflow_Constant > Aleph::Compiler_Dataflow_Detail::make_constant_vector (const size_t count, const Compiler_Dataflow_Constant &fill)
 
bool Aleph::Compiler_Dataflow_Detail::bit_set_equals (const Compiler_Dataflow_Bit_Set &lhs, const Compiler_Dataflow_Bit_Set &rhs) noexcept
 
bool Aleph::Compiler_Dataflow_Detail::constant_vector_equals (const DynArray< Compiler_Dataflow_Constant > &lhs, const DynArray< Compiler_Dataflow_Constant > &rhs) noexcept
 
Compiler_Dataflow_Bit_Set Aleph::Compiler_Dataflow_Detail::bit_set_union (const Compiler_Dataflow_Bit_Set &lhs, const Compiler_Dataflow_Bit_Set &rhs)
 
Compiler_Dataflow_Bit_Set Aleph::Compiler_Dataflow_Detail::bit_set_intersection (const Compiler_Dataflow_Bit_Set &lhs, const Compiler_Dataflow_Bit_Set &rhs)
 
Compiler_Dataflow_Bit_Set Aleph::Compiler_Dataflow_Detail::bit_set_subtract (const Compiler_Dataflow_Bit_Set &lhs, const Compiler_Dataflow_Bit_Set &rhs)
 
Compiler_Dataflow_Bit_Set Aleph::Compiler_Dataflow_Detail::initial_assigned_state (const Compiler_IR_Function &function)
 
DynArray< Compiler_Dataflow_Constant > Aleph::Compiler_Dataflow_Detail::initial_constant_state (const Compiler_IR_Function &function)
 
Compiler_Dataflow_Constant Aleph::Compiler_Dataflow_Detail::value_constant (const DynArray< Compiler_Dataflow_Constant > &values, const Compiler_IR_Value_Id id)
 
void Aleph::Compiler_Dataflow_Detail::mark_value_used (DynArray< unsigned char > &used_values, const Compiler_IR_Value_Id id)
 
bool Aleph::Compiler_Dataflow_Detail::is_value_used (const DynArray< unsigned char > &used_values, const Compiler_IR_Value_Id id) noexcept
 
bool Aleph::Compiler_Dataflow_Detail::is_pure_instruction (const Compiler_IR_Instruction &inst) noexcept
 
Compiler_Dataflow_Constant Aleph::Compiler_Dataflow_Detail::evaluate_unary (const Compiler_Operator_Kind op, const Compiler_Dataflow_Constant &operand)
 
Compiler_Dataflow_Constant Aleph::Compiler_Dataflow_Detail::evaluate_binary (const Compiler_Operator_Kind op, const Compiler_Dataflow_Constant &lhs, const Compiler_Dataflow_Constant &rhs)
 
Block_Use_Def Aleph::Compiler_Dataflow_Detail::compute_block_use_def (const Compiler_IR_Function &function, const Compiler_IR_Block &block)
 
DynArray< bool > Aleph::Compiler_Dataflow_Detail::compute_reachability (const Compiler_IR_Function &function)
 
Block_Simulation Aleph::Compiler_Dataflow_Detail::simulate_block (const Compiler_IR_Function &function, const Compiler_IR_Block &block, const Compiler_Dataflow_Bit_Set &assigned_in, const DynArray< Compiler_Dataflow_Constant > &constants_in, DynArray< Compiler_Dataflow_Uninitialized_Read > *findings=nullptr)
 
std::string Aleph::Compiler_Dataflow_Detail::format_slot_set (const Compiler_IR_Function &function, const Compiler_Dataflow_Bit_Set &set)
 
std::string Aleph::Compiler_Dataflow_Detail::format_slot_constants (const Compiler_IR_Function &function, const DynArray< Compiler_Dataflow_Constant > &constants)
 
void Aleph::Compiler_Dataflow_Detail::rebuild_predecessors (Compiler_IR_Function &function)
 
DynArray< DynArray< Compiler_IR_Block_Id > > Aleph::Compiler_Dataflow_Detail::compute_predecessor_lists (const Compiler_IR_Function &function)
 
size_t Aleph::Compiler_Dataflow_Detail::count_instructions (const Compiler_IR_Function &function)
 
bool Aleph::Compiler_Dataflow_Detail::instruction_is_trivially_dead (const Compiler_IR_Instruction &inst, const Compiler_Dataflow_Bit_Set &live_after, const DynArray< unsigned char > &used_values, const Compiler_IR_Function &function) noexcept
 
Compiler_Dataflow_Function_Analysis Aleph::analyze_dataflow_function (const Compiler_IR_Function &function)
 Computes reachability, liveness, definite assignment, and constant propagation for one IR function.
 
Compiler_Dataflow_Validation_Report Aleph::validate_dataflow_analysis (const Compiler_IR_Function &function, const Compiler_Dataflow_Function_Analysis &analysis)
 Validates structural invariants of a dataflow result against its source function.
 
std::string Aleph::compiler_dump_dataflow_analysis (const Compiler_IR_Function *function, const Compiler_Dataflow_Function_Analysis &analysis, const Compiler_Type_Context *types=nullptr)
 Produces a deterministic, human-readable dump of a dataflow result.
 
Compiler_Dead_Code_Elimination_Result Aleph::eliminate_dead_code (const Compiler_IR_Function &function)
 Eliminates unreachable blocks, dead pure instructions, dead local stores, and folds constant-condition branches.
 
Compiler_Dataflow_Validation_Report Aleph::validate_dead_code_elimination (const Compiler_Dead_Code_Elimination_Result &result, const Compiler_IR_Module *module=nullptr)
 Validates the result of dead-code elimination.
 

Detailed Description

Reusable dataflow analyses and dead-code elimination over Compiler_IR_Model.H.

This header adds the first optimization-oriented layer on top of the reusable non-SSA IR. The current scope remains intentionally conservative:

  • block reachability
  • local-slot liveness
  • definite assignment / initialization for parameters and locals
  • local constant propagation with a small constant lattice
  • dead-code elimination of unreachable blocks, dead pure values, dead local stores, and branches proven constant
  • invariant validators for analysis and DCE results

The analyses operate per Compiler_IR_Function, including the lowered top-level body when represented as <top-level>.

Definition in file Compiler_Dataflow.H.