From a618b8c5e249b0f20e6c0c95f9da1b5cbfdbf08b Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 17 Oct 2024 20:14:22 -0700 Subject: Cleanup atomic intrinsics. (#5324) * Cleanup atomic intrinsics. * Fix. * Fix glsl. * Remove hacky intrinsic expansion logic for glsl image atomics. * Fix all tests. * Fix. * Add `InterlockedAddF16Emulated`. * Fix glsl intrinsic. * Fix. --- source/slang/slang-intrinsic-expand.cpp | 106 -------------------------------- 1 file changed, 106 deletions(-) (limited to 'source/slang/slang-intrinsic-expand.cpp') diff --git a/source/slang/slang-intrinsic-expand.cpp b/source/slang/slang-intrinsic-expand.cpp index 7cde70777..aabc193dd 100644 --- a/source/slang/slang-intrinsic-expand.cpp +++ b/source/slang/slang-intrinsic-expand.cpp @@ -653,112 +653,6 @@ const char* IntrinsicExpandContext::_emitSpecial(const char* cursor) } } break; - - case 'a': - { - // We have an operation that needs to lower to either - // `atomic*` or `imageAtomic*` for GLSL, depending on - // whether its first operand is a subscript into an - // array. This `$a` is the first `a` in `atomic`, - // so we will replace it accordingly. - // - // TODO: This distinction should be made earlier, - // with the front-end picking the right overload - // based on the "address space" of the argument. - - Index argIndex = 0; - SLANG_RELEASE_ASSERT(m_argCount > argIndex); - - auto arg = m_args[argIndex].get(); - if (arg->getOp() == kIROp_ImageSubscript) - { - m_writer->emit("imageA"); - } - else - { - m_writer->emit("a"); - } - } - break; - - case 'A': - { - // We have an operand that represents the destination - // of an atomic operation in GLSL, and it should - // be lowered based on whether it is an ordinary l-value, - // or an image subscript. In the image subscript case - // this operand will turn into multiple arguments - // to the `imageAtomic*` function. - // - - Index argIndex = 0; - SLANG_RELEASE_ASSERT(m_argCount > argIndex); - - auto arg = m_args[argIndex].get(); - if (arg->getOp() == kIROp_ImageSubscript) - { - if (m_emitter->getSourceLanguage() == SourceLanguage::GLSL) - { - // TODO: we don't handle the multisample - // case correctly here, where the last - // component of the image coordinate needs - // to be broken out into its own argument. - // - m_writer->emit("("); - m_emitter->emitOperand(arg->getOperand(0), getInfo(EmitOp::General)); - m_writer->emit("), "); - - // The coordinate argument will have been computed - // as a `vector` because that is how the - // HLSL image subscript operations are defined. - // In contrast, the GLSL `imageAtomic*` operations - // expect `vector` coordinates, so we - // will hackily insert the conversion here as - // part of the intrinsic op. - // - auto coords = arg->getOperand(1); - auto coordsType = coords->getDataType(); - - auto coordsVecType = as(coordsType); - IRIntegerValue elementCount = 1; - if (coordsVecType) - { - coordsType = coordsVecType->getElementType(); - elementCount = getIntVal(coordsVecType->getElementCount()); - } - - SLANG_ASSERT(coordsType->getOp() == kIROp_UIntType); - - if (elementCount > 1) - { - m_writer->emit("ivec"); - m_writer->emit(elementCount); - } - else - { - m_writer->emit("int"); - } - - m_writer->emit("("); - m_emitter->emitOperand(arg->getOperand(1), getInfo(EmitOp::General)); - m_writer->emit(")"); - } - else - { - m_writer->emit("("); - m_emitter->emitOperand(arg, getInfo(EmitOp::General)); - m_writer->emit(")"); - } - } - else - { - m_writer->emit("("); - m_emitter->emitOperand(arg, getInfo(EmitOp::General)); - m_writer->emit(")"); - } - } - break; - case 'P': // Type-based prefix as used for CUDA and C++ targets { -- cgit v1.2.3