summaryrefslogtreecommitdiffstats
path: root/source/slang-core-module
diff options
context:
space:
mode:
authorDarren Wihandi <65404740+fairywreath@users.noreply.github.com>2024-12-27 02:52:49 -0500
committerGitHub <noreply@github.com>2024-12-26 23:52:49 -0800
commit7cecc518e753a90d9b638e8dd1140730ab010ca7 (patch)
tree2d8769853421ffda8671e7d10b79e53f2e9c25f9 /source/slang-core-module
parent2ad1f8138771cef32b710f8c47d4c7beb3f4eab5 (diff)
Add packed 8bit builtin types (#5939)
* Add packed bytes builtin type * fix test
Diffstat (limited to 'source/slang-core-module')
-rw-r--r--source/slang-core-module/slang-embedded-core-module-source.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/source/slang-core-module/slang-embedded-core-module-source.cpp b/source/slang-core-module/slang-embedded-core-module-source.cpp
index 2f606cff4..557b50eb2 100644
--- a/source/slang-core-module/slang-embedded-core-module-source.cpp
+++ b/source/slang-core-module/slang-embedded-core-module-source.cpp
@@ -56,6 +56,12 @@ enum BaseTypeConversionRank : uint8_t
kBaseTypeConversionRank_Int32,
kBaseTypeConversionRank_IntPtr,
kBaseTypeConversionRank_Int64,
+
+ // Packed type conversion ranks where the overall rank order does not apply.
+ // They must be explicitly casted to another type.
+ kBaseTypeConversionRank_Int8x4Packed,
+ kBaseTypeConversionRank_UInt8x4Packed,
+
kBaseTypeConversionRank_Error,
};
@@ -150,6 +156,16 @@ static const BaseTypeConversionInfo kBaseTypes[] = {
kBaseTypeConversionKind_Unsigned,
kBaseTypeConversionRank_IntPtr},
+ {"int8_t4_packed",
+ BaseType::Int8x4Packed,
+ 0,
+ kBaseTypeConversionKind_Unsigned,
+ kBaseTypeConversionRank_Int8x4Packed},
+ {"uint8_t4_packed",
+ BaseType::UInt8x4Packed,
+ 0,
+ kBaseTypeConversionKind_Unsigned,
+ kBaseTypeConversionRank_UInt8x4Packed},
};
void Session::finalizeSharedASTBuilder()
@@ -176,6 +192,11 @@ void Session::finalizeSharedASTBuilder()
globalAstBuilder->getBuiltinType(baseType.tag);
}
+static bool isConversionRankPackedType(BaseTypeConversionRank rank)
+{
+ return (rank == BaseTypeConversionRank::kBaseTypeConversionRank_Int8x4Packed) ||
+ (rank == BaseTypeConversionRank::kBaseTypeConversionRank_UInt8x4Packed);
+}
// Given two base types, we need to be able to compute the cost of converting between them.
ConversionCost getBaseTypeConversionCost(
@@ -189,6 +210,14 @@ ConversionCost getBaseTypeConversionCost(
return kConversionCost_None;
}
+ // Handle special case for packed types, where they must be explicitly casted to another type.
+ bool isToPackedType = isConversionRankPackedType(toInfo.conversionRank);
+ bool isFromPackedType = isConversionRankPackedType(fromInfo.conversionRank);
+ if (isToPackedType || isFromPackedType)
+ {
+ return kConversionCost_GeneralConversion;
+ }
+
// Conversions within the same kind are easist to handle
if (toInfo.conversionKind == fromInfo.conversionKind)
{