diff options
| author | Yong He <yonghe@outlook.com> | 2023-01-30 19:24:09 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-30 19:24:09 -0800 |
| commit | 499b0253c224e68ceed6e5b6b1ee9cd7d65aad0f (patch) | |
| tree | 4c570a36d305c8909d633183694e0d1225f044c2 /source/slang/slang-lower-to-ir.cpp | |
| parent | 134dd7eb26fc7988ae13559d276cbf337b4b9d27 (diff) | |
Make ArrayExpressionType a DeclRefType and define its autodiff extension in stdlib. (#2615)
* Allow array parameters in forward diff.
* Use type canonicalization instead of coersion.
* Reimplement array type.
* Fix.
* Update test case.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 605ac62db..149f5f6b9 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1443,11 +1443,6 @@ struct ValLoweringVisitor : ValVisitor<ValLoweringVisitor, LoweredValInfo, Lower return LoweredValInfo::simple(diff); } - LoweredValInfo visitDifferentialBottomSubtypeWitness(DifferentialBottomSubtypeWitness*) - { - return LoweredValInfo(); - } - LoweredValInfo visitTaggedUnionSubtypeWitness( TaggedUnionSubtypeWitness* val) { @@ -1861,10 +1856,10 @@ struct ValLoweringVisitor : ValVisitor<ValLoweringVisitor, LoweredValInfo, Lower IRType* visitArrayExpressionType(ArrayExpressionType* type) { - auto elementType = lowerType(context, type->baseType); - if (type->arrayLength) + auto elementType = lowerType(context, type->getElementType()); + if (!type->isUnsized()) { - auto elementCount = lowerSimpleVal(context, type->arrayLength); + auto elementCount = lowerSimpleVal(context, type->getElementCount()); return getBuilder()->getArrayType( elementType, elementCount); @@ -3390,18 +3385,10 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> } else if (auto arrayType = as<ArrayExpressionType>(type)) { - UInt elementCount = (UInt) getIntVal(arrayType->arrayLength); - - auto irDefaultElement = getSimpleVal(context, getDefaultVal(arrayType->baseType)); - - List<IRInst*> args; - for(UInt ee = 0; ee < elementCount; ++ee) - { - args.add(irDefaultElement); - } + auto irDefaultElement = getSimpleVal(context, getDefaultVal(arrayType->getElementType())); return LoweredValInfo::simple( - getBuilder()->emitMakeArray(irType, args.getCount(), args.getBuffer())); + getBuilder()->emitMakeArrayFromElement(irType, irDefaultElement)); } else if (auto declRefType = as<DeclRefType>(type)) { @@ -3470,7 +3457,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> // fill in the appropriate field of the result if (auto arrayType = as<ArrayExpressionType>(type)) { - UInt elementCount = (UInt) getIntVal(arrayType->arrayLength); + UInt elementCount = (UInt) getIntVal(arrayType->getElementCount()); for (UInt ee = 0; ee < argCount; ++ee) { @@ -3480,7 +3467,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> } if(elementCount > argCount) { - auto irDefaultValue = getSimpleVal(context, getDefaultVal(arrayType->baseType)); + auto irDefaultValue = getSimpleVal(context, getDefaultVal(arrayType->getElementType())); for(UInt ee = argCount; ee < elementCount; ++ee) { args.add(irDefaultValue); |
