summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index 49c91dc22..131c8d407 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -959,6 +959,19 @@ namespace Slang
}
//
+ // IRTupleTypeLayout
+ //
+
+ void IRTupleTypeLayout::Builder::addAttrsImpl(List<IRInst*>& ioOperands)
+ {
+ auto irBuilder = getIRBuilder();
+ for(auto field : m_fields)
+ {
+ ioOperands.add(irBuilder->getTupleFieldLayoutAttr(field.layout));
+ }
+ }
+
+ //
// IRArrayTypeLayout
//
@@ -967,6 +980,15 @@ namespace Slang
ioOperands.add(m_elementTypeLayout);
}
+ //
+ // IRStructuredBufferTypeLayout
+ //
+
+ void IRStructuredBufferTypeLayout::Builder::addOperandsImpl(List<IRInst*>& ioOperands)
+ {
+ ioOperands.add(m_elementTypeLayout);
+ }
+
//
// IRPointerTypeLayout
//
@@ -4414,6 +4436,19 @@ namespace Slang
return inst;
}
+ IRVar* IRBuilder::emitVar(
+ IRType* type,
+ IRIntegerValue addressSpace)
+ {
+ auto allocatedType = getPtrType(kIROp_PtrType, type, addressSpace);
+ auto inst = createInst<IRVar>(
+ this,
+ kIROp_Var,
+ allocatedType);
+ addInst(inst);
+ return inst;
+ }
+
IRInst* IRBuilder::emitLoadReverseGradient(IRType* type, IRInst* diffValue)
{
auto inst = createInst<IRLoadReverseGradient>(
@@ -5669,6 +5704,18 @@ namespace Slang
operands));
}
+ IRTupleFieldLayoutAttr* IRBuilder::getTupleFieldLayoutAttr(
+ IRTypeLayout* layout)
+ {
+ IRInst* operands[] = { layout };
+
+ return cast<IRTupleFieldLayoutAttr>(createIntrinsicInst(
+ getVoidType(),
+ kIROp_TupleFieldLayoutAttr,
+ SLANG_COUNT_OF(operands),
+ operands));
+ }
+
IRCaseTypeLayoutAttr* IRBuilder::getCaseTypeLayoutAttr(
IRTypeLayout* layout)
{
@@ -7457,6 +7504,21 @@ namespace Slang
if (decorationCaps.isIncompatibleWith(targetCaps))
continue;
+ if(decoration->hasPredicate())
+ {
+ const auto scrutinee = decoration->getTypeScrutinee();
+ const auto predicate = decoration->getTypePredicate();
+ const auto predicateFun =
+ predicate == "boolean" ? [](auto t){ return t->getOp() == kIROp_BoolType; }
+ : predicate == "integral" ? isIntegralType
+ : predicate == "floating" ? isFloatingType
+ : nullptr;
+
+ SLANG_ASSERT(predicateFun);
+ if(!predicateFun(scrutinee))
+ continue;
+ }
+
if(!bestDecoration || decorationCaps.isBetterForTarget(bestCaps, targetCaps))
{
bestDecoration = decoration;