From 17c6c6044965629a3ae7e8ef004cc0b2ca657c55 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 4 Feb 2020 15:19:48 -0500 Subject: CUDA/C++ backend improvements (#1198) * WIP with vector float test. * vector-float test working. * Fixed remaing tests broken with init changes. * Improve 64bit-type-support.md * Disable tests broken on CI system for Dx. * WIP: Make type available for comparison. * Moved type conversion into TypeTextUtil. * Add text/type conversions from DownstreamCompiler to TypeTextUtil. * Allow compaison taking into account type. * Removed quantize in vector-float.slang test. --- source/slang/slang-hlsl-intrinsic-set.cpp | 34 +++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'source/slang/slang-hlsl-intrinsic-set.cpp') diff --git a/source/slang/slang-hlsl-intrinsic-set.cpp b/source/slang/slang-hlsl-intrinsic-set.cpp index 1f42836f3..7500e799a 100644 --- a/source/slang/slang-hlsl-intrinsic-set.cpp +++ b/source/slang/slang-hlsl-intrinsic-set.cpp @@ -245,19 +245,37 @@ SlangResult HLSLIntrinsicSet::makeIntrinsic(IRInst* inst, HLSLIntrinsic& out) // If it's constructed from a type conversion calcIntrinsic(Op::ConstructConvert, inst, out); } + return SLANG_OK; } else { - // We only emit as if it has one operand, but we can tell how many it actually has from the return type - calcIntrinsic(Op::Init, inst, 1, out); + // If we are constructing a basic type, we don't need an Op::Init + if (!IRBasicType::isaImpl(dstType->op)) + { + // Emit the 'init' intrinsic + calcIntrinsic(Op::Init, inst, inst->getOperandCount(), out); + return SLANG_OK; + } } - return SLANG_OK; + return SLANG_FAIL; } case kIROp_makeVector: + { + if (inst->getOperandCount() == 1 && as(inst->getOperand(0)->getDataType())) + { + // This is make from scalar + calcIntrinsic(Op::ConstructFromScalar, inst, out); + } + else + { + calcIntrinsic(Op::Init, inst, inst->getOperandCount(), out); + } + return SLANG_OK; + } case kIROp_MakeMatrix: { // We only emit as if it has one operand, but we can tell how many it actually has from the return type - calcIntrinsic(Op::Init, inst, 1, out); + calcIntrinsic(Op::Init, inst, inst->getOperandCount(), out); return SLANG_OK; } case kIROp_swizzle: @@ -346,6 +364,14 @@ SlangResult HLSLIntrinsicSet::makeIntrinsic(IRInst* inst, HLSLIntrinsic& out) return SLANG_FAIL; } +void HLSLIntrinsicSet::getIntrinsics(List& out) const +{ + for (auto& pair : m_intrinsics) + { + out.add(pair.Value); + } +} + HLSLIntrinsic* HLSLIntrinsicSet::add(const HLSLIntrinsic& intrinsic) { // Make sure it's valid(!) -- cgit v1.2.3