summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-lower-generic-function.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-08-28 09:04:55 -0700
committerGitHub <noreply@github.com>2020-08-28 09:04:55 -0700
commitab5b0a7f9fbc47f7c51a7ec4a20ac0be55333e93 (patch)
treeabeb62d38f2af31e39a6dac216bc77e88af8ffbc /source/slang/slang-ir-lower-generic-function.cpp
parente9bf8de3123563df6f2ca4d3b99291c6a8c99d5d (diff)
Enable lower-generics pass universally. (#1518)
* Enable lower-generics pass universally. * Exclude builtin interfaces and functions from lower-generics pass. * Update stdlib. * Fixup. * Fixes handling of nested intrinsic generic functions. * Fixes. * Fixes.
Diffstat (limited to 'source/slang/slang-ir-lower-generic-function.cpp')
-rw-r--r--source/slang/slang-ir-lower-generic-function.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/source/slang/slang-ir-lower-generic-function.cpp b/source/slang/slang-ir-lower-generic-function.cpp
index f9a7e0a24..c02e9e3d6 100644
--- a/source/slang/slang-ir-lower-generic-function.cpp
+++ b/source/slang/slang-ir-lower-generic-function.cpp
@@ -21,9 +21,21 @@ namespace Slang
IRInst* result = nullptr;
if (sharedContext->loweredGenericFunctions.TryGetValue(genericValue, result))
return result;
+ // Do not lower intrinsic functions.
+ if (genericValue->findDecoration<IRTargetIntrinsicDecoration>())
+ return genericValue;
auto genericParent = as<IRGeneric>(genericValue);
SLANG_ASSERT(genericParent);
auto func = as<IRFunc>(findGenericReturnVal(genericParent));
+ if (!func)
+ {
+ // Nested generic functions are supposed to be flattened before entering
+ // this pass. The reason we are still seeing them must be that they are
+ // intrinsic functions. In this case we ignore the function.
+ SLANG_ASSERT(findInnerMostGenericReturnVal(genericParent)
+ ->findDecoration<IRTargetIntrinsicDecoration>() != nullptr);
+ return genericValue;
+ }
SLANG_ASSERT(func);
if (!func->isDefinition())
{
@@ -133,7 +145,9 @@ namespace Slang
return loweredType;
if (sharedContext->mapLoweredInterfaceToOriginal.ContainsKey(interfaceType))
return interfaceType;
-
+ // Do not lower intrinsic interfaces.
+ if (isBuiltin(interfaceType))
+ return interfaceType;
List<IRInterfaceRequirementEntry*> newEntries;
IRBuilder builder;
@@ -189,6 +203,8 @@ namespace Slang
auto interfaceType = maybeLowerInterfaceType(cast<IRInterfaceType>(witnessTable->getConformanceType()));
if (interfaceType != witnessTable->getConformanceType())
witnessTable->setConformanceType(interfaceType);
+ if (isBuiltin(interfaceType))
+ return;
for (auto child : witnessTable->getChildren())
{
auto entry = as<IRWitnessTableEntry>(child);