diff options
| author | Yong He <yonghe@outlook.com> | 2024-11-15 00:37:58 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-15 00:37:58 -0800 |
| commit | 05903f708856a70d68bf41bbfb2b06620508dee0 (patch) | |
| tree | 7255325656c16f02652c83f2c4111b29ba503913 /source | |
| parent | f0bc4642a563e2318634b38a5a7ac2c3ddd68917 (diff) | |
Embed core module in wasm build. (#5569)
* Embed core module in wasm build.
* format code
* add uintptr_t case.
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/compiler-core/slang-artifact-associated-impl.h | 2 | ||||
| -rw-r--r-- | source/slang-record-replay/record/slang-module.h | 2 | ||||
| -rw-r--r-- | source/slang/slang-ast-decl.h | 4 | ||||
| -rw-r--r-- | source/slang/slang-ast-expr.h | 2 | ||||
| -rw-r--r-- | source/slang/slang-ast-modifier.h | 2 | ||||
| -rw-r--r-- | source/slang/slang-ast-support-types.h | 2 | ||||
| -rw-r--r-- | source/slang/slang-ast-type.cpp | 2 | ||||
| -rw-r--r-- | source/slang/slang-ast-val.cpp | 2 | ||||
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 4 | ||||
| -rw-r--r-- | source/slang/slang-check-expr.cpp | 8 | ||||
| -rw-r--r-- | source/slang/slang-compiler.h | 2 | ||||
| -rw-r--r-- | source/slang/slang-ir-insts.h | 29 | ||||
| -rw-r--r-- | source/slang/slang-ir.cpp | 58 | ||||
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 12 |
14 files changed, 103 insertions, 28 deletions
diff --git a/source/compiler-core/slang-artifact-associated-impl.h b/source/compiler-core/slang-artifact-associated-impl.h index ff8f03163..8a89f865b 100644 --- a/source/compiler-core/slang-artifact-associated-impl.h +++ b/source/compiler-core/slang-artifact-associated-impl.h @@ -189,7 +189,7 @@ public: SLANG_OVERRIDE; // IMetadata - SLANG_NO_THROW virtual SlangResult SLANG_MCALL isParameterLocationUsed( + SLANG_NO_THROW virtual SlangResult isParameterLocationUsed( SlangParameterCategory category, // is this a `t` register? `s` register? SlangUInt spaceIndex, // `space` for D3D12, `set` for Vulkan SlangUInt registerIndex, // `register` for D3D12, `binding` for Vulkan diff --git a/source/slang-record-replay/record/slang-module.h b/source/slang-record-replay/record/slang-module.h index 5cf3126f7..7608ac52d 100644 --- a/source/slang-record-replay/record/slang-module.h +++ b/source/slang-record-replay/record/slang-module.h @@ -180,7 +180,7 @@ public: outDiagnostics); } - virtual SLANG_NO_THROW slang::DeclReflection* getModuleReflection() override; + virtual SLANG_NO_THROW slang::DeclReflection* SLANG_MCALL getModuleReflection() override; slang::IModule* getActualModule() const { return m_actualModule; } diff --git a/source/slang/slang-ast-decl.h b/source/slang/slang-ast-decl.h index 400a9635a..e8886a59a 100644 --- a/source/slang/slang-ast-decl.h +++ b/source/slang/slang-ast-decl.h @@ -552,7 +552,7 @@ class GenericTypeParamDeclBase : public SimpleTypeDecl SLANG_AST_CLASS(GenericTypeParamDeclBase) // The index of the generic parameter. - Index parameterIndex = -1; + int parameterIndex = -1; }; class GenericTypeParamDecl : public GenericTypeParamDeclBase @@ -597,7 +597,7 @@ class GenericValueParamDecl : public VarDeclBase SLANG_AST_CLASS(GenericValueParamDecl) // The index of the generic parameter. - Index parameterIndex = 0; + int parameterIndex = 0; }; // An empty declaration (which might still have modifiers attached). diff --git a/source/slang/slang-ast-expr.h b/source/slang/slang-ast-expr.h index 1f44e31c2..409909b16 100644 --- a/source/slang/slang-ast-expr.h +++ b/source/slang/slang-ast-expr.h @@ -293,7 +293,7 @@ class SwizzleExpr : public Expr { SLANG_AST_CLASS(SwizzleExpr) Expr* base = nullptr; - ShortList<UInt, 4> elementIndices; + ShortList<uint32_t, 4> elementIndices; SourceLoc memberOpLoc; }; diff --git a/source/slang/slang-ast-modifier.h b/source/slang/slang-ast-modifier.h index 956704b4c..ee9b55334 100644 --- a/source/slang/slang-ast-modifier.h +++ b/source/slang/slang-ast-modifier.h @@ -398,7 +398,7 @@ class HLSLPackOffsetSemantic : public HLSLLayoutSemantic { SLANG_AST_CLASS(HLSLPackOffsetSemantic) - Index uniformOffset = 0; + int uniformOffset = 0; }; diff --git a/source/slang/slang-ast-support-types.h b/source/slang/slang-ast-support-types.h index 0a2dbe78d..4bbd51f93 100644 --- a/source/slang/slang-ast-support-types.h +++ b/source/slang/slang-ast-support-types.h @@ -689,7 +689,7 @@ struct SubstitutionSet // `T` is a type pack, then packExpansionIndex will have a value starting from 0 // to the count of the type pack during expansion of the `expand` type when we // substitute `each T` with the element of `T` at index `packExpansionIndex`. - Index packExpansionIndex = -1; + int packExpansionIndex = -1; SubstitutionSet() = default; SubstitutionSet(DeclRefBase* declRefBase) diff --git a/source/slang/slang-ast-type.cpp b/source/slang/slang-ast-type.cpp index 7e4777a76..23d89957a 100644 --- a/source/slang/slang-ast-type.cpp +++ b/source/slang/slang-ast-type.cpp @@ -706,7 +706,7 @@ Val* ExpandType::_substituteImplOverride(ASTBuilder* astBuilder, SubstitutionSet ShortList<Type*> expandedTypes; SLANG_ASSERT(capturedPacks.getCount() != 0); - for (Index i = 0; i < concreteTypePacks[0]->getTypeCount(); i++) + for (int i = 0; i < (int)concreteTypePacks[0]->getTypeCount(); i++) { subst.packExpansionIndex = i; auto substElementType = getPatternType()->substituteImpl(astBuilder, subst, &diff); diff --git a/source/slang/slang-ast-val.cpp b/source/slang/slang-ast-val.cpp index fdb7e6990..98135ef16 100644 --- a/source/slang/slang-ast-val.cpp +++ b/source/slang/slang-ast-val.cpp @@ -364,7 +364,7 @@ Val* ExpandSubtypeWitness::_substituteImplOverride( // If sub is substituted into a concrete type pack, we should return a // TypePackSubtypeWitness. ShortList<SubtypeWitness*> newWitnesses; - for (Index i = 0; i < subTypePack->getTypeCount(); i++) + for (int i = 0; i < (int)subTypePack->getTypeCount(); i++) { auto elementType = subTypePack->getElementType(i); subst.packExpansionIndex = i; diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 663a2186e..fb27614d0 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -2817,7 +2817,7 @@ void SemanticsDeclHeaderVisitor::visitGenericDecl(GenericDecl* genericDecl) // // Accessing the members via index side steps the issue. - Index parameterIndex = 0; + int parameterIndex = 0; const auto& members = genericDecl->members; for (Index i = 0; i < members.getCount(); ++i) { @@ -4392,7 +4392,7 @@ void SemanticsVisitor::addRequiredParamsToSynthesizedDecl( auto elementType = typePack->getElementType(i); auto synMemberExpr = m_astBuilder->create<SwizzleExpr>(); synMemberExpr->base = synArg; - synMemberExpr->elementIndices.add((UInt)i); + synMemberExpr->elementIndices.add((uint32_t)i); synMemberExpr->type = elementType; synArgs.add(synMemberExpr); } diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index 44e399e79..2840cdd39 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -4308,7 +4308,7 @@ Expr* SemanticsVisitor::checkTupleSwizzleExpr(MemberExpr* memberExpr, TupleType* auto span = swizzleText.getUnownedSlice(); Index pos = 0; - ShortList<UInt> elementCoords; + ShortList<uint32_t> elementCoords; bool anyDuplicates = false; @@ -4316,7 +4316,7 @@ Expr* SemanticsVisitor::checkTupleSwizzleExpr(MemberExpr* memberExpr, TupleType* // Every update to cursor corresponds to a check against 0-termination while (pos < span.getLength()) { - UInt elementCoord; + uint32_t elementCoord; // Check for the preceding underscore if (span[pos] != '_') @@ -4341,7 +4341,7 @@ Expr* SemanticsVisitor::checkTupleSwizzleExpr(MemberExpr* memberExpr, TupleType* // member lookup. return checkGeneralMemberLookupExpr(memberExpr, baseTupleType); } - elementCoord = (UInt)StringUtil::parseIntAndAdvancePos(span, pos); + elementCoord = (uint32_t)StringUtil::parseIntAndAdvancePos(span, pos); if (elementCoord >= tupleElementCount) { @@ -4400,7 +4400,7 @@ Expr* SemanticsVisitor::CheckSwizzleExpr( swizExpr->memberOpLoc = memberRefExpr->memberOperatorLoc; IntegerLiteralValue limitElement = baseElementCount; - ShortList<UInt, 4> elementIndices; + ShortList<uint32_t, 4> elementIndices; bool anyDuplicates = false; bool anyError = false; diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 9fea93b7c..e0df18a8c 100644 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -1622,7 +1622,7 @@ public: virtual void buildHash(DigestBuilder<SHA1>& builder) SLANG_OVERRIDE; - virtual slang::DeclReflection* getModuleReflection() SLANG_OVERRIDE; + virtual slang::DeclReflection* SLANG_MCALL getModuleReflection() SLANG_OVERRIDE; void setDigest(SHA1::Digest const& digest) { m_digest = digest; } SHA1::Digest computeDigest(); diff --git a/source/slang/slang-ir-insts.h b/source/slang/slang-ir-insts.h index 9ccfce51c..97989e9ce 100644 --- a/source/slang/slang-ir-insts.h +++ b/source/slang/slang-ir-insts.h @@ -4253,7 +4253,17 @@ public: UInt elementCount, IRInst* const* elementIndices); - IRInst* emitSwizzle(IRType* type, IRInst* base, UInt elementCount, UInt const* elementIndices); + IRInst* emitSwizzle( + IRType* type, + IRInst* base, + UInt elementCount, + uint64_t const* elementIndices); + + IRInst* emitSwizzle( + IRType* type, + IRInst* base, + UInt elementCount, + uint32_t const* elementIndices); IRInst* emitSwizzleSet( IRType* type, @@ -4267,7 +4277,14 @@ public: IRInst* base, IRInst* source, UInt elementCount, - UInt const* elementIndices); + uint64_t const* elementIndices); + + IRInst* emitSwizzleSet( + IRType* type, + IRInst* base, + IRInst* source, + UInt elementCount, + uint32_t const* elementIndices); IRInst* emitSwizzledStore( IRInst* dest, @@ -4279,7 +4296,13 @@ public: IRInst* dest, IRInst* source, UInt elementCount, - UInt const* elementIndices); + uint32_t const* elementIndices); + + IRInst* emitSwizzledStore( + IRInst* dest, + IRInst* source, + UInt elementCount, + uint64_t const* elementIndices); IRInst* emitReturn(IRInst* val); diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 5e4db43b2..e7f82f5ad 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -5311,7 +5311,24 @@ IRInst* IRBuilder::emitSwizzle( IRType* type, IRInst* base, UInt elementCount, - UInt const* elementIndices) + uint64_t const* elementIndices) +{ + auto intType = getBasicType(BaseType::Int); + + IRInst* irElementIndices[4]; + for (UInt ii = 0; ii < elementCount; ++ii) + { + irElementIndices[ii] = getIntValue(intType, elementIndices[ii]); + } + + return emitSwizzle(type, base, elementCount, irElementIndices); +} + +IRInst* IRBuilder::emitSwizzle( + IRType* type, + IRInst* base, + UInt elementCount, + uint32_t const* elementIndices) { auto intType = getBasicType(BaseType::Int); @@ -5380,7 +5397,25 @@ IRInst* IRBuilder::emitSwizzleSet( IRInst* base, IRInst* source, UInt elementCount, - UInt const* elementIndices) + uint32_t const* elementIndices) +{ + auto intType = getBasicType(BaseType::Int); + + IRInst* irElementIndices[4]; + for (UInt ii = 0; ii < elementCount; ++ii) + { + irElementIndices[ii] = getIntValue(intType, elementIndices[ii]); + } + + return emitSwizzleSet(type, base, source, elementCount, irElementIndices); +} + +IRInst* IRBuilder::emitSwizzleSet( + IRType* type, + IRInst* base, + IRInst* source, + UInt elementCount, + uint64_t const* elementIndices) { auto intType = getBasicType(BaseType::Int); @@ -5419,7 +5454,24 @@ IRInst* IRBuilder::emitSwizzledStore( IRInst* dest, IRInst* source, UInt elementCount, - UInt const* elementIndices) + uint32_t const* elementIndices) +{ + auto intType = getBasicType(BaseType::Int); + + IRInst* irElementIndices[4]; + for (UInt ii = 0; ii < elementCount; ++ii) + { + irElementIndices[ii] = getIntValue(intType, elementIndices[ii]); + } + + return emitSwizzledStore(dest, source, elementCount, irElementIndices); +} + +IRInst* IRBuilder::emitSwizzledStore( + IRInst* dest, + IRInst* source, + UInt elementCount, + uint64_t const* elementIndices) { auto intType = getBasicType(BaseType::Int); diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index b98218c5a..92c442433 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -333,8 +333,8 @@ struct SwizzledLValueInfo : ExtendedValueInfo // The base expression (this should be an l-value) LoweredValInfo base; - // THe indices for the elements being swizzled - ShortList<UInt, 4> elementIndices; + // The indices for the elements being swizzled + ShortList<uint32_t, 4> elementIndices; }; // Represents the result of a matrix swizzle operation in an l-value context. @@ -5495,7 +5495,7 @@ struct LValueExprLoweringVisitor : ExprLoweringVisitorBase<LValueExprLoweringVis RefPtr<SwizzledLValueInfo> swizzledLValue = new SwizzledLValueInfo; swizzledLValue->type = irType; swizzledLValue->base = baseSwizzleInfo->base; - swizzledLValue->elementIndices = elementCount; + swizzledLValue->elementIndices.add((uint32_t)elementCount); // Take the swizzle element of the "outer" swizzle, as it was // written by the user. In our running example of `foo[i].zw.y` @@ -7146,7 +7146,7 @@ void assign(IRGenContext* context, LoweredValInfo const& inLeft, LoweredValInfo // If there's a single element, just emit a regular store, otherwise // proceed with a swizzle store auto swizzledStore = - [builder](IRInst* dest, IRInst* source, UInt elementCount, UInt const* elementIndices) + [builder](IRInst* dest, IRInst* source, UInt elementCount, uint32_t const* elementIndices) { if (elementCount == 1) { @@ -7272,14 +7272,14 @@ top: // The number of element writes in each row UInt rowSizes[maxRowIndex] = {}; // The columns being written to in each row - UInt rowWrites[maxRowIndex][maxCols]; + uint32_t rowWrites[maxRowIndex][maxCols]; // The RHS element indices being written in each row UInt rowIndices[maxRowIndex][maxCols]; for (UInt i = 0; i < swizzleInfo->elementCount; ++i) { const auto& c = swizzleInfo->elementCoords[i]; auto& rowSize = rowSizes[c.row]; - rowWrites[c.row][rowSize] = c.col; + rowWrites[c.row][rowSize] = (uint32_t)c.col; rowIndices[c.row][rowSize] = i; ++rowSize; } |
