From 4c4826d47eeef4675daae4ae53ff76f4d5ebd84a Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 16 Feb 2023 13:55:32 -0800 Subject: Overhaul global inst deduplication and cpp/cuda backend. (#2654) * Overhaul global inst deduplication and cpp/cuda backend. * Update IR documentation. --------- Co-authored-by: Yong He --- source/slang/slang-ir-wrap-structured-buffers.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source/slang/slang-ir-wrap-structured-buffers.cpp') diff --git a/source/slang/slang-ir-wrap-structured-buffers.cpp b/source/slang/slang-ir-wrap-structured-buffers.cpp index 2ad09aa90..53671fa7f 100644 --- a/source/slang/slang-ir-wrap-structured-buffers.cpp +++ b/source/slang/slang-ir-wrap-structured-buffers.cpp @@ -134,7 +134,7 @@ struct WrapStructuredBuffersContext // scanning through its IR uses, since values of that // type are using it as a (type) operand. // - for( auto typeUse = newStructuredBufferType->firstUse; typeUse; typeUse = typeUse->nextUse ) + traverseUses(newStructuredBufferType, [&](IRUse* typeUse) { // There might be uses of `newStructuredBufferType` where // it isn't being used as the type of a value, so we @@ -142,7 +142,7 @@ struct WrapStructuredBuffersContext // auto valueOfStructuredBufferType = typeUse->getUser(); if(valueOfStructuredBufferType->getFullType() != newStructuredBufferType) - continue; + return; // Now we have some `valueOfStructuredBufferType`. In our running // example, this might be `gBuffer`, which is an `IRGlobalParam`. @@ -155,7 +155,7 @@ struct WrapStructuredBuffersContext // because these could be calls to intrinsic functions like // `RWStructuredBuffer.Load` // - for( auto valueUse = valueOfStructuredBufferType->firstUse; valueUse; valueUse = valueUse->nextUse ) + traverseUses(valueOfStructuredBufferType, [&](IRUse* valueUse) { // we are only interested in instructions that are calls, // with at least one argument, where the first argument @@ -165,11 +165,11 @@ struct WrapStructuredBuffersContext // auto call = as(valueUse->getUser()); if(!call) - continue; + return; if(call->getArgCount() == 0) - continue; + return; if(call->getArg(0) != valueOfStructuredBufferType) - continue; + return; // At this point we have a candidate `call` instruction, // but we need to determine whether it is a call to @@ -196,7 +196,7 @@ struct WrapStructuredBuffersContext // auto callee = call->getCallee(); if(!as(callee)) - continue; + return; // At this point it seems likely we have one of the calls // we want to rewrite, but there are still intrinsics @@ -285,8 +285,8 @@ struct WrapStructuredBuffersContext newVal->setOperand(0, call); } } - } - } + }); + }); } /// Get the struture field "key" to use for generated wrappers -- cgit v1.2.3