From 4be623c52a6518eb86756a0369706c1d6670f6bb Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 7 Feb 2023 18:36:35 -0800 Subject: Arithmetic simplifications and more IR clean up logic. (#2632) --- source/slang/slang-ir.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 558574bf6..1b16bfe1f 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -4604,6 +4604,14 @@ namespace Slang return inst; } + IRInst* IRBuilder::addFloatingModeOverrideDecoration(IRInst* dest, FloatingPointMode mode) + { + return addDecoration( + dest, + kIROp_FloatingPointModeOverrideDecoration, + getIntValue(getIntType(), (IRIntegerValue)mode)); + } + IRInst* IRBuilder::emitSwizzle( IRType* type, IRInst* base, @@ -6418,6 +6426,20 @@ namespace Slang return false; } + bool isIntegralScalarOrCompositeType(IRType* t) + { + if (!t) + return false; + switch (t->getOp()) + { + case kIROp_VectorType: + case kIROp_MatrixType: + return isIntegralType((IRType*)t->getOperand(0)); + default: + return isIntegralType(t); + } + } + void findAllInstsBreadthFirst(IRInst* inst, List& outInsts) { Index index = outInsts.getCount(); @@ -6577,6 +6599,8 @@ namespace Slang void IRInst::insertBefore(IRInst* other) { SLANG_ASSERT(other); + if (other->getPrevInst() == this) + return; _insertAt(other->getPrevInst(), other, other->getParent()); } -- cgit v1.2.3