summaryrefslogtreecommitdiffstats
path: root/source/slang/ir.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-01-04 13:41:09 -0800
committerTim Foley <tfoleyNV@users.noreply.github.com>2018-01-04 13:41:09 -0800
commit3d435f7321c3f9241d33a0f7521573f21b548186 (patch)
tree3a4f2d21250f1dbad1ca9bf4668b566a6c87ea89 /source/slang/ir.cpp
parente90dfcfd6a0a6d92688012b1216c46c24965cfc0 (diff)
Bug fixes for Slang integration (#356)
* fix #353 * move validateEntryPoint to after all entrypoints has been checked * bug fix: DeclRefType::SubstituteImpl should change ioDiff * bug fix: generic resource usage should have count of 1 instead of 0. * update test case
Diffstat (limited to 'source/slang/ir.cpp')
-rw-r--r--source/slang/ir.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp
index e0f703cbd..088139953 100644
--- a/source/slang/ir.cpp
+++ b/source/slang/ir.cpp
@@ -3095,6 +3095,12 @@ namespace Slang
{
return declRef;
}
+
+ // A callback used to clone (or not) a Val
+ virtual RefPtr<Val> maybeCloneVal(Val* val)
+ {
+ return val;
+ }
};
void registerClonedValue(
@@ -3203,6 +3209,7 @@ namespace Slang
virtual DeclRef<Decl> maybeCloneDeclRef(DeclRef<Decl> const& declRef) override;
virtual RefPtr<Type> maybeCloneType(Type* originalType) override;
+ virtual RefPtr<Val> maybeCloneVal(Val* val) override;
};
@@ -3216,6 +3223,11 @@ namespace Slang
return originalType->Substitute(subst).As<Type>();
}
+ RefPtr<Val> IRSpecContext::maybeCloneVal(Val * val)
+ {
+ return val->Substitute(subst);
+ }
+
IRValue* IRSpecContext::maybeCloneValue(IRValue* originalValue)
{
switch (originalValue->op)
@@ -3316,7 +3328,7 @@ namespace Slang
}
else
{
- return val;
+ return context->maybeCloneVal(val);
}
}
@@ -3439,7 +3451,7 @@ namespace Slang
IRGlobalVar* originalVar,
IROriginalValuesForClone const& originalValues)
{
- auto clonedVar = context->builder->createGlobalVar(context->maybeCloneType(originalVar->getType()->getValueType()));
+ auto clonedVar = context->builder->createGlobalVar(context->maybeCloneType(originalVar->getType()->getValueType()));
registerClonedValue(context, clonedVar, originalValues);
auto mangledName = originalVar->mangledName;
@@ -4229,6 +4241,7 @@ namespace Slang
virtual IRValue* maybeCloneValue(IRValue* originalVal) override;
virtual RefPtr<Type> maybeCloneType(Type* originalType) override;
+ virtual RefPtr<Val> maybeCloneVal(Val* val) override;
};
// Convert a type-level value into an IR-level equivalent.
@@ -4352,6 +4365,11 @@ namespace Slang
return originalType->Substitute(subst).As<Type>();
}
+ RefPtr<Val> IRGenericSpecContext::maybeCloneVal(Val * val)
+ {
+ return val->Substitute(subst);
+ }
+
// Given a list of substitutions, return the inner-most
// generic substitution in the list, or NULL if there
// are no generic substitutions.