175 lines
5.4 KiB
Diff
175 lines
5.4 KiB
Diff
From eb6f6bde062764538a91e35792b06124cf91f0d3 Mon Sep 17 00:00:00 2001
|
|
From: d00573793 <dingguangya1@huawei.com>
|
|
Date: Tue, 28 Feb 2023 21:11:35 +0800
|
|
Subject: [PATCH 19/23] [Pin-server] Init a SimpleIPAPASS
|
|
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 1cfb776..59dee9f 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -83,7 +83,8 @@ target_link_libraries(plg_grpc_proto
|
|
add_subdirectory(include)
|
|
add_subdirectory(lib)
|
|
add_library(pin_user SHARED
|
|
- "user/ArrayWidenPass.cpp"
|
|
+ # "user/ArrayWidenPass.cpp"
|
|
+ "user/StructReorder.cpp"
|
|
"user/InlineFunctionPass.cpp"
|
|
"user/LocalVarSummeryPass.cpp"
|
|
"user/user.cpp")
|
|
diff --git a/include/PluginServer/ManagerSetup.h b/include/PluginServer/ManagerSetup.h
|
|
index 27ba930..e264237 100755
|
|
--- a/include/PluginServer/ManagerSetup.h
|
|
+++ b/include/PluginServer/ManagerSetup.h
|
|
@@ -28,6 +28,7 @@ enum RefPassName {
|
|
PASS_PHIOPT,
|
|
PASS_SSA,
|
|
PASS_LOOP,
|
|
+ PASS_MAC,
|
|
};
|
|
|
|
enum PassPosition {
|
|
diff --git a/include/user/StructReorder.h b/include/user/StructReorder.h
|
|
new file mode 100644
|
|
index 0000000..1d05e56
|
|
--- /dev/null
|
|
+++ b/include/user/StructReorder.h
|
|
@@ -0,0 +1,45 @@
|
|
+/* 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 StructReorderPass class.
|
|
+*/
|
|
+
|
|
+#ifndef STRUCTREORDER_PASS_H
|
|
+#define STRUCTREORDER_PASS_H
|
|
+
|
|
+#include "PluginServer/PluginOptBase.h"
|
|
+
|
|
+namespace PluginOpt {
|
|
+class StructReorderPass : public PluginOptBase {
|
|
+public:
|
|
+ StructReorderPass() : PluginOptBase(HANDLE_MANAGER_SETUP)
|
|
+ {
|
|
+ }
|
|
+ bool Gate()
|
|
+ {
|
|
+ return true;
|
|
+ }
|
|
+ int DoOptimize()
|
|
+ {
|
|
+ uint64_t *fun = (uint64_t *)GetFuncAddr();
|
|
+ return DoOptimize(fun);
|
|
+ }
|
|
+ int DoOptimize(uint64_t *fun);
|
|
+};
|
|
+}
|
|
+
|
|
+#endif
|
|
diff --git a/user/StructReorder.cpp b/user/StructReorder.cpp
|
|
new file mode 100644
|
|
index 0000000..bdc7abb
|
|
--- /dev/null
|
|
+++ b/user/StructReorder.cpp
|
|
@@ -0,0 +1,59 @@
|
|
+/* 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 implementation of the ArrayWidenPass class.
|
|
+*/
|
|
+
|
|
+#include <iostream>
|
|
+#include <map>
|
|
+#include <set>
|
|
+#include <vector>
|
|
+#include <string>
|
|
+#include <sstream>
|
|
+#include "PluginAPI/PluginServerAPI.h"
|
|
+#include "PluginServer/PluginLog.h"
|
|
+#include "PluginAPI/ControlFlowAPI.h"
|
|
+#include "user/StructReorder.h"
|
|
+
|
|
+namespace PluginOpt {
|
|
+using std::string;
|
|
+using std::vector;
|
|
+using std::cout;
|
|
+using namespace mlir;
|
|
+using namespace mlir::Plugin;
|
|
+using namespace PluginAPI;
|
|
+using namespace PinServer;
|
|
+using namespace std;
|
|
+
|
|
+mlir::MLIRContext *context;
|
|
+mlir::OpBuilder* opBuilder = nullptr;
|
|
+std::map<Block*, Value> defs_map;
|
|
+std::map<uint64_t, std::string> opNameMap;
|
|
+
|
|
+
|
|
+static void ProcessStructReorder(uint64_t *fun)
|
|
+{
|
|
+ std::cout << "Running first pass, structreoder\n";
|
|
+
|
|
+}
|
|
+
|
|
+int StructReorderPass::DoOptimize(uint64_t *fun)
|
|
+{
|
|
+ ProcessStructReorder(fun);
|
|
+ return 0;
|
|
+}
|
|
+}
|
|
\ No newline at end of file
|
|
diff --git a/user/user.cpp b/user/user.cpp
|
|
index 16f0687..ee2031a 100644
|
|
--- a/user/user.cpp
|
|
+++ b/user/user.cpp
|
|
@@ -22,12 +22,15 @@
|
|
#include "user/ArrayWidenPass.h"
|
|
#include "user/InlineFunctionPass.h"
|
|
#include "user/LocalVarSummeryPass.h"
|
|
+#include "user/StructReorder.h"
|
|
|
|
void RegisterCallbacks(void)
|
|
{
|
|
PinServer::PluginServer *pluginServer = PinServer::PluginServer::GetInstance();
|
|
- pluginServer->RegisterOpt(std::make_shared<PluginOpt::InlineFunctionPass>(PluginOpt::HANDLE_BEFORE_IPA));
|
|
- pluginServer->RegisterOpt(std::make_shared<PluginOpt::LocalVarSummeryPass>(PluginOpt::HANDLE_BEFORE_IPA));
|
|
+ // pluginServer->RegisterOpt(std::make_shared<PluginOpt::InlineFunctionPass>(PluginOpt::HANDLE_BEFORE_IPA));
|
|
+ // pluginServer->RegisterOpt(std::make_shared<PluginOpt::LocalVarSummeryPass>(PluginOpt::HANDLE_BEFORE_IPA));
|
|
// PluginOpt::ManagerSetup setupData(PluginOpt::PASS_PHIOPT, 1, PluginOpt::PASS_INSERT_AFTER);
|
|
// pluginServer->RegisterPassManagerOpt(setupData, std::make_shared<PluginOpt::ArrayWidenPass>());
|
|
+ PluginOpt::ManagerSetup setupData(PluginOpt::PASS_MAC, 1, PluginOpt::PASS_INSERT_AFTER);
|
|
+ pluginServer->RegisterPassManagerOpt(setupData, std::make_shared<PluginOpt::StructReorderPass>());
|
|
}
|
|
--
|
|
2.33.0
|
|
|