================
@@ -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);
+
+  FieldDecl *LevelField = MipSliceBuilder.Fields["__level"];
+  assert(LevelField && "Could not find the level field.\n");
----------------
Keenuts wrote:

```suggestion
  assert(LevelField && "Could not find the level field.);
```

https://github.com/llvm/llvm-project/pull/186143
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to