Projects
Eulaceura:Factory
pin-server
_service:obs_scm:0011-Pin-server-Add-NopOp-EHEl...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0011-Pin-server-Add-NopOp-EHElseOp-AsmOp-SwitchOp-LabelOp.patch of Package pin-server
From 190a1e5f5278f4966eb3bcdbdcee950560092216 Mon Sep 17 00:00:00 2001 From: huitailangzju <804544223@qq.com> Date: Wed, 22 Feb 2023 11:54:28 +0800 Subject: [PATCH 11/23] =?UTF-8?q?[Pin-server]=20Add=20NopOp=E3=80=81EHElse?= =?UTF-8?q?Op=E3=80=81AsmOp=E3=80=81SwitchOp=E3=80=81LabelOp=E3=80=81EHMnt?= =?UTF-8?q?Op=E3=80=81BindOp=E3=80=81TryOp=E3=80=81CatchOp=E3=80=81GotoOp?= =?UTF-8?q?=E3=80=81TransactionOp=E3=80=81ResxOp=E3=80=81EHDispatchOp.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit diff --git a/include/Dialect/PluginDialect.td b/include/Dialect/PluginDialect.td index 98a84d0..b618b59 100644 --- a/include/Dialect/PluginDialect.td +++ b/include/Dialect/PluginDialect.td @@ -68,7 +68,7 @@ def IComparisonAttr : I32EnumAttr< def IDefineCodeMemRef : I32EnumAttrCase<"MemRef", 0>; def IDefineCodeIntCST : I32EnumAttrCase<"IntCST", 1>; def IDefineCodeSSA : I32EnumAttrCase<"SSA", 2>; -def IDefineCodeTREELIST : I32EnumAttrCase<"TREELIST", 3>; +def IDefineCodeLIST : I32EnumAttrCase<"LIST", 3>; def IDefineCodeStrCST : I32EnumAttrCase<"StrCST", 4>; def IDefineCodeArrayRef : I32EnumAttrCase<"ArrayRef", 5>; def IDefineCodeDecl : I32EnumAttrCase<"Decl", 6>; @@ -81,7 +81,7 @@ def IDefineCodeCOMPONENT : I32EnumAttrCase<"COMPONENT", 12>; def IDefineCodeUNDEF : I32EnumAttrCase<"UNDEF", 13>; def IDefineCodeAttr : I32EnumAttr< "IDefineCode", "plugin define code", - [IDefineCodeMemRef, IDefineCodeIntCST, IDefineCodeSSA, IDefineCodeTREELIST, + [IDefineCodeMemRef, IDefineCodeIntCST, IDefineCodeSSA, IDefineCodeLIST, IDefineCodeStrCST, IDefineCodeArrayRef, IDefineCodeDecl, IDefineCodeFieldDecl, IDefineCodeAddrExp, IDefineCodeConstructor, IDefineCodeVec, IDefineCodeBLOCK, IDefineCodeCOMPONENT, IDefineCodeUNDEF]>{ let cppNamespace = "::mlir::Plugin"; diff --git a/include/Dialect/PluginOps.td b/include/Dialect/PluginOps.td index 4967e91..52c3ceb 100644 --- a/include/Dialect/PluginOps.td +++ b/include/Dialect/PluginOps.td @@ -166,6 +166,25 @@ def AssignOp : Plugin_Op<"assign", [NoSideEffect]> { }]; } +def NopOp : Plugin_Op<"nop", [NoSideEffect]> { + let summary = "nop"; + let description = [{TODO}]; + let arguments = (ins UI64Attr:$id); + let results = (outs AnyType); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id)>, + ]; +} + +def EHElseOp : Plugin_Op<"eh_else", [NoSideEffect]> { + let summary = "EHElseOP"; + let description = [{TODO}]; + let arguments = (ins UI64Attr:$id, ArrayAttr:$nBody, ArrayAttr:$eBody); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id, "ArrayRef<uint64_t>":$nBody, "ArrayRef<uint64_t>":$eBody)>, + ]; +} + class Placeholder<string mnemonic> : Plugin_Op<mnemonic, [SameVariadicOperandSize]> { dag commonArgs = (ins UI64Attr:$id, OptionalAttr<IDefineCodeAttr>:$defCode, @@ -300,7 +319,7 @@ def BlockOp : BLOCK<"block"> { }]; } -def VecOp : Vec<"treevector"> { +def VecOp : Vec<"vector"> { let summary = "VectorOp"; let description = [{TODO}]; let builders = [ @@ -425,8 +444,8 @@ def ConstOp : Constant<"constant value"> { }]; } -def ListOp : List<"tree list"> { - let summary = "tree list"; +def ListOp : List<"list"> { + let summary = "ListOp"; let description = [{TODO}]; let builders = [ OpBuilderDAG<(ins "uint64_t":$id, "IDefineCode":$defCode, "bool":$readOnly, @@ -480,7 +499,113 @@ def DebugOp : Plugin_Op<"debug", [NoSideEffect]> { OpBuilderDAG<(ins "uint64_t":$id)> ]; } +def AsmOp : Plugin_Op<"asm", [NoSideEffect]> { + let summary = "asm Op"; + let description = [{TODO}]; + let arguments = (ins UI64Attr:$id, StrAttr:$statement, UI32Attr:$nInputs, UI32Attr:$nOutputs, UI32Attr:$nClobbers, + Variadic<AnyType>:$operands); + let results = (outs AnyType:$result); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id, "StringRef":$statement, "uint32_t":$nInputs, "uint32_t":$nOutputs, + "uint32_t":$nClobbers, "ArrayRef<Value>":$operands)> + ]; + + let extraClassDeclaration = [{ + unsigned GetNInputs() { return this->nInputsAttr().getInt(); }; + unsigned GetNoutputs() { return this->nOutputsAttr().getInt(); }; + unsigned GetNClobbers() { return this->nClobbersAttr().getInt(); }; + Value GetInputOp(unsigned index) { return getOperand(index); }; + Value GetOutputOp(unsigned index) { return getOperand(this->nInputsAttr().getInt() + index); }; + Value GetCkobberOp(unsigned index) { + return getOperand(this->nInputsAttr().getInt() + this->nOutputsAttr().getInt() + index); }; + }]; +} + +def SwitchOp : Plugin_Op<"switch", [NoSideEffect]> { + let summary = "switch op."; + let description = [{TODO}]; + let successors = (successor + AnySuccessor:$defaultDestination, + VariadicSuccessor<AnySuccessor>:$caseDestinations + ); + let arguments = (ins UI64Attr:$id, AnyType:$index, UI64Attr:$address, AnyType:$defaultLabel, Variadic<AnyType>:$operands, + UI64Attr:$defaultaddr, ArrayAttr:$caseaddrs); + let results = (outs AnyType:$result); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id, "Value":$index, "uint64_t":$address, "Value":$defaultLabel, + "ArrayRef<Value>":$operands, "Block*":$defaultDestination, "uint64_t":$defaultaddr, + "ArrayRef<Block*>":$caseDestinations, "ArrayRef<uint64_t>":$caseaddrs)> + ]; + + let extraClassDeclaration = [{ + unsigned GetNumLabels() { return getNumOperands() - 2; }; + Block* GetDefautDest() { return defaultDestination();} + SmallVector<mlir::Block*> GetCaseDest() { return caseDestinations(); }; + }]; +} + +def LabelOp : Plugin_Op<"label", [NoSideEffect]> { + let summary = "Label op."; + let description = [{TODO}]; + let results = (outs AnyType:$result); + let arguments = (ins UI64Attr:$id, AnyType:$index); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id, "Value":$index)> + ]; + let extraClassDeclaration = [{ + Value GetLabelLabel() { return this->getOperation()->getOperand(0); }; + }]; +} + +def EHMntOp : Plugin_Op<"eh_mnt", [NoSideEffect]> { + let summary = "EH_MUST_NOT_THROW op."; + let description = [{TODO}]; + let results = (outs AnyType:$result); + let arguments = (ins UI64Attr:$id, AnyType:$decl); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id, "Value":$decl)> + ]; + let extraClassDeclaration = [{ + Value Getfndecl() { return decl(); }; + }]; +} + +def BindOp : Plugin_Op<"Bind", [NoSideEffect]> { + let summary = "BindOp"; + let description = [{TODO}]; + let results = (outs AnyType:$result); + let arguments = (ins UI64Attr:$id, AnyType:$vars, ArrayAttr:$body, AnyType:$block); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id, "Value":$vars, "ArrayRef<uint64_t>":$body, "Value":$block)> + ]; + let extraClassDeclaration = [{ + Value GetVars() { return vars(); }; + Value GetBlock() { return block(); }; + }]; +} +def TryOp : Plugin_Op<"try", [NoSideEffect]> { + let summary = "TryOp"; + let description = [{TODO}]; + let results = (outs AnyType:$result); + let arguments = (ins UI64Attr:$id, ArrayAttr:$eval, ArrayAttr:$cleanup, UI64Attr:$kind); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id, "ArrayRef<uint64_t>":$eval, "ArrayRef<uint64_t>":$cleanup, "uint64_t":$kind)> + ]; +} + +def CatchOp : Plugin_Op<"catch", [NoSideEffect]> { + let summary = "CatchOp"; + let description = [{TODO}]; + let results = (outs AnyType:$result); + let arguments = (ins UI64Attr:$id, AnyType:$types, ArrayAttr:$handler); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id, "Value":$types, "ArrayRef<uint64_t>":$handler)> + ]; + let extraClassDeclaration = [{ + Value GetTypes() { return types(); }; + }]; +} // Terminators // Opaque builder used for terminator operations that contain successors. @@ -538,4 +663,66 @@ def RetOp : Plugin_TerminatorOp<"ret", [NoSideEffect]> { ]; } +def GotoOp : Plugin_TerminatorOp<"goto", [NoSideEffect]> { + let summary = "GotoOp"; + let description = [{TODO}]; + let arguments = (ins UI64Attr:$id, UI64Attr:$address, AnyType:$dest, UI64Attr:$successaddr); + let results = (outs AnyType); + let successors = (successor AnySuccessor:$success); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id, "uint64_t":$address, "Value":$dest, "Block*":$success, "uint64_t":$successaddr)> + ]; + + let extraClassDeclaration = [{ + Value GetLabel() { return this->getOperation()->getOperand(0); } + }]; +} + +def TransactionOp : Plugin_TerminatorOp<"transaction", [NoSideEffect]> { + let summary = "TransactionOp"; + let description = [{TODO}]; + let arguments = (ins UI64Attr:$id, UI64Attr:$address, ArrayAttr:$stmtaddr, AnyType:$labelNorm, + AnyType:$labelUninst, AnyType:$labelOver, UI64Attr:$fallthroughaddr, UI64Attr:$abortaddr); + let results = (outs AnyType); + let successors = (successor AnySuccessor:$fallthrough, AnySuccessor:$abort); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id, "uint64_t":$address, "ArrayRef<uint64_t>":$stmtaddr, "Value":$labelNorm, + "Value":$labelUninst, "Value":$labelOver, "Block*":$fallthrough, "uint64_t":$fallthroughaddr, + "Block*":$abort, "uint64_t":$abortaddr)> + ]; + + let extraClassDeclaration = [{ + Value GetTransactionNormal() { return labelNorm(); } + Value GetTransactionUinst() { return labelUninst(); } + Value GetTransactionOver() { return labelOver(); } + }]; +} + +def ResxOp : Plugin_TerminatorOp<"resx", [NoSideEffect]> { + let summary = "ResxOp"; + let description = [{TODO}]; + let arguments = (ins UI64Attr:$id, UI64Attr:$address, UI64Attr:$region); + let results = (outs AnyType); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id, "uint64_t":$address, "uint64_t":$region)> + ]; + let extraClassDeclaration = [{ + uint64_t GetTransactionNormal() { return region(); } + }]; +} + +def EHDispatchOp : Plugin_TerminatorOp<"dispatch", [NoSideEffect]> { + let summary = "EHDispatchOp"; + let description = [{TODO}]; + let arguments = (ins UI64Attr:$id, UI64Attr:$address, UI64Attr:$region, ArrayAttr:$ehHandlersaddrs); + let results = (outs AnyType); + let successors = (successor VariadicSuccessor<AnySuccessor>:$ehHandlers); + let builders = [ + OpBuilderDAG<(ins "uint64_t":$id, "uint64_t":$address, "uint64_t":$region, "ArrayRef<Block*>":$ehHandlers, + "ArrayRef<uint64_t>":$ehHandlersaddrs)> + ]; + let extraClassDeclaration = [{ + uint64_t GetTransactionNormal() { return region(); } + }]; +} #endif // PLUGIN_OPS_TD \ No newline at end of file diff --git a/include/PluginServer/PluginJson.h b/include/PluginServer/PluginJson.h index 4be2ae2..db264f6 100755 --- a/include/PluginServer/PluginJson.h +++ b/include/PluginServer/PluginJson.h @@ -50,6 +50,19 @@ public: void GetPhiOpsJsonDeSerialize(const string&, vector<mlir::Operation *>&); mlir::Value SSAOpJsonDeSerialize(const string& data); mlir::Plugin::LoopOp LoopOpJsonDeSerialize(const string& data); + mlir::Operation *GotoOpJsonDeSerialize(const string& data); + mlir::Operation *TransactionOpJsonDeSerialize(const string& data); + mlir::Operation *LabelOpJsonDeSerialize(const string& data); + mlir::Operation *NopOpJsonDeSerialize(const string& data); + mlir::Operation *EHElseOpJsonDeSerialize(const string& data); + mlir::Operation *AsmOpJsonDeserialize(const string& data); + mlir::Operation *SwitchOpJsonDeserialize(const string &data); + mlir::Operation *ResxOpJsonDeSerialize(const string& data); + mlir::Operation *EHDispatchOpJsonDeSerialize(const string& data); + mlir::Operation *EHMntOpJsonDeSerialize(const string& data); + mlir::Operation *BindOpJsonDeSerialize(const string& data); + mlir::Operation *TryOpJsonDeSerialize(const string& data); + mlir::Operation *CatchOpJsonDeSerialize(const string& data); mlir::Value ListOpDeSerialize(const string& data); mlir::Value StrOpJsonDeSerialize(const string& data); mlir::Value ArrayOpJsonDeSerialize(const string& data); diff --git a/lib/Dialect/PluginOps.cpp b/lib/Dialect/PluginOps.cpp index c8714f6..bb2debe 100644 --- a/lib/Dialect/PluginOps.cpp +++ b/lib/Dialect/PluginOps.cpp @@ -78,6 +78,10 @@ static uint64_t getBlockAddress(mlir::Block* b) return oops.addressAttr().getInt(); } else if (mlir::Plugin::RetOp oops = dyn_cast<mlir::Plugin::RetOp>(b->back())) { return oops.addressAttr().getInt(); + } else if (mlir::Plugin::GotoOp oops = dyn_cast<mlir::Plugin::GotoOp>(b->back())) { + return oops.addressAttr().getInt(); + } else if (mlir::Plugin::TransactionOp oops = dyn_cast<mlir::Plugin::TransactionOp>(b->back())) { + return oops.addressAttr().getInt(); } else { assert(false); } @@ -743,7 +747,31 @@ void AssignOp::build(OpBuilder &builder, OperationState &state, state.addOperands(operands); } -// ===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// +// NopOp +void NopOp::build(OpBuilder &builder, OperationState &state, uint64_t id) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); +} + +//===----------------------------------------------------------------------===// +// EHElseOp +void EHElseOp::build(OpBuilder &builder, OperationState &state, uint64_t id, ArrayRef<uint64_t> nBody, + ArrayRef<uint64_t> eBody) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); + llvm::SmallVector<mlir::Attribute, 4> nbodyattrs, ebodyattrs; + for (auto item : nBody) { + nbodyattrs.push_back(builder.getI64IntegerAttr(item)); + } + for (auto item : eBody) { + ebodyattrs.push_back(builder.getI64IntegerAttr(item)); + } + state.addAttribute("nBody", builder.getArrayAttr(nbodyattrs)); + state.addAttribute("eBody", builder.getArrayAttr(ebodyattrs)); +} + +//===----------------------------------------------------------------------===// // BaseOp void BaseOp::build(OpBuilder &builder, OperationState &state, @@ -763,6 +791,39 @@ void DebugOp::build(OpBuilder &builder, OperationState &state, } // ===----------------------------------------------------------------------===// +// AsmOp +void AsmOp::build(OpBuilder &builder, OperationState &state, + uint64_t id, StringRef statement, uint32_t nInputs, uint32_t nOutputs, + uint32_t nClobbers, ArrayRef<Value> operands) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); + state.addAttribute("statement", builder.getSymbolRefAttr(statement)); + state.addAttribute("nInputs", builder.getI32IntegerAttr(nInputs)); + state.addAttribute("nOutputs", builder.getI32IntegerAttr(nOutputs)); + state.addAttribute("nClobbers", builder.getI32IntegerAttr(nClobbers)); + state.addOperands(operands); +} + +//===----------------------------------------------------------------------===// +// SwitchOp +void SwitchOp::build(OpBuilder &builder, OperationState &state, + uint64_t id, Value index, uint64_t address, Value defaultLabel, ArrayRef<Value> operands, + Block* defaultDest, uint64_t defaultaddr, ArrayRef<Block*> caseDest, ArrayRef<uint64_t> caseaddr) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); + state.addAttribute("address", builder.getI64IntegerAttr(address)); + state.addAttribute("defaultaddr", builder.getI64IntegerAttr(defaultaddr)); + llvm::SmallVector<mlir::Attribute, 4> attributes; + for (int i = 0; i < caseaddr.size(); ++i) { + attributes.push_back(builder.getI64IntegerAttr(caseaddr[i])); + } + state.addAttribute("caseaddrs", builder.getArrayAttr(attributes)); + state.addOperands(index); + state.addOperands(defaultLabel); + state.addOperands(operands); + state.addSuccessors(defaultDest); + state.addSuccessors(caseDest); +} // FallThroughOp void FallThroughOp::build(OpBuilder &builder, OperationState &state, @@ -794,7 +855,130 @@ void RetOp::build(OpBuilder &builder, OperationState &state, uint64_t address) state.addAttribute("address", builder.getI64IntegerAttr(address)); } -// ===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// +// GotoOp + +void GotoOp::build(OpBuilder &builder, OperationState &state, uint64_t id, uint64_t address, +Value dest, Block* success, uint64_t successaddr) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); + state.addAttribute("address", builder.getI64IntegerAttr(address)); + state.addAttribute("successaddr", builder.getI64IntegerAttr(successaddr)); + state.addOperands(dest); + state.addSuccessors(success); +} + +//===----------------------------------------------------------------------===// +// LabelOp +void LabelOp::build(OpBuilder &builder, OperationState &state, uint64_t id, Value label) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); + state.addOperands(label); +} + +//==-----------------------------------------------------------------------===// +// TransactionOp +void TransactionOp::build(OpBuilder &builder, OperationState &state, uint64_t id, uint64_t address, + ArrayRef<uint64_t> stmtaddr, Value labelNorm, Value labelUninst, Value labelOver, Block* fallthrough, + uint64_t fallthroughaddr, Block* abort, uint64_t abortaddr) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); + state.addAttribute("address", builder.getI64IntegerAttr(address)); + llvm::SmallVector<mlir::Attribute, 4> attributes; + for (int i = 0; i < stmtaddr.size(); ++i) { + attributes.push_back(builder.getI64IntegerAttr(stmtaddr[i])); + } + state.addAttribute("stmtaddr", builder.getArrayAttr(attributes)); + state.addOperands({labelNorm, labelUninst, labelOver}); + state.addSuccessors(fallthrough); + state.addAttribute("fallthroughaddr", builder.getI64IntegerAttr(fallthroughaddr)); + state.addSuccessors(abort); + state.addAttribute("abortaddr", builder.getI64IntegerAttr(abortaddr)); +} + +//===----------------------------------------------------------------------===// +// ResxOp + +void ResxOp::build(OpBuilder &builder, OperationState &state, uint64_t id, uint64_t address, uint64_t region) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); + state.addAttribute("address", builder.getI64IntegerAttr(address)); + state.addAttribute("region", builder.getI64IntegerAttr(region)); +} + +//===----------------------------------------------------------------------===// +// EHMntOp +void EHMntOp::build(OpBuilder &builder, OperationState &state, uint64_t id, Value decl) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); + state.addOperands(decl); +} + +//===----------------------------------------------------------------------===// +// EHDispatchOp + +void EHDispatchOp::build(OpBuilder &builder, OperationState &state, uint64_t id, uint64_t address, uint64_t region, + ArrayRef<Block*> ehHandlers, ArrayRef<uint64_t> ehHandlersaddrs) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); + state.addAttribute("address", builder.getI64IntegerAttr(address)); + state.addAttribute("region", builder.getI64IntegerAttr(region)); + state.addSuccessors(ehHandlers); + llvm::SmallVector<mlir::Attribute, 4> attributes; + for (int i = 0; i < ehHandlersaddrs.size(); ++i) { + attributes.push_back(builder.getI64IntegerAttr(ehHandlersaddrs[i])); + } + state.addAttribute("ehHandlersaddrs", builder.getArrayAttr(attributes)); +} +//===----------------------------------------------------------------------===// +// BindOp + +void BindOp::build(OpBuilder &builder, OperationState &state, uint64_t id, Value vars, ArrayRef<uint64_t> body, + Value block) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); + state.addOperands({vars, block}); + llvm::SmallVector<mlir::Attribute, 4> attributes; + for (int i = 0; i < body.size(); ++i) { + attributes.push_back(builder.getI64IntegerAttr(body[i])); + } + state.addAttribute("body", builder.getArrayAttr(attributes)); +} + +//===----------------------------------------------------------------------===// +// TryOp + +void TryOp::build(OpBuilder &builder, OperationState &state, uint64_t id, ArrayRef<uint64_t> eval, + ArrayRef<uint64_t> cleanup, uint64_t kind) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); + llvm::SmallVector<mlir::Attribute, 4> attributes; + for (int i = 0; i < eval.size(); ++i) { + attributes.push_back(builder.getI64IntegerAttr(eval[i])); + } + state.addAttribute("eval", builder.getArrayAttr(attributes)); + attributes.clear(); + for (int i = 0; i < cleanup.size(); ++i) { + attributes.push_back(builder.getI64IntegerAttr(cleanup[i])); + } + state.addAttribute("cleanup", builder.getArrayAttr(attributes)); + state.addAttribute("kind", builder.getI64IntegerAttr(kind)); +} + +//===----------------------------------------------------------------------===// +// CatchOp + +void CatchOp::build(OpBuilder &builder, OperationState &state, uint64_t id, Value types, ArrayRef<uint64_t> handler) +{ + state.addAttribute("id", builder.getI64IntegerAttr(id)); + state.addOperands(types); + llvm::SmallVector<mlir::Attribute, 4> attributes; + for (int i = 0; i < handler.size(); ++i) { + attributes.push_back(builder.getI64IntegerAttr(handler[i])); + } + state.addAttribute("handler", builder.getArrayAttr(attributes)); +} +//===----------------------------------------------------------------------===// // TableGen'd op method definitions // ===----------------------------------------------------------------------===// diff --git a/lib/PluginAPI/ControlFlowAPI.cpp b/lib/PluginAPI/ControlFlowAPI.cpp index b2ed38d..720bac5 100644 --- a/lib/PluginAPI/ControlFlowAPI.cpp +++ b/lib/PluginAPI/ControlFlowAPI.cpp @@ -63,8 +63,13 @@ static uint64_t getBlockAddress(mlir::Block* b) return oops.addressAttr().getInt(); } else if (mlir::Plugin::RetOp oops = llvm::dyn_cast<mlir::Plugin::RetOp>(b->back())) { return oops.addressAttr().getInt(); + } else if (mlir::Plugin::GotoOp oops = llvm::dyn_cast<mlir::Plugin::GotoOp>(b->back())) { + return oops.addressAttr().getInt(); + } else if (mlir::Plugin::TransactionOp oops = llvm::dyn_cast<mlir::Plugin::TransactionOp>(b->back())) { + return oops.addressAttr().getInt(); + } else { + abort(); } - abort(); } bool ControlFlowAPI::UpdateSSA(void) diff --git a/lib/PluginServer/PluginJson.cpp b/lib/PluginServer/PluginJson.cpp index c5e302f..b849cf9 100755 --- a/lib/PluginServer/PluginJson.cpp +++ b/lib/PluginServer/PluginJson.cpp @@ -242,6 +242,33 @@ bool PluginJson::ProcessBlock(mlir::Block* block, mlir::Region& rg, const Json:: } else if (opCode == BaseOp::getOperationName().str()) { uint64_t opID = GetID(opJson["id"]); opBuilder->create<BaseOp>(opBuilder->getUnknownLoc(), opID, opCode); + } else if (opCode == AsmOp::getOperationName().str()) { + AsmOpJsonDeserialize(opJson.toStyledString()); + } else if (opCode == SwitchOp::getOperationName().str()) { + printf("switch op deserialize\n"); + SwitchOpJsonDeserialize(opJson.toStyledString()); + } else if (opCode == GotoOp::getOperationName().str()) { + GotoOpJsonDeSerialize(opJson.toStyledString()); + } else if (opCode == LabelOp::getOperationName().str()) { + LabelOpJsonDeSerialize(opJson.toStyledString()); + } else if (opCode == TransactionOp::getOperationName().str()) { + TransactionOpJsonDeSerialize(opJson.toStyledString()); + } else if (opCode == ResxOp::getOperationName().str()) { + ResxOpJsonDeSerialize(opJson.toStyledString()); + } else if (opCode == EHDispatchOp::getOperationName().str()) { + EHDispatchOpJsonDeSerialize(opJson.toStyledString()); + } else if (opCode == EHMntOp::getOperationName().str()) { + EHMntOpJsonDeSerialize(opJson.toStyledString()); + } else if (opCode == BindOp::getOperationName().str()) { + BindOpJsonDeSerialize(opJson.toStyledString()); + } else if (opCode == TryOp::getOperationName().str()) { + TryOpJsonDeSerialize(opJson.toStyledString()); + } else if (opCode == CatchOp::getOperationName().str()) { + CatchOpJsonDeSerialize(opJson.toStyledString()); + } else if (opCode == NopOp::getOperationName().str()) { + NopOpJsonDeSerialize(opJson.toStyledString()); + } else if (opCode == EHElseOp::getOperationName().str()) { + EHElseOpJsonDeSerialize(opJson.toStyledString()); } } return true; @@ -650,7 +677,7 @@ mlir::Value PluginJson::ListOpDeSerialize(const string& data) mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); mlir::Value trrelist = opBuilder->create<ListOp>(opBuilder->getUnknownLoc(), id, - IDefineCode::TREELIST, readOnly, hasPurpose, ops, retType); + IDefineCode::LIST, readOnly, hasPurpose, ops, retType); return trrelist; } @@ -840,6 +867,298 @@ mlir::Value PluginJson::ComponentOpJsonDeSerialize(const string& data) opBuilder->getUnknownLoc(), id, IDefineCode::COMPONENT, readOnly, component, field, retType); return componentOp; } + +mlir::Operation *PluginJson::GotoOpJsonDeSerialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + int64_t id = GetID(node["id"]); + int64_t address = GetID(node["address"]); + mlir::Value dest = ValueJsonDeSerialize(node["dest"]); + int64_t successaddr = GetID(node["successaddr"]); + mlir::Block* success = PluginServer::GetInstance()->FindBlock(successaddr); + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + GotoOp op = opBuilder->create<GotoOp>(opBuilder->getUnknownLoc(), id, address, dest, success, successaddr); + return op.getOperation(); +} + +mlir::Operation *PluginJson::TransactionOpJsonDeSerialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + int64_t id = GetID(node["id"]); + int64_t address = GetID(node["address"]); + mlir::Value labelNorm = ValueJsonDeSerialize(node["labelNorm"]); + mlir::Value labelUninst = ValueJsonDeSerialize(node["labelUninst"]); + mlir::Value labelOver = ValueJsonDeSerialize(node["labelOver"]); + int64_t fallthroughaddr = GetID(node["fallthroughaddr"]); + int64_t abortaddr = GetID(node["abortaddr"]); + mlir::Block* fallthrough = PluginServer::GetInstance()->FindBlock(fallthroughaddr); + mlir::Block* abort = PluginServer::GetInstance()->FindBlock(abortaddr); + llvm::SmallVector<uint64_t, 4> stmtaddr; + Json::Value stmtaddrJson = node["stmtaddr"]; + for (size_t index = 0; index < stmtaddrJson.getMemberNames().size(); index++) { + string key = std::to_string(index); + uint64_t addr = GetID(stmtaddrJson[key.c_str()]); + stmtaddr.push_back(addr); + } + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + TransactionOp op = opBuilder->create<TransactionOp>(opBuilder->getUnknownLoc(), id, address, stmtaddr, labelNorm, + labelUninst, labelOver, fallthrough, fallthroughaddr, abort, abortaddr); + return op.getOperation(); +} + +mlir::Operation *PluginJson::ResxOpJsonDeSerialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + int64_t id = GetID(node["id"]); + int64_t address = GetID(node["address"]); + int64_t region = GetID(node["region"]); + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + ResxOp op = opBuilder->create<ResxOp>(opBuilder->getUnknownLoc(), + id, address, region); + return op.getOperation(); +} + +mlir::Operation *PluginJson::EHMntOpJsonDeSerialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + int64_t id = GetID(node["id"]); + mlir::Value decl = ValueJsonDeSerialize(node["decl"]); + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + EHMntOp op = opBuilder->create<EHMntOp>(opBuilder->getUnknownLoc(), id, decl); + return op.getOperation(); +} + + +mlir::Operation *PluginJson::EHDispatchOpJsonDeSerialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + int64_t id = GetID(node["id"]); + int64_t address = GetID(node["address"]); + int64_t region = GetID(node["region"]); + llvm::SmallVector<mlir::Block*, 4> ehHandlers; + llvm::SmallVector<uint64_t, 4> ehHandlersaddrs; + Json::Value ehHandlersJson = node["ehHandlersaddrs"]; + Json::Value::Members ehHandlersMember = ehHandlersJson.getMemberNames(); + for (size_t iter = 0; iter < ehHandlersMember.size(); iter++) { + string key = std::to_string(iter); + uint64_t ehaddr = GetID(ehHandlersJson[key.c_str()]); + mlir::Block* succ = PluginServer::GetInstance()->FindBlock(ehaddr); + ehHandlers.push_back(succ); + ehHandlersaddrs.push_back(ehaddr); + } + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + EHDispatchOp op = opBuilder->create<EHDispatchOp>(opBuilder->getUnknownLoc(), + id, address, region, ehHandlers, ehHandlersaddrs); + return op.getOperation(); +} + +mlir::Operation *PluginJson::LabelOpJsonDeSerialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + int64_t id = GetID(node["id"]); + mlir::Value label = ValueJsonDeSerialize(node["label"]); + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + LabelOp op = opBuilder->create<LabelOp>(opBuilder->getUnknownLoc(), id, label); + return op.getOperation(); +} + +mlir::Operation *PluginJson::BindOpJsonDeSerialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + int64_t id = GetID(node["id"]); + mlir::Value vars = ValueJsonDeSerialize(node["vars"]); + mlir::Value block = ValueJsonDeSerialize(node["block"]); + + Json::Value bodyJson = node["body"]; + Json::Value::Members bodyMember = bodyJson.getMemberNames(); + llvm::SmallVector<uint64_t, 4> bodyaddrs; + for (size_t iter = 0; iter < bodyMember.size(); iter++) { + string key = std::to_string(iter); + uint64_t addr = GetID(bodyJson[key.c_str()]); + bodyaddrs.push_back(addr); + } + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + BindOp op = opBuilder->create<BindOp>(opBuilder->getUnknownLoc(), id, vars, bodyaddrs, block); + return op.getOperation(); +} + +mlir::Operation *PluginJson::TryOpJsonDeSerialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + int64_t id = GetID(node["id"]); + Json::Value evalJson = node["eval"]; + Json::Value::Members evalMember = evalJson.getMemberNames(); + llvm::SmallVector<uint64_t, 4> evaladdrs, cleanupaddrs; + for (size_t iter = 0; iter < evalMember.size(); iter++) { + string key = std::to_string(iter); + uint64_t addr = GetID(evalJson[key.c_str()]); + evaladdrs.push_back(addr); + } + Json::Value cleanupJson = node["cleanup"]; + Json::Value::Members cleanupMember = cleanupJson.getMemberNames(); + for (size_t iter = 0; iter < cleanupMember.size(); iter++) { + string key = std::to_string(iter); + uint64_t addr = GetID(cleanupJson[key.c_str()]); + cleanupaddrs.push_back(addr); + } + + int64_t kind = GetID(node["kind"]); + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + TryOp op = opBuilder->create<TryOp>(opBuilder->getUnknownLoc(), id, evaladdrs, cleanupaddrs, kind); + return op.getOperation(); +} + +mlir::Operation *PluginJson::CatchOpJsonDeSerialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + int64_t id = GetID(node["id"]); + mlir::Value types = ValueJsonDeSerialize(node["types"]); + + Json::Value handlerJson = node["handler"]; + Json::Value::Members handlerMember = handlerJson.getMemberNames(); + llvm::SmallVector<uint64_t, 4> handleraddrs; + for (size_t iter = 0; iter < handlerMember.size(); iter++) { + string key = std::to_string(iter); + uint64_t addr = GetID(handlerJson[key.c_str()]); + handleraddrs.push_back(addr); + } + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + CatchOp op = opBuilder->create<CatchOp>(opBuilder->getUnknownLoc(), id, types, handleraddrs); + return op.getOperation(); +} + +mlir::Operation *PluginJson::NopOpJsonDeSerialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + uint64_t id = GetID(node["id"]); + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + NopOp op = opBuilder->create<NopOp>(opBuilder->getUnknownLoc(), id); + PluginServer::GetInstance()->InsertDefOperation(id, op.getOperation()); + return op.getOperation(); +} + +mlir::Operation *PluginJson::EHElseOpJsonDeSerialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + uint64_t id = GetID(node["id"]); + + llvm::SmallVector<uint64_t, 4> nbody, ebody; + + Json::Value nbodyJson = node["nbody"]; + Json::Value::Members nbodyMember = nbodyJson.getMemberNames(); + + for (size_t iter = 0; iter < nbodyMember.size(); iter++) { + string key = std::to_string(iter); + uint64_t addr = GetID(nbodyJson[key.c_str()]); + nbody.push_back(addr); + } + + Json::Value ebodyJson = node["ebody"]; + Json::Value::Members ebodyMember = ebodyJson.getMemberNames(); + + for (size_t iter = 0; iter < ebodyMember.size(); iter++) { + string key = std::to_string(iter); + uint64_t addr = GetID(ebodyJson[key.c_str()]); + ebody.push_back(addr); + } + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + EHElseOp op = opBuilder->create<EHElseOp>(opBuilder->getUnknownLoc(), id, nbody, ebody); + PluginServer::GetInstance()->InsertDefOperation(id, op.getOperation()); + return op.getOperation(); +} + +mlir::Operation *PluginJson::AsmOpJsonDeserialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + Json::Value operandJson = node["operands"]; + Json::Value::Members operandMember = operandJson.getMemberNames(); + llvm::SmallVector<mlir::Value, 4> ops; + for (size_t opIter = 0; opIter < operandMember.size(); opIter++) { + string key = std::to_string(opIter); + mlir::Value opValue = ValueJsonDeSerialize(operandJson[key.c_str()]); + ops.push_back(opValue); + } + uint64_t id = GetID(node["id"]); + mlir::StringRef statement(node["statement"].asString()); + uint32_t nInputs = GetID(node["nInputs"]); + uint32_t nOutputs = GetID(node["nOutputs"]); + uint32_t nClobbers = GetID(node["nClobbers"]); + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + AsmOp op = opBuilder->create<AsmOp>(opBuilder->getUnknownLoc(), id, statement, nInputs, nOutputs, + nClobbers, ops); + PluginServer::GetInstance()->InsertDefOperation(id, op.getOperation()); + return op.getOperation(); +} + +mlir::Operation *PluginJson::SwitchOpJsonDeserialize(const string& data) +{ + Json::Value node; + Json::Reader reader; + reader.parse(data, node); + uint64_t id = GetID(node["id"]); + uint64_t address = GetID(node["address"]); + uint64_t defaultDestAddr = GetID(node["defaultaddr"]); + mlir::Block* defaultDest = PluginServer::GetInstance()->FindBlock(defaultDestAddr); + + + Json::Value operandJson = node["operands"]; + Json::Value::Members operandMember = operandJson.getMemberNames(); + llvm::SmallVector<mlir::Value, 4> ops; + mlir::Value index, defaultLabel; + for (size_t opIter = 0; opIter < operandMember.size(); opIter++) { + string key = std::to_string(opIter); + mlir::Value opValue = ValueJsonDeSerialize(operandJson[key.c_str()]); + if (opIter == 0) { + index = opValue; + continue; + } else if (opIter == 1) { + defaultLabel = opValue; + continue; + } + ops.push_back(opValue); + } + + Json::Value caseaddrJson = node["case"]; + llvm::SmallVector<uint64_t, 4> caseaddr; + llvm::SmallVector<mlir::Block*, 4> caseDest; + for (size_t index = 0; index < caseaddrJson.getMemberNames().size(); index++) { + string key = std::to_string(index); + uint64_t addr = GetID(caseaddrJson[key.c_str()]); + mlir::Block* casebb = PluginServer::GetInstance()->FindBlock(addr); + caseaddr.push_back(addr); + caseDest.push_back(casebb); + } + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + SwitchOp op = opBuilder->create<SwitchOp>(opBuilder->getUnknownLoc(), id, index, address, defaultLabel, ops, defaultDest, + defaultDestAddr, caseDest, caseaddr); + PluginServer::GetInstance()->InsertDefOperation(id, op.getOperation()); + return op.getOperation(); +} + void PluginJson::OpJsonDeSerialize( const string& data, vector<mlir::Operation *>& opData) { @@ -868,6 +1187,32 @@ void PluginJson::OpJsonDeSerialize( uint64_t opID = GetID(opJson["id"]); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); opBuilder->create<BaseOp>(opBuilder->getUnknownLoc(), opID, opCode); + } else if (opCode == AsmOp::getOperationName().str()) { + opData.push_back(AsmOpJsonDeserialize(opJson.toStyledString())); + } else if (opCode == SwitchOp::getOperationName().str()) { + opData.push_back(SwitchOpJsonDeserialize(opJson.toStyledString())); + } else if (opCode == GotoOp::getOperationName().str()) { + opData.push_back(GotoOpJsonDeSerialize(opJson.toStyledString())); + } else if (opCode == LabelOp::getOperationName().str()) { + opData.push_back(LabelOpJsonDeSerialize(opJson.toStyledString())); + } else if (opCode == TransactionOp::getOperationName().str()) { + opData.push_back(TransactionOpJsonDeSerialize(opJson.toStyledString())); + } else if (opCode == ResxOp::getOperationName().str()) { + opData.push_back(ResxOpJsonDeSerialize(opJson.toStyledString())); + } else if (opCode == EHDispatchOp::getOperationName().str()) { + opData.push_back(EHDispatchOpJsonDeSerialize(opJson.toStyledString())); + } else if (opCode == EHMntOp::getOperationName().str()) { + opData.push_back(EHMntOpJsonDeSerialize(opJson.toStyledString())); + } else if (opCode == BindOp::getOperationName().str()) { + opData.push_back(BindOpJsonDeSerialize(opJson.toStyledString())); + } else if (opCode == TryOp::getOperationName().str()) { + opData.push_back(TryOpJsonDeSerialize(opJson.toStyledString())); + } else if (opCode == CatchOp::getOperationName().str()) { + opData.push_back(CatchOpJsonDeSerialize(opJson.toStyledString())); + } else if (opCode == NopOp::getOperationName().str()) { + opData.push_back(NopOpJsonDeSerialize(opJson.toStyledString())); + } else if (opCode == EHElseOp::getOperationName().str()) { + opData.push_back(EHElseOpJsonDeSerialize(opJson.toStyledString())); } } } // namespace PinJson \ No newline at end of file -- 2.33.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2