diff --git a/Makefile b/Makefile index e5e8d5e5694b5c04d63f8f7cfd4d98b5f86cca0c..0f13696858cdb3bdc1d35b3af3ed3a02e034c5e4 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ clean: define build_gn mkdir -p ${INSTALL_DIR}; \ - $(GN) gen ${INSTALL_DIR} --args='$(1)'; \ + $(GN) gen ${INSTALL_DIR} --args='$(1)' --export-compile-commands; \ cd ${INSTALL_DIR}; \ $(NINJA) -v $(2); endef diff --git a/src/bin/jbc2mpl b/src/bin/jbc2mpl index dcd7679c7368efec9bd6cb2f5e77881b0d6b0874..29803ac9ea8efe266a90ae6c548faf9def377374 100755 Binary files a/src/bin/jbc2mpl and b/src/bin/jbc2mpl differ diff --git a/src/bin/maple b/src/bin/maple index 8804d2c34b8c3f296f4984117a03fe3d2dbf8363..5257b16b2f2c4e36a3d000aa48fff95ccae562b6 100755 Binary files a/src/bin/maple and b/src/bin/maple differ diff --git a/src/maple_driver/src/driver_runner.cpp b/src/maple_driver/src/driver_runner.cpp index 0f82d396a34f18aaf4392095f56bfd413f324399..b2be28e6e00f0eece657261005a465b40609ffcf 100644 --- a/src/maple_driver/src/driver_runner.cpp +++ b/src/maple_driver/src/driver_runner.cpp @@ -130,7 +130,7 @@ ErrorCode DriverRunner::ParseInput(const std::string &outputFile, const std::str void DriverRunner::ProcessMpl2mplAndMePhases(const std::string &outputFile, const std::string &vtableImplFile) const { CHECK_MODULE(); - + theMIRModule = theModule; if (mpl2mplOptions != nullptr || meOptions != nullptr) { LogInfo::MapleLogger() << "Processing mpl2mpl&mplme" << '\n'; MPLTimer timer; diff --git a/src/maple_ir/include/mir_nodes.h b/src/maple_ir/include/mir_nodes.h index 1190b8bfac9f70f514ef22944291315b936b9c11..1e491385421d4cc938d78899ecf96209ef52e370 100644 --- a/src/maple_ir/include/mir_nodes.h +++ b/src/maple_ir/include/mir_nodes.h @@ -95,14 +95,14 @@ class BaseNode { return allocator.GetMemPool()->New(*this); } - virtual void DumpBase(const MIRModule &mod, int32 indent) const; + virtual void DumpBase(int32 indent) const; - virtual void Dump(const MIRModule &mod, int32 indent) const { - DumpBase(mod, indent); + virtual void Dump(int32 indent) const { + DumpBase(indent); } - void Dump(const MIRModule &mod) const { - Dump(mod, 0); + void Dump() const { + Dump(0); LogInfo::MapleLogger() << '\n'; } @@ -207,7 +207,7 @@ class UnaryNode : public BaseNode { virtual ~UnaryNode() override = default; void DumpOpnd(const MIRModule &mod, int32 indent) const; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; UnaryNode *CloneTree(MapleAllocator &allocator) const override { @@ -252,7 +252,7 @@ class TypeCvtNode : public UnaryNode { virtual ~TypeCvtNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; TypeCvtNode *CloneTree(MapleAllocator &allocator) const override { @@ -284,9 +284,9 @@ class RetypeNode : public TypeCvtNode { : TypeCvtNode(OP_retype, typ, fromtyp, expr), tyIdx(idx) {} virtual ~RetypeNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; + void Dump(int32 indent) const override; - RetypeNode *CloneTree(MapleAllocator &allocator) const { + RetypeNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); node->SetOpnd(Opnd()->CloneTree(allocator)); return node; @@ -319,7 +319,7 @@ class ExtractbitsNode : public UnaryNode { virtual ~ExtractbitsNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; ExtractbitsNode *CloneTree(MapleAllocator &allocator) const override { @@ -357,7 +357,7 @@ class GCMallocNode : public BaseNode { virtual ~GCMallocNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; GCMallocNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); @@ -393,7 +393,7 @@ class JarrayMallocNode : public UnaryNode { virtual ~JarrayMallocNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; JarrayMallocNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); @@ -426,7 +426,7 @@ class IreadNode : public UnaryNode { : UnaryNode(o, typ, expr), tyIdx(typeIdx), fieldID(fid) {} virtual ~IreadNode() = default; - virtual void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; IreadNode *CloneTree(MapleAllocator &allocator) const override { @@ -478,10 +478,10 @@ class IreadoffNode : public UnaryNode { virtual ~IreadoffNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; - bool Verify() const; + void Dump(int32 indent) const override; + bool Verify() const override; - IreadoffNode *CloneTree(MapleAllocator &allocator) const { + IreadoffNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); node->SetOpnd(Opnd()->CloneTree(allocator)); return node; @@ -507,7 +507,7 @@ class IreadFPoffNode : public BaseNode { virtual ~IreadFPoffNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; IreadFPoffNode *CloneTree(MapleAllocator &allocator) const override { @@ -531,7 +531,7 @@ class BinaryOpnds { public: virtual ~BinaryOpnds() = default; - virtual void Dump(const MIRModule &mod, int32 indent) const; + virtual void Dump(int32 indent) const; BaseNode *GetBOpnd(int32 i) const { CHECK_FATAL(i >= 0 && i < kOperandNumBinary, "Invalid operand idx in BinaryOpnds"); @@ -560,8 +560,8 @@ class BinaryNode : public BaseNode, public BinaryOpnds { virtual ~BinaryNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; - void Dump(const MIRModule &mod) const; + void Dump(int32 indent) const override; + void Dump() const; bool Verify() const override; BinaryNode *CloneTree(MapleAllocator &allocator) const override { @@ -620,11 +620,11 @@ class CompareNode : public BinaryNode { virtual ~CompareNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; - void Dump(const MIRModule &mod) const; - bool Verify() const; + void Dump(int32 indent) const override; + void Dump() const; + bool Verify() const override; - CompareNode *CloneTree(MapleAllocator &allocator) const { + CompareNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); node->SetBOpnd(GetBOpnd(0)->CloneTree(allocator), 0); node->SetBOpnd(GetBOpnd(1)->CloneTree(allocator), 1); @@ -654,7 +654,7 @@ class DepositbitsNode : public BinaryNode { virtual ~DepositbitsNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; DepositbitsNode *CloneTree(MapleAllocator &allocator) const override { @@ -701,9 +701,9 @@ class ResolveFuncNode : public BinaryNode { virtual ~ResolveFuncNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; + void Dump(int32 indent) const override; - ResolveFuncNode *CloneTree(MapleAllocator &allocator) const { + ResolveFuncNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); node->SetBOpnd(GetBOpnd(0)->CloneTree(allocator), 0); node->SetBOpnd(GetBOpnd(1)->CloneTree(allocator), 1); @@ -744,7 +744,7 @@ class TernaryNode : public BaseNode { virtual ~TernaryNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; TernaryNode *CloneTree(MapleAllocator &allocator) const override { @@ -787,7 +787,7 @@ class NaryOpnds { virtual ~NaryOpnds() = default; - virtual void Dump(const MIRModule &mod, int32 indent) const; + virtual void Dump(int32 indent) const; bool VerifyOpnds() const; const MapleVector &GetNopnd() const { @@ -839,7 +839,7 @@ class NaryNode : public BaseNode, public NaryOpnds { NaryNode &operator=(const NaryNode &node) = delete; virtual ~NaryNode() = default; - virtual void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; NaryNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(allocator, *this); @@ -900,10 +900,10 @@ class IntrinsicopNode : public NaryNode { IntrinsicopNode &operator=(const IntrinsicopNode &node) = delete; virtual ~IntrinsicopNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; - bool Verify() const; + void Dump(int32 indent) const override; + bool Verify() const override; - IntrinsicopNode *CloneTree(MapleAllocator &allocator) const { + IntrinsicopNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(allocator, *this); for (size_t i = 0; i < GetNopndSize(); ++i) { node->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator)); @@ -948,7 +948,7 @@ class ConstvalNode : public BaseNode { ConstvalNode(PrimType typ, MIRConst *constv) : BaseNode(OP_constval, typ, 0), constVal(constv) {} virtual ~ConstvalNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; ConstvalNode *CloneTree(MapleAllocator &allocator) const override { return allocator.GetMemPool()->New(*this); @@ -980,7 +980,7 @@ class ConststrNode : public BaseNode { virtual ~ConststrNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; ConststrNode *CloneTree(MapleAllocator &allocator) const override { return allocator.GetMemPool()->New(*this); @@ -1008,7 +1008,7 @@ class Conststr16Node : public BaseNode { virtual ~Conststr16Node() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; Conststr16Node *CloneTree(MapleAllocator &allocator) const override { return allocator.GetMemPool()->New(*this); @@ -1036,7 +1036,7 @@ class SizeoftypeNode : public BaseNode { virtual ~SizeoftypeNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; SizeoftypeNode *CloneTree(MapleAllocator &allocator) const override { @@ -1066,7 +1066,7 @@ class FieldsDistNode : public BaseNode { virtual ~FieldsDistNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; FieldsDistNode *CloneTree(MapleAllocator &allocator) const override { return allocator.GetMemPool()->New(*this); @@ -1128,16 +1128,16 @@ class ArrayNode : public NaryNode { ArrayNode &operator=(const ArrayNode &node) = delete; virtual ~ArrayNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; - bool Verify() const; + void Dump(int32 indent) const override; + bool Verify() const override; bool IsSameBase(ArrayNode*); - uint8 NumOpnds() const { + uint8 NumOpnds() const override { ASSERT(numOpnds == GetNopndSize(), "ArrayNode has wrong numOpnds field"); return GetNopndSize(); } - ArrayNode *CloneTree(MapleAllocator &allocator) const { + ArrayNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(allocator, *this); for (size_t i = 0; i < GetNopndSize(); ++i) { node->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator)); @@ -1192,7 +1192,7 @@ class AddrofNode : public BaseNode { virtual ~AddrofNode() = default; - virtual void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; bool CheckNode(const MIRModule &mod) const; @@ -1240,7 +1240,7 @@ class RegreadNode : public BaseNode { virtual ~RegreadNode() = default; - virtual void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; RegreadNode *CloneTree(MapleAllocator &allocator) const override { @@ -1266,7 +1266,7 @@ class AddroffuncNode : public BaseNode { virtual ~AddroffuncNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; AddroffuncNode *CloneTree(MapleAllocator &allocator) const override { @@ -1293,7 +1293,7 @@ class AddroflabelNode : public BaseNode { virtual ~AddroflabelNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; AddroflabelNode *CloneTree(MapleAllocator &allocator) const override { @@ -1408,9 +1408,9 @@ class StmtNode : public BaseNode, public PtrListNodeBase { virtual ~StmtNode() = default; - void DumpBase(const MIRModule &mod, int32 indent) const override; - void Dump(const MIRModule &mod, int32 indent) const override; - void Dump(const MIRModule &mod) const; + void DumpBase(int32 indent) const override; + void Dump(int32 indent) const override; + void Dump() const; void InsertAfterThis(StmtNode &pos); void InsertBeforeThis(StmtNode &pos); @@ -1503,7 +1503,7 @@ class IassignNode : public StmtNode { } } - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; IassignNode *CloneTree(MapleAllocator &allocator) const override { @@ -1551,7 +1551,7 @@ class GotoNode : public StmtNode { virtual ~GotoNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; GotoNode *CloneTree(MapleAllocator &allocator) const override { auto *g = allocator.GetMemPool()->New(*this); @@ -1581,7 +1581,7 @@ class JsTryNode : public StmtNode { virtual ~JsTryNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; JsTryNode *CloneTree(MapleAllocator &allocator) const override { auto *t = allocator.GetMemPool()->New(*this); @@ -1623,8 +1623,8 @@ class TryNode : public StmtNode { TryNode &operator=(const TryNode &node) = delete; virtual ~TryNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; - void Dump(const MIRModule &mod) const; + void Dump(int32 indent) const override; + void Dump() const; LabelIdx GetOffset(size_t i) const { ASSERT(i < offsets.size(), "array index out of range"); @@ -1692,8 +1692,8 @@ class CatchNode : public StmtNode { CatchNode &operator=(const CatchNode &node) = delete; virtual ~CatchNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; - void Dump(const MIRModule &mod) const; + void Dump(int32 indent) const override; + void Dump() const; TyIdx GetExceptionTyIdxVecElement(size_t i) const { CHECK_FATAL(i < exceptionTyIdxVec.size(), "array index out of range"); @@ -1761,7 +1761,7 @@ class SwitchNode : public StmtNode { SwitchNode &operator=(const SwitchNode &node) = delete; virtual ~SwitchNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; SwitchNode *CloneTree(MapleAllocator &allocator) const override { @@ -1854,7 +1854,7 @@ class MultiwayNode : public StmtNode { MultiwayNode &operator=(const MultiwayNode &node) = delete; virtual ~MultiwayNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; MultiwayNode *CloneTree(MapleAllocator &allocator) const override { auto *nd = allocator.GetMemPool()->New(allocator, *this); @@ -1908,8 +1908,8 @@ class UnaryStmtNode : public StmtNode { virtual ~UnaryStmtNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; - void Dump(const MIRModule &mod) const; + void Dump(int32 indent) const override; + void Dump() const; void DumpOpnd(const MIRModule &mod, int32 indent) const; bool Verify() const override { @@ -1965,7 +1965,7 @@ class DassignNode : public UnaryStmtNode { virtual ~DassignNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; DassignNode *CloneTree(MapleAllocator &allocator) const override { @@ -2025,7 +2025,7 @@ class RegassignNode : public UnaryStmtNode { virtual ~RegassignNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; RegassignNode *CloneTree(MapleAllocator &allocator) const override { @@ -2065,8 +2065,8 @@ class CondGotoNode : public UnaryStmtNode { virtual ~CondGotoNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; - bool Verify() const; + void Dump(int32 indent) const override; + bool Verify() const override; uint32 GetOffset() const { return offset; @@ -2076,7 +2076,7 @@ class CondGotoNode : public UnaryStmtNode { offset = offsetValue; } - CondGotoNode *CloneTree(MapleAllocator &allocator) const { + CondGotoNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); node->SetStmtID(stmtIDNext++); node->SetOpnd(Opnd()->CloneTree(allocator)); @@ -2108,9 +2108,9 @@ class RangeGotoNode : public UnaryStmtNode { RangeGotoNode &operator=(const RangeGotoNode &node) = delete; virtual ~RangeGotoNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; - bool Verify() const; - RangeGotoNode *CloneTree(MapleAllocator &allocator) const { + void Dump(int32 indent) const override; + bool Verify() const override; + RangeGotoNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(allocator, *this); node->SetOpnd(Opnd()->CloneTree(allocator)); for (size_t i = 0; i < rangegotoTable.size(); ++i) { @@ -2166,12 +2166,12 @@ class BlockNode : public StmtNode { void InsertAfter(StmtNode *stmtNode1, StmtNode *stmtNode2); // Insert ss2 after ss1 in current block. // insert all the stmts in inblock to the current block after stmt1 void InsertBlockAfter(BlockNode &inblock, StmtNode *stmt1); - void Dump(const MIRModule &mod, int32 indent, const MIRSymbolTable *theSymTab, MIRPregTable *thePregTab, + void Dump(int32 indent, const MIRSymbolTable *theSymTab, MIRPregTable *thePregTab, bool withInfo, bool isFuncbody) const; bool Verify() const override; - void Dump(const MIRModule &mod, int32 indent) const override { - Dump(mod, indent, nullptr, nullptr, false, false); + void Dump(int32 indent) const override { + Dump(indent, nullptr, nullptr, false, false); } BlockNode *CloneTree(MapleAllocator &allocator) const override { @@ -2254,10 +2254,10 @@ class IfStmtNode : public UnaryStmtNode { virtual ~IfStmtNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; - bool Verify() const; + void Dump(int32 indent) const override; + bool Verify() const override; - IfStmtNode *CloneTree(MapleAllocator &allocator) const { + IfStmtNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); node->SetStmtID(stmtIDNext++); node->SetOpnd(Opnd()->CloneTree(allocator)); @@ -2268,7 +2268,7 @@ class IfStmtNode : public UnaryStmtNode { return node; } - BaseNode *Opnd(size_t i = 0) const { + BaseNode *Opnd(size_t i = 0) const override { if (i == 0) { return UnaryStmtNode::Opnd(); } else if (i == 1) { @@ -2298,7 +2298,7 @@ class IfStmtNode : public UnaryStmtNode { elsePart = node; } - uint8 NumOpnds() const { + uint8 NumOpnds() const override { return numOpnds; } @@ -2316,10 +2316,10 @@ class WhileStmtNode : public UnaryStmtNode { virtual ~WhileStmtNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; - bool Verify() const; + void Dump(int32 indent) const override; + bool Verify() const override; - WhileStmtNode *CloneTree(MapleAllocator &allocator) const { + WhileStmtNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); node->SetStmtID(stmtIDNext++); node->SetOpnd(Opnd()->CloneTree(allocator)); @@ -2355,7 +2355,7 @@ class DoloopNode : public StmtNode { virtual ~DoloopNode() = default; void DumpDoVar(const MIRModule &mod) const; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; bool Verify() const override; DoloopNode *CloneTree(MapleAllocator &allocator) const override { @@ -2493,17 +2493,17 @@ class ForeachelemNode : public StmtNode { loopBody = loopBodyValue; } - BaseNode *Opnd(size_t i = 0) const { + BaseNode *Opnd(size_t i = 0) const override { return loopBody; } - uint8 NumOpnds() const { + uint8 NumOpnds() const override { return numOpnds; } - void Dump(const MIRModule &mod, int32 indent) const; + void Dump(int32 indent) const override; - ForeachelemNode *CloneTree(MapleAllocator &allocator) const { + ForeachelemNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); node->SetStmtID(stmtIDNext++); node->SetLoopBody(loopBody->CloneTree(allocator)); @@ -2523,9 +2523,9 @@ class BinaryStmtNode : public StmtNode, public BinaryOpnds { virtual ~BinaryStmtNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; - virtual bool Verify() const; - BinaryStmtNode *CloneTree(MapleAllocator &allocator) const { + void Dump(int32 indent) const override; + bool Verify() const override; + BinaryStmtNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); node->SetStmtID(stmtIDNext++); node->SetBOpnd(GetBOpnd(0)->CloneTree(allocator), 0); @@ -2533,21 +2533,21 @@ class BinaryStmtNode : public StmtNode, public BinaryOpnds { return node; } - BaseNode *Opnd(size_t i) const { + BaseNode *Opnd(size_t i) const override { ASSERT(i < kOperandNumBinary, "Invalid operand idx in BinaryStmtNode"); ASSERT(i >= 0, "Invalid operand idx in BinaryStmtNode"); return GetBOpnd(i); } - uint8 NumOpnds() const { + uint8 NumOpnds() const override { return kOperandNumBinary; } - void SetOpnd(BaseNode *node, size_t i) { + void SetOpnd(BaseNode *node, size_t i) override { SetBOpnd(node, i); } - bool IsLeaf() const { + bool IsLeaf() const override { return false; } }; @@ -2566,10 +2566,10 @@ class IassignoffNode : public BinaryStmtNode { virtual ~IassignoffNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; - bool Verify() const; + void Dump(int32 indent) const override; + bool Verify() const override; - IassignoffNode *CloneTree(MapleAllocator &allocator) const { + IassignoffNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); node->SetStmtID(stmtIDNext++); node->SetBOpnd(GetBOpnd(0)->CloneTree(allocator), 0); @@ -2602,10 +2602,10 @@ class IassignFPoffNode : public UnaryStmtNode { virtual ~IassignFPoffNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; - bool Verify() const; + void Dump(int32 indent) const override; + bool Verify() const override; - IassignFPoffNode *CloneTree(MapleAllocator &allocator) const { + IassignFPoffNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(*this); node->SetStmtID(stmtIDNext++); node->SetOpnd(Opnd()->CloneTree(allocator)); @@ -2641,8 +2641,8 @@ class NaryStmtNode : public StmtNode, public NaryOpnds { NaryStmtNode &operator=(const NaryStmtNode &node) = delete; virtual ~NaryStmtNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; - virtual bool Verify() const override; + void Dump(int32 indent) const override; + bool Verify() const override; NaryStmtNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(allocator, *this); @@ -2720,12 +2720,12 @@ class CallNode : public NaryStmtNode { CallNode(CallNode &node) = delete; CallNode &operator=(const CallNode &node) = delete; virtual ~CallNode() = default; - virtual void Dump(const MIRModule &mod, int32 indent, bool newline) const; - bool Verify() const; - MIRType *GetCallReturnType(); + virtual void Dump(int32 indent, bool newline) const; + bool Verify() const override; + MIRType *GetCallReturnType() override ; const MIRSymbol *GetCallReturnSymbol(const MIRModule &mod) const; - CallNode *CloneTree(MapleAllocator &allocator) const { + CallNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(allocator, *this); for (size_t i = 0; i < GetNopndSize(); ++i) { node->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator)); @@ -2780,16 +2780,16 @@ class CallNode : public NaryStmtNode { returnValues = vec; } - uint8 NumOpnds() const { + uint8 NumOpnds() const override { ASSERT(numOpnds == GetNopndSize(), "CallNode has wrong numOpnds field"); return GetNopndSize(); } - virtual void Dump(const MIRModule &mod, int32 indent) const { - Dump(mod, indent, true); + void Dump(int32 indent) const override { + Dump(indent, true); } - CallReturnVector *GetCallReturnVector() { + CallReturnVector *GetCallReturnVector() override { return &returnValues; } @@ -2824,10 +2824,10 @@ class IcallNode : public NaryStmtNode { IcallNode &operator=(const IcallNode &node) = delete; virtual ~IcallNode() = default; - virtual void Dump(const MIRModule &mod, int32 indent, bool newline) const; - bool Verify() const; - MIRType *GetCallReturnType(); - IcallNode *CloneTree(MapleAllocator &allocator) const { + virtual void Dump(int32 indent, bool newline) const; + bool Verify() const override; + MIRType *GetCallReturnType() override ; + IcallNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(allocator, *this); for (size_t i = 0; i < GetNopndSize(); ++i) { node->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator)); @@ -2859,16 +2859,16 @@ class IcallNode : public NaryStmtNode { returnValues = vec; } - uint8 NumOpnds() const { + uint8 NumOpnds() const override { ASSERT(numOpnds == GetNopndSize(), "IcallNode has wrong numOpnds field"); return GetNopndSize(); } - virtual void Dump(const MIRModule &mod, int32 indent) const { - Dump(mod, indent, true); + void Dump(int32 indent) const override { + Dump(indent, true); } - CallReturnVector *GetCallReturnVector() { + CallReturnVector *GetCallReturnVector() override { return &returnValues; } @@ -2905,11 +2905,11 @@ class IntrinsiccallNode : public NaryStmtNode { IntrinsiccallNode &operator=(const IntrinsiccallNode &node) = delete; virtual ~IntrinsiccallNode() = default; - virtual void Dump(const MIRModule &mod, int32 indent, bool newline) const; - bool Verify() const; - MIRType *GetCallReturnType(); + virtual void Dump(int32 indent, bool newline) const; + bool Verify() const override; + MIRType *GetCallReturnType() override; - IntrinsiccallNode *CloneTree(MapleAllocator &allocator) const { + IntrinsiccallNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(allocator, *this); for (size_t i = 0; i < GetNopndSize(); ++i) { node->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator)); @@ -2949,16 +2949,16 @@ class IntrinsiccallNode : public NaryStmtNode { returnValues = vec; } - uint8 NumOpnds() const { + uint8 NumOpnds() const override { ASSERT(numOpnds == GetNopndSize(), "IntrinsiccallNode has wrong numOpnds field"); return GetNopndSize(); } - virtual void Dump(const MIRModule &mod, int32 indent) const { - Dump(mod, indent, true); + void Dump(int32 indent) const override { + Dump(indent, true); } - CallReturnVector *GetCallReturnVector() { + CallReturnVector *GetCallReturnVector() override { return &returnValues; } @@ -2994,12 +2994,12 @@ class CallinstantNode : public CallNode { CallinstantNode &operator=(const CallinstantNode &node) = delete; virtual ~CallinstantNode() = default; - virtual void Dump(const MIRModule &mod, int32 indent, bool newline) const; - virtual void Dump(const MIRModule &mod, int32 indent) const { - Dump(mod, indent, true); + void Dump(int32 indent, bool newline) const override; + void Dump(int32 indent) const override { + Dump(indent, true); } - CallinstantNode *CloneTree(MapleAllocator &allocator) const { + CallinstantNode *CloneTree(MapleAllocator &allocator) const override { auto *node = allocator.GetMemPool()->New(allocator, *this); for (size_t i = 0; i < GetNopndSize(); ++i) { node->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator)); @@ -3011,7 +3011,7 @@ class CallinstantNode : public CallNode { return node; } - CallReturnVector *GetCallReturnVector() { + CallReturnVector *GetCallReturnVector() override { return &GetReturnVec(); } @@ -3028,7 +3028,7 @@ class AssertStmtNode : public BinaryStmtNode { virtual ~AssertStmtNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; + void Dump(int32 indent) const override; private: bool isLt; @@ -3042,7 +3042,7 @@ class LabelNode : public StmtNode { virtual ~LabelNode() = default; - void Dump(const MIRModule &mod, int32 indent) const override; + void Dump(int32 indent) const override; LabelNode *CloneTree(MapleAllocator &allocator) const override { auto *l = allocator.GetMemPool()->New(*this); @@ -3083,9 +3083,9 @@ class CommentNode : public StmtNode { CommentNode &operator=(const CommentNode &node) = delete; virtual ~CommentNode() = default; - void Dump(const MIRModule &mod, int32 indent) const; + void Dump(int32 indent) const override; - CommentNode *CloneTree(MapleAllocator &allocator) const { + CommentNode *CloneTree(MapleAllocator &allocator) const override { auto *c = allocator.GetMemPool()->New(allocator, *this); return c; } diff --git a/src/maple_ir/src/mir_function.cpp b/src/maple_ir/src/mir_function.cpp index fb0d24b3e212dba7da6e0ac58c126b239067bbb0..627f71c49d46cdb8c61196cb40e76815c64742a1 100644 --- a/src/maple_ir/src/mir_function.cpp +++ b/src/maple_ir/src/mir_function.cpp @@ -244,7 +244,7 @@ void MIRFunction::Dump(bool withoutBody) { MIRSymbol *symbol = GlobalTables::GetGsymTable().GetSymbolFromStidx(symbolTableIdx.Idx()); ASSERT(symbol != nullptr, "symbol MIRSymbol is null"); LogInfo::MapleLogger() << "func " << "&" << symbol->GetName(); - + theMIRModule = module; funcAttrs.DumpAttributes(); if (module->GetFlavor() < kMmpl) { @@ -257,7 +257,7 @@ void MIRFunction::Dump(bool withoutBody) { LogInfo::MapleLogger() << "# [WARNING] skipped dumping because codeMemPool is nullptr " << '\n'; } else if (GetBody() != nullptr && !withoutBody && symbol->GetStorageClass() != kScExtern) { ResetInfoPrinted(); // this ensures funcinfo will be printed - GetBody()->Dump(*module, 0, module->GetFlavor() < kMmpl ? GetSymTab() : nullptr, + GetBody()->Dump(0, module->GetFlavor() < kMmpl ? GetSymTab() : nullptr, module->GetFlavor() < kMmpl ? GetPregTab() : nullptr, false, true); // Dump body } else { LogInfo::MapleLogger() << '\n'; diff --git a/src/maple_ir/src/mir_nodes.cpp b/src/maple_ir/src/mir_nodes.cpp index 863844c9bf833fd7005e0cb76d50cd83cb79d9f3..56090d8943a60928485a7913918c0d64ff7aef84 100644 --- a/src/maple_ir/src/mir_nodes.cpp +++ b/src/maple_ir/src/mir_nodes.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. @@ -195,12 +195,12 @@ void BlockNode::InsertBlockAfter(BlockNode &inblock, StmtNode *stmt1) { stmtNodeList.splice(stmt1, inblock.GetStmtNodes()); } -void BaseNode::DumpBase(const MIRModule &mod, int32 indent) const { +void BaseNode::DumpBase(int32 indent) const { PrintIndentation(indent); LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " " << GetPrimTypeName(GetPrimType()); } -void CatchNode::Dump(const MIRModule &mod, int32 indent) const { +void CatchNode::Dump(int32 indent) const { PrintIndentation(indent); LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " {"; size_t size = exceptionTyIdxVec.size(); @@ -211,28 +211,28 @@ void CatchNode::Dump(const MIRModule &mod, int32 indent) const { LogInfo::MapleLogger() << " }\n"; } -void CatchNode::Dump(const MIRModule &mod) const { - this->BaseNode::Dump(mod); +void CatchNode::Dump() const { + this->BaseNode::Dump(); } void UnaryNode::DumpOpnd(const MIRModule &mod, int indent) const { LogInfo::MapleLogger() << " ("; - uOpnd->Dump(mod, indent); + uOpnd->Dump(indent); LogInfo::MapleLogger() << ")"; } -void UnaryNode::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); - DumpOpnd(mod, indent); +void UnaryNode::Dump(int32 indent) const { + BaseNode::DumpBase(0); + DumpOpnd(*theMIRModule, indent); } -void TypeCvtNode::Dump(const MIRModule &mod, int32 indent) const { +void TypeCvtNode::Dump(int32 indent) const { LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " "; LogInfo::MapleLogger() << GetPrimTypeName(GetPrimType()) << " " << GetPrimTypeName(FromType()); - DumpOpnd(mod, indent); + DumpOpnd(*theMIRModule, indent); } -void RetypeNode::Dump(const MIRModule &mod, int32 indent) const { +void RetypeNode::Dump(int32 indent) const { LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " "; LogInfo::MapleLogger() << GetPrimTypeName(GetPrimType()) << " "; MIRType *ty = GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx); @@ -243,130 +243,130 @@ void RetypeNode::Dump(const MIRModule &mod, int32 indent) const { } else { ty->Dump(indent + 1); } - DumpOpnd(mod, indent); + DumpOpnd(*theMIRModule, indent); } -void ExtractbitsNode::Dump(const MIRModule &mod, int32 indent) const { +void ExtractbitsNode::Dump(int32 indent) const { LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " " << GetPrimTypeName(GetPrimType()); if (GetOpCode() == OP_extractbits) { LogInfo::MapleLogger() << " " << static_cast(bitsOffset) << " " << static_cast(bitsSize); } else { LogInfo::MapleLogger() << " " << static_cast(bitsSize); } - DumpOpnd(mod, indent); + DumpOpnd(*theMIRModule, indent); } -void IreadNode::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); +void IreadNode::Dump(int32 indent) const { + BaseNode::DumpBase(0); LogInfo::MapleLogger() << " "; GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx)->Dump(0); LogInfo::MapleLogger() << " " << fieldID; - DumpOpnd(mod, indent); + DumpOpnd(*theMIRModule, indent); } -void IreadoffNode::Dump(const MIRModule &mod, int32 indent) const { +void IreadoffNode::Dump(int32 indent) const { LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " " << GetPrimTypeName(GetPrimType()); LogInfo::MapleLogger() << " " << offset; - DumpOpnd(mod, indent); + DumpOpnd(*theMIRModule, indent); } -void IreadFPoffNode::Dump(const MIRModule &mod, int32 indent) const { +void IreadFPoffNode::Dump(int32 indent) const { LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " " << GetPrimTypeName(GetPrimType()); LogInfo::MapleLogger() << " " << offset; } -void BinaryNode::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); - BinaryOpnds::Dump(mod, indent); +void BinaryNode::Dump(int32 indent) const { + BaseNode::DumpBase(0); + BinaryOpnds::Dump(indent); } -void BinaryNode::Dump(const MIRModule &mod) const { - this->BaseNode::Dump(mod); +void BinaryNode::Dump() const { + this->BaseNode::Dump(); } -void BinaryOpnds::Dump(const MIRModule &mod, int32 indent) const { +void BinaryOpnds::Dump(int32 indent) const { LogInfo::MapleLogger() << " ("; if (bOpnd[0]->IsLeaf() && bOpnd[1]->IsLeaf()) { - bOpnd[0]->Dump(mod, 0); + bOpnd[0]->Dump(0); LogInfo::MapleLogger() << ", "; - bOpnd[1]->Dump(mod, 0); + bOpnd[1]->Dump(0); } else { LogInfo::MapleLogger() << '\n'; PrintIndentation(indent + 1); - bOpnd[0]->Dump(mod, indent + 1); + bOpnd[0]->Dump(indent + 1); LogInfo::MapleLogger() << ",\n"; PrintIndentation(indent + 1); - bOpnd[1]->Dump(mod, indent + 1); + bOpnd[1]->Dump(indent + 1); } LogInfo::MapleLogger() << ")"; } -void ResolveFuncNode::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); +void ResolveFuncNode::Dump(int32 indent) const { + BaseNode::DumpBase(0); MIRFunction *func = GlobalTables::GetFunctionTable().GetFunctionFromPuidx(puIdx); LogInfo::MapleLogger() << " &" << func->GetName(); - BinaryOpnds::Dump(mod, indent); + BinaryOpnds::Dump(indent); } -void CompareNode::Dump(const MIRModule &mod, int32 indent) const { +void CompareNode::Dump(int32 indent) const { LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " " << GetPrimTypeName(GetPrimType()); LogInfo::MapleLogger() << " " << GetPrimTypeName(opndType); - BinaryOpnds::Dump(mod, indent); + BinaryOpnds::Dump(indent); } -void CompareNode::Dump(const MIRModule &mod) const { - this->BaseNode::Dump(mod); +void CompareNode::Dump() const { + this->BaseNode::Dump(); } -void DepositbitsNode::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); +void DepositbitsNode::Dump(int32 indent) const { + BaseNode::DumpBase(0); LogInfo::MapleLogger() << " " << static_cast(bitsOffset) << " " << static_cast(bitsSize) << " ("; if (GetBOpnd(0)->IsLeaf() && GetBOpnd(1)->IsLeaf()) { - GetBOpnd(0)->Dump(mod, 0); + GetBOpnd(0)->Dump(0); LogInfo::MapleLogger() << ", "; - GetBOpnd(1)->Dump(mod, 0); + GetBOpnd(1)->Dump(0); } else { LogInfo::MapleLogger() << '\n'; PrintIndentation(indent + 1); - GetBOpnd(0)->Dump(mod, indent + 1); + GetBOpnd(0)->Dump(indent + 1); LogInfo::MapleLogger() << ",\n"; PrintIndentation(indent + 1); - GetBOpnd(1)->Dump(mod, indent + 1); + GetBOpnd(1)->Dump(indent + 1); } LogInfo::MapleLogger() << ")"; } -void TernaryNode::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); +void TernaryNode::Dump(int32 indent) const { + BaseNode::DumpBase(0); LogInfo::MapleLogger() << " ("; if (topnd[0]->IsLeaf() && topnd[1]->IsLeaf() && topnd[2]->IsLeaf()) { - topnd[0]->Dump(mod, 0); + topnd[0]->Dump(0); LogInfo::MapleLogger() << ", "; - topnd[1]->Dump(mod, 0); + topnd[1]->Dump(0); LogInfo::MapleLogger() << ", "; - topnd[2]->Dump(mod, 0); + topnd[2]->Dump(0); } else { LogInfo::MapleLogger() << '\n'; PrintIndentation(indent + 1); - topnd[0]->Dump(mod, indent + 1); + topnd[0]->Dump(indent + 1); LogInfo::MapleLogger() << ",\n"; PrintIndentation(indent + 1); - topnd[1]->Dump(mod, indent + 1); + topnd[1]->Dump(indent + 1); LogInfo::MapleLogger() << ",\n"; PrintIndentation(indent + 1); - topnd[2]->Dump(mod, indent + 1); + topnd[2]->Dump(indent + 1); } LogInfo::MapleLogger() << ")"; } -void NaryOpnds::Dump(const MIRModule &mod, int32 indent) const { +void NaryOpnds::Dump(int32 indent) const { LogInfo::MapleLogger() << " ("; if (GetNopndSize() == 0) { LogInfo::MapleLogger() << ")"; return; } if (GetNopndSize() == 1) { - GetNopndAt(0)->Dump(mod, indent); + GetNopndAt(0)->Dump(indent); } else { bool allisLeaf = true; for (size_t i = 0; i < GetNopndSize(); ++i) @@ -375,19 +375,19 @@ void NaryOpnds::Dump(const MIRModule &mod, int32 indent) const { break; } if (allisLeaf) { - GetNopndAt(0)->Dump(mod, 0); + GetNopndAt(0)->Dump(0); for (size_t i = 1; i < GetNopndSize(); ++i) { LogInfo::MapleLogger() << ", "; - GetNopndAt(i)->Dump(mod, 0); + GetNopndAt(i)->Dump(0); } } else { LogInfo::MapleLogger() << '\n'; PrintIndentation(indent + 1); - GetNopndAt(0)->Dump(mod, indent + 1); + GetNopndAt(0)->Dump(indent + 1); for (size_t i = 1; i < GetNopndSize(); ++i) { LogInfo::MapleLogger() << ",\n"; PrintIndentation(indent + 1); - GetNopndAt(i)->Dump(mod, indent + 1); + GetNopndAt(i)->Dump(indent + 1); } } } @@ -405,9 +405,9 @@ bool NaryOpnds::VerifyOpnds() const { return nOpndsVerify; } -void NaryNode::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); - NaryOpnds::Dump(mod, indent); +void NaryNode::Dump(int32 indent) const { + BaseNode::DumpBase(0); + NaryOpnds::Dump(indent); } const MIRType *ArrayNode::GetArrayType(const TypeTable &tt) const { @@ -429,7 +429,7 @@ BaseNode *ArrayNode::GetDim(const MIRModule &mod, TypeTable &tt, int i) { return const_cast(const_cast(this)->GetDim(mod, tt, i)); } -void ArrayNode::Dump(const MIRModule &mod, int32 indent) const { +void ArrayNode::Dump(int32 indent) const { PrintIndentation(0); LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " "; if (boundsCheck) { @@ -440,7 +440,7 @@ void ArrayNode::Dump(const MIRModule &mod, int32 indent) const { LogInfo::MapleLogger() << GetPrimTypeName(GetPrimType()); LogInfo::MapleLogger() << " "; GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx)->Dump(0); - NaryOpnds::Dump(mod, indent); + NaryOpnds::Dump(indent); } bool ArrayNode::IsSameBase(ArrayNode *arry) { @@ -455,32 +455,32 @@ bool ArrayNode::IsSameBase(ArrayNode *arry) { return static_cast(curBase)->GetStIdx() == static_cast(otherBase)->GetStIdx(); } -void IntrinsicopNode::Dump(const MIRModule &mod, int32 indent) const { +void IntrinsicopNode::Dump(int32 indent) const { LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " " << GetPrimTypeName(GetPrimType()); if (GetOpCode() == OP_intrinsicopwithtype) { LogInfo::MapleLogger() << " "; GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx)->Dump(indent + 1); } LogInfo::MapleLogger() << " " << GetIntrinsicName(GetIntrinsic()); - NaryOpnds::Dump(mod, indent); + NaryOpnds::Dump(indent); } -void ConstvalNode::Dump(const MIRModule &mod, int32 indent) const { +void ConstvalNode::Dump(int32 indent) const { if (GetConstVal()->GetType().GetKind() != kTypePointer) { - BaseNode::DumpBase(mod, 0); + BaseNode::DumpBase(0); LogInfo::MapleLogger() << " "; } GetConstVal()->Dump(); } -void ConststrNode::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); +void ConststrNode::Dump(int32 indent) const { + BaseNode::DumpBase(0); const std::string kStr = GlobalTables::GetUStrTable().GetStringFromStrIdx(UStrIdx(strIdx)); PrintString(kStr); } -void Conststr16Node::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); +void Conststr16Node::Dump(int32 indent) const { + BaseNode::DumpBase(0); const std::u16string kStr16 = GlobalTables::GetU16StrTable().GetStringFromStrIdx(U16StrIdx(strIdx)); // UTF-16 string are dumped as UTF-8 string in mpl to keep the printable chars in ascii form std::string str; @@ -488,22 +488,22 @@ void Conststr16Node::Dump(const MIRModule &mod, int32 indent) const { PrintString(str); } -void SizeoftypeNode::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); +void SizeoftypeNode::Dump(int32 indent) const { + BaseNode::DumpBase(0); LogInfo::MapleLogger() << " "; GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx)->Dump(0); } -void FieldsDistNode::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); +void FieldsDistNode::Dump(int32 indent) const { + BaseNode::DumpBase(0); LogInfo::MapleLogger() << " "; GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx)->Dump(0); LogInfo::MapleLogger() << " " << fieldID1 << " " << fieldID2; } -void AddrofNode::Dump(const MIRModule &mod, int32 indent) const { +void AddrofNode::Dump(int32 indent) const { LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " " << GetPrimTypeName(GetPrimType()); - const MIRSymbol *st = mod.CurFunction()->GetLocalOrGlobalSymbol(GetStIdx()); + const MIRSymbol *st = theMIRModule->CurFunction()->GetLocalOrGlobalSymbol(GetStIdx()); LogInfo::MapleLogger() << (GetStIdx().Islocal() ? " %" : " $"); LogInfo::MapleLogger() << st->GetName(); if (fieldID != 0) { @@ -511,11 +511,11 @@ void AddrofNode::Dump(const MIRModule &mod, int32 indent) const { } } -void RegreadNode::Dump(const MIRModule &mod, int32 indent) const { +void RegreadNode::Dump(int32 indent) const { LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " " << GetPrimTypeName(GetPrimType()); if (regIdx >= 0) { LogInfo::MapleLogger() - << " %" << mod.CurFunction()->GetPregTab()->PregFromPregIdx(static_cast(regIdx))->GetPregNo(); + << " %" << theMIRModule->CurFunction()->GetPregTab()->PregFromPregIdx(static_cast(regIdx))->GetPregNo(); return; } LogInfo::MapleLogger() << " %%"; @@ -542,20 +542,20 @@ void RegreadNode::Dump(const MIRModule &mod, int32 indent) const { } } -void AddroffuncNode::Dump(const MIRModule &mod, int32 indent) const { +void AddroffuncNode::Dump(int32 indent) const { LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " " << GetPrimTypeName(GetPrimType()); MIRFunction *func = GlobalTables::GetFunctionTable().GetFunctionFromPuidx(puIdx); LogInfo::MapleLogger() << " &" << GlobalTables::GetGsymTable().GetSymbolFromStidx(func->GetStIdx().Idx())->GetName(); } -void AddroflabelNode::Dump(const MIRModule &mod, int32 indent) const { +void AddroflabelNode::Dump(int32 indent) const { LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name << " " << GetPrimTypeName(GetPrimType()); - LogInfo::MapleLogger() << " @" << mod.CurFunction()->GetLabelName((LabelIdx)offset); + LogInfo::MapleLogger() << " @" << theMIRModule->CurFunction()->GetLabelName((LabelIdx)offset); } -void StmtNode::DumpBase(const MIRModule &mod, int32 indent) const { +void StmtNode::DumpBase(int32 indent) const { if (srcPosition.FileNum() != 0 && srcPosition.LineNum() != 0 && srcPosition.LineNum() != lastPrintedLineNum && - mod.CurFunction()->WithLocInfo()) { + theMIRModule->CurFunction()->WithLocInfo()) { LogInfo::MapleLogger() << "LOC " << srcPosition.FileNum() << " " << srcPosition.LineNum() << '\n'; lastPrintedLineNum = srcPosition.LineNum(); } @@ -563,13 +563,13 @@ void StmtNode::DumpBase(const MIRModule &mod, int32 indent) const { LogInfo::MapleLogger() << kOpcodeInfo.GetTableItemAt(GetOpCode()).name; } -void StmtNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void StmtNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); LogInfo::MapleLogger() << '\n'; } -void StmtNode::Dump(const MIRModule &mod) const { - this->BaseNode::Dump(mod); +void StmtNode::Dump() const { + this->BaseNode::Dump(); } // Get the next stmt skip the comment stmt. @@ -604,26 +604,26 @@ void StmtNode::InsertBeforeThis(StmtNode &pos) { pos.SetNext(this); } -void DassignNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); - const MIRSymbol *st = mod.CurFunction()->GetLocalOrGlobalSymbol(stIdx); +void DassignNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); + const MIRSymbol *st = theMIRModule->CurFunction()->GetLocalOrGlobalSymbol(stIdx); LogInfo::MapleLogger() << (st->IsLocal() ? " %" : " $"); LogInfo::MapleLogger() << st->GetName() << " " << fieldID; LogInfo::MapleLogger() << " ("; if (GetRHS() != nullptr) { - GetRHS()->Dump(mod, indent + 1); + GetRHS()->Dump(indent + 1); } else { LogInfo::MapleLogger() << "/*empty-rhs*/"; } LogInfo::MapleLogger() << ")\n"; } -void RegassignNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void RegassignNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); LogInfo::MapleLogger() << " " << GetPrimTypeName(GetPrimType()); if (regIdx >= 0) { LogInfo::MapleLogger() - << " %" << mod.CurFunction()->GetPregTab()->PregFromPregIdx(static_cast(regIdx))->GetPregNo(); + << " %" << theMIRModule->CurFunction()->GetPregTab()->PregFromPregIdx(static_cast(regIdx))->GetPregNo(); } else { LogInfo::MapleLogger() << " %%"; switch (regIdx) { @@ -651,205 +651,205 @@ void RegassignNode::Dump(const MIRModule &mod, int32 indent) const { } } LogInfo::MapleLogger() << " ("; - UnaryStmtNode::Opnd()->Dump(mod, indent + 1); + UnaryStmtNode::Opnd()->Dump(indent + 1); LogInfo::MapleLogger() << ")\n"; } -void IassignNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void IassignNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); LogInfo::MapleLogger() << " "; GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx)->Dump(0); LogInfo::MapleLogger() << " " << fieldID; LogInfo::MapleLogger() << " ("; if (addrExpr->IsLeaf() && rhs->IsLeaf()) { - addrExpr->Dump(mod, 0); + addrExpr->Dump(0); LogInfo::MapleLogger() << ", "; - rhs->Dump(mod, 0); + rhs->Dump(0); } else { LogInfo::MapleLogger() << '\n'; PrintIndentation(indent + 1); - addrExpr->Dump(mod, indent + 1); + addrExpr->Dump(indent + 1); LogInfo::MapleLogger() << ", \n"; PrintIndentation(indent + 1); - rhs->Dump(mod, indent + 1); + rhs->Dump(indent + 1); } LogInfo::MapleLogger() << ")\n"; } -void IassignoffNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void IassignoffNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); LogInfo::MapleLogger() << " " << GetPrimTypeName(GetPrimType()) << " " << offset; - BinaryOpnds::Dump(mod, indent); + BinaryOpnds::Dump(indent); LogInfo::MapleLogger() << '\n'; } -void IassignFPoffNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void IassignFPoffNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); LogInfo::MapleLogger() << " " << GetPrimTypeName(GetPrimType()) << " " << offset; - DumpOpnd(mod, indent); + DumpOpnd(*theMIRModule, indent); LogInfo::MapleLogger() << '\n'; } -void GotoNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void GotoNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); if (offset == 0) { LogInfo::MapleLogger() << '\n'; } else { - LogInfo::MapleLogger() << " @" << mod.CurFunction()->GetLabelName((LabelIdx)offset) << '\n'; + LogInfo::MapleLogger() << " @" << theMIRModule->CurFunction()->GetLabelName((LabelIdx)offset) << '\n'; } } -void JsTryNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void JsTryNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); if (catchOffset == 0) { LogInfo::MapleLogger() << " 0"; } else { - LogInfo::MapleLogger() << " @" << mod.CurFunction()->GetLabelName((LabelIdx)catchOffset); + LogInfo::MapleLogger() << " @" << theMIRModule->CurFunction()->GetLabelName((LabelIdx)catchOffset); } if (finallyOffset == 0) { LogInfo::MapleLogger() << " 0\n"; } else { - LogInfo::MapleLogger() << " @" << mod.CurFunction()->GetLabelName((LabelIdx)finallyOffset) << '\n'; + LogInfo::MapleLogger() << " @" << theMIRModule->CurFunction()->GetLabelName((LabelIdx)finallyOffset) << '\n'; } } -void TryNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void TryNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); LogInfo::MapleLogger() << " {"; for (size_t i = 0; i < offsets.size(); ++i) { int64 offset = offsets[i]; - LogInfo::MapleLogger() << " @" << mod.CurFunction()->GetLabelName((LabelIdx)offset); + LogInfo::MapleLogger() << " @" << theMIRModule->CurFunction()->GetLabelName((LabelIdx)offset); } LogInfo::MapleLogger() << " }\n"; } -void TryNode::Dump(const MIRModule &mod) const { - this->BaseNode::Dump(mod); +void TryNode::Dump() const { + this->BaseNode::Dump(); } -void CondGotoNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); - LogInfo::MapleLogger() << " @" << mod.CurFunction()->GetLabelName((LabelIdx)offset); +void CondGotoNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); + LogInfo::MapleLogger() << " @" << theMIRModule->CurFunction()->GetLabelName((LabelIdx)offset); LogInfo::MapleLogger() << " ("; - Opnd()->Dump(mod, indent); + Opnd()->Dump(indent); LogInfo::MapleLogger() << ")\n"; } -void SwitchNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void SwitchNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); LogInfo::MapleLogger() << " ("; - switchOpnd->Dump(mod, indent); + switchOpnd->Dump(indent); if (defaultLabel == 0) { LogInfo::MapleLogger() << ") 0 {"; } else { - LogInfo::MapleLogger() << ") @" << mod.CurFunction()->GetLabelName(defaultLabel) << " {"; + LogInfo::MapleLogger() << ") @" << theMIRModule->CurFunction()->GetLabelName(defaultLabel) << " {"; } for (auto it = switchTable.begin(); it != switchTable.end(); it++) { LogInfo::MapleLogger() << '\n'; PrintIndentation(indent + 1); LogInfo::MapleLogger() << std::hex << "0x" << it->first << std::dec; - LogInfo::MapleLogger() << ": goto @" << mod.CurFunction()->GetLabelName(it->second); + LogInfo::MapleLogger() << ": goto @" << theMIRModule->CurFunction()->GetLabelName(it->second); } LogInfo::MapleLogger() << " }\n"; } -void RangeGotoNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void RangeGotoNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); LogInfo::MapleLogger() << " ("; - Opnd()->Dump(mod, indent); + Opnd()->Dump(indent); LogInfo::MapleLogger() << ") " << tagOffset << " {"; for (auto it = rangegotoTable.begin(); it != rangegotoTable.end(); it++) { LogInfo::MapleLogger() << '\n'; PrintIndentation(indent + 1); LogInfo::MapleLogger() << std::hex << "0x" << it->first << std::dec; - LogInfo::MapleLogger() << ": goto @" << mod.CurFunction()->GetLabelName(it->second); + LogInfo::MapleLogger() << ": goto @" << theMIRModule->CurFunction()->GetLabelName(it->second); } LogInfo::MapleLogger() << " }\n"; } -void MultiwayNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void MultiwayNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); LogInfo::MapleLogger() << " ("; - multiWayOpnd->Dump(mod, indent); + multiWayOpnd->Dump(indent); if (defaultLabel == 0) { LogInfo::MapleLogger() << ") 0 {"; } else { - LogInfo::MapleLogger() << ") @" << mod.CurFunction()->GetLabelName(defaultLabel) << " {"; + LogInfo::MapleLogger() << ") @" << theMIRModule->CurFunction()->GetLabelName(defaultLabel) << " {"; } for (auto it = multiWayTable.begin(); it != multiWayTable.end(); it++) { LogInfo::MapleLogger() << '\n'; PrintIndentation(indent); LogInfo::MapleLogger() << " ("; - it->first->Dump(mod, indent + 1); - LogInfo::MapleLogger() << "): goto @" << mod.CurFunction()->GetLabelName(it->second); + it->first->Dump(indent + 1); + LogInfo::MapleLogger() << "): goto @" << theMIRModule->CurFunction()->GetLabelName(it->second); } LogInfo::MapleLogger() << " }\n"; } void UnaryStmtNode::DumpOpnd(const MIRModule &mod, int indent) const { LogInfo::MapleLogger() << " ("; - uOpnd->Dump(mod, indent); + uOpnd->Dump(indent); LogInfo::MapleLogger() << ")"; } -void UnaryStmtNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void UnaryStmtNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); LogInfo::MapleLogger() << " ("; if (uOpnd) { - uOpnd->Dump(mod, indent); + uOpnd->Dump(indent); } LogInfo::MapleLogger() << ")\n"; } -void UnaryStmtNode::Dump(const MIRModule &mod) const { - this->BaseNode::Dump(mod); +void UnaryStmtNode::Dump() const { + this->BaseNode::Dump(); } -void GCMallocNode::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); +void GCMallocNode::Dump(int32 indent) const { + BaseNode::DumpBase(0); LogInfo::MapleLogger() << " "; GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx)->Dump(0); } -void JarrayMallocNode::Dump(const MIRModule &mod, int32 indent) const { - BaseNode::DumpBase(mod, 0); +void JarrayMallocNode::Dump(int32 indent) const { + BaseNode::DumpBase(0); LogInfo::MapleLogger() << " "; GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx)->Dump(0, false); - DumpOpnd(mod, indent); + DumpOpnd(*theMIRModule, indent); } -void IfStmtNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void IfStmtNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); LogInfo::MapleLogger() << " ("; - Opnd()->Dump(mod, indent); + Opnd()->Dump(indent); LogInfo::MapleLogger() << ")"; - thenPart->Dump(mod, indent); + thenPart->Dump(indent); if (elsePart) { PrintIndentation(indent); LogInfo::MapleLogger() << "else {\n"; for (auto &stmt : elsePart->GetStmtNodes()) { - stmt.Dump(mod, indent + 1); + stmt.Dump(indent + 1); } PrintIndentation(indent); LogInfo::MapleLogger() << "}\n"; } } -void WhileStmtNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); +void WhileStmtNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); if (GetOpCode() == OP_while) { LogInfo::MapleLogger() << " ("; - Opnd()->Dump(mod, indent); + Opnd()->Dump(indent); LogInfo::MapleLogger() << ")"; - body->Dump(mod, indent); + body->Dump(indent); } else { // OP_dowhile LogInfo::MapleLogger() << " {\n"; for (auto &stmt : body->GetStmtNodes()) { - stmt.Dump(mod, indent + 1); + stmt.Dump(indent + 1); } PrintIndentation(indent); LogInfo::MapleLogger() << "} ("; - Opnd()->Dump(mod, indent); + Opnd()->Dump(indent); LogInfo::MapleLogger() << ")\n"; } } @@ -865,46 +865,46 @@ void DoloopNode::DumpDoVar(const MIRModule &mod) const { } } -void DoloopNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); - DumpDoVar(mod); +void DoloopNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); + DumpDoVar(*theMIRModule); PrintIndentation(indent + 1); - startExpr->Dump(mod, indent + 1); + startExpr->Dump(indent + 1); LogInfo::MapleLogger() << ",\n"; PrintIndentation(indent + 1); - condExpr->Dump(mod, indent + 1); + condExpr->Dump(indent + 1); LogInfo::MapleLogger() << ",\n"; PrintIndentation(indent + 1); - incrExpr->Dump(mod, indent + 1); + incrExpr->Dump(indent + 1); LogInfo::MapleLogger() << ")"; - doBody->Dump(mod, indent + 1); + doBody->Dump(indent + 1); } -void ForeachelemNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); - const MIRSymbol *st = mod.CurFunction()->GetLocalOrGlobalSymbol(elemStIdx); +void ForeachelemNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); + const MIRSymbol *st = theMIRModule->CurFunction()->GetLocalOrGlobalSymbol(elemStIdx); ASSERT(st != nullptr, "null ptr check"); LogInfo::MapleLogger() << " %" << st->GetName(); - st = mod.CurFunction()->GetLocalOrGlobalSymbol(arrayStIdx); + st = theMIRModule->CurFunction()->GetLocalOrGlobalSymbol(arrayStIdx); ASSERT(st != nullptr, "null ptr check"); LogInfo::MapleLogger() << (arrayStIdx.Islocal() ? " %" : " $"); LogInfo::MapleLogger() << st->GetName(); - loopBody->Dump(mod, indent + 1); + loopBody->Dump(indent + 1); } -void BinaryStmtNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); - BinaryOpnds::Dump(mod, indent); +void BinaryStmtNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); + BinaryOpnds::Dump(indent); LogInfo::MapleLogger() << '\n'; } -void AssertStmtNode::Dump(const MIRModule &mod, int32 indent) const { - BinaryStmtNode::Dump(mod, indent); +void AssertStmtNode::Dump(int32 indent) const { + BinaryStmtNode::Dump(indent); } -void NaryStmtNode::Dump(const MIRModule &mod, int32 indent) const { - StmtNode::DumpBase(mod, indent); - NaryOpnds::Dump(mod, indent); +void NaryStmtNode::Dump(int32 indent) const { + StmtNode::DumpBase(indent); + NaryOpnds::Dump(indent); LogInfo::MapleLogger() << '\n'; } @@ -985,8 +985,8 @@ const MIRSymbol *CallNode::GetCallReturnSymbol(const MIRModule &mod) const { } -void CallNode::Dump(const MIRModule &mod, int32 indent, bool newline) const { - StmtNode::DumpBase(mod, indent); +void CallNode::Dump(int32 indent, bool newline) const { + StmtNode::DumpBase(indent); if (tyIdx != 0) { LogInfo::MapleLogger() << " "; GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx)->Dump(indent + 1); @@ -994,9 +994,9 @@ void CallNode::Dump(const MIRModule &mod, int32 indent, bool newline) const { CHECK(puIdx < GlobalTables::GetFunctionTable().GetFuncTable().size(), "index out of range in CallNode::Dump"); MIRFunction *func = GlobalTables::GetFunctionTable().GetFunctionFromPuidx(puIdx); LogInfo::MapleLogger() << " &" << func->GetName(); - NaryOpnds::Dump(mod, indent); + NaryOpnds::Dump(indent); if (kOpcodeInfo.IsCallAssigned(GetOpCode())) { - DumpCallReturns(mod, this->GetReturnVec(), indent); + DumpCallReturns(*theMIRModule, this->GetReturnVec(), indent); } else if (newline) { LogInfo::MapleLogger() << '\n'; } @@ -1006,11 +1006,11 @@ MIRType *IcallNode::GetCallReturnType() { return GlobalTables::GetTypeTable().GetTypeFromTyIdx(retTyIdx); } -void IcallNode::Dump(const MIRModule &mod, int32 indent, bool newline) const { - StmtNode::DumpBase(mod, indent); - NaryOpnds::Dump(mod, indent); +void IcallNode::Dump(int32 indent, bool newline) const { + StmtNode::DumpBase(indent); + NaryOpnds::Dump(indent); if (kOpcodeInfo.IsCallAssigned(GetOpCode())) { - DumpCallReturns(mod, this->returnValues, indent); + DumpCallReturns(*theMIRModule, this->returnValues, indent); } else if (newline) { LogInfo::MapleLogger() << '\n'; } @@ -1022,8 +1022,8 @@ MIRType *IntrinsiccallNode::GetCallReturnType() { return intrinDesc->GetReturnType(); } -void IntrinsiccallNode::Dump(const MIRModule &mod, int32 indent, bool newline) const { - StmtNode::DumpBase(mod, indent); +void IntrinsiccallNode::Dump(int32 indent, bool newline) const { + StmtNode::DumpBase(indent); if (tyIdx != 0) { LogInfo::MapleLogger() << " "; GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx)->Dump(indent + 1); @@ -1034,16 +1034,16 @@ void IntrinsiccallNode::Dump(const MIRModule &mod, int32 indent, bool newline) c } else { LogInfo::MapleLogger() << " " << intrinsic; } - NaryOpnds::Dump(mod, indent); + NaryOpnds::Dump(indent); if (kOpcodeInfo.IsCallAssigned(GetOpCode())) { - DumpCallReturns(mod, this->GetReturnVec(), indent); + DumpCallReturns(*theMIRModule, this->GetReturnVec(), indent); } else if (newline) { LogInfo::MapleLogger() << '\n'; } } -void CallinstantNode::Dump(const MIRModule &mod, int32 indent, bool newline) const { - StmtNode::DumpBase(mod, indent); +void CallinstantNode::Dump(int32 indent, bool newline) const { + StmtNode::DumpBase(indent); MIRFunction *func = GlobalTables::GetFunctionTable().GetFunctionFromPuidx(GetPUIdx()); LogInfo::MapleLogger() << " &" << func->GetName(); MIRType *ty = GlobalTables::GetTypeTable().GetTypeFromTyIdx(instVecTyIdx); @@ -1051,25 +1051,25 @@ void CallinstantNode::Dump(const MIRModule &mod, int32 indent, bool newline) con auto *instVecType = static_cast(ty); instVecType->Dump(indent); LogInfo::MapleLogger() << ">"; - NaryOpnds::Dump(mod, indent); + NaryOpnds::Dump(indent); if (kOpcodeInfo.IsCallAssigned(GetOpCode())) { - DumpCallReturns(mod, this->GetReturnVec(), indent); + DumpCallReturns(*theMIRModule, this->GetReturnVec(), indent); } else if (newline) { LogInfo::MapleLogger() << '\n'; } } -void BlockNode::Dump(const MIRModule &mod, int32 indent, const MIRSymbolTable *theSymTab, MIRPregTable *thePregTab, +void BlockNode::Dump(int32 indent, const MIRSymbolTable *theSymTab, MIRPregTable *thePregTab, bool withInfo, bool isFuncbody) const { if (!withInfo) { LogInfo::MapleLogger() << " {\n"; } // output puid for debugging purpose if (isFuncbody) { - mod.CurFunction()->DumpFuncBody(indent); + theMIRModule->CurFunction()->DumpFuncBody(indent); if (theSymTab != nullptr && thePregTab != nullptr) { // print the locally declared type names - for (auto it : mod.CurFunction()->GetGStrIdxToTyIdxMap()) { + for (auto it : theMIRModule->CurFunction()->GetGStrIdxToTyIdxMap()) { const std::string &name = GlobalTables::GetStrTable().GetStringFromStrIdx(it.first); MIRType *type = GlobalTables::GetTypeTable().GetTypeFromTyIdx(it.second); PrintIndentation(indent + 1); @@ -1086,7 +1086,7 @@ void BlockNode::Dump(const MIRModule &mod, int32 indent, const MIRSymbolTable *t thePregTab->DumpRef(indent + 1); } LogInfo::MapleLogger() << '\n'; - for (std::pair it : mod.CurFunction()->GetAliasVarMap()) { + for (std::pair it : theMIRModule->CurFunction()->GetAliasVarMap()) { LogInfo::MapleLogger() << "ALIAS %" << GlobalTables::GetStrTable().GetStringFromStrIdx(it.first) << " %" << GlobalTables::GetStrTable().GetStringFromStrIdx(it.second.memPoolStrIdx) << " "; GlobalTables::GetTypeTable().GetTypeFromTyIdx(it.second.tyIdx)->Dump(0); @@ -1097,29 +1097,29 @@ void BlockNode::Dump(const MIRModule &mod, int32 indent, const MIRSymbolTable *t } } if (srcPosition.FileNum() != 0 && srcPosition.LineNum() != 0 && srcPosition.LineNum() != lastPrintedLineNum && - mod.CurFunction()->WithLocInfo()) { + theMIRModule->CurFunction()->WithLocInfo()) { LogInfo::MapleLogger() << "LOC " << srcPosition.FileNum() << " " << srcPosition.LineNum() << '\n'; lastPrintedLineNum = srcPosition.LineNum(); } for (auto &stmt : GetStmtNodes()) { - stmt.Dump(mod, indent + 1); + stmt.Dump(indent + 1); } PrintIndentation(indent); LogInfo::MapleLogger() << "}\n"; } -void LabelNode::Dump(const MIRModule &mod, int32 indent) const { +void LabelNode::Dump(int32 indent) const { if (srcPosition.FileNum() != 0 && srcPosition.LineNum() != 0 && srcPosition.LineNum() != lastPrintedLineNum && - mod.CurFunction()->WithLocInfo()) { + theMIRModule->CurFunction()->WithLocInfo()) { LogInfo::MapleLogger() << "LOC " << srcPosition.FileNum() << " " << srcPosition.LineNum() << '\n'; lastPrintedLineNum = srcPosition.LineNum(); } - LogInfo::MapleLogger() << "@" << mod.CurFunction()->GetLabelName(labelIdx) << " "; + LogInfo::MapleLogger() << "@" << theMIRModule->CurFunction()->GetLabelName(labelIdx) << " "; } -void CommentNode::Dump(const MIRModule &mod, int32 indent) const { +void CommentNode::Dump(int32 indent) const { if (srcPosition.FileNum() != 0 && srcPosition.LineNum() != 0 && srcPosition.LineNum() != lastPrintedLineNum && - mod.CurFunction()->WithLocInfo()) { + theMIRModule->CurFunction()->WithLocInfo()) { LogInfo::MapleLogger() << "LOC " << srcPosition.FileNum() << " " << srcPosition.LineNum() << '\n'; lastPrintedLineNum = srcPosition.LineNum(); } @@ -1146,7 +1146,7 @@ bool ArithTypeVerify(const BaseNode &opnd) { bool verifyResult = ExcludeSmallIntTypeVerify(opnd); if (!verifyResult) { LogInfo::MapleLogger() << "\n#Error:u1,i8,u8,i16,u16 should not be used as types of arithmetic operations\n"; - opnd.Dump(*theMIRModule); + opnd.Dump(); } return verifyResult; } @@ -1156,7 +1156,7 @@ inline bool ReadTypeVerify(const BaseNode &opnd) { if (!verifyResult) { LogInfo::MapleLogger() << "\n#Error:u1,i8,u8,i16,u16 should not be used as result types for dread/iread/regread/ireadoff/ireadfpoff\n"; - opnd.Dump(*theMIRModule); + opnd.Dump(); } return verifyResult; } @@ -1285,8 +1285,8 @@ bool CompatibleTypeVerify(const BaseNode &opnd1, const BaseNode &opnd2) { } if (!verifyResult) { LogInfo::MapleLogger() << "\n#Error:incompatible operand types :\n"; - opnd1.Dump(*theMIRModule); - opnd2.Dump(*theMIRModule); + opnd1.Dump(); + opnd2.Dump(); } return verifyResult; } @@ -1554,12 +1554,12 @@ bool BinaryNode::Verify() const { resTypeVerf = true; // don't print the same kind of error message twice if (GetOpCode() != OP_add && GetOpCode() != OP_sub) { LogInfo::MapleLogger() << "\n#Error: Only add and sub are allowed for pointer arithemetic\n"; - this->Dump(*theMIRModule); + this->Dump(); } else if (!IsAddress(GetPrimType())) { LogInfo::MapleLogger() << "\n#Error: Adding an offset to a pointer or subtracting one from a pointer should result in a pointer " "value\n"; - this->Dump(*theMIRModule); + this->Dump(); } } } @@ -1567,7 +1567,7 @@ bool BinaryNode::Verify() const { LogInfo::MapleLogger() << "\n#Error:result type of [add,div,sub,mul,max,min] and [ashr,band,bior,bxor,land,lior,lshr,shl,rem] must " "be in [i32,u32,i64,u64,f32,f64,dynamic-type]\n"; - this->Dump(*theMIRModule); + this->Dump(); } bool comp0Verf = CompatibleTypeVerify(*GetBOpnd(0), *this); bool comp1Verf = CompatibleTypeVerify(*GetBOpnd(1), *this); @@ -1591,7 +1591,7 @@ bool CompareNode::Verify() const { bool compVerf = CompatibleTypeVerify(*GetBOpnd(0), *GetBOpnd(1)); bool resTypeVerf = CompareTypeVerify(GetPrimType()); if (!resTypeVerf) { - this->Dump(*theMIRModule); + this->Dump(); } bool signVerf = true; bool typeVerf = compVerf && resTypeVerf; diff --git a/src/maple_ir/src/parser.cpp b/src/maple_ir/src/parser.cpp index a3c79ca9d20228274678a459886c1dfd5ad03849..58d8d6ebe0494e052b3fd5a7f82ab4e129287f5d 100644 --- a/src/maple_ir/src/parser.cpp +++ b/src/maple_ir/src/parser.cpp @@ -1724,7 +1724,8 @@ bool MIRParser::ParseDeclareVar(MIRSymbol &symbol) { bool allowEmpty = false; // allow empty initialization for vtable, itable, vtableOffsetTable and fieldOffsetTable if (symbolStrName.find(VTAB_PREFIX_STR) == 0 || symbolStrName.find(NameMangler::kVtabOffsetTabStr) == 0 || - symbolStrName.find(ITAB_PREFIX_STR) == 0 || symbolStrName.find(NameMangler::kFieldOffsetTabStr) == 0) { + symbolStrName.find(ITAB_PREFIX_STR) == 0 || symbolStrName.find(NameMangler::kFieldOffsetTabStr) == 0 || + symbolStrName.find(ITAB_CONFLICT_PREFIX_STR) == 0) { allowEmpty = true; } if (!ParseInitValue(mirConst, tyIdx, allowEmpty)) { diff --git a/src/maple_me/include/dse.h b/src/maple_me/include/dse.h index 4ba0681f655cc9698e013ede20c8f252c38bb76d..ab4e79187f3f25731c4be256249ba2dbeb405ab8 100644 --- a/src/maple_me/include/dse.h +++ b/src/maple_me/include/dse.h @@ -28,7 +28,8 @@ class DSE { public: DSE(MIRModule &mod, std::vector &&bbVec, BB &commonEntryBB, BB &commonExitBB, SSATab &ssaTab, Dominance &postDom, bool enableDebug = false) - : enableDebug(enableDebug), mirModule(mod), bbVec(bbVec), commonEntryBB(commonEntryBB), + : enableDebug(enableDebug), + bbVec(bbVec), commonEntryBB(commonEntryBB), commonExitBB(commonExitBB), ssaTab(ssaTab), postDom(postDom), bbRequired(bbVec.size(), false) {} @@ -106,7 +107,6 @@ class DSE { bool StmtMustRequired(const StmtNode &stmt, BB &bb); void DumpStmt(const StmtNode &stmt, const std::string &msg); - MIRModule &mirModule; std::vector bbVec; BB &commonEntryBB; BB &commonExitBB; diff --git a/src/maple_me/include/ssa_mir_nodes.h b/src/maple_me/include/ssa_mir_nodes.h index 207a88a2abe42bef672bb9731a9fed15ddf1e403..5a73ef2e4050ee20934a530e3f324392ca26f87d 100644 --- a/src/maple_me/include/ssa_mir_nodes.h +++ b/src/maple_me/include/ssa_mir_nodes.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. @@ -480,8 +480,8 @@ class AddrofSSANode : public SSANode { ~AddrofSSANode() override = default; - void Dump(const MIRModule &mod, int32 indent) const override { - addrofNode->Dump(mod, indent); + void Dump(int32 indent) const override { + addrofNode->Dump(indent); if (GetSSAVar() != nullptr) { GetSSAVar()->Dump(true); } @@ -505,11 +505,11 @@ class IreadSSANode : public SSANode { ~IreadSSANode() override = default; - void Dump(const MIRModule &mod, int32 indent) const override { + void Dump(int32 indent) const override { if (GetSSAVar() != nullptr) { GetSSAVar()->Dump(true); } - ireadNode->Dump(mod, indent); + ireadNode->Dump(indent); } FieldID GetFieldID() const { @@ -538,8 +538,8 @@ class RegreadSSANode : public SSANode { ~RegreadSSANode() override = default; - void Dump(const MIRModule &mod, int32 indent) const override { - regreadNode->Dump(mod, indent); + void Dump(int32 indent) const override { + regreadNode->Dump(indent); if (GetSSAVar() != nullptr) { GetSSAVar()->Dump(true); } diff --git a/src/maple_me/src/bb.cpp b/src/maple_me/src/bb.cpp index ad5d167308051881c017862229421583b447ccd6..8a26c3e8e5cef10c59f3f8f94e1e57c76b600732 100644 --- a/src/maple_me/src/bb.cpp +++ b/src/maple_me/src/bb.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. @@ -88,7 +88,7 @@ void BB::DumpHeader(MIRModule *mod) const { if (bbLabel != 0) { static LabelNode lblNode; lblNode.SetLabelIdx(bbLabel); - lblNode.Dump(*mod, 0); + lblNode.Dump(0); mod->GetOut() << '\n'; } } @@ -97,7 +97,7 @@ void BB::Dump(MIRModule *mod) { DumpHeader(mod); DumpPhi(); for (auto &stmt : stmtNodeList) { - stmt.Dump(*mod, 1); + stmt.Dump(1); } } diff --git a/src/maple_me/src/dse.cpp b/src/maple_me/src/dse.cpp index 7a68c8e7bb7492b36b734c9428877e2bcc444f75..b1dc8a44099a2c89188d51fac3b419cd9392acdf 100644 --- a/src/maple_me/src/dse.cpp +++ b/src/maple_me/src/dse.cpp @@ -125,7 +125,7 @@ bool DSE::StmtMustRequired(const StmtNode &stmt, BB &bb) { void DSE::DumpStmt(const StmtNode &stmt, const std::string &msg) { if (enableDebug) { LogInfo::MapleLogger() << msg; - stmt.Dump(mirModule); + stmt.Dump(); } } diff --git a/src/maple_me/src/me_cfg.cpp b/src/maple_me/src/me_cfg.cpp index 8ccdc6429b5a6937941652f43f082996aa37525a..751461fd8735ba7ea8ec00493d75e2b0f2029773 100644 --- a/src/maple_me/src/me_cfg.cpp +++ b/src/maple_me/src/me_cfg.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. @@ -788,7 +788,7 @@ void MeCFG::DumpToFileInStrs(std::ofstream &cfgFile) const { if (ContainsConststr(stmt)) { continue; } - stmt.Dump(func.GetMIRModule(), 1); + stmt.Dump(1); } cfgFile << "}\"];\n"; } diff --git a/src/maple_me/src/me_irmap.cpp b/src/maple_me/src/me_irmap.cpp index 836bb75e1b4a2f5f65210509775b609c17f007c8..64fffbb56d830c7d2a942328e6124e8d67c63543 100644 --- a/src/maple_me/src/me_irmap.cpp +++ b/src/maple_me/src/me_irmap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. @@ -48,7 +48,7 @@ void MeIRMap::Dump() { LogInfo::MapleLogger() << "(" << i++ << ") "; } if (meStmt.GetOp() != OP_piassign) { - meStmt.EmitStmt(GetSSATab()).Dump(GetMIRModule(), 0); + meStmt.EmitStmt(GetSSATab()).Dump(0); } meStmt.Dump(this); } diff --git a/src/maple_me/src/ssa_mir_nodes.cpp b/src/maple_me/src/ssa_mir_nodes.cpp index 083f8510f7f43bebd57bbd3b0578cd211015c13f..afa2bc0396eb39b4b550e961bb04f6cb2bdb8b9a 100644 --- a/src/maple_me/src/ssa_mir_nodes.cpp +++ b/src/maple_me/src/ssa_mir_nodes.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. @@ -20,7 +20,7 @@ namespace maple { void GenericSSAPrint(MIRModule &mod, const StmtNode &stmtNode, int32 indent, StmtsSSAPart &stmtsSSAPart) { - stmtNode.Dump(mod, indent); + stmtNode.Dump(indent); // print SSAPart Opcode op = stmtNode.GetOpCode(); AccessSSANodes *ssaPart = stmtsSSAPart.SSAPartOf(stmtNode); diff --git a/src/maple_me/src/ver_symbol.cpp b/src/maple_me/src/ver_symbol.cpp index 582d0ffd9624be1864d127694594c4db865282f2..fab15a05021b843654ca259529d2ac56bd6678d7 100644 --- a/src/maple_me/src/ver_symbol.cpp +++ b/src/maple_me/src/ver_symbol.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. @@ -25,7 +25,7 @@ void VersionSt::DumpDefStmt(const MIRModule *mod) const { } switch (defType) { case kAssign: - defStmt.assign->Dump(*mod, 0); + defStmt.assign->Dump(0); return; case kPhi: defStmt.phi->Dump();