Projects
Eulaceura:Factory
pin-server
_service:obs_scm:0022-Pin-server-Add-support-fo...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0022-Pin-server-Add-support-for-decl-and-field-SetDeclNam.patch of Package pin-server
From d41c7945688f533b15c9ef1d9f41a00cbd7afbdf Mon Sep 17 00:00:00 2001 From: huitailangzju <804544223@qq.com> Date: Mon, 6 Mar 2023 10:17:31 +0800 Subject: [PATCH 22/23] [Pin-server] Add support for decl and field: SetDeclName, SetDeclType,SetDeclAlign,SetUserAlign,SetSourceLocation,SetAddressable,SetNonAddressablep,SetVolatile,SetDeclContext,SetDeclChain diff --git a/include/Dialect/PluginDialect.td b/include/Dialect/PluginDialect.td index b618b59..56f2e4c 100644 --- a/include/Dialect/PluginDialect.td +++ b/include/Dialect/PluginDialect.td @@ -78,12 +78,14 @@ 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 IDefineCodeTYPEDECL : I32EnumAttrCase<"TYPEDECL", 13>; +def IDefineCodeUNDEF : I32EnumAttrCase<"UNDEF", 14>; def IDefineCodeAttr : I32EnumAttr< "IDefineCode", "plugin define code", [IDefineCodeMemRef, IDefineCodeIntCST, IDefineCodeSSA, IDefineCodeLIST, IDefineCodeStrCST, IDefineCodeArrayRef, IDefineCodeDecl, IDefineCodeFieldDecl, IDefineCodeAddrExp, - IDefineCodeConstructor, IDefineCodeVec, IDefineCodeBLOCK, IDefineCodeCOMPONENT, IDefineCodeUNDEF]>{ + IDefineCodeConstructor, IDefineCodeVec, IDefineCodeBLOCK, IDefineCodeCOMPONENT, IDefineCodeTYPEDECL, + IDefineCodeUNDEF]>{ let cppNamespace = "::mlir::Plugin"; } diff --git a/include/Dialect/PluginOps.td b/include/Dialect/PluginOps.td index 9554067..6c4d80f 100644 --- a/include/Dialect/PluginOps.td +++ b/include/Dialect/PluginOps.td @@ -375,6 +375,19 @@ def FieldDeclOp : FieldDecl<"field"> { Optional<uint64_t> GetChain() { return chain(); } Value GetFieldOffset() { return fieldOffset(); } Value GetFieldBitOffset() { return fieldBitOffset(); } + + void SetName(FieldDeclOp); + void SetType(FieldDeclOp); + void SetDeclAlign(FieldDeclOp); + void SetSourceLocation(FieldDeclOp); + void SetUserAlign(FieldDeclOp); + void SetAddressable(FieldDeclOp); + void SetNonAddressablep(FieldDeclOp); + void SetVolatile(FieldDeclOp); + void SetDeclContext(uint64_t); + void SetDeclChain(FieldDeclOp); + + unsigned GetTypeSize(); }]; } diff --git a/include/PluginAPI/BasicPluginOpsAPI.h b/include/PluginAPI/BasicPluginOpsAPI.h index e8c0a50..d659662 100644 --- a/include/PluginAPI/BasicPluginOpsAPI.h +++ b/include/PluginAPI/BasicPluginOpsAPI.h @@ -51,6 +51,28 @@ public: virtual vector<FunctionOp> GetAllFunc() = 0; virtual FunctionOp GetFunctionOpById(uint64_t) = 0; + virtual vector<mlir::Plugin::DeclBaseOp> GetFuncDecls(uint64_t) = 0; + virtual llvm::SmallVector<mlir::Plugin::FieldDeclOp> GetFields(uint64_t) = 0; + virtual mlir::Plugin::DeclBaseOp BuildDecl(IDefineCode, llvm::StringRef, PluginIR::PluginTypeBase) = 0; + + virtual mlir::Plugin::FieldDeclOp MakeNode(IDefineCode) = 0; + virtual void SetDeclName(uint64_t newfieldId, uint64_t fieldId) = 0; + virtual void SetDeclType(uint64_t newfieldId, uint64_t fieldId) = 0; + virtual void SetDeclAlign(uint64_t newfieldId, uint64_t fieldId) = 0; + virtual void SetUserAlign(uint64_t newfieldId, uint64_t fieldId) = 0; + virtual void SetSourceLocation(uint64_t newfieldId, uint64_t fieldId) = 0; + virtual void SetAddressable(uint64_t newfieldId, uint64_t fieldId) = 0; + virtual void SetNonAddressablep(uint64_t newfieldId, uint64_t fieldId) = 0; + virtual void SetVolatile(uint64_t newfieldId, uint64_t fieldId) = 0; + virtual void SetDeclContext(uint64_t newfieldId, uint64_t declId) = 0; + virtual void SetDeclChain(uint64_t newfieldId, uint64_t fieldId) = 0; + + virtual unsigned GetDeclTypeSize(uint64_t declId) = 0; + + virtual void SetTypeFields(uint64_t declId, uint64_t fieldId) = 0; + virtual void LayoutType(uint64_t declId) = 0; + virtual void LayoutDecl(uint64_t declId) = 0; + virtual vector<LocalDeclOp> GetDecls(uint64_t) = 0; virtual LoopOp AllocateNewLoop(uint64_t) = 0; virtual vector<LoopOp> GetLoopsFromFunc(uint64_t) = 0; diff --git a/include/PluginAPI/PluginServerAPI.h b/include/PluginAPI/PluginServerAPI.h index 71b59b0..239dd23 100644 --- a/include/PluginAPI/PluginServerAPI.h +++ b/include/PluginAPI/PluginServerAPI.h @@ -44,6 +44,28 @@ public: vector<FunctionOp> GetAllFunc() override; FunctionOp GetFunctionOpById(uint64_t); + vector<mlir::Plugin::DeclBaseOp> GetFuncDecls(uint64_t) override; + llvm::SmallVector<mlir::Plugin::FieldDeclOp> GetFields(uint64_t) override; + mlir::Plugin::DeclBaseOp BuildDecl(IDefineCode, llvm::StringRef, PluginIR::PluginTypeBase) override; + + mlir::Plugin::FieldDeclOp MakeNode(IDefineCode) override; + void SetDeclName(uint64_t newfieldId, uint64_t fieldId) override; + void SetDeclType(uint64_t newfieldId, uint64_t fieldId) override; + void SetDeclAlign(uint64_t newfieldId, uint64_t fieldId) override; + void SetUserAlign(uint64_t newfieldId, uint64_t fieldId) override; + void SetSourceLocation(uint64_t newfieldId, uint64_t fieldId) override; + void SetAddressable(uint64_t newfieldId, uint64_t fieldId) override; + void SetNonAddressablep(uint64_t newfieldId, uint64_t fieldId) override; + void SetVolatile(uint64_t newfieldId, uint64_t fieldId) override; + void SetDeclContext(uint64_t newfieldId, uint64_t declId) override; + void SetDeclChain(uint64_t newfieldId, uint64_t fieldId) override; + + unsigned GetDeclTypeSize(uint64_t declId) override; + + void SetTypeFields(uint64_t declId, uint64_t fieldId) override; + void LayoutType(uint64_t declId) override; + void LayoutDecl(uint64_t declId) override; + vector<LocalDeclOp> GetDecls(uint64_t) override; PhiOp GetPhiOp(uint64_t) override; CallOp GetCallOp(uint64_t) override; diff --git a/include/PluginServer/PluginCom.h b/include/PluginServer/PluginCom.h index d507b6f..af819ad 100755 --- a/include/PluginServer/PluginCom.h +++ b/include/PluginServer/PluginCom.h @@ -57,6 +57,12 @@ public: string GetStringDataResult(void); vector<mlir::Plugin::FunctionOp> GetFunctionOpResult(void); vector<mlir::Plugin::LocalDeclOp> GetLocalDeclResult(void); + vector<mlir::Plugin::DeclBaseOp> GetFuncDeclsResult(void); + llvm::SmallVector<mlir::Plugin::FieldDeclOp> GetFieldsResult(void); + mlir::Plugin::DeclBaseOp GetBuildDeclResult(void); + + mlir::Plugin::FieldDeclOp GetMakeNodeResult(void); + mlir::Plugin::CGnodeOp GetCGnodeOpResult(void); mlir::Plugin::LoopOp LoopOpResult(void); vector<mlir::Plugin::LoopOp> LoopOpsResult(void); @@ -77,6 +83,7 @@ private: mlir::Plugin::CGnodeOp cgnode; vector<mlir::Plugin::FunctionOp> funcOpData; vector<mlir::Plugin::LocalDeclOp> decls; + vector<mlir::Plugin::DeclBaseOp> declOps; vector<mlir::Plugin::LoopOp> loops; mlir::Plugin::LoopOp loop; vector<std::pair<mlir::Block*, mlir::Block*> > edges; @@ -86,6 +93,9 @@ private: uint64_t idResult; vector<uint64_t> idsResult; mlir::Value valueResult; + mlir::Plugin::DeclBaseOp declOp; + mlir::Plugin::FieldDeclOp fielddeclOp; + llvm::SmallVector<mlir::Plugin::FieldDeclOp> fieldsOps; }; } // namespace PinCom diff --git a/include/PluginServer/PluginJson.h b/include/PluginServer/PluginJson.h index eddbb2a..1d4bfbc 100755 --- a/include/PluginServer/PluginJson.h +++ b/include/PluginServer/PluginJson.h @@ -39,6 +39,9 @@ public: void FuncOpJsonDeSerialize(const string&, vector<mlir::Plugin::FunctionOp>&); void LocalDeclOpJsonDeSerialize(const string&, vector<mlir::Plugin::LocalDeclOp>&); + void FuncDeclsOpJsonDeSerialize(const string&, + vector<mlir::Plugin::DeclBaseOp>&); + void FieldOpsJsonDeSerialize(const string&, llvm::SmallVector<mlir::Plugin::FieldDeclOp>&); void LoopOpsJsonDeSerialize(const string&, vector<mlir::Plugin::LoopOp>&); void EdgesJsonDeSerialize(const string&, vector<std::pair<mlir::Block*, mlir::Block*>>&); diff --git a/include/PluginServer/PluginServer.h b/include/PluginServer/PluginServer.h index d993505..29a790b 100644 --- a/include/PluginServer/PluginServer.h +++ b/include/PluginServer/PluginServer.h @@ -158,6 +158,31 @@ public: RemoteCallClientWithAPI(funName, params); return pluginCom.GetFunctionOpResult(); } + + vector<mlir::Plugin::DeclBaseOp> GetFuncDeclsResult(const string& funName, const string& params) + { + RemoteCallClientWithAPI(funName, params); + return pluginCom.GetFuncDeclsResult(); + } + + mlir::Plugin::FieldDeclOp GetMakeNodeResult(const string& funName, const string& params) + { + RemoteCallClientWithAPI(funName, params); + return pluginCom.GetMakeNodeResult(); + } + + llvm::SmallVector<mlir::Plugin::FieldDeclOp> GetFieldsResult(const string& funName, const string& params) + { + RemoteCallClientWithAPI(funName, params); + return pluginCom.GetFieldsResult(); + } + + mlir::Plugin::DeclBaseOp GetBuildDeclResult(const string& funName, const string& params) + { + RemoteCallClientWithAPI(funName, params); + return pluginCom.GetBuildDeclResult(); + } + vector<mlir::Plugin::LocalDeclOp> GetLocalDeclResult(const string& funName, const string& params) { RemoteCallClientWithAPI(funName, params); diff --git a/include/user/ArrayWidenPass.h b/include/user/ArrayWidenPass.h index 38c692d..5528297 100755 --- a/include/user/ArrayWidenPass.h +++ b/include/user/ArrayWidenPass.h @@ -35,10 +35,10 @@ public: } int DoOptimize() { - uint64_t *fun = (uint64_t *)GetFuncAddr(); + uint64_t fun = (uint64_t)GetFuncAddr(); return DoOptimize(fun); } - int DoOptimize(uint64_t *fun); + int DoOptimize(uint64_t fun); }; } diff --git a/lib/Dialect/PluginOps.cpp b/lib/Dialect/PluginOps.cpp index 928dc53..57b06b4 100644 --- a/lib/Dialect/PluginOps.cpp +++ b/lib/Dialect/PluginOps.cpp @@ -432,6 +432,82 @@ void FieldDeclOp::build(OpBuilder &builder, OperationState &state, uint64_t id, state.addTypes(retType); } +void FieldDeclOp::SetName(FieldDeclOp field) +{ + PluginAPI::PluginServerAPI pluginAPI; + uint64_t fieldId = field.idAttr().getInt(); + unsigned idx = 1; + this->setOperand(idx ,field.GetName()); + return pluginAPI.SetDeclName(this->idAttr().getInt(), fieldId); +} + +void FieldDeclOp::SetType(FieldDeclOp field) +{ + PluginAPI::PluginServerAPI pluginAPI; + uint64_t fieldId = field.idAttr().getInt(); + return pluginAPI.SetDeclType(this->idAttr().getInt(), fieldId); +} + +void FieldDeclOp::SetDeclAlign(FieldDeclOp field) +{ + PluginAPI::PluginServerAPI pluginAPI; + uint64_t fieldId = field.idAttr().getInt(); + return pluginAPI.SetDeclAlign(this->idAttr().getInt(), fieldId); +} + +void FieldDeclOp::SetUserAlign(FieldDeclOp field) +{ + PluginAPI::PluginServerAPI pluginAPI; + uint64_t fieldId = field.idAttr().getInt(); + return pluginAPI.SetUserAlign(this->idAttr().getInt(), fieldId); +} + +unsigned FieldDeclOp::GetTypeSize() +{ + PluginAPI::PluginServerAPI pluginAPI; + return pluginAPI.GetDeclTypeSize(this->idAttr().getInt()); +} + +void FieldDeclOp::SetSourceLocation(FieldDeclOp field) +{ + PluginAPI::PluginServerAPI pluginAPI; + uint64_t fieldId = field.idAttr().getInt(); + return pluginAPI.SetSourceLocation(this->idAttr().getInt(), fieldId); +} + +void FieldDeclOp::SetAddressable(FieldDeclOp field) +{ + PluginAPI::PluginServerAPI pluginAPI; + uint64_t fieldId = field.idAttr().getInt(); + return pluginAPI.SetAddressable(this->idAttr().getInt(), fieldId); +} + +void FieldDeclOp::SetNonAddressablep(FieldDeclOp field) +{ + PluginAPI::PluginServerAPI pluginAPI; + uint64_t fieldId = field.idAttr().getInt(); + return pluginAPI.SetNonAddressablep(this->idAttr().getInt(), fieldId); +} + +void FieldDeclOp::SetVolatile(FieldDeclOp field) +{ + PluginAPI::PluginServerAPI pluginAPI; + uint64_t fieldId = field.idAttr().getInt(); + return pluginAPI.SetVolatile(this->idAttr().getInt(), fieldId); +} + +void FieldDeclOp::SetDeclContext(uint64_t declId) +{ + PluginAPI::PluginServerAPI pluginAPI; + return pluginAPI.SetDeclContext(this->idAttr().getInt(), declId); +} + +void FieldDeclOp::SetDeclChain(FieldDeclOp field) +{ + PluginAPI::PluginServerAPI pluginAPI; + uint64_t fieldId = field.idAttr().getInt(); + return pluginAPI.SetDeclChain(this->idAttr().getInt(), fieldId); +} //===----------------------------------------------------------------------===// // AddressOp diff --git a/lib/PluginAPI/PluginServerAPI.cpp b/lib/PluginAPI/PluginServerAPI.cpp index 5297357..537d389 100644 --- a/lib/PluginAPI/PluginServerAPI.cpp +++ b/lib/PluginAPI/PluginServerAPI.cpp @@ -442,6 +442,186 @@ vector<LocalDeclOp> PluginServerAPI::GetDecls(uint64_t funcID) return PluginServer::GetInstance()->GetLocalDeclResult(funName, params); } +vector<mlir::Plugin::DeclBaseOp> PluginServerAPI::GetFuncDecls(uint64_t funcID) +{ + Json::Value root; + string funName = __func__; + root["funcId"] = std::to_string(funcID); + string params = root.toStyledString(); + + return PluginServer::GetInstance()->GetFuncDeclsResult(funName, params); +} + +mlir::Plugin::FieldDeclOp PluginServerAPI::MakeNode(IDefineCode code) +{ + Json::Value root; + string funName = __func__; + root["defCode"] = std::to_string(static_cast<int32_t>(code)); + string params = root.toStyledString(); + + return PluginServer::GetInstance()->GetMakeNodeResult(funName, params); +} + +llvm::SmallVector<mlir::Plugin::FieldDeclOp> PluginServerAPI::GetFields(uint64_t declID) +{ + Json::Value root; + string funName = __func__; + root["declId"] = std::to_string(declID); + string params = root.toStyledString(); + + return PluginServer::GetInstance()->GetFieldsResult(funName, params); +} + +void PluginServerAPI::SetDeclName(uint64_t newfieldId, uint64_t fieldId) +{ + Json::Value root; + string funName = __func__; + root["newfieldId"] = std::to_string(newfieldId); + root["fieldId"] = std::to_string(fieldId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + +void PluginServerAPI::SetDeclType(uint64_t newfieldId, uint64_t fieldId) +{ + Json::Value root; + string funName = __func__; + root["newfieldId"] = std::to_string(newfieldId); + root["fieldId"] = std::to_string(fieldId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + +void PluginServerAPI::SetDeclAlign(uint64_t newfieldId, uint64_t fieldId) +{ + Json::Value root; + string funName = __func__; + root["newfieldId"] = std::to_string(newfieldId); + root["fieldId"] = std::to_string(fieldId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + +void PluginServerAPI::SetUserAlign(uint64_t newfieldId, uint64_t fieldId) +{ + Json::Value root; + string funName = __func__; + root["newfieldId"] = std::to_string(newfieldId); + root["fieldId"] = std::to_string(fieldId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + +unsigned PluginServerAPI::GetDeclTypeSize(uint64_t declId) +{ + Json::Value root; + string funName = __func__; + root["declId"] = std::to_string(declId); + string params = root.toStyledString(); + return PluginServer::GetInstance()->GetIntegerDataResult(funName, params); +} + +void PluginServerAPI::SetSourceLocation(uint64_t newfieldId, uint64_t fieldId) +{ + Json::Value root; + string funName = __func__; + root["newfieldId"] = std::to_string(newfieldId); + root["fieldId"] = std::to_string(fieldId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + +void PluginServerAPI::SetAddressable(uint64_t newfieldId, uint64_t fieldId) +{ + Json::Value root; + string funName = __func__; + root["newfieldId"] = std::to_string(newfieldId); + root["fieldId"] = std::to_string(fieldId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + +void PluginServerAPI::SetNonAddressablep(uint64_t newfieldId, uint64_t fieldId) +{ + Json::Value root; + string funName = __func__; + root["newfieldId"] = std::to_string(newfieldId); + root["fieldId"] = std::to_string(fieldId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + +void PluginServerAPI::SetVolatile(uint64_t newfieldId, uint64_t fieldId) +{ + Json::Value root; + string funName = __func__; + root["newfieldId"] = std::to_string(newfieldId); + root["fieldId"] = std::to_string(fieldId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + +void PluginServerAPI::SetDeclContext(uint64_t newfieldId, uint64_t declId) +{ + Json::Value root; + string funName = __func__; + root["newfieldId"] = std::to_string(newfieldId); + root["declId"] = std::to_string(declId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + +void PluginServerAPI::SetDeclChain(uint64_t newfieldId, uint64_t fieldId) +{ + Json::Value root; + string funName = __func__; + root["newfieldId"] = std::to_string(newfieldId); + root["fieldId"] = std::to_string(fieldId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + +mlir::Plugin::DeclBaseOp PluginServerAPI::BuildDecl(IDefineCode code, llvm::StringRef name, PluginIR::PluginTypeBase type) +{ + Json::Value root; + string funName = __func__; + root["defCode"] = std::to_string(static_cast<int32_t>(code)); + root["name"] = name.str(); + PinJson::PluginJson json; + root["type"] = json.TypeJsonSerialize(type); + string params = root.toStyledString(); + + return PluginServer::GetInstance()->GetBuildDeclResult(funName, params); +} + +void PluginServerAPI::SetTypeFields(uint64_t declId, uint64_t fieldId) +{ + Json::Value root; + string funName = __func__; + root["declId"] = std::to_string(declId); + root["fieldId"] = std::to_string(fieldId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + +void PluginServerAPI::LayoutType(uint64_t declId) +{ + Json::Value root; + string funName = __func__; + root["declId"] = std::to_string(declId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + +void PluginServerAPI::LayoutDecl(uint64_t declId) +{ + Json::Value root; + string funName = __func__; + root["declId"] = std::to_string(declId); + string params = root.toStyledString(); + PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params); +} + mlir::Block* PluginServerAPI::BlockResult(const string& funName, const string& params) { uint64_t blockId = PluginServer::GetInstance()->GetIdResult(funName, params); diff --git a/lib/PluginServer/PluginCom.cpp b/lib/PluginServer/PluginCom.cpp index ddf0605..573de13 100755 --- a/lib/PluginServer/PluginCom.cpp +++ b/lib/PluginServer/PluginCom.cpp @@ -65,6 +65,32 @@ mlir::Plugin::CGnodeOp PluginCom::GetCGnodeOpResult(void) return retop; } +vector<mlir::Plugin::DeclBaseOp> PluginCom::GetFuncDeclsResult(void) +{ + vector<mlir::Plugin::DeclBaseOp> retOps = declOps; + declOps.clear(); + return retOps; +} + +mlir::Plugin::FieldDeclOp PluginCom::GetMakeNodeResult(void) +{ + mlir::Plugin::FieldDeclOp retOp = fielddeclOp; + return retOp; +} + +llvm::SmallVector<mlir::Plugin::FieldDeclOp> PluginCom::GetFieldsResult(void) +{ + llvm::SmallVector<mlir::Plugin::FieldDeclOp> retOps = fieldsOps; + fieldsOps.clear(); + return retOps; +} + +mlir::Plugin::DeclBaseOp PluginCom::GetBuildDeclResult(void) +{ + mlir::Plugin::DeclBaseOp retOp = declOp; + return retOp; +} + vector<mlir::Plugin::LoopOp> PluginCom::LoopOpsResult(void) { vector<mlir::Plugin::LoopOp> retLoops = loops; @@ -151,6 +177,14 @@ void PluginCom::JsonDeSerialize(const string& key, const string& data) json.IdsJsonDeSerialize(data, this->idsResult); } else if (key == "IdResult") { this->idResult = atol(data.c_str()); + } else if (key == "DeclOpResult") { + mlir::Value decl = json.DeclBaseOpJsonDeSerialize(data); + this->declOp = llvm::dyn_cast<mlir::Plugin::DeclBaseOp>(decl.getDefiningOp()); + printf("server 164 declop ----------------\n"); + printf("server 164 declop code %d\n", this->declOp.defCodeAttr().getInt()); + printf("server 165 declop ----------------\n"); + } else if (key == "GetFieldsOpResult") { + json.FieldOpsJsonDeSerialize(data, this->fieldsOps); } else if (key == "OpsResult") { json.OpJsonDeSerialize(data.c_str(), this->opData); } else if (key == "ValueResult") { diff --git a/lib/PluginServer/PluginJson.cpp b/lib/PluginServer/PluginJson.cpp index ba2136b..7c2abbe 100755 --- a/lib/PluginServer/PluginJson.cpp +++ b/lib/PluginServer/PluginJson.cpp @@ -375,7 +375,7 @@ void PluginJson::FuncOpJsonDeSerialize( mlir::Region &bodyRegion = fOp.bodyRegion(); Json::Value regionJson = node["region"]; Json::Value::Members bbMember = regionJson.getMemberNames(); - // We must create Blocks before process ops + // We must create Blocks before process opsG for (size_t bbIdx = 0; bbIdx < bbMember.size(); bbIdx++) { string blockKey = "block" + std::to_string(bbIdx); Json::Value blockJson = regionJson[blockKey]; @@ -502,6 +502,42 @@ void PluginJson::LocalDeclOpJsonDeSerialize( } } +void PluginJson::FuncDeclsOpJsonDeSerialize(const string& data, + vector<mlir::Plugin::DeclBaseOp>& declOps) +{ + Json::Value root; + Json::Reader reader; + Json::Value node; + reader.parse(data, root); + Json::Value::Members operation = root.getMemberNames(); + mlir::OpBuilder opBuilder(PluginServer::GetInstance()->GetContext()); + for (size_t iter = 0; iter < operation.size(); iter++) { + string operationKey = std::to_string(iter); + node = root[operationKey]; + mlir::Value opValue = DeclBaseOpJsonDeSerialize(node.toStyledString()); //ValueJsonDeSerialize(node); + DeclBaseOp d = llvm::dyn_cast<DeclBaseOp>(opValue.getDefiningOp()); + declOps.push_back(d); + } +} + +void PluginJson::FieldOpsJsonDeSerialize(const string& data, + llvm::SmallVector<mlir::Plugin::FieldDeclOp>& fieldOps) +{ + Json::Value root; + Json::Reader reader; + Json::Value node; + reader.parse(data, root); + Json::Value::Members operation = root.getMemberNames(); + mlir::OpBuilder opBuilder(PluginServer::GetInstance()->GetContext()); + for (size_t iter = 0; iter < operation.size(); iter++) { + string operationKey = std::to_string(iter); + node = root[operationKey]; + mlir::Value opValue = FieldDeclOpJsonDeSerialize(node.toStyledString()); //ValueJsonDeSerialize(node); + FieldDeclOp d = llvm::dyn_cast<FieldDeclOp>(opValue.getDefiningOp()); + fieldOps.push_back(d); + } +} + void PluginJson::LoopOpsJsonDeSerialize( const string& data, vector<mlir::Plugin::LoopOp>& loops) { @@ -767,7 +803,7 @@ mlir::Value PluginJson::ListOpDeSerialize(const string& data) 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::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString()); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); mlir::Value trrelist = opBuilder->create<ListOp>(opBuilder->getUnknownLoc(), id, IDefineCode::LIST, readOnly, hasPurpose, ops, retType); @@ -782,7 +818,7 @@ mlir::Value PluginJson::StrOpJsonDeSerialize(const string& data) 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::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString()); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); mlir::Value strop = opBuilder->create<StrOp>(opBuilder->getUnknownLoc(), id, IDefineCode::StrCST, readOnly, str, retType); @@ -797,7 +833,7 @@ mlir::Value PluginJson::ArrayOpJsonDeSerialize(const string& data) 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::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString()); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); mlir::Value arrayref = opBuilder->create<ArrayOp>(opBuilder->getUnknownLoc(), id, IDefineCode::ArrayRef, readOnly, base, offset, retType); @@ -820,7 +856,8 @@ mlir::Value PluginJson::DeclBaseOpJsonDeSerialize(const string& data) if (root["chain"]) { chain = GetID(root["chain"]); } - mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); + mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString()); + PluginIR::PluginTypeBase pluginType = retType.dyn_cast<PluginIR::PluginTypeBase>(); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); mlir::Value declOp = opBuilder->create<DeclBaseOp>(opBuilder->getUnknownLoc(), id, IDefineCode::Decl, readOnly, addressable, used, uid, initial, name, chain, retType); @@ -842,7 +879,7 @@ mlir::Value PluginJson::FieldDeclOpJsonDeSerialize(const string& data) 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::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString()); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); mlir::Value fieldOp = opBuilder->create<FieldDeclOp>(opBuilder->getUnknownLoc(), id, IDefineCode::FieldDecl, readOnly, addressable, used, uid, initial, name, chain, @@ -858,7 +895,7 @@ mlir::Value PluginJson::AddressOpJsonDeSerialize(const string& data) 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::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString()); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); mlir::Value addrOp = opBuilder->create<AddressOp>(opBuilder->getUnknownLoc(), id, IDefineCode::AddrExp, readOnly, operand, retType); @@ -886,7 +923,7 @@ mlir::Value PluginJson::ConstructorOpJsonDeSerialize(const string& data) 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::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString()); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); mlir::Value constructorOp = opBuilder->create<ConstructorOp>(opBuilder->getUnknownLoc(), id, IDefineCode::Constructor, readOnly, len, idx, val, retType); @@ -908,7 +945,7 @@ mlir::Value PluginJson::VecOpJsonDeSerialize(const string& data) 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::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString()); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); mlir::Value vecOp = opBuilder->create<VecOp>(opBuilder->getUnknownLoc(), id, IDefineCode::Vec, readOnly, len, elements, retType); @@ -937,7 +974,7 @@ mlir::Value PluginJson::BlockOpJsonDeSerialize(const string& data) if (root["abstract_origin"]) { abstract_origin = ValueJsonDeSerialize(root["abstract_origin"]); } - mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString().c_str()); + mlir::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString()); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); mlir::Value blockOp = opBuilder->create<BlockOp>( opBuilder->getUnknownLoc(), id, IDefineCode::BLOCK, readOnly, vars, supercontext, subblocks, @@ -954,7 +991,7 @@ mlir::Value PluginJson::ComponentOpJsonDeSerialize(const string& data) 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::Type retType = TypeJsonDeSerialize(root["retType"].toStyledString()); mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder(); mlir::Value componentOp = opBuilder->create<ComponentOp>( opBuilder->getUnknownLoc(), id, IDefineCode::COMPONENT, readOnly, component, field, retType); -- 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