Skip to content

Conversation

@makslevental
Copy link
Contributor

This reverts commit 222f4e4.

@llvmbot
Copy link
Member

llvmbot commented Nov 11, 2025

@llvm/pr-subscribers-mlir-llvm
@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-arith

Author: Maksim Levental (makslevental)

Changes

This reverts commit 222f4e4.


Patch is 29.45 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/167429.diff

16 Files Affected:

  • (removed) mlir/include/mlir/Conversion/ArithToAPFloat/ArithToAPFloat.h (-21)
  • (modified) mlir/include/mlir/Conversion/Passes.h (-1)
  • (modified) mlir/include/mlir/Conversion/Passes.td (-15)
  • (modified) mlir/include/mlir/Dialect/Func/Utils/Utils.h (-7)
  • (modified) mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h (-4)
  • (removed) mlir/lib/Conversion/ArithToAPFloat/ArithToAPFloat.cpp (-161)
  • (removed) mlir/lib/Conversion/ArithToAPFloat/CMakeLists.txt (-17)
  • (modified) mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp (-1)
  • (modified) mlir/lib/Conversion/CMakeLists.txt (-1)
  • (modified) mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp (-14)
  • (modified) mlir/lib/Dialect/Func/Utils/Utils.cpp (-25)
  • (modified) mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp (-11)
  • (removed) mlir/lib/ExecutionEngine/APFloatWrappers.cpp (-81)
  • (modified) mlir/lib/ExecutionEngine/CMakeLists.txt (-12)
  • (removed) mlir/test/Conversion/ArithToApfloat/arith-to-apfloat.mlir (-128)
  • (removed) mlir/test/Integration/Dialect/Arith/CPU/test-apfloat-emulation.mlir (-34)
