@@ -3095,6 +3095,12 @@ namespace Slang
3095
3095
{
3096
3096
return declRef;
3097
3097
}
3098
+
3099
+ // A callback used to clone (or not) a Val
3100
+ virtual RefPtr<Val> maybeCloneVal (Val* val)
3101
+ {
3102
+ return val;
3103
+ }
3098
3104
};
3099
3105
3100
3106
void registerClonedValue (
@@ -3203,6 +3209,7 @@ namespace Slang
3203
3209
virtual DeclRef<Decl> maybeCloneDeclRef (DeclRef<Decl> const & declRef) override ;
3204
3210
3205
3211
virtual RefPtr<Type> maybeCloneType (Type* originalType) override ;
3212
+ virtual RefPtr<Val> maybeCloneVal (Val* val) override ;
3206
3213
};
3207
3214
3208
3215
@@ -3216,6 +3223,11 @@ namespace Slang
3216
3223
return originalType->Substitute (subst).As <Type>();
3217
3224
}
3218
3225
3226
+ RefPtr<Val> IRSpecContext::maybeCloneVal (Val * val)
3227
+ {
3228
+ return val->Substitute (subst);
3229
+ }
3230
+
3219
3231
IRValue* IRSpecContext::maybeCloneValue (IRValue* originalValue)
3220
3232
{
3221
3233
switch (originalValue->op )
@@ -3316,7 +3328,7 @@ namespace Slang
3316
3328
}
3317
3329
else
3318
3330
{
3319
- return val;
3331
+ return context-> maybeCloneVal ( val) ;
3320
3332
}
3321
3333
}
3322
3334
@@ -3439,7 +3451,7 @@ namespace Slang
3439
3451
IRGlobalVar* originalVar,
3440
3452
IROriginalValuesForClone const & originalValues)
3441
3453
{
3442
- auto clonedVar = context->builder ->createGlobalVar (context->maybeCloneType (originalVar->getType ()->getValueType ()));
3454
+ auto clonedVar = context->builder ->createGlobalVar (context->maybeCloneType (originalVar->getType ()->getValueType ()));
3443
3455
registerClonedValue (context, clonedVar, originalValues);
3444
3456
3445
3457
auto mangledName = originalVar->mangledName ;
@@ -4229,6 +4241,7 @@ namespace Slang
4229
4241
virtual IRValue* maybeCloneValue (IRValue* originalVal) override ;
4230
4242
4231
4243
virtual RefPtr<Type> maybeCloneType (Type* originalType) override ;
4244
+ virtual RefPtr<Val> maybeCloneVal (Val* val) override ;
4232
4245
};
4233
4246
4234
4247
// Convert a type-level value into an IR-level equivalent.
@@ -4352,6 +4365,11 @@ namespace Slang
4352
4365
return originalType->Substitute (subst).As <Type>();
4353
4366
}
4354
4367
4368
+ RefPtr<Val> IRGenericSpecContext::maybeCloneVal (Val * val)
4369
+ {
4370
+ return val->Substitute (subst);
4371
+ }
4372
+
4355
4373
// Given a list of substitutions, return the inner-most
4356
4374
// generic substitution in the list, or NULL if there
4357
4375
// are no generic substitutions.
0 commit comments