[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:23:38 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:

In fact, it seems that I can't change it here without changing it all the way up to the type in the .td file. I can have it print "incomplete" only when `Scomplete` is false, but that seems a bit off. The examples in the CIRTypes.td description say that it will print "complete" and "incomplete" depending on which it is, but that's not true in the incubator implementation at the moment, and that also seems like it would be kind of weird.

https://github.com/llvm/llvm-project/pull/135105


More information about the cfe-commits mailing list