From b14803116c8488a4c765799fd31966991f2031d7 Mon Sep 17 00:00:00 2001 From: benniaobufeijiushiji Date: Sun, 19 Feb 2023 11:43:57 +0800 Subject: [PATCH 04/23] [Pin-server] Add DebugOp diff --git a/include/Dialect/PluginOps.td b/include/Dialect/PluginOps.td index 2af4a33..f4062ad 100644 --- a/include/Dialect/PluginOps.td +++ b/include/Dialect/PluginOps.td @@ -82,8 +82,8 @@ def LoopOp : Plugin_Op<"loop", [NoSideEffect]> { let extraClassDeclaration = [{ mlir::Block* GetHeader(); mlir::Block* GetLatch(); - void SetHeader(mlir::Block*); - void SetLatch(mlir::Block*); + void SetHeader(mlir::Block*); + void SetLatch(mlir::Block*); std::pair GetSingleExit(); void Delete(); LoopOp GetInnerLoop(); @@ -247,7 +247,7 @@ def SSAOp : SSA<"SSA"> { Value Copy(); Value GetCurrentDef(); bool SetCurrentDef(Value def); - Operation* GetSSADefOperation(); + Operation* GetSSADefOperation(); }]; } @@ -274,6 +274,16 @@ def BaseOp : Plugin_Op<"statement_base", [NoSideEffect]> { ]; } +def DebugOp : Plugin_Op<"debug", [NoSideEffect]> { + let summary = "DebugOp."; + let description = [{TODO}]; + let arguments = (ins UI64Attr:$id); + let results = (outs AnyType); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id)> + ]; +} + // Terminators // Opaque builder used for terminator operations that contain successors. diff --git a/lib/Dialect/PluginOps.cpp b/lib/Dialect/PluginOps.cpp index a0591b5..a49ce16 100644 --- a/lib/Dialect/PluginOps.cpp +++ b/lib/Dialect/PluginOps.cpp @@ -549,6 +549,15 @@ void BaseOp::build(OpBuilder &builder, OperationState &state, state.addAttribute("opCode", builder.getStringAttr(opCode)); } +//===----------------------------------------------------------------------===// +// DebugOp + +void DebugOp::build(OpBuilder &builder, OperationState &state, + uint64_t id) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); +} + // ===----------------------------------------------------------------------===// // FallThroughOp diff --git a/lib/PluginServer/PluginJson.cpp b/lib/PluginServer/PluginJson.cpp index c399aad..d89945c 100755 --- a/lib/PluginServer/PluginJson.cpp +++ b/lib/PluginServer/PluginJson.cpp @@ -196,6 +196,9 @@ bool PluginJson::ProcessBlock(mlir::Block* block, mlir::Region& rg, const Json:: RetOpJsonDeSerialize(opJson.toStyledString()); } else if (opCode == FallThroughOp::getOperationName().str()) { FallThroughOpJsonDeSerialize(opJson.toStyledString()); + } else if (opCode == DebugOp::getOperationName().str()) { + uint64_t opID = GetID(opJson["id"]); + opBuilder->create(opBuilder->getUnknownLoc(), opID); } else if (opCode == BaseOp::getOperationName().str()) { uint64_t opID = GetID(opJson["id"]); opBuilder->create(opBuilder->getUnknownLoc(), opID, opCode); @@ -603,6 +606,10 @@ void PluginJson::OpJsonDeSerialize( opData.push_back(RetOpJsonDeSerialize(opJson.toStyledString())); } else if (opCode == FallThroughOp::getOperationName().str()) { opData.push_back(FallThroughOpJsonDeSerialize(opJson.toStyledString())); + } else if (opCode == DebugOp::getOperationName().str()) { + uint64_t opID = GetID(opJson["id"]); + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + opBuilder->create(opBuilder->getUnknownLoc(), opID); } else if (opCode == BaseOp::getOperationName().str()) { uint64_t opID = GetID(opJson["id"]); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); diff --git a/user.cpp b/user.cpp index a6fe555..8163cec 100644 --- a/user.cpp +++ b/user.cpp @@ -318,7 +318,7 @@ struct originLoopInfo { Value *limitptr; Value arr1; /* Array 1 in the old loop. */ Value *arr1ptr; - Value arr2; /* Array 2 in the old loop. */ + Value arr2; /* Array 2 in the old loop. */ Value *arr2ptr; edge entryEdge; /* The edge into the old loop. */ edgePtr entryEdgePtr; @@ -646,7 +646,7 @@ static bool getIvBase(CondOp cond) original loop; When prolog_assign is present, make sure loop header is in simple form; And the interpretation of prolog_assign is as follows: eg: while (++len != limit) - ...... + ...... For such a loop, ++len will be processed before entering header_bb, and the assign is regarded as the prolog_assign of the loop. */ static bool recordOriginLoopHeader(LoopOp loop) @@ -665,6 +665,9 @@ static bool recordOriginLoopHeader(LoopOp loop) continue; } + if (auto debugOp = dyn_cast(op)) + continue; + if (auto cond = dyn_cast(op)) { if (!getIvUpperBound(cond)) { return false; -- 2.33.0