Skip to content

Conversation

@jgarzik
Copy link
Contributor

@jgarzik jgarzik commented Dec 7, 2025

No description provided.

@jgarzik jgarzik requested a review from Copilot December 7, 2025 03:58
@jgarzik jgarzik self-assigned this Dec 7, 2025
@jgarzik jgarzik added the enhancement New feature or request label Dec 7, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements type interning for the C compiler, replacing direct Type usage with TypeId references managed by a TypeTable. This architectural change follows the pattern established by IdentTable for string interning, reducing memory usage and enabling efficient type comparison by ID rather than deep structural comparison.

Key changes:

  • Introduces TypeId as a unique identifier for interned types and TypeTable for type storage and lookup
  • Migrates type query methods (size, alignment, compatibility checks) from Type to TypeTable
  • Updates all compiler phases (parsing, symbol management, IR generation, SSA conversion, code generation) to use TypeId and TypeTable

Reviewed changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
cc/types.rs Implements TypeId and TypeTable with type interning, deduplication, and pre-interned common types; moves type query methods from Type to TypeTable
cc/symbol.rs Updates Symbol to store TypeId instead of Type; enum_constant now requires TypeId parameter
cc/parse/ast.rs Changes AST expression and declaration nodes to use TypeId; updates test helpers
cc/parse/parser.rs Adds TypeTable to parser; updates all type operations to use interned TypeIds
cc/ir.rs Changes IR structures (Instruction, Function, Module) to use TypeId; adds with_type_and_size helper
cc/ssa.rs Updates SSA conversion to accept TypeTable and use TypeId for type queries
cc/arch/x86_64/codegen.rs Passes TypeTable through code generation; uses TypeTable for type queries
cc/arch/aarch64/codegen.rs Similar updates for AArch64 backend
cc/main.rs Creates TypeTable and passes it to parser and linearizer
cc/lower.rs Updates tests to use TypeTable
cc/dominate.rs Updates tests to use TypeTable

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jgarzik jgarzik merged commit 7cfdd27 into main Dec 7, 2025
4 checks passed
@jgarzik jgarzik deleted the cc branch December 7, 2025 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants