diff options
Diffstat (limited to 'source/slang/lower-to-ir.cpp')
| -rw-r--r-- | source/slang/lower-to-ir.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp index 0f3e85805..b395d2a95 100644 --- a/source/slang/lower-to-ir.cpp +++ b/source/slang/lower-to-ir.cpp @@ -819,14 +819,6 @@ IRType* getIntType( return context->getSession()->getBuiltinType(BaseType::Int); } -// Get a pointer type to the given element type -RefPtr<PtrType> getPtrType( - IRGenContext* context, - IRType* valueType) -{ - return context->getSession()->getPtrType(valueType); -} - RefPtr<IRFuncType> getFuncType( IRGenContext* context, UInt paramCount, @@ -1089,7 +1081,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> RefPtr<Type> loweredBaseType = loweredBaseVal->getType(); if (loweredBaseType->As<PointerLikeType>() - || loweredBaseType->As<PtrType>()) + || loweredBaseType->As<PtrTypeBase>()) { // Note that we do *not* perform an actual `load` operation // here, but rather just use the pointer value to construct @@ -1461,7 +1453,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> case LoweredValInfo::Flavor::Ptr: return LoweredValInfo::ptr( builder->emitElementAddress( - getPtrType(context, getSimpleType(type)), + context->getSession()->getPtrType(getSimpleType(type)), baseVal.val, indexVal)); @@ -1498,7 +1490,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> IRValue* irBasePtr = base.val; return LoweredValInfo::ptr( getBuilder()->emitFieldAddress( - getPtrType(context, getSimpleType(fieldType)), + context->getSession()->getPtrType(getSimpleType(fieldType)), irBasePtr, getBuilder()->getDeclRefVal(field))); } @@ -3114,14 +3106,22 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> paramTypes.Add(irParamType); break; - default: - // The parameter is being used for input/output purposes, - // so it will lower to an actual parameter with a pointer type. - // - // TODO: Is this the best representation we can use? + // If the parameter is declared `out` or `inout`, + // 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: + paramTypes.Add( + context->getSession()->getOutType(irParamType)); + break; + case kParameterDirection_InOut: + paramTypes.Add( + context->getSession()->getInOutType(irParamType)); + break; - auto irPtrType = getPtrType(context, irParamType); - paramTypes.Add(irPtrType); + default: + SLANG_UNEXPECTED("unknown parameter direction"); + break; } } @@ -3190,7 +3190,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // // TODO: Is this the best representation we can use? - auto irPtrType = irParamType.As<PtrType>(); + auto irPtrType = irParamType.As<PtrTypeBase>(); IRParam* irParamPtr = subBuilder->emitParam(irPtrType); if(auto paramDecl = paramInfo.decl) |
