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

Namespaces

namespace  utils

Classes

class  AssignmentNode
 AST node for assignment statements. More...
class  ASTNode
 Abstract Syntax Tree (AST) node base class. More...
class  BinaryOpNode
 AST node for binary operations (arithmetic and relational). More...
struct  BrightnessToAffine
class  CallNode
 AST node for function calls. More...
struct  ChainedBrightnessPattern
struct  ChainedInvertPattern
struct  ChainRotatePattern
class  CLIOptions
 Struct to hold command-line options for the compiler. More...
struct  CombineNestedCrops
 Canonicalization pattern for the CropOp that combines nested crop operations into a single crop operation. only applicable when both crop operations have constant integer coordinates and dimensions. 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
class  FunctionNode
 AST node for function definitions. More...
struct  IdentityConvolutionPattern
class  IfNode
 AST node for if conditional statements. More...
class  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...
class  KernelData
class  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  Location
 Struct to hold location information. More...
class  MLIRGen
 MLIR code generator that converts AST nodes to MLIR constructs. This offers the initial IR generation from the AST. More...
class  ModuleNode
 AST node for the entire module. More...
struct  NeighbourhoodOpsToAffine
class  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
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  PrintToCalls
struct  ReadNumberToCall
struct  ReadStringToCall
struct  RemoveInvertPattern
struct  RotateToAffine
struct  SameOperandPattern
 Canonicalization pattern for the BlendOp that replaces blend(img, img, weight) with img if both input images are the same. More...
struct  SaveImageToCall
 Pattern to lower SaveImageOp to a function call. More...
struct  ShowImageToCall
 Pattern to lower ShowImageOp to a function call. More...
struct  StringConstConverter
class  StringNode
 AST node for string literals. More...
struct  Token
 Represents a token produced by the lexer. More...
class  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.

Enumerations

enum class  Channel : uint8_t {
  R = 0 , G = 1 , B = 2 , A = 3 ,
  Count = 4
}
enum class  BinaryOperatorType : uint8_t {
  Add , Sub , Mul , Div ,
  Equal , NotEqual , LessThan , LessEqual ,
  GreaterThan , GreaterEqual
}

Functions

template<typename T>
auto getRawPointers (const std::vector< std::unique_ptr< T > > &vec)
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.
BinaryOperatorType getBinaryOpType (const std::string &opStr)
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)
Result< KernelDatacalculateSharpenKernel (SharpenOp op, SharpenOpAdaptor adaptor)
Result< KernelDatacalculateBoxBlurKernel (BoxBlurOp op, BoxBlurOpAdaptor adaptor)
Result< KernelDatacalculateGaussianKernel (GaussianBlurOp op, GaussianBlurOpAdaptor adaptor)
Result< KernelDatacalculateEdgeDetectKernel (EdgeDetectOp op, EdgeDetectOpAdaptor adaptor)
Result< 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.

Enumeration Type Documentation

◆ BinaryOperatorType

enum class picceler::BinaryOperatorType : uint8_t
strong
Enumerator
Add 
Sub 
Mul 
Div 
Equal 
NotEqual 
LessThan 
LessEqual 
GreaterThan 
GreaterEqual 

◆ Channel

enum class picceler::Channel : uint8_t
strong
Enumerator
Count 

Function Documentation

◆ calculateBoxBlurKernel()

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

◆ calculateEdgeDetectKernel()

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

◆ calculateEmbossKernel()

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

◆ calculateGaussianKernel()

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

◆ calculateSharpenKernel()

Result< 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.

◆ getBinaryOpType()

BinaryOperatorType picceler::getBinaryOpType ( const std::string & opStr)
inline

◆ getKernelNeighborhoodSize()

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

◆ getRawPointers()

template<typename T>
auto picceler::getRawPointers ( const std::vector< std::unique_ptr< T > > & vec)

◆ 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.