diff --git a/mlir/include/mlir/Conversion/ArithToAPFloat/ArithToAPFloat.h b/mlir/include/mlir/Conversion/ArithToAPFloat/ArithToAPFloat.h deleted file mode 100644 index 64a42a228199e..0000000000000 --- a/mlir/include/mlir/Conversion/ArithToAPFloat/ArithToAPFloat.h +++ /dev/null @@ -1,21 +0,0 @@ -//===- ArithToAPFloat.h - Arith to APFloat impl conversion ---*- C++ ----*-===// -// -// Part of the APFloat Project, under the Apache License v2.0 with APFloat -// Exceptions. See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH APFloat-exception -// -//===----------------------------------------------------------------------===// - -#ifndef MLIR_CONVERSION_ARITHTOAPFLOAT_ARITHTOAPFLOAT_H -#define MLIR_CONVERSION_ARITHTOAPFLOAT_ARITHTOAPFLOAT_H - -#include <memory> - -namespace mlir { -class Pass; - -#define GEN_PASS_DECL_ARITHTOAPFLOATCONVERSIONPASS -#include "mlir/Conversion/Passes.h.inc" -} // namespace mlir - -#endif // MLIR_CONVERSION_ARITHTOAPFLOAT_ARITHTOAPFLOAT_H diff --git a/mlir/include/mlir/Conversion/Passes.h b/mlir/include/mlir/Conversion/Passes.h index 82bdfd02661a6..40d866ec7bf10 100644 --- a/mlir/include/mlir/Conversion/Passes.h +++ b/mlir/include/mlir/Conversion/Passes.h @@ -12,7 +12,6 @@ #include "mlir/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.h" #include "mlir/Conversion/AffineToStandard/AffineToStandard.h" #include "mlir/Conversion/ArithToAMDGPU/ArithToAMDGPU.h" -#include "mlir/Conversion/ArithToAPFloat/ArithToAPFloat.h" #include "mlir/Conversion/ArithToArmSME/ArithToArmSME.h" #include "mlir/Conversion/ArithToEmitC/ArithToEmitCPass.h" #include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h" diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td index 79bc380dbcb7a..70e3e45c225db 100644 --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -186,21 +186,6 @@ def ArithToLLVMConversionPass : Pass<"convert-arith-to-llvm"> { ]; } -//===----------------------------------------------------------------------===// -// ArithToAPFloat -//===----------------------------------------------------------------------===// - -def ArithToAPFloatConversionPass - : Pass<"convert-arith-to-apfloat", "ModuleOp"> { - let summary = "Convert Arith ops to APFloat runtime library calls"; - let description = [{ - This pass converts supported Arith ops to APFloat-based runtime library - calls (APFloatWrappers.cpp). APFloat is a software implementation of - floating-point arithmetic operations. - }]; - let dependentDialects = ["func::FuncDialect"]; -} - //===----------------------------------------------------------------------===// // ArithToSPIRV //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Dialect/Func/Utils/Utils.h b/mlir/include/mlir/Dialect/Func/Utils/Utils.h index 00d50874a2e8d..3576126a487ac 100644 --- a/mlir/include/mlir/Dialect/Func/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Func/Utils/Utils.h @@ -60,13 +60,6 @@ mlir::FailureOr<std::pair<mlir::func::FuncOp, mlir::func::CallOp>> deduplicateArgsOfFuncOp(mlir::RewriterBase &rewriter, mlir::func::FuncOp funcOp, mlir::ModuleOp moduleOp); -/// Look up a FuncOp with signature `resultTypes`(`paramTypes`)` and name -/// `name`. Return a failure if the FuncOp is found but with a different -/// signature. -FailureOr<FuncOp> lookupFnDecl(SymbolOpInterface symTable, StringRef name, - FunctionType funcT, - SymbolTableCollection *symbolTables = nullptr); - } // namespace func } // namespace mlir diff --git a/mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h b/mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h index b09d32022e348..8ad9ed18acebd 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h +++ b/mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h @@ -52,10 +52,6 @@ lookupOrCreatePrintF32Fn(OpBuilder &b, Operation *moduleOp, FailureOr<LLVM::LLVMFuncOp> lookupOrCreatePrintF64Fn(OpBuilder &b, Operation *moduleOp, SymbolTableCollection *symbolTables = nullptr); -FailureOr<LLVM::LLVMFuncOp> -lookupOrCreateApFloatPrintFn(OpBuilder &b, Operation *moduleOp, - SymbolTableCollection *symbolTables = nullptr); - /// Declares a function to print a C-string. /// If a custom runtime function is defined via `runtimeFunctionName`, it must /// have the signature void(char const*). The default function is `printString`. diff --git a/mlir/lib/Conversion/ArithToAPFloat/ArithToAPFloat.cpp b/mlir/lib/Conversion/ArithToAPFloat/ArithToAPFloat.cpp deleted file mode 100644 index 012e934d3050f..0000000000000 --- a/mlir/lib/Conversion/ArithToAPFloat/ArithToAPFloat.cpp +++ /dev/null @@ -1,161 +0,0 @@ -//===- ArithToAPFloat.cpp - Arithmetic to APFloat Conversion --------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "mlir/Conversion/ArithToAPFloat/ArithToAPFloat.h" - -#include "mlir/Dialect/Arith/IR/Arith.h" -#include "mlir/Dialect/Arith/Transforms/Passes.h" -#include "mlir/Dialect/Func/IR/FuncOps.h" -#include "mlir/Dialect/Func/Utils/Utils.h" -#include "mlir/IR/PatternMatch.h" -#include "mlir/IR/Verifier.h" -#include "mlir/Transforms/WalkPatternRewriteDriver.h" -#include "llvm/Support/Debug.h" - -#define DEBUG_TYPE "arith-to-apfloat" - -namespace mlir { -#define GEN_PASS_DEF_ARITHTOAPFLOATCONVERSIONPASS -#include "mlir/Conversion/Passes.h.inc" -} // namespace mlir - -using namespace mlir; -using namespace mlir::func; - -static FuncOp createFnDecl(OpBuilder &b, SymbolOpInterface symTable, - StringRef name, FunctionType funcT, bool setPrivate, - SymbolTableCollection *symbolTables = nullptr) { - OpBuilder::InsertionGuard g(b); - assert(!symTable->getRegion(0).empty() && "expected non-empty region"); - b.setInsertionPointToStart(&symTable->getRegion(0).front()); - FuncOp funcOp = FuncOp::create(b, symTable->getLoc(), name, funcT); - if (setPrivate) - funcOp.setPrivate(); - if (symbolTables) { - SymbolTable &symbolTable = symbolTables->getSymbolTable(symTable); - symbolTable.insert(funcOp, symTable->getRegion(0).front().begin()); - } - return funcOp; -} - -/// Helper function to look up or create the symbol for a runtime library -/// function for a binary arithmetic operation. -/// -/// Parameter 1: APFloat semantics -/// Parameter 2: Left-hand side operand -/// Parameter 3: Right-hand side operand -/// -/// This function will return a failure if the function is found but has an -/// unexpected signature. -/// -static FailureOr<FuncOp> -lookupOrCreateBinaryFn(OpBuilder &b, SymbolOpInterface symTable, StringRef name, - SymbolTableCollection *symbolTables = nullptr) { - auto i32Type = IntegerType::get(symTable->getContext(), 32); - auto i64Type = IntegerType::get(symTable->getContext(), 64); - - std::string funcName = (llvm::Twine("__mlir_apfloat_") + name).str(); - FunctionType funcT = - FunctionType::get(b.getContext(), {i32Type, i64Type, i64Type}, {i64Type}); - FailureOr<FuncOp> func = - lookupFnDecl(symTable, funcName, funcT, symbolTables); - // Failed due to type mismatch. - if (failed(func)) - return func; - // Successfully matched existing decl. - if (*func) - return *func; - - return createFnDecl(b, symTable, funcName, funcT, - /*setPrivate=*/true, symbolTables); -} - -/// Rewrite a binary arithmetic operation to an APFloat function call. -template <typename OpTy, const char *APFloatName> -struct BinaryArithOpToAPFloatConversion final : OpRewritePattern<OpTy> { - BinaryArithOpToAPFloatConversion(MLIRContext *context, PatternBenefit benefit, - SymbolOpInterface symTable) - : OpRewritePattern<OpTy>(context, benefit), symTable(symTable) {}; - - LogicalResult matchAndRewrite(OpTy op, - PatternRewriter &rewriter) const override { - // Get APFloat function from runtime library. - FailureOr<FuncOp> fn = - lookupOrCreateBinaryFn(rewriter, symTable, APFloatName); - if (failed(fn)) - return fn; - - rewriter.setInsertionPoint(op); - // Cast operands to 64-bit integers. - Location loc = op.getLoc(); - auto floatTy = cast<FloatType>(op.getType()); - auto intWType = rewriter.getIntegerType(floatTy.getWidth()); - auto int64Type = rewriter.getI64Type(); - Value lhsBits = arith::ExtUIOp::create( - rewriter, loc, int64Type, - arith::BitcastOp::create(rewriter, loc, intWType, op.getLhs())); - Value rhsBits = arith::ExtUIOp::create( - rewriter, loc, int64Type, - arith::BitcastOp::create(rewriter, loc, intWType, op.getRhs())); - - // Call APFloat function. - int32_t sem = - llvm::APFloatBase::SemanticsToEnum(floatTy.getFloatSemantics()); - Value semValue = arith::ConstantOp::create( - rewriter, loc, rewriter.getI32Type(), - rewriter.getIntegerAttr(rewriter.getI32Type(), sem)); - SmallVector<Value> params = {semValue, lhsBits, rhsBits}; - auto resultOp = - func::CallOp::create(rewriter, loc, TypeRange(rewriter.getI64Type()), - SymbolRefAttr::get(*fn), params); - - // Truncate result to the original width. - Value truncatedBits = arith::TruncIOp::create(rewriter, loc, intWType, - resultOp->getResult(0)); - rewriter.replaceOp( - op, arith::BitcastOp::create(rewriter, loc, floatTy, truncatedBits)); - return success(); - } - - SymbolOpInterface symTable; -}; - -namespace { -struct ArithToAPFloatConversionPass final - : impl::ArithToAPFloatConversionPassBase<ArithToAPFloatConversionPass> { - using Base::Base; - - void runOnOperation() override { - MLIRContext *context = &getContext(); - RewritePatternSet patterns(context); - static const char add[] = "add"; - static const char subtract[] = "subtract"; - static const char multiply[] = "multiply"; - static const char divide[] = "divide"; - static const char remainder[] = "remainder"; - patterns.add<BinaryArithOpToAPFloatConversion<arith::AddFOp, add>, - BinaryArithOpToAPFloatConversion<arith::SubFOp, subtract>, - BinaryArithOpToAPFloatConversion<arith::MulFOp, multiply>, - BinaryArithOpToAPFloatConversion<arith::DivFOp, divide>, - BinaryArithOpToAPFloatConversion<arith::RemFOp, remainder>>( - context, 1, getOperation()); - LogicalResult result = success(); - ScopedDiagnosticHandler scopedHandler(context, [&result](Diagnostic &diag) { - if (diag.getSeverity() == DiagnosticSeverity::Error) { - result = failure(); - } - // NB: if you don't return failure, no other diag handlers will fire (see - // mlir/lib/IR/Diagnostics.cpp:DiagnosticEngineImpl::emit). - return failure(); - }); - walkAndApplyPatterns(getOperation(), std::move(patterns)); - if (failed(result)) - return signalPassFailure(); - } -}; -} // namespace diff --git a/mlir/lib/Conversion/ArithToAPFloat/CMakeLists.txt b/mlir/lib/Conversion/ArithToAPFloat/CMakeLists.txt deleted file mode 100644 index b0d1e46b3655f..0000000000000 --- a/mlir/lib/Conversion/ArithToAPFloat/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -add_mlir_conversion_library(MLIRArithToAPFloat - ArithToAPFloat.cpp - - ADDITIONAL_HEADER_DIRS - ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/ArithToLLVM - - DEPENDS - MLIRConversionPassIncGen - - LINK_COMPONENTS - Core - - LINK_LIBS PUBLIC - MLIRArithDialect - MLIRArithTransforms - MLIRFuncDialect - ) diff --git a/mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp b/mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp index f2bacc3399144..b6099902cc337 100644 --- a/mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp +++ b/mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp @@ -14,7 +14,6 @@ #include "mlir/Conversion/LLVMCommon/VectorPattern.h" #include "mlir/Dialect/Arith/IR/Arith.h" #include "mlir/Dialect/Arith/Transforms/Passes.h" -#include "mlir/Dialect/LLVMIR/FunctionCallUtils.h" #include "mlir/Dialect/LLVMIR/LLVMAttrs.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/IR/TypeUtilities.h" diff --git a/mlir/lib/Conversion/CMakeLists.txt b/mlir/lib/Conversion/CMakeLists.txt index 613dc6d242ceb..bebf1b8fff3f9 100644 --- a/mlir/lib/Conversion/CMakeLists.txt +++ b/mlir/lib/Conversion/CMakeLists.txt @@ -2,7 +2,6 @@ add_subdirectory(AffineToStandard) add_subdirectory(AMDGPUToROCDL) add_subdirectory(ArithCommon) add_subdirectory(ArithToAMDGPU) -add_subdirectory(ArithToAPFloat) add_subdirectory(ArithToArmSME) add_subdirectory(ArithToEmitC) add_subdirectory(ArithToLLVM) diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp index c747e1b59558a..69a317ecd101f 100644 --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -1654,20 +1654,6 @@ class VectorPrintOpConversion : public ConvertOpToLLVMPattern<vector::PrintOp> { return failure(); } } - } else if (auto floatTy = dyn_cast<FloatType>(printType)) { - // Print other floating-point types using the APFloat runtime library. - int32_t sem = - llvm::APFloatBase::SemanticsToEnum(floatTy.getFloatSemantics()); - Value semValue = LLVM::ConstantOp::create( - rewriter, loc, rewriter.getI32Type(), - rewriter.getIntegerAttr(rewriter.getI32Type(), sem)); - Value floatBits = - LLVM::ZExtOp::create(rewriter, loc, rewriter.getI64Type(), value); - printer = - LLVM::lookupOrCreateApFloatPrintFn(rewriter, parent, symbolTables); - emitCall(rewriter, loc, printer.value(), - ValueRange({semValue, floatBits})); - return success(); } else { return failure(); } diff --git a/mlir/lib/Dialect/Func/Utils/Utils.cpp b/mlir/lib/Dialect/Func/Utils/Utils.cpp index d6dfd0229963c..b4cb0932ef631 100644 --- a/mlir/lib/Dialect/Func/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Func/Utils/Utils.cpp @@ -254,28 +254,3 @@ func::deduplicateArgsOfFuncOp(RewriterBase &rewriter, func::FuncOp funcOp, return std::make_pair(*newFuncOpOrFailure, newCallOp); } - -FailureOr<func::FuncOp> -func::lookupFnDecl(SymbolOpInterface symTable, StringRef name, - FunctionType funcT, SymbolTableCollection *symbolTables) { - FuncOp func; - if (symbolTables) { - func = symbolTables->lookupSymbolIn<FuncOp>( - symTable, StringAttr::get(symTable->getContext(), name)); - } else { - func = llvm::dyn_cast_or_null<FuncOp>( - SymbolTable::lookupSymbolIn(symTable, name)); - } - - if (!func) - return func; - - mlir::FunctionType foundFuncT = func.getFunctionType(); - // Assert the signature of the found function is same as expected - if (funcT != foundFuncT) { - return func.emitError("matched function '") - << name << "' but with different type: " << foundFuncT - << " (expected " << funcT << ")"; - } - return func; -} diff --git a/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp b/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp index 160b6ae89215c..feaffa34897b6 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp @@ -30,7 +30,6 @@ static constexpr llvm::StringRef kPrintF16 = "printF16"; static constexpr llvm::StringRef kPrintBF16 = "printBF16"; static constexpr llvm::StringRef kPrintF32 = "printF32"; static constexpr llvm::StringRef kPrintF64 = "printF64"; -static constexpr llvm::StringRef kPrintApFloat = "printApFloat"; static constexpr llvm::StringRef kPrintString = "printString"; static constexpr llvm::StringRef kPrintOpen = "printOpen"; static constexpr llvm::StringRef kPrintClose = "printClose"; @@ -161,16 +160,6 @@ mlir::LLVM::lookupOrCreatePrintF64Fn(OpBuilder &b, Operation *moduleOp, LLVM::LLVMVoidType::get(moduleOp->getContext()), symbolTables); } -FailureOr<LLVM::LLVMFuncOp> -mlir::LLVM::lookupOrCreateApFloatPrintFn(OpBuilder &b, Operation *moduleOp, - SymbolTableCollection *symbolTables) { - return lookupOrCreateReservedFn( - b, moduleOp, kPrintApFloat, - {IntegerType::get(moduleOp->getContext(), 32), - IntegerType::get(moduleOp->getContext(), 64)}, - LLVM::LLVMVoidType::get(moduleOp->getContext()), symbolTables); -} - static LLVM::LLVMPointerType getCharPtr(MLIRContext *context) { return LLVM::LLVMPointerType::get(context); } diff --git a/mlir/lib/ExecutionEngine/APFloatWrappers.cpp b/mlir/lib/ExecutionEngine/APFloatWrappers.cpp deleted file mode 100644 index 85ea0986cde5b..0000000000000 --- a/mlir/lib/ExecutionEngine/APFloatWrappers.cpp +++ /dev/null @@ -1,81 +0,0 @@ -//===- APFloatWrappers.cpp - Software Implementation of FP Arithmetics --- ===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file exposes the APFloat infrastructure to MLIR programs as a runtime -// library. APFloat is a software implementation of floating point arithmetics. -// -// On the MLIR side, floating-point values must be bitcasted to 64-bit integers -// before calling a runtime function. If a floating-point type has less than -// 64 bits, it must be zero-extended to 64 bits after bitcasting it to an -// integer. -// -// Runtime functions receive the floating-point operands of the arithmeic -// operation in the form of 64-bit integers, along with the APFloat semantics -// in the form of a 32-bit integer, which will be interpreted as an -// APFloatBase::Semantics enum value. -// -#include "llvm/ADT/APFloat.h" - -#if (defined(_WIN32) || defined(__CYGWIN__)) -#define MLIR_APFLOAT_WRAPPERS_EXPORTED __declspec(dllexport) -#else -#define MLIR_APFLOAT_WRAPPERS_EXPORTED __attribute__((visibility("default"))) -#endif - -/// Binary operations without rounding mode. -#define APFLOAT_BINARY_OP(OP) \ - int64_t MLIR_APFLOAT_WRAPPERS_EXPORTED __mlir_apfloat_##OP( \ - int32_t semantics, uint64_t a, uint64_t b) { \ - const llvm::fltSemantics &sem = llvm::APFloatBase::EnumToSemantics( \ - static_cast<llvm::APFloatBase::Semantics>(semantics)); \ - unsigned bitWidth = llvm::APFloatBase::semanticsSizeInBits(sem); \ - llvm::APFloat lhs(sem, llvm::APInt(bitWidth, a)); \ - llvm::APFloat rhs(sem, llvm::APInt(bitWidth, b)); \ - lhs.OP(rhs); \ - return lhs.bitcastToAPInt().getZExtValue(); \ - } - -/// Binary operations with rounding mode. -#define APFLOAT_BINARY_OP_ROUNDING_MODE(OP, ROUNDING_MODE) \ - int64_t MLIR_APFLOAT_WRAPPERS_EXPORTED __mlir_apfloat_##OP( \ - int32_t semantics, uint64_t a, uint64_t b) { \ - const llvm::fltSemantics &sem = llvm::APFloatBase::EnumToSemantics( \ - static_cast<llvm::APFloatBase::Semantics>(semantics)); \ - unsigned bitWidth = llvm::APFloatBase::semanticsSizeInBits(sem); \ - llvm::APFloat lhs(sem, llvm::APInt(bitWidth, a)); \ - llvm::APFloat rhs(sem, llvm::APInt(bitWidth, b)); \ - lhs.OP(rhs, ROUNDING_MODE); \ - return lhs.bitcastToAPInt().getZExtValue(); \ - } - -extern "C" { - -#define BIN_OPS_WITH_ROUNDING(X) \ - X(add, llvm::RoundingMode::NearestT... [truncated] 
@llvmbot
Copy link
Member

