[clang] [CIR][NFC] Group related "creation" helpers + add comments (PR #180921)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 11 03:29:19 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Andrzej WarzyĆski (banach-space)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/180921.diff
1 Files Affected:
- (modified) clang/lib/CIR/CodeGen/CIRGenBuilder.h (+45-24)
``````````diff
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,
``````````
</details>
https://github.com/llvm/llvm-project/pull/180921
More information about the cfe-commits
mailing list