From d8354993aa0de5638ed7975988e3f9704edbf17f Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Fri, 11 Apr 2025 16:30:34 -0700 Subject: [PATCH 1/2] [CIR] Rename `cir.struct` to `cir.record` and associated changes During the initial upstreaming of `cir.struct` support, a request was made to rename `cir.struct` to `cir.record` for consistency with its multiple uses. This change makes the modification along with renaming various other related classes. I've attempted to also update variable names and comments to keep everything consistent. --- .../CIR/Dialect/Builder/CIRBaseBuilder.h | 18 +-- clang/include/clang/CIR/Dialect/IR/CIRAttrs.h | 2 +- .../include/clang/CIR/Dialect/IR/CIRAttrs.td | 48 +++---- .../clang/CIR/Dialect/IR/CIRDataLayout.h | 30 ++--- clang/include/clang/CIR/Dialect/IR/CIROps.td | 124 +++++++++--------- .../clang/CIR/Dialect/IR/CIRTBAAAttrs.td | 4 +- clang/include/clang/CIR/Dialect/IR/CIRTypes.h | 2 +- .../include/clang/CIR/Dialect/IR/CIRTypes.td | 81 ++++++------ .../clang/CIR/Dialect/IR/CIRTypesDetails.h | 32 ++--- clang/lib/CIR/CodeGen/CIRAsm.cpp | 6 +- clang/lib/CIR/CodeGen/CIRGenBuilder.cpp | 8 +- clang/lib/CIR/CodeGen/CIRGenBuilder.h | 90 ++++++------- clang/lib/CIR/CodeGen/CIRGenBuiltinNVPTX.cpp | 6 +- clang/lib/CIR/CodeGen/CIRGenCall.cpp | 16 +-- clang/lib/CIR/CodeGen/CIRGenExpr.cpp | 10 +- clang/lib/CIR/CodeGen/CIRGenExprConst.cpp | 108 +++++++-------- clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h | 8 +- clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp | 2 +- clang/lib/CIR/CodeGen/CIRGenModule.cpp | 8 +- clang/lib/CIR/CodeGen/CIRGenRecordLayout.h | 30 ++--- clang/lib/CIR/CodeGen/CIRGenTypes.cpp | 36 ++--- clang/lib/CIR/CodeGen/CIRGenTypes.h | 10 +- clang/lib/CIR/CodeGen/CIRGenVTables.cpp | 6 +- clang/lib/CIR/CodeGen/CIRGenVTables.h | 2 +- .../CIR/CodeGen/CIRRecordLayoutBuilder.cpp | 12 +- clang/lib/CIR/CodeGen/ConstantInitBuilder.cpp | 6 +- clang/lib/CIR/CodeGen/ConstantInitBuilder.h | 96 +++++++------- clang/lib/CIR/Dialect/IR/CIRAttrs.cpp | 26 ++-- clang/lib/CIR/Dialect/IR/CIRDataLayout.cpp | 94 ++++++------- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 44 +++---- clang/lib/CIR/Dialect/IR/CIRTypes.cpp | 106 +++++++-------- clang/lib/CIR/Dialect/Transforms/DropAST.cpp | 2 +- clang/lib/CIR/Dialect/Transforms/LibOpt.cpp | 6 +- .../CIR/Dialect/Transforms/LifetimeCheck.cpp | 54 ++++---- .../Dialect/Transforms/LoweringPrepare.cpp | 14 +- .../lib/CIR/Dialect/Transforms/StdHelpers.cpp | 2 +- .../Transforms/TargetLowering/ABIInfoImpl.cpp | 8 +- .../Transforms/TargetLowering/ABIInfoImpl.h | 2 +- .../Transforms/TargetLowering/CIRCXXABI.h | 2 +- .../TargetLowering/CIRLowerContext.cpp | 4 +- .../TargetLowering/CIRToCIRArgMapping.h | 2 +- .../TargetLowering/ItaniumCXXABI.cpp | 22 ++-- .../TargetLowering/LowerFunction.cpp | 66 +++++----- .../TargetLowering/LowerFunctionInfo.h | 10 +- .../Transforms/TargetLowering/LowerTypes.cpp | 2 +- .../TargetLowering/RecordLayoutBuilder.cpp | 34 ++--- .../Targets/LoweringPrepareX86CXXABI.cpp | 26 ++-- .../Transforms/TargetLowering/Targets/X86.cpp | 40 +++--- .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 70 +++++----- .../CIR/CallConvLowering/AArch64/struct.c | 2 +- .../test/CIR/CallConvLowering/AArch64/union.c | 2 +- .../CIR/CallConvLowering/x86_64/int128.cpp | 2 +- clang/test/CIR/CodeGen/CUDA/registration.cu | 2 +- clang/test/CIR/CodeGen/agg-init.cpp | 4 +- clang/test/CIR/CodeGen/agg-init2.cpp | 2 +- clang/test/CIR/CodeGen/array.c | 2 +- clang/test/CIR/CodeGen/array.cpp | 2 +- clang/test/CIR/CodeGen/atomic-xchg-field.c | 2 +- clang/test/CIR/CodeGen/atomic.cpp | 2 +- clang/test/CIR/CodeGen/bitfield-union.c | 2 +- clang/test/CIR/CodeGen/bitfields.c | 20 +-- clang/test/CIR/CodeGen/bitfields.cpp | 8 +- .../test/CIR/CodeGen/builtin-arm-exclusive.c | 2 +- clang/test/CIR/CodeGen/c11atomic.c | 6 +- .../CodeGen/call-via-class-member-funcptr.cpp | 4 +- clang/test/CIR/CodeGen/compound-literal.c | 4 +- .../test/CIR/CodeGen/conditional-cleanup.cpp | 10 +- clang/test/CIR/CodeGen/const-bitfields.c | 10 +- clang/test/CIR/CodeGen/coro-task.cpp | 14 +- clang/test/CIR/CodeGen/ctor.cpp | 2 +- clang/test/CIR/CodeGen/derived-to-base.cpp | 10 +- clang/test/CIR/CodeGen/dtors.cpp | 4 +- .../CodeGen/dynamic-cast-relative-layout.cpp | 2 +- clang/test/CIR/CodeGen/dynamic-cast.cpp | 4 +- clang/test/CIR/CodeGen/forward-decls.cpp | 22 ++-- clang/test/CIR/CodeGen/fun-ptr.c | 2 +- clang/test/CIR/CodeGen/global-new.cpp | 2 +- clang/test/CIR/CodeGen/globals-ref-globals.c | 20 +-- clang/test/CIR/CodeGen/globals.c | 14 +- clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp | 2 +- .../CIR/CodeGen/initlist-ptr-unsigned.cpp | 2 +- clang/test/CIR/CodeGen/lambda.cpp | 8 +- clang/test/CIR/CodeGen/move.cpp | 2 +- clang/test/CIR/CodeGen/multi-vtable.cpp | 16 +-- clang/test/CIR/CodeGen/new-null.cpp | 2 +- clang/test/CIR/CodeGen/nrvo.cpp | 2 +- clang/test/CIR/CodeGen/packed-structs.c | 20 +-- clang/test/CIR/CodeGen/paren-list-init.cpp | 8 +- .../CIR/CodeGen/pointer-to-data-member.cpp | 4 +- clang/test/CIR/CodeGen/rangefor.cpp | 6 +- clang/test/CIR/CodeGen/std-array.cpp | 2 +- clang/test/CIR/CodeGen/std-find.cpp | 2 +- clang/test/CIR/CodeGen/stmtexpr-init.c | 8 +- clang/test/CIR/CodeGen/string-literals.c | 2 +- clang/test/CIR/CodeGen/struct-empty.c | 4 +- clang/test/CIR/CodeGen/struct.c | 20 +-- clang/test/CIR/CodeGen/struct.cpp | 16 +-- .../test/CIR/CodeGen/three-way-comparison.cpp | 4 +- clang/test/CIR/CodeGen/try-catch-dtors.cpp | 8 +- clang/test/CIR/CodeGen/union-array.c | 2 +- clang/test/CIR/CodeGen/union-init.c | 6 +- clang/test/CIR/CodeGen/union-padding.c | 8 +- clang/test/CIR/CodeGen/union.cpp | 22 ++-- clang/test/CIR/CodeGen/var-arg-float.c | 4 +- clang/test/CIR/CodeGen/var-arg.c | 4 +- clang/test/CIR/CodeGen/variadics.c | 2 +- clang/test/CIR/CodeGen/vtable-emission.cpp | 6 +- clang/test/CIR/CodeGen/vtable-rtti.cpp | 14 +- clang/test/CIR/IR/aliases.cir | 6 +- clang/test/CIR/IR/data-member-ptr.cir | 2 +- clang/test/CIR/IR/getmember.cir | 6 +- clang/test/CIR/IR/global.cir | 6 +- clang/test/CIR/IR/invalid.cir | 48 +++---- clang/test/CIR/IR/struct.cir | 24 ++-- clang/test/CIR/IR/vtableAttr.cir | 2 +- .../test/CIR/Lowering/ThroughMLIR/vtable.cir | 16 +-- clang/test/CIR/Lowering/array.cir | 4 +- .../test/CIR/Lowering/attribute-lowering.cir | 2 +- clang/test/CIR/Lowering/class.cir | 22 ++-- clang/test/CIR/Lowering/const.cir | 4 +- clang/test/CIR/Lowering/data-member.cir | 4 +- clang/test/CIR/Lowering/globals.cir | 18 +-- clang/test/CIR/Lowering/struct.cir | 28 ++-- clang/test/CIR/Lowering/types.cir | 4 +- clang/test/CIR/Lowering/unions.cir | 6 +- clang/test/CIR/Lowering/variadics.cir | 2 +- 126 files changed, 1015 insertions(+), 1016 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h index b771b80aa453..224f4863554d 100644 --- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h +++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h @@ -143,8 +143,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { return getZeroAttr(arrTy); if (auto ptrTy = mlir::dyn_cast(ty)) return getConstNullPtrAttr(ptrTy); - if (auto structTy = mlir::dyn_cast(ty)) - return getZeroAttr(structTy); + if (auto RecordTy = mlir::dyn_cast(ty)) + return getZeroAttr(RecordTy); if (auto methodTy = mlir::dyn_cast(ty)) return getNullMethodAttr(methodTy); if (mlir::isa(ty)) { @@ -496,16 +496,16 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { return createCast(cir::CastKind::int_to_ptr, src, newTy); } - mlir::Value createGetMemberOp(mlir::Location &loc, mlir::Value structPtr, + mlir::Value createGetMemberOp(mlir::Location &loc, mlir::Value recordPtr, const char *fldName, unsigned idx) { - assert(mlir::isa(structPtr.getType())); - auto structBaseTy = - mlir::cast(structPtr.getType()).getPointee(); - assert(mlir::isa(structBaseTy)); - auto fldTy = mlir::cast(structBaseTy).getMembers()[idx]; + assert(mlir::isa(recordPtr.getType())); + auto recordBaseTy = + mlir::cast(recordPtr.getType()).getPointee(); + assert(mlir::isa(recordBaseTy)); + auto fldTy = mlir::cast(recordBaseTy).getMembers()[idx]; auto fldPtrTy = cir::PointerType::get(getContext(), fldTy); - return create(loc, fldPtrTy, structPtr, fldName, idx); + return create(loc, fldPtrTy, recordPtr, fldName, idx); } mlir::Value createPtrToInt(mlir::Value src, mlir::Type newTy) { diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h index 7e60de084265..cf7a4a8ccc95 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.h @@ -37,7 +37,7 @@ class RecordDecl; namespace cir { class ArrayType; -class StructType; +class RecordType; class BoolType; } // namespace cir diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index 0ae6e1c4c5de..0b1316fc4012 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -331,12 +331,12 @@ def ConstVectorAttr : CIR_Attr<"ConstVector", "const_vector", } //===----------------------------------------------------------------------===// -// ConstStructAttr +// ConstRecordAttr //===----------------------------------------------------------------------===// -def ConstStructAttr : CIR_Attr<"ConstStruct", "const_struct", +def ConstRecordAttr : CIR_Attr<"ConstRecord", "const_record", [TypedAttrInterface]> { - let summary = "Represents a constant struct"; + let summary = "Represents a constant record"; let description = [{ Effectively supports "struct-like" constants. It's must be built from an `mlir::ArrayAttr `instance where each elements is a typed attribute @@ -344,9 +344,9 @@ def ConstStructAttr : CIR_Attr<"ConstStruct", "const_struct", Example: ``` - cir.global external @rgb2 = #cir.const_struct<{0 : i8, + cir.global external @rgb2 = #cir.const_record<{0 : i8, 5 : i64, #cir.null : !cir.ptr - }> : !cir.struct<"", i8, i64, !cir.ptr> + }> : !cir.record<"", i8, i64, !cir.ptr> ``` }]; @@ -354,14 +354,14 @@ def ConstStructAttr : CIR_Attr<"ConstStruct", "const_struct", "mlir::ArrayAttr":$members); let builders = [ - AttrBuilderWithInferredContext<(ins "cir::StructType":$type, + AttrBuilderWithInferredContext<(ins "cir::RecordType":$type, "mlir::ArrayAttr":$members), [{ return $_get(type.getContext(), type, members); }]> ]; let assemblyFormat = [{ - `<` custom($members) `>` + `<` custom($members) `>` }]; let genVerifyDecl = 1; @@ -576,7 +576,7 @@ def DataMemberAttr : CIR_Attr<"DataMember", "data_member", pointer-to-data-member value. The `member_index` parameter represents the index of the pointed-to member - within its containing struct. It is an optional parameter; lack of this + within its containing record. It is an optional parameter; lack of this parameter indicates a null pointer-to-data-member value. Example: @@ -687,7 +687,7 @@ def GlobalViewAttr : CIR_Attr<"GlobalView", "global_view", [TypedAttrInterface]> A list of indices can be optionally passed and each element subsequently indexes underlying types. For `symbol` types like `!cir.array` - and `!cir.struct`, it leads to the constant address of sub-elements, while + and `!cir.record`, it leads to the constant address of sub-elements, while for `!cir.ptr`, an offset is applied. The first index is relative to the original symbol type, not the produced one. @@ -764,9 +764,9 @@ def TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", [TypedAttrInterface]> { layout is determined by the C++ ABI used (clang only implements itanium on CIRGen). - The verifier enforces that the output type is always a `!cir.struct`, + The verifier enforces that the output type is always a `!cir.record`, and that the ArrayAttr element types match the equivalent member type - for the resulting struct, i.e, a GlobalViewAttr for symbol reference or + for the resulting record, i.e, a GlobalViewAttr for symbol reference or an IntAttr for flags. Example: @@ -776,7 +776,7 @@ def TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", [TypedAttrInterface]> { cir.global external @type_info_B = #cir.typeinfo<< {#cir.global_view<@_ZTVN10__cxxabiv120__si_class_type_infoE, [2]> : !cir.ptr} - >> : !cir.struct<"", !cir.ptr> + >> : !cir.record<"", !cir.ptr> ``` }]; @@ -790,11 +790,11 @@ def TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", [TypedAttrInterface]> { }]> ]; - // Checks struct element types should match the array for every equivalent + // Checks record element types should match the array for every equivalent // element type. let genVerifyDecl = 1; let assemblyFormat = [{ - `<` custom($data) `>` + `<` custom($data) `>` }]; } @@ -805,7 +805,7 @@ def TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", [TypedAttrInterface]> { def VTableAttr : CIR_Attr<"VTable", "vtable", [TypedAttrInterface]> { let summary = "Represents a C++ vtable"; let description = [{ - Wraps a #cir.const_struct containing vtable data. + Wraps a #cir.const_record containing vtable data. Example: ``` @@ -816,11 +816,11 @@ def VTableAttr : CIR_Attr<"VTable", "vtable", [TypedAttrInterface]> { #cir.global_view<@_ZN1BD0Ev> : !cir.ptr, #cir.global_view<@_ZNK1A5quackEv> : !cir.ptr]> : !cir.array x 5>}>> - : !cir.struct<"", !cir.array x 5>> + : !cir.record<"", !cir.array x 5>> ``` }]; - // `vtable_data` is const struct with one element, containing an array of + // `vtable_data` is const record with one element, containing an array of // vtable information. let parameters = (ins AttributeSelfTypeParameter<"">:$type, "mlir::ArrayAttr":$vtable_data); @@ -834,21 +834,21 @@ def VTableAttr : CIR_Attr<"VTable", "vtable", [TypedAttrInterface]> { let genVerifyDecl = 1; let assemblyFormat = [{ - `<` custom($vtable_data) `>` + `<` custom($vtable_data) `>` }]; } //===----------------------------------------------------------------------===// -// StructLayoutAttr +// RecordLayoutAttr //===----------------------------------------------------------------------===// -// Used to decouple layout information from the struct type. StructType's +// Used to decouple layout information from the record type. RecordType's // uses this attribute to cache that information. -def StructLayoutAttr : CIR_Attr<"StructLayout", "struct_layout"> { - let summary = "ABI specific information about a struct layout"; +def RecordLayoutAttr : CIR_Attr<"RecordLayout", "record_layout"> { + let summary = "ABI specific information about a record layout"; let description = [{ - Holds layout information often queried by !cir.struct users + Holds layout information often queried by !cir.record users during lowering passes and optimizations. }]; @@ -888,7 +888,7 @@ def DynamicCastInfoAttr Provide ABI specific information about a dynamic cast operation. The `srcRtti` and the `destRtti` parameters give the RTTI of the source - struct type and the destination struct type, respectively. + record type and the destination record type, respectively. The `runtimeFunc` parameter gives the `__dynamic_cast` function which is provided by the runtime. The `badCastFunc` parameter gives the diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDataLayout.h b/clang/include/clang/CIR/Dialect/IR/CIRDataLayout.h index 9db2dc568f9f..6e972ba298f7 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRDataLayout.h +++ b/clang/include/clang/CIR/Dialect/IR/CIRDataLayout.h @@ -22,7 +22,7 @@ namespace cir { -class StructLayout; +class RecordLayout; // FIXME(cir): This might be replaced by a CIRDataLayout interface which can // provide the same functionalities. @@ -31,9 +31,9 @@ class CIRDataLayout { /// Primitive type alignment data. This is sorted by type and bit /// width during construction. - llvm::DataLayout::PrimitiveSpec StructAlignment; + llvm::DataLayout::PrimitiveSpec RecordAlignment; - // The StructType -> StructLayout map. + // The RecordType -> RecordLayout map. mutable void *LayoutMap = nullptr; TypeSizeInfoAttr typeSizeInfo; @@ -52,11 +52,11 @@ class CIRDataLayout { bool isBigEndian() const { return bigEndian; } - /// Returns a StructLayout object, indicating the alignment of the - /// struct, its size, and the offsets of its fields. + /// Returns a RecordLayout object, indicating the alignment of the + /// record, its size, and the offsets of its fields. /// /// Note that this information is lazily cached. - const StructLayout *getStructLayout(cir::StructType Ty) const; + const RecordLayout *getRecordLayout(cir::RecordType Ty) const; /// Internal helper method that returns requested alignment for type. llvm::Align getAlignment(mlir::Type Ty, bool abiOrPref) const; @@ -121,21 +121,21 @@ class CIRDataLayout { /// Used to lazily calculate structure layout information for a target machine, /// based on the DataLayout structure. -class StructLayout final - : public llvm::TrailingObjects { - llvm::TypeSize StructSize; - llvm::Align StructAlignment; +class RecordLayout final + : public llvm::TrailingObjects { + llvm::TypeSize RecordSize; + llvm::Align RecordAlignment; unsigned IsPadded : 1; unsigned NumElements : 31; public: - llvm::TypeSize getSizeInBytes() const { return StructSize; } + llvm::TypeSize getSizeInBytes() const { return RecordSize; } - llvm::TypeSize getSizeInBits() const { return 8 * StructSize; } + llvm::TypeSize getSizeInBits() const { return 8 * RecordSize; } - llvm::Align getAlignment() const { return StructAlignment; } + llvm::Align getAlignment() const { return RecordAlignment; } - /// Returns whether the struct has padding or not between its fields. + /// Returns whether the record has padding or not between its fields. /// NB: Padding in nested element is not taken into account. bool hasPadding() const { return IsPadded; } @@ -164,7 +164,7 @@ class StructLayout final private: friend class CIRDataLayout; // Only DataLayout can create this class - StructLayout(cir::StructType ST, const CIRDataLayout &DL); + RecordLayout(cir::RecordType ST, const CIRDataLayout &DL); size_t numTrailingObjects(OverloadToken) const { return NumElements; diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 23b75e89acaa..f4c455a1f039 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -210,18 +210,18 @@ def DynamicCastKind : I32EnumAttr< } def DynamicCastOp : CIR_Op<"dyn_cast"> { - let summary = "Perform dynamic cast on struct pointers"; + let summary = "Perform dynamic cast on record pointers"; let description = [{ The `cir.dyn_cast` operation models part of the semantics of the `dynamic_cast` operator in C++. It can be used to perform 3 kinds of casts - on struct pointers: + on record pointers: - Down-cast, which casts a base class pointer to a derived class pointer; - Side-cast, which casts a class pointer to a sibling class pointer; - Cast-to-complete, which casts a class pointer to a void pointer. - The input of the operation must be a struct pointer. The result of the - operation is either a struct pointer or a void pointer. + The input of the operation must be a record pointer. The result of the + operation is either a record pointer or a void pointer. The parameter `kind` specifies the semantics of this operation. If its value is `ptr`, then the operation models dynamic casts on pointers. Otherwise, if @@ -246,7 +246,7 @@ def DynamicCastOp : CIR_Op<"dyn_cast"> { }]; let arguments = (ins DynamicCastKind:$kind, - StructPtr:$src, + RecordPtr:$src, OptionalAttr:$info, UnitAttr:$relative_layout); let results = (outs CIR_PointerType:$result); @@ -2704,12 +2704,12 @@ def SetBitfieldOp : CIR_Op<"set_bitfield"> { ```mlir // 'd' is in the storage with the index 1 - !struct_type = !cir.struct, !cir.int, !cir.int} #cir.record.decl.ast> + !record_type = !cir.record, !cir.int, !cir.int} #cir.record.decl.ast> #bfi_d = #cir.bitfield_info %1 = cir.const #cir.int<3> : !s32i - %2 = cir.load %0 : !cir.ptr>, !cir.ptr - %3 = cir.get_member %2[1] {name = "d"} : !cir.ptr -> !cir.ptr + %2 = cir.load %0 : !cir.ptr>, !cir.ptr + %3 = cir.get_member %2[1] {name = "d"} : !cir.ptr -> !cir.ptr %4 = cir.set_bitfield(#bfi_d, %3 : !cir.ptr, %1 : !s32i) -> !s32i ``` }]; @@ -2784,11 +2784,11 @@ def GetBitfieldOp : CIR_Op<"get_bitfield"> { ```mlir // 'd' is in the storage with the index 1 - !struct_type = !cir.struct, !cir.int, !cir.int} #cir.record.decl.ast> + !record_type = !cir.record, !cir.int, !cir.int} #cir.record.decl.ast> #bfi_d = #cir.bitfield_info - %2 = cir.load %0 : !cir.ptr>, !cir.ptr - %3 = cir.get_member %2[1] {name = "d"} : !cir.ptr -> !cir.ptr + %2 = cir.load %0 : !cir.ptr>, !cir.ptr + %3 = cir.get_member %2[1] {name = "d"} : !cir.ptr -> !cir.ptr %4 = cir.get_bitfield(#bfi_d, %3 : !cir.ptr) -> !s32i ``` }]; @@ -2829,7 +2829,7 @@ def GetBitfieldOp : CIR_Op<"get_bitfield"> { //===----------------------------------------------------------------------===// def GetMemberOp : CIR_Op<"get_member"> { - let summary = "Get the address of a member of a struct"; + let summary = "Get the address of a member of a record"; let description = [{ The `cir.get_member` operation gets the address of a particular named member from the input record. @@ -2839,13 +2839,13 @@ def GetMemberOp : CIR_Op<"get_member"> { Example: ```mlir - // Suppose we have a struct with multiple members. + // Suppose we have a record with multiple members. !s32i = !cir.int !s8i = !cir.int - !struct_ty = !cir.struct<"struct.Bar" {!s32i, !s8i}> + !record_ty = !cir.record<"struct.Bar" {!s32i, !s8i}> // Get the address of the member at index 1. - %1 = cir.get_member %0[1] {name = "i"} : (!cir.ptr) -> !cir.ptr + %1 = cir.get_member %0[1] {name = "i"} : (!cir.ptr) -> !cir.ptr ``` }]; @@ -2873,7 +2873,7 @@ def GetMemberOp : CIR_Op<"get_member"> { ]; let extraClassDeclaration = [{ - /// Return the index of the struct member being accessed. + /// Return the index of the record member being accessed. uint64_t getIndex() { return getIndexAttr().getZExtValue(); } /// Return the record type pointed by the base pointer. @@ -2893,7 +2893,7 @@ def GetMemberOp : CIR_Op<"get_member"> { //===----------------------------------------------------------------------===// def ExtractMemberOp : CIR_Op<"extract_member", [Pure]> { - let summary = "Extract the value of a member of a struct value"; + let summary = "Extract the value of a member of a record value"; let description = [{ The `cir.extract_member` operation extracts the value of a particular member from the input record. Unlike `cir.get_member` which derives pointers, this @@ -2905,20 +2905,20 @@ def ExtractMemberOp : CIR_Op<"extract_member", [Pure]> { Example: ```mlir - // Suppose we have a struct with multiple members. + // Suppose we have a record with multiple members. !s32i = !cir.int !s8i = !cir.int - !struct_ty = !cir.struct<"struct.Bar" {!s32i, !s8i}> + !record_ty = !cir.record<"struct.Bar" {!s32i, !s8i}> - // And suppose we have a value of the struct type. - %0 = cir.const #cir.const_struct<{#cir.int<1> : !s32i, #cir.int<2> : !s8i}> : !struct_ty + // And suppose we have a value of the record type. + %0 = cir.const #cir.const_record<{#cir.int<1> : !s32i, #cir.int<2> : !s8i}> : !record_ty - // Extract the value of the second member of the struct. - %1 = cir.extract_member %0[1] : !struct_ty -> !s8i + // Extract the value of the second member of the record. + %1 = cir.extract_member %0[1] : !record_ty -> !s8i ``` }]; - let arguments = (ins CIRStructType:$record, IndexAttr:$index_attr); + let arguments = (ins CIRRecordType:$record, IndexAttr:$index_attr); let results = (outs CIR_AnyType:$result); let assemblyFormat = [{ @@ -2932,14 +2932,14 @@ def ExtractMemberOp : CIR_Op<"extract_member", [Pure]> { build($_builder, $_state, type, record, fieldIdx); }]>, OpBuilder<(ins "mlir::Value":$record, "uint64_t":$index), [{ - auto recordTy = mlir::cast(record.getType()); + auto recordTy = mlir::cast(record.getType()); mlir::Type memberTy = recordTy.getMembers()[index]; build($_builder, $_state, memberTy, record, index); }]> ]; let extraClassDeclaration = [{ - /// Get the index of the struct member being accessed. + /// Get the index of the record member being accessed. uint64_t getIndex() { return getIndexAttr().getZExtValue(); } }]; @@ -2952,11 +2952,11 @@ def ExtractMemberOp : CIR_Op<"extract_member", [Pure]> { def InsertMemberOp : CIR_Op<"insert_member", [Pure, AllTypesMatch<["record", "result"]>]> { - let summary = "Overwrite the value of a member of a struct value"; + let summary = "Overwrite the value of a member of a record value"; let description = [{ The `cir.insert_member` operation overwrites the value of a particular - member in the input struct value, and returns the modified struct value. The - result of this operation is equal to the input struct value, except for the + member in the input record value, and returns the modified record value. The + result of this operation is equal to the input record value, except for the member specified by `index_attr` whose value is equal to the given value. This operation is named after the LLVM instruction `insertvalue`. @@ -2966,25 +2966,25 @@ def InsertMemberOp : CIR_Op<"insert_member", Example: ```mlir - // Suppose we have a struct with multiple members. + // Suppose we have a record with multiple members. !s32i = !cir.int !s8i = !cir.int - !struct_ty = !cir.struct<"struct.Bar" {!s32i, !s8i}> + !record_ty = !cir.record<"struct.Bar" {!s32i, !s8i}> - // And suppose we have a value of the struct type. - %0 = cir.const #cir.const_struct<{#cir.int<1> : !s32i, #cir.int<2> : !s8i}> : !struct_ty + // And suppose we have a value of the record type. + %0 = cir.const #cir.const_record<{#cir.int<1> : !s32i, #cir.int<2> : !s8i}> : !record_ty // %0 is {1, 2} - // Overwrite the second member of the struct value. + // Overwrite the second member of the record value. %1 = cir.const #cir.int<3> : !s8i - %2 = cir.insert_member %0[1], %1 : !struct_ty, !s8i + %2 = cir.insert_member %0[1], %1 : !record_ty, !s8i // %2 is {1, 3} ``` }]; - let arguments = (ins CIRStructType:$record, IndexAttr:$index_attr, + let arguments = (ins CIRRecordType:$record, IndexAttr:$index_attr, CIR_AnyType:$value); - let results = (outs CIRStructType:$result); + let results = (outs CIRRecordType:$result); let builders = [ OpBuilder<(ins "mlir::Value":$record, "uint64_t":$index, @@ -2995,7 +2995,7 @@ def InsertMemberOp : CIR_Op<"insert_member", ]; let extraClassDeclaration = [{ - /// Get the index of the struct member being accessed. + /// Get the index of the record member being accessed. uint64_t getIndex() { return getIndexAttr().getZExtValue(); } }]; @@ -3012,7 +3012,7 @@ def InsertMemberOp : CIR_Op<"insert_member", //===----------------------------------------------------------------------===// def GetRuntimeMemberOp : CIR_Op<"get_runtime_member"> { - let summary = "Get the address of a member of a struct"; + let summary = "Get the address of a member of a record"; let description = [{ The `cir.get_runtime_member` operation gets the address of a member from the input record. The target member is given by a value of type @@ -3051,7 +3051,7 @@ def GetRuntimeMemberOp : CIR_Op<"get_runtime_member"> { }]; let arguments = (ins - Arg:$addr, + Arg:$addr, Arg:$member); let results = (outs Res:$result); @@ -3105,7 +3105,7 @@ def GetMethodOp : CIR_Op<"get_method"> { method. }]; - let arguments = (ins CIR_MethodType:$method, StructPtr:$object); + let arguments = (ins CIR_MethodType:$method, RecordPtr:$object); let results = (outs FuncPtr:$callee, VoidPtr:$adjusted_this); let assemblyFormat = [{ @@ -4417,8 +4417,8 @@ def CopyOp : CIR_Op<"copy", Examples: ```mlir - // Copying contents from one struct to another: - cir.copy %0 to %1 : !cir.ptr + // Copying contents from one record to another: + cir.copy %0 to %1 : !cir.ptr ``` }]; @@ -4463,9 +4463,9 @@ def MemCpyOp : CIR_MemOp<"libc.memcpy"> { Examples: ```mlir - // Copying 2 bytes from one array to a struct: + // Copying 2 bytes from one array to a record: %2 = cir.const #cir.int<2> : !u32i - cir.libc.memcpy %2 bytes from %arr to %struct : !cir.ptr -> !cir.ptr + cir.libc.memcpy %2 bytes from %arr to %record : !cir.ptr -> !cir.ptr ``` }]; @@ -4493,9 +4493,9 @@ def MemMoveOp : CIR_MemOp<"libc.memmove"> { Examples: ```mlir - // Copying 2 bytes from one array to a struct: + // Copying 2 bytes from one array to a record: %2 = cir.const #cir.int<2> : !u32i - cir.libc.memmove %2 bytes from %arr to %struct : !cir.ptr, !u64i + cir.libc.memmove %2 bytes from %arr to %record : !cir.ptr, !u64i ``` }]; @@ -4529,8 +4529,8 @@ def MemCpyInlineOp : CIR_MemOp<"memcpy_inline"> { Examples: ```mlir - // Copying 2 bytes from one array to a struct: - cir.memcpy_inline 2 bytes from %arr to %struct : !cir.ptr -> !cir.ptr + // Copying 2 bytes from one array to a record: + cir.memcpy_inline 2 bytes from %arr to %record : !cir.ptr -> !cir.ptr ``` }]; @@ -4558,11 +4558,11 @@ def MemSetOp : CIR_Op<"libc.memset"> { Examples: ```mlir - // Set 2 bytes from a struct to 0: + // Set 2 bytes from a record to 0: %2 = cir.const #cir.int<2> : !u32i %3 = cir.const #cir.int<0> : !u32i %zero = cir.cast(integral, %3 : !s32i), !u8i - cir.libc.memset %2 bytes from %struct set to %zero : !cir.ptr, !s32i, !u64i + cir.libc.memset %2 bytes from %record set to %zero : !cir.ptr, !s32i, !u64i ``` }]; @@ -4593,8 +4593,8 @@ def MemSetInlineOp : CIR_Op<"memset_inline"> { Examples: ```mlir - // Set 2 bytes from a struct to 0 - cir.memset_inline 2 bytes from %struct set to %zero : !cir.ptr, !s32i + // Set 2 bytes from a record to 0 + cir.memset_inline 2 bytes from %record set to %zero : !cir.ptr, !s32i ``` }]; @@ -5039,11 +5039,11 @@ def FreeExceptionOp : CIR_Op<"free.exception"> { Example: ```mlir - %0 = cir.alloc.exception 16 -> !cir.ptr - %1 = cir.get_global @d2 : !cir.ptr + %0 = cir.alloc.exception 16 -> !cir.ptr + %1 = cir.get_global @d2 : !cir.ptr cir.try synthetic cleanup { - cir.call exception @_ZN7test2_DC1ERKS_(%0, %1) : (!cir.ptr, !cir.ptr) -> () cleanup { - %2 = cir.cast(bitcast, %0 : !cir.ptr), !cir.ptr + cir.call exception @_ZN7test2_DC1ERKS_(%0, %1) : (!cir.ptr, !cir.ptr) -> () cleanup { + %2 = cir.cast(bitcast, %0 : !cir.ptr), !cir.ptr cir.free.exception %2 cir.yield } @@ -5180,7 +5180,7 @@ def CIR_InlineAsmOp : CIR_Op<"asm", [RecursiveMemoryEffects]> { output, input and then in/out operands. Note, when several output operands are present, the result type may be represented as - an anon struct type. + an anon record type. Example: ```C++ @@ -5190,8 +5190,8 @@ def CIR_InlineAsmOp : CIR_Op<"asm", [RecursiveMemoryEffects]> { ``` ```mlir - !ty_22anon2E022 = !cir.struct, !cir.int}> - !ty_22anon2E122 = !cir.struct, !cir.int}> + !ty_22anon2E022 = !cir.record, !cir.int}> + !ty_22anon2E122 = !cir.record, !cir.int}> ... %0 = cir.alloca !s32i, !cir.ptr, ["x", init] %1 = cir.alloca !s32i, !cir.ptr, ["y", init] @@ -5569,7 +5569,7 @@ def AtomicXchg : CIR_Op<"atomic.xchg", [AllTypesMatch<["result", "val"]>]> { `__atomic_exchange`and `__atomic_exchange_n`. Example: - %res = cir.atomic.xchg(%ptr : !cir.ptr, + %res = cir.atomic.xchg(%ptr : !cir.ptr, %val : !u64i, seq_cst) : !u64i }]; let results = (outs CIR_AnyType:$result); @@ -5610,7 +5610,7 @@ def AtomicCmpXchg : CIR_Op<"atomic.cmp_xchg", `__atomic_compare_exchange_n` and `__atomic_compare_exchange`. Example: - %old, %cmp = cir.atomic.cmp_xchg(%ptr : !cir.ptr, + %old, %cmp = cir.atomic.cmp_xchg(%ptr : !cir.ptr, %expected : !u64i, %desired : !u64i, success = seq_cst, diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTBAAAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRTBAAAttrs.td index 21478329e621..02894d228912 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTBAAAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTBAAAttrs.td @@ -86,7 +86,7 @@ def CIR_TBAAMemberAttr : CIR_Attr<"TBAAMember", "tbaa_member", []> { Example: ```mlir - !ty_StructS = !cir.struct + !ty_StructS = !cir.record #tbaa_scalar = #cir.tbaa_scalar #tbaa_scalar1 = #cir.tbaa_scalar #tbaa_struct = #cir.tbaa_struct, <#tbaa_scalar, 4>}> @@ -135,7 +135,7 @@ def CIR_TBAAStructAttr : CIR_Attr<"TBAAStruct", Example: ```mlir - !ty_StructS = !cir.struct + !ty_StructS = !cir.record #tbaa_scalar = #cir.tbaa_scalar #tbaa_scalar1 = #cir.tbaa_scalar // CIR_TBAAStructAttr diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h index fa5a9de34281..eb55f3e0abb0 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h @@ -22,7 +22,7 @@ namespace cir { namespace detail { -struct StructTypeStorage; +struct RecordTypeStorage; } // namespace detail bool isAnyFloatingPointType(mlir::Type t); diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td index 0294a78de185..4c7252d6e4e6 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td @@ -295,11 +295,11 @@ def CIR_DataMemberType : CIR_Type<"DataMember", "data_member", let description = [{ `cir.member_ptr` models the pointer-to-data-member type in C++. Values of this type are essentially offsets of the pointed-to member within one of - its containing struct. + its containing record. }]; let parameters = (ins "mlir::Type":$memberTy, - "cir::StructType":$clsTy); + "cir::RecordType":$clsTy); let assemblyFormat = [{ `<` $memberTy `in` $clsTy `>` @@ -450,7 +450,7 @@ def CIR_MethodType : CIR_Type<"Method", "method", }]; let parameters = (ins "cir::FuncType":$memberFuncTy, - "cir::StructType":$clsTy); + "cir::RecordType":$clsTy); let assemblyFormat = [{ `<` qualified($memberFuncTy) `in` $clsTy `>` @@ -524,13 +524,13 @@ def ComplexPtr : Type< ]>, "!cir.complex*"> { } -// Pointer to struct -def StructPtr : Type< +// Pointer to record +def RecordPtr : Type< And<[ CPred<"::mlir::isa<::cir::PointerType>($_self)">, - CPred<"::mlir::isa<::cir::StructType>(" + CPred<"::mlir::isa<::cir::RecordType>(" "::mlir::cast<::cir::PointerType>($_self).getPointee())"> - ]>, "!cir.struct*"> { + ]>, "!cir.record*"> { } // Pointer to exception info @@ -603,52 +603,51 @@ def FuncPtr : Type< } //===----------------------------------------------------------------------===// -// StructType +// RecordType // // The base type for all RecordDecls. //===----------------------------------------------------------------------===// -def CIR_StructType : CIR_Type<"Struct", "struct", +def CIR_RecordType : CIR_Type<"Record", "record", [ DeclareTypeInterfaceMethods, MutableType, ]> { - let summary = "CIR struct type"; + let summary = "CIR record type"; let description = [{ - Each unique clang::RecordDecl is mapped to a `cir.struct` and any object in - C/C++ that has a struct type will have a `cir.struct` in CIR. + Each unique clang::RecordDecl is mapped to a `cir.record` and any object in + C/C++ that has a struct or class type will have a `cir.record` in CIR. There are three possible formats for this type: - - Identified and complete structs: unique name and a known body. - - Identified and incomplete structs: unique name and unknown body. - - Anonymous structs: no name and a known body. + - Identified and complete records: unique name and a known body. + - Identified and incomplete records: unique name and unknown body. + - Anonymous records: no name and a known body. - Identified structs are uniqued by their name, and anonymous structs are - uniqued by their body. This means that two anonymous structs with the same - body will be the same type, and two identified structs with the same name - will be the same type. Attempting to build a struct with an existing name, + Identified records are uniqued by their name, and anonymous records are + uniqued by their body. This means that two anonymous records with the same + body will be the same type, and two identified records with the same name + will be the same type. Attempting to build a record with an existing name, but a different body will result in an error. A few examples: ```mlir - !complete = !cir.struct}> - !incomplete = !cir.struct - !anonymous = !cir.struct}> + !complete = !cir.record}> + !incomplete = !cir.record + !anonymous = !cir.record}> ``` - Incomplete structs are mutable, meaning they can be later completed with a + Incomplete records are mutable, meaning they can be later completed with a body automatically updating in place every type in the code that uses the - incomplete struct. Mutability allows for recursive types to be represented, - meaning the struct can have members that refer to itself. This is useful for + incomplete record. Mutability allows for recursive types to be represented, + meaning the record can have members that refer to itself. This is useful for representing recursive records and is implemented through a special syntax. - In the example below, the `Node` struct has a member that is a pointer to a - `Node` struct: + In the example below, the `Node` record has a member that is a pointer to a + `Node` record: ```mlir - !struct = !cir.struct>}> + !s = !cir.record>}> ``` }]; @@ -658,19 +657,19 @@ def CIR_StructType : CIR_Type<"Struct", "struct", "bool":$incomplete, "bool":$packed, "bool":$padded, - "StructType::RecordKind":$kind, + "RecordType::RecordKind":$kind, OptionalParameter<"ASTRecordDeclInterface">:$ast ); // StorageClass is defined in C++ for mutability. - let storageClass = "StructTypeStorage"; + let storageClass = "RecordTypeStorage"; let genStorageClass = 0; let skipDefaultBuilders = 1; let genVerifyDecl = 1; let builders = [ - // Create an identified and complete struct type. + // Create an identified and complete record type. TypeBuilder<(ins "llvm::ArrayRef":$members, "mlir::StringAttr":$name, @@ -683,7 +682,7 @@ def CIR_StructType : CIR_Type<"Struct", "struct", kind, ast); }]>, - // Create an identified and incomplete struct type. + // Create an identified and incomplete record type. TypeBuilder<(ins "mlir::StringAttr":$name, "RecordKind":$kind @@ -694,7 +693,7 @@ def CIR_StructType : CIR_Type<"Struct", "struct", /*ast=*/ASTRecordDeclInterface{}); }]>, - // Create an anonymous struct type (always complete). + // Create an anonymous record type (always complete). TypeBuilder<(ins "llvm::ArrayRef":$members, "bool":$packed, @@ -730,7 +729,7 @@ def CIR_StructType : CIR_Type<"Struct", "struct", case RecordKind::Struct: return "struct"; } - llvm_unreachable("Invalid value for StructType::getKind()"); + llvm_unreachable("Invalid value for RecordType::getKind()"); } std::string getPrefixedName() { return getKindAsStr() + "." + getName().getValue().str(); @@ -742,11 +741,11 @@ def CIR_StructType : CIR_Type<"Struct", "struct", uint64_t getElementOffset(const mlir::DataLayout &dataLayout, unsigned idx) const; - bool isLayoutIdentical(const StructType &other); + bool isLayoutIdentical(const RecordType &other); // Utilities for lazily computing and cacheing data layout info. // FIXME: currently opaque because there's a cycle if CIRTypes.types include - // from CIRAttrs.h. The implementation operates in terms of StructLayoutAttr + // from CIRAttrs.h. The implementation operates in terms of RecordLayoutAttr // instead. private: mutable mlir::Attribute layoutInfo; @@ -757,10 +756,10 @@ def CIR_StructType : CIR_Type<"Struct", "struct", let hasCustomAssemblyFormat = 1; } -// Note CIRStructType is used instead of CIR_StructType +// Note CIRRecordType is used instead of CIR_RecordType // because of tablegen conflicts. -def CIRStructType : Type< - CPred<"::mlir::isa<::cir::StructType>($_self)">, "CIR struct type">; +def CIRRecordType : Type< + CPred<"::mlir::isa<::cir::RecordType>($_self)">, "CIR record type">; //===----------------------------------------------------------------------===// // Global type constraints @@ -769,7 +768,7 @@ def CIRStructType : Type< def CIR_AnyType : AnyTypeOf<[ CIR_IntType, CIR_PointerType, CIR_DataMemberType, CIR_MethodType, CIR_BoolType, CIR_ArrayType, CIR_VectorType, CIR_FuncType, CIR_VoidType, - CIR_StructType, CIR_ExceptionType, CIR_AnyFloat, CIR_FP16, CIR_BFloat16, + CIR_RecordType, CIR_ExceptionType, CIR_AnyFloat, CIR_FP16, CIR_BFloat16, CIR_ComplexType ]>; diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypesDetails.h b/clang/include/clang/CIR/Dialect/IR/CIRTypesDetails.h index 7b4778d588bb..d7668d46633f 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypesDetails.h +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypesDetails.h @@ -22,23 +22,23 @@ namespace cir { namespace detail { //===----------------------------------------------------------------------===// -// CIR StructTypeStorage +// CIR RecordTypeStorage //===----------------------------------------------------------------------===// /// Type storage for CIR record types. -struct StructTypeStorage : public mlir::TypeStorage { +struct RecordTypeStorage : public mlir::TypeStorage { struct KeyTy { llvm::ArrayRef members; mlir::StringAttr name; bool incomplete; bool packed; bool padded; - StructType::RecordKind kind; + RecordType::RecordKind kind; ASTRecordDeclInterface ast; KeyTy(llvm::ArrayRef members, mlir::StringAttr name, bool incomplete, bool packed, bool padded, - StructType::RecordKind kind, ASTRecordDeclInterface ast) + RecordType::RecordKind kind, ASTRecordDeclInterface ast) : members(members), name(name), incomplete(incomplete), packed(packed), padded(padded), kind(kind), ast(ast) {} }; @@ -48,12 +48,12 @@ struct StructTypeStorage : public mlir::TypeStorage { bool incomplete; bool packed; bool padded; - StructType::RecordKind kind; + RecordType::RecordKind kind; ASTRecordDeclInterface ast; - StructTypeStorage(llvm::ArrayRef members, mlir::StringAttr name, + RecordTypeStorage(llvm::ArrayRef members, mlir::StringAttr name, bool incomplete, bool packed, bool padded, - StructType::RecordKind kind, ASTRecordDeclInterface ast) + RecordType::RecordKind kind, ASTRecordDeclInterface ast) : members(members), name(name), incomplete(incomplete), packed(packed), padded(padded), kind(kind), ast(ast) {} @@ -76,33 +76,33 @@ struct StructTypeStorage : public mlir::TypeStorage { key.padded, key.kind, key.ast); } - static StructTypeStorage *construct(mlir::TypeStorageAllocator &allocator, + static RecordTypeStorage *construct(mlir::TypeStorageAllocator &allocator, const KeyTy &key) { - return new (allocator.allocate()) StructTypeStorage( + return new (allocator.allocate()) RecordTypeStorage( allocator.copyInto(key.members), key.name, key.incomplete, key.packed, key.padded, key.kind, key.ast); } - /// Mutates the members and attributes an identified struct. + /// Mutates the members and attributes an identified record. /// /// Once a record is mutated, it is marked as complete, preventing further - /// mutations. Anonymous structs are always complete and cannot be mutated. - /// This method does not fail if a mutation of a complete struct does not - /// change the struct. + /// mutations. Anonymous records are always complete and cannot be mutated. + /// This method does not fail if a mutation of a complete record does not + /// change the record. llvm::LogicalResult mutate(mlir::TypeStorageAllocator &allocator, llvm::ArrayRef members, bool packed, bool padded, ASTRecordDeclInterface ast) { - // Anonymous structs cannot mutate. + // Anonymous records cannot mutate. if (!name) return llvm::failure(); - // Mutation of complete structs are allowed if they change nothing. + // Mutation of complete records are allowed if they change nothing. if (!incomplete) return mlir::success((this->members == members) && (this->packed == packed) && (this->padded == padded) && (this->ast == ast)); - // Mutate incomplete struct. + // Mutate incomplete record. this->members = allocator.copyInto(members); this->packed = packed; this->ast = ast; diff --git a/clang/lib/CIR/CodeGen/CIRAsm.cpp b/clang/lib/CIR/CodeGen/CIRAsm.cpp index f7cbe073f4da..84bcd33e343c 100644 --- a/clang/lib/CIR/CodeGen/CIRAsm.cpp +++ b/clang/lib/CIR/CodeGen/CIRAsm.cpp @@ -10,7 +10,7 @@ using namespace clang::CIRGen; using namespace cir; static bool isAggregateType(mlir::Type typ) { - return isa(typ); + return isa(typ); } static AsmFlavor inferFlavor(const CIRGenModule &cgm, const AsmStmt &S) { @@ -621,7 +621,7 @@ mlir::LogicalResult CIRGenFunction::emitAsmStmt(const AsmStmt &S) { ResultType = ResultRegTypes[0]; else if (ResultRegTypes.size() > 1) { auto sname = builder.getUniqueAnonRecordName(); - ResultType = builder.getCompleteStructTy(ResultRegTypes, sname, false, + ResultType = builder.getCompleteRecordTy(ResultRegTypes, sname, false, false, nullptr); } @@ -677,7 +677,7 @@ mlir::LogicalResult CIRGenFunction::emitAsmStmt(const AsmStmt &S) { RegResults.push_back(result); } else if (ResultRegTypes.size() > 1) { auto alignment = CharUnits::One(); - auto sname = cast(ResultType).getName(); + auto sname = cast(ResultType).getName(); auto dest = emitAlloca(sname, ResultType, getLoc(S.getAsmLoc()), alignment, false); auto addr = Address(dest, alignment); diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp index 373e2efaedf0..649f0f0c2b16 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp @@ -87,14 +87,14 @@ void CIRGenBuilderTy::computeGlobalViewIndicesFromFlatOffset( const auto [Index, NewOffset] = getIndexAndNewOffset(Offset, EltSize); Indices.push_back(Index); Offset = NewOffset; - } else if (auto StructTy = mlir::dyn_cast(Ty)) { - auto Elts = StructTy.getMembers(); + } else if (auto RecordTy = mlir::dyn_cast(Ty)) { + auto Elts = RecordTy.getMembers(); int64_t Pos = 0; for (size_t I = 0; I < Elts.size(); ++I) { int64_t EltSize = (int64_t)Layout.getTypeAllocSize(Elts[I]).getFixedValue(); unsigned AlignMask = Layout.getABITypeAlign(Elts[I]).value() - 1; - if (StructTy.getPacked()) + if (RecordTy.getPacked()) AlignMask = 0; Pos = (Pos + AlignMask) & ~AlignMask; assert(Offset >= 0); @@ -120,7 +120,7 @@ uint64_t CIRGenBuilderTy::computeOffsetFromGlobalViewIndices( int64_t offset = 0; for (int64_t idx : indexes) { - if (auto sTy = dyn_cast(typ)) { + if (auto sTy = dyn_cast(typ)) { offset += sTy.getElementOffset(layout.layout, idx); assert(idx < (int64_t)sTy.getMembers().size()); typ = sTy.getMembers()[idx]; diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h index 534bc5ad9a6f..39ca13bcdf26 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h @@ -190,13 +190,13 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { return cir::ConstArrayAttr::get(arrayTy, attrs); } - mlir::Attribute getConstStructOrZeroAttr(mlir::ArrayAttr arrayAttr, + mlir::Attribute getConstRecordOrZeroAttr(mlir::ArrayAttr arrayAttr, bool packed = false, bool padded = false, mlir::Type type = {}) { llvm::SmallVector members; - auto structTy = mlir::dyn_cast(type); - assert(structTy && "expected cir.struct"); + auto recordTy = mlir::dyn_cast(type); + assert(recordTy && "expected cir.record"); // Collect members and check if they are all zero. bool isZero = true; @@ -206,19 +206,19 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { isZero &= isNullValue(typedAttr); } - // Struct type not specified: create anon struct type from members. - if (!structTy) - structTy = getType(members, packed, padded, - cir::StructType::Struct, + // Record type not specified: create anon record type from members. + if (!recordTy) + recordTy = getType(members, packed, padded, + cir::RecordType::Struct, /*ast=*/nullptr); - // Return zero or anonymous constant struct. + // Return zero or anonymous constant record. if (isZero) - return cir::ZeroAttr::get(getContext(), structTy); - return cir::ConstStructAttr::get(structTy, arrayAttr); + return cir::ZeroAttr::get(getContext(), recordTy); + return cir::ConstRecordAttr::get(recordTy, arrayAttr); } - cir::ConstStructAttr getAnonConstStruct(mlir::ArrayAttr arrayAttr, + cir::ConstRecordAttr getAnonConstRecord(mlir::ArrayAttr arrayAttr, bool packed = false, bool padded = false, mlir::Type ty = {}) { @@ -230,16 +230,16 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { } if (!ty) - ty = getAnonStructTy(members, packed, padded); + ty = getAnonRecordTy(members, packed, padded); - auto sTy = mlir::dyn_cast(ty); - assert(sTy && "expected struct type"); - return cir::ConstStructAttr::get(sTy, arrayAttr); + auto sTy = mlir::dyn_cast(ty); + assert(sTy && "expected record type"); + return cir::ConstRecordAttr::get(sTy, arrayAttr); } cir::TypeInfoAttr getTypeInfo(mlir::ArrayAttr fieldsAttr) { - auto anonStruct = getAnonConstStruct(fieldsAttr); - return cir::TypeInfoAttr::get(anonStruct.getType(), fieldsAttr); + auto anonRecord = getAnonConstRecord(fieldsAttr); + return cir::TypeInfoAttr::get(anonRecord.getType(), fieldsAttr); } cir::CmpThreeWayInfoAttr getCmpThreeWayInfoStrongOrdering( @@ -292,9 +292,9 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { return FV.bitwiseIsEqual(fpVal); } - if (const auto structVal = mlir::dyn_cast(attr)) { - for (const auto elt : structVal.getMembers()) { - // FIXME(cir): the struct's ID should not be considered a member. + if (const auto recordVal = mlir::dyn_cast(attr)) { + for (const auto elt : recordVal.getMembers()) { + // FIXME(cir): the record's ID should not be considered a member. if (mlir::isa(elt)) continue; if (!isNullValue(elt)) @@ -448,28 +448,28 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { return cir::PointerType::get(getContext(), typeCache.UInt32Ty); } - /// Get a CIR anonymous struct type. - cir::StructType getAnonStructTy(llvm::ArrayRef members, + /// Get a CIR anonymous record type. + cir::RecordType getAnonRecordTy(llvm::ArrayRef members, bool packed = false, bool padded = false, const clang::RecordDecl *ast = nullptr) { cir::ASTRecordDeclAttr astAttr = nullptr; - auto kind = cir::StructType::RecordKind::Struct; + auto kind = cir::RecordType::RecordKind::Struct; if (ast) { astAttr = getAttr(ast); kind = getRecordKind(ast->getTagKind()); } - return getType(members, packed, padded, kind, astAttr); + return getType(members, packed, padded, kind, astAttr); } /// Get a CIR record kind from a AST declaration tag. - cir::StructType::RecordKind getRecordKind(const clang::TagTypeKind kind) { + cir::RecordType::RecordKind getRecordKind(const clang::TagTypeKind kind) { switch (kind) { case clang::TagTypeKind::Struct: - return cir::StructType::Struct; + return cir::RecordType::Struct; case clang::TagTypeKind::Union: - return cir::StructType::Union; + return cir::RecordType::Union; case clang::TagTypeKind::Class: - return cir::StructType::Class; + return cir::RecordType::Class; case clang::TagTypeKind::Interface: llvm_unreachable("interface records are NYI"); case clang::TagTypeKind::Enum: @@ -477,45 +477,45 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { } } - /// Get a incomplete CIR struct type. - cir::StructType getIncompleteStructTy(llvm::StringRef name, + /// Get a incomplete CIR record type. + cir::RecordType getIncompleteRecordTy(llvm::StringRef name, const clang::RecordDecl *ast) { const auto nameAttr = getStringAttr(name); - auto kind = cir::StructType::RecordKind::Struct; + auto kind = cir::RecordType::RecordKind::Struct; if (ast) kind = getRecordKind(ast->getTagKind()); - return getType(nameAttr, kind); + return getType(nameAttr, kind); } - /// Get a CIR named struct type. + /// Get a CIR named record type. /// - /// If a struct already exists and is complete, but the client tries to fetch + /// If a record already exists and is complete, but the client tries to fetch /// it with a different set of attributes, this method will crash. - cir::StructType getCompleteStructTy(llvm::ArrayRef members, + cir::RecordType getCompleteRecordTy(llvm::ArrayRef members, llvm::StringRef name, bool packed, bool padded, const clang::RecordDecl *ast) { const auto nameAttr = getStringAttr(name); cir::ASTRecordDeclAttr astAttr = nullptr; - auto kind = cir::StructType::RecordKind::Struct; + auto kind = cir::RecordType::RecordKind::Struct; if (ast) { astAttr = getAttr(ast); kind = getRecordKind(ast->getTagKind()); } - // Create or get the struct. - auto type = getType(members, nameAttr, packed, padded, + // Create or get the record. + auto type = getType(members, nameAttr, packed, padded, kind, astAttr); - // Complete an incomplete struct or ensure the existing complete struct + // Complete an incomplete record or ensure the existing complete record // matches the requested attributes. type.complete(members, packed, padded, astAttr); return type; } - cir::StructType - getCompleteStructType(mlir::ArrayAttr fields, bool packed = false, + cir::RecordType + getCompleteRecordType(mlir::ArrayAttr fields, bool packed = false, bool padded = false, llvm::StringRef name = "", const clang::RecordDecl *ast = nullptr) { llvm::SmallVector members; @@ -525,9 +525,9 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { } if (name.empty()) - return getAnonStructTy(members, packed, padded, ast); + return getAnonRecordTy(members, packed, padded, ast); else - return getCompleteStructTy(members, name, packed, padded, ast); + return getCompleteRecordTy(members, name, packed, padded, ast); } cir::ArrayType getArrayType(mlir::Type eltType, unsigned size) { @@ -535,7 +535,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { } bool isSized(mlir::Type ty) { - if (mlir::isa(ty)) return true; if (mlir::isa(ty)) { @@ -604,7 +604,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { cir::ConstantOp getZero(mlir::Location loc, mlir::Type ty) { // TODO: dispatch creation for primitive types. - assert((mlir::isa(ty) || mlir::isa(ty) || + assert((mlir::isa(ty) || mlir::isa(ty) || mlir::isa(ty)) && "NYI for other types"); return create(loc, ty, getZeroAttr(ty)); diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinNVPTX.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinNVPTX.cpp index 70a60e1590f0..81159a7afba3 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuiltinNVPTX.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinNVPTX.cpp @@ -87,12 +87,12 @@ mlir::Value packArgsIntoNVPTXFormatBuffer(CIRGenFunction &cgf, for (auto arg : llvm::drop_begin(args)) argTypes.push_back(arg.getRValue(cgf, loc).getScalarVal().getType()); - // We can directly store the arguments into a struct, and the alignment + // We can directly store the arguments into a record, and the alignment // would automatically be correct. That's because vprintf does not // accept aggregates. mlir::Type allocaTy = - cir::StructType::get(&cgf.getMLIRContext(), argTypes, /*packed=*/false, - /*padded=*/false, StructType::Struct); + cir::RecordType::get(&cgf.getMLIRContext(), argTypes, /*packed=*/false, + /*padded=*/false, cir::RecordType::Struct); mlir::Value alloca = cgf.CreateTempAlloca(allocaTy, loc, "printf_args", nullptr); diff --git a/clang/lib/CIR/CodeGen/CIRGenCall.cpp b/clang/lib/CIR/CodeGen/CIRGenCall.cpp index 20500482cb7c..ed082781561f 100644 --- a/clang/lib/CIR/CodeGen/CIRGenCall.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenCall.cpp @@ -64,8 +64,8 @@ CIRGenFunctionInfo *CIRGenFunctionInfo::create( FI->Required = required; FI->HasRegParm = info.getHasRegParm(); FI->RegParm = info.getRegParm(); - FI->ArgStruct = nullptr; - FI->ArgStructAlign = 0; + FI->ArgRecord = nullptr; + FI->ArgRecordAlign = 0; FI->NumArgs = argTypes.size(); FI->HasExtParameterInfos = !paramInfos.empty(); FI->getArgsBuffer()[0].type = resultType; @@ -249,7 +249,7 @@ cir::FuncType CIRGenTypes::GetFunctionType(const CIRGenFunctionInfo &FI) { case cir::ABIArgInfo::Extend: case cir::ABIArgInfo::Direct: { mlir::Type argType = ArgInfo.getCoerceToType(); - // TODO: handle the test against llvm::StructType from codegen + // TODO: handle the test against llvm::RecordType from codegen assert(NumCIRArgs == 1); ArgTypes[FirstCIRArg] = argType; break; @@ -272,7 +272,7 @@ cir::FuncType CIRGenTypes::GetFunctionTypeForVTable(GlobalDecl GD) { if (!isFuncTypeConvertible(FPT)) { llvm_unreachable("NYI"); - // return llvm::StructType::get(getLLVMContext()); + // return llvm::RecordType::get(getLLVMContext()); } return GetFunctionType(GD); @@ -296,7 +296,7 @@ void CIRGenFunction::emitAggregateStore(mlir::Value Val, Address Dest, // fast-isel. // In CIR codegen: // Emit the most simple cir.store possible (e.g. a store for a whole - // struct), which can later be broken down in other CIR levels (or prior + // record), which can later be broken down in other CIR levels (or prior // to dialect codegen). (void)DestIsVolatile; // Stored result for the callers of this function expected to be in the same @@ -627,7 +627,7 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &CallInfo, // If we're using inalloca, insert the allocation after the stack save. // FIXME: Do this earlier rather than hacking it in here! Address ArgMemory = Address::invalid(); - assert(!CallInfo.getArgStruct() && "NYI"); + assert(!CallInfo.getArgRecord() && "NYI"); ClangToCIRArgMapping CIRFunctionArgs(CGM.getASTContext(), CallInfo); SmallVector CIRCallArgs(CIRFunctionArgs.totalCIRArgs()); @@ -659,7 +659,7 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &CallInfo, switch (ArgInfo.getKind()) { case cir::ABIArgInfo::Direct: { - if (!mlir::isa(ArgInfo.getCoerceToType()) && + if (!mlir::isa(ArgInfo.getCoerceToType()) && ArgInfo.getCoerceToType() == convertType(info_it->type) && ArgInfo.getDirectOffset() == 0) { assert(NumCIRArgs == 1); @@ -700,7 +700,7 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &CallInfo, // Fast-isel and the optimizer generally like scalar values better than // FCAs, so we flatten them if this is safe to do for this argument. - auto STy = dyn_cast(ArgInfo.getCoerceToType()); + auto STy = dyn_cast(ArgInfo.getCoerceToType()); if (STy && ArgInfo.isDirect() && ArgInfo.getCanBeFlattened()) { auto SrcTy = Src.getElementType(); // FIXME(cir): get proper location for each argument. diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp index 43208913ee28..5d745ca60e80 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp @@ -1670,7 +1670,7 @@ static bool isPreserveAIArrayBase(CIRGenFunction &CGF, const Expr *ArrayBase) { const auto *PointeeT = PtrT->getPointeeType()->getUnqualifiedDesugaredType(); - if (const auto *RecT = dyn_cast(PointeeT)) + if (const auto *RecT = dyn_cast(PointeeT)) return RecT->getDecl()->hasAttr(); return false; } @@ -2007,7 +2007,7 @@ LValue CIRGenFunction::emitCastLValue(const CastExpr *E) { case CK_UncheckedDerivedToBase: case CK_DerivedToBase: { const auto *DerivedClassTy = - E->getSubExpr()->getType()->castAs(); + E->getSubExpr()->getType()->castAs(); auto *DerivedClassDecl = cast(DerivedClassTy->getDecl()); LValue LV = emitLValue(E->getSubExpr()); @@ -2263,8 +2263,8 @@ static void pushTemporaryCleanup(CIRGenFunction &CGF, } CXXDestructorDecl *ReferenceTemporaryDtor = nullptr; - if (const RecordType *RT = - E->getType()->getBaseElementTypeUnsafe()->getAs()) { + if (const clang::RecordType *RT = + E->getType()->getBaseElementTypeUnsafe()->getAs()) { // Get the destructor for the reference temporary. auto *ClassDecl = cast(RT->getDecl()); if (!ClassDecl->hasTrivialDestructor()) @@ -3146,7 +3146,7 @@ static bool isConstantEmittableObjectType(QualType type) { // Otherwise, all object types satisfy this except C++ classes with // mutable subobjects or non-trivial copy/destroy behavior. - if (const auto *RT = dyn_cast(type)) + if (const auto *RT = dyn_cast(type)) if (const auto *RD = dyn_cast(RT->getDecl())) if (RD->hasMutableFields() || !RD->isTrivial()) return false; diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp b/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp index f0ee6333c53a..faee4cad9e30 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp @@ -91,7 +91,7 @@ struct ConstantAggregateBuilderUtils { } }; -/// Incremental builder for an mlir::TypedAttr holding a struct or array +/// Incremental builder for an mlir::TypedAttr holding a record or array /// constant. class ConstantAggregateBuilder : private ConstantAggregateBuilderUtils { /// The elements of the constant. These two arrays must have the same size; @@ -372,7 +372,7 @@ mlir::Attribute ConstantAggregateBuilder::buildFrom( DesiredSize = Size; } - // The natural alignment of an unpacked CIR struct with the given elements. + // The natural alignment of an unpacked CIR record with the given elements. CharUnits Align = CharUnits::One(); for (auto e : Elems) { // FIXME(cir): migrate most of this file to use mlir::TypedAttr directly. @@ -402,7 +402,7 @@ mlir::Attribute ConstantAggregateBuilder::buildFrom( // If we don't have a natural layout, insert padding as necessary. // As we go, double-check to see if we can actually just emit Elems - // as a non-packed struct and do so opportunistically if possible. + // as a non-packed record and do so opportunistically if possible. llvm::SmallVector PackedElems; if (!NaturalLayout) { CharUnits SizeSoFar = CharUnits::Zero(); @@ -437,12 +437,12 @@ mlir::Attribute ConstantAggregateBuilder::buildFrom( auto arrAttr = mlir::ArrayAttr::get(builder.getContext(), Packed ? PackedElems : UnpackedElems); - auto strType = builder.getCompleteStructType(arrAttr, Packed); - if (auto desired = dyn_cast(DesiredTy)) + auto strType = builder.getCompleteRecordType(arrAttr, Packed); + if (auto desired = dyn_cast(DesiredTy)) if (desired.isLayoutIdentical(strType)) strType = desired; - return builder.getConstStructOrZeroAttr(arrAttr, Packed, Padded, strType); + return builder.getConstRecordOrZeroAttr(arrAttr, Packed, Padded, strType); } void ConstantAggregateBuilder::condense(CharUnits Offset, @@ -467,7 +467,7 @@ void ConstantAggregateBuilder::condense(CharUnits Offset, mlir::TypedAttr C = mlir::dyn_cast(Elems[First]); assert(C && "expected typed attribute"); if (Length == 1 && Offsets[First] == Offset && getSize(C) == Size) { - // Re-wrap single element structs if necessary. Otherwise, leave any single + // Re-wrap single element records if necessary. Otherwise, leave any single // element constant of the right size alone even if it has the wrong type. llvm_unreachable("NYI"); } @@ -481,26 +481,26 @@ void ConstantAggregateBuilder::condense(CharUnits Offset, } //===----------------------------------------------------------------------===// -// ConstStructBuilder +// ConstRecordBuilder //===----------------------------------------------------------------------===// -class ConstStructBuilder { +class ConstRecordBuilder { CIRGenModule &CGM; ConstantEmitter &Emitter; ConstantAggregateBuilder &Builder; CharUnits StartOffset; public: - static mlir::Attribute BuildStruct(ConstantEmitter &Emitter, - InitListExpr *ILE, QualType StructTy); - static mlir::Attribute BuildStruct(ConstantEmitter &Emitter, + static mlir::Attribute BuildRecord(ConstantEmitter &Emitter, + InitListExpr *ILE, QualType RecordTy); + static mlir::Attribute BuildRecord(ConstantEmitter &Emitter, const APValue &Value, QualType ValTy); - static bool UpdateStruct(ConstantEmitter &Emitter, + static bool UpdateRecord(ConstantEmitter &Emitter, ConstantAggregateBuilder &Const, CharUnits Offset, InitListExpr *Updater); private: - ConstStructBuilder(ConstantEmitter &Emitter, + ConstRecordBuilder(ConstantEmitter &Emitter, ConstantAggregateBuilder &Builder, CharUnits StartOffset) : CGM(Emitter.CGM), Emitter(Emitter), Builder(Builder), StartOffset(StartOffset) {} @@ -528,7 +528,7 @@ class ConstStructBuilder { mlir::Attribute Finalize(QualType Ty); }; -bool ConstStructBuilder::AppendField(const FieldDecl *Field, +bool ConstRecordBuilder::AppendField(const FieldDecl *Field, uint64_t FieldOffset, mlir::Attribute InitCst, bool AllowOverwrite) { @@ -539,13 +539,13 @@ bool ConstStructBuilder::AppendField(const FieldDecl *Field, return AppendBytes(FieldOffsetInChars, InitCst, AllowOverwrite); } -bool ConstStructBuilder::AppendBytes(CharUnits FieldOffsetInChars, +bool ConstRecordBuilder::AppendBytes(CharUnits FieldOffsetInChars, mlir::Attribute InitCst, bool AllowOverwrite) { return Builder.add(InitCst, StartOffset + FieldOffsetInChars, AllowOverwrite); } -bool ConstStructBuilder::AppendBitField(const FieldDecl *Field, +bool ConstRecordBuilder::AppendBitField(const FieldDecl *Field, uint64_t FieldOffset, cir::IntAttr CI, bool AllowOverwrite) { const auto &RL = CGM.getTypes().getCIRGenRecordLayout(Field->getParent()); @@ -573,7 +573,7 @@ static bool EmitDesignatedInitUpdater(ConstantEmitter &Emitter, CharUnits Offset, QualType Type, InitListExpr *Updater) { if (Type->isRecordType()) - return ConstStructBuilder::UpdateStruct(Emitter, Const, Offset, Updater); + return ConstRecordBuilder::UpdateRecord(Emitter, Const, Offset, Updater); auto CAT = Emitter.CGM.getASTContext().getAsConstantArrayType(Type); if (!CAT) @@ -617,8 +617,8 @@ static bool EmitDesignatedInitUpdater(ConstantEmitter &Emitter, return true; } -bool ConstStructBuilder::Build(InitListExpr *ILE, bool AllowOverwrite) { - RecordDecl *RD = ILE->getType()->castAs()->getDecl(); +bool ConstRecordBuilder::Build(InitListExpr *ILE, bool AllowOverwrite) { + RecordDecl *RD = ILE->getType()->castAs()->getDecl(); const ASTRecordLayout &Layout = CGM.getASTContext().getASTRecordLayout(RD); unsigned FieldNo = -1; @@ -647,7 +647,7 @@ bool ConstStructBuilder::Build(InitListExpr *ILE, bool AllowOverwrite) { if (Field->isUnnamedBitField()) continue; - // Get the initializer. A struct can include fields without initializers, + // Get the initializer. A record can include fields without initializers, // we just use explicit null values for them. Expr *Init = nullptr; if (ElementNo < ILE->getNumInits()) @@ -656,7 +656,7 @@ bool ConstStructBuilder::Build(InitListExpr *ILE, bool AllowOverwrite) { continue; // Zero-sized fields are not emitted, but their initializers may still - // prevent emission of this struct as a constant. + // prevent emission of this record as a constant. if (Field->isZeroSize(CGM.getASTContext())) { if (Init->HasSideEffects(CGM.getASTContext())) return false; @@ -739,7 +739,7 @@ struct BaseInfo { }; } // namespace -bool ConstStructBuilder::Build(const APValue &Val, const RecordDecl *RD, +bool ConstRecordBuilder::Build(const APValue &Val, const RecordDecl *RD, bool IsPrimaryBase, const CXXRecordDecl *VTableClass, CharUnits Offset) { @@ -828,7 +828,7 @@ bool ConstStructBuilder::Build(const APValue &Val, const RecordDecl *RD, return true; } -bool ConstStructBuilder::ApplyZeroInitPadding( +bool ConstRecordBuilder::ApplyZeroInitPadding( const ASTRecordLayout &Layout, unsigned FieldNo, const FieldDecl &Field, bool AllowOverwrite, CharUnits &SizeSoFar, bool &ZeroFieldSize) { @@ -860,7 +860,7 @@ bool ConstStructBuilder::ApplyZeroInitPadding( return true; } -bool ConstStructBuilder::ApplyZeroInitPadding(const ASTRecordLayout &Layout, +bool ConstRecordBuilder::ApplyZeroInitPadding(const ASTRecordLayout &Layout, bool AllowOverwrite, CharUnits SizeSoFar) { CharUnits TotalSize = Layout.getSize(); @@ -873,18 +873,18 @@ bool ConstStructBuilder::ApplyZeroInitPadding(const ASTRecordLayout &Layout, return true; } -mlir::Attribute ConstStructBuilder::Finalize(QualType Type) { +mlir::Attribute ConstRecordBuilder::Finalize(QualType Type) { Type = Type.getNonReferenceType(); - RecordDecl *RD = Type->castAs()->getDecl(); + RecordDecl *RD = Type->castAs()->getDecl(); mlir::Type ValTy = CGM.convertType(Type); return Builder.build(ValTy, RD->hasFlexibleArrayMember()); } -mlir::Attribute ConstStructBuilder::BuildStruct(ConstantEmitter &Emitter, +mlir::Attribute ConstRecordBuilder::BuildRecord(ConstantEmitter &Emitter, InitListExpr *ILE, QualType ValTy) { ConstantAggregateBuilder Const(Emitter.CGM); - ConstStructBuilder Builder(Emitter, Const, CharUnits::Zero()); + ConstRecordBuilder Builder(Emitter, Const, CharUnits::Zero()); if (!Builder.Build(ILE, /*AllowOverwrite*/ false)) return nullptr; @@ -892,13 +892,13 @@ mlir::Attribute ConstStructBuilder::BuildStruct(ConstantEmitter &Emitter, return Builder.Finalize(ValTy); } -mlir::Attribute ConstStructBuilder::BuildStruct(ConstantEmitter &Emitter, +mlir::Attribute ConstRecordBuilder::BuildRecord(ConstantEmitter &Emitter, const APValue &Val, QualType ValTy) { ConstantAggregateBuilder Const(Emitter.CGM); - ConstStructBuilder Builder(Emitter, Const, CharUnits::Zero()); + ConstRecordBuilder Builder(Emitter, Const, CharUnits::Zero()); - const RecordDecl *RD = ValTy->castAs()->getDecl(); + const RecordDecl *RD = ValTy->castAs()->getDecl(); const CXXRecordDecl *CD = dyn_cast(RD); if (!Builder.Build(Val, RD, false, CD, CharUnits::Zero())) return nullptr; @@ -906,10 +906,10 @@ mlir::Attribute ConstStructBuilder::BuildStruct(ConstantEmitter &Emitter, return Builder.Finalize(ValTy); } -bool ConstStructBuilder::UpdateStruct(ConstantEmitter &Emitter, +bool ConstRecordBuilder::UpdateRecord(ConstantEmitter &Emitter, ConstantAggregateBuilder &Const, CharUnits Offset, InitListExpr *Updater) { - return ConstStructBuilder(Emitter, Const, Offset) + return ConstRecordBuilder(Emitter, Const, Offset) .Build(Updater, /*AllowOverwrite*/ true); } @@ -1140,12 +1140,12 @@ class ConstExprEmitter if (!desiredArrayType) return false; - auto elementStructType = - dyn_cast(desiredArrayType.getEltType()); - if (!elementStructType) + auto elementRecordType = + dyn_cast(desiredArrayType.getEltType()); + if (!elementRecordType) return false; - return elementStructType.isUnion(); + return elementRecordType.isUnion(); }(); // Emit initializer elements as MLIR attributes and check for common type. @@ -1171,7 +1171,7 @@ class ConstExprEmitter } mlir::Attribute EmitRecordInitialization(InitListExpr *ILE, QualType T) { - return ConstStructBuilder::BuildStruct(Emitter, ILE, T); + return ConstRecordBuilder::BuildRecord(Emitter, ILE, T); } mlir::Attribute EmitVectorInitialization(InitListExpr *ILE, QualType T) { @@ -1306,7 +1306,7 @@ emitArrayConstant(CIRGenModule &CGM, mlir::Type DesiredType, cir::ArrayType::get(builder.getContext(), CommonElementType, ArrayBound)); // TODO(cir): If all the elements had the same type up to the trailing - // zeroes, emit a struct of two arrays (the nonzero data and the + // zeroes, emit a record of two arrays (the nonzero data and the // zeroinitializer). Use DesiredType to get the element type. } else if (Elements.size() != ArrayBound) { // Otherwise pad to the right size with the filler if necessary. @@ -1334,7 +1334,7 @@ emitArrayConstant(CIRGenModule &CGM, mlir::Type DesiredType, Eles.push_back(Element); auto arrAttr = mlir::ArrayAttr::get(builder.getContext(), Eles); - return builder.getAnonConstStruct(arrAttr, false); + return builder.getAnonConstRecord(arrAttr, false); } } // end anonymous namespace. @@ -1835,7 +1835,7 @@ mlir::Attribute ConstantEmitter::emitForMemory(CIRGenModule &CGM, (outerSize - innerSize) / 8)); SmallVector anonElts = {C, zeroArray}; auto arrAttr = mlir::ArrayAttr::get(builder.getContext(), anonElts); - return builder.getAnonConstStruct(arrAttr, false); + return builder.getAnonConstRecord(arrAttr, false); } // Zero-extend bool. @@ -1992,7 +1992,7 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &Value, return ConstantLValueEmitter(*this, Value, DestType).tryEmit(); case APValue::Struct: case APValue::Union: - return ConstStructBuilder::BuildStruct(*this, Value, DestType); + return ConstRecordBuilder::BuildRecord(*this, Value, DestType); case APValue::FixedPoint: case APValue::ComplexInt: case APValue::ComplexFloat: @@ -2015,7 +2015,7 @@ mlir::Value CIRGenModule::emitNullConstant(QualType T, mlir::Location loc) { llvm_unreachable("NYI"); } - if (const RecordType *RT = T->getAs()) + if (const clang::RecordType *RT = T->getAs()) llvm_unreachable("NYI"); assert(T->isMemberDataPointerType() && @@ -2087,19 +2087,19 @@ mlir::Attribute ConstantEmitter::emitNullForMemory(mlir::Location loc, } static mlir::TypedAttr emitNullConstant(CIRGenModule &CGM, - const RecordDecl *record, + const RecordDecl *rd, bool asCompleteObject) { const CIRGenRecordLayout &layout = - CGM.getTypes().getCIRGenRecordLayout(record); + CGM.getTypes().getCIRGenRecordLayout(rd); mlir::Type ty = (asCompleteObject ? layout.getCIRType() : layout.getBaseSubobjectCIRType()); - auto structure = dyn_cast(ty); - assert(structure && "expected"); + auto record = dyn_cast(ty); + assert(record && "expected"); - unsigned numElements = structure.getNumElements(); + unsigned numElements = record.getNumElements(); SmallVector elements(numElements); - auto CXXR = dyn_cast(record); + auto CXXR = dyn_cast(rd); // Fill in all the bases. if (CXXR) { for (const auto &I : CXXR->bases()) { @@ -2113,7 +2113,7 @@ static mlir::TypedAttr emitNullConstant(CIRGenModule &CGM, } // Fill in all the fields. - for (const auto *Field : record->fields()) { + for (const auto *Field : rd->fields()) { // Fill in non-bitfields. (Bitfields always use a zero pattern, which we // will fill in later.) if (!Field->isBitField()) { @@ -2122,7 +2122,7 @@ static mlir::TypedAttr emitNullConstant(CIRGenModule &CGM, } // For unions, stop after the first named field. - if (record->isUnion()) { + if (rd->isUnion()) { if (Field->getIdentifier()) break; if (const auto *FieldRD = Field->getType()->getAsRecordDecl()) @@ -2145,8 +2145,8 @@ static mlir::TypedAttr emitNullConstant(CIRGenModule &CGM, } } - mlir::MLIRContext *mlirContext = structure.getContext(); - return cir::ConstStructAttr::get(mlirContext, structure, + mlir::MLIRContext *mlirContext = record.getContext(); + return cir::ConstRecordAttr::get(mlirContext, record, mlir::ArrayAttr::get(mlirContext, elements)); } diff --git a/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h b/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h index 3f442bad2e61..ce6fdaa5c196 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h +++ b/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h @@ -129,8 +129,8 @@ class CIRGenFunctionInfo final /// TODO: think about modeling this properly, this is just a dumb subsitution /// for now since we arent supporting anything other than arguments in /// registers atm - cir::StructType *ArgStruct; - unsigned ArgStructAlign : 31; + cir::RecordType *ArgRecord; + unsigned ArgRecordAlign : 31; unsigned HasExtParameterInfos : 1; unsigned NumArgs; @@ -275,10 +275,10 @@ class CIRGenFunctionInfo final return isVariadic() ? getRequiredArgs().getNumRequiredArgs() : arg_size(); } - cir::StructType *getArgStruct() const { return ArgStruct; } + cir::RecordType *getArgRecord() const { return ArgRecord; } /// Return true if this function uses inalloca arguments. - bool usesInAlloca() const { return ArgStruct; } + bool usesInAlloca() const { return ArgRecord; } }; } // namespace clang::CIRGen diff --git a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp b/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp index bb342648a9af..ba1e46085d36 100644 --- a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp @@ -2132,7 +2132,7 @@ void CIRGenItaniumCXXABI::emitVTableDefinitions(CIRGenVTables &CGVT, // Create and set the initializer. ConstantInitBuilder builder(CGM); - auto components = builder.beginStruct(); + auto components = builder.beginRecord(); CGVT.createVTableInitializer(components, VTLayout, RTTI, cir::isLocalLinkage(Linkage)); diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index 7663dd3d6a56..b6d2f0117802 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -955,7 +955,7 @@ static GlobalViewAttr createNewGlobalView(CIRGenModule &cgm, GlobalOp newGlob, bld.computeGlobalViewIndicesFromFlatOffset(offset, newTy, layout, newInds); cir::PointerType newPtrTy; - if (isa(oldTy)) + if (isa(oldTy)) newPtrTy = cir::PointerType::get(ctxt, newTy); else if (cir::ArrayType oldArTy = dyn_cast(oldTy)) newPtrTy = dyn_cast(attr.getType()); @@ -2171,7 +2171,7 @@ static bool isVarDeclStrongDefinition(const ASTContext &astContext, if (astContext.isAlignmentRequired(varType)) return true; - if (const auto *rt = varType->getAs()) { + if (const auto *rt = varType->getAs()) { const RecordDecl *rd = rt->getDecl(); for (const FieldDecl *fd : rd->fields()) { if (fd->isBitField()) @@ -3067,7 +3067,7 @@ cir::FuncOp CIRGenModule::GetOrCreateCIRFunction( } // This function doesn't have a complete type (for example, the return type is - // an incomplete struct). Use a fake type instead, and make sure not to try to + // an incomplete record). Use a fake type instead, and make sure not to try to // set attributes. bool isIncompleteFunction = false; @@ -4071,7 +4071,7 @@ CharUnits CIRGenModule::computeNonVirtualBaseClassOffset( const ASTRecordLayout &layout = astContext.getASTRecordLayout(rd); const auto *baseDecl = - cast(base->getType()->castAs()->getDecl()); + cast(base->getType()->castAs()->getDecl()); // Add the offset. offset += layout.getBaseClassOffset(baseDecl); diff --git a/clang/lib/CIR/CodeGen/CIRGenRecordLayout.h b/clang/lib/CIR/CodeGen/CIRGenRecordLayout.h index 19d48b886af3..f10322136d49 100644 --- a/clang/lib/CIR/CodeGen/CIRGenRecordLayout.h +++ b/clang/lib/CIR/CodeGen/CIRGenRecordLayout.h @@ -16,7 +16,7 @@ namespace clang::CIRGen { -/// Structure with information about how a bitfield should be accessed. This is +/// Record with information about how a bitfield should be accessed. This is /// very similar to what LLVM codegen does, once CIR evolves it's possible we /// can use a more higher level representation. /// TODO(cir): the comment below is extracted from LLVM, build a CIR version of @@ -31,7 +31,7 @@ namespace clang::CIRGen { /// Then accessing a particular bitfield involves converting this byte array /// into a single integer of that size (i24 or i40 -- may not be power-of-two /// size), loading it, and shifting and masking to extract the particular -/// subsequence of bits which make up that particular bitfield. This structure +/// subsequence of bits which make up that particular bitfield. This record /// encodes the information used to construct the extraction code sequences. /// The CIRGenRecordLayout also has a field index which encodes which /// byte-sequence this bitfield falls within. Let's assume the following C @@ -76,7 +76,7 @@ struct CIRGenBitFieldInfo { /// bitfield. unsigned StorageSize; - /// The offset of the bitfield storage from the start of the struct. + /// The offset of the bitfield storage from the start of the record. clang::CharUnits StorageOffset; /// The offset within a contiguous run of bitfields that are represented as a @@ -88,7 +88,7 @@ struct CIRGenBitFieldInfo { /// bitfield. unsigned VolatileStorageSize; - /// The offset of the bitfield storage from the start of the struct. + /// The offset of the bitfield storage from the start of the record. clang::CharUnits VolatileStorageOffset; /// The name of a bitfield @@ -119,7 +119,7 @@ struct CIRGenBitFieldInfo { clang::CharUnits StorageOffset); }; -/// This class handles struct and union layout info while lowering AST types +/// This class handles record and union layout info while lowering AST types /// to CIR types. /// /// These layout objects are only created on demand as CIR generation requires. @@ -132,17 +132,17 @@ class CIRGenRecordLayout { private: /// The CIR type corresponding to this record layout; used when laying it out /// as a complete object. - cir::StructType CompleteObjectType; + cir::RecordType CompleteObjectType; /// The CIR type for the non-virtual part of this record layout; used when /// laying it out as a base subobject. - cir::StructType BaseSubobjectType; + cir::RecordType BaseSubobjectType; - /// Map from (non-bit-field) struct field to the corresponding cir struct type + /// Map from (non-bit-field) record field to the corresponding cir record type /// field no. This info is populated by the record builder. llvm::DenseMap FieldInfo; - /// Map from (bit-field) struct field to the corresponding CIR struct type + /// Map from (bit-field) record field to the corresponding CIR record type /// field no. This info is populated by record builder. /// TODO(CIR): value is an int for now, fix when we support bitfields llvm::DenseMap BitFields; @@ -165,8 +165,8 @@ class CIRGenRecordLayout { bool IsZeroInitializableAsBase : 1; public: - CIRGenRecordLayout(cir::StructType CompleteObjectType, - cir::StructType BaseSubobjectType, + CIRGenRecordLayout(cir::RecordType CompleteObjectType, + cir::RecordType BaseSubobjectType, bool IsZeroInitializable, bool IsZeroInitializableAsBase) : CompleteObjectType(CompleteObjectType), BaseSubobjectType(BaseSubobjectType), @@ -175,20 +175,20 @@ class CIRGenRecordLayout { /// Return the "complete object" LLVM type associated with /// this record. - cir::StructType getCIRType() const { return CompleteObjectType; } + cir::RecordType getCIRType() const { return CompleteObjectType; } /// Return the "base subobject" LLVM type associated with /// this record. - cir::StructType getBaseSubobjectCIRType() const { return BaseSubobjectType; } + cir::RecordType getBaseSubobjectCIRType() const { return BaseSubobjectType; } - /// Return cir::StructType element number that corresponds to the field FD. + /// Return cir::RecordType element number that corresponds to the field FD. unsigned getCIRFieldNo(const clang::FieldDecl *FD) const { FD = FD->getCanonicalDecl(); assert(FieldInfo.count(FD) && "Invalid field for record!"); return FieldInfo.lookup(FD); } - /// Check whether this struct can be C++ zero-initialized with a + /// Check whether this record can be C++ zero-initialized with a /// zeroinitializer. bool isZeroInitializable() const { return IsZeroInitializable; } diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp index 715a5a38e074..f9d3569ab0aa 100644 --- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp @@ -81,7 +81,7 @@ std::string CIRGenTypes::getRecordTypeName(const clang::RecordDecl *recordDecl, /// Return true if the specified type is already completely laid out. bool CIRGenTypes::isRecordLayoutComplete(const Type *Ty) const { - llvm::DenseMap::const_iterator I = + llvm::DenseMap::const_iterator I = recordDeclTypes.find(Ty); return I != recordDeclTypes.end() && I->second.isComplete(); } @@ -97,7 +97,7 @@ static bool isSafeToConvert(const RecordDecl *RD, CIRGenTypes &CGT, llvm::SmallPtrSet &AlreadyChecked) { // If we have already checked this type (maybe the same type is used by-value - // multiple times in multiple structure fields, don't check again. + // multiple times in multiple record fields, don't check again. if (!AlreadyChecked.insert(RD).second) return true; @@ -133,7 +133,7 @@ isSafeToConvert(const RecordDecl *RD, CIRGenTypes &CGT, } /// Return true if it is safe to convert this field type, which requires the -/// structure elements contained by-value to all be recursively safe to convert. +/// record elements contained by-value to all be recursively safe to convert. static bool isSafeToConvert(QualType T, CIRGenTypes &CGT, llvm::SmallPtrSet &AlreadyChecked) { @@ -150,8 +150,8 @@ isSafeToConvert(QualType T, CIRGenTypes &CGT, return isSafeToConvert(AT->getElementType(), CGT, AlreadyChecked); // Otherwise, there is no concern about transforming this. We only care about - // things that are contained by-value in a structure that can have another - // structure as a member. + // things that are contained by-value in a record that can have another + // record as a member. return true; } @@ -159,7 +159,7 @@ isSafeToConvert(QualType T, CIRGenTypes &CGT, // it out, false if doing so would cause us to get into a recursive compilation // mess. static bool isSafeToConvert(const RecordDecl *RD, CIRGenTypes &CGT) { - // If no structs are being laid out, we can certainly do this one. + // If no records are being laid out, we can certainly do this one. if (CGT.noRecordsBeingLaidOut()) return true; @@ -167,17 +167,17 @@ static bool isSafeToConvert(const RecordDecl *RD, CIRGenTypes &CGT) { return isSafeToConvert(RD, CGT, AlreadyChecked); } -/// Lay out a tagged decl type like struct or union. +/// Lay out a tagged decl type like record or union. mlir::Type CIRGenTypes::convertRecordDeclType(const clang::RecordDecl *RD) { // TagDecl's are not necessarily unique, instead use the (clang) type // connected to the decl. const auto *key = astContext.getTagDeclType(RD).getTypePtr(); - cir::StructType entry = recordDeclTypes[key]; + cir::RecordType entry = recordDeclTypes[key]; // Handle forward decl / incomplete types. if (!entry) { auto name = getRecordTypeName(RD, ""); - entry = Builder.getIncompleteStructTy(name, RD); + entry = Builder.getIncompleteRecordTy(name, RD); recordDeclTypes[key] = entry; } @@ -194,7 +194,7 @@ mlir::Type CIRGenTypes::convertRecordDeclType(const clang::RecordDecl *RD) { // Okay, this is a definition of a type. Compile the implementation now. bool InsertResult = RecordsBeingLaidOut.insert(key).second; (void)InsertResult; - assert(InsertResult && "Recursively compiling a struct?"); + assert(InsertResult && "Recursively compiling a record?"); // Force conversion of non-virtual base classes recursively. if (const auto *cxxRecordDecl = dyn_cast(RD)) { @@ -210,19 +210,19 @@ mlir::Type CIRGenTypes::convertRecordDeclType(const clang::RecordDecl *RD) { recordDeclTypes[key] = entry; CIRGenRecordLayouts[key] = std::move(Layout); - // We're done laying out this struct. + // We're done laying out this record. bool EraseResult = RecordsBeingLaidOut.erase(key); (void)EraseResult; - assert(EraseResult && "struct not in RecordsBeingLaidOut set?"); + assert(EraseResult && "record not in RecordsBeingLaidOut set?"); - // If this struct blocked a FunctionType conversion, then recompute whatever + // If this record blocked a FunctionType conversion, then recompute whatever // was derived from that. // FIXME: This is hugely overconservative. if (SkippedLayout) TypeCache.clear(); // If we're done converting the outer-most record, then convert any deferred - // structs as well. + // records as well. if (RecordsBeingLaidOut.empty()) while (!DeferredRecords.empty()) convertRecordDeclType(DeferredRecords.pop_back_val()); @@ -255,7 +255,7 @@ mlir::Type CIRGenTypes::convertFunctionTypeInternal(QualType QFT) { const Type *Ty = QFT.getTypePtr(); const FunctionType *FT = cast(QFT.getTypePtr()); // First, check whether we can build the full function type. If the function - // type depends on an incomplete type (e.g. a struct or enum), we cannot lower + // type depends on an incomplete type (e.g. a record or enum), we cannot lower // the function type. assert(isFuncTypeConvertible(FT) && "NYI"); @@ -310,7 +310,7 @@ bool CIRGenTypes::isFuncParamTypeConvertible(clang::QualType Ty) { /// Code to verify a given function type is complete, i.e. the return type and /// all of the parameter types are complete. Also check to see if we are in a -/// RS_StructPointer context, and if so whether any struct types have been +/// RS_RecordPointer context, and if so whether any record types have been /// pended. If so, we don't want to ask the ABI lowering code to handle a type /// that cannot be converted to a CIR type. bool CIRGenTypes::isFuncTypeConvertible(const FunctionType *FT) { @@ -644,7 +644,7 @@ mlir::Type CIRGenTypes::convertType(QualType T) { assert(A->getIndexTypeCVRQualifiers() == 0 && "FIXME: We only handle trivial array types so far!"); // int X[] -> [0 x int], unless the element type is not sized. If it is - // unsized (e.g. an incomplete struct) just use [0 x i8]. + // unsized (e.g. an incomplete record) just use [0 x i8]. ResultType = convertTypeForMem(A->getElementType()); if (!Builder.isSized(ResultType)) { SkippedLayout = true; @@ -715,7 +715,7 @@ mlir::Type CIRGenTypes::convertType(QualType T) { auto memberTy = convertType(MPT->getPointeeType()); auto clsTy = - mlir::cast(convertType(QualType(MPT->getClass(), 0))); + mlir::cast(convertType(QualType(MPT->getClass(), 0))); if (MPT->isMemberDataPointer()) ResultType = cir::DataMemberType::get(Builder.getContext(), memberTy, clsTy); diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.h b/clang/lib/CIR/CodeGen/CIRGenTypes.h index 37a6e1cd1a09..084bc7c126b7 100644 --- a/clang/lib/CIR/CodeGen/CIRGenTypes.h +++ b/clang/lib/CIR/CodeGen/CIRGenTypes.h @@ -35,7 +35,7 @@ class FunctionType; class DataLayout; class Type; class LLVMContext; -class StructType; +class RecordType; } // namespace llvm namespace clang { @@ -65,7 +65,7 @@ class Type; } // namespace mlir namespace cir { -class StructType; +class RecordType; } // namespace cir namespace clang::CIRGen { @@ -93,7 +93,7 @@ class CIRGenTypes { CIRGenRecordLayouts; /// Contains the CIR type for any converted RecordDecl - llvm::DenseMap recordDeclTypes; + llvm::DenseMap recordDeclTypes; /// Hold memoized CIRGenFunctionInfo results llvm::FoldingSet FunctionInfos; @@ -106,7 +106,7 @@ class CIRGenTypes { llvm::SmallPtrSet FunctionsBeingProcessed; - /// True if we didn't layout a function due to being inside a recursive struct + /// True if we didn't layout a function due to being inside a recursive record /// conversion, set this to true. bool SkippedLayout; @@ -170,7 +170,7 @@ class CIRGenTypes { mlir::Type convertRecordDeclType(const clang::RecordDecl *recordDecl); std::unique_ptr - computeRecordLayout(const clang::RecordDecl *D, cir::StructType *Ty); + computeRecordLayout(const clang::RecordDecl *D, cir::RecordType *Ty); std::string getRecordTypeName(const clang::RecordDecl *, llvm::StringRef suffix); diff --git a/clang/lib/CIR/CodeGen/CIRGenVTables.cpp b/clang/lib/CIR/CodeGen/CIRGenVTables.cpp index 81f7971ac787..6a4e534c09f3 100644 --- a/clang/lib/CIR/CodeGen/CIRGenVTables.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenVTables.cpp @@ -63,7 +63,7 @@ mlir::Type CIRGenVTables::getVTableType(const VTableLayout &layout) { // FIXME(cir): should VTableLayout be encoded like we do for some // AST nodes? - return CGM.getBuilder().getAnonStructTy(tys, /*incomplete=*/false); + return CGM.getBuilder().getAnonRecordTy(tys, /*incomplete=*/false); } /// At this point in the translation unit, does it appear that can we @@ -304,7 +304,7 @@ void CIRGenVTables::addVTableComponent(ConstantArrayBuilder &builder, llvm_unreachable("Unexpected vtable component kind"); } -void CIRGenVTables::createVTableInitializer(ConstantStructBuilder &builder, +void CIRGenVTables::createVTableInitializer(ConstantRecordBuilder &builder, const VTableLayout &layout, mlir::Attribute rtti, bool vtableHasLocalLinkage) { @@ -377,7 +377,7 @@ cir::GlobalOp CIRGenVTables::generateConstructionVTable( // Create and set the initializer. ConstantInitBuilder builder(CGM); - auto components = builder.beginStruct(); + auto components = builder.beginRecord(); createVTableInitializer(components, *VTLayout, RTTI, cir::isLocalLinkage(VTable.getLinkage())); components.finishAndSetAsInitializer(VTable); diff --git a/clang/lib/CIR/CodeGen/CIRGenVTables.h b/clang/lib/CIR/CodeGen/CIRGenVTables.h index 639eb370ca0e..451ea2cbec4f 100644 --- a/clang/lib/CIR/CodeGen/CIRGenVTables.h +++ b/clang/lib/CIR/CodeGen/CIRGenVTables.h @@ -69,7 +69,7 @@ class CIRGenVTables { public: /// Add vtable components for the given vtable layout to the given /// global initializer. - void createVTableInitializer(ConstantStructBuilder &builder, + void createVTableInitializer(ConstantRecordBuilder &builder, const VTableLayout &layout, mlir::Attribute rtti, bool vtableHasLocalLinkage); diff --git a/clang/lib/CIR/CodeGen/CIRRecordLayoutBuilder.cpp b/clang/lib/CIR/CodeGen/CIRRecordLayoutBuilder.cpp index e179cf5f89ca..231051042502 100644 --- a/clang/lib/CIR/CodeGen/CIRRecordLayoutBuilder.cpp +++ b/clang/lib/CIR/CodeGen/CIRRecordLayoutBuilder.cpp @@ -293,7 +293,7 @@ void CIRRecordLowering::lower(bool nonVirtualBaseType) { llvm::stable_sort(members); // TODO: implement clipTailPadding once bitfields are implemented - // TODO: implemented packed structs + // TODO: implemented packed records // TODO: implement padding // TODO: support zeroInit @@ -694,13 +694,13 @@ void CIRRecordLowering::insertPadding() { } std::unique_ptr -CIRGenTypes::computeRecordLayout(const RecordDecl *D, cir::StructType *Ty) { +CIRGenTypes::computeRecordLayout(const RecordDecl *D, cir::RecordType *Ty) { CIRRecordLowering builder(*this, D, /*packed=*/false); assert(Ty->isIncomplete() && "recomputing record layout?"); builder.lower(/*nonVirtualBaseType=*/false); // If we're in C++, compute the base subobject type. - cir::StructType BaseTy; + cir::RecordType BaseTy; if (llvm::isa(D) && !D->isUnion() && !D->hasAttr()) { BaseTy = *Ty; @@ -709,7 +709,7 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *D, cir::StructType *Ty) { CIRRecordLowering baseBuilder(*this, D, /*Packed=*/builder.isPacked); baseBuilder.lower(/*NonVirtualBaseType=*/true); auto baseIdentifier = getRecordTypeName(D, ".base"); - BaseTy = Builder.getCompleteStructTy(baseBuilder.fieldTypes, + BaseTy = Builder.getCompleteRecordTy(baseBuilder.fieldTypes, baseIdentifier, baseBuilder.isPacked, baseBuilder.isPadded, D); // TODO(cir): add something like addRecordTypeName @@ -721,14 +721,14 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *D, cir::StructType *Ty) { } } - // Fill in the struct *after* computing the base type. Filling in the body + // Fill in the record *after* computing the base type. Filling in the body // signifies that the type is no longer opaque and record layout is complete, // but we may need to recursively layout D while laying D out as a base type. auto astAttr = cir::ASTRecordDeclAttr::get(Ty->getContext(), D); Ty->complete(builder.fieldTypes, builder.isPacked, builder.isPadded, astAttr); auto RL = std::make_unique( - Ty ? *Ty : cir::StructType{}, BaseTy ? BaseTy : cir::StructType{}, + Ty ? *Ty : cir::RecordType{}, BaseTy ? BaseTy : cir::RecordType{}, (bool)builder.IsZeroInitializable, (bool)builder.IsZeroInitializableAsBase); diff --git a/clang/lib/CIR/CodeGen/ConstantInitBuilder.cpp b/clang/lib/CIR/CodeGen/ConstantInitBuilder.cpp index b0b146e12e2c..1ef96e73d113 100644 --- a/clang/lib/CIR/CodeGen/ConstantInitBuilder.cpp +++ b/clang/lib/CIR/CodeGen/ConstantInitBuilder.cpp @@ -300,8 +300,8 @@ mlir::Attribute ConstantAggregateBuilderBase::finishArray(mlir::Type eltTy) { } mlir::Attribute -ConstantAggregateBuilderBase::finishStruct(mlir::MLIRContext *mlirContext, - cir::StructType ty) { +ConstantAggregateBuilderBase::finishRecord(mlir::MLIRContext *mlirContext, + cir::RecordType ty) { markFinished(); auto &buffer = getBuffer(); @@ -318,7 +318,7 @@ ConstantAggregateBuilderBase::finishStruct(mlir::MLIRContext *mlirContext, // constant = llvm::ConstantStruct::get(ty, elts); } else { const auto members = mlir::ArrayAttr::get(mlirContext, elts); - constant = Builder.CGM.getBuilder().getAnonConstStruct(members, Packed); + constant = Builder.CGM.getBuilder().getAnonConstRecord(members, Packed); } buffer.erase(buffer.begin() + Begin, buffer.end()); diff --git a/clang/lib/CIR/CodeGen/ConstantInitBuilder.h b/clang/lib/CIR/CodeGen/ConstantInitBuilder.h index d3a8c0abd308..f7fe2b7c6e72 100644 --- a/clang/lib/CIR/CodeGen/ConstantInitBuilder.h +++ b/clang/lib/CIR/CodeGen/ConstantInitBuilder.h @@ -36,11 +36,11 @@ class CIRGenModule; /// /// The basic usage pattern is expected to be something like: /// ConstantInitBuilder builder(CGM); -/// auto toplevel = builder.beginStruct(); +/// auto toplevel = builder.beginRecord(); /// toplevel.addInt(CGM.SizeTy, widgets.size()); /// auto widgetArray = builder.beginArray(); /// for (auto &widget : widgets) { -/// auto widgetDesc = widgetArray.beginStruct(); +/// auto widgetDesc = widgetArray.beginRecord(); /// widgetDesc.addInt(CGM.SizeTy, widget.getPower()); /// widgetDesc.add(CGM.GetAddrOfConstantString(widget.getName())); /// widgetDesc.add(CGM.GetAddrOfGlobal(widget.getInitializerDecl())); @@ -90,7 +90,7 @@ class ConstantInitBuilderBase { void abandon(size_t newEnd); }; -/// A concrete base class for struct and array aggregate +/// A concrete base class for record and array aggregate /// initializer builders. class ConstantAggregateBuilderBase { protected: @@ -157,7 +157,7 @@ class ConstantAggregateBuilderBase { operator=(ConstantAggregateBuilderBase &&other) = delete; /// Return the number of elements that have been added to - /// this struct or array. + /// this record or array. size_t size() const { assert(!this->Finished && "cannot query after finishing builder"); assert(!this->Frozen && "cannot query while sub-builder is active"); @@ -165,7 +165,7 @@ class ConstantAggregateBuilderBase { return this->getBuffer().size() - this->Begin; } - /// Return true if no elements have yet been added to this struct or array. + /// Return true if no elements have yet been added to this record or array. bool empty() const { return size() == 0; } /// Abandon this builder completely. @@ -265,14 +265,14 @@ class ConstantAggregateBuilderBase { PlaceholderPosition(size_t index) : Index(index) {} }; - /// Add a placeholder value to the structure. The returned position + /// Add a placeholder value to the record. The returned position /// can be used to set the value later; it will not be invalidated by /// any intermediate operations except (1) filling the same position or /// (2) finishing the entire builder. /// - /// This is useful for emitting certain kinds of structure which + /// This is useful for emitting certain kinds of record which /// contain some sort of summary field, generally a count, before any - /// of the data. By emitting a placeholder first, the structure can + /// of the data. By emitting a placeholder first, the record can /// be emitted eagerly. PlaceholderPosition addPlaceholder() { assert(!Finished && "cannot add more values after finishing builder"); @@ -324,8 +324,8 @@ class ConstantAggregateBuilderBase { protected: mlir::Attribute finishArray(mlir::Type eltTy); - mlir::Attribute finishStruct(mlir::MLIRContext *mlirContext, - cir::StructType structTy); + mlir::Attribute finishRecord(mlir::MLIRContext *mlirContext, + cir::RecordType recordTy); private: void getGEPIndicesTo(llvm::SmallVectorImpl &indices, @@ -349,7 +349,7 @@ class ConstantAggregateBuilderTemplateBase public: using InitBuilder = typename Traits::InitBuilder; using ArrayBuilder = typename Traits::ArrayBuilder; - using StructBuilder = typename Traits::StructBuilder; + using RecordBuilder = typename Traits::RecordBuilder; using AggregateBuilderBase = typename Traits::AggregateBuilderBase; protected: @@ -364,12 +364,12 @@ class ConstantAggregateBuilderTemplateBase return ArrayBuilder(static_cast(this->Builder), this, eltTy); } - StructBuilder beginStruct(cir::StructType ty = nullptr) { - return StructBuilder(static_cast(this->Builder), this, ty); + RecordBuilder beginRecord(cir::RecordType ty = nullptr) { + return RecordBuilder(static_cast(this->Builder), this, ty); } - /// Given that this builder was created by beginning an array or struct - /// component on the given parent builder, finish the array/struct + /// Given that this builder was created by beginning an array or record + /// component on the given parent builder, finish the array/record /// component and add it to the parent. /// /// It is an intentional choice that the parent is passed in explicitly @@ -383,8 +383,8 @@ class ConstantAggregateBuilderTemplateBase parent.add(asImpl().finishImpl(mlirContext)); } - /// Given that this builder was created by beginning an array or struct - /// directly on a ConstantInitBuilder, finish the array/struct and + /// Given that this builder was created by beginning an array or record + /// directly on a ConstantInitBuilder, finish the array/record and /// create a global variable with it as the initializer. template cir::GlobalOp finishAndCreateGlobal(mlir::MLIRContext *mlirContext, @@ -394,23 +394,23 @@ class ConstantAggregateBuilderTemplateBase std::forward(args)...); } - /// Given that this builder was created by beginning an array or struct - /// directly on a ConstantInitBuilder, finish the array/struct and + /// Given that this builder was created by beginning an array or record + /// directly on a ConstantInitBuilder, finish the array/record and /// set it as the initializer of the given global variable. void finishAndSetAsInitializer(cir::GlobalOp global, bool forVTable = false) { assert(!this->Parent && "finishing non-root builder"); mlir::Attribute init = asImpl().finishImpl(global.getContext()); - auto initCSA = mlir::dyn_cast(init); + auto initCSA = mlir::dyn_cast(init); assert(initCSA && - "expected #cir.const_struct attribute to represent vtable data"); + "expected #cir.const_record attribute to represent vtable data"); return this->Builder.setGlobalInitializer( global, forVTable ? cir::VTableAttr::get(initCSA.getType(), initCSA.getMembers()) : init); } - /// Given that this builder was created by beginning an array or struct - /// directly on a ConstantInitBuilder, finish the array/struct and + /// Given that this builder was created by beginning an array or record + /// directly on a ConstantInitBuilder, finish the array/record and /// return a future which can be used to install the initializer in /// a global later. /// @@ -460,11 +460,11 @@ class ConstantArrayBuilderTemplateBase /// prefer. This would probably not be necessary if C++ just /// supported extension methods. template -class ConstantStructBuilderTemplateBase +class ConstantRecordBuilderTemplateBase : public ConstantAggregateBuilderTemplateBase< - typename Traits::StructBuilder, Traits> { + typename Traits::RecordBuilder, Traits> { using super = - ConstantAggregateBuilderTemplateBase; public: @@ -472,29 +472,29 @@ class ConstantStructBuilderTemplateBase using AggregateBuilderBase = typename Traits::AggregateBuilderBase; private: - cir::StructType StructTy; + cir::RecordType RecordTy; template friend class ConstantAggregateBuilderTemplateBase; protected: - ConstantStructBuilderTemplateBase(InitBuilder &builder, + ConstantRecordBuilderTemplateBase(InitBuilder &builder, AggregateBuilderBase *parent, - cir::StructType structTy) - : super(builder, parent), StructTy(structTy) { - if (structTy) { + cir::RecordType recordTy) + : super(builder, parent), RecordTy(recordTy) { + if (recordTy) { llvm_unreachable("NYI"); - // this->Packed = structTy->isPacked(); + // this->Packed = recordTy->isPacked(); } } public: void setPacked(bool packed) { this->Packed = packed; } - /// Use the given type for the struct if its element count is correct. + /// Use the given type for the record if its element count is correct. /// Don't add more elements after calling this. - void suggestType(cir::StructType structTy) { - if (this->size() == structTy.getNumElements()) { - StructTy = structTy; + void suggestType(cir::RecordType recordTy) { + if (this->size() == recordTy.getNumElements()) { + RecordTy = recordTy; } } @@ -502,7 +502,7 @@ class ConstantStructBuilderTemplateBase /// Form an array constant from the values that have been added to this /// builder. mlir::Attribute finishImpl(mlir::MLIRContext *mlirContext) { - return AggregateBuilderBase::finishStruct(mlirContext, StructTy); + return AggregateBuilderBase::finishRecord(mlirContext, RecordTy); } }; @@ -520,26 +520,26 @@ class ConstantInitBuilderTemplateBase : public ConstantInitBuilderBase { public: using InitBuilder = typename Traits::InitBuilder; using ArrayBuilder = typename Traits::ArrayBuilder; - using StructBuilder = typename Traits::StructBuilder; + using RecordBuilder = typename Traits::RecordBuilder; ArrayBuilder beginArray(mlir::Type eltTy = nullptr) { return ArrayBuilder(static_cast(*this), nullptr, eltTy); } - StructBuilder beginStruct(cir::StructType structTy = nullptr) { - return StructBuilder(static_cast(*this), nullptr, structTy); + RecordBuilder beginRecord(cir::RecordType recordTy = nullptr) { + return RecordBuilder(static_cast(*this), nullptr, recordTy); } }; class ConstantInitBuilder; -class ConstantStructBuilder; +class ConstantRecordBuilder; class ConstantArrayBuilder; struct ConstantInitBuilderTraits { using InitBuilder = ConstantInitBuilder; using AggregateBuilderBase = ConstantAggregateBuilderBase; using ArrayBuilder = ConstantArrayBuilder; - using StructBuilder = ConstantStructBuilder; + using RecordBuilder = ConstantRecordBuilder; }; /// The standard implementation of ConstantInitBuilder used in Clang. @@ -566,19 +566,19 @@ class ConstantArrayBuilder }; /// A helper class of ConstantInitBuilder, used for building constant -/// struct initializers. -class ConstantStructBuilder - : public ConstantStructBuilderTemplateBase { +/// record initializers. +class ConstantRecordBuilder + : public ConstantRecordBuilderTemplateBase { template friend class ConstantInitBuilderTemplateBase; // The use of explicit qualification is a GCC workaround. template friend class ConstantAggregateBuilderTemplateBase; - ConstantStructBuilder(ConstantInitBuilder &builder, + ConstantRecordBuilder(ConstantInitBuilder &builder, ConstantAggregateBuilderBase *parent, - cir::StructType structTy) - : ConstantStructBuilderTemplateBase(builder, parent, structTy) {} + cir::RecordType recordTy) + : ConstantRecordBuilderTemplateBase(builder, parent, recordTy) {} }; } // namespace clang::CIRGen diff --git a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp index 32ceb0096d71..19da8f32519c 100644 --- a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp @@ -34,8 +34,8 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/ExprCXX.h" -static void printStructMembers(mlir::AsmPrinter &p, mlir::ArrayAttr members); -static mlir::ParseResult parseStructMembers(::mlir::AsmParser &parser, +static void printRecordMembers(mlir::AsmPrinter &p, mlir::ArrayAttr members); +static mlir::ParseResult parseRecordMembers(::mlir::AsmParser &parser, mlir::ArrayAttr &members); static void printFloatLiteral(mlir::AsmPrinter &p, llvm::APFloat value, @@ -110,14 +110,14 @@ void CIRDialect::printAttribute(Attribute attr, DialectAsmPrinter &os) const { llvm_unreachable("unexpected CIR type kind"); } -static void printStructMembers(mlir::AsmPrinter &printer, +static void printRecordMembers(mlir::AsmPrinter &printer, mlir::ArrayAttr members) { printer << '{'; llvm::interleaveComma(members, printer); printer << '}'; } -static ParseResult parseStructMembers(mlir::AsmParser &parser, +static ParseResult parseRecordMembers(mlir::AsmParser &parser, mlir::ArrayAttr &members) { llvm::SmallVector elts; @@ -137,12 +137,12 @@ static ParseResult parseStructMembers(mlir::AsmParser &parser, return mlir::success(); } -LogicalResult ConstStructAttr::verify( +LogicalResult ConstRecordAttr::verify( ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, mlir::Type type, ArrayAttr members) { - auto sTy = mlir::dyn_cast_if_present(type); + auto sTy = mlir::dyn_cast_if_present(type); if (!sTy) { - emitError() << "expected !cir.struct type"; + emitError() << "expected !cir.record type"; return failure(); } @@ -170,7 +170,7 @@ LogicalResult ConstStructAttr::verify( return success(); } -LogicalResult StructLayoutAttr::verify( +LogicalResult RecordLayoutAttr::verify( ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, unsigned size, unsigned alignment, bool padded, mlir::Type largest_member, mlir::ArrayAttr offsets) { @@ -447,21 +447,21 @@ DataMemberAttr::verify(function_ref emitError, return success(); } - auto clsStructTy = ty.getClsTy(); - if (clsStructTy.isIncomplete()) { - emitError() << "incomplete 'cir.struct' cannot be used to build a non-null " + auto clsRecordTy = ty.getClsTy(); + if (clsRecordTy.isIncomplete()) { + emitError() << "incomplete 'cir.record' cannot be used to build a non-null " "data member pointer"; return failure(); } auto memberIndexValue = memberIndex.value(); - if (memberIndexValue >= clsStructTy.getNumElements()) { + if (memberIndexValue >= clsRecordTy.getNumElements()) { emitError() << "member index of a #cir.data_member attribute is out of range"; return failure(); } - auto memberTy = clsStructTy.getMembers()[memberIndexValue]; + auto memberTy = clsRecordTy.getMembers()[memberIndexValue]; if (memberTy != ty.getMemberTy()) { emitError() << "member type of a #cir.data_member attribute must match the " "attribute type"; diff --git a/clang/lib/CIR/Dialect/IR/CIRDataLayout.cpp b/clang/lib/CIR/Dialect/IR/CIRDataLayout.cpp index 0ccebdccf6a7..f3bf19934192 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDataLayout.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDataLayout.cpp @@ -7,12 +7,12 @@ using namespace cir; //===----------------------------------------------------------------------===// -// Support for StructLayout +// Support for RecordLayout //===----------------------------------------------------------------------===// -StructLayout::StructLayout(cir::StructType ST, const CIRDataLayout &DL) - : StructSize(llvm::TypeSize::getFixed(0)) { - assert(!ST.isIncomplete() && "Cannot get layout of opaque structs"); +RecordLayout::RecordLayout(cir::RecordType ST, const CIRDataLayout &DL) + : RecordSize(llvm::TypeSize::getFixed(0)) { + assert(!ST.isIncomplete() && "Cannot get layout of opaque records"); IsPadded = false; NumElements = ST.getNumElements(); @@ -23,43 +23,43 @@ StructLayout::StructLayout(cir::StructType ST, const CIRDataLayout &DL) llvm_unreachable("Scalable types are not yet supported in CIR"); assert(!cir::MissingFeatures::recordDeclIsPacked() && - "Cannot identify packed structs"); + "Cannot identify packed records"); const llvm::Align TyAlign = ST.getPacked() ? llvm::Align(1) : DL.getABITypeAlign(Ty); // Add padding if necessary to align the data element properly. - // Currently the only structure with scalable size will be the homogeneous + // Currently the only record with scalable size will be the homogeneous // scalable vector types. Homogeneous scalable vector types have members of // the same data type so no alignment issue will happen. The condition here // assumes so and needs to be adjusted if this assumption changes (e.g. we - // support structures with arbitrary scalable data type, or structure that + // support records with arbitrary scalable data type, or record that // contains both fixed size and scalable size data type members). - if (!StructSize.isScalable() && !isAligned(TyAlign, StructSize)) { + if (!RecordSize.isScalable() && !isAligned(TyAlign, RecordSize)) { IsPadded = true; - StructSize = llvm::TypeSize::getFixed(alignTo(StructSize, TyAlign)); + RecordSize = llvm::TypeSize::getFixed(alignTo(RecordSize, TyAlign)); } // Keep track of maximum alignment constraint. - StructAlignment = std::max(TyAlign, StructAlignment); + RecordAlignment = std::max(TyAlign, RecordAlignment); - getMemberOffsets()[i] = StructSize; + getMemberOffsets()[i] = RecordSize; // Consume space for this data item - StructSize += DL.getTypeAllocSize(Ty); + RecordSize += DL.getTypeAllocSize(Ty); } - // Add padding to the end of the struct so that it could be put in an array + // Add padding to the end of the record so that it could be put in an array // and all array elements would be aligned correctly. - if (!StructSize.isScalable() && !isAligned(StructAlignment, StructSize)) { + if (!RecordSize.isScalable() && !isAligned(RecordAlignment, RecordSize)) { IsPadded = true; - StructSize = llvm::TypeSize::getFixed(alignTo(StructSize, StructAlignment)); + RecordSize = llvm::TypeSize::getFixed(alignTo(RecordSize, RecordAlignment)); } } -/// getElementContainingOffset - Given a valid offset into the structure, -/// return the structure index that contains it. -unsigned StructLayout::getElementContainingOffset(uint64_t FixedOffset) const { - assert(!StructSize.isScalable() && - "Cannot get element at offset for structure containing scalable " +/// getElementContainingOffset - Given a valid offset into the record, +/// return the record index that contains it. +unsigned RecordLayout::getElementContainingOffset(uint64_t FixedOffset) const { + assert(!RecordSize.isScalable() && + "Cannot get element at offset for record containing scalable " "vector types"); llvm::TypeSize Offset = llvm::TypeSize::getFixed(FixedOffset); llvm::ArrayRef MemberOffsets = getMemberOffsets(); @@ -69,7 +69,7 @@ unsigned StructLayout::getElementContainingOffset(uint64_t FixedOffset) const { [](llvm::TypeSize LHS, llvm::TypeSize RHS) -> bool { return llvm::TypeSize::isKnownLT(LHS, RHS); }); - assert(SI != MemberOffsets.begin() && "Offset not in structure type!"); + assert(SI != MemberOffsets.begin() && "Offset not in record type!"); --SI; assert(llvm::TypeSize::isKnownLE(*SI, Offset) && "upper_bound didn't work"); assert((SI == MemberOffsets.begin() || @@ -92,21 +92,21 @@ unsigned StructLayout::getElementContainingOffset(uint64_t FixedOffset) const { namespace { -class StructLayoutMap { - using LayoutInfoTy = llvm::DenseMap; +class RecordLayoutMap { + using LayoutInfoTy = llvm::DenseMap; LayoutInfoTy LayoutInfo; public: - ~StructLayoutMap() { + ~RecordLayoutMap() { // Remove any layouts. for (const auto &I : LayoutInfo) { - StructLayout *Value = I.second; - Value->~StructLayout(); + RecordLayout *Value = I.second; + Value->~RecordLayout(); free(Value); } } - StructLayout *&operator[](cir::StructType STy) { return LayoutInfo[STy]; } + RecordLayout *&operator[](cir::RecordType STy) { return LayoutInfo[STy]; } }; } // namespace @@ -142,7 +142,7 @@ void CIRDataLayout::reset(mlir::DataLayoutSpecInterface spec) { // ManglingMode = MM_None; // NonIntegralAddressSpaces.clear(); - StructAlignment = + RecordAlignment = llvm::DataLayout::PrimitiveSpec{0, llvm::Align(1), llvm::Align(8)}; // NOTE(cir): Alignment setter functions are skipped as these should already @@ -150,29 +150,29 @@ void CIRDataLayout::reset(mlir::DataLayoutSpecInterface spec) { } void CIRDataLayout::clear() { - delete static_cast(LayoutMap); + delete static_cast(LayoutMap); LayoutMap = nullptr; } -const StructLayout *CIRDataLayout::getStructLayout(cir::StructType Ty) const { +const RecordLayout *CIRDataLayout::getRecordLayout(cir::RecordType Ty) const { if (!LayoutMap) - LayoutMap = new StructLayoutMap(); + LayoutMap = new RecordLayoutMap(); - StructLayoutMap *STM = static_cast(LayoutMap); - StructLayout *&SL = (*STM)[Ty]; + RecordLayoutMap *STM = static_cast(LayoutMap); + RecordLayout *&SL = (*STM)[Ty]; if (SL) return SL; - // Otherwise, create the struct layout. Because it is variable length, we + // Otherwise, create the record layout. Because it is variable length, we // malloc it, then use placement new. - StructLayout *L = (StructLayout *)llvm::safe_malloc( - StructLayout::totalSizeToAlloc(Ty.getNumElements())); + RecordLayout *L = (RecordLayout *)llvm::safe_malloc( + RecordLayout::totalSizeToAlloc(Ty.getNumElements())); - // Set SL before calling StructLayout's ctor. The ctor could cause other + // Set SL before calling RecordLayout's ctor. The ctor could cause other // entries to be added to TheMap, invalidating our reference. SL = L; - new (L) StructLayout(Ty, *this); + new (L) RecordLayout(Ty, *this); return L; } @@ -187,20 +187,20 @@ const StructLayout *CIRDataLayout::getStructLayout(cir::StructType Ty) const { */ llvm::Align CIRDataLayout::getAlignment(mlir::Type Ty, bool abiOrPref) const { - if (llvm::isa(Ty)) { - // Packed structure types always have an ABI alignment of one. + if (llvm::isa(Ty)) { + // Packed record types always have an ABI alignment of one. if (cir::MissingFeatures::recordDeclIsPacked() && abiOrPref) llvm_unreachable("NYI"); - auto stTy = llvm::dyn_cast(Ty); + auto stTy = llvm::dyn_cast(Ty); if (stTy && stTy.getPacked() && abiOrPref) return llvm::Align(1); // Get the layout annotation... which is lazily created on demand. - const StructLayout *Layout = - getStructLayout(llvm::cast(Ty)); + const RecordLayout *Layout = + getRecordLayout(llvm::cast(Ty)); const llvm::Align Align = - abiOrPref ? StructAlignment.ABIAlign : StructAlignment.PrefAlign; + abiOrPref ? RecordAlignment.ABIAlign : RecordAlignment.PrefAlign; return std::max(Align, Layout->getAlignment()); } @@ -220,10 +220,10 @@ llvm::TypeSize CIRDataLayout::getTypeSizeInBits(mlir::Type Ty) const { assert(!cir::MissingFeatures::typeIsSized() && "Cannot getTypeInfo() on a type that is unsized!"); - if (auto structTy = llvm::dyn_cast(Ty)) { - // FIXME(cir): CIR struct's data layout implementation doesn't do a good job + if (auto recordTy = llvm::dyn_cast(Ty)) { + // FIXME(cir): CIR record's data layout implementation doesn't do a good job // of handling unions particularities. We should have a separate union type. - return structTy.getTypeSizeInBits(layout, {}); + return recordTy.getTypeSizeInBits(layout, {}); } // FIXME(cir): This does not account for different address spaces, and relies diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index 2a441afbe08e..3740eb73f97c 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -60,10 +60,10 @@ struct CIROpAsmDialectInterface : public OpAsmDialectInterface { using OpAsmDialectInterface::OpAsmDialectInterface; AliasResult getAlias(Type type, raw_ostream &os) const final { - if (auto structType = dyn_cast(type)) { - StringAttr nameAttr = structType.getName(); + if (auto recordType = dyn_cast(type)) { + StringAttr nameAttr = recordType.getName(); if (!nameAttr) - os << "ty_anon_" << structType.getKindAsStr(); + os << "ty_anon_" << recordType.getKindAsStr(); else os << "ty_" << nameAttr.getValue(); return AliasResult::OverridableAlias; @@ -392,10 +392,10 @@ static LogicalResult checkConstantTypes(mlir::Operation *op, mlir::Type opType, } if (isa(attrType)) { - if (::mlir::isa(opType)) return success(); - return op->emitOpError("zero expects struct or array type"); + return op->emitOpError("zero expects record or array type"); } if (isa(attrType)) { @@ -437,7 +437,7 @@ static LogicalResult checkConstantTypes(mlir::Operation *op, mlir::Type opType, mlir::isa(attrType) || mlir::isa(attrType) || mlir::isa(attrType) || - mlir::isa(attrType) || + mlir::isa(attrType) || mlir::isa(attrType)) return success(); if (mlir::isa(attrType)) @@ -551,8 +551,8 @@ LogicalResult cir::CastOp::verify() { return success(); } case cir::CastKind::bitcast: { - // Allow bitcast of structs for calling conventions. - if (isa(srcType) || isa(resType)) + // Allow bitcast of records for calling conventions. + if (isa(srcType) || isa(resType)) return success(); // Handle the pointer types first. @@ -854,9 +854,9 @@ OpFoldResult cir::UnaryOp::fold(FoldAdaptor adaptor) { LogicalResult cir::DynamicCastOp::verify() { auto resultPointeeTy = mlir::cast(getType()).getPointee(); - if (!mlir::isa(resultPointeeTy)) + if (!mlir::isa(resultPointeeTy)) return emitOpError() - << "cir.dyn_cast must produce a void ptr or struct ptr"; + << "cir.dyn_cast must produce a void ptr or record ptr"; return mlir::success(); } @@ -3526,7 +3526,7 @@ LogicalResult cir::TypeInfoAttr::verify( ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type type, ::mlir::ArrayAttr typeinfoData) { - if (cir::ConstStructAttr::verify(emitError, type, typeinfoData).failed()) + if (cir::ConstRecordAttr::verify(emitError, type, typeinfoData).failed()) return failure(); for (auto &member : typeinfoData) { @@ -3542,13 +3542,13 @@ LogicalResult cir::TypeInfoAttr::verify( LogicalResult cir::VTableAttr::verify( ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type type, ::mlir::ArrayAttr vtableData) { - auto sTy = mlir::dyn_cast_if_present(type); + auto sTy = mlir::dyn_cast_if_present(type); if (!sTy) { - emitError() << "expected !cir.struct type result"; + emitError() << "expected !cir.record type result"; return failure(); } if (sTy.getMembers().empty() || vtableData.empty()) { - emitError() << "expected struct type with one or more subtype"; + emitError() << "expected record type with one or more subtype"; return failure(); } @@ -3557,11 +3557,11 @@ LogicalResult cir::VTableAttr::verify( auto arrayTy = mlir::dyn_cast(sTy.getMembers()[i]); auto constArrayAttr = mlir::dyn_cast(vtableData[i]); if (!arrayTy || !constArrayAttr) { - emitError() << "expected struct type with one array element"; + emitError() << "expected record type with one array element"; return failure(); } - if (cir::ConstStructAttr::verify(emitError, type, vtableData).failed()) + if (cir::ConstRecordAttr::verify(emitError, type, vtableData).failed()) return failure(); LogicalResult eltTypeCheck = success(); @@ -3606,7 +3606,7 @@ LogicalResult cir::CopyOp::verify() { LogicalResult cir::GetMemberOp::verify() { - const auto recordTy = dyn_cast(getAddrTy().getPointee()); + const auto recordTy = dyn_cast(getAddrTy().getPointee()); if (!recordTy) return emitError() << "expected pointer to a record type"; @@ -3627,8 +3627,8 @@ LogicalResult cir::GetMemberOp::verify() { //===----------------------------------------------------------------------===// LogicalResult cir::ExtractMemberOp::verify() { - auto recordTy = mlir::cast(getRecord().getType()); - if (recordTy.getKind() == cir::StructType::Union) + auto recordTy = mlir::cast(getRecord().getType()); + if (recordTy.getKind() == cir::RecordType::Union) return emitError() << "cir.extract_member currently does not work on unions"; if (recordTy.getMembers().size() <= getIndex()) @@ -3643,8 +3643,8 @@ LogicalResult cir::ExtractMemberOp::verify() { //===----------------------------------------------------------------------===// LogicalResult cir::InsertMemberOp::verify() { - auto recordTy = mlir::cast(getRecord().getType()); - if (recordTy.getKind() == cir::StructType::Union) + auto recordTy = mlir::cast(getRecord().getType()); + if (recordTy.getKind() == cir::RecordType::Union) return emitError() << "cir.update_member currently does not work on unions"; if (recordTy.getMembers().size() <= getIndex()) return emitError() << "member index out of range"; @@ -3660,7 +3660,7 @@ LogicalResult cir::InsertMemberOp::verify() { LogicalResult cir::GetRuntimeMemberOp::verify() { auto recordTy = - cast(cast(getAddr().getType()).getPointee()); + cast(cast(getAddr().getType()).getPointee()); auto memberPtrTy = getMember().getType(); if (recordTy != memberPtrTy.getClsTy()) { diff --git a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp index 71dd1ef771b2..3ba3ae1541a6 100644 --- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp @@ -81,7 +81,7 @@ Type CIRDialect::parseType(DialectAsmParser &parser) const { // Type is not tablegen'd: try to parse as a raw C++ type. return StringSwitch>(mnemonic) - .Case("struct", [&] { return StructType::parse(parser); }) + .Case("record", [&] { return RecordType::parse(parser); }) .Default([&] { parser.emitError(typeLoc) << "unknown CIR type: " << mnemonic; return Type(); @@ -95,7 +95,7 @@ void CIRDialect::printType(Type type, DialectAsmPrinter &os) const { // Type is not tablegen'd: try printing as a raw C++ type. TypeSwitch(type) - .Case([&](StructType type) { + .Case([&](RecordType type) { os << type.getMnemonic(); type.print(os); }) @@ -105,19 +105,19 @@ void CIRDialect::printType(Type type, DialectAsmPrinter &os) const { } //===----------------------------------------------------------------------===// -// StructType Definitions +// RecordType Definitions //===----------------------------------------------------------------------===// /// Return the largest member of in the type. /// /// Recurses into union members never returning a union as the largest member. -Type StructType::getLargestMember(const ::mlir::DataLayout &dataLayout) const { +Type RecordType::getLargestMember(const ::mlir::DataLayout &dataLayout) const { if (!layoutInfo) computeSizeAndAlignment(dataLayout); - return mlir::cast(layoutInfo).getLargestMember(); + return mlir::cast(layoutInfo).getLargestMember(); } -Type StructType::parse(mlir::AsmParser &parser) { +Type RecordType::parse(mlir::AsmParser &parser) { FailureOr cyclicParseGuard; const auto loc = parser.getCurrentLocation(); const auto eLoc = parser.getEncodedSourceLoc(loc); @@ -130,7 +130,7 @@ Type StructType::parse(mlir::AsmParser &parser) { return {}; // TODO(cir): in the future we should probably separate types for different - // source language declarations such as cir.class, cir.union, and cir.struct + // source language declarations such as cir.class, cir.union, and cir.record if (parser.parseOptionalKeyword("struct").succeeded()) kind = RecordKind::Struct; else if (parser.parseOptionalKeyword("union").succeeded()) @@ -138,7 +138,7 @@ Type StructType::parse(mlir::AsmParser &parser) { else if (parser.parseOptionalKeyword("class").succeeded()) kind = RecordKind::Class; else { - parser.emitError(loc, "unknown struct type"); + parser.emitError(loc, "unknown record type"); return {}; } @@ -201,19 +201,19 @@ Type StructType::parse(mlir::AsmParser &parser) { type = getChecked(eLoc, context, membersRef, name, packed, padded, kind); // If the record has a self-reference, its type already exists in a // incomplete state. In this case, we must complete it. - if (mlir::cast(type).isIncomplete()) - mlir::cast(type).complete(membersRef, packed, padded, ast); + if (mlir::cast(type).isIncomplete()) + mlir::cast(type).complete(membersRef, packed, padded, ast); } else if (!name && !incomplete) { // anonymous & complete type = getChecked(eLoc, context, membersRef, packed, padded, kind); } else { // anonymous & incomplete - parser.emitError(loc, "anonymous structs must be complete"); + parser.emitError(loc, "anonymous records must be complete"); return {}; } return type; } -void StructType::print(mlir::AsmPrinter &printer) const { +void RecordType::print(mlir::AsmPrinter &printer) const { FailureOr cyclicPrintGuard; printer << '<'; @@ -265,46 +265,46 @@ void StructType::print(mlir::AsmPrinter &printer) const { } mlir::LogicalResult -StructType::verify(function_ref emitError, +RecordType::verify(function_ref emitError, llvm::ArrayRef members, mlir::StringAttr name, bool incomplete, bool packed, bool padded, - StructType::RecordKind kind, ASTRecordDeclInterface ast) { + RecordType::RecordKind kind, ASTRecordDeclInterface ast) { if (name && name.getValue().empty()) { - emitError() << "identified structs cannot have an empty name"; + emitError() << "identified records cannot have an empty name"; return mlir::failure(); } return mlir::success(); } -void StructType::dropAst() { getImpl()->ast = nullptr; } +void RecordType::dropAst() { getImpl()->ast = nullptr; } -::llvm::ArrayRef StructType::getMembers() const { +::llvm::ArrayRef RecordType::getMembers() const { return getImpl()->members; } -bool StructType::isIncomplete() const { return getImpl()->incomplete; } +bool RecordType::isIncomplete() const { return getImpl()->incomplete; } -mlir::StringAttr StructType::getName() const { return getImpl()->name; } +mlir::StringAttr RecordType::getName() const { return getImpl()->name; } -bool StructType::getIncomplete() const { return getImpl()->incomplete; } +bool RecordType::getIncomplete() const { return getImpl()->incomplete; } -bool StructType::getPacked() const { return getImpl()->packed; } +bool RecordType::getPacked() const { return getImpl()->packed; } -bool StructType::getPadded() const { return getImpl()->padded; } +bool RecordType::getPadded() const { return getImpl()->padded; } -cir::StructType::RecordKind StructType::getKind() const { +cir::RecordType::RecordKind RecordType::getKind() const { return getImpl()->kind; } -ASTRecordDeclInterface StructType::getAst() const { return getImpl()->ast; } +ASTRecordDeclInterface RecordType::getAst() const { return getImpl()->ast; } -void StructType::complete(ArrayRef members, bool packed, bool padded, +void RecordType::complete(ArrayRef members, bool packed, bool padded, ASTRecordDeclInterface ast) { if (mutate(members, packed, padded, ast).failed()) - llvm_unreachable("failed to complete struct"); + llvm_unreachable("failed to complete record"); } -bool StructType::isLayoutIdentical(const StructType &other) { +bool RecordType::isLayoutIdentical(const RecordType &other) { if (getImpl() == other.getImpl()) return true; @@ -386,42 +386,42 @@ cir::VectorType::getABIAlignment(const ::mlir::DataLayout &dataLayout, } llvm::TypeSize -StructType::getTypeSizeInBits(const ::mlir::DataLayout &dataLayout, +RecordType::getTypeSizeInBits(const ::mlir::DataLayout &dataLayout, ::mlir::DataLayoutEntryListRef params) const { if (!layoutInfo) computeSizeAndAlignment(dataLayout); return llvm::TypeSize::getFixed( - mlir::cast(layoutInfo).getSize() * 8); + mlir::cast(layoutInfo).getSize() * 8); } uint64_t -StructType::getABIAlignment(const ::mlir::DataLayout &dataLayout, +RecordType::getABIAlignment(const ::mlir::DataLayout &dataLayout, ::mlir::DataLayoutEntryListRef params) const { if (!layoutInfo) computeSizeAndAlignment(dataLayout); - return mlir::cast(layoutInfo).getAlignment(); + return mlir::cast(layoutInfo).getAlignment(); } -uint64_t StructType::getElementOffset(const ::mlir::DataLayout &dataLayout, +uint64_t RecordType::getElementOffset(const ::mlir::DataLayout &dataLayout, unsigned idx) const { assert(idx < getMembers().size() && "access not valid"); if (!layoutInfo) computeSizeAndAlignment(dataLayout); - auto offsets = mlir::cast(layoutInfo).getOffsets(); + auto offsets = mlir::cast(layoutInfo).getOffsets(); auto intAttr = mlir::cast(offsets[idx]); return intAttr.getInt(); } -void StructType::computeSizeAndAlignment( +void RecordType::computeSizeAndAlignment( const ::mlir::DataLayout &dataLayout) const { - assert(isComplete() && "Cannot get layout of incomplete structs"); + assert(isComplete() && "Cannot get layout of incomplete records"); // Do not recompute. if (layoutInfo) return; // This is a similar algorithm to LLVM's StructLayout. - unsigned structSize = 0; - llvm::Align structAlignment{1}; + unsigned recordSize = 0; + llvm::Align recordAlignment{1}; bool isPadded = false; unsigned numElements = getNumElements(); auto members = getMembers(); @@ -455,46 +455,46 @@ void StructType::computeSizeAndAlignment( llvm::Align(getPacked() ? 1 : dataLayout.getTypeABIAlignment(ty)); // Add padding if necessary to align the data element properly. - if (!llvm::isAligned(tyAlign, structSize)) { + if (!llvm::isAligned(tyAlign, recordSize)) { isPadded = true; - structSize = llvm::alignTo(structSize, tyAlign); + recordSize = llvm::alignTo(recordSize, tyAlign); } // Keep track of maximum alignment constraint. - structAlignment = std::max(tyAlign, structAlignment); + recordAlignment = std::max(tyAlign, recordAlignment); - // Struct size up to each element is the element offset. + // Record size up to each element is the element offset. memberOffsets.push_back(mlir::IntegerAttr::get( - mlir::IntegerType::get(getContext(), 32), isUnion() ? 0 : structSize)); + mlir::IntegerType::get(getContext(), 32), isUnion() ? 0 : recordSize)); // Consume space for this data item - structSize += dataLayout.getTypeSize(ty); + recordSize += dataLayout.getTypeSize(ty); } // For unions, the size and aligment is that of the largest element. if (isUnion()) { - structSize = largestMemberSize; + recordSize = largestMemberSize; if (getPadded()) { memberOffsets.push_back(mlir::IntegerAttr::get( - mlir::IntegerType::get(getContext(), 32), structSize)); + mlir::IntegerType::get(getContext(), 32), recordSize)); auto ty = getMembers()[numElements]; - structSize += dataLayout.getTypeSize(ty); + recordSize += dataLayout.getTypeSize(ty); isPadded = true; } else { isPadded = false; } } else { - // Add padding to the end of the struct so that it could be put in an array + // Add padding to the end of the record so that it could be put in an array // and all array elements would be aligned correctly. - if (!llvm::isAligned(structAlignment, structSize)) { + if (!llvm::isAligned(recordAlignment, recordSize)) { isPadded = true; - structSize = llvm::alignTo(structSize, structAlignment); + recordSize = llvm::alignTo(recordSize, recordAlignment); } } auto offsets = mlir::ArrayAttr::get(getContext(), memberOffsets); - layoutInfo = cir::StructLayoutAttr::get(getContext(), structSize, - structAlignment.value(), isPadded, + layoutInfo = cir::RecordLayoutAttr::get(getContext(), recordSize, + recordAlignment.value(), isPadded, largestMember, offsets); } @@ -869,8 +869,8 @@ static mlir::Type getMethodLayoutType(mlir::MLIRContext *ctx) { // TODO: consider member function pointer layout in other ABIs auto voidPtrTy = cir::PointerType::get(cir::VoidType::get(ctx)); mlir::Type fields[2]{voidPtrTy, voidPtrTy}; - return cir::StructType::get(ctx, fields, /*packed=*/false, - /*padded=*/false, cir::StructType::Struct); + return cir::RecordType::get(ctx, fields, /*packed=*/false, + /*padded=*/false, cir::RecordType::Struct); } llvm::TypeSize diff --git a/clang/lib/CIR/Dialect/Transforms/DropAST.cpp b/clang/lib/CIR/Dialect/Transforms/DropAST.cpp index 716412c0f6d8..fee7ade2c6ce 100644 --- a/clang/lib/CIR/Dialect/Transforms/DropAST.cpp +++ b/clang/lib/CIR/Dialect/Transforms/DropAST.cpp @@ -33,7 +33,7 @@ void DropASTPass::runOnOperation() { op->walk([&](Operation *op) { if (auto alloca = dyn_cast(op)) { alloca.removeAstAttr(); - auto ty = mlir::dyn_cast(alloca.getAllocaType()); + auto ty = mlir::dyn_cast(alloca.getAllocaType()); if (!ty) return; ty.dropAst(); diff --git a/clang/lib/CIR/Dialect/Transforms/LibOpt.cpp b/clang/lib/CIR/Dialect/Transforms/LibOpt.cpp index 30719a3d60f9..2c4c6a5a5b3c 100644 --- a/clang/lib/CIR/Dialect/Transforms/LibOpt.cpp +++ b/clang/lib/CIR/Dialect/Transforms/LibOpt.cpp @@ -91,7 +91,7 @@ static bool isSequentialContainer(mlir::Type t) { return isStdArrayType(t); } -static bool getIntegralNTTPAt(StructType t, size_t pos, unsigned &size) { +static bool getIntegralNTTPAt(RecordType t, size_t pos, unsigned &size) { auto *d = dyn_cast(t.getAst().getRawDecl()); if (!d) @@ -109,7 +109,7 @@ static bool getIntegralNTTPAt(StructType t, size_t pos, unsigned &size) { return true; } -static bool containerHasStaticSize(StructType t, unsigned &size) { +static bool containerHasStaticSize(RecordType t, unsigned &size) { // TODO: add others. if (!isStdArrayType(t)) return false; @@ -179,7 +179,7 @@ void LibOptPass::xformStdFindIntoMemchr(StdFindOp findOp) { // Look at this pointer to retrieve container information. auto thisPtr = cast(iterBegin.getOperand().getType()).getPointee(); - auto containerTy = dyn_cast(thisPtr); + auto containerTy = dyn_cast(thisPtr); unsigned staticSize = 0; if (containerTy && isSequentialContainer(containerTy) && diff --git a/clang/lib/CIR/Dialect/Transforms/LifetimeCheck.cpp b/clang/lib/CIR/Dialect/Transforms/LifetimeCheck.cpp index 323b8e4cd125..738efb2ddffd 100644 --- a/clang/lib/CIR/Dialect/Transforms/LifetimeCheck.cpp +++ b/clang/lib/CIR/Dialect/Transforms/LifetimeCheck.cpp @@ -58,10 +58,10 @@ struct LifetimeCheckPass : public LifetimeCheckBase { void classifyAndInitTypeCategories(mlir::Value addr, mlir::Type t, mlir::Location loc, unsigned nestLevel); void updatePointsTo(mlir::Value addr, mlir::Value data, mlir::Location loc); - void updatePointsToForConstStruct(mlir::Value addr, - cir::ConstStructAttr value, + void updatePointsToForConstRecord(mlir::Value addr, + cir::ConstRecordAttr value, mlir::Location loc); - void updatePointsToForZeroStruct(mlir::Value addr, StructType sTy, + void updatePointsToForZeroRecord(mlir::Value addr, RecordType sTy, mlir::Location loc); enum DerefStyle { @@ -368,9 +368,9 @@ struct LifetimeCheckPass : public LifetimeCheckBase { // Track types we already know to be a lambda llvm::DenseMap IsLambdaTyCache; - // Check if a given cir type is a struct containing a lambda + // Check if a given cir type is a record containing a lambda bool isLambdaType(mlir::Type ty); - // Get the lambda struct from a member access to it. + // Get the lambda record from a member access to it. mlir::Value getLambdaFromMemberAccess(mlir::Value addr); /// @@ -868,10 +868,10 @@ void LifetimeCheckPass::checkIf(IfOp ifOp) { joinPmaps(pmapOps); } -template bool isStructAndHasAttr(mlir::Type ty) { - if (!mlir::isa(ty)) +template bool isRecordAndHasAttr(mlir::Type ty) { + if (!mlir::isa(ty)) return false; - return hasAttr(mlir::cast(ty).getAst()); + return hasAttr(mlir::cast(ty).getAst()); } static bool isOwnerType(mlir::Type ty) { @@ -897,10 +897,10 @@ static bool isOwnerType(mlir::Type ty) { // library headers, the following well known standard types are treated as-if // annotated as Owners: stack, queue, priority_queue, optional, variant, any, // and regex. - return isStructAndHasAttr(ty); + return isRecordAndHasAttr(ty); } -static bool containsPointerElts(cir::StructType s) { +static bool containsPointerElts(cir::RecordType s) { auto members = s.getMembers(); return std::any_of(members.begin(), members.end(), [](mlir::Type t) { return mlir::isa(t); @@ -908,7 +908,7 @@ static bool containsPointerElts(cir::StructType s) { } static bool isAggregateType(LifetimeCheckPass *pass, mlir::Type agg) { - auto t = mlir::dyn_cast(agg); + auto t = mlir::dyn_cast(agg); if (!t) return false; // Lambdas have their special handling, and shall not be considered as @@ -960,7 +960,7 @@ static bool isPointerType(mlir::Type t) { // erence_wrapper, and vector::reference. if (mlir::isa(t)) return true; - return isStructAndHasAttr(t); + return isRecordAndHasAttr(t); } void LifetimeCheckPass::classifyAndInitTypeCategories(mlir::Value addr, @@ -1012,11 +1012,11 @@ void LifetimeCheckPass::classifyAndInitTypeCategories(mlir::Value addr, break; // Map values for members to it's index in the aggregate. - auto members = mlir::cast(t).getMembers(); + auto members = mlir::cast(t).getMembers(); llvm::SmallVector fieldVals; fieldVals.assign(members.size(), {}); - // Go through uses of the alloca via `cir.struct_element_addr`, and + // Go through uses of the alloca via `cir.record_element_addr`, and // track only the fields that are actually used. std::for_each(addr.use_begin(), addr.use_end(), [&](mlir::OpOperand &use) { auto op = dyn_cast(use.getOwner()); @@ -1127,8 +1127,8 @@ void LifetimeCheckPass::checkLambdaCaptureStore(StoreOp storeOp) { getPmap()[lambdaAddr].insert(State::getLocalValue(localByRefAddr)); } -void LifetimeCheckPass::updatePointsToForConstStruct(mlir::Value addr, - cir::ConstStructAttr value, +void LifetimeCheckPass::updatePointsToForConstRecord(mlir::Value addr, + cir::ConstRecordAttr value, mlir::Location loc) { assert(aggregates.count(addr) && "expected association with aggregate"); int memberIdx = 0; @@ -1146,8 +1146,8 @@ void LifetimeCheckPass::updatePointsToForConstStruct(mlir::Value addr, } } -void LifetimeCheckPass::updatePointsToForZeroStruct(mlir::Value addr, - StructType sTy, +void LifetimeCheckPass::updatePointsToForZeroRecord(mlir::Value addr, + RecordType sTy, mlir::Location loc) { assert(aggregates.count(addr) && "expected association with aggregate"); int memberIdx = 0; @@ -1210,15 +1210,15 @@ void LifetimeCheckPass::updatePointsTo(mlir::Value addr, mlir::Value data, // Aggregates can be bulk materialized in CIR, handle proper update of // individual exploded fields. if (aggregates.count(addr)) { - if (auto constStruct = - mlir::dyn_cast(cstOp.getValue())) { - updatePointsToForConstStruct(addr, constStruct, loc); + if (auto constRecord = + mlir::dyn_cast(cstOp.getValue())) { + updatePointsToForConstRecord(addr, constRecord, loc); return; } if (auto zero = mlir::dyn_cast(cstOp.getValue())) { - if (auto zeroStructTy = dyn_cast(zero.getType())) { - updatePointsToForZeroStruct(addr, zeroStructTy, loc); + if (auto zeroRecordTy = dyn_cast(zero.getType())) { + updatePointsToForZeroRecord(addr, zeroRecordTy, loc); return; } } @@ -1676,8 +1676,8 @@ void LifetimeCheckPass::checkForOwnerAndPointerArguments(CallOp callOp, if (aggregates.count(arg)) { int memberIdx = 0; auto sTy = - dyn_cast(cast(arg.getType()).getPointee()); - assert(sTy && "expected struct type"); + dyn_cast(cast(arg.getType()).getPointee()); + assert(sTy && "expected record type"); for (auto m : sTy.getMembers()) { auto ptrMemberAddr = aggregates[arg][memberIdx]; if (isa(m) && ptrMemberAddr) { @@ -1726,7 +1726,7 @@ bool LifetimeCheckPass::isLambdaType(mlir::Type ty) { return IsLambdaTyCache[ty]; IsLambdaTyCache[ty] = false; - auto taskTy = mlir::dyn_cast(ty); + auto taskTy = mlir::dyn_cast(ty); if (!taskTy) return false; if (taskTy.getAst().isLambda()) @@ -1741,7 +1741,7 @@ bool LifetimeCheckPass::isTaskType(mlir::Value taskVal) { return IsTaskTyCache[ty]; bool result = [&] { - auto taskTy = mlir::dyn_cast(taskVal.getType()); + auto taskTy = mlir::dyn_cast(taskVal.getType()); if (!taskTy) return false; return taskTy.getAst().hasPromiseType(); diff --git a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp index 9e1a57e7f665..8a4e49a51823 100644 --- a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp +++ b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp @@ -1068,13 +1068,13 @@ void LoweringPreparePass::buildCUDAModuleCtor() { fatbinStr.setSection(fatbinConstName); fatbinStr.setPrivate(); - // Create a struct FatbinWrapper, pointing to the GPU binary. - // Struct layout: + // Create a record FatbinWrapper, pointing to the GPU binary. + // Record layout: // struct { int magicNum; int version; void *fatbin; void *unused; }; // This will be initialized in the module ctor below. - auto fatbinWrapperType = StructType::get( + auto fatbinWrapperType = RecordType::get( &getContext(), {intTy, intTy, voidPtrTy, voidPtrTy}, /*packed=*/false, - /*padded=*/false, StructType::RecordKind::Struct); + /*padded=*/false, RecordType::RecordKind::Struct); std::string fatbinWrapperName = addUnderscoredPrefix(cudaPrefix, "_fatbin_wrapper"); @@ -1090,7 +1090,7 @@ void LoweringPreparePass::buildCUDAModuleCtor() { mlir::FlatSymbolRefAttr::get(fatbinStr.getSymNameAttr()); auto fatbinInit = GlobalViewAttr::get(voidPtrTy, fatbinStrSymbol); auto unusedInit = builder.getConstNullPtrAttr(voidPtrTy); - fatbinWrapper.setInitialValueAttr(cir::ConstStructAttr::get( + fatbinWrapper.setInitialValueAttr(cir::ConstRecordAttr::get( fatbinWrapperType, ArrayAttr::get(&getContext(), {magicInit, versionInit, fatbinInit, unusedInit}))); @@ -1433,7 +1433,7 @@ void LoweringPreparePass::lowerToMemCpy(StoreOp op) { CIRBaseBuilderTy builder(getContext()); // Create a global which is initialized with the attribute that is either a - // constant array or struct. + // constant array or record. assert(!cir::MissingFeatures::unnamedAddr() && "NYI"); builder.setInsertionPointToStart(&theModule.getBodyRegion().front()); std::string globalName = @@ -1568,7 +1568,7 @@ void LoweringPreparePass::runOnOp(Operation *op) { lowerArrayDtor(arrayDtor); } else if (auto storeOp = dyn_cast(op)) { mlir::Type valTy = storeOp.getValue().getType(); - if (isa(valTy) || isa(valTy)) + if (isa(valTy) || isa(valTy)) lowerToMemCpy(storeOp); } else if (auto fnOp = dyn_cast(op)) { if (auto globalCtor = fnOp.getGlobalCtorAttr()) { diff --git a/clang/lib/CIR/Dialect/Transforms/StdHelpers.cpp b/clang/lib/CIR/Dialect/Transforms/StdHelpers.cpp index 19807738505e..07d0f207fc62 100644 --- a/clang/lib/CIR/Dialect/Transforms/StdHelpers.cpp +++ b/clang/lib/CIR/Dialect/Transforms/StdHelpers.cpp @@ -11,7 +11,7 @@ namespace cir { bool isStdArrayType(mlir::Type t) { - auto sTy = mlir::dyn_cast(t); + auto sTy = mlir::dyn_cast(t); if (!sTy) return false; auto recordDecl = sTy.getAst(); diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.cpp index feac26463304..f136297b77d3 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.cpp @@ -24,7 +24,7 @@ bool classifyReturnType(const CIRCXXABI &CXXABI, LowerFunctionInfo &FI, const ABIInfo &Info) { mlir::Type Ty = FI.getReturnType(); - if (const auto RT = mlir::dyn_cast(Ty)) { + if (const auto RT = mlir::dyn_cast(Ty)) { cir_cconv_assert(!cir::MissingFeatures::isCXXRecordDecl()); } @@ -49,7 +49,7 @@ mlir::Value emitRoundPointerUpToAlignment(cir::CIRBaseBuilderTy &builder, } mlir::Type useFirstFieldIfTransparentUnion(mlir::Type Ty) { - if (auto RT = mlir::dyn_cast(Ty)) { + if (auto RT = mlir::dyn_cast(Ty)) { if (RT.isUnion()) cir_cconv_assert_or_abort( !cir::MissingFeatures::ABITransparentUnionHandling(), "NYI"); @@ -57,7 +57,7 @@ mlir::Type useFirstFieldIfTransparentUnion(mlir::Type Ty) { return Ty; } -CIRCXXABI::RecordArgABI getRecordArgABI(const StructType RT, +CIRCXXABI::RecordArgABI getRecordArgABI(const RecordType RT, CIRCXXABI &CXXABI) { if (cir::MissingFeatures::typeIsCXXRecordDecl()) { cir_cconv_unreachable("NYI"); @@ -66,7 +66,7 @@ CIRCXXABI::RecordArgABI getRecordArgABI(const StructType RT, } CIRCXXABI::RecordArgABI getRecordArgABI(mlir::Type ty, CIRCXXABI &CXXABI) { - auto st = mlir::dyn_cast(ty); + auto st = mlir::dyn_cast(ty); if (!st) return CIRCXXABI::RAA_Default; return getRecordArgABI(st, CXXABI); diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.h b/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.h index 8088a333c4a5..db55bb7c084b 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.h +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.h @@ -32,7 +32,7 @@ mlir::Value emitRoundPointerUpToAlignment(cir::CIRBaseBuilderTy &builder, /// should ensure that all elements of the union have the same "machine type". mlir::Type useFirstFieldIfTransparentUnion(mlir::Type Ty); -CIRCXXABI::RecordArgABI getRecordArgABI(const StructType RT, CIRCXXABI &CXXABI); +CIRCXXABI::RecordArgABI getRecordArgABI(const RecordType RT, CIRCXXABI &CXXABI); CIRCXXABI::RecordArgABI getRecordArgABI(mlir::Type ty, CIRCXXABI &CXXABI); } // namespace cir diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRCXXABI.h b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRCXXABI.h index e2f1b658fe14..ec62ed1dbacf 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRCXXABI.h +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRCXXABI.h @@ -64,7 +64,7 @@ class CIRCXXABI { /// Returns how an argument of the given record type should be passed. /// FIXME(cir): This expects a CXXRecordDecl! Not any record type. - virtual RecordArgABI getRecordArgABI(const StructType RD) const = 0; + virtual RecordArgABI getRecordArgABI(const RecordType RD) const = 0; /// Lower the given data member pointer type to its ABI type. The returned /// type is also a CIR type. diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.cpp index b6c82adfd038..3e2b4d93079a 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.cpp @@ -54,7 +54,7 @@ clang::TypeInfo CIRLowerContext::getTypeInfoImpl(const mlir::Type T) const { auto typeKind = clang::Type::Builtin; if (mlir::isa(T)) { typeKind = clang::Type::Builtin; - } else if (mlir::isa(T)) { + } else if (mlir::isa(T)) { typeKind = clang::Type::Record; } else { cir_cconv_assert_or_abort(!cir::MissingFeatures::ABIClangTypeKind(), @@ -105,7 +105,7 @@ clang::TypeInfo CIRLowerContext::getTypeInfoImpl(const mlir::Type T) const { break; } case clang::Type::Record: { - const auto RT = mlir::dyn_cast(T); + const auto RT = mlir::dyn_cast(T); cir_cconv_assert(!cir::MissingFeatures::tagTypeClassAbstraction()); // Only handle TagTypes (names types) for now. diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRToCIRArgMapping.h b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRToCIRArgMapping.h index 1310505da536..5b294e246dd8 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRToCIRArgMapping.h +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRToCIRArgMapping.h @@ -94,7 +94,7 @@ class CIRToCIRArgMapping { case cir::ABIArgInfo::Direct: { // FIXME(cir): handle sseregparm someday... cir_cconv_assert(AI.getCoerceToType() && "Missing coerced type!!"); - StructType STy = mlir::dyn_cast(AI.getCoerceToType()); + RecordType STy = mlir::dyn_cast(AI.getCoerceToType()); if (AI.isDirect() && AI.getCanBeFlattened() && STy) { IRArgs.NumberOfArgs = STy.getNumElements(); } else { diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/ItaniumCXXABI.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/ItaniumCXXABI.cpp index 06d0f4d27dc3..edf895ef05fb 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/ItaniumCXXABI.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/ItaniumCXXABI.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// // // This provides CIR lowering logic targeting the Itanium C++ ABI. The class in -// this file generates structures that follow the Itanium C++ ABI, which is +// this file generates records that follow the Itanium C++ ABI, which is // documented at: // https://itanium-cxx-abi.github.io/cxx-abi/abi.html // https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html @@ -34,11 +34,11 @@ class ItaniumCXXABI : public CIRCXXABI { protected: enum class VTableComponentLayout { - /// Components in the vtable are pointers to other structs/functions. + /// Components in the vtable are pointers to other records/functions. Pointer, /// Components in the vtable are relative offsets between the vtable and the - /// other structs/functions. + /// other records/functions. Relative, }; @@ -59,7 +59,7 @@ class ItaniumCXXABI : public CIRCXXABI { bool classifyReturnType(LowerFunctionInfo &FI) const override; // FIXME(cir): This expects a CXXRecordDecl! Not any record type. - RecordArgABI getRecordArgABI(const StructType RD) const override { + RecordArgABI getRecordArgABI(const RecordType RD) const override { cir_cconv_assert(!cir::MissingFeatures::recordDeclIsCXXDecl()); // If C++ prohibits us from making a copy, pass by address. cir_cconv_assert(!cir::MissingFeatures::recordDeclCanPassInRegisters()); @@ -133,7 +133,7 @@ class ItaniumCXXABI : public CIRCXXABI { } // namespace bool ItaniumCXXABI::classifyReturnType(LowerFunctionInfo &FI) const { - const StructType RD = mlir::dyn_cast(FI.getReturnType()); + const RecordType RD = mlir::dyn_cast(FI.getReturnType()); if (!RD) return false; @@ -178,9 +178,9 @@ ItaniumCXXABI::lowerMethodType(cir::MethodType type, // Note that clang CodeGen emits struct{ptrdiff_t, ptrdiff_t} for member // function pointers. Let's follow this approach. - return cir::StructType::get(type.getContext(), {ptrdiffCIRTy, ptrdiffCIRTy}, + return cir::RecordType::get(type.getContext(), {ptrdiffCIRTy, ptrdiffCIRTy}, /*packed=*/false, /*padded=*/false, - cir::StructType::Struct); + cir::RecordType::Struct); } mlir::TypedAttr ItaniumCXXABI::lowerDataMemberConstant( @@ -208,7 +208,7 @@ mlir::TypedAttr ItaniumCXXABI::lowerMethodConstant( cir::MethodAttr attr, const mlir::DataLayout &layout, const mlir::TypeConverter &typeConverter) const { cir::IntType ptrdiffCIRTy = getPtrDiffCIRTy(LM); - auto loweredMethodTy = mlir::cast( + auto loweredMethodTy = mlir::cast( lowerMethodType(attr.getType(), typeConverter)); auto zero = cir::IntAttr::get(ptrdiffCIRTy, 0); @@ -232,7 +232,7 @@ mlir::TypedAttr ItaniumCXXABI::lowerMethodConstant( // // clang CodeGen emits struct{null, null} for null member function pointers. // Let's do the same here. - return cir::ConstStructAttr::get( + return cir::ConstRecordAttr::get( loweredMethodTy, mlir::ArrayAttr::get(attr.getContext(), {zero, zero})); } @@ -256,7 +256,7 @@ mlir::TypedAttr ItaniumCXXABI::lowerMethodConstant( // uintfnptr_t is an unsigned integer of the same size as fnptr_t. auto ptr = cir::IntAttr::get(ptrdiffCIRTy, 1 + attr.getVtableOffset().value()); - return cir::ConstStructAttr::get( + return cir::ConstRecordAttr::get( loweredMethodTy, mlir::ArrayAttr::get(attr.getContext(), {ptr, zero})); } @@ -266,7 +266,7 @@ mlir::TypedAttr ItaniumCXXABI::lowerMethodConstant( // represented with ptr set to a pointer to the function, using the base // ABI's representation of function pointers. auto ptr = cir::GlobalViewAttr::get(ptrdiffCIRTy, attr.getSymbol().value()); - return cir::ConstStructAttr::get( + return cir::ConstRecordAttr::get( loweredMethodTy, mlir::ArrayAttr::get(attr.getContext(), {ptr, zero})); } diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerFunction.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerFunction.cpp index 59420c1d2b54..a2f42aa72693 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerFunction.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerFunction.cpp @@ -59,15 +59,15 @@ mlir::Value createBitcast(mlir::Value Src, mlir::Type Ty, LowerFunction &LF) { Src); } -/// Given a struct pointer that we are accessing some number of bytes out of it, -/// try to gep into the struct to get at its inner goodness. Dive as deep as +/// Given a record pointer that we are accessing some number of bytes out of it, +/// try to gep into the record to get at its inner goodness. Dive as deep as /// possible without entering an element with an in-memory size smaller than /// DstSize. -mlir::Value enterStructPointerForCoercedAccess(mlir::Value SrcPtr, - StructType SrcSTy, +mlir::Value enterRecordPointerForCoercedAccess(mlir::Value SrcPtr, + RecordType SrcSTy, uint64_t DstSize, LowerFunction &CGF) { - // We can't dive into a zero-element struct. + // We can't dive into a zero-element record. if (SrcSTy.getNumElements() == 0) cir_cconv_unreachable("NYI"); @@ -77,7 +77,7 @@ mlir::Value enterStructPointerForCoercedAccess(mlir::Value SrcPtr, FirstElt = SrcSTy.getLargestMember(CGF.LM.getDataLayout().layout); // If the first elt is at least as large as what we're looking for, or if the - // first element is the same size as the whole struct, we can enter it. The + // first element is the same size as the whole record, we can enter it. The // comparison must be made on the store size and not the alloca size. Using // the alloca size may overstate the size of the load. uint64_t FirstEltSize = CGF.LM.getDataLayout().getTypeStoreSize(FirstElt); @@ -88,7 +88,7 @@ mlir::Value enterStructPointerForCoercedAccess(mlir::Value SrcPtr, auto &rw = CGF.getRewriter(); auto *ctxt = rw.getContext(); auto ptrTy = PointerType::get(ctxt, FirstElt); - if (mlir::isa(SrcPtr.getType())) { + if (mlir::isa(SrcPtr.getType())) { auto addr = SrcPtr; if (auto load = mlir::dyn_cast(SrcPtr.getDefiningOp())) addr = load.getAddr(); @@ -101,8 +101,8 @@ mlir::Value enterStructPointerForCoercedAccess(mlir::Value SrcPtr, SrcPtr = rw.create(SrcPtr.getLoc(), cast); } - if (auto sty = mlir::dyn_cast(SrcPtr.getType())) - return enterStructPointerForCoercedAccess(SrcPtr, sty, DstSize, CGF); + if (auto sty = mlir::dyn_cast(SrcPtr.getType())) + return enterRecordPointerForCoercedAccess(SrcPtr, sty, DstSize, CGF); return SrcPtr; } @@ -260,9 +260,9 @@ void createCoercedStore(mlir::Value Src, mlir::Value Dst, bool DstIsVolatile, auto dstPtrTy = mlir::dyn_cast(DstTy); if (dstPtrTy) - if (auto dstSTy = mlir::dyn_cast(dstPtrTy.getPointee())) + if (auto dstSTy = mlir::dyn_cast(dstPtrTy.getPointee())) if (SrcTy != dstSTy) - Dst = enterStructPointerForCoercedAccess(Dst, dstSTy, + Dst = enterRecordPointerForCoercedAccess(Dst, dstSTy, SrcSize.getFixedValue(), CGF); auto &layout = CGF.LM.getDataLayout(); @@ -275,7 +275,7 @@ void createCoercedStore(mlir::Value Src, mlir::Value Dst, bool DstIsVolatile, mlir::isa(dstPtrTy.getPointee()) && SrcSize == layout.getTypeAllocSize(dstPtrTy.getPointee())) { cir_cconv_unreachable("NYI"); - } else if (auto STy = mlir::dyn_cast(SrcTy)) { + } else if (auto STy = mlir::dyn_cast(SrcTy)) { cir_cconv_unreachable("NYI"); } else { Dst = createCoercedBitcast(Dst, SrcTy, CGF); @@ -322,8 +322,8 @@ mlir::Value createCoercedValue(mlir::Value Src, mlir::Type Ty, llvm::TypeSize DstSize = CGF.LM.getDataLayout().getTypeAllocSize(Ty); - if (auto SrcSTy = mlir::dyn_cast(SrcTy)) { - Src = enterStructPointerForCoercedAccess(Src, SrcSTy, + if (auto SrcSTy = mlir::dyn_cast(SrcTy)) { + Src = enterRecordPointerForCoercedAccess(Src, SrcSTy, DstSize.getFixedValue(), CGF); SrcTy = Src.getType(); } @@ -341,7 +341,7 @@ mlir::Value createCoercedValue(mlir::Value Src, mlir::Type Ty, if (!SrcSize.isScalable() && !DstSize.isScalable() && SrcSize.getFixedValue() >= DstSize.getFixedValue()) { // Generally SrcSize is never greater than DstSize, since this means we are - // losing bits. However, this can happen in cases where the structure has + // losing bits. However, this can happen in cases where the record has // additional padding, for example due to a user specified alignment. // // FIXME: Assert that we aren't truncating non-padding bits when have access @@ -418,7 +418,7 @@ mlir::Value castReturnValue(mlir::Value Src, mlir::Type Ty, LowerFunction &LF) { llvm::TypeSize DstSize = LF.LM.getDataLayout().getTypeAllocSize(Ty); - // FIXME(cir): Do we need the EnterStructPointerForCoercedAccess routine here? + // FIXME(cir): Do we need the EnterRecordPointerForCoercedAccess routine here? llvm::TypeSize SrcSize = LF.LM.getDataLayout().getTypeAllocSize(SrcTy); @@ -431,7 +431,7 @@ mlir::Value castReturnValue(mlir::Value Src, mlir::Type Ty, LowerFunction &LF) { if (!SrcSize.isScalable() && !DstSize.isScalable() && SrcSize.getFixedValue() >= DstSize.getFixedValue()) { // Generally SrcSize is never greater than DstSize, since this means we are - // losing bits. However, this can happen in cases where the structure has + // losing bits. However, this can happen in cases where the record has // additional padding, for example due to a user specified alignment. // // FIXME: Assert that we aren't truncating non-padding bits when have access @@ -480,7 +480,7 @@ llvm::LogicalResult LowerFunction::buildFunctionProlog( // parameter, which is a pointer to the complete memory area. cir_cconv_assert(!cir::MissingFeatures::inallocaArgs()); - // Name the struct return parameter. + // Name the record return parameter. cir_cconv_assert(!cir::MissingFeatures::sretArgs()); // Track if we received the parameter as a pointer (indirect, byval, or @@ -541,7 +541,7 @@ llvm::LogicalResult LowerFunction::buildFunctionProlog( // Prepare the argument value. If we have the trivial case, handle it // with no muss and fuss. - if (!mlir::isa(ArgI.getCoerceToType()) && + if (!mlir::isa(ArgI.getCoerceToType()) && ArgI.getCoerceToType() == Ty && ArgI.getDirectOffset() == 0) { cir_cconv_assert(NumIRArgs == 1); @@ -572,7 +572,7 @@ llvm::LogicalResult LowerFunction::buildFunctionProlog( cir_cconv_assert(!cir::MissingFeatures::vectorType()); - StructType STy = mlir::dyn_cast(ArgI.getCoerceToType()); + RecordType STy = mlir::dyn_cast(ArgI.getCoerceToType()); if (ArgI.isDirect() && !ArgI.getCanBeFlattened() && STy && STy.getNumElements() > 1) { cir_cconv_unreachable("NYI"); @@ -595,15 +595,15 @@ llvm::LogicalResult LowerFunction::buildFunctionProlog( if (ArgI.isDirect() && ArgI.getCanBeFlattened() && STy && STy.getNumElements() > 1) { auto ptrType = mlir::cast(Ptr.getType()); - llvm::TypeSize structSize = + llvm::TypeSize recordSize = LM.getTypes().getDataLayout().getTypeAllocSize(STy); llvm::TypeSize ptrElementSize = LM.getTypes().getDataLayout().getTypeAllocSize( ptrType.getPointee()); - if (structSize.isScalable()) { + if (recordSize.isScalable()) { cir_cconv_unreachable("NYI"); } else { - uint64_t srcSize = structSize.getFixedValue(); + uint64_t srcSize = recordSize.getFixedValue(); uint64_t dstSize = ptrElementSize.getFixedValue(); mlir::Value addrToStoreInto; @@ -1025,7 +1025,7 @@ mlir::Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo, mlir::Location loc) { // FIXME: We no longer need the types from CallArgs; lift up and simplify. - // Handle struct-return functions by passing a pointer to the + // Handle record-return functions by passing a pointer to the // location that we would like to return into. mlir::Type RetTy = CallInfo.getReturnType(); // ABI-agnostic type. const cir::ABIArgInfo &RetAI = CallInfo.getReturnInfo(); @@ -1039,7 +1039,7 @@ mlir::Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo, // If we're using inalloca, insert the allocation after the stack save. // FIXME: Do this earlier rather than hacking it in here! - if (StructType ArgStruct = CallInfo.getArgStruct()) { + if (RecordType ArgRecord = CallInfo.getArgRecord()) { cir_cconv_unreachable("NYI"); } @@ -1047,7 +1047,7 @@ mlir::Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo, llvm::SmallVector IRCallArgs(IRFunctionArgs.totalIRArgs()); mlir::Value sRetPtr; - // If the call returns a temporary with struct return, create a temporary + // If the call returns a temporary with record return, create a temporary // alloca to hold the result, unless one is given to us. if (RetAI.isIndirect() || RetAI.isCoerceAndExpand() || RetAI.isInAlloca()) { sRetPtr = createAlloca(loc, RetTy, *this); @@ -1082,12 +1082,12 @@ mlir::Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo, break; } - if (!mlir::isa(ArgInfo.getCoerceToType()) && + if (!mlir::isa(ArgInfo.getCoerceToType()) && ArgInfo.getCoerceToType() == info_it->type && ArgInfo.getDirectOffset() == 0) { cir_cconv_assert(NumIRArgs == 1); mlir::Value V; - if (!mlir::isa(I->getType())) { + if (!mlir::isa(I->getType())) { V = *I; } else { cir_cconv_unreachable("NYI"); @@ -1113,7 +1113,7 @@ mlir::Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo, // FIXME: Avoid the conversion through memory if possible. mlir::Value Src = {}; - if (!mlir::isa(I->getType())) { + if (!mlir::isa(I->getType())) { cir_cconv_unreachable("NYI"); } else { // NOTE(cir): L/RValue stuff are left for CIRGen to handle. @@ -1130,7 +1130,7 @@ mlir::Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo, // coerced type can be STy = struct { u64, i32 }. Hence a function with // a single argument SrcTy will be rewritten to take two arguments, // namely u64 and i32. - StructType STy = mlir::dyn_cast(ArgInfo.getCoerceToType()); + RecordType STy = mlir::dyn_cast(ArgInfo.getCoerceToType()); if (STy && ArgInfo.isDirect() && ArgInfo.getCanBeFlattened()) { mlir::Type SrcTy = Src.getType(); llvm::TypeSize SrcTypeSize = LM.getDataLayout().getTypeAllocSize(SrcTy); @@ -1342,8 +1342,8 @@ mlir::Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo, // An empty record can overlap other data (if declared with // no_unique_address); omit the store for such types - as there is no // actual data to store. - if (mlir::dyn_cast(RetTy) && - mlir::cast(RetTy).getNumElements() != 0) { + if (mlir::dyn_cast(RetTy) && + mlir::cast(RetTy).getNumElements() != 0) { RetVal = newCallOp.getResult(); createCoercedStore(RetVal, dstPtr, false, *this); @@ -1384,7 +1384,7 @@ mlir::Value LowerFunction::getUndefRValue(mlir::Type Ty) { cir::TypeEvaluationKind LowerFunction::getEvaluationKind(mlir::Type type) { // FIXME(cir): Implement type classes for CIR types. - if (mlir::isa(type)) + if (mlir::isa(type)) return cir::TypeEvaluationKind::TEK_Aggregate; if (mlir::isa(type)) diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerFunctionInfo.h b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerFunctionInfo.h index 6b0823c6d7c1..631c71fd68be 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerFunctionInfo.h +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerFunctionInfo.h @@ -93,9 +93,9 @@ class LowerFunctionInfo final RequiredArgs Required; - /// The struct representing all arguments passed in memory. Only used when + /// The record representing all arguments passed in memory. Only used when /// passing non-trivial types with inalloca. Not part of the profile. - StructType ArgStruct; + RecordType ArgRecord; unsigned NumArgs; @@ -121,7 +121,7 @@ class LowerFunctionInfo final FI->ChainCall = chainCall; FI->DelegateCall = delegateCall; FI->Required = required; - FI->ArgStruct = nullptr; + FI->ArgRecord = nullptr; FI->NumArgs = argTypes.size(); FI->getArgsBuffer()[0].type = resultType; for (unsigned i = 0, e = argTypes.size(); i != e; ++i) @@ -167,8 +167,8 @@ class LowerFunctionInfo final /// into an LLVM CC. unsigned getCallingConvention() const { return CallingConvention; } - /// Get the struct type used to represent all the arguments in memory. - StructType getArgStruct() const { return ArgStruct; } + /// Get the record type used to represent all the arguments in memory. + RecordType getArgRecord() const { return ArgRecord; } }; } // namespace cir diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.cpp index d655ae9023dd..f1d65916cb54 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.cpp @@ -88,7 +88,7 @@ FuncType LowerTypes::getFunctionType(const LowerFunctionInfo &FI) { // Fast-isel and the optimizer generally like scalar values better than // FCAs, so we flatten them if this is safe to do for this argument. mlir::Type argType = ArgInfo.getCoerceToType(); - StructType st = mlir::dyn_cast(argType); + RecordType st = mlir::dyn_cast(argType); if (st && ArgInfo.isDirect() && ArgInfo.getCanBeFlattened()) { cir_cconv_assert(NumIRArgs == st.getNumElements()); for (unsigned i = 0, e = st.getNumElements(); i != e; ++i) diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/RecordLayoutBuilder.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/RecordLayoutBuilder.cpp index e47fb6fa3afc..caa74d95f13c 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/RecordLayoutBuilder.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/RecordLayoutBuilder.cpp @@ -33,7 +33,7 @@ class EmptySubobjectMap { uint64_t CharWidth; /// The class whose empty entries we're keeping track of. - const StructType Class; + const RecordType Class; /// The highest offset known to contain an empty base subobject. clang::CharUnits MaxEmptyClassOffset; @@ -47,7 +47,7 @@ class EmptySubobjectMap { /// any empty classes. clang::CharUnits SizeOfLargestEmptySubobject; - EmptySubobjectMap(const CIRLowerContext &Context, const StructType Class) + EmptySubobjectMap(const CIRLowerContext &Context, const RecordType Class) : Context(Context), CharWidth(Context.getCharWidth()), Class(Class) { ComputeEmptySubobjectSizes(); } @@ -63,7 +63,7 @@ void EmptySubobjectMap::ComputeEmptySubobjectSizes() { // Check the fields. for (const auto FT : Class.getMembers()) { cir_cconv_assert(!cir::MissingFeatures::qualifiedTypes()); - const auto RT = dyn_cast(FT); + const auto RT = dyn_cast(FT); // We only care about record types. if (!RT) @@ -155,7 +155,7 @@ class ItaniumRecordLayoutBuilder { clang::CharUnits PaddedFieldSize; /// The primary base class (if one exists) of the class we're laying out. - const StructType PrimaryBase; + const RecordType PrimaryBase; /// Whether the primary base of the class we're laying out is virtual. bool PrimaryBaseIsVirtual; @@ -193,9 +193,9 @@ class ItaniumRecordLayoutBuilder { HasOwnVFPtr(false), HasPackedField(false), HandledFirstNonOverlappingEmptyField(false) {} - void layout(const StructType D); + void layout(const RecordType D); - void layoutFields(const StructType D); + void layoutFields(const RecordType D); void layoutField(const Type Ty, bool InsertExtraPadding); void UpdateAlignment(clang::CharUnits NewAlignment, @@ -224,7 +224,7 @@ class ItaniumRecordLayoutBuilder { void initializeLayout(const Type Ty); /// Finalize record layout. Adjust record size based on the alignment. - void finishLayout(const StructType D); + void finishLayout(const RecordType D); uint64_t getDataSizeInBits() const { return DataSize; } @@ -234,7 +234,7 @@ class ItaniumRecordLayoutBuilder { void setDataSize(uint64_t NewSize) { DataSize = NewSize; } }; -void ItaniumRecordLayoutBuilder::layout(const StructType RT) { +void ItaniumRecordLayoutBuilder::layout(const RecordType RT) { initializeLayout(RT); // Lay out the vtable and the non-virtual bases. @@ -250,7 +250,7 @@ void ItaniumRecordLayoutBuilder::layout(const StructType RT) { } void ItaniumRecordLayoutBuilder::initializeLayout(const mlir::Type Ty) { - if (const auto RT = dyn_cast(Ty)) { + if (const auto RT = dyn_cast(Ty)) { IsUnion = RT.isUnion(); cir_cconv_assert(!cir::MissingFeatures::recordDeclIsMSStruct()); } @@ -283,7 +283,7 @@ void ItaniumRecordLayoutBuilder::initializeLayout(const mlir::Type Ty) { !Context.getTargetInfo().defaultsToAIXPowerAlignment() || IsNaturalAlign; // If there is an external AST source, ask it for the various offsets. - if (const auto RT = dyn_cast(Ty)) { + if (const auto RT = dyn_cast(Ty)) { if (cir::MissingFeatures::astContextGetExternalSource()) { cir_cconv_unreachable("NYI"); } @@ -292,7 +292,7 @@ void ItaniumRecordLayoutBuilder::initializeLayout(const mlir::Type Ty) { void ItaniumRecordLayoutBuilder::layoutField(const Type D, bool InsertExtraPadding) { - // auto FieldClass = D.dyn_cast(); + // auto FieldClass = D.dyn_cast(); cir_cconv_assert(!cir::MissingFeatures::fieldDeclIsPotentiallyOverlapping() && !cir::MissingFeatures::CXXRecordDeclIsEmptyCXX11()); bool IsOverlappingEmptyField = false; // FIXME(cir): Needs more features. @@ -466,7 +466,7 @@ void ItaniumRecordLayoutBuilder::layoutField(const Type D, cir_cconv_unreachable("NYI"); } -void ItaniumRecordLayoutBuilder::layoutFields(const StructType D) { +void ItaniumRecordLayoutBuilder::layoutFields(const RecordType D) { // Layout each field, for now, just sequentially, respecting alignment. In // the future, this will need to be tweakable by targets. cir_cconv_assert(!cir::MissingFeatures::recordDeclMayInsertExtraPadding() && @@ -480,7 +480,7 @@ void ItaniumRecordLayoutBuilder::layoutFields(const StructType D) { } } -void ItaniumRecordLayoutBuilder::finishLayout(const StructType D) { +void ItaniumRecordLayoutBuilder::finishLayout(const RecordType D) { // If we have any remaining field tail padding, include that in the overall // size. setSize(std::max(getSizeInBits(), (uint64_t)Context.toBits(PaddedFieldSize))); @@ -537,7 +537,7 @@ void ItaniumRecordLayoutBuilder::checkFieldPadding( cir_cconv_unreachable("NYI"); // FIXME(cir): Should the following be skiped in CIR? - // Don't warn about structs created without a SourceLocation. This can + // Don't warn about records created without a SourceLocation. This can // be done by clients of the AST, such as codegen. unsigned CharBitNum = Context.getTargetInfo().getCharWidth(); @@ -566,7 +566,7 @@ bool isMsLayout(const CIRLowerContext &Context) { /// Does the target C++ ABI require us to skip over the tail-padding /// of the given class (considering it as a base class) when allocating /// objects? -static bool mustSkipTailPadding(clang::TargetCXXABI ABI, const StructType RD) { +static bool mustSkipTailPadding(clang::TargetCXXABI ABI, const RecordType RD) { cir_cconv_assert(!cir::MissingFeatures::recordDeclIsCXXDecl()); switch (ABI.getTailPaddingUseRules()) { case clang::TargetCXXABI::AlwaysUseTailPadding: @@ -611,8 +611,8 @@ static bool mustSkipTailPadding(clang::TargetCXXABI ABI, const StructType RD) { /// (struct/union/class), which indicates its size and field position /// information. const CIRRecordLayout &CIRLowerContext::getCIRRecordLayout(const Type D) const { - cir_cconv_assert(isa(D) && "Not a record type"); - auto RT = dyn_cast(D); + cir_cconv_assert(isa(D) && "Not a record type"); + auto RT = dyn_cast(D); cir_cconv_assert(RT.isComplete() && "Cannot get layout of forward declarations!"); diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/LoweringPrepareX86CXXABI.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/LoweringPrepareX86CXXABI.cpp index 643d8280a20b..334034b682c1 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/LoweringPrepareX86CXXABI.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/LoweringPrepareX86CXXABI.cpp @@ -91,7 +91,7 @@ mlir::Value LoweringPrepareX86CXXABI::lowerVAArgX86_64( // Let's hope LLVM's va_arg instruction can take care of it. // Remove this when X86_64ABIInfo::classify can take care of every type. if (!mlir::isa(op.getType())) + cir::RecordType, LongDoubleType>(op.getType())) return nullptr; // Assume that va_list type is correct; should be pointer to LLVM type: @@ -191,16 +191,16 @@ mlir::Value LoweringPrepareX86CXXABI::lowerVAArgX86_64( if (neededInt && neededSSE) { // FIXME: Cleanup. assert(ai.isDirect() && "Unexpected ABI info for mixed regs"); - StructType structTy = mlir::cast(ai.getCoerceToType()); + auto recordTy = mlir::cast(ai.getCoerceToType()); cir::PointerType addrTy = builder.getPointerTo(ty); mlir::Value tmp = builder.createAlloca(loc, addrTy, ty, "tmp", CharUnits::fromQuantity(tyAlign)); - tmp = builder.createPtrBitcast(tmp, structTy); - assert(structTy.getNumElements() == 2 && + tmp = builder.createPtrBitcast(tmp, recordTy); + assert(recordTy.getNumElements() == 2 && "Unexpected ABI info for mixed regs"); - mlir::Type tyLo = structTy.getMembers()[0]; - mlir::Type tyHi = structTy.getMembers()[1]; + mlir::Type tyLo = recordTy.getMembers()[0]; + mlir::Type tyHi = recordTy.getMembers()[1]; assert((isFPOrFPVectorTy(tyLo) ^ isFPOrFPVectorTy(tyHi)) && "Unexpected ABI info for mixed regs"); mlir::Value gpAddr = builder.createPtrStride(loc, regSaveArea, gp_offset); @@ -295,21 +295,21 @@ mlir::Value LoweringPrepareX86CXXABI::lowerVAArgX86_64( loc, regAddrLo, builder.getUnsignedInt(loc, 16, /*numBits=*/32)); mlir::MLIRContext *Context = abiInfo.getContext().getMLIRContext(); - StructType structTy = + cir::RecordType recordTy = ai.canHaveCoerceToType() - ? cast(ai.getCoerceToType()) - : StructType::get( + ? cast(ai.getCoerceToType()) + : cir::RecordType::get( Context, {DoubleType::get(Context), DoubleType::get(Context)}, - /*packed=*/false, /*padded=*/false, StructType::Struct); + /*packed=*/false, /*padded=*/false, cir::RecordType::Struct); cir::PointerType addrTy = builder.getPointerTo(ty); mlir::Value tmp = builder.createAlloca(loc, addrTy, ty, "tmp", CharUnits::fromQuantity(tyAlign)); - tmp = builder.createPtrBitcast(tmp, structTy); + tmp = builder.createPtrBitcast(tmp, recordTy); mlir::Value v = builder.createLoad( - loc, builder.createPtrBitcast(regAddrLo, structTy.getMembers()[0])); + loc, builder.createPtrBitcast(regAddrLo, recordTy.getMembers()[0])); builder.createStore(loc, v, builder.createGetMemberOp(loc, tmp, "", 0)); v = builder.createLoad( - loc, builder.createPtrBitcast(regAddrHi, structTy.getMembers()[1])); + loc, builder.createPtrBitcast(regAddrHi, recordTy.getMembers()[1])); builder.createStore(loc, v, builder.createGetMemberOp(loc, tmp, "", 1)); tmp = builder.createPtrBitcast(tmp, ty); diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/X86.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/X86.cpp index 0a3bbc53ca7c..4a198dd6091f 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/X86.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/X86.cpp @@ -53,7 +53,7 @@ static bool BitsContainNoUserData(mlir::Type Ty, unsigned StartBit, cir_cconv_unreachable("NYI"); } - if (auto structTy = llvm::dyn_cast(Ty)) { + if (auto recordTy = llvm::dyn_cast(Ty)) { const CIRRecordLayout &Layout = Context.getCIRRecordLayout(Ty); // If this is a C++ record, check the bases first. @@ -64,10 +64,10 @@ static bool BitsContainNoUserData(mlir::Type Ty, unsigned StartBit, // Verify that no field has data that overlaps the region of interest. Yes // this could be sped up a lot by being smarter about queried fields, - // however we're only looking at structs up to 16 bytes, so we don't care + // however we're only looking at records up to 16 bytes, so we don't care // much. unsigned idx = 0; - for (auto type : structTy.getMembers()) { + for (auto type : recordTy.getMembers()) { unsigned FieldOffset = (unsigned)Layout.getFieldOffset(idx); // If we found a field after the region we care about, then we're done. @@ -184,7 +184,7 @@ void X86_64ABIInfo::classify(mlir::Type Ty, uint64_t OffsetBase, Class &Lo, Current = Class::Integer; } else if (mlir::isa(Ty)) { Current = Class::Integer; - } else if (const auto RT = mlir::dyn_cast(Ty)) { + } else if (const auto RT = mlir::dyn_cast(Ty)) { uint64_t Size = getContext().getTypeSize(Ty); // AMD64-ABI 3.2.3p2: Rule 1. If the size of an object is larger @@ -233,7 +233,7 @@ void X86_64ABIInfo::classify(mlir::Type Ty, uint64_t OffsetBase, Class &Lo, // MEMORY. // // The only case a 256-bit or a 512-bit wide vector could be used is - // when the struct contains a single 256-bit or 512-bit element. Early + // when the record contains a single 256-bit or 512-bit element. Early // check and fallback to memory. // // FIXME: Extended the Lo and Hi logic properly to work for size wider @@ -256,7 +256,7 @@ void X86_64ABIInfo::classify(mlir::Type Ty, uint64_t OffsetBase, Class &Lo, Class FieldLo, FieldHi; // Bit-fields require special handling, they do not force the - // structure to be passed in memory even if unaligned, and + // record to be passed in memory even if unaligned, and // therefore they can straddle an eightbyte. if (BitField) { cir_cconv_unreachable("NYI"); @@ -325,7 +325,7 @@ ABIArgInfo X86_64ABIInfo::getIndirectResult(mlir::Type ty, // // We currently expect it to be rare (particularly in well written code) for // arguments to be passed on the stack when there are still free integer - // registers available (this would typically imply large structs being passed + // registers available (this would typically imply large records being passed // by value), so this seems like a fair tradeoff for now. // // We can revisit this if the backend grows support for 'onstack' parameter @@ -379,7 +379,7 @@ mlir::Type X86_64ABIInfo::GetSSETypeAtOffset(mlir::Type IRType, /// The ABI specifies that a value should be passed in an 8-byte GPR. This /// means that we either have a scalar or we are talking about the high or low -/// part of an up-to-16-byte struct. This routine picks the best CIR type +/// part of an up-to-16-byte record. This routine picks the best CIR type /// to represent this, which may be i64 or may be anything else that the /// backend will pass in a GPR that works better (e.g. i8, %foo*, etc). /// @@ -426,9 +426,9 @@ mlir::Type X86_64ABIInfo::GetINTEGERTypeAtOffset(mlir::Type DestTy, } } - if (auto RT = mlir::dyn_cast(DestTy)) { - // If this is a struct, recurse into the field at the specified offset. - const cir::StructLayout *SL = getDataLayout().getStructLayout(RT); + if (auto RT = mlir::dyn_cast(DestTy)) { + // If this is a record, recurse into the field at the specified offset. + const cir::RecordLayout *SL = getDataLayout().getRecordLayout(RT); if (IROffset < SL->getSizeInBytes()) { unsigned FieldIdx = SL->getElementContainingOffset(IROffset); IROffset -= SL->getElementOffset(FieldIdx); @@ -439,7 +439,7 @@ mlir::Type X86_64ABIInfo::GetINTEGERTypeAtOffset(mlir::Type DestTy, } // Okay, we don't have any better idea of what to pass, so we pass this in - // an integer register that isn't too big to fit the rest of the struct. + // an integer register that isn't too big to fit the rest of the record. unsigned TySizeInBytes = (unsigned)getContext().getTypeSizeInChars(SourceTy).getQuantity(); @@ -448,7 +448,7 @@ mlir::Type X86_64ABIInfo::GetINTEGERTypeAtOffset(mlir::Type DestTy, cir_cconv_assert(TySizeInBytes != SourceOffset && "Empty field?"); // It is always safe to classify this as an integer type up to i64 that - // isn't larger than the structure. + // isn't larger than the record. // FIXME(cir): Perhaps we should have the concept of singless integers in // CIR, mostly because coerced types should carry sign. On the other hand, // this might not make a difference in practice. For now, we just preserve the @@ -469,7 +469,7 @@ static mlir::Type GetX86_64ByValArgumentPair(mlir::Type lo, mlir::Type hi, const cir::CIRDataLayout &td) { // In order to correctly satisfy the ABI, we need to the high part to start // at offset 8. If the high and low parts we inferred are both 4-byte types - // (e.g. i32 and i32) then the resultant struct type ({i32,i32}) won't have + // (e.g. i32 and i32) then the resultant record type ({i32,i32}) won't have // the second element at offset 8. Check for this: unsigned loSize = (unsigned)td.getTypeAllocSize(lo); llvm::Align highAlign = td.getABITypeAlign(hi); @@ -479,7 +479,7 @@ static mlir::Type GetX86_64ByValArgumentPair(mlir::Type lo, mlir::Type hi, // To handle this, we have to increase the size of the low part so that the // second element will start at an 8 byte offset. We can't increase the size // of the second element because it might make us access off the end of the - // struct. + // record. if (highStart != 8) { // There are usually two sorts of types the ABI generation code can produce // for the low part of a pair that aren't 8 bytes in size: half, float or @@ -496,11 +496,11 @@ static mlir::Type GetX86_64ByValArgumentPair(mlir::Type lo, mlir::Type hi, } } - auto result = StructType::get(lo.getContext(), {lo, hi}, /*packed=*/false, - /*padded=*/false, StructType::Struct); + auto result = RecordType::get(lo.getContext(), {lo, hi}, /*packed=*/false, + /*padded=*/false, RecordType::Struct); // Verify that the second element is at an 8-byte offset. - assert(td.getStructLayout(result)->getElementOffset(1) == 8 && + assert(td.getRecordLayout(result)->getElementOffset(1) == 8 && "Invalid x86-64 argument pair!"); return result; } @@ -569,7 +569,7 @@ cir::ABIArgInfo X86_64ABIInfo::classifyReturnType(mlir::Type RetTy) const { // If a high part was specified, merge it together with the low part. It is // known to pass in the high eightbyte of the result. We do this by forming - // a first class struct aggregate with the high and low part: {low, high} + // a first class record aggregate with the high and low part: {low, high} if (HighPart) resType = GetX86_64ByValArgumentPair(resType, HighPart, getDataLayout()); @@ -686,7 +686,7 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType( // If a high part was specified, merge it together with the low part. It is // known to pass in the high eightbyte of the result. We do this by forming a - // first class struct aggregate with the high and low part: {low, high} + // first class record aggregate with the high and low part: {low, high} if (HighPart) ResType = GetX86_64ByValArgumentPair(ResType, HighPart, getDataLayout()); diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index 0bc01e5afae7..bb1a43893e55 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -449,7 +449,7 @@ class CirAttrToValue { mlir::Value visit(mlir::Attribute attr) { return llvm::TypeSwitch(attr) .Case( [&](auto attrT) { return visitCirAttr(attrT); }) @@ -459,7 +459,7 @@ class CirAttrToValue { mlir::Value visitCirAttr(cir::IntAttr attr); mlir::Value visitCirAttr(cir::FPAttr attr); mlir::Value visitCirAttr(cir::ConstPtrAttr attr); - mlir::Value visitCirAttr(cir::ConstStructAttr attr); + mlir::Value visitCirAttr(cir::ConstRecordAttr attr); mlir::Value visitCirAttr(cir::ConstArrayAttr attr); mlir::Value visitCirAttr(cir::ConstVectorAttr attr); mlir::Value visitCirAttr(cir::BoolAttr attr); @@ -534,14 +534,14 @@ mlir::Value CirAttrToValue::visitCirAttr(cir::PoisonAttr poisonAttr) { loc, converter->convertType(poisonAttr.getType())); } -/// ConstStruct visitor. -mlir::Value CirAttrToValue::visitCirAttr(cir::ConstStructAttr constStruct) { - auto llvmTy = converter->convertType(constStruct.getType()); +/// ConstRecord visitor. +mlir::Value CirAttrToValue::visitCirAttr(cir::ConstRecordAttr constRecord) { + auto llvmTy = converter->convertType(constRecord.getType()); auto loc = parentOp->getLoc(); mlir::Value result = rewriter.create(loc, llvmTy); - // Iteratively lower each constant element of the struct. - for (auto [idx, elt] : llvm::enumerate(constStruct.getMembers())) { + // Iteratively lower each constant element of the record. + for (auto [idx, elt] : llvm::enumerate(constRecord.getMembers())) { mlir::Value init = emitCirAttrToMemory(parentOp, elt, rewriter, converter, dataLayout); result = rewriter.create(loc, result, init, idx); @@ -1864,17 +1864,17 @@ mlir::LogicalResult CIRToLLVMConstantOpLowering::matchAndRewrite( rewriter.eraseOp(op); return mlir::success(); } - } else if (const auto structAttr = - mlir::dyn_cast(op.getValue())) { + } else if (const auto recordAttr = + mlir::dyn_cast(op.getValue())) { // TODO(cir): this diverges from traditional lowering. Normally the // initializer would be a global constant that is memcopied. Here we just // define a local constant with llvm.undef that will be stored into the // stack. - auto initVal = lowerCirAttrAsValue(op, structAttr, rewriter, typeConverter, + auto initVal = lowerCirAttrAsValue(op, recordAttr, rewriter, typeConverter, dataLayout); rewriter.replaceOp(op, initVal); return mlir::success(); - } else if (auto strTy = mlir::dyn_cast(op.getType())) { + } else if (auto strTy = mlir::dyn_cast(op.getType())) { auto attr = op.getValue(); if (mlir::isa(attr)) { auto initVal = @@ -1883,7 +1883,7 @@ mlir::LogicalResult CIRToLLVMConstantOpLowering::matchAndRewrite( return mlir::success(); } - return op.emitError() << "unsupported lowering for struct constant type " + return op.emitError() << "unsupported lowering for record constant type " << op.getType(); } else if (const auto vecTy = mlir::dyn_cast(op.getType())) { rewriter.replaceOp(op, lowerCirAttrAsValue(op, op.getValue(), rewriter, @@ -2415,7 +2415,7 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::lowerInitializer( return lowerInitializerDirect(rewriter, op, llvmType, init, useInitializerRegion); } else if (mlir::isa(init)) { // TODO(cir): once LLVM's dialect has proper equivalent attributes this // should be updated. For now, we use a custom op to initialize globals @@ -3527,22 +3527,22 @@ mlir::LogicalResult CIRToLLVMGetMemberOpLowering::matchAndRewrite( cir::GetMemberOp op, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const { auto llResTy = getTypeConverter()->convertType(op.getType()); - const auto structTy = - mlir::cast(op.getAddrTy().getPointee()); - assert(structTy && "expected struct type"); + const auto recordTy = + mlir::cast(op.getAddrTy().getPointee()); + assert(recordTy && "expected record type"); - switch (structTy.getKind()) { - case cir::StructType::Struct: - case cir::StructType::Class: { + switch (recordTy.getKind()) { + case cir::RecordType::Struct: + case cir::RecordType::Class: { // Since the base address is a pointer to an aggregate, the first offset // is always zero. The second offset tell us which member it will access. llvm::SmallVector offset{0, op.getIndex()}; - const auto elementTy = getTypeConverter()->convertType(structTy); + const auto elementTy = getTypeConverter()->convertType(recordTy); rewriter.replaceOpWithNewOp(op, llResTy, elementTy, adaptor.getAddr(), offset); return mlir::success(); } - case cir::StructType::Union: + case cir::RecordType::Union: // Union members share the address space, so we just need a bitcast to // conform to type-checking. rewriter.replaceOpWithNewOp(op, llResTy, @@ -3564,16 +3564,16 @@ mlir::LogicalResult CIRToLLVMExtractMemberOpLowering::matchAndRewrite( return mlir::success(); } - auto cirStructTy = mlir::cast(recordTy); - switch (cirStructTy.getKind()) { - case cir::StructType::Struct: - case cir::StructType::Class: { + auto cirRecordTy = mlir::cast(recordTy); + switch (cirRecordTy.getKind()) { + case cir::RecordType::Struct: + case cir::RecordType::Class: { rewriter.replaceOpWithNewOp( op, adaptor.getRecord(), indecies); return mlir::success(); } - case cir::StructType::Union: { + case cir::RecordType::Union: { op.emitError("cir.extract_member cannot extract member from a union"); return mlir::failure(); } @@ -3586,8 +3586,8 @@ mlir::LogicalResult CIRToLLVMInsertMemberOpLowering::matchAndRewrite( std::int64_t indecies[1] = {static_cast(op.getIndex())}; mlir::Type recordTy = op.getRecord().getType(); - if (auto cirStructTy = mlir::dyn_cast(recordTy)) { - if (cirStructTy.getKind() == cir::StructType::Union) { + if (auto cirRecordTy = mlir::dyn_cast(recordTy)) { + if (cirRecordTy.getKind() == cir::RecordType::Union) { op.emitError("cir.update_member cannot update member of a union"); return mlir::failure(); } @@ -4471,19 +4471,19 @@ void prepareTypeConverter(mlir::LLVMTypeConverter &converter, auto varArg = type.isVarArg(); return mlir::LLVM::LLVMFunctionType::get(result, arguments, varArg); }); - converter.addConversion([&](cir::StructType type) -> mlir::Type { + converter.addConversion([&](cir::RecordType type) -> mlir::Type { // FIXME(cir): create separate unions, struct, and classes types. // Convert struct members. llvm::SmallVector llvmMembers; switch (type.getKind()) { - case cir::StructType::Class: + case cir::RecordType::Class: // TODO(cir): This should be properly validated. - case cir::StructType::Struct: + case cir::RecordType::Struct: for (auto ty : type.getMembers()) llvmMembers.push_back(convertTypeForMemory(converter, dataLayout, ty)); break; // Unions are lowered as only the largest member. - case cir::StructType::Union: { + case cir::RecordType::Union: { auto largestMember = type.getLargestMember(dataLayout); if (largestMember) llvmMembers.push_back( @@ -4497,15 +4497,15 @@ void prepareTypeConverter(mlir::LLVMTypeConverter &converter, } } - // Struct has a name: lower as an identified struct. + // Record has a name: lower as an identified record. mlir::LLVM::LLVMStructType llvmStruct; if (type.getName()) { llvmStruct = mlir::LLVM::LLVMStructType::getIdentified( type.getContext(), type.getPrefixedName()); if (llvmStruct.setBody(llvmMembers, /*isPacked=*/type.getPacked()) .failed()) - llvm_unreachable("Failed to set body of struct"); - } else { // Struct has no name: lower as literal struct. + llvm_unreachable("Failed to set body of record"); + } else { // Record has no name: lower as literal record. llvmStruct = mlir::LLVM::LLVMStructType::getLiteral( type.getContext(), llvmMembers, /*isPacked=*/type.getPacked()); } diff --git a/clang/test/CIR/CallConvLowering/AArch64/struct.c b/clang/test/CIR/CallConvLowering/AArch64/struct.c index 4d22819a4ef4..2100d02ec43b 100644 --- a/clang/test/CIR/CallConvLowering/AArch64/struct.c +++ b/clang/test/CIR/CallConvLowering/AArch64/struct.c @@ -70,7 +70,7 @@ void foo1() { // CIR: %[[#V2:]] = cir.alloca !ty_S, !cir.ptr, ["__retval"] {alignment = 4 : i64} // CIR: %[[#V3:]] = cir.alloca !ty_S, !cir.ptr, ["s2"] // CIR: %[[#V4:]] = cir.alloca !ty_S, !cir.ptr, ["tmp"] {alignment = 4 : i64} -// CIR: %[[#V5:]] = cir.const #cir.const_struct<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !ty_S +// CIR: %[[#V5:]] = cir.const #cir.const_record<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !ty_S // CIR: cir.store %[[#V5]], %[[#V3]] : !ty_S, !cir.ptr // CIR: %[[#V6:]] = cir.cast(bitcast, %[[#V0]] : !cir.ptr), !cir.ptr // CIR: %[[#V7:]] = cir.load %[[#V6]] : !cir.ptr, !u64i diff --git a/clang/test/CIR/CallConvLowering/AArch64/union.c b/clang/test/CIR/CallConvLowering/AArch64/union.c index ed02e9aded7a..857061b3804a 100644 --- a/clang/test/CIR/CallConvLowering/AArch64/union.c +++ b/clang/test/CIR/CallConvLowering/AArch64/union.c @@ -3,7 +3,7 @@ // RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll -fclangir-call-conv-lowering // RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM -// CIR: !ty_U = !cir.struct +// CIR: !ty_U = !cir.record // LLVM: %union.U = type { i32 } typedef union { int a, b, c; diff --git a/clang/test/CIR/CallConvLowering/x86_64/int128.cpp b/clang/test/CIR/CallConvLowering/x86_64/int128.cpp index a8ca701331f7..8d8dadd5dae0 100644 --- a/clang/test/CIR/CallConvLowering/x86_64/int128.cpp +++ b/clang/test/CIR/CallConvLowering/x86_64/int128.cpp @@ -3,7 +3,7 @@ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -fclangir-call-conv-lowering -emit-llvm %s -o %t.ll // RUN: FileCheck --input-file=%t.ll %s --check-prefix=LLVM -// CHECK: ![[I128_STRUCT:.+]] = !cir.struct +// CHECK: ![[I128_STRUCT:.+]] = !cir.record // CHECK: @_Z5test1nn(%[[ARG0:.+]]: !s64i loc({{.+}}), %[[ARG1:.+]]: !s64i loc({{.+}}), %[[ARG2:.+]]: !s64i loc({{.+}}), %[[ARG3:.+]]: !s64i loc({{.+}})) -> ![[I128_STRUCT]] // LLVM: define dso_local { i64, i64 } @_Z5test1nn(i64 %[[#A_LO:]], i64 %[[#A_HI:]], i64 %[[#B_LO:]], i64 %[[#B_HI:]]) diff --git a/clang/test/CIR/CodeGen/CUDA/registration.cu b/clang/test/CIR/CodeGen/CUDA/registration.cu index 9446ce04ae4d..fad25c6e77ec 100644 --- a/clang/test/CIR/CodeGen/CUDA/registration.cu +++ b/clang/test/CIR/CodeGen/CUDA/registration.cu @@ -84,7 +84,7 @@ __global__ void fn() {} // The first value is CUDA file head magic number. // CIR-HOST: cir.global "private" constant internal @__cuda_fatbin_wrapper -// CIR-HOST: = #cir.const_struct<{ +// CIR-HOST: = #cir.const_record<{ // CIR-HOST: #cir.int<1180844977> : !s32i, // CIR-HOST: #cir.int<1> : !s32i, // CIR-HOST: #cir.global_view<@__cuda_fatbin_str> : !cir.ptr, diff --git a/clang/test/CIR/CodeGen/agg-init.cpp b/clang/test/CIR/CodeGen/agg-init.cpp index 68a302a98e2d..9629f4b07b62 100644 --- a/clang/test/CIR/CodeGen/agg-init.cpp +++ b/clang/test/CIR/CodeGen/agg-init.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fclangir -Wno-unused-value -emit-cir %s -o %t.cir // RUN: FileCheck --input-file=%t.cir %s -// CHECK: !ty_yep_ = !cir.struct +// CHECK: !ty_yep_ = !cir.record typedef enum xxy_ { xxy_Low = 0, @@ -49,7 +49,7 @@ void yo() { // CHECK: cir.func @_Z2yov() // CHECK: %0 = cir.alloca !ty_Yo, !cir.ptr, ["ext"] {alignment = 8 : i64} // CHECK: %1 = cir.alloca !ty_Yo, !cir.ptr, ["ext2", init] {alignment = 8 : i64} -// CHECK: %2 = cir.const #cir.const_struct<{#cir.int<1000070000> : !u32i, #cir.ptr : !cir.ptr, #cir.int<0> : !u64i}> : !ty_Yo +// CHECK: %2 = cir.const #cir.const_record<{#cir.int<1000070000> : !u32i, #cir.ptr : !cir.ptr, #cir.int<0> : !u64i}> : !ty_Yo // CHECK: cir.store %2, %0 : !ty_Yo, !cir.ptr // CHECK: %3 = cir.get_member %1[0] {name = "type"} : !cir.ptr -> !cir.ptr // CHECK: %4 = cir.const #cir.int<1000066001> : !u32i diff --git a/clang/test/CIR/CodeGen/agg-init2.cpp b/clang/test/CIR/CodeGen/agg-init2.cpp index 66b3e380a010..4eef5e40c25e 100644 --- a/clang/test/CIR/CodeGen/agg-init2.cpp +++ b/clang/test/CIR/CodeGen/agg-init2.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fclangir -Wno-unused-value -emit-cir %s -o %t.cir // RUN: FileCheck --input-file=%t.cir %s -// CHECK: !ty_Zero = !cir.struct +// CHECK: !ty_Zero = !cir.record struct Zero { void yolo(); diff --git a/clang/test/CIR/CodeGen/array.c b/clang/test/CIR/CodeGen/array.c index ed83c663bd60..80f42c93a929 100644 --- a/clang/test/CIR/CodeGen/array.c +++ b/clang/test/CIR/CodeGen/array.c @@ -5,7 +5,7 @@ struct S { int i; } arr[3] = {{1}}; -// CHECK: cir.global external @arr = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_S, #cir.zero : !ty_S, #cir.zero : !ty_S]> : !cir.array +// CHECK: cir.global external @arr = #cir.const_array<[#cir.const_record<{#cir.int<1> : !s32i}> : !ty_S, #cir.zero : !ty_S, #cir.zero : !ty_S]> : !cir.array int a[4]; // CHECK: cir.global external @a = #cir.zero : !cir.array diff --git a/clang/test/CIR/CodeGen/array.cpp b/clang/test/CIR/CodeGen/array.cpp index 4504b58c7078..b6209dec6c3a 100644 --- a/clang/test/CIR/CodeGen/array.cpp +++ b/clang/test/CIR/CodeGen/array.cpp @@ -70,7 +70,7 @@ int globalNullArr[] = {0, 0}; struct S { int i; } arr[3] = {{1}}; -// CHECK: cir.global external @arr = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_S, #cir.zero : !ty_S, #cir.zero : !ty_S]> : !cir.array +// CHECK: cir.global external @arr = #cir.const_array<[#cir.const_record<{#cir.int<1> : !s32i}> : !ty_S, #cir.zero : !ty_S, #cir.zero : !ty_S]> : !cir.array void testPointerDecaySubscriptAccess(int arr[]) { // CHECK: cir.func @{{.+}}testPointerDecaySubscriptAccess diff --git a/clang/test/CIR/CodeGen/atomic-xchg-field.c b/clang/test/CIR/CodeGen/atomic-xchg-field.c index 4ca4daa4baf6..3a6236df2088 100644 --- a/clang/test/CIR/CodeGen/atomic-xchg-field.c +++ b/clang/test/CIR/CodeGen/atomic-xchg-field.c @@ -22,7 +22,7 @@ void field_access(wPtr item) { __atomic_exchange_n((&item->ref), (((void*)0)), 5); } -// CHECK: ![[W:.*]] = !cir.struct, {{.*}} {alignment = 8 : i64} // CHECK: %[[FIELD:.*]] = cir.load %[[WADDR]] diff --git a/clang/test/CIR/CodeGen/atomic.cpp b/clang/test/CIR/CodeGen/atomic.cpp index dcdae8065de3..22a3ac70d9d1 100644 --- a/clang/test/CIR/CodeGen/atomic.cpp +++ b/clang/test/CIR/CodeGen/atomic.cpp @@ -21,7 +21,7 @@ unsigned int ui; signed long long sll; unsigned long long ull; -// CHECK: ![[A:.*]] = !cir.struct +// CHECK: ![[A:.*]] = !cir.record int basic_binop_fetch(int *i) { return __atomic_add_fetch(i, 1, memory_order_seq_cst); diff --git a/clang/test/CIR/CodeGen/bitfield-union.c b/clang/test/CIR/CodeGen/bitfield-union.c index b08b035e2fd0..b0501c5876b4 100644 --- a/clang/test/CIR/CodeGen/bitfield-union.c +++ b/clang/test/CIR/CodeGen/bitfield-union.c @@ -13,7 +13,7 @@ void main() { d.z = 0; } -// CHECK: !ty_demo = !cir.struct +// CHECK: !ty_demo = !cir.record // CHECK: #bfi_y = #cir.bitfield_info // CHECK: #bfi_z = #cir.bitfield_info diff --git a/clang/test/CIR/CodeGen/bitfields.c b/clang/test/CIR/CodeGen/bitfields.c index d102ef699dde..fbb36533225c 100644 --- a/clang/test/CIR/CodeGen/bitfields.c +++ b/clang/test/CIR/CodeGen/bitfields.c @@ -55,16 +55,16 @@ typedef struct { // because (tail - startOffset) is 65 after 'l' field } U; -// CHECK: !ty_D = !cir.struct -// CHECK: !ty_G = !cir.struct -// CHECK: !ty_T = !cir.struct -// CHECK: !ty_anon2E0 = !cir.struct +// CHECK: !ty_D = !cir.record +// CHECK: !ty_G = !cir.record +// CHECK: !ty_T = !cir.record +// CHECK: !ty_anon2E0 = !cir.record // CHECK: #bfi_a = #cir.bitfield_info // CHECK: #bfi_e = #cir.bitfield_info -// CHECK: !ty_S = !cir.struct, !u16i, !u32i}> -// CHECK: !ty_U = !cir.struct}> -// CHECK: !ty___long = !cir.struct}> -// CHECK: !ty_anon_struct = !cir.struct, !s32i}> +// CHECK: !ty_S = !cir.record, !u16i, !u32i}> +// CHECK: !ty_U = !cir.record}> +// CHECK: !ty___long = !cir.record}> +// CHECK: !ty_anon_struct = !cir.record, !s32i}> // CHECK: #bfi_d = #cir.bitfield_info, size = 2, offset = 17, is_signed = true> // CHECK: cir.func {{.*@store_field}} @@ -127,7 +127,7 @@ void createU() { // CHECK: cir.func {{.*@createD}} // CHECK: %0 = cir.alloca !ty_D, !cir.ptr, ["d"] {alignment = 4 : i64} // CHECK: %1 = cir.cast(bitcast, %0 : !cir.ptr), !cir.ptr -// CHECK: %2 = cir.const #cir.const_struct<{#cir.int<33> : !u8i, #cir.int<0> : !u8i, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array, #cir.int<3> : !s32i}> : !ty_anon_struct +// CHECK: %2 = cir.const #cir.const_record<{#cir.int<33> : !u8i, #cir.int<0> : !u8i, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array, #cir.int<3> : !s32i}> : !ty_anon_struct // CHECK: cir.store %2, %1 : !ty_anon_struct, !cir.ptr void createD() { D d = {1,2,3}; @@ -148,7 +148,7 @@ typedef struct { int y ; } G; -// CHECK: cir.global external @g = #cir.const_struct<{#cir.int<133> : !u8i, #cir.int<127> : !u8i, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array, #cir.int<254> : !s32i}> : !ty_anon_struct +// CHECK: cir.global external @g = #cir.const_record<{#cir.int<133> : !u8i, #cir.int<127> : !u8i, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array, #cir.int<254> : !s32i}> : !ty_anon_struct G g = { -123, 254UL}; // CHECK: cir.func {{.*@get_y}} diff --git a/clang/test/CIR/CodeGen/bitfields.cpp b/clang/test/CIR/CodeGen/bitfields.cpp index 7efa43e5c9df..58e0f26f73cc 100644 --- a/clang/test/CIR/CodeGen/bitfields.cpp +++ b/clang/test/CIR/CodeGen/bitfields.cpp @@ -27,10 +27,10 @@ typedef struct { int a : 3; // one bitfield with size < 8 unsigned b; } T; -// CHECK: !ty_T = !cir.struct -// CHECK: !ty_anon2E0 = !cir.struct -// CHECK: !ty_S = !cir.struct, !u16i, !u32i}> -// CHECK: !ty___long = !cir.struct}> +// CHECK: !ty_T = !cir.record +// CHECK: !ty_anon2E0 = !cir.record +// CHECK: !ty_S = !cir.record, !u16i, !u32i}> +// CHECK: !ty___long = !cir.record}> // CHECK: cir.func @_Z11store_field // CHECK: [[TMP0:%.*]] = cir.alloca !ty_S, !cir.ptr diff --git a/clang/test/CIR/CodeGen/builtin-arm-exclusive.c b/clang/test/CIR/CodeGen/builtin-arm-exclusive.c index fc35cb1dd87b..da5b3d8a6db7 100644 --- a/clang/test/CIR/CodeGen/builtin-arm-exclusive.c +++ b/clang/test/CIR/CodeGen/builtin-arm-exclusive.c @@ -4,7 +4,7 @@ struct twoFldT { char a, b; }; -// CIR: !ty_twoFldT = !cir.struct}> -// CIR-DAG: cir.global external @testPromotedStructGlobal = #cir.const_struct<{#cir.const_struct<{#cir.int<1> : !s16i, #cir.int<2> : !s16i, #cir.int<3> : !s16i}> : ![[PS]], #cir.zero : !cir.array}> : ![[ANON]] +// CIR-DAG: ![[PS:.*]] = !cir.record}> +// CIR-DAG: cir.global external @testPromotedStructGlobal = #cir.const_record<{#cir.const_record<{#cir.int<1> : !s16i, #cir.int<2> : !s16i, #cir.int<3> : !s16i}> : ![[PS]], #cir.zero : !cir.array}> : ![[ANON]] // LLVM-DAG: %[[PS:.*]] = type { i16, i16, i16 } // LLVM-DAG: @testPromotedStructGlobal = global { %[[PS]], [2 x i8] } { %[[PS]] { i16 1, i16 2, i16 3 }, [2 x i8] zeroinitializer } diff --git a/clang/test/CIR/CodeGen/call-via-class-member-funcptr.cpp b/clang/test/CIR/CodeGen/call-via-class-member-funcptr.cpp index ba8e811151e6..02ea747b5b83 100644 --- a/clang/test/CIR/CodeGen/call-via-class-member-funcptr.cpp +++ b/clang/test/CIR/CodeGen/call-via-class-member-funcptr.cpp @@ -16,8 +16,8 @@ class f { const char *f::b() { return g.b(h); } void fn1() { f f1; } -// CIR: ty_a = !cir.struct -// CIR: ty_f = !cir.struct +// CIR: ty_a = !cir.record +// CIR: ty_f = !cir.record // CIR: cir.global external @h = #cir.int<0> // CIR: cir.func private @_ZN1a1bEi(!s32i) -> !cir.ptr diff --git a/clang/test/CIR/CodeGen/compound-literal.c b/clang/test/CIR/CodeGen/compound-literal.c index c4b281fd7617..b3881f4c69ff 100644 --- a/clang/test/CIR/CodeGen/compound-literal.c +++ b/clang/test/CIR/CodeGen/compound-literal.c @@ -13,7 +13,7 @@ S a = { }; // CIR: cir.global "private" internal @".compoundLiteral.0" = #cir.zero : !cir.array {alignment = 4 : i64} -// CIR: cir.global external @a = #cir.const_struct<{#cir.global_view<@".compoundLiteral.0"> : !cir.ptr}> : !ty_S +// CIR: cir.global external @a = #cir.const_record<{#cir.global_view<@".compoundLiteral.0"> : !cir.ptr}> : !ty_S // LLVM: @.compoundLiteral.0 = internal global [0 x i32] zeroinitializer // LLVM: @a = global %struct.S { ptr @.compoundLiteral.0 } @@ -23,7 +23,7 @@ S b = { }; // CIR: cir.global "private" internal @".compoundLiteral.1" = #cir.const_array<[#cir.int<1> : !s32i]> : !cir.array {alignment = 4 : i64} -// CIR: cir.global external @b = #cir.const_struct<{#cir.global_view<@".compoundLiteral.1"> : !cir.ptr}> : !ty_S +// CIR: cir.global external @b = #cir.const_record<{#cir.global_view<@".compoundLiteral.1"> : !cir.ptr}> : !ty_S // LLVM: @.compoundLiteral.1 = internal global [1 x i32] [i32 1] // LLVM: @b = global %struct.S { ptr @.compoundLiteral.1 } diff --git a/clang/test/CIR/CodeGen/conditional-cleanup.cpp b/clang/test/CIR/CodeGen/conditional-cleanup.cpp index d1ecca2d1da4..eadbb2307ad4 100644 --- a/clang/test/CIR/CodeGen/conditional-cleanup.cpp +++ b/clang/test/CIR/CodeGen/conditional-cleanup.cpp @@ -23,11 +23,11 @@ namespace test7 { } } -// CIR-DAG: ![[A:.*]] = !cir.struct, !cir.ptr>, ["__retval"] {alignment = 8 : i64} @@ -232,4 +232,4 @@ namespace test7 { // CIR_EH: } // Nothing special, just test it passes! -// CIR_FLAT_EH-LABEL: @_ZN5test74testEv \ No newline at end of file +// CIR_FLAT_EH-LABEL: @_ZN5test74testEv diff --git a/clang/test/CIR/CodeGen/const-bitfields.c b/clang/test/CIR/CodeGen/const-bitfields.c index 71e02507b9d0..ae07bf5ed90c 100644 --- a/clang/test/CIR/CodeGen/const-bitfields.c +++ b/clang/test/CIR/CodeGen/const-bitfields.c @@ -14,17 +14,17 @@ struct Inner { unsigned d : 30; }; -// CHECK: !ty_anon_struct = !cir.struct -// CHECK: !ty_T = !cir.struct, !s32i} #cir.record.decl.ast> -// CHECK: !ty_anon_struct1 = !cir.struct, !u8i, !u8i, !u8i, !u8i}> +// CHECK: !ty_anon_struct = !cir.record +// CHECK: !ty_T = !cir.record, !s32i} #cir.record.decl.ast> +// CHECK: !ty_anon_struct1 = !cir.record, !u8i, !u8i, !u8i, !u8i}> // CHECK: #bfi_Z = #cir.bitfield_info, size = 9, offset = 11, is_signed = true> struct T GV = { 1, 5, 26, 42 }; -// CHECK: cir.global external @GV = #cir.const_struct<{#cir.int<161> : !u8i, #cir.int<208> : !u8i, #cir.int<0> : !u8i, #cir.zero : !u8i, #cir.int<42> : !s32i}> : !ty_anon_struct +// CHECK: cir.global external @GV = #cir.const_record<{#cir.int<161> : !u8i, #cir.int<208> : !u8i, #cir.int<0> : !u8i, #cir.zero : !u8i, #cir.int<42> : !s32i}> : !ty_anon_struct // check padding is used (const array of zeros) struct Inner var = { 1, 0, 1, 21}; -// CHECK: cir.global external @var = #cir.const_struct<{#cir.int<5> : !u8i, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array, #cir.int<21> : !u8i, #cir.int<0> : !u8i, #cir.int<0> : !u8i, #cir.int<0> : !u8i}> : !ty_anon_struct1 +// CHECK: cir.global external @var = #cir.const_record<{#cir.int<5> : !u8i, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array, #cir.int<21> : !u8i, #cir.int<0> : !u8i, #cir.int<0> : !u8i, #cir.int<0> : !u8i}> : !ty_anon_struct1 // CHECK: cir.func {{.*@getZ()}} diff --git a/clang/test/CIR/CodeGen/coro-task.cpp b/clang/test/CIR/CodeGen/coro-task.cpp index a572c4b20873..e9ba7007bb4e 100644 --- a/clang/test/CIR/CodeGen/coro-task.cpp +++ b/clang/test/CIR/CodeGen/coro-task.cpp @@ -126,13 +126,13 @@ co_invoke_fn co_invoke; }} // namespace folly::coro -// CHECK-DAG: ![[IntTask:.*]] = !cir.struct" padded {!u8i}> -// CHECK-DAG: ![[VoidTask:.*]] = !cir.struct" padded {!u8i}> -// CHECK-DAG: ![[VoidPromisse:.*]] = !cir.struct::promise_type" padded {!u8i}> -// CHECK-DAG: ![[CoroHandleVoid:.*]] = !cir.struct" padded {!u8i}> -// CHECK-DAG: ![[CoroHandlePromise:ty_.*]] = !cir.struct::promise_type>" padded {!u8i}> -// CHECK-DAG: ![[StdString:.*]] = !cir.struct -// CHECK-DAG: ![[SuspendAlways:.*]] = !cir.struct +// CHECK-DAG: ![[IntTask:.*]] = !cir.record" padded {!u8i}> +// CHECK-DAG: ![[VoidTask:.*]] = !cir.record" padded {!u8i}> +// CHECK-DAG: ![[VoidPromisse:.*]] = !cir.record::promise_type" padded {!u8i}> +// CHECK-DAG: ![[CoroHandleVoid:.*]] = !cir.record" padded {!u8i}> +// CHECK-DAG: ![[CoroHandlePromise:ty_.*]] = !cir.record::promise_type>" padded {!u8i}> +// CHECK-DAG: ![[StdString:.*]] = !cir.record +// CHECK-DAG: ![[SuspendAlways:.*]] = !cir.record // CHECK: module {{.*}} { // CHECK-NEXT: cir.global external @_ZN5folly4coro9co_invokeE = #cir.zero : !ty_folly3A3Acoro3A3Aco_invoke_fn diff --git a/clang/test/CIR/CodeGen/ctor.cpp b/clang/test/CIR/CodeGen/ctor.cpp index c3ac21d6cd56..c0b524e199ba 100644 --- a/clang/test/CIR/CodeGen/ctor.cpp +++ b/clang/test/CIR/CodeGen/ctor.cpp @@ -11,7 +11,7 @@ void baz() { Struk s; } -// CHECK: !ty_Struk = !cir.struct +// CHECK: !ty_Struk = !cir.record // CHECK: cir.func linkonce_odr @_ZN5StrukC2Ev(%arg0: !cir.ptr // CHECK-NEXT: %0 = cir.alloca !cir.ptr, !cir.ptr>, ["this", init] {alignment = 8 : i64} diff --git a/clang/test/CIR/CodeGen/derived-to-base.cpp b/clang/test/CIR/CodeGen/derived-to-base.cpp index ec7f175b3dcd..14f7a7a57184 100644 --- a/clang/test/CIR/CodeGen/derived-to-base.cpp +++ b/clang/test/CIR/CodeGen/derived-to-base.cpp @@ -75,11 +75,11 @@ void C3::Layer::Initialize() { } } -// CHECK-DAG: !ty_C23A3ALayer = !cir.struct !u32i>>>} #cir.record.decl.ast> +// CHECK: ![[ClassA:ty_.*]] = !cir.record !u32i>>>} #cir.record.decl.ast> // Class B -// CHECK: ![[ClassB:ty_.*]] = !cir.struct +// CHECK: ![[ClassB:ty_.*]] = !cir.record // CHECK: cir.func @_Z4bluev() // CHECK: %0 = cir.alloca !ty_PSEvent, !cir.ptr, ["p", init] {alignment = 8 : i64} diff --git a/clang/test/CIR/CodeGen/dynamic-cast-relative-layout.cpp b/clang/test/CIR/CodeGen/dynamic-cast-relative-layout.cpp index c50d03fa68ed..33c5adc295da 100644 --- a/clang/test/CIR/CodeGen/dynamic-cast-relative-layout.cpp +++ b/clang/test/CIR/CodeGen/dynamic-cast-relative-layout.cpp @@ -5,7 +5,7 @@ struct Base { virtual ~Base(); }; -// BEFORE: !ty_Base = !cir.struct(ptr); diff --git a/clang/test/CIR/CodeGen/dynamic-cast.cpp b/clang/test/CIR/CodeGen/dynamic-cast.cpp index ba3208b907b7..e0bc4388653c 100644 --- a/clang/test/CIR/CodeGen/dynamic-cast.cpp +++ b/clang/test/CIR/CodeGen/dynamic-cast.cpp @@ -8,8 +8,8 @@ struct Base { struct Derived : Base {}; // BEFORE: #dyn_cast_info__ZTI4Base__ZTI7Derived = #cir.dyn_cast_info<#cir.global_view<@_ZTI4Base> : !cir.ptr, #cir.global_view<@_ZTI7Derived> : !cir.ptr, @__dynamic_cast, @__cxa_bad_cast, #cir.int<0> : !s64i> -// BEFORE: !ty_Base = !cir.struct -// BEFORE: !ty_Derived = !cir.struct +// BEFORE: !ty_Base = !cir.record +// BEFORE: !ty_Derived = !cir.record Derived *ptr_cast(Base *b) { return dynamic_cast(b); diff --git a/clang/test/CIR/CodeGen/forward-decls.cpp b/clang/test/CIR/CodeGen/forward-decls.cpp index d44869f4a8f1..fdaa79a55073 100644 --- a/clang/test/CIR/CodeGen/forward-decls.cpp +++ b/clang/test/CIR/CodeGen/forward-decls.cpp @@ -9,7 +9,7 @@ // Forward declaration of the record is never defined, so it is created as // an incomplete struct in CIR and will remain as such. -// CHECK1: ![[INC_STRUCT:.+]] = !cir.struct +// CHECK1: ![[INC_STRUCT:.+]] = !cir.record struct IncompleteStruct; // CHECK1: testIncompleteStruct(%arg0: !cir.ptr void testIncompleteStruct(struct IncompleteStruct *s) {}; @@ -24,7 +24,7 @@ void testIncompleteStruct(struct IncompleteStruct *s) {}; // Foward declaration of the struct is followed by usage, then definition. // This means it will initially be created as incomplete, then completed. -// CHECK2: ![[COMPLETE:.+]] = !cir.struct +// CHECK2: ![[COMPLETE:.+]] = !cir.record // CHECK2: testForwardDeclaredStruct(%arg0: !cir.ptr struct ForwardDeclaredStruct; void testForwardDeclaredStruct(struct ForwardDeclaredStruct *fds) {}; @@ -42,7 +42,7 @@ struct ForwardDeclaredStruct { // Struct is initially forward declared since the self-reference is generated // first. Then, once the type is fully generated, it is completed. -// CHECK3: ![[STRUCT:.+]] = !cir.struct>} #cir.record.decl.ast> +// CHECK3: ![[STRUCT:.+]] = !cir.record>} #cir.record.decl.ast> struct RecursiveStruct { int value; struct RecursiveStruct *next; @@ -67,8 +67,8 @@ void testRecursiveStruct(struct RecursiveStruct *arg) { // in recursive type, each struct is expanded until there are no more recursive // types, or all the recursive types are self references. -// CHECK4: ![[B:.+]] = !cir.struct>} -// CHECK4: ![[A:.+]] = !cir.struct}> +// CHECK4: ![[B:.+]] = !cir.record>} +// CHECK4: ![[A:.+]] = !cir.record}> struct StructNodeB; struct StructNodeA { int value; @@ -96,12 +96,12 @@ void testIndirectSelfReference(struct StructNodeA arg) { // RUN: FileCheck --check-prefix=CHECK5 --input-file=%t/complex_struct.cir %s // A sizeable complex struct just to double check that stuff is working. -// CHECK5: !cir.struct, !cir.struct>, !cir.struct>, !cir.ptr>, !cir.ptr>} #cir.record.decl.ast>, !cir.struct>, !cir.struct>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>} #cir.record.decl.ast> -// CHECK5: !cir.struct>, !cir.struct, !cir.struct>, !cir.struct>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.ptr>, !cir.struct, !cir.struct} #cir.record.decl.ast>>, !cir.struct>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.ptr>} #cir.record.decl.ast> -// CHECK5: !cir.struct>, !ty_C, !cir.struct} #cir.record.decl.ast>>, !cir.struct} #cir.record.decl.ast>} #cir.record.decl.ast>>} #cir.record.decl.ast> -// CHECK5: !cir.struct>, !ty_C, !cir.struct} #cir.record.decl.ast>} #cir.record.decl.ast>>, !ty_anon2E2} #cir.record.decl.ast> -// CHECK5: !cir.struct>, !ty_C, !ty_anon2E1} #cir.record.decl.ast> -// CHECK5: !cir.struct +// CHECK5: !cir.record, !cir.record>, !cir.record>, !cir.ptr>, !cir.ptr>} #cir.record.decl.ast>, !cir.record>, !cir.record>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>} #cir.record.decl.ast> +// CHECK5: !cir.record>, !cir.record, !cir.record>, !cir.record>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.ptr>, !cir.record, !cir.record} #cir.record.decl.ast>>, !cir.record>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.ptr>} #cir.record.decl.ast> +// CHECK5: !cir.record>, !ty_C, !cir.record} #cir.record.decl.ast>>, !cir.record} #cir.record.decl.ast>} #cir.record.decl.ast>>} #cir.record.decl.ast> +// CHECK5: !cir.record>, !ty_C, !cir.record} #cir.record.decl.ast>} #cir.record.decl.ast>>, !ty_anon2E2} #cir.record.decl.ast> +// CHECK5: !cir.record>, !ty_C, !ty_anon2E1} #cir.record.decl.ast> +// CHECK5: !cir.record struct A { struct { struct A *a1; diff --git a/clang/test/CIR/CodeGen/fun-ptr.c b/clang/test/CIR/CodeGen/fun-ptr.c index 087164c7b474..329e653a5f8d 100644 --- a/clang/test/CIR/CodeGen/fun-ptr.c +++ b/clang/test/CIR/CodeGen/fun-ptr.c @@ -17,7 +17,7 @@ typedef struct A { fun_typ fun; } A; -// CIR: !ty_A = !cir.struct>) -> !s32i>>} #cir.record.decl.ast> +// CIR: !ty_A = !cir.record>) -> !s32i>>} #cir.record.decl.ast> A a = {(fun_typ)0}; int extract_a(Data* d) { diff --git a/clang/test/CIR/CodeGen/global-new.cpp b/clang/test/CIR/CodeGen/global-new.cpp index 65534d59ab40..1cce344d2e2c 100644 --- a/clang/test/CIR/CodeGen/global-new.cpp +++ b/clang/test/CIR/CodeGen/global-new.cpp @@ -12,7 +12,7 @@ struct e { e(int); }; e *g = new e(0); -// CIR_BEFORE: ![[ty:.*]] = !cir.struct { // CIR_BEFORE: %[[GlobalAddr:.*]] = cir.get_global @g : !cir.ptr> diff --git a/clang/test/CIR/CodeGen/globals-ref-globals.c b/clang/test/CIR/CodeGen/globals-ref-globals.c index 056b8c71c528..90cd2562da2b 100644 --- a/clang/test/CIR/CodeGen/globals-ref-globals.c +++ b/clang/test/CIR/CodeGen/globals-ref-globals.c @@ -20,17 +20,17 @@ static S g6[2] = {{2799, 9, 123}, {2799, 9, 123}}; static int *g7[2] = {&g6[0].f2, &g6[1].f2}; static int **g8 = &g7[1]; -// CHECK-DAG: !ty_anon_struct = !cir.struct -// CHECK-DAG: !ty_anon_struct1 = !cir.struct, !s32i}> -// CHECK-DAG: !ty_anon_struct2 = !cir.struct -// CHECK-DAG: !ty_anon_struct3 = !cir.struct, !s32i, !s8i, !cir.array}> +// CHECK-DAG: !ty_anon_struct = !cir.record +// CHECK-DAG: !ty_anon_struct1 = !cir.record, !s32i}> +// CHECK-DAG: !ty_anon_struct2 = !cir.record +// CHECK-DAG: !ty_anon_struct3 = !cir.record, !s32i, !s8i, !cir.array}> -// CHECK-DAG: g1 = #cir.const_struct<{#cir.int<239> : !u8i, #cir.int<10> : !u8i, #cir.int<0> : !u8i, #cir.zero : !u8i, #cir.int<9> : !s32i, #cir.int<123> : !s32i}> : !ty_anon_struct +// CHECK-DAG: g1 = #cir.const_record<{#cir.int<239> : !u8i, #cir.int<10> : !u8i, #cir.int<0> : !u8i, #cir.zero : !u8i, #cir.int<9> : !s32i, #cir.int<123> : !s32i}> : !ty_anon_struct // CHECK-DAG: g2 = #cir.const_array<[#cir.global_view<@g1, [4]> : !cir.ptr, #cir.global_view<@g1, [4]> : !cir.ptr, #cir.global_view<@g1, [4]> : !cir.ptr, #cir.global_view<@g1, [4]> : !cir.ptr]> : !cir.array x 4> // CHECK-DAG: g3 = #cir.global_view<@g2, [1 : i32]> : !cir.ptr> // CHECK-DAG: g4 = #cir.global_view<@g3> : !cir.ptr>> // CHECK-DAG: g5 = #cir.global_view<@g4> : !cir.ptr>>> -// CHECK-DAG: g6 = #cir.const_array<[#cir.const_struct<{#cir.int<239> : !u8i, #cir.int<10> : !u8i, #cir.int<0> : !u8i, #cir.zero : !u8i, #cir.int<9> : !s32i, #cir.int<123> : !s32i}> : !ty_anon_struct, #cir.const_struct<{#cir.int<239> : !u8i, #cir.int<10> : !u8i, #cir.int<0> : !u8i, #cir.zero : !u8i, #cir.int<9> : !s32i, #cir.int<123> : !s32i}> : !ty_anon_struct]> : !cir.array +// CHECK-DAG: g6 = #cir.const_array<[#cir.const_record<{#cir.int<239> : !u8i, #cir.int<10> : !u8i, #cir.int<0> : !u8i, #cir.zero : !u8i, #cir.int<9> : !s32i, #cir.int<123> : !s32i}> : !ty_anon_struct, #cir.const_record<{#cir.int<239> : !u8i, #cir.int<10> : !u8i, #cir.int<0> : !u8i, #cir.zero : !u8i, #cir.int<9> : !s32i, #cir.int<123> : !s32i}> : !ty_anon_struct]> : !cir.array // CHECK-DAG: g7 = #cir.const_array<[#cir.global_view<@g6, [0, 5]> : !cir.ptr, #cir.global_view<@g6, [1, 5]> : !cir.ptr]> : !cir.array x 2> // CHECK-DAG: g8 = #cir.global_view<@g7, [1 : i32]> : !cir.ptr> @@ -67,9 +67,9 @@ typedef struct { S2 g11 = {1, 42}; int* g12 = &g11.f6; -// CHECK-DAG: g9 = #cir.const_struct<{#cir.int<1> : !s8i, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array, #cir.int<42> : !s32i}> : !ty_anon_struct1 {alignment = 4 : i64} +// CHECK-DAG: g9 = #cir.const_record<{#cir.int<1> : !s8i, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array, #cir.int<42> : !s32i}> : !ty_anon_struct1 {alignment = 4 : i64} // CHECK-DAG: g10 = #cir.global_view<@g9, [2 : i32]> : !cir.ptr {alignment = 8 : i64} -// CHECK-DAG: g11 = #cir.const_struct<{#cir.int<1> : !s8i, #cir.int<42> : !s32i}> : !ty_S2_ {alignment = 1 : i64} +// CHECK-DAG: g11 = #cir.const_record<{#cir.int<1> : !s8i, #cir.int<42> : !s32i}> : !ty_S2_ {alignment = 1 : i64} // CHECK-DAG: g12 = #cir.global_view<@g11, [1 : i32]> : !cir.ptr {alignment = 8 : i64} // LLVM-DAG: @g9 = global { i8, [3 x i8], i32 } { i8 1, [3 x i8] zeroinitializer, i32 42 }, align 4 @@ -90,7 +90,7 @@ typedef struct { static S3 g13 = {-1L,0L,1L}; static S3* g14[2][2] = {{0, &g13}, {&g13, &g13}}; -// CHECK-DAG: g13 = #cir.const_struct<{#cir.int<-1> : !s16i, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array, #cir.int<0> : !s32i, #cir.int<1> : !s8i, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array}> : !ty_anon_struct3 +// CHECK-DAG: g13 = #cir.const_record<{#cir.int<-1> : !s16i, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array, #cir.int<0> : !s32i, #cir.int<1> : !s8i, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array}> : !ty_anon_struct3 // CHECK-DAG: g14 = #cir.const_array<[#cir.const_array<[#cir.ptr : !cir.ptr, #cir.global_view<@g13> : !cir.ptr]> : !cir.array x 2>, #cir.const_array<[#cir.global_view<@g13> : !cir.ptr, #cir.global_view<@g13> : !cir.ptr]> : !cir.array x 2>]> : !cir.array x 2> x 2> typedef struct { @@ -109,7 +109,7 @@ static S5 g15 = {187,1,442,{123,321}}; int* g16 = &g15.f3.f1; -// CHECK-DAG: g15 = #cir.const_struct<{#cir.int<187> : !u8i, #cir.int<0> : !u8i, #cir.int<2> : !u8i, #cir.zero : !u8i, #cir.int<186> : !u8i, #cir.int<1> : !u8i, #cir.int<0> : !u8i, #cir.zero : !u8i, #cir.const_struct<{#cir.int<123> : !s32i, #cir.int<321> : !s32i}> : !ty_S4_}> : !ty_anon_struct2 {alignment = 4 : i64} +// CHECK-DAG: g15 = #cir.const_record<{#cir.int<187> : !u8i, #cir.int<0> : !u8i, #cir.int<2> : !u8i, #cir.zero : !u8i, #cir.int<186> : !u8i, #cir.int<1> : !u8i, #cir.int<0> : !u8i, #cir.zero : !u8i, #cir.const_record<{#cir.int<123> : !s32i, #cir.int<321> : !s32i}> : !ty_S4_}> : !ty_anon_struct2 {alignment = 4 : i64} // CHECK-DAG: g16 = #cir.global_view<@g15, [8, 1]> : !cir.ptr {alignment = 8 : i64} // LLVM-DAG: @g15 = internal global { i8, i8, i8, i8, i8, i8, i8, i8, %struct.S4 } { i8 -69, i8 0, i8 2, i8 0, i8 -70, i8 1, i8 0, i8 0, %struct.S4 { i32 123, i32 321 } }, align 4 diff --git a/clang/test/CIR/CodeGen/globals.c b/clang/test/CIR/CodeGen/globals.c index 78d73c06b3e4..f8bf1e841a29 100644 --- a/clang/test/CIR/CodeGen/globals.c +++ b/clang/test/CIR/CodeGen/globals.c @@ -36,19 +36,19 @@ struct { int x; int y[2][2]; } nestedTwoDim = {1, {{2, 3}, {4, 5}}}; -// CHECK: cir.global external @nestedTwoDim = #cir.const_struct<{#cir.int<1> : !s32i, #cir.const_array<[#cir.const_array<[#cir.int<2> : !s32i, #cir.int<3> : !s32i]> : !cir.array, #cir.const_array<[#cir.int<4> : !s32i, #cir.int<5> : !s32i]> : !cir.array]> : !cir.array x 2>}> +// CHECK: cir.global external @nestedTwoDim = #cir.const_record<{#cir.int<1> : !s32i, #cir.const_array<[#cir.const_array<[#cir.int<2> : !s32i, #cir.int<3> : !s32i]> : !cir.array, #cir.const_array<[#cir.int<4> : !s32i, #cir.int<5> : !s32i]> : !cir.array]> : !cir.array x 2>}> struct { char x[3]; char y[3]; char z[3]; } nestedString = {"1", "", "\0"}; -// CHECK: cir.global external @nestedString = #cir.const_struct<{#cir.const_array<"1" : !cir.array, trailing_zeros> : !cir.array, #cir.zero : !cir.array, #cir.zero : !cir.array}> +// CHECK: cir.global external @nestedString = #cir.const_record<{#cir.const_array<"1" : !cir.array, trailing_zeros> : !cir.array, #cir.zero : !cir.array, #cir.zero : !cir.array}> struct { char *name; } nestedStringPtr = {"1"}; -// CHECK: cir.global external @nestedStringPtr = #cir.const_struct<{#cir.global_view<@".str"> : !cir.ptr}> +// CHECK: cir.global external @nestedStringPtr = #cir.const_record<{#cir.global_view<@".str"> : !cir.ptr}> int *globalPtr = &nestedString.y[1]; // CHECK: cir.global external @globalPtr = #cir.global_view<@nestedString, [1 : i32, 1 : i32]> : !cir.ptr @@ -57,25 +57,25 @@ const int i = 12; int i2 = i; struct { int i; } i3 = {i}; // CHECK: cir.global external @i2 = #cir.int<12> : !s32i -// CHECK: cir.global external @i3 = #cir.const_struct<{#cir.int<12> : !s32i}> : !ty_anon2E3 +// CHECK: cir.global external @i3 = #cir.const_record<{#cir.int<12> : !s32i}> : !ty_anon2E3 int a[10][10][10]; int *a2 = &a[3][0][8]; struct { int *p; } a3 = {&a[3][0][8]}; // CHECK: cir.global external @a2 = #cir.global_view<@a, [3 : i32, 0 : i32, 8 : i32]> : !cir.ptr -// CHECK: cir.global external @a3 = #cir.const_struct<{#cir.global_view<@a, [3 : i32, 0 : i32, 8 : i32]> : !cir.ptr}> : !ty_anon2E4 +// CHECK: cir.global external @a3 = #cir.const_record<{#cir.global_view<@a, [3 : i32, 0 : i32, 8 : i32]> : !cir.ptr}> : !ty_anon2E4 int p[10]; int *p1 = &p[0]; struct { int *x; } p2 = {&p[0]}; // CHECK: cir.global external @p1 = #cir.global_view<@p> : !cir.ptr -// CHECK: cir.global external @p2 = #cir.const_struct<{#cir.global_view<@p> : !cir.ptr}> : !ty_anon2E5 +// CHECK: cir.global external @p2 = #cir.const_record<{#cir.global_view<@p> : !cir.ptr}> : !ty_anon2E5 int q[10]; int *q1 = q; struct { int *x; } q2 = {q}; // CHECK: cir.global external @q1 = #cir.global_view<@q> : !cir.ptr -// CHECK: cir.global external @q2 = #cir.const_struct<{#cir.global_view<@q> : !cir.ptr}> : !ty_anon2E6 +// CHECK: cir.global external @q2 = #cir.const_record<{#cir.global_view<@q> : !cir.ptr}> : !ty_anon2E6 int foo() { extern int optind; diff --git a/clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp b/clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp index 25873623d6e8..130785a5a990 100644 --- a/clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp +++ b/clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp @@ -15,7 +15,7 @@ void test() { } } // namespace std -// CIR: [[INITLIST_TYPE:!.*]] = !cir.struct" {!cir.ptr>, !cir.ptr>}> +// CIR: [[INITLIST_TYPE:!.*]] = !cir.record" {!cir.ptr>, !cir.ptr>}> // CIR: cir.func linkonce_odr @_ZSt1fIPKcEvSt16initializer_listIT_E(%arg0: [[INITLIST_TYPE]] // CIR: [[LOCAL:%.*]] = cir.alloca [[INITLIST_TYPE]], !cir.ptr<[[INITLIST_TYPE]]>, // CIR: cir.store %arg0, [[LOCAL]] : [[INITLIST_TYPE]], !cir.ptr<[[INITLIST_TYPE]]> diff --git a/clang/test/CIR/CodeGen/initlist-ptr-unsigned.cpp b/clang/test/CIR/CodeGen/initlist-ptr-unsigned.cpp index cc90d0ac1d84..ea78ec370d37 100644 --- a/clang/test/CIR/CodeGen/initlist-ptr-unsigned.cpp +++ b/clang/test/CIR/CodeGen/initlist-ptr-unsigned.cpp @@ -15,7 +15,7 @@ void test() { } } // namespace std -// CIR: [[INITLIST_TYPE:!.*]] = !cir.struct" {!cir.ptr, !u64i}> +// CIR: [[INITLIST_TYPE:!.*]] = !cir.record" {!cir.ptr, !u64i}> // CIR: cir.func linkonce_odr @_ZSt1fIiEvSt16initializer_listIT_E(%arg0: [[INITLIST_TYPE]] // CIR: [[REG0:%.*]] = cir.alloca [[INITLIST_TYPE]], !cir.ptr<[[INITLIST_TYPE]]>, diff --git a/clang/test/CIR/CodeGen/lambda.cpp b/clang/test/CIR/CodeGen/lambda.cpp index f1f54111d176..8dee9d0da307 100644 --- a/clang/test/CIR/CodeGen/lambda.cpp +++ b/clang/test/CIR/CodeGen/lambda.cpp @@ -9,10 +9,10 @@ void fn() { a(); } -// CHECK-DAG: !ty_A = !cir.struct -// CHECK: !ty_anon2E0 = !cir.struct -// CHECK-DAG: !ty_anon2E7 = !cir.struct -// CHECK-DAG: !ty_anon2E8 = !cir.struct}> +// CHECK-DAG: !ty_A = !cir.record +// CHECK: !ty_anon2E0 = !cir.record +// CHECK-DAG: !ty_anon2E7 = !cir.record +// CHECK-DAG: !ty_anon2E8 = !cir.record}> // CHECK-DAG: module // CHECK: cir.func lambda internal private @_ZZ2fnvENK3$_0clEv{{.*}}) extra diff --git a/clang/test/CIR/CodeGen/move.cpp b/clang/test/CIR/CodeGen/move.cpp index b61488459137..439c74cdcf8e 100644 --- a/clang/test/CIR/CodeGen/move.cpp +++ b/clang/test/CIR/CodeGen/move.cpp @@ -16,7 +16,7 @@ struct string { } // std namespace -// CHECK: ![[StdString:ty_.*]] = !cir.struct +// CHECK: ![[StdString:ty_.*]] = !cir.record std::string getstr(); void emplace(std::string &&s); diff --git a/clang/test/CIR/CodeGen/multi-vtable.cpp b/clang/test/CIR/CodeGen/multi-vtable.cpp index 4b43f4fc7459..b1d6152f333f 100644 --- a/clang/test/CIR/CodeGen/multi-vtable.cpp +++ b/clang/test/CIR/CodeGen/multi-vtable.cpp @@ -30,14 +30,14 @@ int main() { return 0; } -// CIR: ![[VTypeInfoA:ty_.*]] = !cir.struct, !cir.ptr}> -// CIR: ![[VTypeInfoB:ty_.*]] = !cir.struct, !cir.ptr, !u32i, !u32i, !cir.ptr, !s64i, !cir.ptr, !s64i}> -// CIR: ![[VTableTypeMother:ty_.*]] = !cir.struct x 4>}> -// CIR: ![[VTableTypeFather:ty_.*]] = !cir.struct x 3>}> -// CIR: ![[VTableTypeChild:ty_.*]] = !cir.struct x 4>, !cir.array x 3>}> -// CIR: !ty_Father = !cir.struct !u32i>>>} #cir.record.decl.ast> -// CIR: !ty_Mother = !cir.struct !u32i>>>} #cir.record.decl.ast> -// CIR: !ty_Child = !cir.struct +// CIR: ![[VTypeInfoA:ty_.*]] = !cir.record, !cir.ptr}> +// CIR: ![[VTypeInfoB:ty_.*]] = !cir.record, !cir.ptr, !u32i, !u32i, !cir.ptr, !s64i, !cir.ptr, !s64i}> +// CIR: ![[VTableTypeMother:ty_.*]] = !cir.record x 4>}> +// CIR: ![[VTableTypeFather:ty_.*]] = !cir.record x 3>}> +// CIR: ![[VTableTypeChild:ty_.*]] = !cir.record x 4>, !cir.array x 3>}> +// CIR: !ty_Father = !cir.record !u32i>>>} #cir.record.decl.ast> +// CIR: !ty_Mother = !cir.record !u32i>>>} #cir.record.decl.ast> +// CIR: !ty_Child = !cir.record // CIR: cir.func linkonce_odr @_ZN6MotherC2Ev(%arg0: !cir.ptr // CIR: %{{[0-9]+}} = cir.vtable.address_point(@_ZTV6Mother, vtable_index = 0, address_point_index = 2) : !cir.ptr !u32i>>> diff --git a/clang/test/CIR/CodeGen/new-null.cpp b/clang/test/CIR/CodeGen/new-null.cpp index b3c99c049933..75443f9cb0b2 100644 --- a/clang/test/CIR/CodeGen/new-null.cpp +++ b/clang/test/CIR/CodeGen/new-null.cpp @@ -39,7 +39,7 @@ void *operator new[](size_t, void*, bool) throw(); namespace test15 { struct A { A(); ~A(); }; - // CIR-DAG: ![[TEST15A:.*]] = !cir.struct test_nrvo() { return result; } -// CHECK: ![[VEC:.*]] = !cir.struct" {!cir.ptr>, !cir.ptr>, !cir.ptr>}> +// CHECK: ![[VEC:.*]] = !cir.record" {!cir.ptr>, !cir.ptr>, !cir.ptr>}> // CHECK: cir.func @_Z9test_nrvov() -> ![[VEC]] // CHECK: %0 = cir.alloca ![[VEC]], !cir.ptr, ["__retval", init] {alignment = 8 : i64} diff --git a/clang/test/CIR/CodeGen/packed-structs.c b/clang/test/CIR/CodeGen/packed-structs.c index bf363e20a626..c2c9121a408a 100644 --- a/clang/test/CIR/CodeGen/packed-structs.c +++ b/clang/test/CIR/CodeGen/packed-structs.c @@ -22,16 +22,16 @@ typedef struct { } __attribute__((aligned(2))) C; -// CIR: !ty_A = !cir.struct -// CIR: !ty_C = !cir.struct -// CIR: !ty_D = !cir.struct}> -// CIR: !ty_I = !cir.struct +// CIR: !ty_C = !cir.record +// CIR: !ty_D = !cir.record}> +// CIR: !ty_I = !cir.record // LLVM: %struct.B = type <{ i32, i8, [6 x %struct.A] }> diff --git a/clang/test/CIR/CodeGen/paren-list-init.cpp b/clang/test/CIR/CodeGen/paren-list-init.cpp index ac36e75eaaab..ed10c74a44a4 100644 --- a/clang/test/CIR/CodeGen/paren-list-init.cpp +++ b/clang/test/CIR/CodeGen/paren-list-init.cpp @@ -13,11 +13,11 @@ struct S1 { Vec v; }; -// CIR-DAG: ![[VecType:.*]] = !cir.struct -// CIR-DAG: ![[S1:.*]] = !cir.struct +// CIR-DAG: ![[VecType:.*]] = !cir.record +// CIR-DAG: ![[S1:.*]] = !cir.record -// CIR_EH-DAG: ![[VecType:.*]] = !cir.struct -// CIR_EH-DAG: ![[S1:.*]] = !cir.struct +// CIR_EH-DAG: ![[VecType:.*]] = !cir.record +// CIR_EH-DAG: ![[S1:.*]] = !cir.record template void make1() { diff --git a/clang/test/CIR/CodeGen/pointer-to-data-member.cpp b/clang/test/CIR/CodeGen/pointer-to-data-member.cpp index cf86aec8ad97..f8acbcde325d 100644 --- a/clang/test/CIR/CodeGen/pointer-to-data-member.cpp +++ b/clang/test/CIR/CodeGen/pointer-to-data-member.cpp @@ -6,10 +6,10 @@ struct Point { int y; int z; }; -// CHECK-DAG: !ty_Point = !cir.struct +// CHECK-DAG: !ty_Incomplete = !cir.record int Point::*pt_member = &Point::x; // CHECK: cir.global external @pt_member = #cir.data_member<0> : !cir.data_member diff --git a/clang/test/CIR/CodeGen/rangefor.cpp b/clang/test/CIR/CodeGen/rangefor.cpp index b9ab633064c3..511fc0e0da36 100644 --- a/clang/test/CIR/CodeGen/rangefor.cpp +++ b/clang/test/CIR/CodeGen/rangefor.cpp @@ -21,9 +21,9 @@ void init(unsigned numImages) { } } -// CHECK-DAG: !ty_triple = !cir.struct, !u32i}> -// CHECK-DAG: ![[VEC:.*]] = !cir.struct" {!cir.ptr, !cir.ptr, !cir.ptr}> -// CHECK-DAG: ![[VEC_IT:.*]] = !cir.struct" {!cir.ptr}> +// CHECK-DAG: !ty_triple = !cir.record, !u32i}> +// CHECK-DAG: ![[VEC:.*]] = !cir.record" {!cir.ptr, !cir.ptr, !cir.ptr}> +// CHECK-DAG: ![[VEC_IT:.*]] = !cir.record" {!cir.ptr}> // CHECK: cir.func @_Z4initj(%arg0: !u32i // CHECK: %0 = cir.alloca !u32i, !cir.ptr, ["numImages", init] {alignment = 4 : i64} diff --git a/clang/test/CIR/CodeGen/std-array.cpp b/clang/test/CIR/CodeGen/std-array.cpp index 891eb99d8888..97142935fa64 100644 --- a/clang/test/CIR/CodeGen/std-array.cpp +++ b/clang/test/CIR/CodeGen/std-array.cpp @@ -8,7 +8,7 @@ void t() { (void)v.end(); } -// CHECK: ![[array:.*]] = !cir.struct" +// CHECK: ![[array:.*]] = !cir.record" // CHECK: {{.*}} = cir.get_member // CHECK: {{.*}} = cir.cast(array_to_ptrdecay diff --git a/clang/test/CIR/CodeGen/std-find.cpp b/clang/test/CIR/CodeGen/std-find.cpp index 6f4e41a35ca5..b6a56158fbe4 100644 --- a/clang/test/CIR/CodeGen/std-find.cpp +++ b/clang/test/CIR/CodeGen/std-find.cpp @@ -3,7 +3,7 @@ #include "std-cxx.h" -// CHECK: ![[array:.*]] = !cir.struct" +// CHECK: ![[array:.*]] = !cir.record" int test_find(unsigned char n = 3) { diff --git a/clang/test/CIR/CodeGen/stmtexpr-init.c b/clang/test/CIR/CodeGen/stmtexpr-init.c index 66b676400761..2b469eb12b49 100644 --- a/clang/test/CIR/CodeGen/stmtexpr-init.c +++ b/clang/test/CIR/CodeGen/stmtexpr-init.c @@ -3,8 +3,8 @@ // RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-llvm %s -o %t.ll // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s -// CIR: ![[annon_struct:.*]] = !cir.struct}> -// CIR: ![[sized_array:.*]] = !cir.struct} +// CIR: ![[annon_struct:.*]] = !cir.record}> +// CIR: ![[sized_array:.*]] = !cir.record} void escape(const void *); @@ -33,11 +33,11 @@ struct outer { }; void T2(void) { - // CIR-DAG: cir.global "private" constant internal dsolocal @T2._a = #cir.const_struct<{#cir.int<2> : !s32i, #cir.const_array<[#cir.int<50> : !s32i, #cir.int<60> : !s32i]> : !cir.array}> + // CIR-DAG: cir.global "private" constant internal dsolocal @T2._a = #cir.const_record<{#cir.int<2> : !s32i, #cir.const_array<[#cir.int<50> : !s32i, #cir.int<60> : !s32i]> : !cir.array}> // LLVM-DAG: internal constant { i32, [2 x i32] } { i32 2, [2 x i32] [i32 50, i32 60] } const struct sized_array *A = ARRAY_PTR(50, 60); - // CIR-DAG: cir.global "private" constant internal dsolocal @T2._a.1 = #cir.const_struct<{#cir.int<3> : !s32i, #cir.const_array<[#cir.int<10> : !s32i, #cir.int<20> : !s32i, #cir.int<30> : !s32i]> : !cir.array}> + // CIR-DAG: cir.global "private" constant internal dsolocal @T2._a.1 = #cir.const_record<{#cir.int<3> : !s32i, #cir.const_array<[#cir.int<10> : !s32i, #cir.int<20> : !s32i, #cir.int<30> : !s32i]> : !cir.array}> // LLVM-DAG: internal constant { i32, [3 x i32] } { i32 3, [3 x i32] [i32 10, i32 20, i32 30] } struct outer X = {ARRAY_PTR(10, 20, 30)}; diff --git a/clang/test/CIR/CodeGen/string-literals.c b/clang/test/CIR/CodeGen/string-literals.c index 7be9d6819d3e..13a866b66558 100644 --- a/clang/test/CIR/CodeGen/string-literals.c +++ b/clang/test/CIR/CodeGen/string-literals.c @@ -10,7 +10,7 @@ struct { } literals = {"1", "", "\00"}; // CIR-LABEL: @literals -// CIR: #cir.const_struct<{ +// CIR: #cir.const_record<{ // CIR: #cir.const_array<"1" : !cir.array, trailing_zeros> : !cir.array, // CIR: #cir.zero : !cir.array, // CIR: #cir.zero : !cir.array diff --git a/clang/test/CIR/CodeGen/struct-empty.c b/clang/test/CIR/CodeGen/struct-empty.c index 678eb50be05b..c657b983d31e 100644 --- a/clang/test/CIR/CodeGen/struct-empty.c +++ b/clang/test/CIR/CodeGen/struct-empty.c @@ -3,8 +3,8 @@ // RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-llvm %s -o %t.ll // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s -// CIR: ![[lock:.*]] = !cir.struct -// CIR: ![[fs_struct:.*]] = !cir.struct +// CIR: ![[fs_struct:.*]] = !cir.record>} #cir.record.decl.ast> -// CHECK-DAG: !ty_Bar = !cir.struct -// CHECK-DAG: !ty_Foo = !cir.struct -// CHECK-DAG: !ty_SLocal = !cir.struct -// CHECK-DAG: !ty_SLocal2E0 = !cir.struct +// CHECK-DAG: !ty_Node = !cir.record>} #cir.record.decl.ast> +// CHECK-DAG: !ty_Bar = !cir.record +// CHECK-DAG: !ty_Foo = !cir.record +// CHECK-DAG: !ty_SLocal = !cir.record +// CHECK-DAG: !ty_SLocal2E0 = !cir.record // CHECK-DAG: module {{.*}} { // CHECK: cir.func @baz() // CHECK-NEXT: %0 = cir.alloca !ty_Bar, !cir.ptr, ["b"] {alignment = 4 : i64} @@ -39,9 +39,9 @@ void shouldConstInitStructs(void) { struct Foo f = {1, 2, {3, 4}}; // CHECK: %[[#V0:]] = cir.alloca !ty_Foo, !cir.ptr, ["f"] {alignment = 4 : i64} // CHECK: %[[#V1:]] = cir.cast(bitcast, %[[#V0]] : !cir.ptr), !cir.ptr - // CHECK: %[[#V2:]] = cir.const #cir.const_struct<{#cir.int<1> : !s32i, #cir.int<2> : !s8i, + // CHECK: %[[#V2:]] = cir.const #cir.const_record<{#cir.int<1> : !s32i, #cir.int<2> : !s8i, // CHECK-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array, - // CHECK-SAME: #cir.const_struct<{#cir.int<3> : !s32i, #cir.int<4> : !s8i, + // CHECK-SAME: #cir.const_record<{#cir.int<3> : !s32i, #cir.int<4> : !s8i, // CHECK-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array}> // CHECK-SAME: : !ty_anon_struct}> : !ty_anon_struct1 // CHECK: cir.store %[[#V2]], %[[#V1]] : !ty_anon_struct1, !cir.ptr @@ -59,7 +59,7 @@ struct S1 { float f; int *p; } s1 = {1, .1, 0}; -// CHECK-DAG: cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, #cir.fp<1.000000e-01> : !cir.float, #cir.ptr : !cir.ptr}> : !ty_S1 +// CHECK-DAG: cir.global external @s1 = #cir.const_record<{#cir.int<1> : !s32i, #cir.fp<1.000000e-01> : !cir.float, #cir.ptr : !cir.ptr}> : !ty_S1 // Should initialize global nested structs. struct S2 { @@ -67,13 +67,13 @@ struct S2 { int a; } s2a; } s2 = {{1}}; -// CHECK-DAG: cir.global external @s2 = #cir.const_struct<{#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_S2A}> : !ty_S2 +// CHECK-DAG: cir.global external @s2 = #cir.const_record<{#cir.const_record<{#cir.int<1> : !s32i}> : !ty_S2A}> : !ty_S2 // Should initialize global arrays of structs. struct S3 { int a; } s3[3] = {{1}, {2}, {3}}; -// CHECK-DAG: cir.global external @s3 = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_S3, #cir.const_struct<{#cir.int<2> : !s32i}> : !ty_S3, #cir.const_struct<{#cir.int<3> : !s32i}> : !ty_S3]> : !cir.array +// CHECK-DAG: cir.global external @s3 = #cir.const_array<[#cir.const_record<{#cir.int<1> : !s32i}> : !ty_S3, #cir.const_record<{#cir.int<2> : !s32i}> : !ty_S3, #cir.const_record<{#cir.int<3> : !s32i}> : !ty_S3]> : !cir.array void shouldCopyStructAsCallArg(struct S1 s) { // CHECK-DAG: cir.func @shouldCopyStructAsCallArg diff --git a/clang/test/CIR/CodeGen/struct.cpp b/clang/test/CIR/CodeGen/struct.cpp index b3c502e66534..894da59687d7 100644 --- a/clang/test/CIR/CodeGen/struct.cpp +++ b/clang/test/CIR/CodeGen/struct.cpp @@ -26,13 +26,13 @@ void baz() { struct incomplete; void yoyo(incomplete *i) {} -// CHECK-DAG: !ty_incomplete = !cir.struct +// CHECK-DAG: !ty_incomplete = !cir.record -// CHECK-DAG: !ty_Foo = !cir.struct -// CHECK-DAG: !ty_Mandalore = !cir.struct, !s32i} #cir.record.decl.ast> -// CHECK-DAG: !ty_Adv = !cir.struct -// CHECK-DAG: !ty_Entry = !cir.struct, !cir.ptr) -> !u32i>>}> +// CHECK-DAG: !ty_Foo = !cir.record +// CHECK-DAG: !ty_Mandalore = !cir.record, !s32i} #cir.record.decl.ast> +// CHECK-DAG: !ty_Adv = !cir.record +// CHECK-DAG: !ty_Entry = !cir.record, !cir.ptr) -> !u32i>>}> // CHECK: cir.func linkonce_odr @_ZN3Bar6methodEv(%arg0: !cir.ptr // CHECK-NEXT: %0 = cir.alloca !cir.ptr, !cir.ptr>, ["this", init] {alignment = 8 : i64} @@ -117,11 +117,11 @@ struct A { // Should globally const-initialize struct members. struct A simpleConstInit = {1}; -// CHECK: cir.global external @simpleConstInit = #cir.const_struct<{#cir.int<1> : !s32i}> : !ty_A +// CHECK: cir.global external @simpleConstInit = #cir.const_record<{#cir.int<1> : !s32i}> : !ty_A // Should globally const-initialize arrays with struct members. struct A arrConstInit[1] = {{1}}; -// CHECK: cir.global external @arrConstInit = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_A]> : !cir.array +// CHECK: cir.global external @arrConstInit = #cir.const_array<[#cir.const_record<{#cir.int<1> : !s32i}> : !ty_A]> : !cir.array // Should globally const-initialize empty structs with a non-trivial constexpr // constructor (as undef, to match existing clang CodeGen behavior). diff --git a/clang/test/CIR/CodeGen/three-way-comparison.cpp b/clang/test/CIR/CodeGen/three-way-comparison.cpp index be26e90d0d30..5733db509398 100644 --- a/clang/test/CIR/CodeGen/three-way-comparison.cpp +++ b/clang/test/CIR/CodeGen/three-way-comparison.cpp @@ -7,8 +7,8 @@ // BEFORE: #cmp3way_info_partial_ltn1eq0gt1unn127 = #cir.cmp3way_info // BEFORE: #cmp3way_info_strong_ltn1eq0gt1 = #cir.cmp3way_info -// BEFORE: !ty_std3A3A__13A3Apartial_ordering = !cir.struct y; diff --git a/clang/test/CIR/CodeGen/try-catch-dtors.cpp b/clang/test/CIR/CodeGen/try-catch-dtors.cpp index e212133e3e6f..c24240b72605 100644 --- a/clang/test/CIR/CodeGen/try-catch-dtors.cpp +++ b/clang/test/CIR/CodeGen/try-catch-dtors.cpp @@ -20,11 +20,11 @@ void yo() { } } -// CIR-DAG: ![[VecTy:.*]] = !cir.struct -// CIR-DAG: ![[S1:.*]] = !cir.struct +// CIR-DAG: ![[VecTy:.*]] = !cir.record +// CIR-DAG: ![[S1:.*]] = !cir.record -// CIR_FLAT-DAG: ![[VecTy:.*]] = !cir.struct -// CIR_FLAT-DAG: ![[S1:.*]] = !cir.struct +// CIR_FLAT-DAG: ![[VecTy:.*]] = !cir.record +// CIR_FLAT-DAG: ![[S1:.*]] = !cir.record // CIR: cir.scope { // CIR: %[[VADDR:.*]] = cir.alloca ![[VecTy]], !cir.ptr, ["v", init] diff --git a/clang/test/CIR/CodeGen/union-array.c b/clang/test/CIR/CodeGen/union-array.c index 8ac8264b159d..92ec655cf019 100644 --- a/clang/test/CIR/CodeGen/union-array.c +++ b/clang/test/CIR/CodeGen/union-array.c @@ -18,5 +18,5 @@ typedef union { void foo() { U arr[2] = {{.b = {1, 2}}, {.a = {1}}}; } -// CIR: cir.const #cir.const_struct<{#cir.const_struct<{#cir.const_struct<{#cir.int<1> : !s64i, #cir.int<2> : !s64i}> : {{.*}}}> : {{.*}}, #cir.const_struct<{#cir.const_struct<{#cir.int<1> : !s8i}> : {{.*}}, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array}> +// CIR: cir.const #cir.const_record<{#cir.const_record<{#cir.const_record<{#cir.int<1> : !s64i, #cir.int<2> : !s64i}> : {{.*}}}> : {{.*}}, #cir.const_record<{#cir.const_record<{#cir.int<1> : !s8i}> : {{.*}}, #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array}> // LLVM: store { { %struct.S_2 }, { %struct.S_1, [15 x i8] } } { { %struct.S_2 } { %struct.S_2 { i64 1, i64 2 } }, { %struct.S_1, [15 x i8] } { %struct.S_1 { i8 1 }, [15 x i8] zeroinitializer } } diff --git a/clang/test/CIR/CodeGen/union-init.c b/clang/test/CIR/CodeGen/union-init.c index 96750904536b..ab2bc6ad8564 100644 --- a/clang/test/CIR/CodeGen/union-init.c +++ b/clang/test/CIR/CodeGen/union-init.c @@ -12,11 +12,11 @@ void foo(int x) { A a = {.x = x}; } -// CHECK-DAG: ![[anon0:.*]] = !cir.struct -// CHECK-DAG: ![[anon:.*]] = !cir.struct +// CHECK-DAG: ![[anon0:.*]] = !cir.record +// CHECK-DAG: ![[anon:.*]] = !cir.record // CHECK-DAG: #[[bfi_x:.*]] = #cir.bitfield_info // CHECK-DAG: #[[bfi_y:.*]] = #cir.bitfield_info -// CHECK-DAG: ![[anon1:.*]] = !cir.struct} +// CHECK-DAG: ![[anon1:.*]] = !cir.record} // CHECK-LABEL: cir.func @foo( // CHECK: %[[VAL_1:.*]] = cir.alloca !s32i, !cir.ptr, ["x", init] {alignment = 4 : i64} diff --git a/clang/test/CIR/CodeGen/union-padding.c b/clang/test/CIR/CodeGen/union-padding.c index 85ed30d52ce5..8a6ba2c6a716 100644 --- a/clang/test/CIR/CodeGen/union-padding.c +++ b/clang/test/CIR/CodeGen/union-padding.c @@ -15,17 +15,17 @@ short use() { U u; return **g3; } -// CHECK: !ty_U = !cir.struct}> -// CHECK: !ty_anon_struct = !cir.struct}> +// CHECK: !ty_U = !cir.record}> +// CHECK: !ty_anon_struct = !cir.record}> // CHECK: @g3 = #cir.global_view<@g2> : !cir.ptr> // CHECK: @g2 = #cir.const_array<[#cir.global_view<@g1, [1]> : !cir.ptr]> : !cir.array x 1> // CHECK: @g1 = // CHECK-SAME: #cir.const_array<[ -// CHECK-SAME: #cir.const_struct<{#cir.int<-2> : !s16i, +// CHECK-SAME: #cir.const_record<{#cir.int<-2> : !s16i, // CHECK-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array}> : !ty_anon_struct, -// CHECK-SAME: #cir.const_struct<{#cir.int<-2> : !s16i, +// CHECK-SAME: #cir.const_record<{#cir.int<-2> : !s16i, // CHECK-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array}> : !ty_anon_struct // CHECK-SAME: ]> : !cir.array diff --git a/clang/test/CIR/CodeGen/union.cpp b/clang/test/CIR/CodeGen/union.cpp index a1a1218de107..eeecf07cb506 100644 --- a/clang/test/CIR/CodeGen/union.cpp +++ b/clang/test/CIR/CodeGen/union.cpp @@ -6,15 +6,15 @@ typedef union { yolo y; struct { int lifecnt; }; } yolm; typedef union { yolo y; struct { int *lifecnt; int genpad; }; } yolm2; typedef union { yolo y; struct { bool life; int genpad; }; } yolm3; -// CHECK-DAG: !ty_U23A3ADummy = !cir.struct -// CHECK-DAG: !ty_anon2E0 = !cir.struct -// CHECK-DAG: !ty_anon2E2 = !cir.struct -// CHECK-DAG: !ty_yolo = !cir.struct -// CHECK-DAG: !ty_anon2E1 = !cir.struct, !s32i} #cir.record.decl.ast> +// CHECK-DAG: !ty_U23A3ADummy = !cir.record +// CHECK-DAG: !ty_anon2E0 = !cir.record +// CHECK-DAG: !ty_anon2E2 = !cir.record +// CHECK-DAG: !ty_yolo = !cir.record +// CHECK-DAG: !ty_anon2E1 = !cir.record, !s32i} #cir.record.decl.ast> -// CHECK-DAG: !ty_yolm = !cir.struct -// CHECK-DAG: !ty_yolm3 = !cir.struct -// CHECK-DAG: !ty_yolm2 = !cir.struct +// CHECK-DAG: !ty_yolm = !cir.record +// CHECK-DAG: !ty_yolm3 = !cir.record +// CHECK-DAG: !ty_yolm2 = !cir.record // Should generate a union type with all members preserved. union U { @@ -24,7 +24,7 @@ union U { float f; double d; }; -// CHECK-DAG: !ty_U = !cir.struct +// CHECK-DAG: !ty_U = !cir.record // Should generate unions with complex members. union U2 { @@ -34,14 +34,14 @@ union U2 { float f; } s; } u2; -// CHECK-DAG: !cir.struct +// CHECK-DAG: !cir.record // Should genereate unions without padding. union U3 { short b; U u; } u3; -// CHECK-DAG: !ty_U3 = !cir.struct +// CHECK-DAG: !ty_U3 = !cir.record void m() { yolm q; diff --git a/clang/test/CIR/CodeGen/var-arg-float.c b/clang/test/CIR/CodeGen/var-arg-float.c index 5b8539cfa380..646e6935d931 100644 --- a/clang/test/CIR/CodeGen/var-arg-float.c +++ b/clang/test/CIR/CodeGen/var-arg-float.c @@ -13,7 +13,7 @@ double f1(int n, ...) { return res; } -// BEFORE: !ty___va_list = !cir.struct, !cir.ptr, !cir.ptr, !s32i, !s32i} +// BEFORE: !ty___va_list = !cir.record, !cir.ptr, !cir.ptr, !s32i, !s32i} // BEFORE: cir.func @f1(%arg0: !s32i, ...) -> !cir.double // BEFORE: [[RETP:%.*]] = cir.alloca !cir.double, !cir.ptr, ["__retval"] // BEFORE: [[RESP:%.*]] = cir.alloca !cir.double, !cir.ptr, ["res", init] @@ -27,7 +27,7 @@ double f1(int n, ...) { // BEFORE: cir.return [[RETV]] : !cir.double // beginning block cir code -// AFTER: !ty___va_list = !cir.struct, !cir.ptr, !cir.ptr, !s32i, !s32i} +// AFTER: !ty___va_list = !cir.record, !cir.ptr, !cir.ptr, !s32i, !s32i} // AFTER: cir.func @f1(%arg0: !s32i, ...) -> !cir.double // AFTER: [[RETP:%.*]] = cir.alloca !cir.double, !cir.ptr, ["__retval"] // AFTER: [[RESP:%.*]] = cir.alloca !cir.double, !cir.ptr, ["res", init] diff --git a/clang/test/CIR/CodeGen/var-arg.c b/clang/test/CIR/CodeGen/var-arg.c index b2f1161fa443..24e9487b389d 100644 --- a/clang/test/CIR/CodeGen/var-arg.c +++ b/clang/test/CIR/CodeGen/var-arg.c @@ -13,7 +13,7 @@ int f1(int n, ...) { return res; } -// BEFORE: !ty___va_list = !cir.struct, !cir.ptr, !cir.ptr, !s32i, !s32i} +// BEFORE: !ty___va_list = !cir.record, !cir.ptr, !cir.ptr, !s32i, !s32i} // BEFORE: cir.func @f1(%arg0: !s32i, ...) -> !s32i // BEFORE: [[RETP:%.*]] = cir.alloca !s32i, !cir.ptr, ["__retval"] // BEFORE: [[RESP:%.*]] = cir.alloca !s32i, !cir.ptr, ["res", init] @@ -26,7 +26,7 @@ int f1(int n, ...) { // BEFORE: [[RETV:%.*]] = cir.load [[RETP]] : !cir.ptr, !s32i // BEFORE: cir.return [[RETV]] : !s32i -// AFTER: !ty___va_list = !cir.struct, !cir.ptr, !cir.ptr, !s32i, !s32i} +// AFTER: !ty___va_list = !cir.record, !cir.ptr, !cir.ptr, !s32i, !s32i} // AFTER: cir.func @f1(%arg0: !s32i, ...) -> !s32i // AFTER: [[RETP:%.*]] = cir.alloca !s32i, !cir.ptr, ["__retval"] // AFTER: [[RESP:%.*]] = cir.alloca !s32i, !cir.ptr, ["res", init] diff --git a/clang/test/CIR/CodeGen/variadics.c b/clang/test/CIR/CodeGen/variadics.c index dd79ceedd93a..6cfc71aa5fc4 100644 --- a/clang/test/CIR/CodeGen/variadics.c +++ b/clang/test/CIR/CodeGen/variadics.c @@ -8,7 +8,7 @@ typedef __builtin_va_list va_list; #define va_arg(ap, type) __builtin_va_arg(ap, type) #define va_copy(dst, src) __builtin_va_copy(dst, src) -// CHECK: [[VALISTTYPE:!.+va_list.*]] = !cir.struct !s32i diff --git a/clang/test/CIR/CodeGen/vtable-emission.cpp b/clang/test/CIR/CodeGen/vtable-emission.cpp index 31a8d6fcbe9b..adba48865895 100644 --- a/clang/test/CIR/CodeGen/vtable-emission.cpp +++ b/clang/test/CIR/CodeGen/vtable-emission.cpp @@ -12,15 +12,15 @@ struct S { void S::key() {} -// CHECK-DAG: !ty_anon_struct1 = !cir.struct x 4>}> -// CHECK-DAG: !ty_anon_struct2 = !cir.struct}> +// CHECK-DAG: !ty_anon_struct1 = !cir.record x 4>}> +// CHECK-DAG: !ty_anon_struct2 = !cir.record}> // The definition of the key function should result in the vtable being emitted. // CHECK: cir.global external @_ZTV1S = #cir.vtable // LLVM: @_ZTV1S = global { [4 x ptr] } { [4 x ptr] // LLVM-SAME: [ptr null, ptr @_ZTI1S, ptr @_ZN1S3keyEv, ptr @_ZN1S6nonKeyEv] }, align 8 -// CHECK: cir.global external @sobj = #cir.const_struct +// CHECK: cir.global external @sobj = #cir.const_record // CHECK-SAME: <{#cir.global_view<@_ZTV1S, [0 : i32, 2 : i32]> : // CHECK-SAME: !cir.ptr}> : !ty_anon_struct2 {alignment = 8 : i64} // LLVM: @sobj = global { ptr } { ptr getelementptr inbounds diff --git a/clang/test/CIR/CodeGen/vtable-rtti.cpp b/clang/test/CIR/CodeGen/vtable-rtti.cpp index b9857a58b38c..c7d14a66dea3 100644 --- a/clang/test/CIR/CodeGen/vtable-rtti.cpp +++ b/clang/test/CIR/CodeGen/vtable-rtti.cpp @@ -20,19 +20,19 @@ class B : public A }; // Type info B. -// CHECK: ![[TypeInfoB:ty_.*]] = !cir.struct, !cir.ptr, !cir.ptr}> +// CHECK: ![[TypeInfoB:ty_.*]] = !cir.record, !cir.ptr, !cir.ptr}> // vtable for A type -// CHECK: ![[VTableTypeA:ty_.*]] = !cir.struct x 5>}> -// RTTI_DISABLED: ![[VTableTypeA:ty_.*]] = !cir.struct x 5>}> +// CHECK: ![[VTableTypeA:ty_.*]] = !cir.record x 5>}> +// RTTI_DISABLED: ![[VTableTypeA:ty_.*]] = !cir.record x 5>}> // Class A -// CHECK: ![[ClassA:ty_.*]] = !cir.struct !u32i>>>} #cir.record.decl.ast> -// RTTI_DISABLED: ![[ClassA:ty_.*]] = !cir.struct !u32i>>>} #cir.record.decl.ast> +// CHECK: ![[ClassA:ty_.*]] = !cir.record !u32i>>>} #cir.record.decl.ast> +// RTTI_DISABLED: ![[ClassA:ty_.*]] = !cir.record !u32i>>>} #cir.record.decl.ast> // Class B -// CHECK: ![[ClassB:ty_.*]] = !cir.struct -// RTTI_DISABLED: ![[ClassB:ty_.*]] = !cir.struct +// CHECK: ![[ClassB:ty_.*]] = !cir.record +// RTTI_DISABLED: ![[ClassB:ty_.*]] = !cir.record // B ctor => @B::B() // Calls @A::A() and initialize __vptr with address of B's vtable. diff --git a/clang/test/CIR/IR/aliases.cir b/clang/test/CIR/IR/aliases.cir index 6d2fd8190464..4916209bcfd2 100644 --- a/clang/test/CIR/IR/aliases.cir +++ b/clang/test/CIR/IR/aliases.cir @@ -5,11 +5,11 @@ module { // CHECK: @testAnonRecordsAlias cir.func @testAnonRecordsAlias() { // CHECK: cir.alloca !ty_anon_struct, !cir.ptr - %0 = cir.alloca !cir.struct}>, !cir.ptr}>>, ["A"] + %0 = cir.alloca !cir.record}>, !cir.ptr}>>, ["A"] // CHECK: cir.alloca !ty_anon_struct1, !cir.ptr - %1 = cir.alloca !cir.struct}>, !cir.ptr}>>, ["B"] + %1 = cir.alloca !cir.record}>, !cir.ptr}>>, ["B"] // CHECK: cir.alloca !ty_anon_union, !cir.ptr - %2 = cir.alloca !cir.struct}>, !cir.ptr}>>, ["C"] + %2 = cir.alloca !cir.record}>, !cir.ptr}>>, ["C"] cir.return } } diff --git a/clang/test/CIR/IR/data-member-ptr.cir b/clang/test/CIR/IR/data-member-ptr.cir index 7078510bc594..32f56aa09dd0 100644 --- a/clang/test/CIR/IR/data-member-ptr.cir +++ b/clang/test/CIR/IR/data-member-ptr.cir @@ -1,7 +1,7 @@ // RUN: cir-opt %s | cir-opt | FileCheck %s !s32i = !cir.int -!ty_Foo = !cir.struct +!ty_Foo = !cir.record module { cir.func @null_member() { diff --git a/clang/test/CIR/IR/getmember.cir b/clang/test/CIR/IR/getmember.cir index d9cecc0dea9c..d9c3891e1d2c 100644 --- a/clang/test/CIR/IR/getmember.cir +++ b/clang/test/CIR/IR/getmember.cir @@ -4,9 +4,9 @@ !u16i = !cir.int !u32i = !cir.int -!ty_Class = !cir.struct -!ty_Incomplete = !cir.struct -!ty_Struct = !cir.struct +!ty_Class = !cir.record +!ty_Incomplete = !cir.record +!ty_Struct = !cir.record module { cir.func @shouldGetStructMember(%arg0 : !cir.ptr) { diff --git a/clang/test/CIR/IR/global.cir b/clang/test/CIR/IR/global.cir index ae08062b1c43..0ab07e94383b 100644 --- a/clang/test/CIR/IR/global.cir +++ b/clang/test/CIR/IR/global.cir @@ -3,12 +3,12 @@ !s8i = !cir.int !s32i = !cir.int !s64i = !cir.int -!ty_Init = !cir.struct +!ty_Init = !cir.record module { cir.global external @a = #cir.int<3> : !s32i cir.global external @rgb = #cir.const_array<[#cir.int<0> : !s8i, #cir.int<-23> : !s8i, #cir.int<33> : !s8i] : !cir.array> cir.global external @b = #cir.const_array<"example\00" : !cir.array> - cir.global external @rgb2 = #cir.const_struct<{#cir.int<0> : !s8i, #cir.int<5> : !s64i, #cir.ptr : !cir.ptr}> : !cir.struct}> + cir.global external @rgb2 = #cir.const_record<{#cir.int<0> : !s8i, #cir.int<5> : !s64i, #cir.ptr : !cir.ptr}> : !cir.record}> cir.global "private" constant internal @".str" : !cir.array {alignment = 1 : i64} cir.global "private" internal @c : !s32i cir.global "private" constant internal @".str.2" = #cir.const_array<"example\00" : !cir.array> : !cir.array {alignment = 1 : i64} @@ -31,7 +31,7 @@ module { #cir.global_view<@_ZTVN10__cxxabiv120__si_class_type_infoE, [2]> : !cir.ptr, #cir.global_view<@type_info_name_B> : !cir.ptr, #cir.global_view<@type_info_A> : !cir.ptr}> - : !cir.struct, !cir.ptr, !cir.ptr}> + : !cir.record, !cir.ptr, !cir.ptr}> cir.func private @_ZN4InitC1Eb(!cir.ptr, !s8i) cir.func private @_ZN4InitD1Ev(!cir.ptr) cir.global "private" internal @_ZL8__ioinit = ctor : !ty_Init { diff --git a/clang/test/CIR/IR/invalid.cir b/clang/test/CIR/IR/invalid.cir index 67dcce0ee4ef..709022fa6486 100644 --- a/clang/test/CIR/IR/invalid.cir +++ b/clang/test/CIR/IR/invalid.cir @@ -382,7 +382,7 @@ module { !u32i = !cir.int module { - cir.global external @v = #cir.zero : !u32i // expected-error {{zero expects struct or array type}} + cir.global external @v = #cir.zero : !u32i // expected-error {{zero expects record or array type}} } // ----- @@ -579,7 +579,7 @@ module { // expected-error@+1 {{element at index 0 has type '!cir.ptr>' but return type for this element is '!cir.ptr>'}} cir.global external @type_info_B = #cir.typeinfo<{ #cir.global_view<@_ZTVN10__cxxabiv120__si_class_type_infoE, [2]> : !cir.ptr}> - : !cir.struct}> + : !cir.record}> } // ----- @@ -755,7 +755,7 @@ module { // ----- !s8i = !cir.int -!ty_Init = !cir.struct +!ty_Init = !cir.record module { cir.global "private" internal @_ZL8__ioinit = ctor : !ty_Init { } @@ -765,7 +765,7 @@ module { // ----- !s8i = !cir.int #true = #cir.bool : !cir.bool -!ty_Init = !cir.struct +!ty_Init = !cir.record module { cir.func private @_ZN4InitC1Eb(!cir.ptr) cir.global "private" internal @_ZL8__ioinit = ctor : !ty_Init { @@ -794,7 +794,7 @@ module { !u16i = !cir.int !u32i = !cir.int -!struct = !cir.struct +!struct = !cir.record module { cir.func @memeber_index_out_of_bounds(%arg0 : !cir.ptr) { // expected-error@+1 {{member index out of bounds}} @@ -807,7 +807,7 @@ module { !u16i = !cir.int !u32i = !cir.int -!struct = !cir.struct +!struct = !cir.record module { cir.func @memeber_type_mismatch(%arg0 : !cir.ptr) { // expected-error@+1 {{member type mismatch}} @@ -819,24 +819,24 @@ module { // ----- !u16i = !cir.int -// expected-error@+1 {{anonymous structs must be complete}} -!struct = !cir.struct +// expected-error@+1 {{anonymous records must be complete}} +!struct = !cir.record // ----- !u16i = !cir.int -// expected-error@+1 {{identified structs cannot have an empty name}} -!struct = !cir.struct +// expected-error@+1 {{identified records cannot have an empty name}} +!struct = !cir.record // ----- // expected-error@+1 {{invalid self-reference within record}} -!struct = !cir.struct}> +!struct = !cir.record}> // ----- // expected-error@+1 {{record already defined}} -!struct = !cir.struct}> +!struct = !cir.record}> // ----- !s32i = !cir.int @@ -880,7 +880,7 @@ module { !u16i = !cir.int !u32i = !cir.int -!struct1 = !cir.struct +!struct1 = !cir.record // expected-error@+1 {{member type of a #cir.data_member attribute must match the attribute type}} #invalid_member_ty = #cir.data_member<0> : !cir.data_member @@ -889,12 +889,12 @@ module { !u16i = !cir.int !u32i = !cir.int -!struct1 = !cir.struct +!struct1 = !cir.record module { cir.func @invalid_base_type(%arg0 : !cir.data_member) { %0 = cir.alloca !u32i, !cir.ptr, ["tmp"] {alignment = 4 : i64} - // expected-error@+1 {{'cir.get_runtime_member' op operand #0 must be !cir.struct*}} + // expected-error@+1 {{'cir.get_runtime_member' op operand #0 must be !cir.record*}} %1 = cir.get_runtime_member %0[%arg0 : !cir.data_member] : !cir.ptr -> !cir.ptr cir.return } @@ -904,8 +904,8 @@ module { !u16i = !cir.int !u32i = !cir.int -!struct1 = !cir.struct -!struct2 = !cir.struct +!struct1 = !cir.record +!struct2 = !cir.record module { cir.func @invalid_base_type(%arg0 : !cir.data_member) { @@ -920,7 +920,7 @@ module { !u16i = !cir.int !u32i = !cir.int -!struct1 = !cir.struct +!struct1 = !cir.record module { cir.func @invalid_base_type(%arg0 : !cir.data_member) { @@ -934,9 +934,9 @@ module { // ----- !u16i = !cir.int -!incomplete_struct = !cir.struct +!incomplete_struct = !cir.record -// expected-error@+1 {{incomplete 'cir.struct' cannot be used to build a non-null data member pointer}} +// expected-error@+1 {{incomplete 'cir.record' cannot be used to build a non-null data member pointer}} #incomplete_cls_member = #cir.data_member<0> : !cir.data_member @@ -1176,8 +1176,8 @@ cir.func @bad_long_double(%arg0 : !cir.long_double) -> () { !u8i = !cir.int !void = !cir.void -!Base = !cir.struct !cir.int>>>}> -!Derived = !cir.struct !cir.int>>>}>}> +!Base = !cir.record !cir.int>>>}> +!Derived = !cir.record !cir.int>>>}>}> module { cir.global "private" constant external @_ZTI4Base : !cir.ptr @@ -1198,8 +1198,8 @@ module { !u8i = !cir.int !void = !cir.void -!Base = !cir.struct !cir.int>>>}> -!Derived = !cir.struct !cir.int>>>}>}> +!Base = !cir.record !cir.int>>>}> +!Derived = !cir.record !cir.int>>>}>}> module { cir.global "private" constant external @_ZTI4Base : !cir.ptr diff --git a/clang/test/CIR/IR/struct.cir b/clang/test/CIR/IR/struct.cir index 2068d77bc5da..067579170dba 100644 --- a/clang/test/CIR/IR/struct.cir +++ b/clang/test/CIR/IR/struct.cir @@ -6,16 +6,16 @@ !s32i = !cir.int !u32i = !cir.int -!ty_2222 = !cir.struct x 5>}> -!ty_22221 = !cir.struct, !cir.ptr, !cir.ptr}> -!ty_A = !cir.struct -!ty_i = !cir.struct -!ty_S = !cir.struct -!ty_S1 = !cir.struct +!ty_2222 = !cir.record x 5>}> +!ty_22221 = !cir.record, !cir.ptr, !cir.ptr}> +!ty_A = !cir.record +!ty_i = !cir.record +!ty_S = !cir.record +!ty_S1 = !cir.record // Test recursive struct parsing/printing. -!ty_Node = !cir.struct>} #cir.record.decl.ast> -// CHECK-DAG: !cir.struct>} #cir.record.decl.ast> +!ty_Node = !cir.record>} #cir.record.decl.ast> +// CHECK-DAG: !cir.record>} #cir.record.decl.ast> module { // Dummy function to use types and force them to be printed. @@ -24,8 +24,8 @@ module { } cir.func @structs() { - %0 = cir.alloca !cir.ptr>, !cir.ptr>>, ["s", init] - %1 = cir.alloca !cir.ptr>, !cir.ptr>>, ["i", init] + %0 = cir.alloca !cir.ptr>, !cir.ptr>>, ["s", init] + %1 = cir.alloca !cir.ptr>, !cir.ptr>>, ["i", init] cir.return } @@ -34,8 +34,8 @@ module { // CHECK: %1 = cir.alloca !cir.ptr, !cir.ptr>, ["i", init] cir.func @shouldSuccessfullyParseConstStructAttrs() { - %0 = cir.const #cir.const_struct<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !ty_S1 - // CHECK: cir.const #cir.const_struct<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !ty_S1 + %0 = cir.const #cir.const_record<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !ty_S1 + // CHECK: cir.const #cir.const_record<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !ty_S1 cir.return } } diff --git a/clang/test/CIR/IR/vtableAttr.cir b/clang/test/CIR/IR/vtableAttr.cir index f3792517eea4..d02c33125857 100644 --- a/clang/test/CIR/IR/vtableAttr.cir +++ b/clang/test/CIR/IR/vtableAttr.cir @@ -3,6 +3,6 @@ !u8i = !cir.int module { // Should parse VTable attribute. - cir.global external @testVTable = #cir.vtable<{#cir.const_array<[#cir.ptr : !cir.ptr]> : !cir.array x 1>}> : !cir.struct x 1>}> + cir.global external @testVTable = #cir.vtable<{#cir.const_array<[#cir.ptr : !cir.ptr]> : !cir.array x 1>}> : !cir.record x 1>}> // CHECK: cir.global external @testVTable = #cir.vtable<{#cir.const_array<[#cir.ptr : !cir.ptr]> : !cir.array x 1>}> : !ty_anon_struct } diff --git a/clang/test/CIR/Lowering/ThroughMLIR/vtable.cir b/clang/test/CIR/Lowering/ThroughMLIR/vtable.cir index 1cb4c0b672ae..4c827d143b87 100644 --- a/clang/test/CIR/Lowering/ThroughMLIR/vtable.cir +++ b/clang/test/CIR/Lowering/ThroughMLIR/vtable.cir @@ -8,14 +8,14 @@ !u8i = !cir.int !void = !cir.void -!ty_anon_struct = !cir.struct>, !cir.ptr>}> -!ty_anon_struct1 = !cir.struct>, !cir.ptr>, !cir.int, !cir.int, !cir.ptr>, !cir.int, !cir.ptr>, !cir.int}> -!ty_anon_struct2 = !cir.struct> x 4>}> -!ty_anon_struct3 = !cir.struct> x 3>}> -!ty_anon_struct4 = !cir.struct> x 4>, !cir.array> x 3>}> -!ty_Father = !cir.struct !cir.int>>>} #cir.record.decl.ast> -!ty_Mother = !cir.struct !cir.int>>>} #cir.record.decl.ast> -!ty_Child = !cir.struct !cir.int>>>} #cir.record.decl.ast>, !cir.struct !cir.int>>>} #cir.record.decl.ast>} #cir.record.decl.ast> +!ty_anon_struct = !cir.record>, !cir.ptr>}> +!ty_anon_struct1 = !cir.record>, !cir.ptr>, !cir.int, !cir.int, !cir.ptr>, !cir.int, !cir.ptr>, !cir.int}> +!ty_anon_struct2 = !cir.record> x 4>}> +!ty_anon_struct3 = !cir.record> x 3>}> +!ty_anon_struct4 = !cir.record> x 4>, !cir.array> x 3>}> +!ty_Father = !cir.record !cir.int>>>} #cir.record.decl.ast> +!ty_Mother = !cir.record !cir.int>>>} #cir.record.decl.ast> +!ty_Child = !cir.record !cir.int>>>} #cir.record.decl.ast>, !cir.record !cir.int>>>} #cir.record.decl.ast>} #cir.record.decl.ast> module { cir.func linkonce_odr @_ZN6Mother6simpleEv(%arg0: !cir.ptr) { diff --git a/clang/test/CIR/Lowering/array.cir b/clang/test/CIR/Lowering/array.cir index 30a5aae7bfae..c8fcb7bd156a 100644 --- a/clang/test/CIR/Lowering/array.cir +++ b/clang/test/CIR/Lowering/array.cir @@ -2,7 +2,7 @@ // RUN: cir-translate %s -cir-to-llvmir --disable-cc-lowering -o - | FileCheck %s -check-prefix=LLVM !s32i = !cir.int -!ty_S = !cir.struct +!ty_S = !cir.record module { cir.func @foo() { @@ -21,7 +21,7 @@ module { // LLVM: %1 = alloca [10 x i32], i64 1, align 16 // LLVM-NEXT: ret void - cir.global external @arr = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_S, #cir.zero : !ty_S]> : !cir.array + cir.global external @arr = #cir.const_array<[#cir.const_record<{#cir.int<1> : !s32i}> : !ty_S, #cir.zero : !ty_S]> : !cir.array // CHECK: llvm.mlir.global external @arr() {addr_space = 0 : i32} : !llvm.array<2 x struct<"struct.S", (i32)>> { // CHECK: %0 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.S", (i32)>> // CHECK: %1 = llvm.mlir.undef : !llvm.struct<"struct.S", (i32)> diff --git a/clang/test/CIR/Lowering/attribute-lowering.cir b/clang/test/CIR/Lowering/attribute-lowering.cir index 71ddf2002a25..180ce6367aa7 100644 --- a/clang/test/CIR/Lowering/attribute-lowering.cir +++ b/clang/test/CIR/Lowering/attribute-lowering.cir @@ -8,7 +8,7 @@ module { cir.global "private" internal @const_array = #cir.const_array<[#cir.int<1> : !s32i]> : !cir.array {section = ".abc"} // LLVM: @const_array = internal global [1 x i32] [i32 1], section ".abc" - cir.global "private" internal @const_struct = #cir.const_struct<{#cir.int<1> : !s32i}> : !cir.struct {section = ".abc"} + cir.global "private" internal @const_struct = #cir.const_record<{#cir.int<1> : !s32i}> : !cir.record {section = ".abc"} // LLVM: @const_struct = internal global { i32 } { i32 1 }, section ".abc" cir.func @func_zeroext(%arg0: !u8i {cir.zeroext}) -> (!u8i {cir.zeroext}) { diff --git a/clang/test/CIR/Lowering/class.cir b/clang/test/CIR/Lowering/class.cir index 4f0c25151179..609166c00b88 100644 --- a/clang/test/CIR/Lowering/class.cir +++ b/clang/test/CIR/Lowering/class.cir @@ -4,11 +4,11 @@ !s32i = !cir.int !u8i = !cir.int !u32i = !cir.int -!ty_S = !cir.struct -!ty_S2A = !cir.struct -!ty_S1_ = !cir.struct} #cir.record.decl.ast> -!ty_S2_ = !cir.struct -!ty_S3_ = !cir.struct +!ty_S = !cir.record +!ty_S2A = !cir.record +!ty_S1_ = !cir.record} #cir.record.decl.ast> +!ty_S2_ = !cir.record +!ty_S3_ = !cir.record module { cir.func @test() { @@ -24,7 +24,7 @@ module { cir.func @shouldConstInitLocalClassesWithConstStructAttr() { %0 = cir.alloca !ty_S2A, !cir.ptr, ["s"] {alignment = 4 : i64} - %1 = cir.const #cir.const_struct<{#cir.int<1> : !s32i}> : !ty_S2A + %1 = cir.const #cir.const_record<{#cir.int<1> : !s32i}> : !ty_S2A cir.store %1, %0 : !ty_S2A, !cir.ptr cir.return } @@ -38,8 +38,8 @@ module { // CHECK: llvm.return // CHECK: } - // Should lower basic #cir.const_struct initializer. - cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, #cir.fp<1.000000e-01> : !cir.float, #cir.ptr : !cir.ptr}> : !ty_S1_ + // Should lower basic #cir.const_record initializer. + cir.global external @s1 = #cir.const_record<{#cir.int<1> : !s32i, #cir.fp<1.000000e-01> : !cir.float, #cir.ptr : !cir.ptr}> : !ty_S1_ // CHECK: llvm.mlir.global external @s1() {addr_space = 0 : i32} : !llvm.struct<"class.S1", (i32, f32, ptr)> { // CHECK: %0 = llvm.mlir.undef : !llvm.struct<"class.S1", (i32, f32, ptr)> // CHECK: %1 = llvm.mlir.constant(1 : i32) : i32 @@ -51,8 +51,8 @@ module { // CHECK: llvm.return %6 : !llvm.struct<"class.S1", (i32, f32, ptr)> // CHECK: } - // Should lower nested #cir.const_struct initializer. - cir.global external @s2 = #cir.const_struct<{#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_S2A}> : !ty_S2_ + // Should lower nested #cir.const_record initializer. + cir.global external @s2 = #cir.const_record<{#cir.const_record<{#cir.int<1> : !s32i}> : !ty_S2A}> : !ty_S2_ // CHECK: llvm.mlir.global external @s2() {addr_space = 0 : i32} : !llvm.struct<"class.S2", (struct<"class.S2A", (i32)>)> { // CHECK: %0 = llvm.mlir.undef : !llvm.struct<"class.S2", (struct<"class.S2A", (i32)>)> // CHECK: %1 = llvm.mlir.undef : !llvm.struct<"class.S2A", (i32)> @@ -62,7 +62,7 @@ module { // CHECK: llvm.return %4 : !llvm.struct<"class.S2", (struct<"class.S2A", (i32)>)> // CHECK: } - cir.global external @s3 = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_S3_, #cir.const_struct<{#cir.int<2> : !s32i}> : !ty_S3_, #cir.const_struct<{#cir.int<3> : !s32i}> : !ty_S3_]> : !cir.array + cir.global external @s3 = #cir.const_array<[#cir.const_record<{#cir.int<1> : !s32i}> : !ty_S3_, #cir.const_record<{#cir.int<2> : !s32i}> : !ty_S3_, #cir.const_record<{#cir.int<3> : !s32i}> : !ty_S3_]> : !cir.array // CHECK: llvm.mlir.global external @s3() {addr_space = 0 : i32} : !llvm.array<3 x struct<"class.S3", (i32)>> { // CHECK: %0 = llvm.mlir.undef : !llvm.array<3 x struct<"class.S3", (i32)>> // CHECK: %1 = llvm.mlir.undef : !llvm.struct<"class.S3", (i32)> diff --git a/clang/test/CIR/Lowering/const.cir b/clang/test/CIR/Lowering/const.cir index 7d9b495f784e..9de178c33c0d 100644 --- a/clang/test/CIR/Lowering/const.cir +++ b/clang/test/CIR/Lowering/const.cir @@ -4,7 +4,7 @@ !s8i = !cir.int !s32i = !cir.int !s64i = !cir.int -!ty_anon2E1_ = !cir.struct, !cir.int} #cir.record.decl.ast> +!ty_anon2E1_ = !cir.record, !cir.int} #cir.record.decl.ast> module { cir.func @testConstArrInit() { %0 = cir.const #cir.const_array<"string\00" : !cir.array> : !cir.array @@ -41,7 +41,7 @@ module { cir.func @testConstArrayOfStructs() { %0 = cir.alloca !cir.array, !cir.ptr>, ["a"] {alignment = 4 : i64} - %1 = cir.const #cir.const_array<[#cir.const_struct<{#cir.int<0> : !s32i, #cir.int<1> : !s32i}> : !ty_anon2E1_]> : !cir.array + %1 = cir.const #cir.const_array<[#cir.const_record<{#cir.int<0> : !s32i, #cir.int<1> : !s32i}> : !ty_anon2E1_]> : !cir.array cir.store %1, %0 : !cir.array, !cir.ptr> cir.return } diff --git a/clang/test/CIR/Lowering/data-member.cir b/clang/test/CIR/Lowering/data-member.cir index d96f57ea4560..90f4d34dd0c5 100644 --- a/clang/test/CIR/Lowering/data-member.cir +++ b/clang/test/CIR/Lowering/data-member.cir @@ -3,7 +3,7 @@ !s32i = !cir.int !s64i = !cir.int -!structT = !cir.struct, !cir.int, !cir.int}> +!structT = !cir.record, !cir.int, !cir.int}> module @test attributes { cir.triple = "x86_64-unknown-linux-gnu", @@ -54,4 +54,4 @@ module @test attributes { // LLVM-NEXT: %[[#VAL:]] = getelementptr i8, ptr %[[ARG0]], i64 %[[ARG1]] // LLVM-NEXT: ret ptr %[[#VAL]] // LLVM-NEXT: } -} \ No newline at end of file +} diff --git a/clang/test/CIR/Lowering/globals.cir b/clang/test/CIR/Lowering/globals.cir index 3f99fd102efd..0f25312827a7 100644 --- a/clang/test/CIR/Lowering/globals.cir +++ b/clang/test/CIR/Lowering/globals.cir @@ -11,11 +11,11 @@ !u32i = !cir.int !u64i = !cir.int !u8i = !cir.int -!ty_A = !cir.struct x 2>} #cir.record.decl.ast> -!ty_Bar = !cir.struct -!ty_StringStruct = !cir.struct, !cir.array, !cir.array} #cir.record.decl.ast> -!ty_StringStructPtr = !cir.struct} #cir.record.decl.ast> -!ty_anon2E1_ = !cir.struct)>>} #cir.record.decl.ast> +!ty_A = !cir.record x 2>} #cir.record.decl.ast> +!ty_Bar = !cir.record +!ty_StringStruct = !cir.record, !cir.array, !cir.array} #cir.record.decl.ast> +!ty_StringStructPtr = !cir.record} #cir.record.decl.ast> +!ty_anon2E1_ = !cir.record)>>} #cir.record.decl.ast> module { cir.global external @a = #cir.int<3> : !s32i @@ -98,11 +98,11 @@ module { // The following tests check direclty the resulting LLVM IR because the MLIR // version is two long. Always prefer the MLIR prefix when possible. - cir.global external @nestedTwoDim = #cir.const_struct<{#cir.int<1> : !s32i, #cir.const_array<[#cir.const_array<[#cir.int<2> : !s32i, #cir.int<3> : !s32i]> : !cir.array, #cir.const_array<[#cir.int<4> : !s32i, #cir.int<5> : !s32i]> : !cir.array]> : !cir.array x 2>}> : !ty_A + cir.global external @nestedTwoDim = #cir.const_record<{#cir.int<1> : !s32i, #cir.const_array<[#cir.const_array<[#cir.int<2> : !s32i, #cir.int<3> : !s32i]> : !cir.array, #cir.const_array<[#cir.int<4> : !s32i, #cir.int<5> : !s32i]> : !cir.array]> : !cir.array x 2>}> : !ty_A // LLVM: @nestedTwoDim = global %struct.A { i32 1, [2 x [2 x i32{{\]\] \[\[}}2 x i32] [i32 2, i32 3], [2 x i32] [i32 4, i32 5{{\]\]}} } - cir.global external @nestedString = #cir.const_struct<{#cir.const_array<"1\00\00" : !cir.array> : !cir.array, #cir.const_array<"\00\00\00" : !cir.array> : !cir.array, #cir.const_array<"\00\00\00" : !cir.array> : !cir.array}> : !ty_StringStruct + cir.global external @nestedString = #cir.const_record<{#cir.const_array<"1\00\00" : !cir.array> : !cir.array, #cir.const_array<"\00\00\00" : !cir.array> : !cir.array, #cir.const_array<"\00\00\00" : !cir.array> : !cir.array}> : !ty_StringStruct // LLVM: @nestedString = global %struct.StringStruct { [3 x i8] c"1\00\00", [3 x i8] zeroinitializer, [3 x i8] zeroinitializer } - cir.global external @nestedStringPtr = #cir.const_struct<{#cir.global_view<@".str"> : !cir.ptr}> : !ty_StringStructPtr + cir.global external @nestedStringPtr = #cir.const_record<{#cir.global_view<@".str"> : !cir.ptr}> : !ty_StringStructPtr // LLVM: @nestedStringPtr = global %struct.StringStructPtr { ptr @.str } cir.func @_Z11get_globalsv() { @@ -164,7 +164,7 @@ module { // MLIR: } // LLVM: @undefStruct = global %struct.Bar undef - cir.global "private" internal @Handlers = #cir.const_array<[#cir.const_struct<{#cir.global_view<@myfun> : !cir.ptr>}> : !ty_anon2E1_]> : !cir.array + cir.global "private" internal @Handlers = #cir.const_array<[#cir.const_record<{#cir.global_view<@myfun> : !cir.ptr>}> : !ty_anon2E1_]> : !cir.array cir.func internal private @myfun(%arg0: !s32i) { %0 = cir.alloca !s32i, !cir.ptr, ["a", init] {alignment = 4 : i64} cir.store %arg0, %0 : !s32i, !cir.ptr diff --git a/clang/test/CIR/Lowering/struct.cir b/clang/test/CIR/Lowering/struct.cir index e082d5a7f113..beac6fcd9b8c 100644 --- a/clang/test/CIR/Lowering/struct.cir +++ b/clang/test/CIR/Lowering/struct.cir @@ -4,13 +4,13 @@ !s32i = !cir.int !u8i = !cir.int !u32i = !cir.int -!ty_S = !cir.struct -!ty_S2A = !cir.struct -!ty_S1_ = !cir.struct} #cir.record.decl.ast> -!ty_S2_ = !cir.struct -!ty_S3_ = !cir.struct +!ty_S = !cir.record +!ty_S2A = !cir.record +!ty_S1_ = !cir.record} #cir.record.decl.ast> +!ty_S2_ = !cir.record +!ty_S3_ = !cir.record -!struct_with_bool = !cir.struct +!struct_with_bool = !cir.record module { cir.func @test() { @@ -26,7 +26,7 @@ module { // CHECK-LABEL: @test_value cir.func @test_value() { - %0 = cir.const #cir.const_struct<{#cir.int<1> : !u8i, #cir.int<2> : !s32i}> : !ty_S + %0 = cir.const #cir.const_record<{#cir.int<1> : !u8i, #cir.int<2> : !s32i}> : !ty_S // CHECK: %[[#v0:]] = llvm.mlir.undef : !llvm.struct<"struct.S", (i8, i32)> // CHECK-NEXT: %[[#v1:]] = llvm.mlir.constant(1 : i8) : i8 // CHECK-NEXT: %[[#v2:]] = llvm.insertvalue %[[#v1]], %[[#v0]][0] : !llvm.struct<"struct.S", (i8, i32)> @@ -41,7 +41,7 @@ module { cir.func @shouldConstInitLocalStructsWithConstStructAttr() { %0 = cir.alloca !ty_S2A, !cir.ptr, ["s"] {alignment = 4 : i64} - %1 = cir.const #cir.const_struct<{#cir.int<1> : !s32i}> : !ty_S2A + %1 = cir.const #cir.const_record<{#cir.int<1> : !s32i}> : !ty_S2A cir.store %1, %0 : !ty_S2A, !cir.ptr cir.return } @@ -55,8 +55,8 @@ module { // CHECK: llvm.return // CHECK: } - // Should lower basic #cir.const_struct initializer. - cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, #cir.fp<1.000000e-01> : !cir.float, #cir.ptr : !cir.ptr}> : !ty_S1_ + // Should lower basic #cir.const_record initializer. + cir.global external @s1 = #cir.const_record<{#cir.int<1> : !s32i, #cir.fp<1.000000e-01> : !cir.float, #cir.ptr : !cir.ptr}> : !ty_S1_ // CHECK: llvm.mlir.global external @s1() {addr_space = 0 : i32} : !llvm.struct<"struct.S1", (i32, f32, ptr)> { // CHECK: %0 = llvm.mlir.undef : !llvm.struct<"struct.S1", (i32, f32, ptr)> // CHECK: %1 = llvm.mlir.constant(1 : i32) : i32 @@ -68,8 +68,8 @@ module { // CHECK: llvm.return %6 : !llvm.struct<"struct.S1", (i32, f32, ptr)> // CHECK: } - // Should lower nested #cir.const_struct initializer. - cir.global external @s2 = #cir.const_struct<{#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_S2A}> : !ty_S2_ + // Should lower nested #cir.const_record initializer. + cir.global external @s2 = #cir.const_record<{#cir.const_record<{#cir.int<1> : !s32i}> : !ty_S2A}> : !ty_S2_ // CHECK: llvm.mlir.global external @s2() {addr_space = 0 : i32} : !llvm.struct<"struct.S2", (struct<"struct.S2A", (i32)>)> { // CHECK: %0 = llvm.mlir.undef : !llvm.struct<"struct.S2", (struct<"struct.S2A", (i32)>)> // CHECK: %1 = llvm.mlir.undef : !llvm.struct<"struct.S2A", (i32)> @@ -79,7 +79,7 @@ module { // CHECK: llvm.return %4 : !llvm.struct<"struct.S2", (struct<"struct.S2A", (i32)>)> // CHECK: } - cir.global external @s3 = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_S3_, #cir.const_struct<{#cir.int<2> : !s32i}> : !ty_S3_, #cir.const_struct<{#cir.int<3> : !s32i}> : !ty_S3_]> : !cir.array + cir.global external @s3 = #cir.const_array<[#cir.const_record<{#cir.int<1> : !s32i}> : !ty_S3_, #cir.const_record<{#cir.int<2> : !s32i}> : !ty_S3_, #cir.const_record<{#cir.int<3> : !s32i}> : !ty_S3_]> : !cir.array // CHECK: llvm.mlir.global external @s3() {addr_space = 0 : i32} : !llvm.array<3 x struct<"struct.S3", (i32)>> { // CHECK: %0 = llvm.mlir.undef : !llvm.array<3 x struct<"struct.S3", (i32)>> // CHECK: %1 = llvm.mlir.undef : !llvm.struct<"struct.S3", (i32)> @@ -112,7 +112,7 @@ module { } // Verify that boolean fields are lowered to i8 and that the correct type is inserted during initialization. - cir.global external @struct_with_bool = #cir.const_struct<{#cir.int<1> : !u32i, #cir.bool : !cir.bool}> : !struct_with_bool + cir.global external @struct_with_bool = #cir.const_record<{#cir.int<1> : !u32i, #cir.bool : !cir.bool}> : !struct_with_bool // CHECK: llvm.mlir.global external @struct_with_bool() {addr_space = 0 : i32} : !llvm.struct<"struct.struct_with_bool", (i32, i8)> { // CHECK: %[[FALSE:.+]] = llvm.mlir.constant(false) : i1 // CHECK-NEXT: %[[FALSE_MEM:.+]] = llvm.zext %[[FALSE]] : i1 to i8 diff --git a/clang/test/CIR/Lowering/types.cir b/clang/test/CIR/Lowering/types.cir index f91f25cb5e41..c195b09e1a93 100644 --- a/clang/test/CIR/Lowering/types.cir +++ b/clang/test/CIR/Lowering/types.cir @@ -4,7 +4,7 @@ !void = !cir.void !u8i = !cir.int module { - cir.global external @testVTable = #cir.vtable<{#cir.const_array<[#cir.ptr<-8> : !cir.ptr]> : !cir.array x 1>}> : !cir.struct x 1>}> + cir.global external @testVTable = #cir.vtable<{#cir.const_array<[#cir.ptr<-8> : !cir.ptr]> : !cir.array x 1>}> : !cir.record x 1>}> // CHECK: llvm.mlir.constant(-8 : i64) : i64 // CHECK: llvm.inttoptr %{{[0-9]+}} : i64 to !llvm.ptr cir.func @testTypeLowering() { @@ -15,4 +15,4 @@ module { // CHECK: llvm.mlir.zero : !llvm.ptr cir.return } -} \ No newline at end of file +} diff --git a/clang/test/CIR/Lowering/unions.cir b/clang/test/CIR/Lowering/unions.cir index 445ef463ef2d..8f674b6fedc4 100644 --- a/clang/test/CIR/Lowering/unions.cir +++ b/clang/test/CIR/Lowering/unions.cir @@ -4,9 +4,9 @@ !s16i = !cir.int !s32i = !cir.int #true = #cir.bool : !cir.bool -!ty_U1_ = !cir.struct -!ty_U2_ = !cir.struct -!ty_U3_ = !cir.struct +!ty_U1_ = !cir.record +!ty_U2_ = !cir.record +!ty_U3_ = !cir.record module { // Should lower union to struct with only the largest member. cir.global external @u1 = #cir.zero : !ty_U1_ diff --git a/clang/test/CIR/Lowering/variadics.cir b/clang/test/CIR/Lowering/variadics.cir index dfbfbf66e56f..116137d58c70 100644 --- a/clang/test/CIR/Lowering/variadics.cir +++ b/clang/test/CIR/Lowering/variadics.cir @@ -5,7 +5,7 @@ !u32i = !cir.int !u8i = !cir.int -!ty___va_list_tag = !cir.struct, !cir.ptr} #cir.record.decl.ast> +!ty___va_list_tag = !cir.record, !cir.ptr} #cir.record.decl.ast> module { cir.func @average(%arg0: !s32i, ...) -> !s32i { From dce12b3b71d3ee7dc12b9d8566f99518238fc643 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Fri, 11 Apr 2025 16:44:28 -0700 Subject: [PATCH 2/2] Fix formatting --- clang/lib/CIR/CodeGen/CIRGenExpr.cpp | 5 +++-- clang/lib/CIR/CodeGen/CIRGenExprConst.cpp | 6 ++---- clang/lib/CIR/CodeGen/CIRGenModule.cpp | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp index 5d745ca60e80..6de9e5ca7ab9 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp @@ -2263,8 +2263,9 @@ static void pushTemporaryCleanup(CIRGenFunction &CGF, } CXXDestructorDecl *ReferenceTemporaryDtor = nullptr; - if (const clang::RecordType *RT = - E->getType()->getBaseElementTypeUnsafe()->getAs()) { + if (const clang::RecordType *RT = E->getType() + ->getBaseElementTypeUnsafe() + ->getAs()) { // Get the destructor for the reference temporary. auto *ClassDecl = cast(RT->getDecl()); if (!ClassDecl->hasTrivialDestructor()) diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp b/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp index faee4cad9e30..d54a19cbbe6a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp @@ -2086,11 +2086,9 @@ mlir::Attribute ConstantEmitter::emitNullForMemory(mlir::Location loc, return emitForMemory(CGM, cstOp.getValue(), T); } -static mlir::TypedAttr emitNullConstant(CIRGenModule &CGM, - const RecordDecl *rd, +static mlir::TypedAttr emitNullConstant(CIRGenModule &CGM, const RecordDecl *rd, bool asCompleteObject) { - const CIRGenRecordLayout &layout = - CGM.getTypes().getCIRGenRecordLayout(rd); + const CIRGenRecordLayout &layout = CGM.getTypes().getCIRGenRecordLayout(rd); mlir::Type ty = (asCompleteObject ? layout.getCIRType() : layout.getBaseSubobjectCIRType()); auto record = dyn_cast(ty); diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index b6d2f0117802..7d7f9e636f1b 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -4070,8 +4070,8 @@ CharUnits CIRGenModule::computeNonVirtualBaseClassOffset( // Get the layout. const ASTRecordLayout &layout = astContext.getASTRecordLayout(rd); - const auto *baseDecl = - cast(base->getType()->castAs()->getDecl()); + const auto *baseDecl = cast( + base->getType()->castAs()->getDecl()); // Add the offset. offset += layout.getBaseClassOffset(baseDecl);