llvmbot commented Nov 11, 2025

@llvm/pr-subscribers-mlir-func

Author: Maksim Levental (makslevental)

Changes

This reverts commit 222f4e4.


Patch is 29.45 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/167429.diff

16 Files Affected:

  • (removed) mlir/include/mlir/Conversion/ArithToAPFloat/ArithToAPFloat.h (-21)
  • (modified) mlir/include/mlir/Conversion/Passes.h (-1)
  • (modified) mlir/include/mlir/Conversion/Passes.td (-15)
  • (modified) mlir/include/mlir/Dialect/Func/Utils/Utils.h (-7)
  • (modified) mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h (-4)
  • (removed) mlir/lib/Conversion/ArithToAPFloat/ArithToAPFloat.cpp (-161)
  • (removed) mlir/lib/Conversion/ArithToAPFloat/CMakeLists.txt (-17)
  • (modified) mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp (-1)
  • (modified) mlir/lib/Conversion/CMakeLists.txt (-1)
  • (modified) mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp (-14)
  • (modified) mlir/lib/Dialect/Func/Utils/Utils.cpp (-25)
  • (modified) mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp (-11)
  • (removed) mlir/lib/ExecutionEngine/APFloatWrappers.cpp (-81)
  • (modified) mlir/lib/ExecutionEngine/CMakeLists.txt (-12)
  • (removed) mlir/test/Conversion/ArithToApfloat/arith-to-apfloat.mlir (-128)
  • (removed) mlir/test/Integration/Dialect/Arith/CPU/test-apfloat-emulation.mlir (-34)
