picceler
Loading...
Searching...
No Matches
picceler Namespace Reference

Namespaces

namespace  utils

Classes

struct  AssignmentNode
 AST node for assignment statements. More...
struct  ASTNode
 Abstract Syntax Tree (AST) node base class. More...
struct  BrightnessToAffine
struct  CallNode
 AST node for function calls. More...
class  CLIOptions
 Struct to hold command-line options for the compiler. More...
struct  CompileError
 Struct to hold compilation error information. More...
class  Compiler
 Compiler class that orchestrates the compilation process. More...
struct  CropToAffine
struct  ElementWiseBinaryOpToAffine
struct  FilterToConvolutionPattern
struct  ImageAccessHelper
 Helper class to generate LLVM IR for accessing fields of the Image struct via an opaque pointer. Assumes the following C++ struct layout: struct Image { uint32_t _width; // Offset 0 uint32_t _height; // Offset 4 unsigned char *_data; // Offset 8 };. More...
struct  InvertToAffine
class  IRPassManager
 Wrapper around MLIR PassManager to manage and run passes. More...
struct  KernelData
struct  KernelNode
 AST node for kernel definitions. More...
struct  KernelToMemref
class  Lexer
 Lexical analyzer for the picceler programming language. More...
struct  LoadImageToCall
 Pattern to lower LoadImageOp to a function call. More...
class  MLIRGen
 MLIR code generator that converts AST nodes to MLIR constructs. This offers the initial IR generation from the AST. More...
struct  ModuleNode
 AST node for the entire module. More...
struct  NeighbourhoodOpsToAffine
struct  NumberNode
 AST node for numeric literals. More...
class  Parser
 The Parser class that converts tokens into an AST. More...
struct  PassLogger
 Custom struct to log pass execution using spdlog. This struct implements the PassInstrumentation interface to hook into the pass execution lifecycle. More...
struct  PiccelerFiltersToConvPass
 A pass that converts high-level image filter operations (like sharpen, blur, edge detect) into convolution operations with constant kernels. More...
struct  PiccelerKernelToMemrefPass
 A pass that converts KernelConstOp operations, which represent constant convolution kernels, into MemRef operations that allocate memory for the kernel and store the constant values into it. More...
struct  PiccelerOpsToFuncCallsPass
 A pass that converts image operations (like load, show, save) into function calls. More...
struct  PiccelerToAffinePass
 A pass that converts Picceler operations to the Affine dialect. This is the crucial step where we lower from our high-level image processing operations to a more explicit representation that can be further lowered to LLVM IR. Each Picceler operation is matched and rewritten into one or more Affine loops that perform the equivalent computation. This pass also handles type conversions and ensures that necessary runtime functions (like piccelerCreateImage) are declared. More...
struct  PiccelerToLLVMIRPass
 A pass that helps convert last pieces of Picceler IR to LLVM IR. More...
struct  ReadNumberToCall
struct  ReadStringToCall
struct  RotateToAffine
struct  SaveImageToCall
 Pattern to lower SaveImageOp to a function call. More...
struct  ShowImageToCall
 Pattern to lower ShowImageOp to a function call. More...
struct  StringConstConverter
struct  StringNode
 AST node for string literals. More...
struct  Token
 Represents a token produced by the lexer. More...
struct  VariableNode
 AST node for variable references. More...

Typedefs

template<typename T>
using Result = std::expected<T, CompileError>
 A type alias for the result of a compilation operation.

Functions

std::ostream & operator<< (std::ostream &os, const Token &token)
 Outputs a token to the given output stream.
mlir::Value createFloatConstant (mlir::OpBuilder &builder, mlir::Location loc, double value)
 Common utility function to create a constant float value in MLIR.
mlir::Value createIntConstant (mlir::OpBuilder &builder, mlir::Location loc, int64_t value)
 Common utility function to create a constant int value in MLIR.
mlir::Value coerceValueToInt64 (mlir::OpBuilder &builder, mlir::Location loc, mlir::Value value, llvm::StringRef opName, llvm::StringRef argName)
 Coerces a given MLIR value to a 64-bit integer if possible, with special handling for constants.
Result< std::pair< mlir::Value, mlir::Value > > getKernelNeighborhoodSize (mlir::OpBuilder &builder, mlir::Location loc, mlir::Value kernelOperand)
mlir::FailureOr< KernelDatacalculateSharpenKernel (SharpenOp op, SharpenOpAdaptor adaptor)
mlir::FailureOr< KernelDatacalculateBoxBlurKernel (BoxBlurOp op, BoxBlurOpAdaptor adaptor)
mlir::FailureOr< KernelDatacalculateGaussianKernel (GaussianBlurOp op, GaussianBlurOpAdaptor adaptor)
mlir::FailureOr< KernelDatacalculateEdgeDetectKernel (EdgeDetectOp op, EdgeDetectOpAdaptor adaptor)
mlir::FailureOr< KernelDatacalculateEmbossKernel (EmbossOp op, EmbossOpAdaptor adaptor)
mlir::func::FuncOp ensureRuntimeFunc (mlir::ModuleOp module, mlir::StringRef name, llvm::ArrayRef< mlir::Type > inputs, llvm::ArrayRef< mlir::Type > results, mlir::PatternRewriter &rewriter, mlir::Location loc)
 Ensures that a runtime function is declared in the module. If the function does not exist, it is created.
The following functions create instances of the various passes used in the compilation process.

Each function corresponds to a specific pass that transforms the IR in a particular way.

std::unique_ptr< mlir::Pass > createPiccelerKernelToMemrefPass ()
std::unique_ptr< mlir::Pass > createPiccelerOpsToFuncCallsPass ()
std::unique_ptr< mlir::Pass > createPiccelerToAffinePass ()
std::unique_ptr< mlir::Pass > createPiccelerToLLVMIRPass ()
std::unique_ptr< mlir::Pass > createPiccelerFiltersToConvPass ()

Typedef Documentation

◆ Result

template<typename T>
using picceler::Result = std::expected<T, CompileError>

A type alias for the result of a compilation operation.

Template Parameters
TThe type of the successful result.

Function Documentation

◆ calculateBoxBlurKernel()

mlir::FailureOr< KernelData > picceler::calculateBoxBlurKernel ( BoxBlurOp op,
BoxBlurOpAdaptor adaptor )

◆ calculateEdgeDetectKernel()

mlir::FailureOr< KernelData > picceler::calculateEdgeDetectKernel ( EdgeDetectOp op,
EdgeDetectOpAdaptor adaptor )

◆ calculateEmbossKernel()

mlir::FailureOr< KernelData > picceler::calculateEmbossKernel ( EmbossOp op,
EmbossOpAdaptor adaptor )

◆ calculateGaussianKernel()

mlir::FailureOr< KernelData > picceler::calculateGaussianKernel ( GaussianBlurOp op,
GaussianBlurOpAdaptor adaptor )

◆ calculateSharpenKernel()

mlir::FailureOr< KernelData > picceler::calculateSharpenKernel ( SharpenOp op,
SharpenOpAdaptor adaptor )

◆ coerceValueToInt64()

mlir::Value picceler::coerceValueToInt64 ( mlir::OpBuilder & builder,
mlir::Location loc,
mlir::Value value,
llvm::StringRef opName,
llvm::StringRef argName )

Coerces a given MLIR value to a 64-bit integer if possible, with special handling for constants.

Parameters
builderThe MLIR OpBuilder to use for creating new operations if coercion is needed.
locThe location to use for any new operations created during coercion.
valueThe MLIR value to coerce.
opNameThe name of the operation for error reporting purposes.
argNameThe name of the argument for error reporting purposes.
Returns
The coerced MLIR value as a 64-bit integer.
Exceptions
std::runtime_errorif the value cannot be coerced to a 64-bit integer, or if a floating-point constant is not a whole number or is out of range.

◆ createFloatConstant()

mlir::Value picceler::createFloatConstant ( mlir::OpBuilder & builder,
mlir::Location loc,
double value )

Common utility function to create a constant float value in MLIR.

Parameters
builderThe MLIR OpBuilder to use for creating the operation.
locThe MLIR Location to associate with the operation.
valueThe double value to create as a constant.
Returns
An MLIR Value representing the constant float.

◆ createIntConstant()

mlir::Value picceler::createIntConstant ( mlir::OpBuilder & builder,
mlir::Location loc,
int64_t value )

Common utility function to create a constant int value in MLIR.

Parameters
builderThe MLIR OpBuilder to use for creating the operation.
locThe MLIR Location to associate with the operation.
valueThe int64_t value to create as a constant.
Returns
An MLIR Value representing the constant int.

◆ createPiccelerFiltersToConvPass()

std::unique_ptr< mlir::Pass > picceler::createPiccelerFiltersToConvPass ( )

◆ createPiccelerKernelToMemrefPass()

std::unique_ptr< mlir::Pass > picceler::createPiccelerKernelToMemrefPass ( )

◆ createPiccelerOpsToFuncCallsPass()

std::unique_ptr< mlir::Pass > picceler::createPiccelerOpsToFuncCallsPass ( )

◆ createPiccelerToAffinePass()

std::unique_ptr< mlir::Pass > picceler::createPiccelerToAffinePass ( )

◆ createPiccelerToLLVMIRPass()

std::unique_ptr< mlir::Pass > picceler::createPiccelerToLLVMIRPass ( )

◆ ensureRuntimeFunc()

mlir::func::FuncOp picceler::ensureRuntimeFunc ( mlir::ModuleOp module,
mlir::StringRef name,
llvm::ArrayRef< mlir::Type > inputs,
llvm::ArrayRef< mlir::Type > results,
mlir::PatternRewriter & rewriter,
mlir::Location loc )

Ensures that a runtime function is declared in the module. If the function does not exist, it is created.

Parameters
moduleThe MLIR module to check.
nameThe name of the function.
inputsThe input types of the function.
resultsThe result types of the function.
rewriterThe pattern rewriter to use for creating the function.
locThe location to use for the function.
Returns
The function operation.

◆ getKernelNeighborhoodSize()

Result< std::pair< mlir::Value, mlir::Value > > picceler::getKernelNeighborhoodSize ( mlir::OpBuilder & builder,
mlir::Location loc,
mlir::Value kernelOperand )

◆ operator<<()

std::ostream & picceler::operator<< ( std::ostream & os,
const Token & token )

Outputs a token to the given output stream.

Parameters
osThe output stream.
tokenThe token to output.
Returns
The output stream.