|
clang 24.0.0git
|
CIR-specific implementation of mlir::abi::ABIRewriteContext. More...
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 |
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.
|
inline |
Definition at line 45 of file CIRABIRewriteContext.h.
References cir::registerCIRAliasAnalyses().
|
inline |
Definition at line 50 of file CIRABIRewriteContext.h.
| 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.
|
inlineoverride |
Definition at line 112 of file CIRABIRewriteContext.h.
| 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().
|
override |
Definition at line 1696 of file CIRABIRewriteContext.cpp.
References cir::getIndirectCalleeType(), and cir::RecordType::isStruct().
| 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.
|
override |
Definition at line 1528 of file CIRABIRewriteContext.cpp.
|
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().