================
@@ -1269,6 +1418,124 @@ BuiltinTypeDeclBuilder
&BuiltinTypeDeclBuilder::addLoadMethods() {
return *this;
}
+CXXRecordDecl *BuiltinTypeDeclBuilder::addMipsSliceType(ResourceDimension Dim,
+ QualType ReturnType) {
+ ASTContext &AST = Record->getASTContext();
+ uint32_t VecSize = getResourceDimensions(Dim);
+ QualType IntTy = AST.IntTy;
+ QualType IndexTy = VecSize > 1 ? AST.getExtVectorType(IntTy, VecSize) :
IntTy;
+ QualType Int3Ty = AST.getExtVectorType(IntTy, VecSize + 1);
+ using PH = BuiltinTypeMethodBuilder::PlaceHolder;
+
+ // Define the mips_slice_type which is returned by mips_type::operator[].
+ // It holds the resource handle and the mip level. It has an operator[]
+ // that takes the coordinate and performs the actual resource load.
+ CXXRecordDecl *MipSliceRecord = nullptr;
+ addPrivateNestedRecord("mips_slice_type", MipSliceRecord);
+ BuiltinTypeDeclBuilder MipSliceBuilder(SemaRef, MipSliceRecord);
+ MipSliceBuilder.addFriend(Record);
+ MipSliceBuilder.addHandleMember(getResourceAttrs().ResourceClass, Dim,
+ getResourceAttrs().IsROV, false, ReturnType,
+ AccessSpecifier::AS_public);
+ MipSliceBuilder.addMemberVariable("__level", IntTy, {},
+ AccessSpecifier::AS_public);
+
+ MipSliceBuilder.addDefaultHandleConstructor(AccessSpecifier::AS_protected)
+ .addCopyConstructor(AccessSpecifier::AS_protected)
+ .addCopyAssignmentOperator(AccessSpecifier::AS_protected);
----------------
Keenuts wrote:
Those can all be chained
```suggestion
BuiltinTypeDeclBuilder MipSliceBuilder(SemaRef, MipSliceRecord)
.addDefaultHandleConstructor(AccessSpecifier::AS_protected)
.addCopyConstructor(AccessSpecifier::AS_protected)
.addCopyAssignmentOperator(AccessSpecifier::AS_protected);
.addFriend(Record);
.addHandleMember(getResourceAttrs().ResourceClass, Dim,
getResourceAttrs().IsROV, false, ReturnType,
AccessSpecifier::AS_public);
.addMemberVariable("__level", IntTy, {}, AccessSpecifier::AS_public);
```
https://github.com/llvm/llvm-project/pull/186143
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits