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

Portable C backend that emits standalone C from Compiler_IR_Model.H. More...

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

Go to the source code of this file.

Classes

struct  Aleph::Compiler_C_Backend_Options
 Options that control one C backend emission request. More...
 
struct  Aleph::Compiler_C_Backend_Emission
 Result of one C backend emission request. More...
 
class  Aleph::Compiler_C_Backend
 Emits portable C from one validated Compiler_IR_Module. More...
 
struct  Aleph::Compiler_C_Backend::Symbol_Names
 
class  Aleph::Compiler_C_Backend::Emitter
 

Namespaces

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

Functions

std::string Aleph::Compiler_Backend_C_Detail::sanitize_identifier (std::string_view text)
 
std::string Aleph::Compiler_Backend_C_Detail::upper_identifier (std::string_view text)
 
std::string Aleph::Compiler_Backend_C_Detail::c_string_literal (std::string_view text)
 
std::string Aleph::Compiler_Backend_C_Detail::safe_comment_text (std::string text)
 
bool Aleph::Compiler_Backend_C_Detail::parse_integer_literal (const std::string &text, long long &value) noexcept
 
size_t Aleph::Compiler_Backend_C_Detail::count_parameters (const Compiler_IR_Function &function) noexcept
 
std::string Aleph::Compiler_Backend_C_Detail::token_name (const Compiler_Operator_Kind kind) noexcept
 
std::string Aleph::Compiler_Backend_C_Detail::value_name (const Compiler_IR_Value_Id id)
 
std::string Aleph::Compiler_Backend_C_Detail::local_name (const Compiler_IR_Local_Slot_Id id)
 
std::string Aleph::Compiler_Backend_C_Detail::global_name (const Compiler_IR_Global_Slot_Id id)
 
std::string Aleph::Compiler_Backend_C_Detail::block_label (const size_t id)
 
std::string Aleph::Compiler_Backend_C_Detail::indent (const size_t count)
 
Compiler_C_Backend_Emission Aleph::compiler_emit_c_module (const Compiler_IR_Module *module, const Compiler_C_Backend_Options &options={}, const Compiler_Type_Context *types=nullptr)
 Convenience wrapper that emits one IR module to portable C.
 

Detailed Description

Portable C backend that emits standalone C from Compiler_IR_Model.H.

This header introduces the first source-emitting backend in the compiler platform. The goal is not to model final ABI/layout decisions yet, but to provide a readable, deterministic, and executable lowering target that can be used for:

  • validating the explicit IR end-to-end
  • experimenting with emit-c workflows before a full driver exists
  • generating portable artifacts that can be compiled by a normal C toolchain

The emitted C intentionally stays close to the structure of Compiler_IR_Model.H:

  • each IR function becomes one C function
  • each IR block becomes one C label plus goto-based control flow
  • each IR value id becomes one local temporary
  • each local/global slot remains explicit
  • a tiny tagged-value runtime is embedded in the generated translation unit

The current MVP favors clarity and portability over performance. It is therefore a good bridge between the reusable IR and future lower-level backends such as LLVM IR or native assembly.

Definition in file Compiler_Backend_C.H.