[clang] 389c1ea - [CIR][NFC] Group related "creation" helpers + add comments (#180921)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 12 01:21:54 PST 2026
Author: Andrzej WarzyĆski
Date: 2026-02-12T09:21:49Z
New Revision: 389c1ea44b0fbe295ebf816c8839fd2d839ffda8
URL: https://github.com/llvm/llvm-project/commit/389c1ea44b0fbe295ebf816c8839fd2d839ffda8
DIFF: https://github.com/llvm/llvm-project/commit/389c1ea44b0fbe295ebf816c8839fd2d839ffda8.diff
LOG: [CIR][NFC] Group related "creation" helpers + add comments (#180921)
Added:
Modified:
clang/lib/CIR/CodeGen/CIRGenBuilder.h
Removed:
################################################################################
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h
index 330de5777f401..debd2faa29ef3 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h
+++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h
@@ -345,10 +345,9 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
return getType<cir::RecordType>(members, packed, padded, kind);
}
- //
+ //===--------------------------------------------------------------------===//
// Constant creation helpers
- // -------------------------
- //
+ //===--------------------------------------------------------------------===//
cir::ConstantOp getSInt32(int32_t c, mlir::Location loc) {
return getConstantInt(loc, getSInt32Ty(), c);
}
@@ -362,10 +361,19 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
return getConstantInt(loc, getUInt64Ty(), c);
}
- //
+ /// Create constant nullptr for pointer-to-data-member type ty.
+ cir::ConstantOp getNullDataMemberPtr(cir::DataMemberType ty,
+ mlir::Location loc) {
+ return cir::ConstantOp::create(*this, loc, getNullDataMemberAttr(ty));
+ }
+
+ cir::ConstantOp getNullMethodPtr(cir::MethodType ty, mlir::Location loc) {
+ return cir::ConstantOp::create(*this, loc, getNullMethodAttr(ty));
+ }
+
+ //===--------------------------------------------------------------------===//
// UnaryOp creation helpers
- // -------------------------
- //
+ //===--------------------------------------------------------------------===//
mlir::Value createNeg(mlir::Value value) {
if (auto intTy = mlir::dyn_cast<cir::IntType>(value.getType())) {
@@ -391,30 +399,9 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
cir::UnaryOpKind::Minus, value);
}
- cir::IsFPClassOp createIsFPClass(mlir::Location loc, mlir::Value src,
- cir::FPClassTest flags) {
- return cir::IsFPClassOp::create(*this, loc, src, flags);
- }
-
- /// Create constant nullptr for pointer-to-data-member type ty.
- cir::ConstantOp getNullDataMemberPtr(cir::DataMemberType ty,
- mlir::Location loc) {
- return cir::ConstantOp::create(*this, loc, getNullDataMemberAttr(ty));
- }
-
- cir::ConstantOp getNullMethodPtr(cir::MethodType ty, mlir::Location loc) {
- return cir::ConstantOp::create(*this, loc, getNullMethodAttr(ty));
- }
-
- // TODO: split this to createFPExt/createFPTrunc when we have dedicated cast
- // operations.
- mlir::Value createFloatingCast(mlir::Value v, mlir::Type destType) {
- assert(!cir::MissingFeatures::fpConstraints());
-
- return cir::CastOp::create(*this, v.getLoc(), destType,
- cir::CastKind::floating, v);
- }
-
+ //===--------------------------------------------------------------------===//
+ // BinaryOp creation helpers
+ //===--------------------------------------------------------------------===//
mlir::Value createFSub(mlir::Location loc, mlir::Value lhs, mlir::Value rhs) {
assert(!cir::MissingFeatures::metaDataNode());
assert(!cir::MissingFeatures::fpConstraints());
@@ -446,6 +433,19 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
return cir::BinOp::create(*this, loc, cir::BinOpKind::Div, lhs, rhs);
}
+ //===--------------------------------------------------------------------===//
+ // CastOp creation helpers
+ //===--------------------------------------------------------------------===//
+
+ // TODO: split this to createFPExt/createFPTrunc when we have dedicated cast
+ // operations.
+ mlir::Value createFloatingCast(mlir::Value v, mlir::Type destType) {
+ assert(!cir::MissingFeatures::fpConstraints());
+
+ return cir::CastOp::create(*this, v.getLoc(), destType,
+ cir::CastKind::floating, v);
+ }
+
mlir::Value createDynCast(mlir::Location loc, mlir::Value src,
cir::PointerType destType, bool isRefCast,
cir::DynamicCastInfoAttr info) {
@@ -465,6 +465,9 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
cir::DynamicCastInfoAttr{}, vtableUseRelativeLayout);
}
+ //===--------------------------------------------------------------------===//
+ // Address creation helpers
+ //===--------------------------------------------------------------------===//
Address createBaseClassAddr(mlir::Location loc, Address addr,
mlir::Type destType, unsigned offset,
bool assumeNotNull) {
@@ -491,6 +494,9 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
return Address(derivedAddr, destType, addr.getAlignment());
}
+ //===--------------------------------------------------------------------===//
+ // Virtual Address creation helpers
+ //===--------------------------------------------------------------------===//
mlir::Value createVTTAddrPoint(mlir::Location loc, mlir::Type retTy,
mlir::Value addr, uint64_t offset) {
return cir::VTTAddrPointOp::create(*this, loc, retTy,
@@ -503,6 +509,14 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
offset);
}
+ //===--------------------------------------------------------------------===//
+ // Other creation helpers
+ //===--------------------------------------------------------------------===//
+ cir::IsFPClassOp createIsFPClass(mlir::Location loc, mlir::Value src,
+ cir::FPClassTest flags) {
+ return cir::IsFPClassOp::create(*this, loc, src, flags);
+ }
+
/// Cast the element type of the given address to a
diff erent type,
/// preserving information like the alignment.
Address createElementBitCast(mlir::Location loc, Address addr,
More information about the cfe-commits
mailing list