[clang] [CIR] Upstream minimal support for structure types (PR #135105)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 11 13:15:33 PDT 2025
================
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains implementation details, such as storage structures, of
+// CIR dialect types.
+//
+//===----------------------------------------------------------------------===//
+#ifndef CIR_DIALECT_IR_CIRTYPESDETAILS_H
+#define CIR_DIALECT_IR_CIRTYPESDETAILS_H
+
+#include "mlir/IR/BuiltinAttributes.h"
+#include "mlir/Support/LogicalResult.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
+#include "llvm/ADT/Hashing.h"
+
+namespace cir {
+namespace detail {
+
+//===----------------------------------------------------------------------===//
+// CIR StructTypeStorage
+//===----------------------------------------------------------------------===//
+
+/// Type storage for CIR record types.
+struct StructTypeStorage : public mlir::TypeStorage {
+ struct KeyTy {
+ llvm::ArrayRef<mlir::Type> members;
+ mlir::StringAttr name;
+ bool incomplete;
+ bool packed;
+ bool padded;
+ StructType::RecordKind kind;
+
+ KeyTy(llvm::ArrayRef<mlir::Type> members, mlir::StringAttr name,
+ bool incomplete, bool packed, bool padded,
+ StructType::RecordKind kind)
+ : members(members), name(name), incomplete(incomplete), packed(packed),
+ padded(padded), kind(kind) {}
+ };
+
+ llvm::ArrayRef<mlir::Type> members;
+ mlir::StringAttr name;
+ bool incomplete;
----------------
andykaylor wrote:
To make sure we're on the same page, are you asking for this to be changed to `complete` just here or all the way up to the attribute in the CIR type? That is, the type definition looks like this:
let parameters = (ins
OptionalArrayRefParameter<"mlir::Type">:$members,
OptionalParameter<"mlir::StringAttr">:$name,
"bool":$incomplete,
"bool":$packed,
"bool":$padded,
"StructType::RecordKind":$kind
);
Do you want to change `$incomplete` to `$complete` there? I think I'd be against that, because it makes more sense to print the type with "incomplete" as this PR does than just omitting "complete" when it's incomplete, and to me that's an argument in favor of leaving it as is here as well.
https://github.com/llvm/llvm-project/pull/135105
More information about the cfe-commits
mailing list