diff options
| author | Copilot <198982749+Copilot@users.noreply.github.com> | 2025-07-15 10:11:39 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-15 10:11:39 +0000 |
| commit | d964555d2ee83fac2ba357e4ec81e2a393a7b12f (patch) | |
| tree | 2ae1591535f39a75c8231e2cf56b6492d330c820 /source/slang/slang-ir-util.cpp | |
| parent | 66d915ac8ec6ab31320c8dbbb43027b33e3a69fd (diff) | |
Replace [KnownBuiltin] string-based comparisons with enum-based system (#7714)
* Initial plan
* Implement enum-based KnownBuiltin system to replace string comparisons
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Add test for enum-based KnownBuiltin system and verify functionality
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Implement enum-based KnownBuiltin system with direct integer values
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Fix IntVal access and update tests for new enum-based KnownBuiltin system
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Replace hardcoded KnownBuiltin integers with preprocessor enum syntax
- Updated all KnownBuiltin attributes to use $( (int)KnownBuiltinDeclName::EnumValue) syntax
- Added space between parentheses to avoid preprocessor bug: $( (int) instead of $((int)
- Updated both core.meta.slang and hlsl.meta.slang files
- Eliminates preprocessor-time integer conversion, baking enum values directly into meta files
- Maintains same functionality while using type-safe enum references
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Fix IDifferentiablePtr KnownBuiltin mapping regression
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Remove unused IDifferentiablePtrType enum case from KnownBuiltinDeclName
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Clean up temporary AST dump files from testing
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Replace hardcoded integer with descriptive constant in KnownBuiltin test
Replace the hardcoded [KnownBuiltin(0)] with a descriptive named constant
GEOMETRY_STREAM_APPEND_BUILTIN to improve code readability and maintainability.
The test now clearly indicates which builtin enum value is being tested.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Gangzheng Tong <gtong-nv@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Gangzheng Tong <gtong-nv@users.noreply.github.com>
Co-authored-by: Gangzheng Tong <tonggangzheng@gmail.com>
Diffstat (limited to 'source/slang/slang-ir-util.cpp')
| -rw-r--r-- | source/slang/slang-ir-util.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp index 69bd2c6c2..c8d76569f 100644 --- a/source/slang/slang-ir-util.cpp +++ b/source/slang/slang-ir-util.cpp @@ -1775,6 +1775,38 @@ UnownedStringSlice getBuiltinFuncName(IRInst* callee) auto decor = getResolvedInstForDecorations(callee)->findDecoration<IRKnownBuiltinDecoration>(); if (!decor) return UnownedStringSlice(); + + // For backward compatibility, convert enum back to string + switch (decor->getName()) + { + case KnownBuiltinDeclName::GeometryStreamAppend: + return UnownedStringSlice::fromLiteral("GeometryStreamAppend"); + case KnownBuiltinDeclName::GeometryStreamRestart: + return UnownedStringSlice::fromLiteral("GeometryStreamRestart"); + case KnownBuiltinDeclName::GetAttributeAtVertex: + return UnownedStringSlice::fromLiteral("GetAttributeAtVertex"); + case KnownBuiltinDeclName::DispatchMesh: + return UnownedStringSlice::fromLiteral("DispatchMesh"); + case KnownBuiltinDeclName::saturated_cooperation: + return UnownedStringSlice::fromLiteral("saturated_cooperation"); + case KnownBuiltinDeclName::saturated_cooperation_using: + return UnownedStringSlice::fromLiteral("saturated_cooperation_using"); + case KnownBuiltinDeclName::IDifferentiable: + return UnownedStringSlice::fromLiteral("IDifferentiable"); + case KnownBuiltinDeclName::IDifferentiablePtr: + return UnownedStringSlice::fromLiteral("IDifferentiablePtr"); + case KnownBuiltinDeclName::NullDifferential: + return UnownedStringSlice::fromLiteral("NullDifferential"); + default: + return UnownedStringSlice(); + } +} + +KnownBuiltinDeclName getBuiltinFuncEnum(IRInst* callee) +{ + auto decor = getResolvedInstForDecorations(callee)->findDecoration<IRKnownBuiltinDecoration>(); + if (!decor) + return KnownBuiltinDeclName::COUNT; // Use COUNT as invalid value return decor->getName(); } |
