[clang] [CIR][NFC] Group related "creation" helpers + add comments (PR #180921)
Andrzej WarzyĆski via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 11 03:28:45 PST 2026
https://github.com/banach-space created https://github.com/llvm/llvm-project/pull/180921
None
>From 0703c8d1d0cef1d0bde5dd49cdc2d659e4d4a6bb Mon Sep 17 00:00:00 2001
From: Andrzej Warzynski <andrzej.warzynski at arm.com>
Date: Wed, 11 Feb 2026 11:27:17 +0000
Subject: [PATCH] [CIR][NFC] Group related "creation" helpers + add comments
---
clang/lib/CIR/CodeGen/CIRGenBuilder.h | 69 +++++++++++++++++----------
1 file changed, 45 insertions(+), 24 deletions(-)
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h
index c262f5dc3d812..4e2c7ae798b89 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h
+++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h
@@ -362,6 +362,16 @@ 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
// -------------------------
@@ -391,30 +401,10 @@ 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 +436,20 @@ 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 +469,10 @@ 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 +499,10 @@ 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 +515,15 @@ 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 different type,
/// preserving information like the alignment.
Address createElementBitCast(mlir::Location loc, Address addr,
More information about the cfe-commits
mailing list