clang 24.0.0git
cir::CIRABIRewriteContext Class Reference

CIR-specific implementation of mlir::abi::ABIRewriteContext. More...

#include "/work/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRABIRewriteContext.h"

Inheritance diagram for cir::CIRABIRewriteContext:
[legend]

Public Member Functions

 CIRABIRewriteContext (mlir::ModuleOp module, const mlir::DataLayout &dl)
 ~CIRABIRewriteContext ()
mlir::LogicalResult rewriteFunctionDefinition (mlir::FunctionOpInterface funcOp, const mlir::abi::FunctionClassification &fc, mlir::OpBuilder &builder) override
mlir::LogicalResult rewriteCallSite (mlir::Operation *callOp, const mlir::abi::FunctionClassification &fc, mlir::OpBuilder &builder) override
mlir::LogicalResult rewriteVAArg (mlir::Operation *vaArgOp, const mlir::abi::ArgClassification &ac, mlir::OpBuilder &builder) override
 Expand a cir.va_arg into the x86-64 SysV register-save-area / overflow-area sequence.
void rewriteFunctionAddress (cir::GetGlobalOp addrOp, cir::FuncOp funcOp, mlir::OpBuilder &builder)
 Retype addrOp, which holds the address of funcOp, to the signature funcOp was rewritten to, and cast it back so existing uses keep the type they were built for.
mlir::LogicalResult prepareNonByvalParameters (cir::FuncOp funcOp, const mlir::abi::FunctionClassification &fc)
 Bring each non-byval indirect parameter of funcOp into the shape the rest of the rewrite assumes: the parameter's only use, if it has one, is a single store into an alloca of the matching pointer type that no other non-byval indirect parameter spills to, and that alloca states the alignment the ABI promises rather than the one CIRGen picked for a local copy.
void finalizeParameterSlots ()
 Replace each non-byval indirect parameter's spill slot with the incoming pointer, so the body operates on the caller's storage in place.
mlir::StringRef getDialectNamespace () const override

Detailed Description

CIR-specific implementation of mlir::abi::ABIRewriteContext.

The driver pass (CallConvLoweringPass) computes a FunctionClassification for each cir.func / cir.call and dispatches to this class to perform the actual IR rewriting using cir dialect operations.

Holds a reference to the module's DataLayout for coercion alignment queries. The DataLayout must outlive the rewrite context.

Definition at line 43 of file CIRABIRewriteContext.h.

Constructor & Destructor Documentation

◆ CIRABIRewriteContext()

cir::CIRABIRewriteContext::CIRABIRewriteContext ( mlir::ModuleOp module,
const mlir::DataLayout & dl )
inline

Definition at line 45 of file CIRABIRewriteContext.h.

References cir::registerCIRAliasAnalyses().

◆ ~CIRABIRewriteContext()

cir::CIRABIRewriteContext::~CIRABIRewriteContext ( )
inline

Definition at line 50 of file CIRABIRewriteContext.h.

Member Function Documentation

◆ finalizeParameterSlots()

void CIRABIRewriteContext::finalizeParameterSlots ( )

Replace each non-byval indirect parameter's spill slot with the incoming pointer, so the body operates on the caller's storage in place.

Call once, after every function and call site has been rewritten: a call forwarding such a parameter reads the slot to recognize it. Not an override, since deferring this has no counterpart in the generic contract.

Definition at line 1520 of file CIRABIRewriteContext.cpp.

◆ getDialectNamespace()

mlir::StringRef cir::CIRABIRewriteContext::getDialectNamespace ( ) const
inlineoverride

Definition at line 112 of file CIRABIRewriteContext.h.

◆ prepareNonByvalParameters()

mlir::LogicalResult CIRABIRewriteContext::prepareNonByvalParameters ( cir::FuncOp funcOp,
const mlir::abi::FunctionClassification & fc )

Bring each non-byval indirect parameter of funcOp into the shape the rest of the rewrite assumes: the parameter's only use, if it has one, is a single store into an alloca of the matching pointer type that no other non-byval indirect parameter spills to, and that alloca states the alignment the ABI promises rather than the one CIRGen picked for a local copy.

A use of the parameter as a call argument is routed through a load of that slot, so that it names the storage an argument has to name.

Call for every function before any definition or call site is rewritten. findParamSpill asserts this shape while the enclosing definition is rewritten, and a call is rewritten with its callee rather than with its enclosing function and so may be reached first.

A parameter read with no spill to name is given one, since it becomes the incoming pointer directly. A parameter spilled twice, spilled to a slot another such parameter also spills to, consumed other than as a call argument, spilled where the incoming pointer cannot replace the storage, or read where the spill does not dominate it gets a diagnostic on the operation at fault and failure.

Not an override, since this has no counterpart in the generic contract.

Definition at line 1493 of file CIRABIRewriteContext.cpp.

References prepareOneNonByvalParameter().

◆ rewriteCallSite()

mlir::LogicalResult CIRABIRewriteContext::rewriteCallSite ( mlir::Operation * callOp,
const mlir::abi::FunctionClassification & fc,
mlir::OpBuilder & builder )
override

◆ rewriteFunctionAddress()

void CIRABIRewriteContext::rewriteFunctionAddress ( cir::GetGlobalOp addrOp,
cir::FuncOp funcOp,
mlir::OpBuilder & builder )

Retype addrOp, which holds the address of funcOp, to the signature funcOp was rewritten to, and cast it back so existing uses keep the type they were built for.

A no-op when the ABI left funcOp's type alone. Call after funcOp has been rewritten. Not an override, since taking a function's address has no counterpart in the generic contract.

Definition at line 1958 of file CIRABIRewriteContext.cpp.

◆ rewriteFunctionDefinition()

mlir::LogicalResult CIRABIRewriteContext::rewriteFunctionDefinition ( mlir::FunctionOpInterface funcOp,
const mlir::abi::FunctionClassification & fc,
mlir::OpBuilder & builder )
override

Definition at line 1528 of file CIRABIRewriteContext.cpp.

◆ rewriteVAArg()

mlir::LogicalResult CIRABIRewriteContext::rewriteVAArg ( mlir::Operation * vaArgOp,
const mlir::abi::ArgClassification & ac,
mlir::OpBuilder & builder )
override

Expand a cir.va_arg into the x86-64 SysV register-save-area / overflow-area sequence.

Definition at line 2246 of file CIRABIRewriteContext.cpp.

References cir::CIRBaseBuilderTy::createAlloca(), clang::CharUnits::fromQuantity(), cir::CIRBaseBuilderTy::getPointerTo(), and cir::CIRBaseBuilderTy::getUIntNTy().


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