[clang] [CIR] Upstream handling of integral-to-pointer casts (PR #161653)
Amr Hesham via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 3 02:46:46 PDT 2025
================
@@ -81,6 +86,19 @@ class CIRDataLayout {
}
llvm::TypeSize getTypeSizeInBits(mlir::Type ty) const;
+
+ llvm::TypeSize getPointerTypeSizeInBits(mlir::Type Ty) const {
+ assert(mlir::isa<cir::PointerType>(Ty) &&
+ "This should only be called with a pointer type");
+ return layout.getTypeSizeInBits(Ty);
+ }
+
+ mlir::Type getIntPtrType(mlir::Type Ty) const {
+ assert(mlir::isa<cir::PointerType>(Ty) && "Expected pointer type");
+ auto IntTy =
+ cir::IntType::get(Ty.getContext(), getPointerTypeSizeInBits(Ty), false);
+ return IntTy;
----------------
AmrDeveloper wrote:
```suggestion
return cir::IntType::get(ty.getContext(), getPointerTypeSizeInBits(ty), false);
```
https://github.com/llvm/llvm-project/pull/161653
More information about the cfe-commits
mailing list