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.
void normalizeParameterSlotAlignments (cir::FuncOp funcOp, const mlir::abi::FunctionClassification &fc)
 Restate each non-byval indirect parameter's CIRGen slot alignment as the alignment the ABI promises for that parameter.
void finalizeParameterSlots ()
 Replace each non-byval indirect parameter's CIRGen 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 41 of file CIRABIRewriteContext.h.

Constructor & Destructor Documentation

◆ CIRABIRewriteContext()

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

Definition at line 43 of file CIRABIRewriteContext.h.

◆ ~CIRABIRewriteContext()

cir::CIRABIRewriteContext::~CIRABIRewriteContext ( )
inline

Definition at line 46 of file CIRABIRewriteContext.h.

Member Function Documentation

◆ finalizeParameterSlots()

void CIRABIRewriteContext::finalizeParameterSlots ( )

Replace each non-byval indirect parameter's CIRGen 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 recognise it. Not an override, since deferring this has no counterpart in the generic contract.

Definition at line 1098 of file CIRABIRewriteContext.cpp.

◆ getDialectNamespace()

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

Definition at line 95 of file CIRABIRewriteContext.h.

◆ normalizeParameterSlotAlignments()

void CIRABIRewriteContext::normalizeParameterSlotAlignments ( cir::FuncOp funcOp,
const mlir::abi::FunctionClassification & fc )

Restate each non-byval indirect parameter's CIRGen slot alignment as the alignment the ABI promises for that parameter.

CIRGen picked the slot's alignment for a local copy of the record, but the slot is about to stand in for the parameter, and a call forwarding it may only promise what the incoming pointer does. Call for every function before any call site is rewritten, since a call is rewritten with its callee rather than with its enclosing function and so may be reached first. Not an override, since this has no counterpart in the generic contract.

Definition at line 1075 of file CIRABIRewriteContext.cpp.

◆ rewriteCallSite()

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

Definition at line 1282 of file CIRABIRewriteContext.cpp.

References cir::RecordType::isStruct().

◆ 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 1498 of file CIRABIRewriteContext.cpp.

◆ rewriteFunctionDefinition()

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

Definition at line 1106 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 1787 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: