Add structured, interned HIR type foundation#32
Merged
Conversation
Introduce a structured Type model (Type/TypeKind/ScalarClass/TypeQualifier) with a single canonical decoder internType() and its exact inverse toLegacyHIRType(). internType reuses the existing TypeSemantics predicates to classify the overloaded HIRType name grammar (qualifier prefix, atomic<> generic, pointer suffix, ][ array dimensions); the exact core spelling and array tokens are preserved so re-serialization round-trips byte for byte. No production code consumes Type yet, so behavior is unchanged. A new crossgl_type_roundtrip_tests executable exhaustively verifies the round trip over all builtin spellings x qualifiers x pointer depths x array forms (plus atomics and struct names) and spot-checks structural classification. First step of the structured-type-system migration (issue #31); later steps move the TypeSemantics predicates and the backends onto Type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First step (issue #31) of replacing the string-based
HIRTypewith a structured, interned type system.HIRTypecurrently overloads a singlenamestring (qualifier prefix + base +atomic<>generic +*pointer suffix) plus a][-joinedarraySize, decoded by re-parsing strings at ~300 sites across ~38 files. This PR lays the foundation without changing any behavior.Changes
include/crossgl/HIR/Type.h— structuredType(TypeKind,ScalarClass,TypeQualifier, vector width, matrix shape, pointer depth, array dimensions, and the preserved core spelling).src/HIR/Type.cpp:internType(const HIRType&)— the single canonical decoder of the name/arraySize grammar, reusing the existingTypeSemanticspredicates for classification.toLegacyHIRType(const Type&)— exact inverse; preserves the core spelling and array tokens so re-serialization is byte-identical.tests/unit/TypeRoundTripTests.cpp(newcrossgl_type_roundtrip_testsctest) — exhaustive round-trip over all 57 builtin spellings × {none/buffer/uniform/shared} × {0,1,2 pointers} × {none,[],[4],[4][8]}, plusatomic<>and struct names, with structural classification spot-checks.Safety
No production code consumes
Typeyet, andtoLegacyHIRType(internType(t)) == tfor every type, so the existing golden suite cannot move.crossgl_compiler,cglc, andcrossgl_unit_testsbuild and link unchanged; the new round-trip test passes locally.Next (issue #31)
TypeSemanticspredicates on top ofType(same signatures); delete the divergent duplicate predicates.HIRTypestorage to an internedTypehandle.typeToIRto switch onTypeKind.Part of #31