summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
m---------external/spirv-tools0
-rw-r--r--source/slang/core.meta.slang22
-rw-r--r--source/slang/slang-ast-builder.cpp10
-rw-r--r--source/slang/slang-ast-builder.h8
-rw-r--r--source/slang/slang-ast-modifier.h6
-rw-r--r--source/slang/slang-ast-support-types.cpp12
-rw-r--r--source/slang/slang-ast-support-types.h94
-rw-r--r--source/slang/slang-ast-type.cpp28
-rw-r--r--source/slang/slang-ast-type.h30
-rw-r--r--source/slang/slang-check-decl.cpp78
-rw-r--r--source/slang/slang-check-expr.cpp18
-rw-r--r--source/slang/slang-check-impl.h8
-rw-r--r--source/slang/slang-check-modifier.cpp4
-rw-r--r--source/slang/slang-check-overload.cpp24
-rw-r--r--source/slang/slang-check-shader.cpp14
-rw-r--r--source/slang/slang-diagnostic-defs.h4
-rw-r--r--source/slang/slang-emit-c-like.cpp12
-rw-r--r--source/slang/slang-emit-cpp.cpp14
-rw-r--r--source/slang/slang-emit-glsl.cpp16
-rw-r--r--source/slang/slang-emit-hlsl.cpp4
-rw-r--r--source/slang/slang-emit-metal.cpp10
-rw-r--r--source/slang/slang-emit-spirv.cpp16
-rw-r--r--source/slang/slang-emit-vm.cpp6
-rw-r--r--source/slang/slang-emit-wgsl.cpp8
-rw-r--r--source/slang/slang-ir-addr-inst-elimination.cpp4
-rw-r--r--source/slang/slang-ir-autodiff-fwd.cpp12
-rw-r--r--source/slang/slang-ir-autodiff-primal-hoist.cpp2
-rw-r--r--source/slang/slang-ir-autodiff-rev.cpp26
-rw-r--r--source/slang/slang-ir-autodiff-transcriber-base.cpp12
-rw-r--r--source/slang/slang-ir-autodiff-transpose.h8
-rw-r--r--source/slang/slang-ir-autodiff-unzip.cpp5
-rw-r--r--source/slang/slang-ir-autodiff-unzip.h6
-rw-r--r--source/slang/slang-ir-autodiff.cpp16
-rw-r--r--source/slang/slang-ir-autodiff.h8
-rw-r--r--source/slang/slang-ir-check-differentiability.cpp2
-rw-r--r--source/slang/slang-ir-defer-buffer-load.cpp2
-rw-r--r--source/slang/slang-ir-fix-entrypoint-callsite.cpp2
-rw-r--r--source/slang/slang-ir-glsl-legalize.cpp27
-rw-r--r--source/slang/slang-ir-glsl-liveness.cpp4
-rw-r--r--source/slang/slang-ir-inline.cpp4
-rw-r--r--source/slang/slang-ir-insert-debug-value-store.cpp8
-rw-r--r--source/slang/slang-ir-insts-stable-names.lua8
-rw-r--r--source/slang/slang-ir-insts.h8
-rw-r--r--source/slang/slang-ir-insts.lua10
-rw-r--r--source/slang/slang-ir-layout.cpp8
-rw-r--r--source/slang/slang-ir-legalize-array-return-type.cpp2
-rw-r--r--source/slang/slang-ir-legalize-types.cpp2
-rw-r--r--source/slang/slang-ir-legalize-varying-params.cpp27
-rw-r--r--source/slang/slang-ir-link.cpp3
-rw-r--r--source/slang/slang-ir-lower-buffer-element-type.cpp12
-rw-r--r--source/slang/slang-ir-lower-out-parameters.cpp4
-rw-r--r--source/slang/slang-ir-marshal-native-call.cpp22
-rw-r--r--source/slang/slang-ir-redundancy-removal.cpp6
-rw-r--r--source/slang/slang-ir-resolve-texture-format.cpp8
-rw-r--r--source/slang/slang-ir-specialize-arrays.cpp6
-rw-r--r--source/slang/slang-ir-specialize-function-call.cpp8
-rw-r--r--source/slang/slang-ir-specialize-resources.cpp8
-rw-r--r--source/slang/slang-ir-spirv-legalize.cpp6
-rw-r--r--source/slang/slang-ir-transform-params-to-constref.cpp10
-rw-r--r--source/slang/slang-ir-translate-global-varying-var.cpp2
-rw-r--r--source/slang/slang-ir-use-uninitialized-values.cpp9
-rw-r--r--source/slang/slang-ir-util.cpp16
-rw-r--r--source/slang/slang-ir-validate.cpp2
-rw-r--r--source/slang/slang-ir.cpp35
-rw-r--r--source/slang/slang-language-server-inlay-hints.cpp2
-rw-r--r--source/slang/slang-lower-to-ir.cpp141
-rw-r--r--source/slang/slang-mangle.cpp14
-rw-r--r--source/slang/slang-parser.cpp2
-rw-r--r--source/slang/slang-syntax.cpp6
-rw-r--r--source/slang/slang-syntax.h2
-rw-r--r--tests/diagnostics/const-ref-differentiable-param.slang2
71 files changed, 537 insertions, 448 deletions
diff --git a/external/spirv-tools b/external/spirv-tools
-Subproject f932fc23e2f84c8affbca4b2761d1da7dd4e0cc
+Subproject 7f2d9ee926f98fc77a3ed1e1e0f113b8c9c4945
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang
index 54e693117..5ffab1f9c 100644
--- a/source/slang/core.meta.slang
+++ b/source/slang/core.meta.slang
@@ -1526,8 +1526,12 @@ extension uintptr_t : IRangedValue
//@hidden:
+// TODO(tfoley): This should really map over to `kIROp_PtrType`,
+// but is currently still mapping to the IR opcode used for `ref`
+// parameters.
+//
__magic_type(ExplicitRefType)
-__intrinsic_type($(kIROp_RefType))
+__intrinsic_type($(kIROp_RefParamType))
struct Ref<
T,
Access access = Access::ReadWrite,
@@ -1535,23 +1539,23 @@ struct Ref<
{};
__magic_type(OutParamType)
-__intrinsic_type($(kIROp_OutType))
+__intrinsic_type($(kIROp_OutParamType))
struct OutParam<T>
{};
-__magic_type(InOutParamType)
-__intrinsic_type($(kIROp_InOutType))
-struct InOutParam<T>
+__magic_type(BorrowInOutParamType)
+__intrinsic_type($(kIROp_BorrowInOutParamType))
+struct BorrowInOutParam<T>
{};
__magic_type(RefParamType)
-__intrinsic_type($(kIROp_RefType))
+__intrinsic_type($(kIROp_RefParamType))
struct RefParam<T>
{};
-__magic_type(ConstRefParamType)
-__intrinsic_type($(kIROp_ConstRefType))
-struct ConstRefParam<T>
+__magic_type(BorrowInParamType)
+__intrinsic_type($(kIROp_BorrowInParamType))
+struct BorrowInParam<T>
{};
// __Addr<T> is AddressSpace::Generic since Slang will specalize & validate the address-space
diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp
index be71fc334..4304bc7c7 100644
--- a/source/slang/slang-ast-builder.cpp
+++ b/source/slang/slang-ast-builder.cpp
@@ -510,14 +510,14 @@ Type* ASTBuilder::getScalarLayoutType()
}
// Construct the type `Out<valueType>`
-OutType* ASTBuilder::getOutType(Type* valueType)
+OutType* ASTBuilder::getOutParamType(Type* valueType)
{
return dynamicCast<OutType>(getPtrType(valueType, "OutParamType"));
}
-InOutType* ASTBuilder::getInOutType(Type* valueType)
+BorrowInOutParamType* ASTBuilder::getBorrowInOutParamType(Type* valueType)
{
- return dynamicCast<InOutType>(getPtrType(valueType, "InOutParamType"));
+ return dynamicCast<BorrowInOutParamType>(getPtrType(valueType, "BorrowInOutParamType"));
}
RefParamType* ASTBuilder::getRefParamType(Type* valueType)
@@ -525,9 +525,9 @@ RefParamType* ASTBuilder::getRefParamType(Type* valueType)
return dynamicCast<RefParamType>(getPtrType(valueType, "RefParamType"));
}
-ConstRefParamType* ASTBuilder::getConstRefParamType(Type* valueType)
+BorrowInParamType* ASTBuilder::getConstRefParamType(Type* valueType)
{
- return dynamicCast<ConstRefParamType>(getPtrType(valueType, "ConstRefParamType"));
+ return dynamicCast<BorrowInParamType>(getPtrType(valueType, "BorrowInParamType"));
}
ExplicitRefType* ASTBuilder::getExplicitRefType(Type* valueType)
diff --git a/source/slang/slang-ast-builder.h b/source/slang/slang-ast-builder.h
index 9386180c8..f4abd4d12 100644
--- a/source/slang/slang-ast-builder.h
+++ b/source/slang/slang-ast-builder.h
@@ -537,16 +537,16 @@ public:
PtrType* getPtrType(Type* valueType, Val* accessQualifier, Val* addrSpace);
// Construct the type `OutParam<valueType>`
- OutParamType* getOutType(Type* valueType);
+ OutParamType* getOutParamType(Type* valueType);
// Construct the type `InOutParam<valueType>`
- InOutParamType* getInOutType(Type* valueType);
+ BorrowInOutParamType* getBorrowInOutParamType(Type* valueType);
// Construct the type `RefParam<valueType>`
RefParamType* getRefParamType(Type* valueType);
- // Construct the type `ConstRefParam<valueType>`
- ConstRefParamType* getConstRefParamType(Type* valueType);
+ // Construct the type `ImmutableBorrowParam<valueType>`
+ BorrowInParamType* getConstRefParamType(Type* valueType);
// Construct the type `Ref<valueType>`
ExplicitRefType* getExplicitRefType(Type* valueType);
diff --git a/source/slang/slang-ast-modifier.h b/source/slang/slang-ast-modifier.h
index 5793167af..80bb827ff 100644
--- a/source/slang/slang-ast-modifier.h
+++ b/source/slang/slang-ast-modifier.h
@@ -339,16 +339,16 @@ class InOutModifier : public OutModifier
};
-// `__ref` modifier for by-reference parameter passing
+// `ref` modifier for by-reference parameter passing
FIDDLE()
class RefModifier : public Modifier
{
FIDDLE(...)
};
-// `__ref` modifier for by-reference parameter passing
+// `borrow` modifier for borrow parameter passing
FIDDLE()
-class ConstRefModifier : public Modifier
+class BorrowModifier : public Modifier
{
FIDDLE(...)
};
diff --git a/source/slang/slang-ast-support-types.cpp b/source/slang/slang-ast-support-types.cpp
index 9d9fdb7da..4054d8dc4 100644
--- a/source/slang/slang-ast-support-types.cpp
+++ b/source/slang/slang-ast-support-types.cpp
@@ -88,23 +88,23 @@ UnownedStringSlice getHigherOrderOperatorName(HigherOrderInvokeExpr* expr)
return UnownedStringSlice();
}
-void printDiagnosticArg(StringBuilder& sb, ParameterDirection direction)
+void printDiagnosticArg(StringBuilder& sb, ParamPassingMode direction)
{
switch (direction)
{
- case kParameterDirection_In:
+ case ParamPassingMode::In:
sb << "in";
break;
- case kParameterDirection_Out:
+ case ParamPassingMode::Out:
sb << "out";
break;
- case kParameterDirection_Ref:
+ case ParamPassingMode::Ref:
sb << "ref";
break;
- case kParameterDirection_InOut:
+ case ParamPassingMode::BorrowInOut:
sb << "inout";
break;
- case kParameterDirection_ConstRef:
+ case ParamPassingMode::BorrowIn:
sb << "constref";
break;
default:
diff --git a/source/slang/slang-ast-support-types.h b/source/slang/slang-ast-support-types.h
index b69c76307..9dd481acb 100644
--- a/source/slang/slang-ast-support-types.h
+++ b/source/slang/slang-ast-support-types.h
@@ -1686,16 +1686,96 @@ FIDDLE() namespace Slang
};
/// Represents the "direction" that a parameter is being passed (e.g., `in` or `out`
- enum ParameterDirection
+ enum class ParamPassingMode
{
- kParameterDirection_In, ///< Copy in
- kParameterDirection_Out, ///< Copy out
- kParameterDirection_InOut, ///< Copy in, copy out
- kParameterDirection_Ref, ///< By-reference
- kParameterDirection_ConstRef, ///< By-const-reference
+ /// Pass a value as input.
+ ///
+ /// Indicated by using the `in` modifier on a parameter,
+ /// or simply using no modifier (on a parameter of
+ /// copyable type). This is the default mode.
+ ///
+ /// Must (almost by definition) be passed a copy
+ /// of the argument.
+ ///
+ ///
+ In,
+
+ /// Pass a reference to a memory location, to be used for output.
+ ///
+ /// Indicated by using the `out` modifier on a parameter
+ /// (while not also using `in`).
+ ///
+ /// May semantically be implemented by directly passing a
+ /// reference to the argument, or a reference to a temporary
+ /// that is moved out of after the call.
+ ///
+ /// Storage at the passed-in address should be unintialized
+ /// on input, and will be must be initialized by the callee
+ /// on any normal return path. On an error return, the storage
+ /// must be uninitialized.
+ ///
+ Out,
+
+ /// Pass a reference to a borrowed immutable value.
+ ///
+ /// Indicated by using the `borrow` modifier on a parameter,
+ /// or the combination of `borrow` and `in` (while not also
+ /// using `out`).
+ ///
+ /// May semantically be implemented by directly passing a
+ /// reference to the argument, or a reference to a temporary
+ /// that is moved/copied into before the call.
+ ///
+ /// Storage at the passed-in address must be guaranteed (by
+ /// the caller) to be immutable for the duration of the call.
+ ///
+ BorrowIn,
+
+ /// Pass a reference to a borrowed mutable value.
+ ///
+ /// Indicated by using the `inout` modifier on a parameter,
+ /// or the combination of `in` and `out`; may also be combined
+ /// with `borrow` to make the semantics more clear.
+ ///
+ /// May semantically be implemented by directly passing a
+ /// reference to the argument, or a reference to a temporary
+ /// that is moved/copied into before the call, and then
+ /// moved/copied out of after the call.
+ ///
+ /// Storage at the passed-in address must be guaranteed (by
+ /// the caller) to not be be accessed (including both reads
+ /// and writes) via any other potentially-aliasing access path.
+ /// Put another way, the callee has exclusive access to the
+ /// memory location for the duration of the call.
+ ///
+ BorrowInOut,
+
+ /// Pass a reference to a mutable memory location.
+ ///
+ /// Indicated by using the `ref` modifier on a parmater
+ /// (without also using the `readonly` or `writeonly` modifiers).
+ ///
+ /// Must be implemented by directly passing a reference to
+ /// the memory location of the argument. It is an error if
+ /// an argument resolves to a storage location that is not
+ /// a memory location (and cannot be turned into a memory
+ /// location via, e.g., a `ref` accessor).
+ ///
+ /// The memory location at the passed-in address may be
+ /// accessed (for reads, writes, atomics, etc.) during the
+ /// duration of the call, through access paths that alias
+ /// the parameter. The callee does not have a guarantee
+ /// of exclusivity of access to the memory location, and
+ /// must take appropriate precautions to ensure consistency,
+ /// coherency, and synchronization of access.
+ ///
+ /// This parameter-passing mode is more-or-less just syntactic
+ /// sugar for a parameter of an explicit pointer type (`Ptr<T>`).
+ ///
+ Ref,
};
- void printDiagnosticArg(StringBuilder & sb, ParameterDirection direction);
+ void printDiagnosticArg(StringBuilder & sb, ParamPassingMode direction);
/// The kind of a builtin interface requirement that can be automatically synthesized.
enum class BuiltinRequirementKind
diff --git a/source/slang/slang-ast-type.cpp b/source/slang/slang-ast-type.cpp
index 1af81a88f..a3b4b91f6 100644
--- a/source/slang/slang-ast-type.cpp
+++ b/source/slang/slang-ast-type.cpp
@@ -544,7 +544,7 @@ void OutParamType::_toTextOverride(StringBuilder& out)
out << toSlice("out ") << getValueType();
}
-void InOutParamType::_toTextOverride(StringBuilder& out)
+void BorrowInOutParamType::_toTextOverride(StringBuilder& out)
{
out << toSlice("inout ") << getValueType();
}
@@ -554,7 +554,7 @@ void RefParamType::_toTextOverride(StringBuilder& out)
out << toSlice("ref ") << getValueType();
}
-void ConstRefParamType::_toTextOverride(StringBuilder& out)
+void BorrowInParamType::_toTextOverride(StringBuilder& out)
{
out << toSlice("borrow ") << getValueType();
}
@@ -580,31 +580,31 @@ Type* NamedExpressionType::_createCanonicalTypeOverride()
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FuncType !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-ParameterDirection getParamPassingModeFromPossiblyWrappedParamType(Type* paramType)
+ParamPassingMode getParamPassingModeFromPossiblyWrappedParamType(Type* paramType)
{
if (as<RefParamType>(paramType))
{
- return kParameterDirection_Ref;
+ return ParamPassingMode::Ref;
}
- else if (as<ConstRefParamType>(paramType))
+ else if (as<BorrowInParamType>(paramType))
{
- return kParameterDirection_ConstRef;
+ return ParamPassingMode::BorrowIn;
}
- else if (as<InOutType>(paramType))
+ else if (as<BorrowInOutParamType>(paramType))
{
- return kParameterDirection_InOut;
+ return ParamPassingMode::BorrowInOut;
}
else if (as<OutType>(paramType))
{
- return kParameterDirection_Out;
+ return ParamPassingMode::Out;
}
else
{
- return kParameterDirection_In;
+ return ParamPassingMode::In;
}
}
-ParameterDirection FuncType::getParamDirection(Index index)
+ParamPassingMode FuncType::getParamDirection(Index index)
{
auto paramType = getParamTypeWithDirectionWrapper(index);
return getParamPassingModeFromPossiblyWrappedParamType(paramType);
@@ -613,7 +613,7 @@ ParameterDirection FuncType::getParamDirection(Index index)
Type* FuncType::getParamValueType(Index index)
{
auto paramType = getParamTypeWithDirectionWrapper(index);
- if (auto wrappedParamType = as<ParamDirectionType>(paramType))
+ if (auto wrappedParamType = as<ParamPassingModeType>(paramType))
return wrappedParamType->getValueType();
return paramType;
}
@@ -1402,10 +1402,10 @@ Val* TextureTypeBase::getFormat()
Type* removeParamDirType(Type* type)
{
- for (auto paramDirType = as<ParamDirectionType>(type); paramDirType;)
+ for (auto paramDirType = as<ParamPassingModeType>(type); paramDirType;)
{
type = paramDirType->getValueType();
- paramDirType = as<ParamDirectionType>(type);
+ paramDirType = as<ParamPassingModeType>(type);
}
return type;
}
diff --git a/source/slang/slang-ast-type.h b/source/slang/slang-ast-type.h
index 26d86fc7f..3df34e768 100644
--- a/source/slang/slang-ast-type.h
+++ b/source/slang/slang-ast-type.h
@@ -713,14 +713,8 @@ class PtrType : public PtrTypeBase
/// A pointer-like type used to represent a parameter-passing mode.
///
-/// Historically the codebase has referredd to different parameter-passing
-/// modes as parameter "directions," because they initially included
-/// only `in`, `out`, and `inout`. The name is confusing when applied
-/// to things like `ref` parameters, but we haven't had time to rename
-/// everything yet.
-///
FIDDLE()
-class ParamDirectionType : public PtrTypeBase
+class ParamPassingModeType : public PtrTypeBase
{
FIDDLE(...)
};
@@ -729,13 +723,12 @@ class ParamDirectionType : public PtrTypeBase
// logical pointer that is passed for an `out`
// or `in out` parameter
FIDDLE(abstract)
-class OutParamTypeBase : public ParamDirectionType
+class OutParamTypeBase : public ParamPassingModeType
{
FIDDLE(...)
};
-using OutTypeBase = OutParamTypeBase;
-// The type for an `out` parameter, e.g., `out T`
+// The type for an output parameter, e.g., `out T`
FIDDLE()
class OutParamType : public OutParamTypeBase
{
@@ -744,24 +737,23 @@ class OutParamType : public OutParamTypeBase
};
using OutType = OutParamType;
-// The type for an `in out` parameter, e.g., `in out T`
+// The type for a mutable borrow input/output parameter, e.g., `in out T`
FIDDLE()
-class InOutParamType : public OutParamTypeBase
+class BorrowInOutParamType : public OutParamTypeBase
{
FIDDLE(...)
void _toTextOverride(StringBuilder& out);
};
-using InOutType = InOutParamType;
-// The type for an `ref` parameter, e.g., `ref T`
+// The type for a by-reference parameter, e.g., `ref T`
FIDDLE()
-class RefParamType : public ParamDirectionType
+class RefParamType : public ParamPassingModeType
{
FIDDLE(...)
void _toTextOverride(StringBuilder& out);
};
-/// The type for a `constref` parameter, e.g., `constref T`
+/// The type for a immutable borrow input parameter, e.g., `borrow T`
///
/// Note that, despite the modifier currently used to represent
/// this case in code, this is *not* comparable to the `ref`
@@ -769,7 +761,7 @@ class RefParamType : public ParamDirectionType
/// equivalent of `inout`.
///
FIDDLE()
-class ConstRefParamType : public ParamDirectionType
+class BorrowInParamType : public ParamPassingModeType
{
FIDDLE(...)
void _toTextOverride(StringBuilder& out);
@@ -880,14 +872,14 @@ class FuncType : public Type
/// Get the parameter-passing mode of one of the function's parameters, by index.
///
- ParameterDirection getParamDirection(Index index);
+ ParamPassingMode getParamDirection(Index index);
/// Combined information on the type and parameter-passing mode of a parameter.
///
struct ParamInfo
{
/// The parameter-passing mode used for the parameter.
- ParameterDirection direction = kParameterDirection_In;
+ ParamPassingMode direction = ParamPassingMode::In;
/// The user-perceived type of the parameter.
Type* type = nullptr;
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 2afd05df2..6a4e3668f 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -5202,13 +5202,13 @@ void SemanticsVisitor::addRequiredParamsToSynthesizedDecl(
}
else if (
as<InOutModifier>(modifier) || as<OutModifier>(modifier) ||
- as<ConstRefModifier>(modifier) || as<RefModifier>(modifier))
+ as<BorrowModifier>(modifier) || as<RefModifier>(modifier))
{
auto clonedModifier =
(Modifier*)m_astBuilder->createByNodeType(modifier->astNodeType);
clonedModifier->keywordName = modifier->keywordName;
addModifier(synParamDecl, clonedModifier);
- if (as<ConstRefModifier>(modifier))
+ if (as<BorrowModifier>(modifier))
paramType.isLeftValue = false;
}
}
@@ -5361,15 +5361,15 @@ static bool isWrapperTypeDecl(Decl* decl)
// Is it allowed to have an interface method parameter whose direction is `reqDir`, and an
// implementing method parameter whose direction is `implDir`?
//
-static bool matchParamDirection(ParameterDirection implDir, ParameterDirection reqDir)
+static bool matchParamDirection(ParamPassingMode implDir, ParamPassingMode reqDir)
{
// If the parameter directions match exactly, then we are good.
if (implDir == reqDir)
return true;
// Otherwise, we only allow the cases where reqDir is `InOut` and implDir is `In` or `Out`.
- if (implDir == kParameterDirection_In && reqDir == kParameterDirection_InOut)
+ if (implDir == ParamPassingMode::In && reqDir == ParamPassingMode::BorrowInOut)
return true;
- if (implDir == kParameterDirection_Out && reqDir == kParameterDirection_InOut)
+ if (implDir == ParamPassingMode::Out && reqDir == ParamPassingMode::BorrowInOut)
return true;
return false;
}
@@ -9440,8 +9440,8 @@ bool SemanticsVisitor::doFunctionSignaturesMatch(DeclRef<FuncDecl> fst, DeclRef<
// If one parameter is `constref` and the other isn't, then they don't match.
//
- if (fstParam.getDecl()->hasModifier<ConstRefModifier>() !=
- sndParam.getDecl()->hasModifier<ConstRefModifier>())
+ if (fstParam.getDecl()->hasModifier<BorrowModifier>() !=
+ sndParam.getDecl()->hasModifier<BorrowModifier>())
return false;
}
@@ -9962,7 +9962,7 @@ void SemanticsDeclHeaderVisitor::visitParamDecl(ParamDecl* paramDecl)
isMutable = true;
continue;
}
- if (as<RefModifier>(modifier) || as<ConstRefModifier>(modifier))
+ if (as<RefModifier>(modifier) || as<BorrowModifier>(modifier))
{
hasRefModifier = true;
}
@@ -9973,7 +9973,7 @@ void SemanticsDeclHeaderVisitor::visitParamDecl(ParamDecl* paramDecl)
if (isMutable)
newModifiers.add(this->getASTBuilder()->create<RefModifier>());
else
- newModifiers.add(this->getASTBuilder()->create<ConstRefModifier>());
+ newModifiers.add(this->getASTBuilder()->create<BorrowModifier>());
}
paramDecl->modifiers.first = newModifiers.getFirst();
for (Index i = 0; i < newModifiers.getCount(); i++)
@@ -9992,7 +9992,7 @@ void SemanticsDeclHeaderVisitor::visitParamDecl(ParamDecl* paramDecl)
for (auto modifier : paramDecl->modifiers)
{
if (as<OutModifier>(modifier) || as<InOutModifier>(modifier) ||
- as<RefModifier>(modifier) || as<ConstRefModifier>(modifier))
+ as<RefModifier>(modifier) || as<BorrowModifier>(modifier))
{
getSink()->diagnose(modifier, Diagnostics::parameterPackMustBeConst);
}
@@ -10534,17 +10534,17 @@ void SemanticsDeclHeaderVisitor::setFuncTypeIntoRequirementDecl(
param->type.type = paramType;
switch (paramDir)
{
- case ParameterDirection::kParameterDirection_InOut:
+ case ParamPassingMode::BorrowInOut:
addModifier(param, m_astBuilder->create<InOutModifier>());
break;
- case ParameterDirection::kParameterDirection_Out:
+ case ParamPassingMode::Out:
addModifier(param, m_astBuilder->create<OutModifier>());
break;
- case ParameterDirection::kParameterDirection_Ref:
+ case ParamPassingMode::Ref:
addModifier(param, m_astBuilder->create<RefModifier>());
break;
- case ParameterDirection::kParameterDirection_ConstRef:
- addModifier(param, m_astBuilder->create<ConstRefModifier>());
+ case ParamPassingMode::BorrowIn:
+ addModifier(param, m_astBuilder->create<BorrowModifier>());
break;
default:
break;
@@ -10657,11 +10657,11 @@ void SemanticsDeclHeaderVisitor::checkDifferentiableCallableCommon(CallableDecl*
}
if (!paramDecl->hasModifier<NoDiffModifier>())
{
- if (auto modifier = paramDecl->findModifier<ConstRefModifier>())
+ if (auto modifier = paramDecl->findModifier<BorrowModifier>())
{
getSink()->diagnose(
modifier,
- Diagnostics::cannotUseConstRefOnDifferentiableParameter);
+ Diagnostics::cannotUseBorrowInOnDifferentiableParameter);
}
}
}
@@ -12946,10 +12946,10 @@ Type* getTypeForThisExpr(SemanticsVisitor* visitor, DeclRef<FunctionDeclBase> fu
struct ArgsWithDirectionInfo
{
List<Expr*> args;
- List<ParameterDirection> directions;
+ List<ParamPassingMode> directions;
Expr* thisArg;
- ParameterDirection thisArgDirection;
+ ParamPassingMode thisArgDirection;
};
template<typename TDerivativeAttr>
@@ -12958,9 +12958,9 @@ void checkDerivativeAttributeImpl(
Decl* funcDecl,
TDerivativeAttr* attr,
const List<Expr*>& imaginaryArguments,
- const List<ParameterDirection>& expectedParamDirections,
+ const List<ParamPassingMode>& expectedParamDirections,
Expr* expectedThisArg,
- ParameterDirection expectedThisArgDirection)
+ ParamPassingMode expectedThisArgDirection)
{
if (isInterfaceRequirement(funcDecl))
{
@@ -13055,20 +13055,20 @@ void checkDerivativeAttributeImpl(
}
// If left value is true, then convert the
- // inner type to an InOutType.
+ // inner type to an BorrowInOutParamType.
//
auto qualTypeToString = [&](QualType qualType) -> String
{
Type* type = qualType.type;
if (qualType.isLeftValue)
{
- type = ctx.getASTBuilder()->getInOutType(type);
+ type = ctx.getASTBuilder()->getBorrowInOutParamType(type);
}
return type->toString();
};
List<Expr*> argList = imaginaryArguments;
- List<ParameterDirection> paramDirections = expectedParamDirections;
+ List<ParamPassingMode> paramDirections = expectedParamDirections;
bool expectStaticFunc = false;
if (expectedThisArg)
@@ -13275,7 +13275,7 @@ ArgsWithDirectionInfo getImaginaryArgsToFunc(
SourceLoc loc)
{
List<Expr*> imaginaryArguments;
- List<ParameterDirection> directions;
+ List<ParamPassingMode> directions;
for (auto param : func->getParameters())
{
auto arg = astBuilder->create<VarExpr>();
@@ -13286,7 +13286,7 @@ ArgsWithDirectionInfo getImaginaryArgsToFunc(
imaginaryArguments.add(arg);
directions.add(getParameterDirection(param));
}
- return {imaginaryArguments, directions, nullptr, ParameterDirection::kParameterDirection_In};
+ return {imaginaryArguments, directions, nullptr, ParamPassingMode::In};
}
ArgsWithDirectionInfo getImaginaryArgsToForwardDerivative(
@@ -13314,9 +13314,9 @@ ArgsWithDirectionInfo getImaginaryArgsToForwardDerivative(
}
}
- ParameterDirection thisTypeDirection = (thisArgExpr && !thisArgExpr->type.isLeftValue)
- ? ParameterDirection::kParameterDirection_In
- : ParameterDirection::kParameterDirection_InOut;
+ ParamPassingMode thisTypeDirection = (thisArgExpr && !thisArgExpr->type.isLeftValue)
+ ? ParamPassingMode::In
+ : ParamPassingMode::BorrowInOut;
List<Expr*> imaginaryArguments;
for (auto param : originalFuncDecl->getParameters())
@@ -13337,7 +13337,7 @@ ArgsWithDirectionInfo getImaginaryArgsToForwardDerivative(
}
// Copy parameter directions as is.
- List<ParameterDirection> expectedParamDirections;
+ List<ParamPassingMode> expectedParamDirections;
for (auto param : originalFuncDecl->getParameters())
{
expectedParamDirections.add(getParameterDirection(param));
@@ -13375,12 +13375,12 @@ ArgsWithDirectionInfo getImaginaryArgsToBackwardDerivative(
}
}
- ParameterDirection thisTypeDirection = (thisArgExpr && !thisArgExpr->type.isLeftValue)
- ? ParameterDirection::kParameterDirection_In
- : ParameterDirection::kParameterDirection_InOut;
+ ParamPassingMode thisTypeDirection = (thisArgExpr && !thisArgExpr->type.isLeftValue)
+ ? ParamPassingMode::In
+ : ParamPassingMode::BorrowInOut;
List<Expr*> imaginaryArguments;
- List<ParameterDirection> expectedParamDirections;
+ List<ParamPassingMode> expectedParamDirections;
auto isOutParam = [&](ParamDecl* param)
{
@@ -13397,7 +13397,7 @@ ArgsWithDirectionInfo getImaginaryArgsToBackwardDerivative(
arg->type.type = param->getType();
arg->loc = loc;
- ParameterDirection direction = getParameterDirection(param);
+ ParamPassingMode direction = getParameterDirection(param);
bool isDiffParam = (!param->findModifier<NoDiffModifier>());
if (isDiffParam)
@@ -13416,13 +13416,13 @@ ArgsWithDirectionInfo getImaginaryArgsToBackwardDerivative(
visitor->getASTBuilder(),
pairType->getPrimalType());
- direction = ParameterDirection::kParameterDirection_In;
+ direction = ParamPassingMode::In;
}
else
{
// in T : IDifferentiable -> inout DifferentialPair<T>
// inout T : IDifferentiable -> inout DifferentialPair<T>
- direction = ParameterDirection::kParameterDirection_InOut;
+ direction = ParamPassingMode::BorrowInOut;
}
}
else if (auto refPairType = as<DifferentialPtrPairType>(diffPair))
@@ -13446,7 +13446,7 @@ ArgsWithDirectionInfo getImaginaryArgsToBackwardDerivative(
// no_diff inout T -> in T
// no_diff in T -> in T
//
- direction = ParameterDirection::kParameterDirection_In;
+ direction = ParamPassingMode::In;
}
imaginaryArguments.add(arg);
@@ -13461,7 +13461,7 @@ ArgsWithDirectionInfo getImaginaryArgsToBackwardDerivative(
arg->type.type = diffReturnType;
arg->loc = loc;
imaginaryArguments.add(arg);
- expectedParamDirections.add(ParameterDirection::kParameterDirection_In);
+ expectedParamDirections.add(ParamPassingMode::In);
}
return {imaginaryArguments, expectedParamDirections, thisArgExpr, thisTypeDirection};
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index 235b57ca6..511834cef 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -2966,7 +2966,7 @@ Expr* SemanticsVisitor::CheckInvokeExprWithCheckedOperands(InvokeExpr* expr)
}
compareMemoryQualifierOfParamToArgument(paramDecl, argExpr);
- if (as<OutTypeBase>(paramType) || as<RefParamType>(paramType))
+ if (as<OutParamTypeBase>(paramType) || as<RefParamType>(paramType))
{
// `out`, `inout`, and `ref` parameters currently require
// an *exact* match on the type of the argument.
@@ -2994,7 +2994,7 @@ Expr* SemanticsVisitor::CheckInvokeExprWithCheckedOperands(InvokeExpr* expr)
//
// An argument can be made that transformation shouldn't apply to the
// ref scenario in general.
- if (implicitCastExpr && as<OutTypeBase>(paramType) &&
+ if (implicitCastExpr && as<OutParamTypeBase>(paramType) &&
_canLValueCoerce(
implicitCastExpr->arguments[0]->type,
implicitCastExpr->type))
@@ -3579,7 +3579,7 @@ Type* SemanticsVisitor::_toDifferentialParamType(Type* primalParamType)
// mode, and are not a proper part of the Slang type system
// (at least not at this time).
//
- if (auto primalParamWrapperType = as<ParamDirectionType>(primalParamType))
+ if (auto primalParamWrapperType = as<ParamPassingModeType>(primalParamType))
{
// Some parameter-passing modes do not naturally lend themselves
// to being differentiated - most notably, `ref` parameters.
@@ -3609,13 +3609,13 @@ Type* SemanticsVisitor::_toDifferentialParamType(Type* primalParamType)
//
if (as<OutType>(primalParamWrapperType))
{
- return m_astBuilder->getOutType(diffValueType);
+ return m_astBuilder->getOutParamType(diffValueType);
}
- else if (as<InOutType>(primalParamWrapperType))
+ else if (as<BorrowInOutParamType>(primalParamWrapperType))
{
- return m_astBuilder->getInOutType(diffValueType);
+ return m_astBuilder->getBorrowInOutParamType(diffValueType);
}
- else if (as<ConstRefParamType>(primalParamWrapperType))
+ else if (as<BorrowInParamType>(primalParamWrapperType))
{
return m_astBuilder->getConstRefParamType(diffValueType);
}
@@ -3753,9 +3753,9 @@ Type* SemanticsVisitor::getBackwardDiffFuncType(FuncType* originalType)
if (as<DifferentialPairType>(derivType))
{
// An `in` differentiable parameter becomes an `inout` parameter.
- derivType = m_astBuilder->getInOutType(derivType);
+ derivType = m_astBuilder->getBorrowInOutParamType(derivType);
}
- else if (auto inoutType = as<InOutType>(derivType))
+ else if (auto inoutType = as<BorrowInOutParamType>(derivType))
{
if (!as<DifferentialPairType>(inoutType->getValueType()))
{
diff --git a/source/slang/slang-check-impl.h b/source/slang/slang-check-impl.h
index dd5c816b1..d5d9c2372 100644
--- a/source/slang/slang-check-impl.h
+++ b/source/slang/slang-check-impl.h
@@ -1913,10 +1913,10 @@ public:
DeclRef<Decl> candidateMethod; // The method that was considered but failed
Type* actualType = nullptr; // For type mismatches: the actual type found
Type* expectedType = nullptr; // For type mismatches: the expected type
- ParameterDirection actualDir =
- kParameterDirection_In; // For direction mismatches: the actual direction
- ParameterDirection expectedDir =
- kParameterDirection_In; // For direction mismatches: the expected direction
+ ParamPassingMode actualDir =
+ ParamPassingMode::In; // For direction mismatches: the actual direction
+ ParamPassingMode expectedDir =
+ ParamPassingMode::In; // For direction mismatches: the expected direction
ParamDecl* paramDecl = nullptr; // For direction mismatches: the parameter declaration
};
diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp
index ebda2d637..7686a4703 100644
--- a/source/slang/slang-check-modifier.cpp
+++ b/source/slang/slang-check-modifier.cpp
@@ -1306,7 +1306,7 @@ ASTNodeType getModifierConflictGroupKind(ASTNodeType modifierType)
return modifierType;
case ASTNodeType::OutModifier:
case ASTNodeType::RefModifier:
- case ASTNodeType::ConstRefModifier:
+ case ASTNodeType::BorrowModifier:
case ASTNodeType::InOutModifier:
return ASTNodeType::OutModifier;
@@ -1415,7 +1415,7 @@ bool isModifierAllowedOnDecl(bool isGLSLInput, ASTNodeType modifierType, Decl* d
[[fallthrough]];
case ASTNodeType::RefModifier:
- case ASTNodeType::ConstRefModifier:
+ case ASTNodeType::BorrowModifier:
case ASTNodeType::GLSLBufferModifier:
case ASTNodeType::GLSLPatchModifier:
return (as<VarDeclBase>(decl) && isGlobalDecl(decl)) || as<ParamDecl>(decl) ||
diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp
index 2ad31c9d1..a13442135 100644
--- a/source/slang/slang-check-overload.cpp
+++ b/source/slang/slang-check-overload.cpp
@@ -632,9 +632,9 @@ static QualType getParamQualType(ASTBuilder* astBuilder, DeclRef<ParamDecl> para
bool isLVal = false;
switch (getParameterDirection(param.getDecl()))
{
- case kParameterDirection_InOut:
- case kParameterDirection_Out:
- case kParameterDirection_Ref:
+ case ParamPassingMode::BorrowInOut:
+ case ParamPassingMode::Out:
+ case ParamPassingMode::Ref:
isLVal = true;
break;
}
@@ -647,11 +647,11 @@ static QualType getParamQualType(Type* paramType)
// the accessors for the parameters of a `FuncType` should
// directly return a `QualType` for each parameter rather than
// a plain `Type` that potentially includes a wrapping
- // `ParamDirectionType`.
+ // `ParamPassingModeType`.
//
// In addition, the determination of what value category a reference
// to a parameter should be (and thus what the `QualType` sould be)
- // should be driven by computing the `ParameterDirection` first,
+ // should be driven by computing the `ParamPassingMode` first,
// and then using the direction to determine the value category
// (so as to isolate the code that needs to care about the wrapper
// types to just the computation of the dirction).
@@ -661,10 +661,10 @@ static QualType getParamQualType(Type* paramType)
//
bool isLVal = false;
Type* valueType = paramType;
- if (auto paramDirType = as<ParamDirectionType>(paramType))
+ if (auto paramDirType = as<ParamPassingModeType>(paramType))
{
valueType = paramDirType->getValueType();
- if (as<InOutParamType>(paramDirType))
+ if (as<BorrowInOutParamType>(paramDirType))
isLVal = true;
if (as<OutParamType>(paramDirType))
isLVal = true;
@@ -3031,7 +3031,7 @@ Expr* SemanticsVisitor::ResolveInvoke(InvokeExpr* expr)
// `openExistential` operation that was applied to `out` arguments.
//
auto funcType = context.bestCandidate->funcType;
- ShortList<ParameterDirection> paramDirections;
+ ShortList<ParamPassingMode> paramDirections;
if (funcType)
{
for (Index i = 0; i < funcType->getParamCount(); i++)
@@ -3053,10 +3053,10 @@ Expr* SemanticsVisitor::ResolveInvoke(InvokeExpr* expr)
{
switch (paramDirections[i])
{
- case kParameterDirection_Out:
- case kParameterDirection_InOut:
- case kParameterDirection_Ref:
- case kParameterDirection_ConstRef:
+ case ParamPassingMode::Out:
+ case ParamPassingMode::BorrowInOut:
+ case ParamPassingMode::Ref:
+ case ParamPassingMode::BorrowIn:
break;
default:
continue;
diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp
index 7b6ed2261..b714826de 100644
--- a/source/slang/slang-check-shader.cpp
+++ b/source/slang/slang-check-shader.cpp
@@ -843,15 +843,15 @@ Type* getParamTypeWithDirectionWrapper(ASTBuilder* astBuilder, DeclRef<VarDeclBa
auto direction = getParameterDirection(paramDeclRef.getDecl());
switch (direction)
{
- case kParameterDirection_In:
+ case ParamPassingMode::In:
return result;
- case kParameterDirection_ConstRef:
+ case ParamPassingMode::BorrowIn:
return astBuilder->getConstRefParamType(result);
- case kParameterDirection_Out:
- return astBuilder->getOutType(result);
- case kParameterDirection_InOut:
- return astBuilder->getInOutType(result);
- case kParameterDirection_Ref:
+ case ParamPassingMode::Out:
+ return astBuilder->getOutParamType(result);
+ case ParamPassingMode::BorrowInOut:
+ return astBuilder->getBorrowInOutParamType(result);
+ case ParamPassingMode::Ref:
return astBuilder->getRefParamType(result);
default:
return result;
diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h
index b1bb22ef3..d31247623 100644
--- a/source/slang/slang-diagnostic-defs.h
+++ b/source/slang/slang-diagnostic-defs.h
@@ -2224,8 +2224,8 @@ DIAGNOSTIC(
DIAGNOSTIC(
38034,
Error,
- cannotUseConstRefOnDifferentiableParameter,
- "cannot use '__constref' on a differentiable parameter.")
+ cannotUseBorrowInOnDifferentiableParameter,
+ "cannot use 'borrow in' on a differentiable parameter.")
DIAGNOSTIC(
38034,
Error,
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp
index 08caedb94..77c45a6d9 100644
--- a/source/slang/slang-emit-c-like.cpp
+++ b/source/slang/slang-emit-c-like.cpp
@@ -1619,7 +1619,7 @@ bool CLikeSourceEmitter::shouldFoldInstIntoUseSites(IRInst* inst)
auto ptrType = load->getPtr()->getDataType();
if (load->getPtr()->getOp() == kIROp_GlobalParam)
{
- if (ptrType->getOp() == kIROp_ConstRefType)
+ if (ptrType->getOp() == kIROp_BorrowInParamType)
return true;
if (auto ptrTypeBase = as<IRPtrTypeBase>(ptrType))
{
@@ -3879,24 +3879,24 @@ void CLikeSourceEmitter::emitParamTypeImpl(IRType* type, String const& name)
// encoded as a parameter of pointer type, so
// we need to decode that here.
//
- if (auto outType = as<IROutType>(type))
+ if (auto outType = as<IROutParamType>(type))
{
m_writer->emit("out ");
type = outType->getValueType();
}
- else if (auto inOutType = as<IRInOutType>(type))
+ else if (auto inOutType = as<IRBorrowInOutParamType>(type))
{
m_writer->emit("inout ");
type = inOutType->getValueType();
}
- else if (auto refType = as<IRRefType>(type))
+ else if (auto refType = as<IRRefParamType>(type))
{
// Note: There is no HLSL/GLSL equivalent for by-reference parameters,
// so we don't actually expect to encounter these in user code.
m_writer->emit("inout ");
type = refType->getValueType();
}
- else if (auto constRefType = as<IRConstRefType>(type))
+ else if (auto constRefType = as<IRBorrowInParamType>(type))
{
type = constRefType->getValueType();
}
@@ -4948,7 +4948,7 @@ void CLikeSourceEmitter::emitGlobalParam(IRGlobalParam* varDecl)
varType = ptrType->getValueType();
break;
default:
- if (as<IROutTypeBase>(ptrType))
+ if (as<IROutParamTypeBase>(ptrType))
varType = ptrType->getValueType();
break;
}
diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp
index 66829308d..c6d2bc6f3 100644
--- a/source/slang/slang-emit-cpp.cpp
+++ b/source/slang/slang-emit-cpp.cpp
@@ -305,7 +305,7 @@ SlangResult CPPSourceEmitter::calcTypeName(IRType* type, CodeGenTarget target, S
}
case kIROp_NativePtrType:
case kIROp_PtrType:
- case kIROp_ConstRefType:
+ case kIROp_BorrowInParamType:
{
// Special note on `constref` types and why they are not emitted
// as a `const` pointer:
@@ -499,8 +499,8 @@ void CPPSourceEmitter::useType(IRType* type)
type = static_cast<IRPtrType*>(type)->getValueType();
break;
}
- case kIROp_RefType:
- case kIROp_ConstRefType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
{
type = static_cast<IRPtrTypeBase*>(type)->getValueType();
break;
@@ -1151,16 +1151,16 @@ void CPPSourceEmitter::_emitType(IRType* type, DeclaratorInfo* declarator)
break;
}
case kIROp_PtrType:
- case kIROp_InOutType:
- case kIROp_OutType:
+ case kIROp_BorrowInOutParamType:
+ case kIROp_OutParamType:
{
auto ptrType = cast<IRPtrTypeBase>(type);
PtrDeclaratorInfo ptrDeclarator(declarator);
_emitType(ptrType->getValueType(), &ptrDeclarator);
}
break;
- case kIROp_RefType:
- case kIROp_ConstRefType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
{
auto ptrType = cast<IRPtrTypeBase>(type);
PtrDeclaratorInfo refDeclarator(declarator);
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp
index eb6d4c694..d2dc53a84 100644
--- a/source/slang/slang-emit-glsl.cpp
+++ b/source/slang/slang-emit-glsl.cpp
@@ -1218,8 +1218,10 @@ void GLSLSourceEmitter::_maybeEmitGLSLBuiltin(IRGlobalParam* var, UnownedStringS
// GLSL has some specific requirements about how these are declared,
// Do it manually here to avoid `emitGlobalParam` emitting
// decorations/layout we are not allowed to output.
- auto varType =
- composeGetters<IRType>(var, &IRGlobalParam::getDataType, &IROutTypeBase::getValueType);
+ auto varType = composeGetters<IRType>(
+ var,
+ &IRGlobalParam::getDataType,
+ &IROutParamTypeBase::getValueType);
SLANG_ASSERT(varType && "Indices mesh output dind't have an 'out' type");
m_writer->emit("out ");
@@ -1230,7 +1232,7 @@ void GLSLSourceEmitter::_maybeEmitGLSLBuiltin(IRGlobalParam* var, UnownedStringS
{
// Is this an output? We do not need to define input.
auto varType = var->getDataType();
- if (auto outType = as<IROutType>(varType))
+ if (auto outType = as<IROutParamType>(varType))
{
varType = outType->getValueType();
m_writer->emit("out ");
@@ -3229,7 +3231,7 @@ void GLSLSourceEmitter::emitVectorTypeNameImpl(IRType* elementType, IRIntegerVal
void GLSLSourceEmitter::emitTypeImpl(IRType* type, const StringSliceLoc* nameAndLoc)
{
- if (auto refType = as<IRRefType>(type))
+ if (auto refType = as<IRRefParamType>(type))
{
_requireGLSLExtension(UnownedStringSlice("GL_EXT_spirv_intrinsics"));
m_writer->emit("spirv_by_reference ");
@@ -3240,7 +3242,7 @@ void GLSLSourceEmitter::emitTypeImpl(IRType* type, const StringSliceLoc* nameAnd
void GLSLSourceEmitter::emitParamTypeImpl(IRType* type, String const& name)
{
- if (auto refType = as<IRRefType>(type))
+ if (auto refType = as<IRRefParamType>(type))
{
type = refType->getValueType();
@@ -3471,9 +3473,9 @@ void GLSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
emitSimpleTypeImpl(cast<IRAtomicType>(type)->getElementType());
return;
}
- case kIROp_ConstRefType:
+ case kIROp_BorrowInParamType:
{
- emitSimpleTypeImpl(as<IRConstRefType>(type)->getValueType());
+ emitSimpleTypeImpl(as<IRBorrowInParamType>(type)->getValueType());
return;
}
default:
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp
index 240b5c0cb..a5d634ebf 100644
--- a/source/slang/slang-emit-hlsl.cpp
+++ b/source/slang/slang-emit-hlsl.cpp
@@ -1476,9 +1476,9 @@ void HLSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
m_writer->emit(">");
return;
}
- case kIROp_ConstRefType:
+ case kIROp_BorrowInParamType:
{
- emitSimpleTypeImpl(as<IRConstRefType>(type)->getValueType());
+ emitSimpleTypeImpl(as<IRBorrowInParamType>(type)->getValueType());
return;
}
default:
diff --git a/source/slang/slang-emit-metal.cpp b/source/slang/slang-emit-metal.cpp
index 71de65ee7..e992d17f5 100644
--- a/source/slang/slang-emit-metal.cpp
+++ b/source/slang/slang-emit-metal.cpp
@@ -1180,13 +1180,13 @@ void MetalSourceEmitter::emitSimpleTypeImpl(IRType* type)
return;
}
case kIROp_PtrType:
- case kIROp_InOutType:
- case kIROp_OutType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
+ case kIROp_BorrowInOutParamType:
+ case kIROp_OutParamType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
{
auto ptrType = cast<IRPtrTypeBase>(type);
- if (type->getOp() == kIROp_ConstRefType)
+ if (type->getOp() == kIROp_BorrowInParamType)
{
m_writer->emit("const ");
}
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index ea49cb08c..b3232de93 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -1793,10 +1793,10 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
return emitOpTypeFloat(inst, SpvLiteralInteger::from32(int32_t(i.width)));
}
case kIROp_PtrType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
- case kIROp_OutType:
- case kIROp_InOutType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
+ case kIROp_OutParamType:
+ case kIROp_BorrowInOutParamType:
{
SpvStorageClass storageClass = SpvStorageClassFunction;
auto ptrType = as<IRPtrTypeBase>(inst);
@@ -8167,10 +8167,10 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
break;
case kIROp_PtrType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
- case kIROp_OutType:
- case kIROp_InOutType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
+ case kIROp_OutParamType:
+ case kIROp_BorrowInOutParamType:
if (auto ptrType = as<IRPtrTypeBase>(type))
return checkTypeNeedsStorageCapability(
ptrType->getValueType(),
diff --git a/source/slang/slang-emit-vm.cpp b/source/slang/slang-emit-vm.cpp
index 36fa1cea6..1602fbfb8 100644
--- a/source/slang/slang-emit-vm.cpp
+++ b/source/slang/slang-emit-vm.cpp
@@ -356,9 +356,9 @@ public:
case kIROp_UInt64Type:
case kIROp_UIntPtrType:
case kIROp_PtrType:
- case kIROp_OutType:
- case kIROp_InOutType:
- case kIROp_RefType:
+ case kIROp_OutParamType:
+ case kIROp_BorrowInOutParamType:
+ case kIROp_RefParamType:
case kIROp_NativePtrType:
extCode.scalarType = kSlangByteCodeScalarTypeUnsignedInt;
extCode.scalarBitWidth = 3;
diff --git a/source/slang/slang-emit-wgsl.cpp b/source/slang/slang-emit-wgsl.cpp
index b115c723a..3cebae97c 100644
--- a/source/slang/slang-emit-wgsl.cpp
+++ b/source/slang/slang-emit-wgsl.cpp
@@ -567,10 +567,10 @@ void WGSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
}
case kIROp_PtrType:
- case kIROp_InOutType:
- case kIROp_OutType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
+ case kIROp_BorrowInOutParamType:
+ case kIROp_OutParamType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
{
auto ptrType = cast<IRPtrTypeBase>(type);
m_writer->emit("ptr<");
diff --git a/source/slang/slang-ir-addr-inst-elimination.cpp b/source/slang/slang-ir-addr-inst-elimination.cpp
index 51477419b..b4e02465a 100644
--- a/source/slang/slang-ir-addr-inst-elimination.cpp
+++ b/source/slang/slang-ir-addr-inst-elimination.cpp
@@ -98,7 +98,7 @@ struct AddressInstEliminationContext
auto call = as<IRCall>(use->getUser());
// Don't change the use if addr is a non mutable address.
- if (as<IRConstRefType>(getRootAddr(addr)->getDataType()))
+ if (as<IRBorrowInParamType>(getRootAddr(addr)->getDataType()))
{
return;
}
@@ -126,7 +126,7 @@ struct AddressInstEliminationContext
{
for (auto inst : block->getChildren())
{
- if (as<IRConstRefType>(getRootAddr(inst)->getDataType()))
+ if (as<IRBorrowInParamType>(getRootAddr(inst)->getDataType()))
continue;
if (auto ptrType = as<IRPtrTypeBase>(inst->getDataType()))
{
diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp
index cd729ce6b..946d5e7cb 100644
--- a/source/slang/slang-ir-autodiff-fwd.cpp
+++ b/source/slang/slang-ir-autodiff-fwd.cpp
@@ -79,7 +79,7 @@ void ForwardDiffTranscriber::generateTrivialFwdDiffFunc(IRFunc* primalFunc, IRFu
};
for (auto param : diffParams)
{
- if (auto outType = as<IROutTypeBase>(param->getFullType()))
+ if (auto outType = as<IROutParamTypeBase>(param->getFullType()))
{
if (isRelevantDifferentialPair(outType))
{
@@ -794,7 +794,7 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig
markDiffPairTypeInst(&argBuilder, srcVar, pairValType);
auto diffArg = findOrTranscribeDiffInst(&argBuilder, origArg);
- if (ptrParamType->getOp() == kIROp_InOutType)
+ if (ptrParamType->getOp() == kIROp_BorrowInOutParamType)
{
// Set initial value.
auto primalVal = argBuilder.emitLoad(primalArg);
@@ -814,7 +814,7 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig
auto store = argBuilder.emitStore(srcVar, initVal);
markDiffPairTypeInst(&argBuilder, store, pairValType);
}
- if (as<IROutTypeBase>(ptrParamType))
+ if (as<IROutParamTypeBase>(ptrParamType))
{
// Read back new value.
auto newVal = afterBuilder.emitLoad(srcVar);
@@ -1806,7 +1806,7 @@ void insertTempVarForMutableParams(IRModule* module, IRFunc* func)
List<IRParam*> params;
for (auto param : firstBlock->getParams())
{
- if (const auto ptrType = as<IROutTypeBase>(param->getDataType()))
+ if (const auto ptrType = as<IROutParamTypeBase>(param->getDataType()))
{
params.add(param);
}
@@ -1818,7 +1818,7 @@ void insertTempVarForMutableParams(IRModule* module, IRFunc* func)
auto tempVar = builder.emitVar(ptrType->getValueType());
param->replaceUsesWith(tempVar);
mapParamToTempVar[param] = tempVar;
- if (ptrType->getOp() != kIROp_OutType)
+ if (ptrType->getOp() != kIROp_OutParamType)
{
builder.emitStore(tempVar, builder.emitLoad(param));
}
@@ -2315,7 +2315,7 @@ InstPair ForwardDiffTranscriber::transcribeFuncParam(
IRInst* primalInitVal = nullptr;
IRInst* diffInitVal = nullptr;
- if (as<IROutType>(diffPairType))
+ if (as<IROutParamType>(diffPairType))
{
primalInitVal = builder->emitDefaultConstruct(ptrInnerPairType->getValueType());
diffInitVal = builder->emitDefaultConstructRaw(diffType);
diff --git a/source/slang/slang-ir-autodiff-primal-hoist.cpp b/source/slang/slang-ir-autodiff-primal-hoist.cpp
index e9eda21da..5dea7f61b 100644
--- a/source/slang/slang-ir-autodiff-primal-hoist.cpp
+++ b/source/slang/slang-ir-autodiff-primal-hoist.cpp
@@ -2814,7 +2814,7 @@ bool DefaultCheckpointPolicy::canRecompute(UseOrPseudoUse use)
{
// An exception is a load of a constref parameter, which should
// remain constant throughout the function.
- if (as<IRConstRefType>(getRootAddr(ptr)->getDataType()))
+ if (as<IRBorrowInParamType>(getRootAddr(ptr)->getDataType()))
return true;
if (isInstInPrimalOrTransposedParameterBlocks(ptr))
return false;
diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp
index ca768cd66..ab964aef6 100644
--- a/source/slang/slang-ir-autodiff-rev.cpp
+++ b/source/slang/slang-ir-autodiff-rev.cpp
@@ -59,7 +59,7 @@ IRFuncType* BackwardDiffPrimalTranscriber::differentiateFunctionType(
(IRType*)specializeWithGeneric(*builder, intermediateType, as<IRGeneric>(outerGeneric));
}
- auto outType = builder->getOutType(intermediateType);
+ auto outType = builder->getOutParamType(intermediateType);
List<IRType*> paramTypes;
for (UInt i = 0; i < funcType->getParamCount(); i++)
{
@@ -308,7 +308,7 @@ static IRType* _getPrimalTypeFromNoDiffType(
IRType* origType)
{
IRType* valueType = origType;
- auto ptrType = as<IROutTypeBase>(valueType);
+ auto ptrType = as<IROutParamTypeBase>(valueType);
if (ptrType)
valueType = ptrType->getValueType();
@@ -354,7 +354,7 @@ IRType* BackwardDiffTranscriberBase::transcribeParamTypeForPropagateFunc(
IRBuilder* builder,
IRType* paramType)
{
- if (auto outType = as<IROutType>(paramType))
+ if (auto outType = as<IROutParamType>(paramType))
{
auto valueType = outType->getValueType();
auto diffValueType = differentiateType(builder, valueType);
@@ -363,7 +363,7 @@ IRType* BackwardDiffTranscriberBase::transcribeParamTypeForPropagateFunc(
auto maybeConvertInOutTypeToValueType = [](IRType* type)
{
- if (auto inoutType = as<IRInOutType>(type))
+ if (auto inoutType = as<IRBorrowInOutParamType>(type))
return inoutType->getValueType();
return type;
};
@@ -376,7 +376,7 @@ IRType* BackwardDiffTranscriberBase::transcribeParamTypeForPropagateFunc(
if (diffPairType)
{
if (!asRelevantPtrType(diffPairType) && !as<IRDifferentialPtrPairType>(diffPairType))
- return builder->getInOutType(diffPairType);
+ return builder->getBorrowInOutParamType(diffPairType);
return diffPairType;
}
auto primalType = (IRType*)findOrTranscribePrimalInst(builder, paramType);
@@ -515,7 +515,7 @@ InstPair BackwardDiffTranscriber::transcribeFuncHeader(IRBuilder* inBuilder, IRF
// Fetch primal values to use as arguments in primal func call.
IRInst* primalArg = param;
- if (!as<IROutType>(primalParamType) && !as<IRConstRefType>(primalParamType))
+ if (!as<IROutParamType>(primalParamType) && !as<IRBorrowInParamType>(primalParamType))
{
// As long as the primal parameter is not an out or constref type,
// we need to fetch the primal value from the parameter.
@@ -537,7 +537,7 @@ InstPair BackwardDiffTranscriber::transcribeFuncHeader(IRBuilder* inBuilder, IRF
// value of the temp var, otherwise the temp var will be uninitialized which could
// cause undefined behavior in the primal function.
//
- if (!as<IROutType>(primalParamType))
+ if (!as<IROutParamType>(primalParamType))
builder.emitStore(tempVar, primalArg);
primalArgs.add(tempVar);
@@ -588,7 +588,7 @@ InstPair BackwardDiffTranscriber::transcribeFuncHeader(IRBuilder* inBuilder, IRF
auto primalFuncType = builder.getFuncType(primalTypes, primalResultType);
primalArgs.add(intermediateVar);
- primalTypes.add(builder.getOutType(intermediateType));
+ primalTypes.add(builder.getOutParamType(intermediateType));
auto primalFunc =
builder.emitBackwardDifferentiatePrimalInst(primalFuncType, specializedOriginalFunc);
builder.emitCallInst(primalResultType, primalFunc, primalArgs);
@@ -1066,8 +1066,8 @@ ParameterBlockTransposeInfo BackwardDiffTranscriberBase::splitAndTransposeParame
// Common logic that computes all the important types we care about.
IRDifferentialPairType* diffPairType = as<IRDifferentialPairType>(fwdParam->getDataType());
- auto inoutType = as<IRInOutType>(fwdParam->getDataType());
- auto outType = as<IROutType>(fwdParam->getDataType());
+ auto inoutType = as<IRBorrowInOutParamType>(fwdParam->getDataType());
+ auto outType = as<IROutParamType>(fwdParam->getDataType());
if (inoutType)
diffPairType = as<IRDifferentialPairType>(inoutType->getValueType());
else if (outType)
@@ -1094,7 +1094,7 @@ ParameterBlockTransposeInfo BackwardDiffTranscriberBase::splitAndTransposeParame
auto diffParam = builder->emitParam(diffType);
copyNameHintAndDebugDecorations(diffParam, fwdParam);
result.propagateFuncParams.add(diffParam);
- primalRefReplacement = builder->emitParam(builder->getOutType(primalType));
+ primalRefReplacement = builder->emitParam(builder->getOutParamType(primalType));
copyNameHintAndDebugDecorations(primalRefReplacement, fwdParam);
// Create a local var for read access in pre-transpose code.
@@ -1178,7 +1178,7 @@ ParameterBlockTransposeInfo BackwardDiffTranscriberBase::splitAndTransposeParame
SLANG_RELEASE_ASSERT(diffPairType);
// Create inout version.
- auto inoutDiffPairType = builder->getInOutType(diffPairType);
+ auto inoutDiffPairType = builder->getBorrowInOutParamType(diffPairType);
primalRefReplacement = builder->emitParam(primalType);
copyNameHintAndDebugDecorations(primalRefReplacement, fwdParam);
@@ -1217,7 +1217,7 @@ ParameterBlockTransposeInfo BackwardDiffTranscriberBase::splitAndTransposeParame
SLANG_ASSERT(inoutType && diffPairType);
// Process differentiable inout parameters.
- auto primalParam = builder->emitParam(builder->getInOutType(primalType));
+ auto primalParam = builder->emitParam(builder->getBorrowInOutParamType(primalType));
copyNameHintAndDebugDecorations(primalParam, fwdParam);
result.primalFuncParams.add(primalParam);
diff --git a/source/slang/slang-ir-autodiff-transcriber-base.cpp b/source/slang/slang-ir-autodiff-transcriber-base.cpp
index a4934dc28..9aeb6068e 100644
--- a/source/slang/slang-ir-autodiff-transcriber-base.cpp
+++ b/source/slang/slang-ir-autodiff-transcriber-base.cpp
@@ -347,17 +347,17 @@ IRType* AutoDiffTranscriberBase::_differentiateTypeImpl(IRBuilder* builder, IRTy
case kIROp_FuncType:
return differentiateFunctionType(builder, nullptr, as<IRFuncType>(primalType));
- case kIROp_OutType:
+ case kIROp_OutParamType:
if (auto diffValueType =
- differentiateType(builder, as<IROutType>(primalType)->getValueType()))
- return builder->getOutType(diffValueType);
+ differentiateType(builder, as<IROutParamType>(primalType)->getValueType()))
+ return builder->getOutParamType(diffValueType);
else
return nullptr;
- case kIROp_InOutType:
+ case kIROp_BorrowInOutParamType:
if (auto diffValueType =
- differentiateType(builder, as<IRInOutType>(primalType)->getValueType()))
- return builder->getInOutType(diffValueType);
+ differentiateType(builder, as<IRBorrowInOutParamType>(primalType)->getValueType()))
+ return builder->getBorrowInOutParamType(diffValueType);
else
return nullptr;
diff --git a/source/slang/slang-ir-autodiff-transpose.h b/source/slang/slang-ir-autodiff-transpose.h
index 69cb2c8ce..c70374e77 100644
--- a/source/slang/slang-ir-autodiff-transpose.h
+++ b/source/slang/slang-ir-autodiff-transpose.h
@@ -1164,7 +1164,7 @@ struct DiffTransposePass
auto pairVal = builder->emitMakeDifferentialPair(pairType, primalVal, diffVal);
builder->emitStore(tempVar, pairVal);
args.add(tempVar);
- argTypes.add(builder->getInOutType(pairType));
+ argTypes.add(builder->getBorrowInOutParamType(pairType));
argRequiresLoad.add(false);
writebacks.add(DiffValWriteBack{instPair->getDiff(), tempVar});
}
@@ -1193,17 +1193,17 @@ struct DiffTransposePass
diffZero));
args.add(var);
- argTypes.add(builder->getInOutType(pairType));
+ argTypes.add(builder->getBorrowInOutParamType(pairType));
argRequiresLoad.add(true);
}
else
{
- if (as<IROutType>(paramType))
+ if (as<IROutParamType>(paramType))
{
args.add(nullptr);
argRequiresLoad.add(false);
}
- else if (as<IRInOutType>(paramType))
+ else if (as<IRBorrowInOutParamType>(paramType))
{
arg = builder->emitLoad(arg);
args.add(arg);
diff --git a/source/slang/slang-ir-autodiff-unzip.cpp b/source/slang/slang-ir-autodiff-unzip.cpp
index 4d5903ab1..1db476757 100644
--- a/source/slang/slang-ir-autodiff-unzip.cpp
+++ b/source/slang/slang-ir-autodiff-unzip.cpp
@@ -116,7 +116,7 @@ struct ExtractPrimalFuncContext
for (UInt i = 0; i < originalFuncType->getParamCount(); i++)
paramTypes.add(
(IRType*)migrationContext.cloneInst(&builder, originalFuncType->getParamType(i)));
- paramTypes.add(builder.getOutType((IRType*)outIntermediateType));
+ paramTypes.add(builder.getOutParamType((IRType*)outIntermediateType));
auto resultType =
(IRType*)migrationContext.cloneInst(&builder, originalFuncType->getResultType());
auto newFuncType = builder.getFuncType(paramTypes, resultType);
@@ -218,7 +218,8 @@ struct ExtractPrimalFuncContext
auto paramBlock = func->getFirstBlock();
builder.setInsertInto(paramBlock);
auto oldIntermediateParam = func->getLastParam();
- auto outIntermediary = builder.emitParam(builder.getOutType((IRType*)intermediateType));
+ auto outIntermediary =
+ builder.emitParam(builder.getOutParamType((IRType*)intermediateType));
oldIntermediateParam->transferDecorationsTo(outIntermediary);
primalParams.add(outIntermediary);
oldIntermediateParam->replaceUsesWith(outIntermediary);
diff --git a/source/slang/slang-ir-autodiff-unzip.h b/source/slang/slang-ir-autodiff-unzip.h
index 5685906b6..991cbe6ed 100644
--- a/source/slang/slang-ir-autodiff-unzip.h
+++ b/source/slang/slang-ir-autodiff-unzip.h
@@ -337,7 +337,7 @@ struct DiffUnzipPass
SLANG_ASSERT(diffArg);
auto primalParamType = resolvedPrimalFuncType->getParamType(ii);
- if (const auto outType = as<IROutType>(primalParamType))
+ if (const auto outType = as<IROutParamType>(primalParamType))
{
// For `out` parameters that expects an input derivative to propagate
// through, we insert a `LoadReverseGradient` inst here to signify the logic
@@ -351,7 +351,7 @@ struct DiffUnzipPass
diffBuilder->markInstAsDifferential(gradArg, primalArg->getDataType());
diffArgs.add(gradArg);
}
- else if (const auto inoutType = as<IRInOutType>(primalParamType))
+ else if (const auto inoutType = as<IRBorrowInOutParamType>(primalParamType))
{
// Since arg is split into separate vars, we need a new temp var that
// represents the remerged diff pair.
@@ -397,7 +397,7 @@ struct DiffUnzipPass
}
else
{
- if (as<IRInOutType>(resolvedPrimalFuncType->getParamType(ii)))
+ if (as<IRBorrowInOutParamType>(resolvedPrimalFuncType->getParamType(ii)))
{
// For 'inout' parameter we need to create a temp var to hold the value
// before the primal call. This logic is similar to the 'inout' case for
diff --git a/source/slang/slang-ir-autodiff.cpp b/source/slang/slang-ir-autodiff.cpp
index 011d1fec9..c1b724b9d 100644
--- a/source/slang/slang-ir-autodiff.cpp
+++ b/source/slang/slang-ir-autodiff.cpp
@@ -1721,17 +1721,17 @@ IRType* DifferentiableTypeConformanceContext::differentiateType(
SLANG_UNIMPLEMENTED_X("Impl");
}
- case kIROp_OutType:
+ case kIROp_OutParamType:
if (auto diffValueType =
- differentiateType(builder, as<IROutType>(primalType)->getValueType()))
- return builder->getOutType(diffValueType);
+ differentiateType(builder, as<IROutParamType>(primalType)->getValueType()))
+ return builder->getOutParamType(diffValueType);
else
return nullptr;
- case kIROp_InOutType:
+ case kIROp_BorrowInOutParamType:
if (auto diffValueType =
- differentiateType(builder, as<IRInOutType>(primalType)->getValueType()))
- return builder->getInOutType(diffValueType);
+ differentiateType(builder, as<IRBorrowInOutParamType>(primalType)->getValueType()))
+ return builder->getBorrowInOutParamType(diffValueType);
else
return nullptr;
@@ -3301,8 +3301,8 @@ struct AutoDiffPass : public InstPassBase
{
case kIROp_ArrayType:
case kIROp_UnsizedArrayType:
- case kIROp_InOutType:
- case kIROp_OutType:
+ case kIROp_BorrowInOutParamType:
+ case kIROp_OutParamType:
case kIROp_PtrType:
case kIROp_DifferentialPairType:
case kIROp_DifferentialPairUserCodeType:
diff --git a/source/slang/slang-ir-autodiff.h b/source/slang/slang-ir-autodiff.h
index 970f490c9..6515b1e1f 100644
--- a/source/slang/slang-ir-autodiff.h
+++ b/source/slang/slang-ir-autodiff.h
@@ -376,8 +376,8 @@ struct DifferentiableTypeConformanceContext
case kIROp_VectorType:
case kIROp_ArrayType:
case kIROp_PtrType:
- case kIROp_OutType:
- case kIROp_InOutType:
+ case kIROp_OutParamType:
+ case kIROp_BorrowInOutParamType:
origType = (IRType*)origType->getOperand(0);
continue;
default:
@@ -396,8 +396,8 @@ struct DifferentiableTypeConformanceContext
case kIROp_VectorType:
case kIROp_ArrayType:
case kIROp_PtrType:
- case kIROp_OutType:
- case kIROp_InOutType:
+ case kIROp_OutParamType:
+ case kIROp_BorrowInOutParamType:
origType = (IRType*)origType->getOperand(0);
continue;
default:
diff --git a/source/slang/slang-ir-check-differentiability.cpp b/source/slang/slang-ir-check-differentiability.cpp
index d83d7bb76..81e815044 100644
--- a/source/slang/slang-ir-check-differentiability.cpp
+++ b/source/slang/slang-ir-check-differentiability.cpp
@@ -675,7 +675,7 @@ public:
auto paramType = calleeFuncType->getParamType(a);
if (!isDifferentiableType(diffTypeContext, paramType))
continue;
- if (as<IROutTypeBase>(paramType))
+ if (as<IROutParamTypeBase>(paramType))
{
if (!canAddressHoldDerivative(diffTypeContext, arg))
{
diff --git a/source/slang/slang-ir-defer-buffer-load.cpp b/source/slang/slang-ir-defer-buffer-load.cpp
index ccdfe4538..4736b4e65 100644
--- a/source/slang/slang-ir-defer-buffer-load.cpp
+++ b/source/slang/slang-ir-defer-buffer-load.cpp
@@ -59,7 +59,7 @@ static bool isCompositeTypeContainingArrays(IRType* type)
bool isTypePreferrableToDeferLoad(CodeGenContext* codeGenContext, IRType* type)
{
// If parameter is a pointer/reference, we should consider specialize it.
- if (as<IROutTypeBase>(type) || as<IRRefType>(type) || as<IRConstRefType>(type))
+ if (as<IROutParamTypeBase>(type) || as<IRRefParamType>(type) || as<IRBorrowInParamType>(type))
return true;
// We only want to defer loading values that are "large enough" that
diff --git a/source/slang/slang-ir-fix-entrypoint-callsite.cpp b/source/slang/slang-ir-fix-entrypoint-callsite.cpp
index a0ab07928..c0928a2ff 100644
--- a/source/slang/slang-ir-fix-entrypoint-callsite.cpp
+++ b/source/slang/slang-ir-fix-entrypoint-callsite.cpp
@@ -81,7 +81,7 @@ void fixEntryPointCallsites(IRFunc* entryPoint)
{
auto paramType = params[i]->getDataType();
auto arg = call->getArg(i);
- if (auto refType = as<IRConstRefType>(paramType))
+ if (auto refType = as<IRBorrowInParamType>(paramType))
{
if (!as<IRPtrTypeBase>(arg->getDataType()))
{
diff --git a/source/slang/slang-ir-glsl-legalize.cpp b/source/slang/slang-ir-glsl-legalize.cpp
index d87d96da0..bc26b223b 100644
--- a/source/slang/slang-ir-glsl-legalize.cpp
+++ b/source/slang/slang-ir-glsl-legalize.cpp
@@ -1429,7 +1429,7 @@ ScalarizedVal createSimpleGLSLGlobalVarying(
break;
case LayoutResourceKind::VaryingOutput:
addrSpace = systemValueInfo ? AddressSpace::BuiltinOutput : AddressSpace::Output;
- ptrOpCode = kIROp_OutType;
+ ptrOpCode = kIROp_OutParamType;
break;
default:
break;
@@ -2555,8 +2555,8 @@ static void consolidateParameters(GLSLLegalizationContext* context, List<IRParam
auto _paramType = _param->getDataType();
IRType* valueType = _paramType;
- if (as<IROutTypeBase>(_paramType))
- valueType = as<IROutTypeBase>(_paramType)->getValueType();
+ if (as<IROutParamTypeBase>(_paramType))
+ valueType = as<IROutParamTypeBase>(_paramType)->getValueType();
auto key = builder->createStructKey();
if (auto nameDecor = _param->findDecoration<IRNameHintDecoration>())
@@ -2600,13 +2600,13 @@ static void consolidateParameters(GLSLLegalizationContext* context, List<IRParam
// If the parameter is an out/inout type, we need to create a pointer type
IRType* fieldPtrType = nullptr;
- if (as<IROutType>(_paramType))
+ if (as<IROutParamType>(_paramType))
{
- fieldPtrType = builder->getPtrType(kIROp_OutType, fieldType);
+ fieldPtrType = builder->getPtrType(kIROp_OutParamType, fieldType);
}
- else if (as<IRInOutType>(_paramType))
+ else if (as<IRBorrowInOutParamType>(_paramType))
{
- fieldPtrType = builder->getPtrType(kIROp_InOutType, fieldType);
+ fieldPtrType = builder->getPtrType(kIROp_BorrowInOutParamType, fieldType);
}
auto fieldAddr =
@@ -2636,7 +2636,8 @@ void consolidateRayTracingParameters(GLSLLegalizationContext* context, IRFunc* f
if (!isVaryingParameter(paramLayout))
continue;
builder->setInsertBefore(firstBlock->getFirstOrdinaryInst());
- if (as<IROutType>(param->getDataType()) || as<IRInOutType>(param->getDataType()))
+ if (as<IROutParamType>(param->getDataType()) ||
+ as<IRBorrowInOutParamType>(param->getDataType()))
{
outParams.add(param);
}
@@ -3019,7 +3020,7 @@ static void legalizeMeshOutputParam(
auto t = composeGetters<IRType>(
builtin.param,
&IRInst::getFullType,
- &IROutTypeBase::getValueType,
+ &IROutParamTypeBase::getValueType,
&IRArrayTypeBase::getElementType);
auto key = builder->createStructKey();
auto n = builtin.nameDecoration->getStringSlice();
@@ -3386,7 +3387,7 @@ void legalizeEntryPointParameterForGLSL(
{
IRType* type = pp->getFullType();
// Strip out type
- if (auto outType = as<IROutTypeBase>(type))
+ if (auto outType = as<IROutParamTypeBase>(type))
{
type = outType->getValueType();
}
@@ -3581,7 +3582,7 @@ void legalizeEntryPointParameterForGLSL(
// Is the parameter type a special pointer type
// that indicates the parameter is used for `out`
// or `inout` access?
- if (as<IROutTypeBase>(paramType))
+ if (as<IROutParamTypeBase>(paramType))
{
// Okay, we have the more interesting case here,
// where the parameter was being passed by reference.
@@ -3592,7 +3593,7 @@ void legalizeEntryPointParameterForGLSL(
auto localVariable = builder->emitVar(valueType);
auto localVal = ScalarizedVal::address(localVariable);
- if (const auto inOutType = as<IRInOutType>(paramType))
+ if (const auto inOutType = as<IRBorrowInOutParamType>(paramType))
{
// In the `in out` case we need to declare two
// sets of global variables: one for the `in`
@@ -3663,7 +3664,7 @@ void legalizeEntryPointParameterForGLSL(
// reference. We simply replace existing uses of the parameter
// with the real global variable.
SLANG_ASSERT(
- ptrType->getOp() == kIROp_ConstRefType ||
+ ptrType->getOp() == kIROp_BorrowInParamType ||
ptrType->getAddressSpace() == AddressSpace::Input ||
ptrType->getAddressSpace() == AddressSpace::BuiltinInput);
diff --git a/source/slang/slang-ir-glsl-liveness.cpp b/source/slang/slang-ir-glsl-liveness.cpp
index 626313b38..8bde2da01 100644
--- a/source/slang/slang-ir-glsl-liveness.cpp
+++ b/source/slang/slang-ir-glsl-liveness.cpp
@@ -133,10 +133,10 @@ void GLSLLivenessContext::_replaceMarker(IRLiveRangeMarker* markerInst)
{
// We didn't find a function for the type, so lets create one. It has a signature of
//
- // void func(Ref<ReferencedType> target, int sizeInBytes)
+ // void func(ref ReferencedType target, int sizeInBytes)
IRType* paramTypes[] = {
- m_builder.getRefType(
+ m_builder.getRefParamType(
referencedType,
AddressSpace::Generic), ///< Use a reference to the referenced type
m_spirvIntLiteralType, ///< The size type
diff --git a/source/slang/slang-ir-inline.cpp b/source/slang/slang-ir-inline.cpp
index f0f940b12..3334197c0 100644
--- a/source/slang/slang-ir-inline.cpp
+++ b/source/slang/slang-ir-inline.cpp
@@ -1017,7 +1017,7 @@ struct TypeInliningPass : InliningPassBase
const auto op = type->getOp();
switch (op)
{
- case kIROp_RefType:
+ case kIROp_RefParamType:
{
if (callee->findDecoration<IRNoRefInlineDecoration>())
return false;
@@ -1230,7 +1230,7 @@ struct GLSLResourceReturnFunctionInliningPass : InliningPassBase
{
if (isIllegalGLSLParameterType(param->getDataType()))
return true;
- auto outType = as<IROutTypeBase>(param->getDataType());
+ auto outType = as<IROutParamTypeBase>(param->getDataType());
if (!outType)
continue;
auto outValueType = outType->getValueType();
diff --git a/source/slang/slang-ir-insert-debug-value-store.cpp b/source/slang/slang-ir-insert-debug-value-store.cpp
index 25b9c03fa..91b7738f1 100644
--- a/source/slang/slang-ir-insert-debug-value-store.cpp
+++ b/source/slang/slang-ir-insert-debug-value-store.cpp
@@ -118,12 +118,12 @@ void DebugValueStoreContext::insertDebugValueStore(IRFunc* func)
builder.setInsertBefore(firstBlock->getFirstOrdinaryInst());
auto paramType = param->getDataType();
bool isRefParam = false;
- if (auto outType = as<IROutTypeBase>(paramType))
+ if (auto outType = as<IROutParamTypeBase>(paramType))
{
isRefParam = true;
paramType = outType->getValueType();
}
- else if (auto ptrType = as<IRConstRefType>(param->getDataType()))
+ else if (auto ptrType = as<IRBorrowInParamType>(param->getDataType()))
{
isRefParam = true;
paramType = ptrType->getValueType();
@@ -146,7 +146,9 @@ void DebugValueStoreContext::insertDebugValueStore(IRFunc* func)
{
paramVal = param;
}
- else if (as<IRInOutType>(param->getDataType()) || as<IRConstRefType>(param->getDataType()))
+ else if (
+ as<IRBorrowInOutParamType>(param->getDataType()) ||
+ as<IRBorrowInParamType>(param->getDataType()))
{
paramVal = builder.emitLoad(param);
}
diff --git a/source/slang/slang-ir-insts-stable-names.lua b/source/slang/slang-ir-insts-stable-names.lua
index 25d54eb04..cfde8c5fa 100644
--- a/source/slang/slang-ir-insts-stable-names.lua
+++ b/source/slang/slang-ir-insts-stable-names.lua
@@ -59,11 +59,11 @@ return {
["Type.Kind.Rate"] = 55,
["Type.Kind.Generic"] = 56,
["Type.PtrTypeBase.Ptr"] = 57,
- ["Type.PtrTypeBase.Ref"] = 58,
- ["Type.PtrTypeBase.ConstRef"] = 59,
+ ["Type.PtrTypeBase.RefParam"] = 58,
+ ["Type.PtrTypeBase.BorrowInParam"] = 59,
["Type.PtrTypeBase.PseudoPtr"] = 60,
- ["Type.PtrTypeBase.OutTypeBase.Out"] = 61,
- ["Type.PtrTypeBase.OutTypeBase.InOut"] = 62,
+ ["Type.PtrTypeBase.OutParamTypeBase.OutParam"] = 61,
+ ["Type.PtrTypeBase.OutParamTypeBase.BorrowInOutParam"] = 62,
["Type.ComPtr"] = 63,
["Type.NativePtr"] = 64,
["Type.DescriptorHandle"] = 65,
diff --git a/source/slang/slang-ir-insts.h b/source/slang/slang-ir-insts.h
index c64f65ccb..7b27f0b56 100644
--- a/source/slang/slang-ir-insts.h
+++ b/source/slang/slang-ir-insts.h
@@ -3735,10 +3735,10 @@ public:
// Form a ptr type to `valueType` using the same opcode and address space as `ptrWithAddrSpace`.
IRPtrTypeBase* getPtrTypeWithAddressSpace(IRType* valueType, IRPtrTypeBase* ptrWithAddrSpace);
- IROutType* getOutType(IRType* valueType);
- IRInOutType* getInOutType(IRType* valueType);
- IRRefType* getRefType(IRType* valueType, AddressSpace addrSpace);
- IRConstRefType* getConstRefType(IRType* valueType, AddressSpace addrSpace);
+ IROutParamType* getOutParamType(IRType* valueType);
+ IRBorrowInOutParamType* getBorrowInOutParamType(IRType* valueType);
+ IRRefParamType* getRefParamType(IRType* valueType, AddressSpace addrSpace);
+ IRBorrowInParamType* getBorrowInParamType(IRType* valueType, AddressSpace addrSpace);
IRPtrType* getPtrType(
IROp op,
IRType* valueType,
diff --git a/source/slang/slang-ir-insts.lua b/source/slang/slang-ir-insts.lua
index 5f54707a1..045144e06 100644
--- a/source/slang/slang-ir-insts.lua
+++ b/source/slang/slang-ir-insts.lua
@@ -144,8 +144,8 @@ local insts = {
PtrTypeBase = {
hoistable = true,
{ Ptr = { struct_name = "PtrType", min_operands = 1 } },
- { Ref = { struct_name = "RefType", min_operands = 1 } },
- { ConstRef = { struct_name = "ConstRefType", min_operands = 1 } },
+ { RefParam = { struct_name = "RefParamType", min_operands = 1 } },
+ { BorrowInParam = { struct_name = "BorrowInParamType", min_operands = 1 } },
{
PseudoPtr = {
-- A `PsuedoPtr<T>` logically represents a pointer to a value of type
@@ -157,9 +157,9 @@ local insts = {
},
},
{
- OutTypeBase = {
- { Out = { struct_name = "OutType", min_operands = 1 } },
- { InOut = { struct_name = "InOutType", min_operands = 1 } },
+ OutParamTypeBase = {
+ { OutParam = { struct_name = "OutParamType", min_operands = 1 } },
+ { BorrowInOutParam = { struct_name = "BorrowInOutParamType", min_operands = 1 } },
},
},
},
diff --git a/source/slang/slang-ir-layout.cpp b/source/slang/slang-ir-layout.cpp
index d3b86a1c6..123dfdea4 100644
--- a/source/slang/slang-ir-layout.cpp
+++ b/source/slang/slang-ir-layout.cpp
@@ -343,10 +343,10 @@ Result IRTypeLayoutRules::calcSizeAndAlignment(
}
}
break;
- case kIROp_OutType:
- case kIROp_InOutType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
+ case kIROp_OutParamType:
+ case kIROp_BorrowInOutParamType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
case kIROp_RawPointerType:
case kIROp_PtrType:
case kIROp_NativePtrType:
diff --git a/source/slang/slang-ir-legalize-array-return-type.cpp b/source/slang/slang-ir-legalize-array-return-type.cpp
index cedd8386f..c42b3dbfd 100644
--- a/source/slang/slang-ir-legalize-array-return-type.cpp
+++ b/source/slang/slang-ir-legalize-array-return-type.cpp
@@ -19,7 +19,7 @@ void makeFuncReturnViaOutParam(IRBuilder& builder, IRFunc* func)
{
paramTypes.add(funcType->getParamType(i));
}
- auto outParamType = builder.getOutType(funcType->getResultType());
+ auto outParamType = builder.getOutParamType(funcType->getResultType());
paramTypes.add(outParamType);
auto newFuncType = builder.getFuncType(paramTypes, builder.getVoidType());
diff --git a/source/slang/slang-ir-legalize-types.cpp b/source/slang/slang-ir-legalize-types.cpp
index 27abdeaf0..5168f0466 100644
--- a/source/slang/slang-ir-legalize-types.cpp
+++ b/source/slang/slang-ir-legalize-types.cpp
@@ -2753,7 +2753,7 @@ private:
// except we wrap the simple type in `Out<...>` to indicate
// that we are producing an `out` parameter.
//
- m_paramTypes.add(m_context->builder->getOutType(t.getSimple()));
+ m_paramTypes.add(m_context->builder->getOutParamType(t.getSimple()));
break;
// The remaining cases are all simple recursion on the
diff --git a/source/slang/slang-ir-legalize-varying-params.cpp b/source/slang/slang-ir-legalize-varying-params.cpp
index 062330836..39b9b3dd3 100644
--- a/source/slang/slang-ir-legalize-varying-params.cpp
+++ b/source/slang/slang-ir-legalize-varying-params.cpp
@@ -525,11 +525,11 @@ protected:
// the strategy we take.
//
auto paramType = param->getDataType();
- if (auto inOutType = as<IRInOutType>(paramType))
+ if (auto inOutType = as<IRBorrowInOutParamType>(paramType))
{
processInOutParam(param, inOutType);
}
- else if (auto outType = as<IROutType>(paramType))
+ else if (auto outType = as<IROutParamType>(paramType))
{
processOutParam(param, outType);
}
@@ -545,16 +545,16 @@ protected:
// that provides baseline behavior that should in theory work for
// multiple targets.
//
- virtual void processInOutParam(IRParam* param, IRInOutType* inOutType)
+ virtual void processInOutParam(IRParam* param, IRBorrowInOutParamType* inOutType)
{
processMutableParam(param, inOutType);
}
- virtual void processOutParam(IRParam* param, IROutType* inOutType)
+ virtual void processOutParam(IRParam* param, IROutParamType* inOutType)
{
processMutableParam(param, inOutType);
}
- void processMutableParam(IRParam* param, IROutTypeBase* paramPtrType)
+ void processMutableParam(IRParam* param, IROutParamTypeBase* paramPtrType)
{
// The deafult handling of any mutable (`out` or `inout`) parameter
// will be to introduce a local variable of the corresponding
@@ -577,7 +577,7 @@ protected:
builder.addSimpleDecoration<IRTempCallArgVarDecoration>(localVar);
auto localVal = LegalizedVaryingVal::makeAddress(localVar);
- if (const auto inOutType = as<IRInOutType>(paramPtrType))
+ if (const auto inOutType = as<IRBorrowInOutParamType>(paramPtrType))
{
// If the parameter was an `inout` and not just an `out`
// parameter, we will create one more more legal `in`
@@ -1562,7 +1562,7 @@ void depointerizeInputParams(IRFunc* entryPointFunc)
Index i = 0;
for (auto param : entryPointFunc->getParams())
{
- if (auto constRefType = as<IRConstRefType>(param->getFullType()))
+ if (auto constRefType = as<IRBorrowInParamType>(param->getFullType()))
{
switch (constRefType->getValueType()->getOp())
{
@@ -3555,7 +3555,7 @@ protected:
builder.setInsertBefore(
entryPoint.entryPointFunc->getFirstBlock()->getFirstOrdinaryInst());
const auto annotatedPayloadType = builder.getPtrType(
- kIROp_RefType,
+ kIROp_RefParamType,
payloadPtrType->getValueType(),
AddressSpace::MetalObjectData);
auto packedParam = builder.emitParam(annotatedPayloadType);
@@ -3597,8 +3597,9 @@ protected:
IRPtrTypeBase* type = as<IRPtrTypeBase>(param->getDataType());
- const auto annotatedPayloadType =
- builder.getConstRefType(type->getValueType(), AddressSpace::MetalObjectData);
+ const auto annotatedPayloadType = builder.getBorrowInParamType(
+ type->getValueType(),
+ AddressSpace::MetalObjectData);
param->setFullType(annotatedPayloadType);
}
@@ -3660,7 +3661,7 @@ protected:
}
if (param->findDecorationImpl(kIROp_IndicesDecoration))
{
- auto indicesRefType = (IRConstRefType*)param->getDataType();
+ auto indicesRefType = (IRBorrowInParamType*)param->getDataType();
auto indicesOutputType = (IRIndicesType*)indicesRefType->getValueType();
indicesType = indicesOutputType->getElementType();
maxPrimitives = indicesOutputType->getMaxElementCount();
@@ -3670,7 +3671,7 @@ protected:
}
if (param->findDecorationImpl(kIROp_PrimitivesDecoration))
{
- auto primitivesRefType = (IRConstRefType*)param->getDataType();
+ auto primitivesRefType = (IRBorrowInParamType*)param->getDataType();
auto primitivesOutputType = (IRPrimitivesType*)primitivesRefType->getValueType();
primitiveType = primitivesOutputType->getElementType();
SLANG_ASSERT(primitiveType);
@@ -4036,7 +4037,7 @@ void legalizeVertexShaderOutputParamsForMetal(DiagnosticSink* sink, EntryPointIn
// handled further down the pipeline
const bool hasOutParameters = anyOf(
oldFunc->getParams(),
- [](auto param) { return as<IROutTypeBase>(param->getFullType()); });
+ [](auto param) { return as<IROutParamTypeBase>(param->getFullType()); });
auto returnType = oldFunc->getResultType();
if (!as<IRStructType>(returnType) && !hasOutParameters)
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp
index a3466c8c7..c46c57043 100644
--- a/source/slang/slang-ir-link.cpp
+++ b/source/slang/slang-ir-link.cpp
@@ -1863,7 +1863,8 @@ void convertAtomicToStorageBuffer(
auto funcTypeInst = (user->getOperand(0));
auto funcType = funcTypeInst->getFullType();
- auto paramReplacment = builder.getInOutType(builder.getUIntType());
+ auto paramReplacment =
+ builder.getBorrowInOutParamType(builder.getUIntType());
funcType->getOperand(1)->replaceUsesWith(paramReplacment);
builder.addForceInlineDecoration(funcTypeInst);
diff --git a/source/slang/slang-ir-lower-buffer-element-type.cpp b/source/slang/slang-ir-lower-buffer-element-type.cpp
index 128502bd8..83218bade 100644
--- a/source/slang/slang-ir-lower-buffer-element-type.cpp
+++ b/source/slang/slang-ir-lower-buffer-element-type.cpp
@@ -382,7 +382,7 @@ struct LoweredElementTypeContext
IRBuilder builder(structType);
builder.setInsertAfter(structType);
auto func = builder.createFunc();
- auto refStructType = builder.getRefType(structType, AddressSpace::Generic);
+ auto refStructType = builder.getRefParamType(structType, AddressSpace::Generic);
auto funcType = builder.getFuncType(1, (IRType**)&refStructType, matrixType);
func->setFullType(funcType);
builder.addNameHintDecoration(func, UnownedStringSlice("unpackStorage"));
@@ -435,7 +435,7 @@ struct LoweredElementTypeContext
IRBuilder builder(structType);
builder.setInsertAfter(structType);
auto func = builder.createFunc();
- auto outStructType = builder.getRefType(structType, AddressSpace::Generic);
+ auto outStructType = builder.getRefParamType(structType, AddressSpace::Generic);
IRType* paramTypes[] = {outStructType, matrixType};
auto funcType = builder.getFuncType(2, paramTypes, builder.getVoidType());
func->setFullType(funcType);
@@ -521,7 +521,7 @@ struct LoweredElementTypeContext
IRBuilder builder(structType);
builder.setInsertAfter(structType);
auto func = builder.createFunc();
- auto refStructType = builder.getRefType(structType, AddressSpace::Generic);
+ auto refStructType = builder.getRefParamType(structType, AddressSpace::Generic);
auto funcType = builder.getFuncType(1, (IRType**)&refStructType, arrayType);
func->setFullType(funcType);
builder.addNameHintDecoration(func, UnownedStringSlice("unpackStorage"));
@@ -585,7 +585,7 @@ struct LoweredElementTypeContext
IRBuilder builder(structType);
builder.setInsertAfter(structType);
auto func = builder.createFunc();
- auto outLoweredType = builder.getRefType(structType, AddressSpace::Generic);
+ auto outLoweredType = builder.getRefParamType(structType, AddressSpace::Generic);
IRType* paramTypes[] = {outLoweredType, structType};
auto funcType = builder.getFuncType(2, paramTypes, builder.getVoidType());
func->setFullType(funcType);
@@ -939,7 +939,7 @@ struct LoweredElementTypeContext
info.convertLoweredToOriginal.func,
UnownedStringSlice("unpackStorage"));
builder.addForceInlineDecoration(info.convertLoweredToOriginal.func);
- auto refLoweredType = builder.getRefType(loweredType, AddressSpace::Generic);
+ auto refLoweredType = builder.getRefParamType(loweredType, AddressSpace::Generic);
info.convertLoweredToOriginal.func->setFullType(
builder.getFuncType(1, (IRType**)&refLoweredType, type));
builder.emitBlock();
@@ -976,7 +976,7 @@ struct LoweredElementTypeContext
UnownedStringSlice("packStorage"));
builder.addForceInlineDecoration(info.convertOriginalToLowered.func);
- auto outLoweredType = builder.getRefType(loweredType, AddressSpace::Generic);
+ auto outLoweredType = builder.getRefParamType(loweredType, AddressSpace::Generic);
IRType* paramTypes[] = {outLoweredType, type};
info.convertOriginalToLowered.func->setFullType(
builder.getFuncType(2, paramTypes, builder.getVoidType()));
diff --git a/source/slang/slang-ir-lower-out-parameters.cpp b/source/slang/slang-ir-lower-out-parameters.cpp
index 2eec66db5..40e7a8da5 100644
--- a/source/slang/slang-ir-lower-out-parameters.cpp
+++ b/source/slang/slang-ir-lower-out-parameters.cpp
@@ -125,12 +125,12 @@ List<ParamInfo> collectParameterInfo(
info.outVar = nullptr;
info.outFieldKey = nullptr;
- if (auto outType = as<IROutTypeBase>(param->getDataType()))
+ if (auto outType = as<IROutParamTypeBase>(param->getDataType()))
{
// Handle out/inout parameter
info.valueType = outType->getValueType();
info.isOut = true;
- info.isInOut = (outType->getOp() == kIROp_InOutType);
+ info.isInOut = (outType->getOp() == kIROp_BorrowInOutParamType);
// Create field key for out parameter
String fieldName = "param";
diff --git a/source/slang/slang-ir-marshal-native-call.cpp b/source/slang/slang-ir-marshal-native-call.cpp
index f19bf2168..8dd1da18f 100644
--- a/source/slang/slang-ir-marshal-native-call.cpp
+++ b/source/slang/slang-ir-marshal-native-call.cpp
@@ -28,10 +28,10 @@ IRType* NativeCallMarshallingContext::getNativeType(IRBuilder& builder, IRType*
nativeElementType,
arrayType->getElementCount());
}
- case kIROp_InOutType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
- case kIROp_OutType:
+ case kIROp_BorrowInOutParamType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
+ case kIROp_OutParamType:
return builder.getPtrType(getNativeType(builder, (IRType*)type->getOperand(0)));
default:
return type;
@@ -97,10 +97,10 @@ void NativeCallMarshallingContext::marshalManagedValueToNativeValue(
{
switch (originalParamType->getOp())
{
- case kIROp_InOutType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
- case kIROp_OutType:
+ case kIROp_BorrowInOutParamType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
+ case kIROp_OutParamType:
return marshalRefManagedValueToNativeValue(builder, originalArg, args);
case kIROp_StringType:
{
@@ -161,9 +161,9 @@ void NativeCallMarshallingContext::marshalManagedValueToNativeResultValue(
{
switch (originalArg->getDataType()->getOp())
{
- case kIROp_InOutType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
+ case kIROp_BorrowInOutParamType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
SLANG_UNREACHABLE("out and ref types should be handled before reaching here.");
break;
case kIROp_StringType:
diff --git a/source/slang/slang-ir-redundancy-removal.cpp b/source/slang/slang-ir-redundancy-removal.cpp
index 4c10cf246..3b1a731f9 100644
--- a/source/slang/slang-ir-redundancy-removal.cpp
+++ b/source/slang/slang-ir-redundancy-removal.cpp
@@ -133,7 +133,7 @@ bool isAddressMutable(IRInst* inst)
{
case kIROp_ParameterBlockType:
case kIROp_ConstantBufferType:
- case kIROp_ConstRefType:
+ case kIROp_BorrowInParamType:
return false; // immutable
// We should consider StructuredBuffer as mutable by default, since the resources may alias.
@@ -279,7 +279,7 @@ static bool eliminateRedundantTemporaryCopyInFunc(IRFunc* func)
if (nullptr == param)
goto unsafeToOptimize; // IRFunc might be incomplete yet
- if (auto paramPtrType = as<IRConstRefType>(param->getFullType()))
+ if (auto paramPtrType = as<IRBorrowInParamType>(param->getFullType()))
{
if (paramPtrType->getAddressSpace() != loadAddressSpace)
goto unsafeToOptimize; // incompatible address space
@@ -568,7 +568,7 @@ bool isExternallyModifiableAddr(IRInst* rootVar)
if (!rootVar)
return false;
- auto ptr = as<IRConstRefType>(rootVar->getDataType());
+ auto ptr = as<IRBorrowInParamType>(rootVar->getDataType());
if (!ptr)
return true;
diff --git a/source/slang/slang-ir-resolve-texture-format.cpp b/source/slang/slang-ir-resolve-texture-format.cpp
index 09989e892..df30f1dc6 100644
--- a/source/slang/slang-ir-resolve-texture-format.cpp
+++ b/source/slang/slang-ir-resolve-texture-format.cpp
@@ -12,10 +12,10 @@ static IRType* replaceImageElementType(IRInst* originalType, IRInst* newElementT
case kIROp_ArrayType:
case kIROp_UnsizedArrayType:
case kIROp_PtrType:
- case kIROp_OutType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
- case kIROp_InOutType:
+ case kIROp_OutParamType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
+ case kIROp_BorrowInOutParamType:
{
auto newInnerType =
replaceImageElementType(originalType->getOperand(0), newElementType);
diff --git a/source/slang/slang-ir-specialize-arrays.cpp b/source/slang/slang-ir-specialize-arrays.cpp
index edb6cfa28..c2bc4d14e 100644
--- a/source/slang/slang-ir-specialize-arrays.cpp
+++ b/source/slang/slang-ir-specialize-arrays.cpp
@@ -26,19 +26,19 @@ struct ArrayParameterSpecializationCondition : FunctionCallSpecializeCondition
{
auto paramType = param->getDataType();
auto argType = arg->getDataType();
- if (auto outTypeBase = as<IROutTypeBase>(paramType))
+ if (auto outTypeBase = as<IROutParamTypeBase>(paramType))
{
paramType = outTypeBase->getValueType();
SLANG_ASSERT(as<IRPtrTypeBase>(argType));
argType = as<IRPtrTypeBase>(argType)->getValueType();
}
- else if (auto refType = as<IRRefType>(paramType))
+ else if (auto refType = as<IRRefParamType>(paramType))
{
paramType = refType->getValueType();
SLANG_ASSERT(as<IRPtrTypeBase>(argType));
argType = as<IRPtrTypeBase>(argType)->getValueType();
}
- else if (auto constRefType = as<IRConstRefType>(paramType))
+ else if (auto constRefType = as<IRBorrowInParamType>(paramType))
{
paramType = constRefType->getValueType();
SLANG_ASSERT(as<IRPtrTypeBase>(argType));
diff --git a/source/slang/slang-ir-specialize-function-call.cpp b/source/slang/slang-ir-specialize-function-call.cpp
index aead69258..8b16cd101 100644
--- a/source/slang/slang-ir-specialize-function-call.cpp
+++ b/source/slang/slang-ir-specialize-function-call.cpp
@@ -714,10 +714,10 @@ struct FunctionParameterSpecializationContext
IRType* resultType = argType;
switch (paramType->getOp())
{
- case kIROp_InOutType:
- case kIROp_OutType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
+ case kIROp_BorrowInOutParamType:
+ case kIROp_OutParamType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
{
auto ptrParamType = as<IRPtrTypeBase>(paramType);
argType = as<IRPtrTypeBase>(argType)->getValueType();
diff --git a/source/slang/slang-ir-specialize-resources.cpp b/source/slang/slang-ir-specialize-resources.cpp
index 0ac08236f..e8a13b2e7 100644
--- a/source/slang/slang-ir-specialize-resources.cpp
+++ b/source/slang/slang-ir-specialize-resources.cpp
@@ -349,7 +349,7 @@ struct ResourceOutputSpecializationPass
for (auto param : func->getParams())
{
auto paramType = param->getDataType();
- auto outType = as<IROutTypeBase>(paramType);
+ auto outType = as<IROutParamTypeBase>(paramType);
if (!outType)
continue;
auto valueType = outType->getValueType();
@@ -803,11 +803,11 @@ struct ResourceOutputSpecializationPass
FuncInfo& ioFuncInfo)
{
// We only want to specialize in the case where the parameter
- // is an `out` or `inout` (both inherit from `IROutTypeBase`),
+ // is an `out` or `inout` (both inherit from `IROutParamTypeBase`),
// and the pointed-to type is a resource.
//
auto paramType = param->getDataType();
- auto outType = as<IROutTypeBase>(paramType);
+ auto outType = as<IROutParamTypeBase>(paramType);
if (!outType)
return SpecializeFuncResult::Ok;
auto valueType = outType->getValueType();
@@ -835,7 +835,7 @@ struct ResourceOutputSpecializationPass
//
IRVar* newVar = bodyBuilder.emitVar(valueType);
- if (as<IRInOutType>(outType))
+ if (as<IRBorrowInOutParamType>(outType))
{
// If the parameter is an `inout` rather than just
// an `out`, then we still need a parameter to
diff --git a/source/slang/slang-ir-spirv-legalize.cpp b/source/slang/slang-ir-spirv-legalize.cpp
index f795a6559..6bdd02d73 100644
--- a/source/slang/slang-ir-spirv-legalize.cpp
+++ b/source/slang/slang-ir-spirv-legalize.cpp
@@ -316,7 +316,7 @@ struct SPIRVLegalizationContext : public SourceEmitterBase
{
// Skip load's for referenced `Input` variables since a ref implies
// passing as is, which needs to be a pointer (pass as is).
- if (user->getDataType() && user->getDataType()->getOp() == kIROp_RefType &&
+ if (user->getDataType() && user->getDataType()->getOp() == kIROp_RefParamType &&
(addressSpace == AddressSpace::Input ||
addressSpace == AddressSpace::BuiltinInput))
{
@@ -943,7 +943,7 @@ struct SPIRVLegalizationContext : public SourceEmitterBase
if (funcType)
{
if (funcType->getParamCount() > i &&
- as<IRRefType>(funcType->getParamType(i)))
+ as<IRRefParamType>(funcType->getParamType(i)))
{
// If we are passing an address from a structured buffer as a
// ref argument, pass the original pointer as is.
@@ -968,7 +968,7 @@ struct SPIRVLegalizationContext : public SourceEmitterBase
//
// If callee doesn't modify the memory location, no need to write back.
if (funcType && funcType->getParamCount() > i &&
- as<IRConstRefType>(funcType->getParamType(i)))
+ as<IRBorrowInParamType>(funcType->getParamType(i)))
continue;
// If the buffer location is immutable, don't write back.
if (isPointerToImmutableLocation(root))
diff --git a/source/slang/slang-ir-transform-params-to-constref.cpp b/source/slang/slang-ir-transform-params-to-constref.cpp
index d34b3d25b..b08c9b17f 100644
--- a/source/slang/slang-ir-transform-params-to-constref.cpp
+++ b/source/slang/slang-ir-transform-params-to-constref.cpp
@@ -143,7 +143,7 @@ struct TransformParamsToConstRefContext
switch (root->getDataType()->getOp())
{
case kIROp_ConstantBufferType:
- case kIROp_ConstRefType:
+ case kIROp_BorrowInParamType:
case kIROp_ParameterBlockType:
return addr;
default:
@@ -270,17 +270,17 @@ struct TransformParamsToConstRefContext
{
if (shouldTransformParam(param))
{
- // Our goal here is to transform `in T` parameters to const-ref.
+ // Our goal here is to transform `in T` parameters to `borrow in T`.
// We are selective about what we will transform for a few reasons:
// 1. no reason to transform simple primitives like `int`.
// 2. not every type makes sense as constref. For example, `ParameterBlock`.
- // 3. constref is not 100% stable, so we need to be selective on what we let
- // transform into constref.
+ // 3. `borrow in` is not 100% stable, so we need to be selective on what we let
+ // transform into `borrow in`.
//
// This allows us to pass the address of variables directly into a function,
// giving us the choice to remove copies into a parameter.
auto paramType = param->getDataType();
- auto constRefType = builder.getConstRefType(paramType, AddressSpace::Generic);
+ auto constRefType = builder.getBorrowInParamType(paramType, AddressSpace::Generic);
param->setFullType(constRefType);
changed = true;
diff --git a/source/slang/slang-ir-translate-global-varying-var.cpp b/source/slang/slang-ir-translate-global-varying-var.cpp
index 6b8c4842b..1a0f3dd9e 100644
--- a/source/slang/slang-ir-translate-global-varying-var.cpp
+++ b/source/slang/slang-ir-translate-global-varying-var.cpp
@@ -214,7 +214,7 @@ struct GlobalVarTranslationContext
// Emit a new param here to represent the global input var.
auto inputParam =
- builder.emitParam(builder.getConstRefType(inputType, AddressSpace::Input));
+ builder.emitParam(builder.getBorrowInParamType(inputType, AddressSpace::Input));
// Copy the global input vars original decorations onto the new param.
// We need to do this to ensure that we can do things like get system
diff --git a/source/slang/slang-ir-use-uninitialized-values.cpp b/source/slang/slang-ir-use-uninitialized-values.cpp
index daa667a0a..200f29d1b 100644
--- a/source/slang/slang-ir-use-uninitialized-values.cpp
+++ b/source/slang/slang-ir-use-uninitialized-values.cpp
@@ -54,7 +54,7 @@ enum ParameterCheckType
static ParameterCheckType isPotentiallyUnintended(IRParam* param, Stage stage, int index)
{
IRType* type = param->getFullType();
- if (auto out = as<IROutType>(param->getFullType()))
+ if (auto out = as<IROutParamType>(param->getFullType()))
{
// Don't check `out Vertices<T>` or `out Indices<T>` parameters
// in mesh shaders.
@@ -75,7 +75,7 @@ static ParameterCheckType isPotentiallyUnintended(IRParam* param, Stage stage, i
return AsOut;
}
- else if (auto inout = as<IRInOutType>(type))
+ else if (auto inout = as<IRBorrowInOutParamType>(type))
{
// TODO: some way to check if the method
// is actually used for autodiff
@@ -263,7 +263,10 @@ static InstructionUsageType getCallUsageType(IRCall* call, IRInst* inst)
// Consider it as a store if its passed
// as an out/inout/ref parameter
auto type = unwrapAttributedType(ftype->getParamType(index));
- return (as<IROutType>(type) || as<IRInOutType>(type) || as<IRRefType>(type)) ? Store : Load;
+ return (as<IROutParamType>(type) || as<IRBorrowInOutParamType>(type) ||
+ as<IRRefParamType>(type))
+ ? Store
+ : Load;
}
static InstructionUsageType getInstructionUsageType(IRInst* user, IRInst* inst)
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp
index 12e37f42a..9bec464dc 100644
--- a/source/slang/slang-ir-util.cpp
+++ b/source/slang/slang-ir-util.cpp
@@ -312,8 +312,8 @@ bool isWrapperType(IRInst* inst)
case kIROp_VectorType:
case kIROp_MatrixType:
case kIROp_PtrType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
case kIROp_HLSLStructuredBufferType:
case kIROp_HLSLRWStructuredBufferType:
case kIROp_HLSLRasterizerOrderedStructuredBufferType:
@@ -1021,11 +1021,11 @@ bool isPtrLikeOrHandleType(IRInst* type)
case kIROp_ComPtrType:
case kIROp_RawPointerType:
case kIROp_RTTIPointerType:
- case kIROp_OutType:
- case kIROp_InOutType:
+ case kIROp_OutParamType:
+ case kIROp_BorrowInOutParamType:
case kIROp_PtrType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
case kIROp_GLSLShaderStorageBufferType:
return true;
}
@@ -1358,7 +1358,7 @@ bool areCallArgumentsSideEffectFree(IRCall* call, SideEffectAnalysisOptions opti
if (!funcType)
return false;
if (funcType->getParamCount() > i &&
- as<IROutType>(funcType->getParamType(i)))
+ as<IROutParamType>(funcType->getParamType(i)))
continue;
// We are an argument to an inout parameter.
@@ -1762,7 +1762,7 @@ IRPtrTypeBase* isMutablePointerType(IRInst* inst)
{
switch (inst->getOp())
{
- case kIROp_ConstRefType:
+ case kIROp_BorrowInParamType:
return nullptr;
default:
return asRelevantPtrType(inst);
diff --git a/source/slang/slang-ir-validate.cpp b/source/slang/slang-ir-validate.cpp
index e7bb7b548..b14a76784 100644
--- a/source/slang/slang-ir-validate.cpp
+++ b/source/slang/slang-ir-validate.cpp
@@ -488,7 +488,7 @@ static bool isValidAtomicDest(bool skipFuncParamValidation, IRInst* dst)
if (auto param = as<IRParam>(dst))
{
auto paramType = param->getDataType();
- if (auto outType = as<IROutTypeBase>(paramType))
+ if (auto outType = as<IROutParamTypeBase>(paramType))
{
if (outType->getAddressSpace() == AddressSpace::GroupShared)
{
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index e54238a9c..9ec8a2c8b 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -2937,25 +2937,26 @@ IRPtrType* IRBuilder::getPtrType(IRType* valueType)
return (IRPtrType*)getPtrType(kIROp_PtrType, valueType);
}
-IROutType* IRBuilder::getOutType(IRType* valueType)
+IROutParamType* IRBuilder::getOutParamType(IRType* valueType)
{
- return (IROutType*)getPtrType(kIROp_OutType, valueType);
+ return (IROutParamType*)getPtrType(kIROp_OutParamType, valueType);
}
-IRInOutType* IRBuilder::getInOutType(IRType* valueType)
+IRBorrowInOutParamType* IRBuilder::getBorrowInOutParamType(IRType* valueType)
{
- return (IRInOutType*)getPtrType(kIROp_InOutType, valueType);
+ return (IRBorrowInOutParamType*)getPtrType(kIROp_BorrowInOutParamType, valueType);
}
-IRRefType* IRBuilder::getRefType(IRType* valueType, AddressSpace addrSpace)
+IRRefParamType* IRBuilder::getRefParamType(IRType* valueType, AddressSpace addrSpace)
{
- return (IRRefType*)getPtrType(kIROp_RefType, valueType, AccessQualifier::ReadWrite, addrSpace);
+ return (IRRefParamType*)
+ getPtrType(kIROp_RefParamType, valueType, AccessQualifier::ReadWrite, addrSpace);
}
-IRConstRefType* IRBuilder::getConstRefType(IRType* valueType, AddressSpace addrSpace)
+IRBorrowInParamType* IRBuilder::getBorrowInParamType(IRType* valueType, AddressSpace addrSpace)
{
- return (
- IRConstRefType*)getPtrType(kIROp_ConstRefType, valueType, AccessQualifier::Read, addrSpace);
+ return (IRBorrowInParamType*)
+ getPtrType(kIROp_BorrowInParamType, valueType, AccessQualifier::Read, addrSpace);
}
IRSPIRVLiteralType* IRBuilder::getSPIRVLiteralType(IRType* type)
@@ -4025,11 +4026,11 @@ IRInst* IRBuilder::emitDefaultConstruct(IRType* type, bool fallback)
case kIROp_StringType:
return getStringValue(UnownedStringSlice());
case kIROp_PtrType:
- case kIROp_InOutType:
- case kIROp_OutType:
+ case kIROp_BorrowInOutParamType:
+ case kIROp_OutParamType:
case kIROp_RawPointerType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
case kIROp_ComPtrType:
case kIROp_NativePtrType:
case kIROp_NativeStringType:
@@ -4182,11 +4183,11 @@ static TypeCastStyle _getTypeStyleId(IRType* type)
case kIROp_BoolType:
return TypeCastStyle::Bool;
case kIROp_PtrType:
- case kIROp_InOutType:
- case kIROp_OutType:
+ case kIROp_BorrowInOutParamType:
+ case kIROp_OutParamType:
case kIROp_RawPointerType:
- case kIROp_RefType:
- case kIROp_ConstRefType:
+ case kIROp_RefParamType:
+ case kIROp_BorrowInParamType:
return TypeCastStyle::Ptr;
case kIROp_EnumType:
return TypeCastStyle::Enum;
diff --git a/source/slang/slang-language-server-inlay-hints.cpp b/source/slang/slang-language-server-inlay-hints.cpp
index 982b9f910..89c6bd0bc 100644
--- a/source/slang/slang-language-server-inlay-hints.cpp
+++ b/source/slang/slang-language-server-inlay-hints.cpp
@@ -76,7 +76,7 @@ List<LanguageServerProtocol::InlayHint> getInlayHints(
lblSb << "inout ";
else if (param->hasModifier<RefModifier>())
lblSb << "ref ";
- else if (param->hasModifier<ConstRefModifier>())
+ else if (param->hasModifier<BorrowModifier>())
lblSb << "constref ";
lblSb << name->text;
lblSb << ":";
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index 5d83a351f..12545ad0d 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -387,7 +387,7 @@ struct ImplicitCastLValueInfo : ExtendedValueInfo
LoweredValInfo base;
// The type of the lvalue (inout, out, ref, etc.)
- ParameterDirection lValueType;
+ ParamPassingMode lValueType;
};
LoweredValInfo LoweredValInfo::boundMember(BoundMemberInfo* boundMemberInfo)
@@ -2524,8 +2524,9 @@ void addVarDecorations(IRGenContext* context, IRInst* inst, Decl* decl)
}
// TODO: what are other modifiers we need to propagate through?
}
- if (auto t =
- composeGetters<IRMeshOutputType>(inst->getFullType(), &IROutTypeBase::getValueType))
+ if (auto t = composeGetters<IRMeshOutputType>(
+ inst->getFullType(),
+ &IROutParamTypeBase::getValueType))
{
IROp op;
switch (t->getOp())
@@ -2774,17 +2775,17 @@ static void applyOutArgumentFixups(IRGenContext* context, List<OutArgumentFixup>
/// Add one argument value to the argument list for a call being constructed
void addArg(
IRGenContext* context,
- List<IRInst*>* ioArgs, //< The argument list being built
- List<OutArgumentFixup>* ioFixups, //< "Fixup" logic to apply for `out` or `inout` arguments
- LoweredValInfo argVal, //< The lowered value of the argument to add
- IRType* paramType, //< The type of the corresponding parameter
- ParameterDirection paramDirection, //< The direction of the parameter (`in`, `out`, etc.)
- Type* argType, //< The AST-level type of the argument
- SourceLoc loc) //< A location to use if we need to report an error
+ List<IRInst*>* ioArgs, //< The argument list being built
+ List<OutArgumentFixup>* ioFixups, //< "Fixup" logic to apply for `out` or `inout` arguments
+ LoweredValInfo argVal, //< The lowered value of the argument to add
+ IRType* paramType, //< The type of the corresponding parameter
+ ParamPassingMode paramDirection, //< The direction of the parameter (`in`, `out`, etc.)
+ Type* argType, //< The AST-level type of the argument
+ SourceLoc loc) //< A location to use if we need to report an error
{
switch (paramDirection)
{
- case kParameterDirection_Ref:
+ case ParamPassingMode::Ref:
{
// According to our "calling convention" we need to
// pass a pointer into the callee. Unlike the case for
@@ -2808,9 +2809,9 @@ void addArg(
}
break;
- case kParameterDirection_Out:
- case kParameterDirection_InOut:
- case kParameterDirection_ConstRef:
+ case ParamPassingMode::Out:
+ case ParamPassingMode::BorrowInOut:
+ case ParamPassingMode::BorrowIn:
{
// According to our "calling convention" we need to
// pass a pointer into the callee.
@@ -2838,7 +2839,7 @@ void addArg(
paramType = lowerType(context, argType);
}
#if 0
- if (auto refType = as<IRConstRefType>(paramType))
+ if (auto refType = as<IRBorrowInParamType>(paramType))
{
paramType = refType->getValueType();
argVal = LoweredValInfo::simple(
@@ -2853,8 +2854,8 @@ void addArg(
// in the argument, which we accomplish by assigning
// from the l-value to our temp.
//
- if (paramDirection == kParameterDirection_InOut ||
- paramDirection == kParameterDirection_ConstRef)
+ if (paramDirection == ParamPassingMode::BorrowInOut ||
+ paramDirection == ParamPassingMode::BorrowIn)
{
assign(context, tempVar, argVal);
}
@@ -2868,7 +2869,7 @@ void addArg(
// Finally, after the call we will need
// to copy in the other direction: from our
// temp back to the original l-value.
- if (paramDirection != kParameterDirection_ConstRef)
+ if (paramDirection != ParamPassingMode::BorrowIn)
{
OutArgumentFixup fixup;
fixup.src = tempVar;
@@ -2900,17 +2901,17 @@ void addArg(
void addCallArgsForParam(
IRGenContext* context,
IRType* paramType,
- ParameterDirection paramDirection,
+ ParamPassingMode paramDirection,
Expr* argExpr,
List<IRInst*>* ioArgs,
List<OutArgumentFixup>* ioFixups)
{
switch (paramDirection)
{
- case kParameterDirection_Ref:
- case kParameterDirection_ConstRef:
- case kParameterDirection_Out:
- case kParameterDirection_InOut:
+ case ParamPassingMode::Ref:
+ case ParamPassingMode::BorrowIn:
+ case ParamPassingMode::Out:
+ case ParamPassingMode::BorrowInOut:
{
LoweredValInfo loweredArg = lowerLValueExpr(context, argExpr);
addArg(
@@ -2938,38 +2939,38 @@ void addCallArgsForParam(
//
/// Compute the direction for a parameter based on its declaration
-ParameterDirection getParameterDirection(VarDeclBase* paramDecl)
+ParamPassingMode getParameterDirection(VarDeclBase* paramDecl)
{
if (paramDecl->hasModifier<RefModifier>())
{
- return kParameterDirection_Ref;
+ return ParamPassingMode::Ref;
}
- if (paramDecl->hasModifier<ConstRefModifier>() || paramDecl->hasModifier<HLSLPayloadModifier>())
+ if (paramDecl->hasModifier<BorrowModifier>() || paramDecl->hasModifier<HLSLPayloadModifier>())
{
// The payload types are a groupshared variable, and we really don't
// want to copy that into registers in every invocation on platforms
// where this matters, so treat them as by-reference here.
- return kParameterDirection_ConstRef;
+ return ParamPassingMode::BorrowIn;
}
if (paramDecl->hasModifier<InOutModifier>())
{
// The AST specified `inout`:
- return kParameterDirection_InOut;
+ return ParamPassingMode::BorrowInOut;
}
if (paramDecl->hasModifier<OutModifier>())
{
// We saw an `out` modifier, so now we need
// to check if there was a paired `in`.
if (paramDecl->hasModifier<InModifier>())
- return kParameterDirection_InOut;
+ return ParamPassingMode::BorrowInOut;
else
- return kParameterDirection_Out;
+ return ParamPassingMode::Out;
}
else
{
// No direction modifier, or just `in`:
- return kParameterDirection_In;
+ return ParamPassingMode::In;
}
}
@@ -2978,22 +2979,22 @@ ParameterDirection getParameterDirection(VarDeclBase* paramDecl)
/// If the given declaration doesn't care about the direction of a `this` parameter, then
/// it will return the provided `defaultDirection` instead.
///
-ParameterDirection getThisParamDirection(Decl* parentDecl, ParameterDirection defaultDirection)
+ParamPassingMode getThisParamDirection(Decl* parentDecl, ParamPassingMode defaultDirection)
{
auto parentParent = getParentAggTypeDecl(parentDecl);
// The `this` parameter for a `class` is always `in`.
if (as<ClassDecl>(parentParent))
{
- return kParameterDirection_In;
+ return ParamPassingMode::In;
}
if (parentParent && parentParent->findModifier<NonCopyableTypeAttribute>())
{
if (parentDecl->hasModifier<MutatingAttribute>())
- return kParameterDirection_Ref;
+ return ParamPassingMode::Ref;
else
- return kParameterDirection_ConstRef;
+ return ParamPassingMode::BorrowIn;
}
// Applications can opt in to a mutable `this` parameter,
@@ -3002,15 +3003,15 @@ ParameterDirection getThisParamDirection(Decl* parentDecl, ParameterDirection de
//
if (parentDecl->hasModifier<MutatingAttribute>())
{
- return kParameterDirection_InOut;
+ return ParamPassingMode::BorrowInOut;
}
else if (parentDecl->hasModifier<ConstRefAttribute>())
{
- return kParameterDirection_ConstRef;
+ return ParamPassingMode::BorrowIn;
}
else if (parentDecl->hasModifier<RefAttribute>())
{
- return kParameterDirection_Ref;
+ return ParamPassingMode::Ref;
}
// A `set` accessor on a property or subscript declaration
@@ -3019,11 +3020,11 @@ ParameterDirection getThisParamDirection(Decl* parentDecl, ParameterDirection de
//
if (parentDecl->hasModifier<NonmutatingAttribute>())
{
- return kParameterDirection_In;
+ return ParamPassingMode::In;
}
else if (as<SetterDecl>(parentDecl))
{
- return kParameterDirection_InOut;
+ return ParamPassingMode::BorrowInOut;
}
// Declarations that represent abstract storage (a property
@@ -3050,7 +3051,7 @@ ParameterDirection getThisParamDirection(Decl* parentDecl, ParameterDirection de
// For now we make any `this` parameter default to `in`.
//
- return kParameterDirection_In;
+ return ParamPassingMode::In;
}
DeclRef<Decl> createDefaultSpecializedDeclRefImpl(
@@ -3203,10 +3204,10 @@ struct IRLoweringParameterInfo
Type* type = nullptr;
// The direction (`in` vs `out` vs `in out`)
- ParameterDirection direction;
+ ParamPassingMode direction;
// The direction declared in user code.
- ParameterDirection declaredDirection = ParameterDirection::kParameterDirection_In;
+ ParamPassingMode declaredDirection = ParamPassingMode::In;
// The variable/parameter declaration for
// this parameter (if any)
@@ -3272,7 +3273,7 @@ ParameterListCollectMode getModeForCollectingParentParameters(Decl* decl, Contai
// When dealing with a member function, we need to be able to add the `this`
// parameter for the enclosing type:
//
-void addThisParameter(ParameterDirection direction, Type* type, ParameterLists* ioParameterLists)
+void addThisParameter(ParamPassingMode direction, Type* type, ParameterLists* ioParameterLists)
{
IRLoweringParameterInfo info;
info.type = type;
@@ -3291,7 +3292,7 @@ void maybeAddReturnDestinationParam(ParameterLists* ioParameterLists, Type* resu
IRLoweringParameterInfo info;
info.type = resultType;
info.decl = nullptr;
- info.direction = kParameterDirection_Ref;
+ info.direction = ParamPassingMode::Ref;
info.declaredDirection = info.direction;
info.isReturnDestination = true;
ioParameterLists->params.add(info);
@@ -3300,13 +3301,13 @@ void maybeAddReturnDestinationParam(ParameterLists* ioParameterLists, Type* resu
void makeVaryingInputParamConstRef(IRLoweringParameterInfo& paramInfo)
{
- if (paramInfo.direction != kParameterDirection_In)
+ if (paramInfo.direction != ParamPassingMode::In)
return;
if (paramInfo.decl->findModifier<HLSLUniformModifier>())
return;
if (as<HLSLPatchType>(paramInfo.type))
return;
- paramInfo.direction = kParameterDirection_ConstRef;
+ paramInfo.direction = ParamPassingMode::BorrowIn;
}
//
// And here is our function that will do the recursive walk:
@@ -3315,7 +3316,7 @@ void collectParameterLists(
DeclRef<Decl> const& declRef,
ParameterLists* ioParameterLists,
ParameterListCollectMode mode,
- ParameterDirection thisParamDirection)
+ ParamPassingMode thisParamDirection)
{
// Don't collect any parameters beyond certain decls.
if (as<InterfaceDefaultImplDecl>(declRef) || as<AggTypeDeclBase>(declRef))
@@ -3337,7 +3338,7 @@ void collectParameterLists(
if (innerMode < mode)
innerMode = mode;
- ParameterDirection innerThisParamDirection =
+ ParamPassingMode innerThisParamDirection =
getThisParamDirection(declRef.getDecl(), thisParamDirection);
@@ -3368,7 +3369,7 @@ void collectParameterLists(
else if (auto bwdDerivDeclRef = declRef.as<BackwardDerivativeRequirementDecl>())
{
thisType = bwdDerivDeclRef.getDecl()->diffThisType;
- innerThisParamDirection = kParameterDirection_InOut;
+ innerThisParamDirection = ParamPassingMode::BorrowInOut;
}
addThisParameter(innerThisParamDirection, thisType, ioParameterLists);
@@ -3383,10 +3384,10 @@ void collectParameterLists(
{
// We need a special case here when lowering the varying parameters of an entrypoint
// function. Due to the existence of `EvaluateAttributeAtSample` and friends, we need to
- // always lower the varying inputs as `__constref` parameters so we can pass pointers to
+ // always lower the varying inputs as `borrow in` parameters so we can pass pointers to
// these intrinsics.
// This means that although these parameters are declared as "in" parameters in the source,
- // we will actually treat them as __constref parameters when lowering to IR. A complication
+ // we will actually treat them as `borrow in` parameters when lowering to IR. A complication
// result from this is that if the original source code actually modifies the input
// parameter we still need to create a local var to hold the modified value. In the future
// when we are able to update our language spec to always assume input parameters are
@@ -3467,7 +3468,7 @@ void _lowerFuncDeclBaseTypeInfo(
declRef,
&parameterLists,
kParameterListCollectMode_Default,
- kParameterDirection_In);
+ ParamPassingMode::In);
auto& paramTypes = outInfo.paramTypes;
@@ -3477,7 +3478,7 @@ void _lowerFuncDeclBaseTypeInfo(
switch (paramInfo.direction)
{
- case kParameterDirection_In:
+ case ParamPassingMode::In:
// Simple case of a by-value input parameter.
break;
@@ -3485,17 +3486,17 @@ void _lowerFuncDeclBaseTypeInfo(
// then we will represent it with a pointer type in
// the IR, but we will use a specialized pointer
// type that encodes the parameter direction information.
- case kParameterDirection_Out:
- irParamType = builder->getOutType(irParamType);
+ case ParamPassingMode::Out:
+ irParamType = builder->getOutParamType(irParamType);
break;
- case kParameterDirection_InOut:
- irParamType = builder->getInOutType(irParamType);
+ case ParamPassingMode::BorrowInOut:
+ irParamType = builder->getBorrowInOutParamType(irParamType);
break;
- case kParameterDirection_Ref:
- irParamType = builder->getRefType(irParamType, AddressSpace::Generic);
+ case ParamPassingMode::Ref:
+ irParamType = builder->getRefParamType(irParamType, AddressSpace::Generic);
break;
- case kParameterDirection_ConstRef:
- irParamType = builder->getConstRefType(irParamType, AddressSpace::Generic);
+ case ParamPassingMode::BorrowIn:
+ irParamType = builder->getBorrowInParamType(irParamType, AddressSpace::Generic);
break;
default:
SLANG_UNEXPECTED("unknown parameter direction");
@@ -3753,7 +3754,7 @@ struct ExprLoweringContext
InvokeExpr* expr,
Index argIndex,
IRType* paramType,
- ParameterDirection paramDirection,
+ ParamPassingMode paramDirection,
DeclRef<ParamDecl> paramDeclRef,
List<IRInst*>* ioArgs,
List<OutArgumentFixup>* ioFixups)
@@ -4073,7 +4074,7 @@ struct ExprLoweringContext
addCallArgsForParam(
context,
irThisType,
- getThisParamDirection(funcDeclRef.getDecl(), kParameterDirection_In),
+ getThisParamDirection(funcDeclRef.getDecl(), ParamPassingMode::In),
baseExpr,
&irArgs,
&argFixups);
@@ -5851,9 +5852,9 @@ struct LValueExprLoweringVisitor : ExprLoweringVisitorBase<LValueExprLoweringVis
RefPtr<ImplicitCastLValueInfo> lValueInfo = new ImplicitCastLValueInfo();
lValueInfo->type = irType;
lValueInfo->base = loweredArg;
- lValueInfo->lValueType = kParameterDirection_InOut;
+ lValueInfo->lValueType = ParamPassingMode::BorrowInOut;
if (as<OutImplicitCastExpr>(expr))
- lValueInfo->lValueType = kParameterDirection_Out;
+ lValueInfo->lValueType = ParamPassingMode::Out;
context->shared->extValues.add(lValueInfo);
return LoweredValInfo::implicitCastedLValue(lValueInfo);
}
@@ -7809,7 +7810,7 @@ LoweredValInfo tryGetAddress(
if (baseAddr.flavor == LoweredValInfo::Flavor::Ptr)
{
IRInst* result = nullptr;
- if (info->lValueType == kParameterDirection_InOut)
+ if (info->lValueType == ParamPassingMode::BorrowInOut)
result = context->irBuilder->emitInOutImplicitCast(
context->irBuilder->getPtrType(info->type),
baseAddr.val);
@@ -10940,8 +10941,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
if (paramInfo.isReturnDestination)
subContext->returnDestination = paramVal;
- if (paramInfo.declaredDirection == kParameterDirection_In &&
- paramInfo.direction == kParameterDirection_ConstRef)
+ if (paramInfo.declaredDirection == ParamPassingMode::In &&
+ paramInfo.direction == ParamPassingMode::BorrowIn)
{
// If the parameter is originally declared as "in", but we are
// lowering it as constref for any reason (e.g. it is a varying input),
@@ -10967,7 +10968,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
}
break;
- case kParameterDirection_In:
+ case ParamPassingMode::In:
{
// Simple case of a by-value input parameter.
//
diff --git a/source/slang/slang-mangle.cpp b/source/slang/slang-mangle.cpp
index d96b5591b..ee2f5a347 100644
--- a/source/slang/slang-mangle.cpp
+++ b/source/slang/slang-mangle.cpp
@@ -644,27 +644,27 @@ void emitQualifiedName(ManglingContext* context, DeclRef<Decl> declRef, bool inc
// parameter modifier makes big difference in the spirv code generation, for example
// "out"/"inout" parameter will be passed by pointer. Therefore, we need to
// distinguish them in the mangled name to avoid name collision.
- ParameterDirection paramDirection = getParameterDirection(paramDeclRef.getDecl());
+ ParamPassingMode paramDirection = getParameterDirection(paramDeclRef.getDecl());
switch (paramDirection)
{
- case kParameterDirection_Ref:
+ case ParamPassingMode::Ref:
emitRaw(context, "r_");
break;
- case kParameterDirection_ConstRef:
+ case ParamPassingMode::BorrowIn:
emitRaw(context, "c_");
break;
- case kParameterDirection_Out:
+ case ParamPassingMode::Out:
emitRaw(context, "o_");
break;
- case kParameterDirection_InOut:
+ case ParamPassingMode::BorrowInOut:
emitRaw(context, "io_");
break;
- case kParameterDirection_In:
+ case ParamPassingMode::In:
emitRaw(context, "i_");
break;
default:
StringBuilder errMsg;
- errMsg << "Unknown parameter direction: " << paramDirection;
+ errMsg << "Unknown parameter direction: " << int(paramDirection);
SLANG_ABORT_COMPILATION(errMsg.toString().begin());
break;
}
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index c225ff4ee..dde783ce8 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -9589,7 +9589,7 @@ static const SyntaxParseInfo g_parseSyntaxEntries[] = {
_makeParseModifier("out", getSyntaxClass<OutModifier>()),
_makeParseModifier("inout", getSyntaxClass<InOutModifier>()),
_makeParseModifier("__ref", getSyntaxClass<RefModifier>()),
- _makeParseModifier("__constref", getSyntaxClass<ConstRefModifier>()),
+ _makeParseModifier("__constref", getSyntaxClass<BorrowModifier>()),
_makeParseModifier("const", getSyntaxClass<ConstModifier>()),
_makeParseModifier("__builtin", getSyntaxClass<BuiltinModifier>()),
_makeParseModifier("highp", getSyntaxClass<GLSLPrecisionModifier>()),
diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp
index b991a0caf..2498c1226 100644
--- a/source/slang/slang-syntax.cpp
+++ b/source/slang/slang-syntax.cpp
@@ -934,7 +934,7 @@ FuncType* getFuncType(ASTBuilder* astBuilder, DeclRef<CallableDecl> const& declR
{
paramType = astBuilder->getRefParamType(paramType);
}
- else if (paramDecl->findModifier<ConstRefModifier>())
+ else if (paramDecl->findModifier<BorrowModifier>())
{
paramType = astBuilder->getConstRefParamType(paramType);
}
@@ -942,11 +942,11 @@ FuncType* getFuncType(ASTBuilder* astBuilder, DeclRef<CallableDecl> const& declR
{
if (paramDecl->findModifier<InOutModifier>() || paramDecl->findModifier<InModifier>())
{
- paramType = astBuilder->getInOutType(paramType);
+ paramType = astBuilder->getBorrowInOutParamType(paramType);
}
else
{
- paramType = astBuilder->getOutType(paramType);
+ paramType = astBuilder->getOutParamType(paramType);
}
}
paramTypes.add(paramType);
diff --git a/source/slang/slang-syntax.h b/source/slang/slang-syntax.h
index e7a82592c..640fa8fcd 100644
--- a/source/slang/slang-syntax.h
+++ b/source/slang/slang-syntax.h
@@ -238,7 +238,7 @@ SubstitutionSet makeSubstitutionFromIncompleteSet(
Val::OperandView<Val> findInnerMostGenericArgs(SubstitutionSet subst);
-ParameterDirection getParameterDirection(VarDeclBase* varDecl);
+ParamPassingMode getParameterDirection(VarDeclBase* varDecl);
inline Type* getTagType(ASTBuilder* astBuilder, DeclRef<EnumDecl> declRef)
{
diff --git a/tests/diagnostics/const-ref-differentiable-param.slang b/tests/diagnostics/const-ref-differentiable-param.slang
index c345826e7..354744701 100644
--- a/tests/diagnostics/const-ref-differentiable-param.slang
+++ b/tests/diagnostics/const-ref-differentiable-param.slang
@@ -32,7 +32,7 @@ struct MyType2
float compute1(float x) { return 0; }
}
-// CHECK-DAG: {{.*}}(5): error 38034: cannot use '__constref' on a differentiable parameter.
+// CHECK-DAG: {{.*}}(5): error 38034: cannot use 'borrow in' on a differentiable parameter.
// CHECK-NOT {{.*}}error
// CHECK-DAG: {{.*}}(14): error 38034: cannot use '[constref]' on a differentiable member method of a differentiable type.
// CHECK-NOT {{.*}}error