Skip to content

[HC-007] Hard cutover lowering and IR emission into typed codegen modules #8138

@doublemover

Description

@doublemover

Hard cutover policy: lowering builds a typed IR model, and emission serializes that model. No mixed semantic checks inside IR emission, no report text construction inside codegen, no direct string assembly for structured metadata.

Source facts already established:

  • native/objc3c/src/ir/objc3_ir_emitter.cpp has 14,665 lines.
  • Objc3IREmitter owns expression emission, statement emission, function emission, method emission, runtime metadata, proof comments, entrypoint generation, property storage, synthesized methods, and lowering summaries.
  • native/objc3c/src/lower/objc3_lowering_contract.cpp has 5,077 lines and mixes contracts with implementation-ready lowerable state.

Required lowering tree:

  • native/objc3c/src/lower/core/
    • lowering_context.h/.cpp
    • lowering_result.h
    • lowering_diagnostics.h/.cpp
  • native/objc3c/src/lower/model/
    • lowered_module.h/.cpp
    • lowered_function.h/.cpp
    • lowered_value.h/.cpp
    • lowered_type.h/.cpp
  • native/objc3c/src/lower/expr/
    • literal_lowering.h/.cpp
    • identifier_lowering.h/.cpp
    • call_lowering.h/.cpp
    • message_send_lowering.h/.cpp
    • keypath_lowering.h/.cpp
    • block_literal_lowering.h/.cpp
  • native/objc3c/src/lower/stmt/
    • statement_lowering.h/.cpp
    • control_flow_lowering.h/.cpp
    • defer_lowering.h/.cpp
    • error_lowering.h/.cpp
    • concurrency_lowering.h/.cpp
  • native/objc3c/src/lower/objc/
    • class_metadata_lowering.h/.cpp
    • method_lowering.h/.cpp
    • property_lowering.h/.cpp
    • dispatch_lowering.h/.cpp
  • native/objc3c/src/lower/ownership/
    • arc_lowering.h/.cpp
    • autorelease_lowering.h/.cpp
    • weak_lowering.h/.cpp

Required IR tree:

  • native/objc3c/src/ir/model/
    • ir_module.h/.cpp
    • ir_function.h/.cpp
    • ir_instruction.h/.cpp
    • ir_metadata.h/.cpp
  • native/objc3c/src/ir/write/
    • ir_text_writer.h/.cpp
    • ir_metadata_writer.h/.cpp
    • ir_constant_writer.h/.cpp
  • native/objc3c/src/ir/emit/
    • module_emitter.h/.cpp
    • function_emitter.h/.cpp
    • expression_emitter.h/.cpp
    • statement_emitter.h/.cpp
    • objc_metadata_emitter.h/.cpp
    • runtime_call_emitter.h/.cpp
    • entrypoint_emitter.h/.cpp

Required work:

  • Split lowering from IR text emission.
  • Move runtime ABI symbol names into ir/emit/runtime_call_emitter.*.
  • Move metadata record construction into lower/objc/* and serialization into ir/write/*.
  • Move proof, readiness, and report strings to artifacts/.
  • Replace direct string concatenation for structured metadata with IR metadata writer APIs.
  • Delete old monolithic objc3_ir_emitter.cpp and oversized lowering contract implementation.

Maximum effort shared hoist pass:

  • Hoist identifier-safe suffix logic to support/identifiers/.
  • Hoist global initializer evaluation to lower/core/constant_eval.*.
  • Hoist runtime ABI name construction to ir/emit/runtime_call_emitter.*.
  • Hoist stable metadata ordering to support/stable_order/.

Acceptance criteria:

  • No IR or lowering source file exceeds 1,500 lines.
  • IR emission consumes a typed lowered module.
  • Metadata serialization uses writer APIs.
  • Codegen tests cover expressions, statements, message sends, properties, blocks, errors, and entrypoint emission through module-level fixtures.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions