Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions clang/lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4641,11 +4641,17 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
LHS.getBaseInfo(), TBAAAccessInfo());
}

// The HLSL runtime handle the subscript expression on global resource arrays.
if (getLangOpts().HLSL && (E->getType()->isHLSLResourceRecord() ||
E->getType()->isHLSLResourceRecordArray())) {
std::optional<LValue> LV =
CGM.getHLSLRuntime().emitResourceArraySubscriptExpr(E, *this);
// The HLSL runtime handles subscript expressions on global resource arrays
// and objects with HLSL buffer layouts.
if (getLangOpts().HLSL) {
std::optional<LValue> LV;
if (E->getType()->isHLSLResourceRecord() ||
E->getType()->isHLSLResourceRecordArray()) {
LV = CGM.getHLSLRuntime().emitResourceArraySubscriptExpr(E, *this);
} else if (E->getType().getAddressSpace() == LangAS::hlsl_constant) {
LV = CGM.getHLSLRuntime().emitBufferArraySubscriptExpr(E, *this,
EmitIdxAfterBase);
}
if (LV.has_value())
return *LV;
}
Expand Down Expand Up @@ -5110,6 +5116,11 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
EmitIgnoredExpr(E->getBase());
return EmitDeclRefLValue(DRE);
}
if (getLangOpts().HLSL &&
E->getType().getAddressSpace() == LangAS::hlsl_constant) {
// We have an HLSL buffer - emit using HLSL's layout rules.
return CGM.getHLSLRuntime().emitBufferMemberExpr(*this, E);
}

Expr *BaseExpr = E->getBase();
// Check whether the underlying base pointer is a constant null.
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/CodeGen/CGExprAgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,10 @@ void CodeGenFunction::EmitAggregateCopy(LValue Dest, LValue Src, QualType Ty,
}
}

if (getLangOpts().HLSL && Ty.getAddressSpace() == LangAS::hlsl_constant)
if (CGM.getHLSLRuntime().emitBufferCopy(*this, DestPtr, SrcPtr, Ty))
return;

// Aggregate assignment turns into llvm.memcpy. This is almost valid per
// C99 6.5.16.1p3, which states "If the value being stored in an object is
// read from another object that overlaps in anyway the storage of the first
Expand Down
Loading
Loading