MLIR  16.0.0git
Namespaces | Macros | Functions
MathToFuncs.cpp File Reference
#include "mlir/Conversion/MathToFuncs/MathToFuncs.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/Dialect/Vector/Utils/VectorUtils.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/TypeSwitch.h"
#include "mlir/Conversion/Passes.h.inc"
+ Include dependency graph for MathToFuncs.cpp:

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 

Macros

#define GEN_PASS_DEF_CONVERTMATHTOFUNCS
 

Functions

static func::FuncOp createElementIPowIFunc (ModuleOp *module, Type elementType)
 Create linkonce_odr function to implement the power function with the given funcType type inside module. More...
 

Macro Definition Documentation

◆ GEN_PASS_DEF_CONVERTMATHTOFUNCS

#define GEN_PASS_DEF_CONVERTMATHTOFUNCS

Definition at line 27 of file MathToFuncs.cpp.

Function Documentation

◆ createElementIPowIFunc()

static func::FuncOp createElementIPowIFunc ( ModuleOp *  module,
Type  elementType 
)
static

Create linkonce_odr function to implement the power function with the given funcType type inside module.

funcType must be 'IntegerType (*)(IntegerType, IntegerType)' function type.

template <typename T> T __mlir_math_ipowi_*(T b, T p) { if (p == T(0)) return T(1); if (p < T(0)) { if (b == T(0)) return T(1) / T(0); // trigger div-by-zero if (b == T(1)) return T(1); if (b == T(-1)) { if (p & T(1)) return T(-1); return T(1); } return T(0); } T result = T(1); while (true) { if (p & T(1)) result *= b; p >>= T(1); if (p == T(0)) return result; b *= b; } }

Definition at line 129 of file MathToFuncs.cpp.

References mlir::ImplicitLocOpBuilder::atBlockEnd(), mlir::ImplicitLocOpBuilder::create(), mlir::OpBuilder::createBlock(), mlir::Region::end(), mlir::Builder::getContext(), mlir::Builder::getIntegerAttr(), mlir::Type::getIntOrFloatBitWidth(), mlir::ImplicitLocOpBuilder::getLoc(), mlir::Block::getParent(), mlir::Type::isa(), and mlir::OpBuilder::setInsertionPointToEnd().