[clang] [CIR] Add constant record ILE support (PR #155663)
Morris Hafner via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 28 07:17:05 PDT 2025
================
@@ -130,6 +132,44 @@ void CIRGenBuilderTy::computeGlobalViewIndicesFromFlatOffset(
computeGlobalViewIndicesFromFlatOffset(offset, subType, layout, indices);
}
+static mlir::Type getAttributeType(mlir::Attribute attr) {
+ return mlir::cast<mlir::TypedAttr>(attr).getType();
+}
+
+cir::RecordType clang::CIRGen::CIRGenBuilderTy::getCompleteRecordType(
+ mlir::ArrayAttr fields, bool packed, bool padded, llvm::StringRef name,
+ const clang::RecordDecl *ast) {
+ llvm::SmallVector<mlir::Type, 8> members;
+ members.reserve(fields.size());
+ llvm::transform(fields, std::back_inserter(members), getAttributeType);
+
+ if (name.empty())
+ return getAnonRecordTy(members, packed, padded);
+
+ return getCompleteRecordTy(members, name, packed, padded);
+}
+
+mlir::Attribute clang::CIRGen::CIRGenBuilderTy::getConstRecordOrZeroAttr(
+ mlir::ArrayAttr arrayAttr, bool packed, bool padded, mlir::Type type) {
+ auto recordTy = mlir::cast_or_null<cir::RecordType>(type);
+
+ // Record type not specified: create anon record type from members.
+ if (!recordTy) {
+ llvm::SmallVector<mlir::Type, 8> members;
----------------
mmha wrote:
Good point. That also lets me remove that static function above.
https://github.com/llvm/llvm-project/pull/155663
More information about the cfe-commits
mailing list