[clang] [CIR] Upstream initial support for complete record types (PR #135844)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 15 13:59:08 PDT 2025
================
@@ -0,0 +1,212 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 contains code to compute the layout of a record.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CIRGenBuilder.h"
+#include "CIRGenModule.h"
+#include "CIRGenTypes.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/RecordLayout.h"
+#include "clang/CIR/Dialect/IR/CIRAttrs.h"
+#include "llvm/Support/Casting.h"
+
+#include <memory>
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::CIRGen;
+
+namespace {
+/// The CIRRecordLowering is responsible for lowering an ASTRecordLayout to an
+/// mlir::Type. Some of the lowering is straightforward, some is not.
+// TODO: Detail some of the complexities and weirdnesses?
+// (See CGRecordLayoutBuilder.cpp)
+struct CIRRecordLowering final {
+
+ // MemberInfo is a helper structure that contains information about a record
+ // member. In addition to the standard member types, there exists a sentinel
+ // member type that ensures correct rounding.
+ struct MemberInfo final {
+ CharUnits offset;
+ enum class InfoKind { Field } kind;
+ mlir::Type data;
+ union {
+ const FieldDecl *fieldDecl;
+ // CXXRecordDecl will be used here when supported.
----------------
andykaylor wrote:
Yes
https://github.com/llvm/llvm-project/pull/135844
More information about the cfe-commits
mailing list