9 Star 0 Fork 13

src-openEuler/pin-server

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0003-Refactoring-Code-refactoring-of-Communication-Subsys.patch 64.85 KB
一键复制 编辑 原始数据 按行查看 历史
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715
From d395986acddf59c379a107fbe6d1b69c74ff2d3b Mon Sep 17 00:00:00 2001
From: wangding16 <wangding16@huawei.com>
Date: Wed, 8 Feb 2023 15:16:49 +0800
Subject: [PATCH 03/23] [Refactoring] Code refactoring of Communication
Subsystem [3/3]. Code refactoring of Communication subsystem.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f1373e8..3a784df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -92,6 +92,9 @@ add_custom_command(TARGET pin_user COMMAND sha256sum libpin_user.so > libpin_use
add_executable(pin_server
"lib/PluginServer/PluginServer.cpp"
"lib/PluginAPI/ControlFlowAPI.cpp"
+ "lib/PluginServer/PluginGrpc.cpp"
+ "lib/PluginServer/PluginJson.cpp"
+ "lib/PluginServer/PluginCom.cpp"
"lib/PluginServer/PluginLog.cpp"
"lib/PluginServer/main.cpp")
target_link_libraries(pin_server
diff --git a/README.md b/README.md
index f948f51..3513a24 100644
--- a/README.md
+++ b/README.md
@@ -6,10 +6,8 @@ Pin (Plug-IN framework) server provides plugin APIs for compiler optimization de
#### 软件架构
Pin(Plug-IN framework, 插件框架)为生态伙伴提供基于插件IR的编译器优化开发能力,允许开发者使用插件API开发编译器优化pass,并以插件形式向主流编译器(如GCC)提供优化能力。
-本框架采用插件服务端组件(Pin-Server)和插件客户端模块(Pin-gcc-client)组成代理模式。
+本框架采用插件服务端组件(Pin-Server)和插件客户端模块组成代理模式。
Pin-Server为开发者提供插件API进行编译器优化pass的开发。
-Pin-gcc-client基于GCC插件实现,可以在GCC场景执行优化pass。
-
#### 安装教程
diff --git a/include/Dialect/PluginDialect.h b/include/Dialect/PluginDialect.h
index 0affbc2..65e03c0 100644
--- a/include/Dialect/PluginDialect.h
+++ b/include/Dialect/PluginDialect.h
@@ -13,11 +13,11 @@
under the License.
*/
-//===----------------------------------------------------------------------===//
-//
+// ===----------------------------------------------------------------------===//
+//
// This is the header file for the Plugin dialect.
//
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
#ifndef PLUGIN_DIALECT_H
#define PLUGIN_DIALECT_H
diff --git a/include/Dialect/PluginOps.h b/include/Dialect/PluginOps.h
index 8bab877..3c7bd64 100644
--- a/include/Dialect/PluginOps.h
+++ b/include/Dialect/PluginOps.h
@@ -14,11 +14,11 @@
*/
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
//
-// This is the header file for operations in Plugin dialect.
+// This is the header file for operations in Plugin dialect.
//
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
#ifndef Plugin_OPS_H
#define Plugin_OPS_H
diff --git a/include/Dialect/PluginTypes.h b/include/Dialect/PluginTypes.h
index 0b1f4f4..7fb1ff9 100644
--- a/include/Dialect/PluginTypes.h
+++ b/include/Dialect/PluginTypes.h
@@ -131,25 +131,19 @@ public:
class PluginVoidType : public Type::TypeBase<PluginVoidType, PluginTypeBase, TypeStorage> {
public:
using Base::Base;
-
PluginTypeID getPluginTypeID ();
-
}; // class PluginVoidType
class PluginUndefType : public Type::TypeBase<PluginUndefType, PluginTypeBase, TypeStorage> {
public:
using Base::Base;
-
PluginTypeID getPluginTypeID ();
-
}; // class PluginUndefType
class PluginBooleanType : public Type::TypeBase<PluginBooleanType, PluginTypeBase, TypeStorage> {
public:
using Base::Base;
-
PluginTypeID getPluginTypeID ();
-
}; // class PluginBooleanType
} // namespace PluginIR
diff --git a/include/PluginAPI/BasicPluginOpsAPI.h b/include/PluginAPI/BasicPluginOpsAPI.h
index 68abaef..0ca0ac4 100644
--- a/include/PluginAPI/BasicPluginOpsAPI.h
+++ b/include/PluginAPI/BasicPluginOpsAPI.h
@@ -37,6 +37,14 @@ public:
BasicPluginOpsAPI() = default;
virtual ~BasicPluginOpsAPI() = default;
+ virtual int64_t GetInjectDataAddress() = 0;
+ virtual string GetDeclSourceFile(int64_t) = 0;
+ virtual string VariableName(int64_t) = 0;
+ virtual string FuncName(int64_t) = 0;
+ virtual string GetIncludeFile() = 0;
+ virtual int GetDeclSourceLine(int64_t) = 0;
+ virtual int GetDeclSourceColumn(int64_t) = 0;
+
virtual vector<FunctionOp> GetAllFunc() = 0;
virtual vector<LocalDeclOp> GetDecls(uint64_t) = 0;
virtual LoopOp AllocateNewLoop(uint64_t) = 0;
@@ -74,4 +82,4 @@ public:
}; // class BasicPluginOpsAPI
} // namespace PluginAPI
-#endif // BASIC_PLUGIN_OPS_FRAMEWORK_API_H
\ No newline at end of file
+#endif // BASIC_PLUGIN_OPS_FRAMEWORK_API_H
diff --git a/include/PluginAPI/PluginServerAPI.h b/include/PluginAPI/PluginServerAPI.h
index 360ffbd..0655d80 100644
--- a/include/PluginAPI/PluginServerAPI.h
+++ b/include/PluginAPI/PluginServerAPI.h
@@ -52,8 +52,8 @@ public:
vector<pair<mlir::Block*, mlir::Block*> > GetLoopExitEdges(uint64_t loopID);
mlir::Block* GetHeader(uint64_t loopID);
mlir::Block* GetLatch(uint64_t loopID);
- void SetHeader(uint64_t loopID, uint64_t blockID);
- void SetLatch(uint64_t loopID, uint64_t blockID);
+ void SetHeader(uint64_t loopID, uint64_t blockID);
+ void SetLatch(uint64_t loopID, uint64_t blockID);
vector<mlir::Block*> GetLoopBody(uint64_t loopID);
LoopOp GetBlockLoopFather(uint64_t blockID);
mlir::Block* FindBlock(uint64_t);
@@ -73,7 +73,7 @@ public:
PhiOp CreatePhiOp(uint64_t, uint64_t) override;
/* Plugin API for ConstOp. */
mlir::Value CreateConstOp(mlir::Attribute, mlir::Type) override;
- void DebugValue(uint64_t) override;
+ void DebugValue(uint64_t) override;
mlir::Value GetCurrentDefFromSSA(uint64_t) override;
bool SetCurrentDefInSSA(uint64_t, uint64_t) override;
@@ -84,16 +84,15 @@ public:
bool RedirectFallthroughTarget(FallThroughOp&, uint64_t, uint64_t) override;
mlir::Operation* GetSSADefOperation(uint64_t) override;
void InsertCreatedBlock(uint64_t id, mlir::Block* block);
- void WaitClientResult(const string& funName, const string& params);
+ int64_t GetInjectDataAddress() override; // 获取注入点返回数据的地址
+ string GetDeclSourceFile(int64_t) override;
+ string VariableName(int64_t) override;
+ string FuncName(int64_t) override;
+ string GetIncludeFile() override;
+ int GetDeclSourceLine(int64_t) override;
+ int GetDeclSourceColumn(int64_t) override;
private:
- vector<FunctionOp> GetFunctionOpResult(const string& funName, const string& params);
- vector<LocalDeclOp> GetDeclOperationResult(const string& funName, const string& params);
- LoopOp GetLoopResult(const string&funName, const string& params);
- vector<LoopOp> GetLoopsResult(const string& funName, const string& params);
- bool GetBoolResult(const string& funName, const string& params);
- pair<mlir::Block*, mlir::Block*> EdgeResult(const string& funName, const string& params);
- vector<pair<mlir::Block*, mlir::Block*> > EdgesResult(const string& funName, const string& params);
mlir::Block* BlockResult(const string& funName, const string& params);
vector<mlir::Block*> BlocksResult(const string& funName, const string& params);
bool GetDomInfoAvaiResult(const string& funName);
diff --git a/include/PluginServer/ManagerSetup.h b/include/PluginServer/ManagerSetup.h
new file mode 100755
index 0000000..27ba930
--- /dev/null
+++ b/include/PluginServer/ManagerSetup.h
@@ -0,0 +1,67 @@
+/* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. You may obtain
+ a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ License for the specific language governing permissions and limitations
+ under the License.
+
+ Author: Mingchuan Wu and Yancheng Li
+ Create: 2022-08-18
+ Description:
+ This file contains the declaration of the ManagerSetup class.
+ 主要完成功能:提供managerSetup注册方法
+*/
+
+#ifndef MANAGER_SETUP_H
+#define MANAGER_SETUP_H
+
+namespace PluginOpt {
+enum RefPassName {
+ PASS_CFG,
+ PASS_PHIOPT,
+ PASS_SSA,
+ PASS_LOOP,
+};
+
+enum PassPosition {
+ PASS_INSERT_AFTER,
+ PASS_INSERT_BEFORE,
+ PASS_REPLACE,
+};
+
+class ManagerSetup {
+public:
+ ManagerSetup(RefPassName name, int num, PassPosition position)
+ {
+ refPassName = name;
+ passNum = num;
+ passPosition = position;
+ }
+ RefPassName GetPassName()
+ {
+ return refPassName;
+ }
+ int GetPassNum()
+ {
+ return passNum;
+ }
+ PassPosition GetPassPosition()
+ {
+ return passPosition;
+ }
+
+private:
+ RefPassName refPassName;
+ int passNum; // 指定passName的第几次执行作为参考点
+ PassPosition passPosition; // 指定pass是添加在参考点之前还是之后
+};
+} // namespace PinOpt
+
+#endif
\ No newline at end of file
diff --git a/include/PluginServer/PluginCom.h b/include/PluginServer/PluginCom.h
new file mode 100755
index 0000000..6535362
--- /dev/null
+++ b/include/PluginServer/PluginCom.h
@@ -0,0 +1,90 @@
+/* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. You may obtain
+ a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ License for the specific language governing permissions and limitations
+ under the License.
+
+ Author: Mingchuan Wu and Yancheng Li
+ Create: 2022-08-18
+ Description:
+ This file contains the declaration of the PluginCom class.
+ 主要完成功能:和client之间通信、数据解析、数据反序列化
+*/
+
+#ifndef PLUGIN_COM_H
+#define PLUGIN_COM_H
+
+#include "Dialect/PluginOps.h"
+#include "Dialect/PluginTypes.h"
+#include "PluginServer/PluginJson.h"
+#include "PluginServer/PluginGrpc.h"
+
+namespace PinCom {
+using PinGrpc::PluginGrpc;
+using PinJson::PluginJson;
+using std::vector;
+using std::string;
+
+class PluginCom {
+public:
+ bool RegisterServer(const string& port)
+ {
+ return pluginGrpc.RegisterServer(port);
+ }
+ void Run()
+ {
+ pluginGrpc.Run();
+ }
+ void ShutDown()
+ {
+ pluginGrpc.ShutDown();
+ }
+ void ServerSend(const string& key, const string& value)
+ {
+ pluginGrpc.ServerSend(key, value);
+ }
+ /* json反序列化,根据key值分别调用Operation/Decl/Type反序列化接口函数 */
+ void JsonDeSerialize(const string& key, const string& data);
+ int64_t GetIntegerDataResult(void);
+ string GetStringDataResult(void);
+ vector<mlir::Plugin::FunctionOp> GetFunctionOpResult(void);
+ vector<mlir::Plugin::LocalDeclOp> GetLocalDeclResult(void);
+ mlir::Plugin::LoopOp LoopOpResult(void);
+ vector<mlir::Plugin::LoopOp> LoopOpsResult(void);
+ vector<std::pair<mlir::Block*, mlir::Block*> > EdgesResult(void);
+ std::pair<mlir::Block*, mlir::Block*> EdgeResult(void);
+ vector<mlir::Operation *> GetOpResult(void);
+ bool GetBoolResult(void);
+ uint64_t GetIdResult(void);
+ vector<uint64_t> GetIdsResult(void);
+ mlir::Value GetValueResult(void);
+ vector<mlir::Plugin::PhiOp> GetPhiOpsResult(void);
+
+private:
+ PluginGrpc pluginGrpc;
+ PluginJson json;
+ int64_t integerResult;
+ string stringResult;
+ vector<mlir::Plugin::FunctionOp> funcOpData;
+ vector<mlir::Plugin::LocalDeclOp> decls;
+ vector<mlir::Plugin::LoopOp> loops;
+ mlir::Plugin::LoopOp loop;
+ vector<std::pair<mlir::Block*, mlir::Block*> > edges;
+ std::pair<mlir::Block*, mlir::Block*> edge;
+ vector<mlir::Operation *> opData;
+ bool boolResult;
+ uint64_t idResult;
+ vector<uint64_t> idsResult;
+ mlir::Value valueResult;
+};
+} // namespace PinCom
+
+#endif
\ No newline at end of file
diff --git a/include/PluginServer/PluginGrpc.h b/include/PluginServer/PluginGrpc.h
new file mode 100755
index 0000000..9d30dce
--- /dev/null
+++ b/include/PluginServer/PluginGrpc.h
@@ -0,0 +1,65 @@
+/* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. You may obtain
+ a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ License for the specific language governing permissions and limitations
+ under the License.
+
+ Author: Mingchuan Wu and Yancheng Li
+ Create: 2022-08-18
+ Description:
+ This file contains the declaration of the GrpcService class.
+ 主要完成功能:完成grpc server服务的注册,提供server和client之间grpc收发接口
+*/
+
+#ifndef PLUGIN_GRPC_H
+#define PLUGIN_GRPC_H
+
+#include <grpcpp/grpcpp.h>
+#include "plugin.grpc.pb.h"
+
+namespace PinGrpc {
+using grpc::Server;
+using grpc::ServerBuilder;
+using grpc::ServerContext;
+using grpc::ServerReaderWriter;
+using grpc::Status;
+
+using plugin::PluginService;
+using plugin::ClientMsg;
+using plugin::ServerMsg;
+using std::string;
+
+class PluginGrpc final : public PluginService::Service {
+public:
+ PluginGrpc()
+ {
+ shutdown = false;
+ }
+ /* 定义的grpc服务端和客户端通信的接口函数 */
+ Status ReceiveSendMsg(ServerContext* context, ServerReaderWriter<ServerMsg, ClientMsg>* stream) override;
+ /* 服务端发送数据给client接口 */
+ void ServerSend(const string& key, const string& value);
+ bool RegisterServer(const string& port);
+ void Run();
+ void ShutDown()
+ {
+ shutdown = true;
+ }
+
+private:
+ void ServerMonitorThread(); // 监听线程,shutdown为true时,grpc server退出
+ bool shutdown; // 是否关闭grpc server
+ ServerReaderWriter<ServerMsg, ClientMsg> *grpcStream; // 保存server和client通信的grpc stream指针
+ std::unique_ptr<Server> grpcServer;
+};
+} // namespace PinGrpc
+
+#endif
diff --git a/include/PluginServer/PluginJson.h b/include/PluginServer/PluginJson.h
new file mode 100755
index 0000000..6f46187
--- /dev/null
+++ b/include/PluginServer/PluginJson.h
@@ -0,0 +1,68 @@
+/* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. You may obtain
+ a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ License for the specific language governing permissions and limitations
+ under the License.
+
+ Author: Mingchuan Wu and Yancheng Li
+ Create: 2022-08-18
+ Description:
+ This file contains the declaration of the PluginJson class.
+ 主要完成功能:将序列化数据进行反序列化
+*/
+
+#ifndef PLUGIN_JSON_H
+#define PLUGIN_JSON_H
+
+#include <json/json.h>
+#include "Dialect/PluginOps.h"
+#include "Dialect/PluginTypes.h"
+
+using std::string;
+using std::map;
+using std::vector;
+
+namespace PinJson {
+class PluginJson {
+public:
+ void FuncOpJsonDeSerialize(const string&, vector<mlir::Plugin::FunctionOp>&);
+ void LocalDeclOpJsonDeSerialize(const string&,
+ vector<mlir::Plugin::LocalDeclOp>&);
+ void LoopOpsJsonDeSerialize(const string&, vector<mlir::Plugin::LoopOp>&);
+ void EdgesJsonDeSerialize(const string&,
+ vector<std::pair<mlir::Block*, mlir::Block*>>&);
+ void EdgeJsonDeSerialize(const string&, std::pair<mlir::Block*, mlir::Block*>&);
+ void IdsJsonDeSerialize(const string&, vector<uint64_t>&);
+ mlir::Operation *CallOpJsonDeSerialize(const string&);
+ mlir::Operation *CondOpJsonDeSerialize(const string&);
+ mlir::Operation *RetOpJsonDeSerialize(const string&);
+ mlir::Operation *FallThroughOpJsonDeSerialize(const string&);
+ mlir::Operation *PhiOpJsonDeSerialize(const string&);
+ mlir::Operation *AssignOpJsonDeSerialize(const string&);
+ void GetPhiOpsJsonDeSerialize(const string&, vector<mlir::Operation *>&);
+ mlir::Value SSAOpJsonDeSerialize(const string& data);
+ mlir::Plugin::LoopOp LoopOpJsonDeSerialize(const string& data);
+ PluginIR::PluginTypeBase TypeJsonDeSerialize(const string& data);
+ void OpJsonDeSerialize(const string&, vector<mlir::Operation *>&);
+ /* 将整形数据反序列化 */
+ void IntegerDeSerialize(const string& data, int64_t& result);
+ /* 将字符串数据反序列化 */
+ void StringDeSerialize(const string& data, string& result);
+ /* 将json格式数据解析成map<string, string>格式 */
+ void GetAttributes(Json::Value node, map<string, string>& attributes);
+ mlir::Value ValueJsonDeSerialize(Json::Value valueJson);
+ Json::Value TypeJsonSerialize(PluginIR::PluginTypeBase& type);
+ mlir::Value MemRefDeSerialize(const string& data);
+ bool ProcessBlock(mlir::Block*, mlir::Region&, const Json::Value&);
+};
+} // namespace PinJson
+
+#endif
diff --git a/include/user/user.h b/include/user/user.h
new file mode 100755
index 0000000..1fb7a30
--- /dev/null
+++ b/include/user/user.h
@@ -0,0 +1,27 @@
+/* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. You may obtain
+ a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ License for the specific language governing permissions and limitations
+ under the License.
+
+ Author: Mingchuan Wu and Yancheng Li
+ Create: 2022-08-18
+ Description:
+ This file contains the declaration of the User Init.
+*/
+
+#ifndef PLUGIN_USER_H
+#define PLUGIN_USER_H
+
+/* 将注册点及用户函数注册给server, server初始化时调用 */
+void RegisterCallbacks(void);
+
+#endif
diff --git a/lib/Dialect/PluginDialect.cpp b/lib/Dialect/PluginDialect.cpp
index 001fdab..95b38cf 100644
--- a/lib/Dialect/PluginDialect.cpp
+++ b/lib/Dialect/PluginDialect.cpp
@@ -14,11 +14,11 @@
*/
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
//
// This file defines Plugin dialect.
//
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
#include "Dialect/PluginDialect.h"
#include "Dialect/PluginOps.h"
@@ -27,21 +27,22 @@
using namespace mlir;
using namespace mlir::Plugin;
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// Plugin dialect.
-//===----------------------------------------------------------------------===//
-
-void PluginDialect::initialize() {
- addTypes<
- PluginIR::PluginIntegerType,
- PluginIR::PluginFloatType,
- PluginIR::PluginPointerType,
- PluginIR::PluginBooleanType,
- PluginIR::PluginVoidType,
- PluginIR::PluginUndefType>();
-
- addOperations<
+// ===----------------------------------------------------------------------===//
+
+void PluginDialect::initialize()
+{
+ addTypes<
+ PluginIR::PluginIntegerType,
+ PluginIR::PluginFloatType,
+ PluginIR::PluginPointerType,
+ PluginIR::PluginBooleanType,
+ PluginIR::PluginVoidType,
+ PluginIR::PluginUndefType>();
+
+ addOperations<
#define GET_OP_LIST
#include "Dialect/PluginOps.cpp.inc"
- >();
+ >();
}
\ No newline at end of file
diff --git a/lib/Dialect/PluginOps.cpp b/lib/Dialect/PluginOps.cpp
index 4d8974a..a0591b5 100644
--- a/lib/Dialect/PluginOps.cpp
+++ b/lib/Dialect/PluginOps.cpp
@@ -14,11 +14,11 @@
*/
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
//
// This file defines operations in the Plugin dialect.
//
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
#include "PluginAPI/PluginServerAPI.h"
#include "PluginAPI/ControlFlowAPI.h"
@@ -105,7 +105,8 @@ void LocalDeclOp::build(OpBuilder &builder, OperationState &state,
void LoopOp::build(mlir::OpBuilder &builder, mlir::OperationState &state,
uint64_t id, uint32_t index, uint64_t innerLoopId,
- uint64_t outerLoopId, uint32_t numBlock) {
+ uint64_t outerLoopId, uint32_t numBlock)
+{
LoopOp::build(builder, state,
builder.getI64IntegerAttr(id),
builder.getI32IntegerAttr(index),
@@ -219,7 +220,7 @@ void LoopOp::AddBlock(mlir::Block* block)
pluginAPI.AddBlockToLoop(blockId, loopId);
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// PlaceholderOp
void PlaceholderOp::build(OpBuilder &builder, OperationState &state,
@@ -233,7 +234,7 @@ void PlaceholderOp::build(OpBuilder &builder, OperationState &state,
state.addTypes(retType);
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// MemOp
void MemOp::build(OpBuilder &builder, OperationState &state,
@@ -248,7 +249,7 @@ void MemOp::build(OpBuilder &builder, OperationState &state,
if (retType) state.addTypes(retType);
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// SSAOp
void SSAOp::build(OpBuilder &builder, OperationState &state, uint64_t id,
@@ -270,23 +271,23 @@ void SSAOp::build(OpBuilder &builder, OperationState &state, uint64_t id,
Value SSAOp::MakeSSA(OpBuilder &builder, Type t)
{
PluginAPI::PluginServerAPI pluginAPI;
- PinServer::PluginServer::GetInstance()->SetOpBuilder(builder);
+ PinServer::PluginServer::GetInstance()->SetOpBuilder(&builder);
return pluginAPI.CreateSSAOp(t);
}
Value SSAOp::Copy()
{
PluginAPI::PluginServerAPI pluginAPI;
- OpBuilder builder(this->getOperation());
- PinServer::PluginServer::GetInstance()->SetOpBuilder(builder);
+ static OpBuilder builder(this->getOperation());
+ PinServer::PluginServer::GetInstance()->SetOpBuilder(&builder);
return pluginAPI.CopySSAOp(this->idAttr().getInt());
}
Value SSAOp::GetCurrentDef()
{
PluginAPI::PluginServerAPI pluginAPI;
- OpBuilder builder(this->getOperation());
- PinServer::PluginServer::GetInstance()->SetOpBuilder(builder);
+ static OpBuilder builder(this->getOperation());
+ PinServer::PluginServer::GetInstance()->SetOpBuilder(&builder);
return pluginAPI.GetCurrentDefFromSSA(this->idAttr().getInt());
}
@@ -307,7 +308,7 @@ Operation* SSAOp::GetSSADefOperation()
return pluginAPI.GetSSADefOperation(definingId);
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// ConstOp
void ConstOp::build(OpBuilder &builder, OperationState &state, uint64_t id,
@@ -325,11 +326,11 @@ void ConstOp::build(OpBuilder &builder, OperationState &state, uint64_t id,
Value ConstOp::CreateConst(OpBuilder &builder, Attribute value, Type retType)
{
PluginAPI::PluginServerAPI pluginAPI;
- PinServer::PluginServer::GetInstance()->SetOpBuilder(builder);
+ PinServer::PluginServer::GetInstance()->SetOpBuilder(&builder);
return pluginAPI.CreateConstOp(value, retType);
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// PointerOp
void PointerOp::build(OpBuilder &builder, OperationState &state, uint64_t id,
@@ -344,7 +345,7 @@ void PointerOp::build(OpBuilder &builder, OperationState &state, uint64_t id,
state.addAttribute("pointeeReadOnly", builder.getBoolAttr(pointeeReadOnly));
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// CallOp
void CallOp::build(OpBuilder &builder, OperationState &state,
@@ -414,13 +415,14 @@ void CallOp::build(OpBuilder &builder, OperationState &state,
state.addAttribute("callee", builder.getSymbolRefAttr("ctzll"));
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// CondOp
void CondOp::build(OpBuilder &builder, OperationState &state,
uint64_t id, uint64_t address, IComparisonCode condCode,
Value lhs, Value rhs, Block* tb, Block* fb, uint64_t tbaddr,
- uint64_t fbaddr, Value trueLabel, Value falseLabel) {
+ uint64_t fbaddr, Value trueLabel, Value falseLabel)
+{
state.addAttribute("id", builder.getI64IntegerAttr(id));
state.addAttribute("address", builder.getI64IntegerAttr(address));
state.addAttribute("tbaddr", builder.getI64IntegerAttr(tbaddr));
@@ -449,19 +451,18 @@ void CondOp::build(OpBuilder &builder, OperationState &state,
state.addAttribute("id", builder.getI64IntegerAttr(id));
state.addOperands({lhs, rhs});
state.addAttribute("condCode",
- builder.getI32IntegerAttr(static_cast<int32_t>(condCode)));
+ builder.getI32IntegerAttr(static_cast<int32_t>(condCode)));
state.addSuccessors(tb);
state.addSuccessors(fb);
state.addAttribute("tbaddr", builder.getI64IntegerAttr(tbaddr));
state.addAttribute("fbaddr", builder.getI64IntegerAttr(fbaddr));
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// PhiOp
void PhiOp::build(OpBuilder &builder, OperationState &state,
- ArrayRef<Value> operands, uint64_t id,
- uint32_t capacity, uint32_t nArgs)
+ ArrayRef<Value> operands, uint64_t id, uint32_t capacity, uint32_t nArgs)
{
state.addAttribute("id", builder.getI64IntegerAttr(id));
state.addAttribute("capacity", builder.getI32IntegerAttr(capacity));
@@ -472,8 +473,8 @@ void PhiOp::build(OpBuilder &builder, OperationState &state,
Value PhiOp::GetResult()
{
PluginAPI::PluginServerAPI pluginAPI;
- OpBuilder builder(this->getOperation());
- PinServer::PluginServer::GetInstance()->SetOpBuilder(builder);
+ static OpBuilder builder(this->getOperation());
+ PinServer::PluginServer::GetInstance()->SetOpBuilder(&builder);
return pluginAPI.GetResultFromPhi(this->idAttr().getInt());
}
@@ -507,7 +508,7 @@ Value PhiOp::GetArgDef(int i)
}
return getOperand(i);
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// AssignOp
void AssignOp::build(OpBuilder &builder, OperationState &state,
@@ -538,7 +539,7 @@ void AssignOp::build(OpBuilder &builder, OperationState &state,
state.addOperands(operands);
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// BaseOp
void BaseOp::build(OpBuilder &builder, OperationState &state,
@@ -548,7 +549,7 @@ void BaseOp::build(OpBuilder &builder, OperationState &state,
state.addAttribute("opCode", builder.getStringAttr(opCode));
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// FallThroughOp
void FallThroughOp::build(OpBuilder &builder, OperationState &state,
@@ -572,7 +573,7 @@ void FallThroughOp::build(OpBuilder &builder, OperationState &state,
state.addSuccessors(dest);
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// RetOp
void RetOp::build(OpBuilder &builder, OperationState &state, uint64_t address)
@@ -580,9 +581,9 @@ void RetOp::build(OpBuilder &builder, OperationState &state, uint64_t address)
state.addAttribute("address", builder.getI64IntegerAttr(address));
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// TableGen'd op method definitions
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
#define GET_OP_CLASSES
#include "Dialect/PluginOps.cpp.inc"
\ No newline at end of file
diff --git a/lib/Dialect/PluginTypes.cpp b/lib/Dialect/PluginTypes.cpp
index c33d9e0..c0a58c2 100644
--- a/lib/Dialect/PluginTypes.cpp
+++ b/lib/Dialect/PluginTypes.cpp
@@ -36,16 +36,19 @@ namespace detail {
/// The hash key used for uniquing.
using KeyTy = std::pair<unsigned, PluginIntegerType::SignednessSemantics>;
- static llvm::hash_code hashKey(const KeyTy &key) {
+ static llvm::hash_code hashKey(const KeyTy &key)
+ {
return llvm::hash_value(key);
}
- bool operator==(const KeyTy &key) const {
+ bool operator==(const KeyTy &key) const
+ {
return KeyTy(width, signedness) == key;
}
static PluginIntegerTypeStorage *construct(TypeStorageAllocator &allocator,
- KeyTy key) {
+ KeyTy key)
+ {
return new (allocator.allocate<PluginIntegerTypeStorage>())
PluginIntegerTypeStorage(key.first, key.second);
}
@@ -60,12 +63,13 @@ namespace detail {
/// The hash key used for uniquing.
using KeyTy = unsigned;
- bool operator==(const KeyTy &key) const {
+ bool operator==(const KeyTy &key) const
+ {
return KeyTy(width) == key;
}
- static PluginFloatTypeStorage *construct(TypeStorageAllocator &allocator,
- KeyTy key) {
+ static PluginFloatTypeStorage *construct(TypeStorageAllocator &allocator, KeyTy key)
+ {
return new (allocator.allocate<PluginFloatTypeStorage>())
PluginFloatTypeStorage(key);
}
@@ -79,13 +83,14 @@ namespace detail {
PluginPointerTypeStorage(const KeyTy &key)
: pointee(std::get<0>(key)), readOnlyPointee(std::get<1>(key)) {}
- static PluginPointerTypeStorage *construct(TypeStorageAllocator &allocator,
- KeyTy key) {
+ static PluginPointerTypeStorage *construct(TypeStorageAllocator &allocator, KeyTy key)
+ {
return new (allocator.allocate<PluginPointerTypeStorage>())
PluginPointerTypeStorage(key);
}
- bool operator==(const KeyTy &key) const {
+ bool operator==(const KeyTy &key) const
+ {
return std::make_tuple(pointee, readOnlyPointee) == key;
}
@@ -96,9 +101,9 @@ namespace detail {
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// Plugin TypeBase
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
PluginTypeID PluginTypeBase::getPluginTypeID ()
{
@@ -117,7 +122,7 @@ PluginTypeID PluginTypeBase::getPluginTypeID ()
if (auto Ty = dyn_cast<PluginIR::PluginPointerType>()) {
return Ty.getPluginTypeID ();
}
- return PluginTypeID::UndefTyID;
+ return PluginTypeID::UndefTyID;
}
unsigned PluginTypeBase::getPluginIntOrFloatBitWidth ()
@@ -157,9 +162,9 @@ unsigned PluginTypeBase::getTypeSize ()
return size;
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// Plugin Integer Type
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
unsigned PluginIntegerType::getWidth() const
{
@@ -173,10 +178,8 @@ PluginIntegerType::SignednessSemantics PluginIntegerType::getSignedness() const
PluginTypeID PluginIntegerType::getPluginTypeID()
{
- if (isSigned())
- {
- switch (getWidth())
- {
+ if (isSigned()) {
+ switch (getWidth()) {
case 1:
return PluginTypeID::IntegerTy1ID;
case 8:
@@ -191,10 +194,8 @@ PluginTypeID PluginIntegerType::getPluginTypeID()
return PluginTypeID::UndefTyID;
}
}
- if (isUnsigned())
- {
- switch (getWidth())
- {
+ if (isUnsigned()) {
+ switch (getWidth()) {
case 1:
return PluginTypeID::UIntegerTy1ID;
case 8:
@@ -212,15 +213,15 @@ PluginTypeID PluginIntegerType::getPluginTypeID()
return PluginTypeID::UndefTyID;
}
-PluginIntegerType PluginIntegerType::get (MLIRContext *context, unsigned width, PluginIntegerType::SignednessSemantics signedness)
+PluginIntegerType PluginIntegerType::get (MLIRContext *context, unsigned width,
+ PluginIntegerType::SignednessSemantics signedness)
{
return Base::get(context, width, signedness);
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// Plugin Float Type
-//===----------------------------------------------------------------------===//
-
+// ===----------------------------------------------------------------------===//
unsigned PluginFloatType::getWidth () const
{
return getImpl()->width;
@@ -228,10 +229,12 @@ unsigned PluginFloatType::getWidth () const
PluginTypeID PluginFloatType::getPluginTypeID()
{
- if (getWidth() == 32)
+ if (getWidth() == 32) {
return PluginTypeID::FloatTyID;
- if (getWidth() == 64)
+ }
+ if (getWidth() == 64) {
return PluginTypeID::DoubleTyID;
+ }
return PluginTypeID::UndefTyID;
}
@@ -240,36 +243,36 @@ PluginFloatType PluginFloatType::get (MLIRContext *context, unsigned width)
return Base::get(context, width);
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// Plugin Boolean Type
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
PluginTypeID PluginBooleanType::getPluginTypeID()
{
return PluginTypeID::BooleanTyID;
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// Plugin Void Type
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
PluginTypeID PluginVoidType::getPluginTypeID()
{
return PluginTypeID::VoidTyID;
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// Plugin Undef Type
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
PluginTypeID PluginUndefType::getPluginTypeID()
{
return PluginTypeID::UndefTyID;
}
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
// Plugin Pointer Type
-//===----------------------------------------------------------------------===//
+// ===----------------------------------------------------------------------===//
PluginTypeID PluginPointerType::getPluginTypeID()
{
diff --git a/lib/PluginAPI/ControlFlowAPI.cpp b/lib/PluginAPI/ControlFlowAPI.cpp
index b598f57..92c0dd3 100644
--- a/lib/PluginAPI/ControlFlowAPI.cpp
+++ b/lib/PluginAPI/ControlFlowAPI.cpp
@@ -15,7 +15,6 @@
*/
#include "PluginAPI/ControlFlowAPI.h"
-#include "PluginServer/PluginLog.h"
namespace PluginAPI {
using namespace PinServer;
@@ -60,20 +59,18 @@ bool ControlFlowAPI::UpdateSSA(void)
bool ControlFlowAPI::GetUpdateOperationResult(const string &funName)
{
Json::Value root;
- pluginAPI.WaitClientResult(funName, root.toStyledString());
- return PluginServer::GetInstance()->GetBoolResult();
+ return PluginServer::GetInstance()->GetBoolResult(funName, root.toStyledString());
}
vector<PhiOp> ControlFlowAPI::GetPhiOperationResult(const string &funName, const string& params)
{
- pluginAPI.WaitClientResult(funName, params);;
- vector<PhiOp> retOps = PluginServer::GetInstance()->GetPhiOpsResult();
+ vector<PhiOp> retOps = PluginServer::GetInstance()->GetPhiOpsResult(funName, params);
return retOps;
}
void ControlFlowAPI::GetDominatorSetOperationResult(const string &funName, const string& params)
{
- pluginAPI.WaitClientResult(funName, params);;
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
return;
}
@@ -97,12 +94,11 @@ uint64_t ControlFlowAPI::CreateBlock(mlir::Block* b, uint64_t funcAddr, uint64_t
root["funcaddr"] = std::to_string(funcAddr);
root["bbaddr"] = std::to_string(bbAddr);
string params = root.toStyledString();
- pluginAPI.WaitClientResult(funName, params);;
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
return PluginServer::GetInstance()->GetBlockResult(b);
}
-void ControlFlowAPI::DeleteBlock(mlir::Block* b, uint64_t funcAddr,
- uint64_t bbAddr)
+void ControlFlowAPI::DeleteBlock(mlir::Block* b, uint64_t funcAddr, uint64_t bbAddr)
{
Json::Value root;
string funName = __func__;
@@ -111,14 +107,12 @@ void ControlFlowAPI::DeleteBlock(mlir::Block* b, uint64_t funcAddr,
root["funcaddr"] = std::to_string(funcAddr);
root["bbaddr"] = std::to_string(bbAddr);
string params = root.toStyledString();
- pluginAPI.WaitClientResult(funName, params);;
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
PluginServer::GetInstance()->EraseBlock(b);
- // b->erase();
}
/* dir: 1 or 2 */
-void ControlFlowAPI::SetImmediateDominator(uint64_t dir, uint64_t bbAddr,
- uint64_t domiAddr)
+void ControlFlowAPI::SetImmediateDominator(uint64_t dir, uint64_t bbAddr, uint64_t domiAddr)
{
Json::Value root;
string funName = __func__;
@@ -128,7 +122,7 @@ void ControlFlowAPI::SetImmediateDominator(uint64_t dir, uint64_t bbAddr,
root["bbaddr"] = std::to_string(bbAddr);
root["domiaddr"] = std::to_string(domiAddr);
string params = root.toStyledString();
- pluginAPI.WaitClientResult(funName, params);;
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
}
/* dir: 1 or 2 */
@@ -140,8 +134,7 @@ uint64_t ControlFlowAPI::GetImmediateDominator(uint64_t dir, uint64_t bbAddr)
root["dir"] = std::to_string(dir);
root["bbaddr"] = std::to_string(bbAddr);
string params = root.toStyledString();
- pluginAPI.WaitClientResult(funName, params);;
- return PluginServer::GetInstance()->GetIdResult();
+ return PluginServer::GetInstance()->GetIdResult(funName, params);
}
/* dir: 1 or 2 */
@@ -153,8 +146,7 @@ uint64_t ControlFlowAPI::RecomputeDominator(uint64_t dir, uint64_t bbAddr)
root["dir"] = std::to_string(dir);
root["bbaddr"] = std::to_string(bbAddr);
string params = root.toStyledString();
- pluginAPI.WaitClientResult(funName, params);;
- return PluginServer::GetInstance()->GetIdResult();
+ return PluginServer::GetInstance()->GetIdResult(funName, params);
}
mlir::Value ControlFlowAPI::CreateNewDef(mlir::Value oldValue,
@@ -170,8 +162,7 @@ mlir::Value ControlFlowAPI::CreateNewDef(mlir::Value oldValue,
uint64_t defId = 0;
root["defId"] = std::to_string(defId);
string params = root.toStyledString();
- pluginAPI.WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetValueResult();
+ return PluginServer::GetInstance()->GetValueResult(funName, params);
}
void ControlFlowAPI::CreateFallthroughOp(
@@ -182,7 +173,7 @@ void ControlFlowAPI::CreateFallthroughOp(
root["address"] = std::to_string(address);
root["destaddr"] = std::to_string(destaddr);
string params = root.toStyledString();
- pluginAPI.WaitClientResult(funName, params);
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
}
void ControlFlowAPI::RemoveEdge(uint64_t src, uint64_t dest)
@@ -192,7 +183,7 @@ void ControlFlowAPI::RemoveEdge(uint64_t src, uint64_t dest)
root["src"] = std::to_string(src);
root["dest"] = std::to_string(dest);
string params = root.toStyledString();
- pluginAPI.WaitClientResult(funName, params);
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
}
} // namespace PluginAPI
diff --git a/lib/PluginAPI/PluginServerAPI.cpp b/lib/PluginAPI/PluginServerAPI.cpp
index 5ab27d7..523e08d 100644
--- a/lib/PluginAPI/PluginServerAPI.cpp
+++ b/lib/PluginAPI/PluginServerAPI.cpp
@@ -18,24 +18,27 @@
*/
#include "PluginAPI/PluginServerAPI.h"
-#include "PluginServer/PluginLog.h"
+#include "PluginServer/PluginJson.h"
namespace PluginAPI {
using namespace PinServer;
using namespace mlir::Plugin;
-int CheckAttribute(string &attribute)
+static bool CheckAttribute(string &attribute)
{
- /* if (attribute == "") {
+ if (attribute == "NULL") {
printf("param attribute is NULL,check fail!\n");
- return -1;
- } */
- return 0;
+ return false;
+ }
+ return true;
}
-int CheckID(uintptr_t id)
+static bool CheckID(uintptr_t id)
{
- return 0;
+ if (id == 0) {
+ return false;
+ }
+ return true;
}
static uint64_t GetValueId(mlir::Value v)
@@ -52,21 +55,60 @@ static uint64_t GetValueId(mlir::Value v)
}
return 0;
}
+int64_t PluginServerAPI::GetInjectDataAddress()
+{
+ string funName = __func__;
+ string params = "";
-void PluginServerAPI::WaitClientResult(const string& funName, const string& params)
+ return PluginServer::GetInstance()->GetIntegerDataResult(funName, params);
+}
+
+string PluginServerAPI::GetDeclSourceFile(int64_t clientDataAddr)
{
- PluginServer *server = PluginServer::GetInstance();
- server->SetApiFuncName(funName);
- server->SetApiFuncParams(params);
- server->SetUserFunState(STATE_BEGIN);
- server->SemPost();
- while (1) {
- server->ClientReturnSemWait();
- if (server->GetUserFunState() == STATE_RETURN) { // wait client result
- server->SetUserFunState(STATE_WAIT_BEGIN);
- break;
- }
- }
+ string funName = __func__;
+ string params = std::to_string(clientDataAddr);
+
+ return PluginServer::GetInstance()->GetStringDataResult(funName, params);
+}
+
+string PluginServerAPI::VariableName(int64_t clientDataAddr)
+{
+ string funName = __func__;
+ string params = std::to_string(clientDataAddr);
+
+ return PluginServer::GetInstance()->GetStringDataResult(funName, params);
+}
+
+string PluginServerAPI::FuncName(int64_t clientDataAddr)
+{
+ string funName = __func__;
+ string params = std::to_string(clientDataAddr);
+
+ return PluginServer::GetInstance()->GetStringDataResult(funName, params);
+}
+
+string PluginServerAPI::GetIncludeFile()
+{
+ string funName = __func__;
+ string params = "";
+
+ return PluginServer::GetInstance()->GetStringDataResult(funName, params);
+}
+
+int PluginServerAPI::GetDeclSourceLine(int64_t clientDataAddr)
+{
+ string funName = __func__;
+ string params = std::to_string(clientDataAddr);
+
+ return PluginServer::GetInstance()->GetIntegerDataResult(funName, params);
+}
+
+int PluginServerAPI::GetDeclSourceColumn(int64_t clientDataAddr)
+{
+ string funName = __func__;
+ string params = std::to_string(clientDataAddr);
+
+ return PluginServer::GetInstance()->GetIntegerDataResult(funName, params);
}
bool PluginServerAPI::SetCurrentDefInSSA(uint64_t varId, uint64_t defId)
@@ -76,8 +118,7 @@ bool PluginServerAPI::SetCurrentDefInSSA(uint64_t varId, uint64_t defId)
root["varId"] = std::to_string(varId);
root["defId"] = std::to_string(defId);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetBoolResult();
+ return PluginServer::GetInstance()->GetBoolResult(funName, params);
}
mlir::Value PluginServerAPI::GetCurrentDefFromSSA(uint64_t varId)
@@ -86,8 +127,7 @@ mlir::Value PluginServerAPI::GetCurrentDefFromSSA(uint64_t varId)
string funName = __func__;
root["varId"] = std::to_string(varId);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetValueResult();
+ return PluginServer::GetInstance()->GetValueResult(funName, params);
}
mlir::Value PluginServerAPI::CopySSAOp(uint64_t id)
@@ -96,8 +136,7 @@ mlir::Value PluginServerAPI::CopySSAOp(uint64_t id)
string funName = __func__;
root["id"] = std::to_string(id);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetValueResult();
+ return PluginServer::GetInstance()->GetValueResult(funName, params);
}
mlir::Value PluginServerAPI::CreateSSAOp(mlir::Type t)
@@ -105,17 +144,10 @@ mlir::Value PluginServerAPI::CreateSSAOp(mlir::Type t)
Json::Value root;
string funName = __func__;
auto baseTy = t.dyn_cast<PluginIR::PluginTypeBase>();
- root = PluginServer::GetInstance()->TypeJsonSerialize(baseTy);
+ PinJson::PluginJson json;
+ root = json.TypeJsonSerialize(baseTy);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetValueResult();
-}
-
-vector<FunctionOp> PluginServerAPI::GetFunctionOpResult(const string& funName, const string& params)
-{
- WaitClientResult(funName, params);
- vector<FunctionOp> retOps = PluginServer::GetInstance()->GetFunctionOpResult();
- return retOps;
+ return PluginServer::GetInstance()->GetValueResult(funName, params);
}
vector<FunctionOp> PluginServerAPI::GetAllFunc()
@@ -124,7 +156,7 @@ vector<FunctionOp> PluginServerAPI::GetAllFunc()
string funName = __func__;
string params = root.toStyledString();
- return GetFunctionOpResult(funName, params);
+ return PluginServer::GetInstance()->GetFunctionOpResult(funName, params);
}
PhiOp PluginServerAPI::GetPhiOp(uint64_t id)
@@ -133,8 +165,7 @@ PhiOp PluginServerAPI::GetPhiOp(uint64_t id)
string funName = __func__;
root["id"] = std::to_string(id);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- vector<mlir::Operation*> opRet = PluginServer::GetInstance()->GetOpResult();
+ vector<mlir::Operation*> opRet = PluginServer::GetInstance()->GetOpResult(funName, params);
return llvm::dyn_cast<PhiOp>(opRet[0]);
}
@@ -144,8 +175,7 @@ CallOp PluginServerAPI::GetCallOp(uint64_t id)
string funName = __func__;
root["id"] = std::to_string(id);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- vector<mlir::Operation*> opRet = PluginServer::GetInstance()->GetOpResult();
+ vector<mlir::Operation*> opRet = PluginServer::GetInstance()->GetOpResult(funName, params);
return llvm::dyn_cast<CallOp>(opRet[0]);
}
@@ -156,14 +186,10 @@ bool PluginServerAPI::SetLhsInCallOp(uint64_t callId, uint64_t lhsId)
root["callId"] = std::to_string(callId);
root["lhsId"] = std::to_string(lhsId);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetBoolResult();
+ return PluginServer::GetInstance()->GetBoolResult(funName, params);
}
-uint32_t PluginServerAPI::AddArgInPhiOp(uint64_t phiId,
- uint64_t argId,
- uint64_t predId,
- uint64_t succId)
+uint32_t PluginServerAPI::AddArgInPhiOp(uint64_t phiId, uint64_t argId, uint64_t predId, uint64_t succId)
{
Json::Value root;
string funName = __func__;
@@ -172,8 +198,7 @@ uint32_t PluginServerAPI::AddArgInPhiOp(uint64_t phiId,
root["predId"] = std::to_string(predId);
root["succId"] = std::to_string(succId);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetIdResult();
+ return PluginServer::GetInstance()->GetIdResult(funName, params);
}
uint64_t PluginServerAPI::CreateCondOp(uint64_t blockId, IComparisonCode iCode,
@@ -189,8 +214,7 @@ uint64_t PluginServerAPI::CreateCondOp(uint64_t blockId, IComparisonCode iCode,
root["tbaddr"] = std::to_string(tbaddr);
root["fbaddr"] = std::to_string(fbaddr);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetIdResult();
+ return PluginServer::GetInstance()->GetIdResult(funName, params);
}
uint64_t PluginServerAPI::CreateAssignOp(uint64_t blockId, IExprCode iCode, vector<uint64_t> &argIds)
@@ -207,8 +231,7 @@ uint64_t PluginServerAPI::CreateAssignOp(uint64_t blockId, IExprCode iCode, vect
}
root["argIds"] = item;
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetIdResult();
+ return PluginServer::GetInstance()->GetIdResult(funName, params);
}
uint64_t PluginServerAPI::CreateCallOp(uint64_t blockId, uint64_t funcId,
@@ -226,8 +249,7 @@ uint64_t PluginServerAPI::CreateCallOp(uint64_t blockId, uint64_t funcId,
}
root["argIds"] = item;
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetIdResult();
+ return PluginServer::GetInstance()->GetIdResult(funName, params);
}
mlir::Value PluginServerAPI::CreateConstOp(mlir::Attribute attr, mlir::Type type)
@@ -235,15 +257,15 @@ mlir::Value PluginServerAPI::CreateConstOp(mlir::Attribute attr, mlir::Type type
Json::Value root;
string funName = __func__;
auto baseTy = type.dyn_cast<PluginIR::PluginTypeBase>();
- root = PluginServer::GetInstance()->TypeJsonSerialize(baseTy);
+ PinJson::PluginJson json;
+ root = json.TypeJsonSerialize(baseTy);
string valueStr;
if (type.isa<PluginIR::PluginIntegerType>()) {
valueStr = std::to_string(attr.cast<mlir::IntegerAttr>().getInt());
}
root["value"] = valueStr;
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetValueResult();
+ return PluginServer::GetInstance()->GetValueResult(funName, params);
}
mlir::Value PluginServerAPI::GetResultFromPhi(uint64_t phiId)
@@ -252,8 +274,7 @@ mlir::Value PluginServerAPI::GetResultFromPhi(uint64_t phiId)
string funName = __func__;
root["id"] = std::to_string(phiId);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetValueResult();
+ return PluginServer::GetInstance()->GetValueResult(funName, params);
}
PhiOp PluginServerAPI::CreatePhiOp(uint64_t argId, uint64_t blockId)
@@ -263,8 +284,7 @@ PhiOp PluginServerAPI::CreatePhiOp(uint64_t argId, uint64_t blockId)
root["blockId"] = std::to_string(blockId);
root["argId"] = std::to_string(argId);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- vector<mlir::Operation*> opRet = PluginServer::GetInstance()->GetOpResult();
+ vector<mlir::Operation*> opRet = PluginServer::GetInstance()->GetOpResult(funName, params);
return llvm::dyn_cast<PhiOp>(opRet[0]);
}
@@ -275,8 +295,7 @@ mlir::Value PluginServerAPI::ConfirmValue(mlir::Value v)
uint64_t valId = GetValueId(v);
root["valId"] = std::to_string(valId);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetValueResult();
+ return PluginServer::GetInstance()->GetValueResult(funName, params);
}
mlir::Value PluginServerAPI::BuildMemRef(PluginIR::PluginTypeBase type,
@@ -288,55 +307,47 @@ mlir::Value PluginServerAPI::BuildMemRef(PluginIR::PluginTypeBase type,
uint64_t offsetId = GetValueId(offset);
root["baseId"] = baseId;
root["offsetId"] = offsetId;
- root["type"] = PluginServer::GetInstance()->TypeJsonSerialize(type);
+ PinJson::PluginJson json;
+ root["type"] = json.TypeJsonSerialize(type);
string params = root.toStyledString();
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetValueResult();
+ return PluginServer::GetInstance()->GetValueResult(funName, params);
}
PluginIR::PluginTypeID PluginServerAPI::GetTypeCodeFromString(string type)
{
if (type == "VoidTy") {
return PluginIR::PluginTypeID::VoidTyID;
- }else if (type == "UIntegerTy1") {
+ } else if (type == "UIntegerTy1") {
return PluginIR::PluginTypeID::UIntegerTy1ID;
- }else if (type == "UIntegerTy8") {
+ } else if (type == "UIntegerTy8") {
return PluginIR::PluginTypeID::UIntegerTy8ID;
- }else if (type == "UIntegerTy16") {
+ } else if (type == "UIntegerTy16") {
return PluginIR::PluginTypeID::UIntegerTy16ID;
- }else if (type == "UIntegerTy32") {
+ } else if (type == "UIntegerTy32") {
return PluginIR::PluginTypeID::UIntegerTy32ID;
- }else if (type == "UIntegerTy64") {
+ } else if (type == "UIntegerTy64") {
return PluginIR::PluginTypeID::UIntegerTy64ID;
- }else if (type == "IntegerTy1") {
+ } else if (type == "IntegerTy1") {
return PluginIR::PluginTypeID::IntegerTy1ID;
- }else if (type == "IntegerTy8") {
+ } else if (type == "IntegerTy8") {
return PluginIR::PluginTypeID::IntegerTy8ID;
- }else if (type == "IntegerTy16") {
+ } else if (type == "IntegerTy16") {
return PluginIR::PluginTypeID::IntegerTy16ID;
- }else if (type == "IntegerTy32") {
+ } else if (type == "IntegerTy32") {
return PluginIR::PluginTypeID::IntegerTy32ID;
- }else if (type == "IntegerTy64") {
+ } else if (type == "IntegerTy64") {
return PluginIR::PluginTypeID::IntegerTy64ID;
- }else if (type == "BooleanTy") {
+ } else if (type == "BooleanTy") {
return PluginIR::PluginTypeID::BooleanTyID;
- }else if (type == "FloatTy") {
+ } else if (type == "FloatTy") {
return PluginIR::PluginTypeID::FloatTyID;
- }else if (type == "DoubleTy") {
+ } else if (type == "DoubleTy") {
return PluginIR::PluginTypeID::DoubleTyID;
}
return PluginIR::PluginTypeID::UndefTyID;
}
-vector<LocalDeclOp> PluginServerAPI::GetDeclOperationResult(const string&funName,
- const string& params)
-{
- WaitClientResult(funName, params);
- vector<LocalDeclOp> retDecls = PluginServer::GetInstance()->GetLocalDeclResult();
- return retDecls;
-}
-
vector<LocalDeclOp> PluginServerAPI::GetDecls(uint64_t funcID)
{
Json::Value root;
@@ -344,48 +355,12 @@ vector<LocalDeclOp> PluginServerAPI::GetDecls(uint64_t funcID)
root["funcId"] = std::to_string(funcID);
string params = root.toStyledString();
- return GetDeclOperationResult(funName, params);
-}
-
-vector<LoopOp> PluginServerAPI::GetLoopsResult(const string& funName,
- const string& params)
-{
- WaitClientResult(funName, params);
- vector<LoopOp> loops = PluginServer::GetInstance()->LoopOpsResult();
- return loops;
-}
-
-LoopOp PluginServerAPI::GetLoopResult(const string& funName, const string& params)
-{
- WaitClientResult(funName, params);
- LoopOp loop = PluginServer::GetInstance()->LoopOpResult();
- return loop;
-}
-
-bool PluginServerAPI::GetBoolResult(const string& funName, const string& params)
-{
- WaitClientResult(funName, params);
- return PluginServer::GetInstance()->GetBoolResult();
-}
-
-pair<mlir::Block*, mlir::Block*> PluginServerAPI::EdgeResult(const string& funName, const string& params)
-{
- WaitClientResult(funName, params);
- pair<mlir::Block*, mlir::Block*> e = PluginServer::GetInstance()->EdgeResult();
- return e;
-}
-
-vector<pair<mlir::Block*, mlir::Block*> > PluginServerAPI::EdgesResult(const string& funName, const string& params)
-{
- WaitClientResult(funName, params);
- vector<pair<mlir::Block*, mlir::Block*> > retEdges = PluginServer::GetInstance()->EdgesResult();
- return retEdges;
+ return PluginServer::GetInstance()->GetLocalDeclResult(funName, params);
}
mlir::Block* PluginServerAPI::BlockResult(const string& funName, const string& params)
{
- WaitClientResult(funName, params);
- uint64_t blockId = PluginServer::GetInstance()->GetIdResult();
+ uint64_t blockId = PluginServer::GetInstance()->GetIdResult(funName, params);
return PluginServer::GetInstance()->FindBlock(blockId);
}
@@ -393,9 +368,8 @@ vector<mlir::Block*> PluginServerAPI::BlocksResult(const string& funName, const
{
vector<mlir::Block*> res;
PluginServer *server = PluginServer::GetInstance();
- WaitClientResult(funName, params);
- vector<uint64_t> blockIds = server->GetIdsResult();
- for(auto b : blockIds) {
+ vector<uint64_t> blockIds = server->GetIdsResult(funName, params);
+ for (auto b : blockIds) {
res.push_back(server->FindBlock(b));
}
return res;
@@ -408,7 +382,7 @@ vector<LoopOp> PluginServerAPI::GetLoopsFromFunc(uint64_t funcID)
root["funcId"] = std::to_string(funcID);
string params = root.toStyledString();
- return GetLoopsResult(funName, params);
+ return PluginServer::GetInstance()->LoopOpsResult(funName, params);
}
bool PluginServerAPI::IsDomInfoAvailable()
@@ -421,8 +395,7 @@ bool PluginServerAPI::IsDomInfoAvailable()
bool PluginServerAPI::GetDomInfoAvaiResult(const string& funName)
{
Json::Value root;
- WaitClientResult(funName, root.toStyledString());
- return PluginServer::GetInstance()->GetBoolResult();
+ return PluginServer::GetInstance()->GetBoolResult(funName, root.toStyledString());
}
LoopOp PluginServerAPI::AllocateNewLoop(uint64_t funcID)
@@ -432,7 +405,7 @@ LoopOp PluginServerAPI::AllocateNewLoop(uint64_t funcID)
root["funcId"] = std::to_string(funcID);
string params = root.toStyledString();
- return GetLoopResult(funName, params);
+ return PluginServer::GetInstance()->LoopOpResult(funName, params);
}
LoopOp PluginServerAPI::GetLoopById(uint64_t loopID)
@@ -442,7 +415,7 @@ LoopOp PluginServerAPI::GetLoopById(uint64_t loopID)
root["loopId"] = std::to_string(loopID);
string params = root.toStyledString();
- return GetLoopResult(funName, params);
+ return PluginServer::GetInstance()->LoopOpResult(funName, params);
}
void PluginServerAPI::DeleteLoop(uint64_t loopID)
@@ -451,7 +424,7 @@ void PluginServerAPI::DeleteLoop(uint64_t loopID)
string funName("DeleteLoop");
root["loopId"] = std::to_string(loopID);
string params = root.toStyledString();
- WaitClientResult(funName, params);
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
}
void PluginServerAPI::AddLoop(uint64_t loopID, uint64_t outerID, uint64_t funcID)
@@ -462,7 +435,7 @@ void PluginServerAPI::AddLoop(uint64_t loopID, uint64_t outerID, uint64_t funcID
root["outerId"] = outerID;
root["funcId"] = funcID;
string params = root.toStyledString();
- WaitClientResult(funName, params);
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
}
void PluginServerAPI::AddBlockToLoop(uint64_t blockID, uint64_t loopID)
@@ -472,7 +445,7 @@ void PluginServerAPI::AddBlockToLoop(uint64_t blockID, uint64_t loopID)
root["blockId"] = blockID;
root["loopId"] = loopID;
string params = root.toStyledString();
- WaitClientResult(funName, params);
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
}
bool PluginServerAPI::IsBlockInLoop(uint64_t loopID, uint64_t blockID)
@@ -483,7 +456,7 @@ bool PluginServerAPI::IsBlockInLoop(uint64_t loopID, uint64_t blockID)
root["blockId"] = std::to_string(blockID);
string params = root.toStyledString();
- return GetBoolResult(funName, params);
+ return PluginServer::GetInstance()->GetBoolResult(funName, params);
}
mlir::Block* PluginServerAPI::GetHeader(uint64_t loopID)
@@ -513,8 +486,7 @@ void PluginServerAPI::SetHeader(uint64_t loopID, uint64_t blockID)
root["loopId"] = std::to_string(loopID);
root["blockId"] = std::to_string(blockID);
string params = root.toStyledString();
-
- WaitClientResult(funName, params);
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
}
void PluginServerAPI::SetLatch(uint64_t loopID, uint64_t blockID)
@@ -524,8 +496,7 @@ void PluginServerAPI::SetLatch(uint64_t loopID, uint64_t blockID)
root["loopId"] = std::to_string(loopID);
root["blockId"] = std::to_string(blockID);
string params = root.toStyledString();
-
- WaitClientResult(funName, params);
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
}
pair<mlir::Block*, mlir::Block*> PluginServerAPI::LoopSingleExit(uint64_t loopID)
@@ -534,8 +505,7 @@ pair<mlir::Block*, mlir::Block*> PluginServerAPI::LoopSingleExit(uint64_t loopID
string funName("GetLoopSingleExit");
root["loopId"] = std::to_string(loopID);
string params = root.toStyledString();
-
- return EdgeResult(funName, params);
+ return PluginServer::GetInstance()->EdgeResult(funName, params);
}
vector<pair<mlir::Block*, mlir::Block*> > PluginServerAPI::GetLoopExitEdges(uint64_t loopID)
@@ -544,8 +514,7 @@ vector<pair<mlir::Block*, mlir::Block*> > PluginServerAPI::GetLoopExitEdges(uint
string funName("GetLoopExits");
root["loopId"] = std::to_string(loopID);
string params = root.toStyledString();
-
- return EdgesResult(funName, params);
+ return PluginServer::GetInstance()->EdgesResult(funName, params);
}
vector<mlir::Block*> PluginServerAPI::GetLoopBody(uint64_t loopID)
@@ -554,7 +523,6 @@ vector<mlir::Block*> PluginServerAPI::GetLoopBody(uint64_t loopID)
string funName("GetBlocksInLoop");
root["loopId"] = std::to_string(loopID);
string params = root.toStyledString();
-
return BlocksResult(funName, params);
}
@@ -564,8 +532,7 @@ LoopOp PluginServerAPI::GetBlockLoopFather(uint64_t blockID)
string funName("GetBlockLoopFather");
root["blockId"] = std::to_string(blockID);
string params = root.toStyledString();
-
- return GetLoopResult(funName, params);
+ return PluginServer::GetInstance()->LoopOpResult(funName, params);
}
mlir::Block* PluginServerAPI::FindBlock(uint64_t b)
@@ -594,8 +561,8 @@ bool PluginServerAPI::RedirectFallthroughTarget(FallThroughOp& fop,
root["src"] = src;
root["dest"] = dest;
string params = root.toStyledString();
- WaitClientResult(funName, params);
- //update server
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
+ // update server
PluginServer *server = PluginServer::GetInstance();
fop->setSuccessor(server->FindBlock(dest), 0);
return true;
@@ -617,7 +584,7 @@ void PluginServerAPI::DebugValue(uint64_t valId)
string funName = __func__;
root["valId"] = valId;
string params = root.toStyledString();
- WaitClientResult(funName, params);
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, params);
}
} // namespace Plugin_IR
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/pin-server.git
git@gitee.com:src-openeuler/pin-server.git
src-openeuler
pin-server
pin-server
master

搜索帮助