-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Description
Implement the translation of astx.StructDefStmt to LLVM IR identified struct types. This is the foundation for struct support in IRx.
Background
astxalready providesStructDefStmtfor defining structs- IRx needs to translate this to LLVM's
IdentifiedStructType - Inspired by LLVM's CodeGenTypes.cpp
Tasks
- Add
struct_types: dict[str, ir.IdentifiedStructType]inLLVMLiteIRVisitorto track struct name → LLVM type mapping - Add
struct_defs: dict[str, astx.StructDefStmt]to store struct definitions for field lookup - Implement
visit(node: astx.StructDefStmt)visitor method:- Create LLVM
IdentifiedStructTypeusingmodule.context.get_identified_type(name) - Map each field's astx type to LLVM type using
get_data_type() - Set struct body with
struct_type.set_body(*field_types)
- Create LLVM
Example Input (Python)
struct_def = astx.StructDefStmt(
name="Point",
attributes=[
astx.VariableDeclaration(name="x", type_=astx.Int32()),
astx.VariableDeclaration(name="y", type_=astx.Int32()),
],
)Expected LLVM IR Output
%"Point" = type {i32, i32}Files to Modify
src/irx/builders/llvmliteir.py
Acceptance Criteria
-
StructDefStmttranslates to LLVMIdentifiedStructType - Struct types are registered and can be looked up by name
- Unit test
test_struct_definitionpasses
Metadata
Metadata
Assignees
Labels
No labels