MLIR 24.0.0git
mlir::abi::ABIRewriteContext Class Referenceabstract

ABIRewriteContext is the abstract interface that each dialect implements to perform ABI-specific rewrites on its operations. More...

#include "mlir/ABI/ABIRewriteContext.h"

Public Member Functions

virtual ~ABIRewriteContext ()=default
virtual LogicalResult rewriteFunctionDefinition (FunctionOpInterface funcOp, const FunctionClassification &fc, OpBuilder &builder)=0
 Rewrite a function definition to use ABI-lowered types.
virtual LogicalResult rewriteCallSite (Operation *callOp, const FunctionClassification &fc, OpBuilder &builder)=0
 Rewrite a call operation to match the callee's ABI-lowered signature.
virtual LogicalResult rewriteVAArg (Operation *vaArgOp, const ArgClassification &ac, OpBuilder &builder)
 Rewrite a single "fetch the next vararg" operation (e.g.
virtual StringRef getDialectNamespace () const =0
 Return the dialect namespace this context handles (e.g. "cir").

Detailed Description

ABIRewriteContext is the abstract interface that each dialect implements to perform ABI-specific rewrites on its operations.

The pass orchestrator calls these methods after ABI classification to rewrite function definitions and call sites.

Definition at line 184 of file ABIRewriteContext.h.

Constructor & Destructor Documentation

◆ ~ABIRewriteContext()

virtual mlir::abi::ABIRewriteContext::~ABIRewriteContext ( )
virtualdefault

Member Function Documentation

◆ getDialectNamespace()

virtual StringRef mlir::abi::ABIRewriteContext::getDialectNamespace ( ) const
pure virtual

Return the dialect namespace this context handles (e.g. "cir").

◆ rewriteCallSite()

virtual LogicalResult mlir::abi::ABIRewriteContext::rewriteCallSite ( Operation * callOp,
const FunctionClassification & fc,
OpBuilder & builder )
pure virtual

Rewrite a call operation to match the callee's ABI-lowered signature.

This coerces arguments, handles indirect returns (sret), and adapts the call result back to the original high-level type.

Parameters
callOpThe call operation to rewrite.
fcThe ABI classification for the callee.
builderThe OpBuilder to use for modifications.
Returns
success() if the call was rewritten.

◆ rewriteFunctionDefinition()

virtual LogicalResult mlir::abi::ABIRewriteContext::rewriteFunctionDefinition ( FunctionOpInterface funcOp,
const FunctionClassification & fc,
OpBuilder & builder )
pure virtual

Rewrite a function definition to use ABI-lowered types.

This creates a new function with the lowered signature, rewrites the function body to adapt between the ABI types and the original high-level types, and replaces the original function.

Parameters
funcOpThe function to rewrite (via FunctionOpInterface).
fcThe ABI classification for this function.
builderThe OpBuilder to use for modifications.
Returns
success() if the function was rewritten.

◆ rewriteVAArg()

virtual LogicalResult mlir::abi::ABIRewriteContext::rewriteVAArg ( Operation * vaArgOp,
const ArgClassification & ac,
OpBuilder & builder )
inlinevirtual

Rewrite a single "fetch the next vararg" operation (e.g.

C va_arg) to match how ac says the fetched type is passed at the ABI level.

ac classifies only the one type being fetched, in isolation, with the whole register budget available. A vararg fetch advances a runtime cursor (the platform va_list) through registers and then memory, so whether a given fetch lands in a register depends on how much of the budget earlier variadic arguments already consumed at run time, not on the fetch's static position.

An implementation may erase vaArgOp and replace its result, so a caller walking the IR must collect the fetches before rewriting any of them.

The default implementation reports failure, so a dialect that has not implemented vararg fetches does not need to override this. An overrider that fails is responsible for emitting its own diagnostic.

Parameters
vaArgOpThe fetch to rewrite. May be erased.
acThe ABI classification of the fetched type.
builderThe OpBuilder to use for modifications.
Returns
success() if the operation was rewritten.

Definition at line 239 of file ABIRewriteContext.h.


The documentation for this class was generated from the following file: