[flang-commits] [flang] [flang][FIR] add a new fir.bitcast operation (PR #187793)
Razvan Lupusoru via flang-commits
flang-commits at lists.llvm.org
Fri Mar 20 14:11:40 PDT 2026
================
@@ -1481,6 +1481,54 @@ static mlir::ParseResult parseCmpOp(mlir::OpAsmParser &parser,
return mlir::success();
}
+//===----------------------------------------------------------------------===//
+// BitcastOp
+//===----------------------------------------------------------------------===//
+
+static bool isBitcastCompatibleType(mlir::Type ty) {
+ return mlir::isa<mlir::IntegerType, mlir::FloatType, fir::LogicalType>(ty) ||
+ (mlir::isa<fir::CharacterType>(ty) &&
+ mlir::cast<fir::CharacterType>(ty).getLen() ==
+ fir::CharacterType::singleton());
+}
+
+static std::optional<unsigned> getBitcastBitSize(mlir::Type ty) {
+ if (auto intTy = mlir::dyn_cast<mlir::IntegerType>(ty))
+ return intTy.getWidth();
+ if (auto floatTy = mlir::dyn_cast<mlir::FloatType>(ty))
+ return floatTy.getWidth();
+ // Bit size of fir.logical and fir.char depends on the kind map which is not
----------------
razvanlupusoru wrote:
I think it would be great if we had the size in lieu of the kind directly from lowering - which should know the size representation anyway, right?
https://github.com/llvm/llvm-project/pull/187793
More information about the flang-commits
mailing list