• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "me_irmap.h"
17 
18 namespace maple {
Dump()19 void MeIRMap::Dump()
20 {
21     // back up mempool and use a new mempool every time
22     // we dump IRMap, restore the mempool afterwards
23     MIRFunction *mirFunction = func.GetMirFunc();
24     MemPool *backup = mirFunction->GetCodeMempool();
25     mirFunction->SetMemPool(new ThreadLocalMemPool(memPoolCtrler, "IR Dump"));
26     auto theCFG = func.GetCfg();
27     LogInfo::MapleLogger() << "===================Me IR dump==================\n";
28     auto eIt = theCFG->valid_end();
29     for (auto bIt = theCFG->valid_begin(); bIt != eIt; ++bIt) {
30         auto *bb = *bIt;
31         bb->DumpHeader(&GetMIRModule());
32         LogInfo::MapleLogger() << "frequency : " << bb->GetFrequency() << "\n";
33         bb->DumpMeVarPiList(this);
34         bb->DumpMePhiList(this);
35         int i = 0;
36         for (auto &meStmt : bb->GetMeStmts()) {
37             if (GetDumpStmtNum()) {
38                 LogInfo::MapleLogger() << "(" << i++ << ") ";
39             }
40             if (meStmt.GetOp() != OP_piassign) {
41                 meStmt.EmitStmt(GetSSATab()).Dump(0);
42             }
43             meStmt.Dump(this);
44         }
45     }
46     mirFunction->ReleaseCodeMemory();
47     mirFunction->SetMemPool(backup);
48 }
49 }  // namespace maple
50