diff --git a/0010-Pin-server-Add-ComponentOp-ConstructorOp-AddressOp-F.patch b/0010-Pin-server-Add-ComponentOp-ConstructorOp-AddressOp-F.patch new file mode 100644 index 0000000..c86cf4a --- /dev/null +++ b/0010-Pin-server-Add-ComponentOp-ConstructorOp-AddressOp-F.patch @@ -0,0 +1,850 @@ +From b460122fefb5d4f889c807b704f252948d488893 Mon Sep 17 00:00:00 2001 +From: huitailangzju <804544223@qq.com> +Date: Wed, 22 Feb 2023 11:42:02 +0800 +Subject: [PATCH 1/5] =?UTF-8?q?[Pin-server]=20Add=20ComponentOp=E3=80=81Co?= + =?UTF-8?q?nstructorOp=E3=80=81AddressOp=E3=80=81FieldDeclOp=E3=80=81VecOp?= + =?UTF-8?q?=E3=80=81BlockOp=E3=80=81DeclBaseOp=E3=80=81ListOp=E3=80=81StrO?= + =?UTF-8?q?p=E3=80=81ArrayOp.?= +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 d7db477..98a84d0 100644 +--- a/include/Dialect/PluginDialect.td ++++ b/include/Dialect/PluginDialect.td +@@ -68,10 +68,22 @@ def IComparisonAttr : I32EnumAttr< + def IDefineCodeMemRef : I32EnumAttrCase<"MemRef", 0>; + def IDefineCodeIntCST : I32EnumAttrCase<"IntCST", 1>; + def IDefineCodeSSA : I32EnumAttrCase<"SSA", 2>; +-def IDefineCodeUNDEF : I32EnumAttrCase<"UNDEF", 3>; ++def IDefineCodeTREELIST : I32EnumAttrCase<"TREELIST", 3>; ++def IDefineCodeStrCST : I32EnumAttrCase<"StrCST", 4>; ++def IDefineCodeArrayRef : I32EnumAttrCase<"ArrayRef", 5>; ++def IDefineCodeDecl : I32EnumAttrCase<"Decl", 6>; ++def IDefineCodeFieldDecl : I32EnumAttrCase<"FieldDecl", 7>; ++def IDefineCodeAddrExp : I32EnumAttrCase<"AddrExp", 8>; ++def IDefineCodeConstructor : I32EnumAttrCase<"Constructor", 9>; ++def IDefineCodeVec : I32EnumAttrCase<"Vec", 10>; ++def IDefineCodeBLOCK : I32EnumAttrCase<"BLOCK", 11>; ++def IDefineCodeCOMPONENT : I32EnumAttrCase<"COMPONENT", 12>; ++def IDefineCodeUNDEF : I32EnumAttrCase<"UNDEF", 13>; + def IDefineCodeAttr : I32EnumAttr< + "IDefineCode", "plugin define code", +- [IDefineCodeMemRef, IDefineCodeIntCST, IDefineCodeSSA, IDefineCodeUNDEF]>{ ++ [IDefineCodeMemRef, IDefineCodeIntCST, IDefineCodeSSA, IDefineCodeTREELIST, ++ 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 3a88846..4967e91 100644 +--- a/include/Dialect/PluginOps.td ++++ b/include/Dialect/PluginOps.td +@@ -166,7 +166,7 @@ def AssignOp : Plugin_Op<"assign", [NoSideEffect]> { + }]; + } + +-class Placeholder : Plugin_Op { ++class Placeholder : Plugin_Op { + dag commonArgs = (ins UI64Attr:$id, + OptionalAttr:$defCode, + OptionalAttr:$readOnly); +@@ -201,6 +201,61 @@ class Constant : Placeholder { + let arguments = !con(commonArgs, ConstArgs); + } + ++class List : Placeholder { ++ dag ListArgs = (ins BoolAttr:$hasPurpose, ++ Variadic:$operands); ++ let arguments = !con(commonArgs, ListArgs); ++} ++ ++class ComponentRef : Placeholder { ++ dag ComponentRefArgs = (ins AnyType:$component, ++ AnyType:$field); ++ let arguments = !con(commonArgs, ComponentRefArgs); ++} ++ ++class StringCST : Placeholder { ++ dag StringArgs = (ins StrAttr:$str); ++ let arguments = !con(commonArgs, StringArgs); ++} ++ ++class ArrayRef : Placeholder { ++ dag ArrayRefArgs = (ins AnyType:$base, ++ AnyType:$offset); ++ let arguments = !con(commonArgs, ArrayRefArgs); ++} ++ ++class DeclBase : Placeholder { ++ dag DeclBaseArgs = (ins BoolAttr:$addressable, BoolAttr:$used, I32Attr:$uid, ++ AnyType:$initial, AnyType:$name, OptionalAttr:$chain); ++ let arguments = !con(commonArgs, DeclBaseArgs); ++} ++ ++class FieldDecl : DeclBase { ++ dag FieldDeclArgs = (ins AnyType:$fieldOffset, AnyType:$fieldBitOffset); ++ let arguments = !con(commonArgs, DeclBaseArgs, FieldDeclArgs); ++} ++ ++class Address : Placeholder { ++ dag AddressArgs = (ins AnyType:$operand); ++ let arguments = !con(commonArgs, AddressArgs); ++} ++ ++class Constructor : Placeholder { ++ dag ConstructorArgs = (ins I32Attr:$len, Variadic:$idx, Variadic:$val); ++ let arguments = !con(commonArgs, ConstructorArgs); ++} ++ ++class Vec : Placeholder { ++ dag VecArgs = (ins I32Attr:$len, Variadic:$elements); ++ let arguments = !con(commonArgs, VecArgs); ++} ++ ++class BLOCK : Placeholder { ++ dag BLOCKArgs = (ins I32Attr:$len, Optional:$vars, OptionalAttr:$supercontext, ++ Optional:$subblocks, Optional:$chain, Optional:$abstract_origin); ++ let arguments = !con(commonArgs, BLOCKArgs); ++} ++ + def PlaceholderOp : Placeholder<"palceholder"> { + let summary = "PlaceHolder"; + let description = [{TODO}]; +@@ -210,6 +265,110 @@ def PlaceholderOp : Placeholder<"palceholder"> { + ]; + } + ++def DeclBaseOp : DeclBase<"decl"> { ++ let summary = "DeclBaseOp"; ++ let description = [{TODO}]; ++ let builders = [ ++ OpBuilderDAG<(ins "uint64_t":$id, "IDefineCode":$defCode, ++ "bool":$readOnly, "bool":$addressable, "bool":$used, "int":$uid, "Value":$initial, ++ "Value":$name, "Optional":$chain, "Type":$retType)> ++ ]; ++ let extraClassDeclaration = [{ ++ Type getResultType() { return this->getOperation()->getResult(0).getType(); } ++ Value GetInitial() { return initial(); } ++ Value GetName() { return name(); } ++ Optional GetChain() { return chain(); } ++ }]; ++} ++ ++def BlockOp : BLOCK<"block"> { ++ let summary = "BlockOp"; ++ let description = [{TODO}]; ++ let builders = [ ++ OpBuilderDAG<(ins "uint64_t":$id, "IDefineCode":$defCode, ++ "bool":$readOnly, "Optional":$vars, "Optional":$supercontext, ++ "Optional":$subblocks, "Optional":$chain, ++ "Optional":$abstract_origin, "Type":$retType)> ++ ]; ++ let extraClassDeclaration = [{ ++ Type getResultType() { return this->getOperation()->getResult(0).getType(); } ++ Value GetVars() { return vars(); } ++ Optional GetSupercontext() { return supercontext(); } ++ Value GetSubblocks() { return subblocks(); } ++ Value GetChain() { return chain(); } ++ Value GetAbstractorigin() { return abstract_origin(); } ++ }]; ++} ++ ++def VecOp : Vec<"treevector"> { ++ let summary = "VectorOp"; ++ let description = [{TODO}]; ++ let builders = [ ++ OpBuilderDAG<(ins "uint64_t":$id, "IDefineCode":$defCode, ++ "bool":$readOnly, "int":$len, "ArrayRef":$elements, "Type":$retType)> ++ ]; ++} ++ ++def FieldDeclOp : FieldDecl<"field"> { ++ let summary = "FieldDeclOp"; ++ let description = [{TODO}]; ++ ++ let builders = [ ++ OpBuilderDAG<(ins "uint64_t":$id, "IDefineCode":$defCode, ++ "bool":$readOnly, "bool":$addressable, "bool":$used, "int":$uid, "Value":$initial, ++ "Value":$name, "uint64_t":$chain, "Value":$fieldOffset, "Value":$fieldBitOffset, "Type":$retType)> ++]; ++ let extraClassDeclaration = [{ ++ Type getResultType() { return this->getOperation()->getResult(0).getType(); } ++ Value GetInitial() { return initial(); } ++ Value GetName() { return name(); } ++ Optional GetChain() { return chain(); } ++ Value GetFieldOffset() { return fieldOffset(); } ++ Value GetFieldBitOffset() { return fieldBitOffset(); } ++ }]; ++} ++ ++def AddressOp : Address<"address"> { ++ let summary = "AddressOp"; ++ let description = [{TODO}]; ++ let builders = [ ++ OpBuilderDAG<(ins "uint64_t":$id, "IDefineCode":$defCode, ++ "bool":$readOnly, "Value":$operand, "Type":$retType)> ++]; ++ let extraClassDeclaration = [{ ++ Type getResultType() { return this->getOperation()->getResult(0).getType(); } ++ Value GetOperand() { return operand(); } ++ }]; ++} ++ ++def ConstructorOp : Constructor<"constructor"> { ++ let summary = "ConstructorOp"; ++ let description = [{TODO}]; ++ let builders = [ ++ OpBuilderDAG<(ins "uint64_t":$id, "IDefineCode":$defCode, ++ "bool":$readOnly, "int32_t":$len, "ArrayRef":$idx, "ArrayRef":$val, ++ "Type":$retType)> ++]; ++ let extraClassDeclaration = [{ ++ Type getResultType() { return this->getOperation()->getResult(0).getType(); } ++ }]; ++} ++ ++def ComponentOp : ComponentRef<"component"> { ++ let summary = "Component reference op"; ++ let description = [{TODO}]; ++ let builders = [ ++ OpBuilderDAG<(ins "uint64_t":$id, "IDefineCode":$defCode, "bool":$readOnly, ++ "Value":$component, "Value":$field, "Type":$retType)> ++ ]; ++ let results = (outs AnyType); ++ let extraClassDeclaration = [{ ++ Type getResultType() { return this->getOperation()->getResult(0).getType(); } ++ Value GetComponent() { return getOperand(0); } ++ Value GetField() { return getOperand(1); } ++ }]; ++} ++ + def PointerOp : Pointer<"pointer"> { + let summary = "pointer"; + let description = [{TODO}]; +@@ -266,6 +425,42 @@ def ConstOp : Constant<"constant value"> { + }]; + } + ++def ListOp : List<"tree list"> { ++ let summary = "tree list"; ++ let description = [{TODO}]; ++ let builders = [ ++ OpBuilderDAG<(ins "uint64_t":$id, "IDefineCode":$defCode, "bool":$readOnly, ++ "bool":$hasPurpose, "ArrayRef":$operands, "Type":$retType)> ++ ]; ++ let results = (outs AnyType); ++ let extraClassDeclaration = [{ ++ Type getResultType() { return this->getOperation()->getResult(0).getType(); } ++ }]; ++} ++ ++def StrOp : StringCST<"string"> { ++ let summary = "string"; ++ let description = [{TODO}]; ++ let builders = [ ++ OpBuilderDAG<(ins "uint64_t":$id, "IDefineCode":$defCode, "bool":$readOnly,"StringRef":$str, "Type":$retType)> ++ ]; ++} ++ ++def ArrayOp : ArrayRef<"array ref"> { ++ let summary = "array ref"; ++ let description = [{TODO}]; ++ let builders = [ ++ OpBuilderDAG<(ins "uint64_t":$id, "IDefineCode":$defCode, "bool":$readOnly, ++ "Value":$base, "Value":$offset, "Type":$retType)> ++ ]; ++ let results = (outs AnyType); ++ let extraClassDeclaration = [{ ++ Type getResultType() { return this->getOperation()->getResult(0).getType(); } ++ Value GetBase() { return getOperand(0); } ++ Value GetOffset() { return getOperand(1); } ++ }]; ++} ++ + def BaseOp : Plugin_Op<"statement_base", [NoSideEffect]> { + let summary = "Base operation, just like placeholder for statement."; + let description = [{TODO}]; +diff --git a/include/PluginServer/PluginJson.h b/include/PluginServer/PluginJson.h +index 6f46187..4be2ae2 100755 +--- a/include/PluginServer/PluginJson.h ++++ b/include/PluginServer/PluginJson.h +@@ -50,6 +50,16 @@ public: + void GetPhiOpsJsonDeSerialize(const string&, vector&); + mlir::Value SSAOpJsonDeSerialize(const string& data); + mlir::Plugin::LoopOp LoopOpJsonDeSerialize(const string& data); ++ mlir::Value ListOpDeSerialize(const string& data); ++ mlir::Value StrOpJsonDeSerialize(const string& data); ++ mlir::Value ArrayOpJsonDeSerialize(const string& data); ++ mlir::Value DeclBaseOpJsonDeSerialize(const string& data); ++ mlir::Value FieldDeclOpJsonDeSerialize(const string& data); ++ mlir::Value AddressOpJsonDeSerialize(const string& data); ++ mlir::Value ConstructorOpJsonDeSerialize(const string& data); ++ mlir::Value VecOpJsonDeSerialize(const string& data); ++ mlir::Value BlockOpJsonDeSerialize(const string& data); ++ mlir::Value ComponentOpJsonDeSerialize(const string& data); + PluginIR::PluginTypeBase TypeJsonDeSerialize(const string& data); + void OpJsonDeSerialize(const string&, vector&); + /* 将整形数据反序列化 */ +diff --git a/lib/Dialect/PluginOps.cpp b/lib/Dialect/PluginOps.cpp +index a30e9ed..c8714f6 100644 +--- a/lib/Dialect/PluginOps.cpp ++++ b/lib/Dialect/PluginOps.cpp +@@ -44,6 +44,26 @@ static uint64_t GetValueId(Value v) + return ssaOp.id(); + } else if (auto cstOp = dyn_cast(op)) { + return cstOp.id(); ++ } else if (auto treelistop = dyn_cast(op)) { ++ return treelistop.id(); ++ } else if (auto strop = dyn_cast(op)) { ++ return strop.id(); ++ } else if (auto arrayop = dyn_cast(op)) { ++ return arrayop.id(); ++ } else if (auto declop = dyn_cast(op)) { ++ return declop.id(); ++ } else if (auto fieldop = dyn_cast(op)) { ++ return fieldop.id(); ++ } else if (auto addressop = dyn_cast(op)) { ++ return addressop.id(); ++ } else if (auto constructorop = dyn_cast(op)) { ++ return constructorop.id(); ++ } else if (auto vecop = dyn_cast(op)) { ++ return vecop.id(); ++ } else if (auto blockop = dyn_cast(op)) { ++ return blockop.id(); ++ } else if (auto compOp = dyn_cast(op)) { ++ return compOp.id(); + } else if (auto phOp = dyn_cast(op)) { + return phOp.id(); + } +@@ -249,7 +269,143 @@ void MemOp::build(OpBuilder &builder, OperationState &state, + if (retType) state.addTypes(retType); + } + +-// ===----------------------------------------------------------------------===// ++//===----------------------------------------------------------------------===// ++// DeclBaseOp ++ ++void DeclBaseOp::build(OpBuilder &builder, OperationState &state, uint64_t id, ++ IDefineCode defCode, bool readOnly, bool addressable, bool used, int32_t uid, Value initial, ++ Value name, Optional chain, Type retType) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addAttribute("defCode", ++ builder.getI32IntegerAttr(static_cast(defCode))); ++ state.addAttribute("readOnly", builder.getBoolAttr(readOnly)); ++ state.addAttribute("addressable", builder.getBoolAttr(addressable)); ++ state.addAttribute("used", builder.getBoolAttr(used)); ++ state.addAttribute("uid", builder.getI32IntegerAttr(uid)); ++ state.addOperands(initial); ++ if(chain) { ++ state.addAttribute("chain", builder.getI64IntegerAttr(chain.getValue())); ++ } ++ state.addOperands(name); ++ state.addTypes(retType); ++} ++ ++//===----------------------------------------------------------------------===// ++// BlockOp ++ ++void BlockOp::build(OpBuilder &builder, OperationState &state, uint64_t id, ++ IDefineCode defCode, bool readOnly, Optional vars, Optional supercontext, ++ Optional subblocks, Optional abstract_origin, Optional chain, Type retType) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addAttribute("defCode", ++ builder.getI32IntegerAttr(static_cast(defCode))); ++ state.addAttribute("readOnly", builder.getBoolAttr(readOnly)); ++ if(vars) { ++ state.addOperands(vars.getValue()); ++ } ++ if(supercontext) { ++ state.addAttribute("supercontext", builder.getI64IntegerAttr(supercontext.getValue())); ++ } ++ if(subblocks) { ++ state.addOperands(subblocks.getValue()); ++ } ++ if(abstract_origin) { ++ state.addOperands(abstract_origin.getValue()); ++ } ++ if(chain) { ++ state.addOperands(chain.getValue()); ++ } ++ state.addTypes(retType); ++} ++ ++//===----------------------------------------------------------------------===// ++// ComponentOp ++ ++void ComponentOp::build(OpBuilder &builder, OperationState &state, ++ uint64_t id, IDefineCode defCode, bool readOnly, ++ Value component, Value field, Type retType) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addAttribute("readOnly", builder.getBoolAttr(readOnly)); ++ state.addAttribute("defCode", ++ builder.getI32IntegerAttr(static_cast(defCode))); ++ ++ state.addOperands({component, field}); ++ if (retType) state.addTypes(retType); ++} ++//===----------------------------------------------------------------------===// ++// VecOp ++ ++void VecOp::build(OpBuilder &builder, OperationState &state, uint64_t id, ++ IDefineCode defCode, bool readOnly, int32_t len, ArrayRef elements, Type retType) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addAttribute("defCode", ++ builder.getI32IntegerAttr(static_cast(defCode))); ++ state.addAttribute("readOnly", builder.getBoolAttr(readOnly)); ++ state.addAttribute("len", builder.getI32IntegerAttr(len)); ++ state.addOperands(elements); ++ state.addTypes(retType); ++} ++ ++//===----------------------------------------------------------------------===// ++// ConstructorOp ++ ++void ConstructorOp::build(OpBuilder &builder, OperationState &state, uint64_t id, ++ IDefineCode defCode, bool readOnly, int32_t len, ArrayRef idx, ++ ArrayRef val, Type retType) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addAttribute("defCode", ++ builder.getI32IntegerAttr(static_cast(defCode))); ++ state.addAttribute("readOnly", builder.getBoolAttr(readOnly)); ++ state.addAttribute("len", builder.getI32IntegerAttr(len)); ++ state.addOperands(idx); ++ state.addOperands(val); ++ ++ state.addTypes(retType); ++} ++ ++//===----------------------------------------------------------------------===// ++// FieldDeclOp ++ ++void FieldDeclOp::build(OpBuilder &builder, OperationState &state, uint64_t id, ++ IDefineCode defCode, bool readOnly, bool addressable, bool used, int32_t uid, Value initial, ++ Value name, uint64_t chain, Value fieldOffset, Value fieldBitOffset, Type retType) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addAttribute("defCode", ++ builder.getI32IntegerAttr(static_cast(defCode))); ++ state.addAttribute("readOnly", builder.getBoolAttr(readOnly)); ++ state.addAttribute("addressable", builder.getBoolAttr(addressable)); ++ state.addAttribute("used", builder.getBoolAttr(used)); ++ state.addAttribute("uid", builder.getI32IntegerAttr(uid)); ++ state.addOperands(initial); ++ if(chain) { ++ state.addAttribute("chain", builder.getI64IntegerAttr(chain)); ++ } ++ state.addOperands(name); ++ state.addOperands({fieldOffset, fieldBitOffset}); ++ state.addTypes(retType); ++} ++ ++//===----------------------------------------------------------------------===// ++// AddressOp ++ ++void AddressOp::build(OpBuilder &builder, OperationState &state, uint64_t id, ++ IDefineCode defCode, bool readOnly, Value operand, Type retType) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addAttribute("defCode", ++ builder.getI32IntegerAttr(static_cast(defCode))); ++ state.addAttribute("readOnly", builder.getBoolAttr(readOnly)); ++ state.addOperands(operand); ++ state.addTypes(retType); ++} ++ ++//===----------------------------------------------------------------------===// + // SSAOp + + void SSAOp::build(OpBuilder &builder, OperationState &state, uint64_t id, +@@ -345,8 +501,49 @@ void PointerOp::build(OpBuilder &builder, OperationState &state, uint64_t id, + state.addAttribute("pointeeReadOnly", builder.getBoolAttr(pointeeReadOnly)); + } + +-// ===----------------------------------------------------------------------===// +-// CallOp ++//===----------------------------------------------------------------------===// ++// ListOp ++ ++void ListOp::build(OpBuilder &builder, OperationState &state, uint64_t id, ++ IDefineCode defCode, bool readOnly, bool hasPurpose, ++ ArrayRef operands, Type retType) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addAttribute("defCode", ++ builder.getI32IntegerAttr(static_cast(defCode))); ++ state.addAttribute("readOnly", builder.getBoolAttr(readOnly)); ++ state.addAttribute("hasPurpose", builder.getBoolAttr(hasPurpose)); ++ state.addOperands(operands); ++ state.addTypes(retType); ++} ++ ++//===----------------------------------------------------------------------===// ++// StrOp ++void StrOp::build(OpBuilder &builder, OperationState &state, uint64_t id, ++ IDefineCode defCode, bool readOnly, StringRef str, Type retType) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addAttribute("defCode", ++ builder.getI32IntegerAttr(static_cast(defCode))); ++ state.addAttribute("str", builder.getStringAttr(str)); ++ state.addAttribute("readOnly", builder.getBoolAttr(readOnly)); ++ state.addTypes(retType); ++} ++ ++//===----------------------------------------------------------------------===// ++// ArrayOp ++ ++void ArrayOp::build(OpBuilder &builder, OperationState &state, ++ uint64_t id, IDefineCode defCode, bool readOnly, ++ Value addr, Value offset, Type retType) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addAttribute("readOnly", builder.getBoolAttr(readOnly)); ++ state.addOperands({addr, offset}); ++ state.addAttribute("defCode", ++ builder.getI32IntegerAttr(static_cast(defCode))); ++ if (retType) state.addTypes(retType); ++} + + void CallOp::build(OpBuilder &builder, OperationState &state, + int64_t id, StringRef callee, +diff --git a/lib/PluginAPI/ControlFlowAPI.cpp b/lib/PluginAPI/ControlFlowAPI.cpp +index 92c0dd3..b2ed38d 100644 +--- a/lib/PluginAPI/ControlFlowAPI.cpp ++++ b/lib/PluginAPI/ControlFlowAPI.cpp +@@ -29,6 +29,26 @@ static uint64_t GetValueId(mlir::Value v) + return ssaOp.id(); + } else if (auto cstOp = llvm::dyn_cast(op)) { + return cstOp.id(); ++ } else if (auto treelistop = llvm::dyn_cast(op)) { ++ return treelistop.id(); ++ } else if (auto strop = llvm::dyn_cast(op)) { ++ return strop.id(); ++ } else if (auto arrayop = llvm::dyn_cast(op)) { ++ return arrayop.id(); ++ } else if (auto declop = llvm::dyn_cast(op)) { ++ return declop.id(); ++ } else if (auto fieldop = llvm::dyn_cast(op)) { ++ return fieldop.id(); ++ } else if (auto addressop = llvm::dyn_cast(op)) { ++ return addressop.id(); ++ } else if (auto constructorop = llvm::dyn_cast(op)) { ++ return constructorop.id(); ++ } else if (auto vecop = llvm::dyn_cast(op)) { ++ return vecop.id(); ++ } else if (auto blockop = llvm::dyn_cast(op)) { ++ return blockop.id(); ++ } else if (auto compop = llvm::dyn_cast(op)) { ++ return compop.id(); + } else if (auto phOp = llvm::dyn_cast(op)) { + return phOp.id(); + } +diff --git a/lib/PluginAPI/PluginServerAPI.cpp b/lib/PluginAPI/PluginServerAPI.cpp +index f81a3ad..01a799b 100644 +--- a/lib/PluginAPI/PluginServerAPI.cpp ++++ b/lib/PluginAPI/PluginServerAPI.cpp +@@ -50,6 +50,26 @@ static uint64_t GetValueId(mlir::Value v) + return ssaOp.id(); + } else if (auto cstOp = llvm::dyn_cast(op)) { + return cstOp.id(); ++ } else if (auto treelistop = llvm::dyn_cast(op)) { ++ return treelistop.id(); ++ } else if (auto strop = llvm::dyn_cast(op)) { ++ return strop.id(); ++ } else if (auto arrayop = llvm::dyn_cast(op)) { ++ return arrayop.id(); ++ } else if (auto declop = llvm::dyn_cast(op)) { ++ return declop.id(); ++ } else if (auto fieldop = llvm::dyn_cast(op)) { ++ return fieldop.id(); ++ } else if (auto addressop = llvm::dyn_cast(op)) { ++ return addressop.id(); ++ } else if (auto constructorop = llvm::dyn_cast(op)) { ++ return constructorop.id(); ++ } else if (auto vecop = llvm::dyn_cast(op)) { ++ return vecop.id(); ++ } else if (auto blockop = llvm::dyn_cast(op)) { ++ return blockop.id(); ++ } else if (auto compop = llvm::dyn_cast(op)) { ++ return compop.id(); + } else if (auto phOp = llvm::dyn_cast(op)) { + return phOp.id(); + } +diff --git a/lib/PluginServer/PluginJson.cpp b/lib/PluginServer/PluginJson.cpp +index 7bbf681..c5e302f 100755 +--- a/lib/PluginServer/PluginJson.cpp ++++ b/lib/PluginServer/PluginJson.cpp +@@ -109,6 +109,46 @@ mlir::Value PluginJson::ValueJsonDeSerialize(Json::Value valueJson) + opValue = SSAOpJsonDeSerialize(valueJson.toStyledString()); + break; + } ++ case IDefineCode::TREELIST : { ++ opValue = ListOpDeSerialize(valueJson.toStyledString()); ++ break; ++ } ++ case IDefineCode::StrCST : { ++ opValue = StrOpJsonDeSerialize(valueJson.toStyledString()); ++ break; ++ } ++ case IDefineCode::ArrayRef : { ++ opValue = ArrayOpJsonDeSerialize(valueJson.toStyledString()); ++ break; ++ } ++ case IDefineCode::Decl : { ++ opValue = DeclBaseOpJsonDeSerialize(valueJson.toStyledString()); ++ break; ++ } ++ case IDefineCode::FieldDecl : { ++ opValue = FieldDeclOpJsonDeSerialize(valueJson.toStyledString()); ++ break; ++ } ++ case IDefineCode::AddrExp : { ++ opValue = AddressOpJsonDeSerialize(valueJson.toStyledString()); ++ break; ++ } ++ case IDefineCode::Constructor : { ++ opValue = ConstructorOpJsonDeSerialize(valueJson.toStyledString()); ++ break; ++ } ++ case IDefineCode::Vec : { ++ opValue = VecOpJsonDeSerialize(valueJson.toStyledString()); ++ break; ++ } ++ case IDefineCode::BLOCK : { ++ opValue = BlockOpJsonDeSerialize(valueJson.toStyledString()); ++ break; ++ } ++ case IDefineCode::COMPONENT : { ++ opValue = ComponentOpJsonDeSerialize(valueJson.toStyledString()); ++ break; ++ } + default: { + opValue = opBuilder->create( + opBuilder->getUnknownLoc(), opId, defCode, readOnly, retType); +@@ -592,6 +632,214 @@ void PluginJson::GetPhiOpsJsonDeSerialize( + } + } + ++mlir::Value PluginJson::ListOpDeSerialize(const string& data) ++{ ++ Json::Value root; ++ Json::Reader reader; ++ reader.parse(data, root); ++ uint64_t id = GetID(root["id"]); ++ bool readOnly = (bool)atoi(root["readOnly"].asString().c_str()); ++ bool hasPurpose = (bool)atoi(root["hasPurpose"].asString().c_str()); ++ Json::Value operandJson = root["operands"]; ++ Json::Value::Members operandMember = operandJson.getMemberNames(); ++ llvm::SmallVector ops; ++ for (size_t opIter = 0; opIter < operandMember.size(); opIter++) { ++ mlir::Value opValue = ValueJsonDeSerialize(operandJson[std::to_string(opIter).c_str()]); ++ ops.push_back(opValue); ++ } ++ mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); ++ mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); ++ mlir::Value trrelist = opBuilder->create(opBuilder->getUnknownLoc(), id, ++ IDefineCode::TREELIST, readOnly, hasPurpose, ops, retType); ++ return trrelist; ++} ++ ++mlir::Value PluginJson::StrOpJsonDeSerialize(const string& data) ++{ ++ Json::Value root; ++ Json::Reader reader; ++ reader.parse(data, root); ++ uint64_t id = GetID(root["id"]); ++ mlir::StringRef str(root["str"].asString()); ++ bool readOnly = (bool)atoi(root["readOnly"].asString().c_str()); ++ mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); ++ mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); ++ mlir::Value strop = opBuilder->create(opBuilder->getUnknownLoc(), id, ++ IDefineCode::StrCST, readOnly, str, retType); ++ return strop; ++} ++mlir::Value PluginJson::ArrayOpJsonDeSerialize(const string& data) ++{ ++ Json::Value root; ++ Json::Reader reader; ++ reader.parse(data, root); ++ uint64_t id = GetID(root["id"]); ++ bool readOnly = (bool)atoi(root["readOnly"].asString().c_str()); ++ mlir::Value base = ValueJsonDeSerialize(root["base"]); ++ mlir::Value offset = ValueJsonDeSerialize(root["offset"]); ++ mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); ++ mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); ++ mlir::Value arrayref = opBuilder->create(opBuilder->getUnknownLoc(), id, ++ IDefineCode::ArrayRef, readOnly, base, offset, retType); ++ return arrayref; ++} ++ ++mlir::Value PluginJson::DeclBaseOpJsonDeSerialize(const string& data) ++{ ++ Json::Value root; ++ Json::Reader reader; ++ reader.parse(data, root); ++ uint64_t id = GetID(root["id"]); ++ bool readOnly = (bool)atoi(root["readOnly"].asString().c_str()); ++ bool addressable = (bool)atoi(root["addressable"].asString().c_str()); ++ bool used = (bool)atoi(root["used"].asString().c_str()); ++ int32_t uid = GetID(root["uid"]); ++ mlir::Value initial = ValueJsonDeSerialize(root["initial"]); ++ mlir::Value name = ValueJsonDeSerialize(root["name"]); ++ llvm::Optional chain; ++ if (root["chain"]) { ++ chain = GetID(root["chain"]); ++ } ++ mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); ++ mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); ++ mlir::Value declOp = opBuilder->create(opBuilder->getUnknownLoc(), id, ++ IDefineCode::Decl, readOnly, addressable, used, uid, initial, name, chain, retType); ++ return declOp; ++} ++ ++mlir::Value PluginJson::FieldDeclOpJsonDeSerialize(const string& data) ++{ ++ Json::Value root; ++ Json::Reader reader; ++ reader.parse(data, root); ++ uint64_t id = GetID(root["id"]); ++ bool readOnly = (bool)atoi(root["readOnly"].asString().c_str()); ++ bool addressable = (bool)atoi(root["addressable"].asString().c_str()); ++ bool used = (bool)atoi(root["used"].asString().c_str()); ++ int32_t uid = GetID(root["uid"]); ++ mlir::Value initial = ValueJsonDeSerialize(root["initial"]); ++ mlir::Value name = ValueJsonDeSerialize(root["name"]); ++ uint64_t chain = GetID(root["chain"]); ++ mlir::Value fieldOffset = ValueJsonDeSerialize(root["fieldOffset"]); ++ mlir::Value fieldBitOffset = ValueJsonDeSerialize(root["fieldBitOffset"]); ++ mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); ++ mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); ++ mlir::Value fieldOp = opBuilder->create(opBuilder->getUnknownLoc(), id, ++ IDefineCode::FieldDecl, readOnly, addressable, used, uid, initial, name, chain, ++ fieldOffset, fieldBitOffset, retType); ++ return fieldOp; ++} ++ ++mlir::Value PluginJson::AddressOpJsonDeSerialize(const string& data) ++{ ++ Json::Value root; ++ Json::Reader reader; ++ reader.parse(data, root); ++ uint64_t id = GetID(root["id"]); ++ bool readOnly = (bool)atoi(root["readOnly"].asString().c_str()); ++ mlir::Value operand = ValueJsonDeSerialize(root["operand"]); ++ mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); ++ mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); ++ mlir::Value addrOp = opBuilder->create(opBuilder->getUnknownLoc(), id, ++ IDefineCode::AddrExp, readOnly, operand, retType); ++ return addrOp; ++} ++ ++mlir::Value PluginJson::ConstructorOpJsonDeSerialize(const string& data) ++{ ++ Json::Value root; ++ Json::Reader reader; ++ reader.parse(data, root); ++ uint64_t id = GetID(root["id"]); ++ bool readOnly = (bool)atoi(root["readOnly"].asString().c_str()); ++ uint64_t len = GetID(root["len"]); ++ Json::Value idxJson = root["idx"]; ++ Json::Value::Members idxMember = idxJson.getMemberNames(); ++ llvm::SmallVector idx, val; ++ for (size_t iter = 0; iter < idxMember.size(); iter++) { ++ mlir::Value opValue = ValueJsonDeSerialize(idxJson[std::to_string(iter).c_str()]); ++ idx.push_back(opValue); ++ } ++ Json::Value valJson = root["val"]; ++ Json::Value::Members valMember = valJson.getMemberNames(); ++ for (size_t iter = 0; iter < valMember.size(); iter++) { ++ mlir::Value opValue = ValueJsonDeSerialize(valJson[std::to_string(iter).c_str()]); ++ val.push_back(opValue); ++ } ++ mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); ++ mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); ++ mlir::Value constructorOp = opBuilder->create(opBuilder->getUnknownLoc(), id, ++ IDefineCode::Constructor, readOnly, len, idx, val, retType); ++ return constructorOp; ++} ++ ++mlir::Value PluginJson::VecOpJsonDeSerialize(const string& data) ++{ ++ Json::Value root; ++ Json::Reader reader; ++ reader.parse(data, root); ++ uint64_t id = GetID(root["id"]); ++ bool readOnly = (bool)atoi(root["readOnly"].asString().c_str()); ++ uint64_t len = GetID(root["len"]); ++ Json::Value elementsJson = root["elements"]; ++ Json::Value::Members elementsMember = elementsJson.getMemberNames(); ++ llvm::SmallVector elements; ++ for (size_t iter = 0; iter < elementsMember.size(); iter++) { ++ mlir::Value opValue = ValueJsonDeSerialize(elementsJson[std::to_string(iter).c_str()]); ++ elements.push_back(opValue); ++ } ++ mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); ++ mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); ++ mlir::Value vecOp = opBuilder->create(opBuilder->getUnknownLoc(), id, ++ IDefineCode::Vec, readOnly, len, elements, retType); ++ return vecOp; ++} ++ ++mlir::Value PluginJson::BlockOpJsonDeSerialize(const string& data) ++{ ++ Json::Value root; ++ Json::Reader reader; ++ reader.parse(data, root); ++ uint64_t id = GetID(root["id"]); ++ bool readOnly = (bool)atoi(root["readOnly"].asString().c_str()); ++ uint64_t supercontext = GetID(root["supercontext"]); ++ llvm::Optional vars, subblocks, chain, abstract_origin; ++ if (root["vars"]) { ++ vars = ValueJsonDeSerialize(root["vars"]); ++ } ++ ++ if (root["subblocks"]) { ++ subblocks = ValueJsonDeSerialize(root["subblocks"]); ++ } ++ if (root["chain"]) { ++ chain = ValueJsonDeSerialize(root["chain"]); ++ } ++ if (root["abstract_origin"]) { ++ abstract_origin = ValueJsonDeSerialize(root["abstract_origin"]); ++ } ++ mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); ++ mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); ++ mlir::Value blockOp = opBuilder->create( ++ opBuilder->getUnknownLoc(), id, IDefineCode::BLOCK, readOnly, vars, supercontext, subblocks, ++ chain, abstract_origin, retType); ++ return blockOp; ++} ++ ++mlir::Value PluginJson::ComponentOpJsonDeSerialize(const string& data) ++{ ++ Json::Value root; ++ Json::Reader reader; ++ reader.parse(data, root); ++ uint64_t id = GetID(root["id"]); ++ bool readOnly = (bool)atoi(root["readOnly"].asString().c_str()); ++ mlir::Value component = ValueJsonDeSerialize(root["component"]); ++ mlir::Value field = ValueJsonDeSerialize(root["field"]); ++ mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); ++ mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); ++ mlir::Value componentOp = opBuilder->create( ++ opBuilder->getUnknownLoc(), id, IDefineCode::COMPONENT, readOnly, component, field, retType); ++ return componentOp; ++} + void PluginJson::OpJsonDeSerialize( + const string& data, vector& opData) + { +-- +2.27.0.windows.1 + diff --git a/0011-Pin-server-Add-NopOp-EHElseOp-AsmOp-SwitchOp-LabelOp.patch b/0011-Pin-server-Add-NopOp-EHElseOp-AsmOp-SwitchOp-LabelOp.patch new file mode 100644 index 0000000..7f92356 --- /dev/null +++ b/0011-Pin-server-Add-NopOp-EHElseOp-AsmOp-SwitchOp-LabelOp.patch @@ -0,0 +1,912 @@ +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 2/5] =?UTF-8?q?[Pin-server]=20Add=20NopOp=E3=80=81EHElseOp?= + =?UTF-8?q?=E3=80=81AsmOp=E3=80=81SwitchOp=E3=80=81LabelOp=E3=80=81EHMntOp?= + =?UTF-8?q?=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":$nBody, "ArrayRef":$eBody)>, ++ ]; ++} ++ + class Placeholder : Plugin_Op { + dag commonArgs = (ins UI64Attr:$id, + OptionalAttr:$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:$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":$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:$caseDestinations ++ ); ++ let arguments = (ins UI64Attr:$id, AnyType:$index, UI64Attr:$address, AnyType:$defaultLabel, Variadic:$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":$operands, "Block*":$defaultDestination, "uint64_t":$defaultaddr, ++ "ArrayRef":$caseDestinations, "ArrayRef":$caseaddrs)> ++ ]; ++ ++ let extraClassDeclaration = [{ ++ unsigned GetNumLabels() { return getNumOperands() - 2; }; ++ Block* GetDefautDest() { return defaultDestination();} ++ SmallVector 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":$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":$eval, "ArrayRef":$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":$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":$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:$ehHandlers); ++ let builders = [ ++ OpBuilderDAG<(ins "uint64_t":$id, "uint64_t":$address, "uint64_t":$region, "ArrayRef":$ehHandlers, ++ "ArrayRef":$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::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(b->back())) { + return oops.addressAttr().getInt(); ++ } else if (mlir::Plugin::GotoOp oops = dyn_cast(b->back())) { ++ return oops.addressAttr().getInt(); ++ } else if (mlir::Plugin::TransactionOp oops = dyn_cast(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 nBody, ++ ArrayRef eBody) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ llvm::SmallVector 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 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 operands, ++ Block* defaultDest, uint64_t defaultaddr, ArrayRef caseDest, ArrayRef caseaddr) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addAttribute("address", builder.getI64IntegerAttr(address)); ++ state.addAttribute("defaultaddr", builder.getI64IntegerAttr(defaultaddr)); ++ llvm::SmallVector 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 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 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 ehHandlers, ArrayRef ehHandlersaddrs) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addAttribute("address", builder.getI64IntegerAttr(address)); ++ state.addAttribute("region", builder.getI64IntegerAttr(region)); ++ state.addSuccessors(ehHandlers); ++ llvm::SmallVector 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 body, ++ Value block) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addOperands({vars, block}); ++ llvm::SmallVector 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 eval, ++ ArrayRef cleanup, uint64_t kind) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ llvm::SmallVector 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 handler) ++{ ++ state.addAttribute("id", builder.getI64IntegerAttr(id)); ++ state.addOperands(types); ++ llvm::SmallVector 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(b->back())) { + return oops.addressAttr().getInt(); ++ } else if (mlir::Plugin::GotoOp oops = llvm::dyn_cast(b->back())) { ++ return oops.addressAttr().getInt(); ++ } else if (mlir::Plugin::TransactionOp oops = llvm::dyn_cast(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(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(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(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 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(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(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(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 ehHandlers; ++ llvm::SmallVector 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(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(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 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(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 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(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 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(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(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 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(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 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(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 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 caseaddr; ++ llvm::SmallVector 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(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& opData) + { +@@ -868,6 +1187,32 @@ void PluginJson::OpJsonDeSerialize( + uint64_t opID = GetID(opJson["id"]); + mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); + opBuilder->create(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.27.0.windows.1 + diff --git a/0012-Pin-server-Support-Vectortype.patch b/0012-Pin-server-Support-Vectortype.patch new file mode 100644 index 0000000..692d1e7 --- /dev/null +++ b/0012-Pin-server-Support-Vectortype.patch @@ -0,0 +1,151 @@ +From 50801883d5d5e89d44026ead6e38e149caa346b2 Mon Sep 17 00:00:00 2001 +From: d00573793 +Date: Sat, 25 Feb 2023 15:31:02 +0800 +Subject: [PATCH 3/5] [Pin-server] Support Vectortype + + +diff --git a/include/Dialect/PluginTypes.h b/include/Dialect/PluginTypes.h +index 3f7f14b..9693294 100644 +--- a/include/Dialect/PluginTypes.h ++++ b/include/Dialect/PluginTypes.h +@@ -55,8 +55,7 @@ enum PluginTypeID { + PointerTyID, ///< Pointers + StructTyID, ///< Structures + ArrayTyID, ///< Arrays +- FixedVectorTyID, ///< Fixed width SIMD vector type +- ScalableVectorTyID ///< Scalable SIMD vector type ++ VectorTyID, ///< Arrays + }; + + class PluginTypeBase : public Type { +@@ -146,6 +145,21 @@ public: + unsigned getNumElements(); + }; // class PluginArrayType + ++class PluginVectorType : public Type::TypeBase { ++public: ++ using Base::Base; ++ ++ PluginTypeID getPluginTypeID (); ++ ++ static bool isValidElementType(Type type); ++ ++ static PluginVectorType get(MLIRContext *context, Type elementType, unsigned numElements); ++ ++ Type getElementType(); ++ ++ unsigned getNumElements(); ++}; // class PluginVectorType ++ + class PluginFunctionType : public Type::TypeBase { + public: + using Base::Base; +diff --git a/lib/Dialect/PluginDialect.cpp b/lib/Dialect/PluginDialect.cpp +index ba8e4fe..95a78da 100644 +--- a/lib/Dialect/PluginDialect.cpp ++++ b/lib/Dialect/PluginDialect.cpp +@@ -38,6 +38,7 @@ void PluginDialect::initialize() + PluginIR::PluginFloatType, + PluginIR::PluginPointerType, + PluginIR::PluginArrayType, ++ PluginIR::PluginVectorType, + PluginIR::PluginFunctionType, + PluginIR::PluginStructType, + PluginIR::PluginBooleanType, +diff --git a/lib/Dialect/PluginTypes.cpp b/lib/Dialect/PluginTypes.cpp +index 337fc49..89e4b1a 100644 +--- a/lib/Dialect/PluginTypes.cpp ++++ b/lib/Dialect/PluginTypes.cpp +@@ -199,6 +199,9 @@ PluginTypeID PluginTypeBase::getPluginTypeID () + if (auto Ty = dyn_cast()) { + return Ty.getPluginTypeID (); + } ++ if (auto Ty = dyn_cast()) { ++ return Ty.getPluginTypeID (); ++ } + if (auto Ty = dyn_cast()) { + return Ty.getPluginTypeID (); + } +@@ -406,6 +409,35 @@ unsigned PluginArrayType::getNumElements() + return getImpl()->numElements; + } + ++// ===----------------------------------------------------------------------===// ++// Plugin Vector Type ++// ===----------------------------------------------------------------------===// ++ ++PluginTypeID PluginVectorType::getPluginTypeID() ++{ ++ return PluginTypeID::ArrayTyID; ++} ++ ++bool PluginVectorType::isValidElementType(Type type) ++{ ++ return type.isa(); ++} ++ ++PluginVectorType PluginVectorType::get(MLIRContext *context, Type elementType, unsigned numElements) ++{ ++ return Base::get(context, elementType, numElements); ++} ++ ++Type PluginVectorType::getElementType() ++{ ++ return getImpl()->elementType; ++} ++ ++unsigned PluginVectorType::getNumElements() ++{ ++ return getImpl()->numElements; ++} ++ + // ===----------------------------------------------------------------------===// + // Plugin Function Type + // ===----------------------------------------------------------------------===// +diff --git a/lib/PluginAPI/PluginServerAPI.cpp b/lib/PluginAPI/PluginServerAPI.cpp +index e3435b0..a471ddf 100644 +--- a/lib/PluginAPI/PluginServerAPI.cpp ++++ b/lib/PluginAPI/PluginServerAPI.cpp +@@ -347,6 +347,8 @@ PluginIR::PluginTypeID PluginServerAPI::GetTypeCodeFromString(string type) + return PluginIR::PluginTypeID::PointerTyID; + } else if (type == "ArrayTy") { + return PluginIR::PluginTypeID::ArrayTyID; ++ } else if (type == "VectorTy") { ++ return PluginIR::PluginTypeID::VectorTyID; + } else if (type == "FunctionTy") { + return PluginIR::PluginTypeID::FunctionTyID; + } else if (type == "StructTy") { +diff --git a/lib/PluginServer/PluginJson.cpp b/lib/PluginServer/PluginJson.cpp +index e1beddf..4d41351 100755 +--- a/lib/PluginServer/PluginJson.cpp ++++ b/lib/PluginServer/PluginJson.cpp +@@ -343,6 +343,10 @@ PluginIR::PluginTypeBase PluginJson::TypeJsonDeSerialize(const string& data) + mlir::Type elemTy = TypeJsonDeSerialize(type["elementType"].toStyledString()); + uint64_t elemNum = GetID(type["arraysize"]); + baseType = PluginIR::PluginArrayType::get(PluginServer::GetInstance()->GetContext(), elemTy, elemNum); ++ } else if (id == static_cast(PluginIR::VectorTyID)) { ++ mlir::Type elemTy = TypeJsonDeSerialize(type["elementType"].toStyledString()); ++ uint64_t elemNum = GetID(type["vectorelemnum"]); ++ baseType = PluginIR::PluginVectorType::get(PluginServer::GetInstance()->GetContext(), elemTy, elemNum); + } else if (id == static_cast(PluginIR::FunctionTyID)) { + mlir::Type returnTy = TypeJsonDeSerialize(type["fnreturntype"].toStyledString()); + llvm::SmallVector typelist; +diff --git a/user/LocalVarSummeryPass.cpp b/user/LocalVarSummeryPass.cpp +index 2e157e3..ccee9f7 100755 +--- a/user/LocalVarSummeryPass.cpp ++++ b/user/LocalVarSummeryPass.cpp +@@ -61,6 +61,11 @@ static void LocalVarSummery(void) + printf("\n struct argname is : %s\n", pName.c_str()); + } + } ++ if(auto stTy = ty.getReturnType().dyn_cast()) { ++ printf("func return type is PluginVectorType\n"); ++ printf(" vector elem num : %d\n", stTy.getNumElements()); ++ printf(" vector elem type id : %d\n", stTy.getElementType().dyn_cast().getPluginTypeID()); ++ } + size_t paramIndex = 0; + llvm::ArrayRef paramsType = ty.getParams(); + for (auto ty : ty.getParams()) { +-- +2.27.0.windows.1 + diff --git a/0013-Pin-server-Support-Vectortype.patch b/0013-Pin-server-Support-Vectortype.patch new file mode 100644 index 0000000..3fded7b --- /dev/null +++ b/0013-Pin-server-Support-Vectortype.patch @@ -0,0 +1,22 @@ +From 75ac9cb04537b586e77820278600544f83742df3 Mon Sep 17 00:00:00 2001 +From: huitailangzju <804544223@qq.com> +Date: Sun, 26 Feb 2023 17:09:16 +0800 +Subject: [PATCH 1/2] [Pin-server] Fix Definecode name + + +diff --git a/lib/PluginServer/PluginJson.cpp b/lib/PluginServer/PluginJson.cpp +index b849cf9..2500fe8 100755 +--- a/lib/PluginServer/PluginJson.cpp ++++ b/lib/PluginServer/PluginJson.cpp +@@ -109,7 +109,7 @@ mlir::Value PluginJson::ValueJsonDeSerialize(Json::Value valueJson) + opValue = SSAOpJsonDeSerialize(valueJson.toStyledString()); + break; + } +- case IDefineCode::TREELIST : { ++ case IDefineCode::LIST : { + opValue = ListOpDeSerialize(valueJson.toStyledString()); + break; + } +-- +2.27.0.windows.1 + diff --git a/0014-Pin-server-Fix-AWC-pass-can-complice-can-compile-a-c.patch b/0014-Pin-server-Fix-AWC-pass-can-complice-can-compile-a-c.patch new file mode 100644 index 0000000..1d7b25b --- /dev/null +++ b/0014-Pin-server-Fix-AWC-pass-can-complice-can-compile-a-c.patch @@ -0,0 +1,112 @@ +From e760e64864b2c5dfb4da010bef3c97ee5575e936 Mon Sep 17 00:00:00 2001 +From: d00573793 +Date: Sat, 25 Feb 2023 21:03:26 +0800 +Subject: [PATCH 2/2] [Pin-server] Fix AWC pass can complice can compile a + complete program + + +diff --git a/include/PluginAPI/BasicPluginOpsAPI.h b/include/PluginAPI/BasicPluginOpsAPI.h +index f83b888..923dd44 100644 +--- a/include/PluginAPI/BasicPluginOpsAPI.h ++++ b/include/PluginAPI/BasicPluginOpsAPI.h +@@ -46,6 +46,7 @@ public: + virtual int GetDeclSourceColumn(int64_t) = 0; + + virtual vector GetAllFunc() = 0; ++ virtual FunctionOp GetFunctionOpById(uint64_t) = 0; + virtual vector GetDecls(uint64_t) = 0; + virtual LoopOp AllocateNewLoop(uint64_t) = 0; + virtual vector GetLoopsFromFunc(uint64_t) = 0; +diff --git a/include/PluginAPI/PluginServerAPI.h b/include/PluginAPI/PluginServerAPI.h +index b2f8fbf..3da28f5 100644 +--- a/include/PluginAPI/PluginServerAPI.h ++++ b/include/PluginAPI/PluginServerAPI.h +@@ -37,6 +37,7 @@ public: + ~PluginServerAPI () = default; + + vector GetAllFunc() override; ++ FunctionOp GetFunctionOpById(uint64_t); + vector GetDecls(uint64_t) override; + PhiOp GetPhiOp(uint64_t) override; + CallOp GetCallOp(uint64_t) override; +diff --git a/lib/PluginAPI/PluginServerAPI.cpp b/lib/PluginAPI/PluginServerAPI.cpp +index 73c1a61..8ef10d1 100644 +--- a/lib/PluginAPI/PluginServerAPI.cpp ++++ b/lib/PluginAPI/PluginServerAPI.cpp +@@ -179,6 +179,21 @@ vector PluginServerAPI::GetAllFunc() + return PluginServer::GetInstance()->GetFunctionOpResult(funName, params); + } + ++FunctionOp PluginServerAPI::GetFunctionOpById(uint64_t id) ++{ ++ vector allFunction = GetAllFunc(); ++ FunctionOp funOp = nullptr; ++ ++ for (auto &funcOp : allFunction) { ++ if (funcOp.id() == id) { ++ funOp = funcOp; ++ break; ++ } ++ } ++ assert(funOp != nullptr); ++ return funOp; ++} ++ + PhiOp PluginServerAPI::GetPhiOp(uint64_t id) + { + Json::Value root; +diff --git a/user/ArrayWidenPass.cpp b/user/ArrayWidenPass.cpp +index 162fdc9..627e7f7 100644 +--- a/user/ArrayWidenPass.cpp ++++ b/user/ArrayWidenPass.cpp +@@ -1533,32 +1533,31 @@ static void convertToNewLoop(LoopOp* loop, FunctionOp* funcOp) + return; + } + +-static void ProcessArrayWiden(void) ++static void ProcessArrayWiden(uint64_t *fun) + { + std::cout << "Running first pass, awiden\n"; + + PluginServerAPI pluginAPI; +- vector allFunction = pluginAPI.GetAllFunc(); +- +- for (auto &funcOp : allFunction) { +- context = funcOp.getOperation()->getContext(); +- mlir::OpBuilder opBuilder_temp = mlir::OpBuilder(context); +- opBuilder = &opBuilder_temp; +- string name = funcOp.funcNameAttr().getValue().str(); +- printf("Now process func : %s \n", name.c_str()); +- vector allLoop = funcOp.GetAllLoops(); +- for (auto &loop : allLoop) { +- if (determineLoopForm(loop)) { +- printf("The loop form is success matched, and the loop can be optimized.\n"); +- convertToNewLoop(&loop, &funcOp); +- } ++ ++ FunctionOp funcOp = pluginAPI.GetFunctionOpById((uint64_t)fun); ++ ++ context = funcOp.getOperation()->getContext(); ++ mlir::OpBuilder opBuilder_temp = mlir::OpBuilder(context); ++ opBuilder = &opBuilder_temp; ++ string name = funcOp.funcNameAttr().getValue().str(); ++ printf("Now process func : %s \n", name.c_str()); ++ vector allLoop = funcOp.GetAllLoops(); ++ for (auto &loop : allLoop) { ++ if (determineLoopForm(loop)) { ++ printf("The loop form is success matched, and the loop can be optimized.\n"); ++ convertToNewLoop(&loop, &funcOp); + } + } + } + + int ArrayWidenPass::DoOptimize(uint64_t *fun) + { +- ProcessArrayWiden(); ++ ProcessArrayWiden(fun); + return 0; + } + } +-- +2.27.0.windows.1 + diff --git a/pin-server.spec b/pin-server.spec index a7e4668..bb1d04e 100644 --- a/pin-server.spec +++ b/pin-server.spec @@ -1,6 +1,6 @@ Name: pin-server Version: 0.4.0 -Release: 2 +Release: 3 Summary: Pin (Plug-IN framework) server provides plugin APIs for compiler optimization developers to develop optimization pass. License: Apache 2.0 URL: https://gitee.com/openeuler/pin-server @@ -19,6 +19,11 @@ Patch6: 0006-Pin-server-Fix-bug-for-BuildCallOp.patch Patch7: 0007-Pin-server-Refactoring-array-widen-compare-into-a-cl.patch Patch8: 0008-Pin-server-Refactoring-DEMOs-into-PluginOpt-classes.patch Patch9: 0009-Pin-server-Support-functiontype-structtype.eg.patch +Patch10: 0010-Pin-server-Add-ComponentOp-ConstructorOp-AddressOp-F.patch +Patch11: 0011-Pin-server-Add-NopOp-EHElseOp-AsmOp-SwitchOp-LabelOp.patch +Patch12: 0012-Pin-server-Support-Vectortype.patch +Patch13: 0013-Pin-server-Support-Vectortype.patch +Patch14: 0014-Pin-server-Fix-AWC-pass-can-complice-can-compile-a-c.patch %description Pin (Plug-IN framework) server provides plugin APIs for compiler optimization developers to develop optimization pass. @@ -46,6 +51,11 @@ A demo for pin-server %patch7 -p1 %patch8 -p1 %patch9 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 mkdir -p _build cd _build @@ -72,6 +82,12 @@ cd _build %attr(0644,root,root) %{_libdir}/libpin_user.sha256 %changelog +* Sun Feb 26 2023 dingguangya - 0.4.0-3 +- Type:Update +- ID:NA +- SUG:NA +- DESC:Sync patch from openEuler/pin-server + * Wed Feb 22 2023 dingguangya - 0.4.0-2 - Type:Update - ID:NA