diff --git a/src/mapleall/maple_ir/include/mir_type.h b/src/mapleall/maple_ir/include/mir_type.h index fd26ca391f853279ac556cffec0528f47677aa81..e024962155290539299d5f9e292a629c6777c446 100644 --- a/src/mapleall/maple_ir/include/mir_type.h +++ b/src/mapleall/maple_ir/include/mir_type.h @@ -37,6 +37,7 @@ constexpr size_t kMaxArrayDim = 10; const std::string kJstrTypeName = "constStr"; #if MIR_FEATURE_FULL extern bool VerifyPrimType(PrimType primType1, PrimType primType2); // verify if primType1 and primType2 match +extern PrimType GetExactPtrPrimType(); // return either PTY_a64 or PTY_a32 extern uint32 GetPrimTypeSize(PrimType primType); // answer in bytes; 0 if unknown extern uint32 GetPrimTypeP2Size(PrimType primType); // answer in bytes in power-of-two. extern PrimType GetSignedPrimType(PrimType primType); // return signed version diff --git a/src/mapleall/maple_ir/src/mir_type.cpp b/src/mapleall/maple_ir/src/mir_type.cpp index b0a6652881de88efdb31cbb9a86b9e5ffbe67bd9..d2c76ddcd138fce798c37700ba7911310ad58823 100644 --- a/src/mapleall/maple_ir/src/mir_type.cpp +++ b/src/mapleall/maple_ir/src/mir_type.cpp @@ -195,6 +195,11 @@ bool IsNoCvtNeeded(PrimType toType, PrimType fromType) { #define POINTER_SIZE 4 #define POINTER_P2SIZE 2 #endif + +PrimType GetExactPtrPrimType() { + return (POINTER_SIZE == 8) ? PTY_a64 : PTY_a32; +} + // answer in bytes; 0 if unknown uint32 GetPrimTypeSize(PrimType primType) { switch (primType) { diff --git a/src/mapleall/maple_ir/src/parser.cpp b/src/mapleall/maple_ir/src/parser.cpp index f9f55b7316bf57dd204d66c9dbe243a87982441b..4adcdf6241f3907364c08e4506dcd3fd2b5c450d 100644 --- a/src/mapleall/maple_ir/src/parser.cpp +++ b/src/mapleall/maple_ir/src/parser.cpp @@ -1214,9 +1214,9 @@ bool MIRParser::ParsePointType(TyIdx &tyIdx) { return false; } ASSERT(pointTypeIdx != 0u, "something wrong with parsing element type "); - PrimType pty = mod.IsJavaModule() ? PTY_ref : PTY_ptr; + PrimType pty = mod.IsJavaModule() ? PTY_ref : GetExactPtrPrimType(); if (pdtk == maple::TK_constStr) { - pty = PTY_ptr; + pty = GetExactPtrPrimType(); } MIRPtrType pointType(pointTypeIdx, pty); // use reference type here if (!ParseTypeAttrs(pointType.GetTypeAttrs())) { diff --git a/src/mapleall/maple_me/src/me_ivopts.cpp b/src/mapleall/maple_me/src/me_ivopts.cpp index 534a712fe80da5f66be1686cf5eef3f10bb88b7b..3edd512ab34d47bf6e6773fe578e2c71f3aeaadd 100644 --- a/src/mapleall/maple_me/src/me_ivopts.cpp +++ b/src/mapleall/maple_me/src/me_ivopts.cpp @@ -1437,7 +1437,9 @@ MeExpr *IVOptimizer::ComputeExtraExprOfBase(MeExpr &candBase, MeExpr &groupBase, continue; } if (itGroup == groupMap.end()) { - if (itCand.second.first->GetPrimType() == PTY_ptr) { // it's not good to use one obj to form others + if (itCand.second.first->GetPrimType() == PTY_ptr || + itCand.second.first->GetPrimType() == PTY_a64 || + itCand.second.first->GetPrimType() == PTY_a32) { // it's not good to use one obj to form others replaced = false; return nullptr; } diff --git a/src/mapleall/maple_me/src/me_predict.cpp b/src/mapleall/maple_me/src/me_predict.cpp index 18cd057fe9e62da9c3f40b0952597ee4ee921643..0f1e9cef8a4b51f48d211662d98e1a80fd7a5f11 100644 --- a/src/mapleall/maple_me/src/me_predict.cpp +++ b/src/mapleall/maple_me/src/me_predict.cpp @@ -107,7 +107,7 @@ Predictor MePrediction::ReturnPrediction(const MeExpr *val, Prediction &predicti return kPredNoPrediction; } PrimType retType = constExpr->GetPrimType(); - if ((retType == PTY_ref || retType == PTY_ptr) && constExpr->IsZero()) { + if (MustBeAddress(retType) && constExpr->IsZero()) { // nullptr is usually not returned. prediction = kNotTaken; return kPredNullReturn; @@ -383,10 +383,10 @@ void MePrediction::PredictByOpcode(const BB *bb) { } PrimType pty = op0->GetPrimType(); - bool isCmpPtr = cmpExpr->GetOpndType() == PTY_ptr || cmpExpr->GetOpndType() == PTY_ref; + bool isCmpPtr = MustBeAddress(cmpExpr->GetOpndType()); // cmpExpr is not always real compare op, so we should check nullptr for op0 and op1 - bool isOpnd0Ptr = op0 != nullptr && (op0->GetPrimType() == PTY_ptr || op0->GetPrimType() == PTY_ref); - bool isOpnd1Ptr = op1 != nullptr && (op1->GetPrimType() == PTY_ptr || op1->GetPrimType() == PTY_ref); + bool isOpnd0Ptr = op0 != nullptr && MustBeAddress(op0->GetPrimType()); + bool isOpnd1Ptr = op1 != nullptr && MustBeAddress(op1->GetPrimType()); // Try "pointer heuristic." A comparison ptr == 0 is predicted as false. // Similarly, a comparison ptr1 == ptr2 is predicted as false. if (isCmpPtr || isOpnd0Ptr || isOpnd1Ptr) { diff --git a/src/mapleall/maple_me/src/me_stmt_pre.cpp b/src/mapleall/maple_me/src/me_stmt_pre.cpp index effd3bcd84aed273e0826f6850516f0c3ca55a6d..a7a410b5de6c2c6e4b7d1c69a4657a5f0e85087a 100755 --- a/src/mapleall/maple_me/src/me_stmt_pre.cpp +++ b/src/mapleall/maple_me/src/me_stmt_pre.cpp @@ -30,12 +30,12 @@ static bool IsParaAndRetTypeRefOrPtr(const CallMeStmt &stmt) { return false; } for (auto it : stmt.GetOpnds()) { - if (it->GetPrimType() == PTY_ref || it->GetPrimType() == PTY_ptr) { + if (MustBeAddress(it->GetPrimType())) { return true; } } const MeExpr *expr = stmt.GetAssignedLHS(); - if (expr != nullptr && (expr->GetPrimType() == PTY_ref || expr->GetPrimType() == PTY_ptr)) { + if (expr != nullptr && MustBeAddress(expr->GetPrimType())) { return true; } return false;