Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 16 additions & 10 deletions clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4493,28 +4493,34 @@ void CXXNameMangler::mangleType(const ArrayParameterType *T) {
}

void CXXNameMangler::mangleType(const HLSLAttributedResourceType *T) {
mangleType(T->getWrappedType());
llvm::SmallString<64> Str("_Res");
const HLSLAttributedResourceType::Attributes &Attrs = T->getAttrs();
// map resource class to HLSL virtual register letter
switch (Attrs.ResourceClass) {
case llvm::dxil::ResourceClass::UAV:
Out << 'u';
case llvm::dxil::ResourceClass::UAV:
Str += "_u";
break;
case llvm::dxil::ResourceClass::SRV:
Out << 't';
case llvm::dxil::ResourceClass::SRV:
Str += "_t";
break;
case llvm::dxil::ResourceClass::CBuffer:
Out << 'b';
Str += "_b";
break;
case llvm::dxil::ResourceClass::Sampler:
Out << 's';
Str += "_s";
break;
}
mangleNumber(Attrs.IsROV);
mangleNumber(Attrs.RawBuffer);
mangleVendorQualifier(Str);
if (Attrs.IsROV)
mangleVendorQualifier("_ROV");
if (Attrs.RawBuffer)
mangleVendorQualifier("_Raw");

if (!T->hasContainedType())
if (!T->hasContainedType()) {
mangleVendorQualifier("__CT");
mangleType(T->getContainedType());
}
mangleType(T->getWrappedType());
}

void CXXNameMangler::mangleIntegerLiteral(QualType T,
Expand Down
23 changes: 1 addition & 22 deletions clang/lib/AST/MicrosoftMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3756,28 +3756,7 @@ void MicrosoftCXXNameMangler::mangleType(const DependentBitIntType *T,

void MicrosoftCXXNameMangler::mangleType(const HLSLAttributedResourceType *T,
Qualifiers, SourceRange Range) {
mangleType(T->getWrappedType(), SourceRange(), QMM_Escape);
const HLSLAttributedResourceType::Attributes &Attrs = T->getAttrs();
// map resource class to HLSL virtual register letter
switch (Attrs.ResourceClass) {
case llvm::dxil::ResourceClass::UAV:
Out << 'u';
break;
case llvm::dxil::ResourceClass::SRV:
Out << 't';
break;
case llvm::dxil::ResourceClass::CBuffer:
Out << 'b';
break;
case llvm::dxil::ResourceClass::Sampler:
Out << 's';
break;
}
mangleNumber(Attrs.IsROV);
mangleNumber(Attrs.RawBuffer);

if (T->hasContainedType())
mangleType(T->getContainedType(), SourceRange(), QMM_Escape);
mangleArtificialTagType(TagTypeKind::Struct, "HLSLAttributedResourceType", {"__hlsl"});
}

// <this-adjustment> ::= <no-adjustment> | <static-adjustment> |
Expand Down
8 changes: 4 additions & 4 deletions clang/test/CodeGenHLSL/builtins/hlsl_resource_t.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ using handle_float_t = __hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::c
// CHECK: %"class.hlsl::RWBuffer" = type { target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
// CHECK: %"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", %struct.MyStruct = type { <4 x float>, <2 x i32>, [8 x i8] }, 1, 0)

// CHECK: define void @"?fa@@YAXU__hlsl_resource_t@@uA@A@M@Z"(target("dx.TypedBuffer", float, 1, 0, 0) %a)
// CHECK: call void @"?foo1@@YAXU__hlsl_resource_t@@uA@A@M@Z"(target("dx.TypedBuffer", float, 1, 0, 0)
// CHECK: declare void @"?foo1@@YAXU__hlsl_resource_t@@uA@A@M@Z"(target("dx.TypedBuffer", float, 1, 0, 0))
// CHECK: define void @"?fa@@YAXUHLSLAttributedResourceType@__hlsl@@@Z"(target("dx.TypedBuffer", float, 1, 0, 0) %a)
// CHECK: call void @"?foo1@@YAXUHLSLAttributedResourceType@__hlsl@@@Z"(target("dx.TypedBuffer", float, 1, 0, 0) %0)
// CHECK: declare void @"?foo1@@YAXUHLSLAttributedResourceType@__hlsl@@@Z"(target("dx.TypedBuffer", float, 1, 0, 0))

void foo1(handle_float_t res);

void fa(handle_float_t a) {
foo1(a);
}

// CHECK: define void @"?fb@@YAXU__hlsl_resource_t@@uA@A@M@Z"(target("dx.TypedBuffer", float, 1, 0, 0) %a)
// CHECK: define void @"?fb@@YAXUHLSLAttributedResourceType@__hlsl@@@Z"(target("dx.TypedBuffer", float, 1, 0, 0) %a)
void fb(handle_float_t a) {
handle_float_t b = a;
}
Expand Down
Loading