diff --git a/mlir/include/mlir/Conversion/ArithToAPFloat/ArithToAPFloat.h b/mlir/include/mlir/Conversion/ArithToAPFloat/ArithToAPFloat.h deleted file mode 100644 index 64a42a228199e..0000000000000 --- a/mlir/include/mlir/Conversion/ArithToAPFloat/ArithToAPFloat.h +++ /dev/null @@ -1,21 +0,0 @@ -//===- ArithToAPFloat.h - Arith to APFloat impl conversion ---*- C++ ----*-===// -// -// Part of the APFloat Project, under the Apache License v2.0 with APFloat -// Exceptions. See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH APFloat-exception -// -//===----------------------------------------------------------------------===// - -#ifndef MLIR_CONVERSION_ARITHTOAPFLOAT_ARITHTOAPFLOAT_H -#define MLIR_CONVERSION_ARITHTOAPFLOAT_ARITHTOAPFLOAT_H - -#include <memory> - -namespace mlir { -class Pass; - -#define GEN_PASS_DECL_ARITHTOAPFLOATCONVERSIONPASS -#include "mlir/Conversion/Passes.h.inc" -} // namespace mlir - -#endif // MLIR_CONVERSION_ARITHTOAPFLOAT_ARITHTOAPFLOAT_H diff --git a/mlir/include/mlir/Conversion/Passes.h b/mlir/include/mlir/Conversion/Passes.h index 82bdfd02661a6..40d866ec7bf10 100644 --- a/mlir/include/mlir/Conversion/Passes.h +++ b/mlir/include/mlir/Conversion/Passes.h @@ -12,7 +12,6 @@ #include "mlir/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.h" #include "mlir/Conversion/AffineToStandard/AffineToStandard.h" #include "mlir/Conversion/ArithToAMDGPU/ArithToAMDGPU.h" -#include "mlir/Conversion/ArithToAPFloat/ArithToAPFloat.h" #include "mlir/Conversion/ArithToArmSME/ArithToArmSME.h" #include "mlir/Conversion/ArithToEmitC/ArithToEmitCPass.h" #include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h" diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td index 79bc380dbcb7a..70e3e45c225db 100644 --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -186,21 +186,6 @@ def ArithToLLVMConversionPass : Pass<"convert-arith-to-llvm"> { ]; } -//===----------------------------------------------------------------------===// -// ArithToAPFloat -//===----------------------------------------------------------------------===// - -def ArithToAPFloatConversionPass - : Pass<"convert-arith-to-apfloat", "ModuleOp"> { - let summary = "Convert Arith ops to APFloat runtime library calls"; - let description = [{ - This pass converts supported Arith ops to APFloat-based runtime library - calls (APFloatWrappers.cpp). APFloat is a software implementation of - floating-point arithmetic operations. - }]; - let dependentDialects = ["func::FuncDialect"]; -} - //===----------------------------------------------------------------------===// // ArithToSPIRV //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Dialect/Func/Utils/Utils.h b/mlir/include/mlir/Dialect/Func/Utils/Utils.h index 00d50874a2e8d..3576126a487ac 100644 --- a/mlir/include/mlir/Dialect/Func/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Func/Utils/Utils.h @@ -60,13 +60,6 @@ mlir::FailureOr<std::pair<mlir::func::FuncOp, mlir::func::CallOp>> deduplicateArgsOfFuncOp(mlir::RewriterBase &rewriter, mlir::func::FuncOp funcOp, mlir::ModuleOp moduleOp); -/// Look up a FuncOp with signature `resultTypes`(`paramTypes`)` and name -/// `name`. Return a failure if the FuncOp is found but with a different -/// signature. -FailureOr<FuncOp> lookupFnDecl(SymbolOpInterface symTable, StringRef name, - FunctionType funcT, - SymbolTableCollection *symbolTables = nullptr); - } // namespace func } // namespace mlir diff --git a/mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h b/mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h index b09d32022e348..8ad9ed18acebd 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h +++ b/mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h @@ -52,10 +52,6 @@ lookupOrCreatePrintF32Fn(OpBuilder &b, Operation *moduleOp, FailureOr<LLVM::LLVMFuncOp> lookupOrCreatePrintF64Fn(OpBuilder &b, Operation *moduleOp, SymbolTableCollection *symbolTables = nullptr); -FailureOr<LLVM::LLVMFuncOp> -lookupOrCreateApFloatPrintFn(OpBuilder &b, Operation *moduleOp, - SymbolTableCollection *symbolTables = nullptr); - /// Declares a function to print a C-string. /// If a custom runtime function is defined via `runtimeFunctionName`, it must /// have the signature void(char const*). The default function is `printString`. diff --git a/mlir/lib/Conversion/ArithToAPFloat/ArithToAPFloat.cpp b/mlir/lib/Conversion/ArithToAPFloat/ArithToAPFloat.cpp deleted file mode 100644 index 012e934d3050f..0000000000000 --- a/mlir/lib/Conversion/ArithToAPFloat/ArithToAPFloat.cpp +++ /dev/null @@ -1,161 +0,0 @@ -//===- ArithToAPFloat.cpp - Arithmetic to APFloat Conversion --------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "mlir/Conversion/ArithToAPFloat/ArithToAPFloat.h" - -#include "mlir/Dialect/Arith/IR/Arith.h" -#include "mlir/Dialect/Arith/Transforms/Passes.h" -#include "mlir/Dialect/Func/IR/FuncOps.h" -#include "mlir/Dialect/Func/Utils/Utils.h" -#include "mlir/IR/PatternMatch.h" -#include "mlir/IR/Verifier.h" -#include "mlir/Transforms/WalkPatternRewriteDriver.h" -#include "llvm/Support/Debug.h" - -#define DEBUG_TYPE "arith-to-apfloat" - -namespace mlir { -#define GEN_PASS_DEF_ARITHTOAPFLOATCONVERSIONPASS -#include "mlir/Conversion/Passes.h.inc" -} // namespace mlir - -using namespace mlir; -using namespace mlir::func; - -static FuncOp createFnDecl(OpBuilder &b, SymbolOpInterface symTable, - StringRef name, FunctionType funcT, bool setPrivate, - SymbolTableCollection *symbolTables = nullptr) { - OpBuilder::InsertionGuard g(b); - assert(!symTable->getRegion(0).empty() && "expected non-empty region"); - b.setInsertionPointToStart(&symTable->getRegion(0).front()); - FuncOp funcOp = FuncOp::create(b, symTable->getLoc(), name, funcT); - if (setPrivate) - funcOp.setPrivate(); - if (symbolTables) { - SymbolTable &symbolTable = symbolTables->getSymbolTable(symTable); - symbolTable.insert(funcOp, symTable->getRegion(0).front().begin()); - } - return funcOp; -} - -/// Helper function to look up or create the symbol for a runtime library -/// function for a binary arithmetic operation. -/// -/// Parameter 1: APFloat semantics -/// Parameter 2: Left-hand side operand -/// Parameter 3: Right-hand side operand -/// -/// This function will return a failure if the function is found but has an -/// unexpected signature. -/// -static FailureOr<FuncOp> -lookupOrCreateBinaryFn(OpBuilder &b, SymbolOpInterface symTable, StringRef name, - SymbolTableCollection *symbolTables = nullptr) { - auto i32Type = IntegerType::get(symTable->getContext(), 32); - auto i64Type = IntegerType::get(symTable->getContext(), 64); - - std::string funcName = (llvm::Twine("__mlir_apfloat_") + name).str(); - FunctionType funcT = - FunctionType::get(b.getContext(), {i32Type, i64Type, i64Type}, {i64Type}); - FailureOr<FuncOp> func = - lookupFnDecl(symTable, funcName, funcT, symbolTables); - // Failed due to type mismatch. - if (failed(func)) - return func; - // Successfully matched existing decl. - if (*func) - return *func; - - return createFnDecl(b, symTable, funcName, funcT, - /*setPrivate=*/true, symbolTables); -} - -/// Rewrite a binary arithmetic operation to an APFloat function call. -template <typename OpTy, const char *APFloatName> -struct BinaryArithOpToAPFloatConversion final : OpRewritePattern<OpTy> { - BinaryArithOpToAPFloatConversion(MLIRContext *context, PatternBenefit benefit, - SymbolOpInterface symTable) - : OpRewritePattern<OpTy>(context, benefit), symTable(symTable) {}; - - LogicalResult matchAndRewrite(OpTy op, - PatternRewriter &rewriter) const override { - // Get APFloat function from runtime library. - FailureOr<FuncOp> fn = - lookupOrCreateBinaryFn(rewriter, symTable, APFloatName); - if (failed(fn)) - return fn; - - rewriter.setInsertionPoint(op); - // Cast operands to 64-bit integers. - Location loc = op.getLoc(); - auto floatTy = cast<FloatType>(op.getType()); - auto intWType = rewriter.getIntegerType(floatTy.getWidth()); - auto int64Type = rewriter.getI64Type(); - Value lhsBits = arith::ExtUIOp::create( - rewriter, loc, int64Type, - arith::BitcastOp::create(rewriter, loc, intWType, op.getLhs())); - Value rhsBits = arith::ExtUIOp::create( - rewriter, loc, int64Type, - arith::BitcastOp::create(rewriter, loc, intWType, op.getRhs())); - - // Call APFloat function. - int32_t sem = - llvm::APFloatBase::SemanticsToEnum(floatTy.getFloatSemantics()); - Value semValue = arith::ConstantOp::create( - rewriter, loc, rewriter.getI32Type(), - rewriter.getIntegerAttr(rewriter.getI32Type(), sem)); - SmallVector<Value> params = {semValue, lhsBits, rhsBits}; - auto resultOp = - func::CallOp::create(rewriter, loc, TypeRange(rewriter.getI64Type()), - SymbolRefAttr::get(*fn), params); - - // Truncate result to the original width. - Value truncatedBits = arith::TruncIOp::create(rewriter, loc, intWType, - resultOp->getResult(0)); - rewriter.replaceOp( - op, arith::BitcastOp::create(rewriter, loc, floatTy, truncatedBits)); - return success(); - } - - SymbolOpInterface symTable; -}; - -namespace { -struct ArithToAPFloatConversionPass final - : impl::ArithToAPFloatConversionPassBase<ArithToAPFloatConversionPass> { - using Base::Base; - - void runOnOperation() override { - MLIRContext *context = &getContext(); - RewritePatternSet patterns(context); - static const char add[] = "add"; - static const char subtract[] = "subtract"; - static const char multiply[] = "multiply"; - static const char divide[] = "divide"; - static const char remainder[] = "remainder"; - patterns.add<BinaryArithOpToAPFloatConversion<arith::AddFOp, add>, - BinaryArithOpToAPFloatConversion<arith::SubFOp, subtract>, - BinaryArithOpToAPFloatConversion<arith::MulFOp, multiply>, - BinaryArithOpToAPFloatConversion<arith::DivFOp, divide>, - BinaryArithOpToAPFloatConversion<arith::RemFOp, remainder>>( - context, 1, getOperation()); - LogicalResult result = success(); - ScopedDiagnosticHandler scopedHandler(context, [&result](Diagnostic &diag) { - if (diag.getSeverity() == DiagnosticSeverity::Error) { - result = failure(); - } - // NB: if you don't return failure, no other diag handlers will fire (see - // mlir/lib/IR/Diagnostics.cpp:DiagnosticEngineImpl::emit). - return failure(); - }); - walkAndApplyPatterns(getOperation(), std::move(patterns)); - if (failed(result)) - return signalPassFailure(); - } -}; -} // namespace diff --git a/mlir/lib/Conversion/ArithToAPFloat/CMakeLists.txt b/mlir/lib/Conversion/ArithToAPFloat/CMakeLists.txt deleted file mode 100644 index b0d1e46b3655f..0000000000000 --- a/mlir/lib/Conversion/ArithToAPFloat/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -add_mlir_conversion_library(MLIRArithToAPFloat - ArithToAPFloat.cpp - - ADDITIONAL_HEADER_DIRS - ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/ArithToLLVM - - DEPENDS - MLIRConversionPassIncGen - - LINK_COMPONENTS - Core - - LINK_LIBS PUBLIC - MLIRArithDialect - MLIRArithTransforms - MLIRFuncDialect - ) diff --git a/mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp b/mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp index f2bacc3399144..b6099902cc337 100644 --- a/mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp +++ b/mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp @@ -14,7 +14,6 @@ #include "mlir/Conversion/LLVMCommon/VectorPattern.h" #include "mlir/Dialect/Arith/IR/Arith.h" #include "mlir/Dialect/Arith/Transforms/Passes.h" -#include "mlir/Dialect/LLVMIR/FunctionCallUtils.h" #include "mlir/Dialect/LLVMIR/LLVMAttrs.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/IR/TypeUtilities.h" diff --git a/mlir/lib/Conversion/CMakeLists.txt b/mlir/lib/Conversion/CMakeLists.txt index 613dc6d242ceb..bebf1b8fff3f9 100644 --- a/mlir/lib/Conversion/CMakeLists.txt +++ b/mlir/lib/Conversion/CMakeLists.txt @@ -2,7 +2,6 @@ add_subdirectory(AffineToStandard) add_subdirectory(AMDGPUToROCDL) add_subdirectory(ArithCommon) add_subdirectory(ArithToAMDGPU) -add_subdirectory(ArithToAPFloat) add_subdirectory(ArithToArmSME) add_subdirectory(ArithToEmitC) add_subdirectory(ArithToLLVM) diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp index c747e1b59558a..69a317ecd101f 100644 --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -1654,20 +1654,6 @@ class VectorPrintOpConversion : public ConvertOpToLLVMPattern<vector::PrintOp> { return failure(); } } - } else if (auto floatTy = dyn_cast<FloatType>(printType)) { - // Print other floating-point types using the APFloat runtime library. - int32_t sem = - llvm::APFloatBase::SemanticsToEnum(floatTy.getFloatSemantics()); - Value semValue = LLVM::ConstantOp::create( - rewriter, loc, rewriter.getI32Type(), - rewriter.getIntegerAttr(rewriter.getI32Type(), sem)); - Value floatBits = - LLVM::ZExtOp::create(rewriter, loc, rewriter.getI64Type(), value); - printer = - LLVM::lookupOrCreateApFloatPrintFn(rewriter, parent, symbolTables); - emitCall(rewriter, loc, printer.value(), - ValueRange({semValue, floatBits})); - return success(); } else { return failure(); } diff --git a/mlir/lib/Dialect/Func/Utils/Utils.cpp b/mlir/lib/Dialect/Func/Utils/Utils.cpp index d6dfd0229963c..b4cb0932ef631 100644 --- a/mlir/lib/Dialect/Func/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Func/Utils/Utils.cpp @@ -254,28 +254,3 @@ func::deduplicateArgsOfFuncOp(RewriterBase &rewriter, func::FuncOp funcOp, return std::make_pair(*newFuncOpOrFailure, newCallOp); } - -FailureOr<func::FuncOp> -func::lookupFnDecl(SymbolOpInterface symTable, StringRef name, - FunctionType funcT, SymbolTableCollection *symbolTables) { - FuncOp func; - if (symbolTables) { - func = symbolTables->lookupSymbolIn<FuncOp>( - symTable, StringAttr::get(symTable->getContext(), name)); - } else { - func = llvm::dyn_cast_or_null<FuncOp>( - SymbolTable::lookupSymbolIn(symTable, name)); - } - - if (!func) - return func; - - mlir::FunctionType foundFuncT = func.getFunctionType(); - // Assert the signature of the found function is same as expected - if (funcT != foundFuncT) { - return func.emitError("matched function '") - << name << "' but with different type: " << foundFuncT - << " (expected " << funcT << ")"; - } - return func; -} diff --git a/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp b/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp index 160b6ae89215c..feaffa34897b6 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp @@ -30,7 +30,6 @@ static constexpr llvm::StringRef kPrintF16 = "printF16"; static constexpr llvm::StringRef kPrintBF16 = "printBF16"; static constexpr llvm::StringRef kPrintF32 = "printF32"; static constexpr llvm::StringRef kPrintF64 = "printF64"; -static constexpr llvm::StringRef kPrintApFloat = "printApFloat"; static constexpr llvm::StringRef kPrintString = "printString"; static constexpr llvm::StringRef kPrintOpen = "printOpen"; static constexpr llvm::StringRef kPrintClose = "printClose"; @@ -161,16 +160,6 @@ mlir::LLVM::lookupOrCreatePrintF64Fn(OpBuilder &b, Operation *moduleOp, LLVM::LLVMVoidType::get(moduleOp->getContext()), symbolTables); } -FailureOr<LLVM::LLVMFuncOp> -mlir::LLVM::lookupOrCreateApFloatPrintFn(OpBuilder &b, Operation *moduleOp, - SymbolTableCollection *symbolTables) { - return lookupOrCreateReservedFn( - b, moduleOp, kPrintApFloat, - {IntegerType::get(moduleOp->getContext(), 32), - IntegerType::get(moduleOp->getContext(), 64)}, - LLVM::LLVMVoidType::get(moduleOp->getContext()), symbolTables); -} - static LLVM::LLVMPointerType getCharPtr(MLIRContext *context) { return LLVM::LLVMPointerType::get(context); } diff --git a/mlir/lib/ExecutionEngine/APFloatWrappers.cpp b/mlir/lib/ExecutionEngine/APFloatWrappers.cpp deleted file mode 100644 index 85ea0986cde5b..0000000000000 --- a/mlir/lib/ExecutionEngine/APFloatWrappers.cpp +++ /dev/null @@ -1,81 +0,0 @@ -//===- APFloatWrappers.cpp - Software Implementation of FP Arithmetics --- ===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file exposes the APFloat infrastructure to MLIR programs as a runtime -// library. APFloat is a software implementation of floating point arithmetics. -// -// On the MLIR side, floating-point values must be bitcasted to 64-bit integers -// before calling a runtime function. If a floating-point type has less than -// 64 bits, it must be zero-extended to 64 bits after bitcasting it to an -// integer. -// -// Runtime functions receive the floating-point operands of the arithmeic -// operation in the form of 64-bit integers, along with the APFloat semantics -// in the form of a 32-bit integer, which will be interpreted as an -// APFloatBase::Semantics enum value. -// -#include "llvm/ADT/APFloat.h" - -#if (defined(_WIN32) || defined(__CYGWIN__)) -#define MLIR_APFLOAT_WRAPPERS_EXPORTED __declspec(dllexport) -#else -#define MLIR_APFLOAT_WRAPPERS_EXPORTED __attribute__((visibility("default"))) -#endif - -/// Binary operations without rounding mode. -#define APFLOAT_BINARY_OP(OP) \ - int64_t MLIR_APFLOAT_WRAPPERS_EXPORTED __mlir_apfloat_##OP( \ - int32_t semantics, uint64_t a, uint64_t b) { \ - const llvm::fltSemantics &sem = llvm::APFloatBase::EnumToSemantics( \ - static_cast<llvm::APFloatBase::Semantics>(semantics)); \ - unsigned bitWidth = llvm::APFloatBase::semanticsSizeInBits(sem); \ - llvm::APFloat lhs(sem, llvm::APInt(bitWidth, a)); \ - llvm::APFloat rhs(sem, llvm::APInt(bitWidth, b)); \ - lhs.OP(rhs); \ - return lhs.bitcastToAPInt().getZExtValue(); \ - } - -/// Binary operations with rounding mode. -#define APFLOAT_BINARY_OP_ROUNDING_MODE(OP, ROUNDING_MODE) \ - int64_t MLIR_APFLOAT_WRAPPERS_EXPORTED __mlir_apfloat_##OP( \ - int32_t semantics, uint64_t a, uint64_t b) { \ - const llvm::fltSemantics &sem = llvm::APFloatBase::EnumToSemantics( \ - static_cast<llvm::APFloatBase::Semantics>(semantics)); \ - unsigned bitWidth = llvm::APFloatBase::semanticsSizeInBits(sem); \ - llvm::APFloat lhs(sem, llvm::APInt(bitWidth, a)); \ - llvm::APFloat rhs(sem, llvm::APInt(bitWidth, b)); \ - lhs.OP(rhs, ROUNDING_MODE); \ - return lhs.bitcastToAPInt().getZExtValue(); \ - } - -extern "C" { - -#define BIN_OPS_WITH_ROUNDING(X) \ - X(add, llvm::RoundingMode::NearestT... [truncated] 
@makslevental makslevental merged commit 70d379f into main Nov 11, 2025
13 of 16 checks passed
@makslevental makslevental deleted the users/makslevental/fix-revert branch November 11, 2025 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment