13#include "mlir/IR/AsmState.h"
14#include "mlir/IR/SymbolTable.h"
15#include "mlir/Interfaces/FunctionInterfaces.h"
22#define GEN_PASS_DEF_PRINTBASEOBJECTPASS
23#include "Passes/Passes.h.inc"
28struct PrintBaseObjectPass
29 :
public enzyme::impl::PrintBaseObjectPassBase<PrintBaseObjectPass> {
30 using PrintBaseObjectPassBase::PrintBaseObjectPassBase;
32 void runOnOperation()
override {
33 getOperation()->walk([&](FunctionOpInterface function) {
34 AsmState state(function);
35 function.walk([&](Operation *op) {
36 if (!op->hasTrait<OpTrait::ReturnLike>() ||
37 op->getParentOp() != function.getOperation())
39 for (
auto [index, value] : llvm::enumerate(op->getOperands())) {
40 auto &os = llvm::outs();
41 os <<
'@' << SymbolTable::getSymbolName(function).getValue()
42 <<
" return " << index <<
": ";
43 value.printAsOperand(os, state);
46 .printAsOperand(os, state);
Value getBaseObject(Value v, bool offsetAllowed)