diff --git a/src/mapleall/bin/dex2mpl b/src/mapleall/bin/dex2mpl index 79b02df50ee1d2a0acb7f3b434005efe60b4ee2e..9ea6c7dd2f63f6568fb83d7dc956feef56671642 100755 Binary files a/src/mapleall/bin/dex2mpl and b/src/mapleall/bin/dex2mpl differ diff --git a/src/mapleall/bin/dex2mpl_android b/src/mapleall/bin/dex2mpl_android index 769167d16424cbe6c012c104b717b7b6998d1a69..d603acde6e5f9bd8f7ab425f8bec336c43dff2a0 100755 Binary files a/src/mapleall/bin/dex2mpl_android and b/src/mapleall/bin/dex2mpl_android differ diff --git a/src/mapleall/bin/jbc2mpl b/src/mapleall/bin/jbc2mpl index 55c0e948f4b435e970f472130e7f948a865a2ae4..e11d55a4cad3bce421a3dc6f64502240d2962d91 100755 Binary files a/src/mapleall/bin/jbc2mpl and b/src/mapleall/bin/jbc2mpl differ diff --git a/src/mapleall/maple_be/include/cg/aarch64/aarch64_cgfunc.h b/src/mapleall/maple_be/include/cg/aarch64/aarch64_cgfunc.h index f4ea4c0f49ef064640e4c92b40d6d2e20efd6feb..5fd364a25acdb4dfe1bec890e88013fc86318cc3 100644 --- a/src/mapleall/maple_be/include/cg/aarch64/aarch64_cgfunc.h +++ b/src/mapleall/maple_be/include/cg/aarch64/aarch64_cgfunc.h @@ -272,7 +272,7 @@ class AArch64CGFunc : public CGFunc { return GetOrCreatePhysicalRegisterOperand(RFP, kSizeOfPtr * kBitsPerByte, kRegTyInt); } - RegOperand &GenStructParamIndex(RegOperand &base, BaseNode &indexExpr, int shift); + RegOperand &GenStructParamIndex(RegOperand &base, const BaseNode &indexExpr, int shift); MemOperand &GetOrCreateMemOpnd(const MIRSymbol &symbol, int32 offset, uint32 size, bool forLocalRef = false); diff --git a/src/mapleall/maple_be/include/cg/cgfunc.h b/src/mapleall/maple_be/include/cg/cgfunc.h index c4e82a869ec8154f8a5d0085bd3b294463ed997b..3a5b68c62f0d632c91da285cde219941d84e1448 100644 --- a/src/mapleall/maple_be/include/cg/cgfunc.h +++ b/src/mapleall/maple_be/include/cg/cgfunc.h @@ -868,7 +868,7 @@ class CGFunc { return offset; } - // See if the symbol is a structure parameter that requires a copy. + /* See if the symbol is a structure parameter that requires a copy. */ bool IsParamStructCopy(const MIRSymbol &symbol) { if (symbol.GetStorageClass() == kScFormal && GetBecommon().GetTypeSize(symbol.GetTyIdx().GetIdx()) > k16ByteSize) { diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp index 126f68c3a18b99eedaa0d110dc501bb60e92644d..fb7131985ad1b3d810a59b82455efac76af979fb 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -835,7 +835,7 @@ void AArch64CGFunc::SelectDassign(StIdx stIdx, FieldID fieldId, PrimType rhsPTyp Operand &stOpnd = LoadIntoRegister(opnd0, IsPrimitiveInteger(rhsPType), regSize, IsSignedInteger(type->GetPrimType())); MOperator mOp = MOP_undef; - if (type->GetKind() == kTypeStruct || type->GetKind() == kTypeUnion) { + if ((type->GetKind() == kTypeStruct) || (type->GetKind() == kTypeUnion)) { MIRStructType *structType = static_cast(type); type = structType->GetFieldType(fieldId); } else if (type->GetKind() == kTypeClass) { @@ -1422,20 +1422,23 @@ Operand *AArch64CGFunc::SelectAddrof(AddrofNode &expr) { offset = GetBecommon().GetFieldOffset(*structType, expr.GetFieldID()).first; } if ((symbol->GetStorageClass() == kScFormal) && (symbol->GetSKind() == kStVar) && - ((expr.GetFieldID() != 0) || (GetBecommon().GetTypeSize(symbol->GetType()->GetTypeIndex().GetIdx()) > k16ByteSize))) { - // Struct param is copied on the stack by caller if struct size > 16. - // Else if size < 16 then struct param is copied into one or two registers. + ((expr.GetFieldID() != 0) || + (GetBecommon().GetTypeSize(symbol->GetType()->GetTypeIndex().GetIdx()) > k16ByteSize))) { + /* + * Struct param is copied on the stack by caller if struct size > 16. + * Else if size < 16 then struct param is copied into one or two registers. + */ RegOperand *stackAddr = &CreateVirtualRegisterOperand(NewVReg(kRegTyInt, k8ByteSize)); - // load the base address of the struct copy from stack. + /* load the base address of the struct copy from stack. */ SelectAddrof(*stackAddr, CreateStImmOperand(*symbol, 0, 0)); Operand *structAddr; if (GetBecommon().GetTypeSize(symbol->GetType()->GetTypeIndex().GetIdx()) <= k16ByteSize) { isAggParamInReg = true; structAddr = stackAddr; } else { - AArch64OfstOperand *offopnd = &CreateOfstOpnd(0, 32); + AArch64OfstOperand *offopnd = &CreateOfstOpnd(0, k32BitSize); AArch64MemOperand *mo = &GetOrCreateMemOpnd(AArch64MemOperand::kAddrModeBOi, kSizeOfPtr * kBitsPerByte, - stackAddr, nullptr, offopnd, nullptr); + stackAddr, nullptr, offopnd, nullptr); structAddr = &CreateVirtualRegisterOperand(NewVReg(kRegTyInt, k8ByteSize)); GetCurBB()->AppendInsn(GetCG()->BuildInstruction(MOP_xldr, *structAddr, *mo)); } @@ -1554,7 +1557,7 @@ Operand *AArch64CGFunc::SelectIread(const BaseNode &parent, IreadNode &expr) { } MemOperand *memOpnd = &CreateMemOpnd(destType, expr, *expr.Opnd(0), offset, memOrd); - if (aggParamReg) { + if (aggParamReg != nullptr) { isAggParamInReg = false; return aggParamReg; } @@ -5515,7 +5518,7 @@ MemOperand &AArch64CGFunc::CreateMemOpnd(RegOperand &baseOpnd, int32 offset, uin return *memPool->New(AArch64MemOperand::kAddrModeBOi, size, baseOpnd, nullptr, &offsetOpnd, &sym); } -RegOperand &AArch64CGFunc::GenStructParamIndex(RegOperand &base, BaseNode &indexExpr, int shift) { +RegOperand &AArch64CGFunc::GenStructParamIndex(RegOperand &base, const BaseNode &indexExpr, int shift) { RegOperand *index = &LoadIntoRegister(*HandleExpr(indexExpr, *(indexExpr.Opnd(0))), PTY_a64); RegOperand *srcOpnd = &CreateRegisterOperandOfType(PTY_a64); ImmOperand *imm = &CreateImmOperand(PTY_a64, shift); @@ -5523,8 +5526,9 @@ RegOperand &AArch64CGFunc::GenStructParamIndex(RegOperand &base, BaseNode &index RegOperand *result = &CreateRegisterOperandOfType(PTY_a64); SelectAdd(*result, base, *srcOpnd, PTY_a64); - AArch64OfstOperand *offopnd = &CreateOfstOpnd(0, 32); - AArch64MemOperand &mo = GetOrCreateMemOpnd( AArch64MemOperand::kAddrModeBOi, k64BitSize, result, nullptr, offopnd, nullptr); + AArch64OfstOperand *offopnd = &CreateOfstOpnd(0, k32BitSize); + AArch64MemOperand &mo = + GetOrCreateMemOpnd(AArch64MemOperand::kAddrModeBOi, k64BitSize, result, nullptr, offopnd, nullptr); RegOperand &structAddr = CreateVirtualRegisterOperand(NewVReg(kRegTyInt, k8ByteSize)); GetCurBB()->AppendInsn(cg->BuildInstruction(MOP_xldr, structAddr, mo)); diff --git a/src/mapleall/maple_be/src/cg/emit.cpp b/src/mapleall/maple_be/src/cg/emit.cpp index 5851d677c42645c0f1730fe83ea4a304ffb75c4e..b9996e7e0031652604016d02d7753722a1f678b7 100644 --- a/src/mapleall/maple_be/src/cg/emit.cpp +++ b/src/mapleall/maple_be/src/cg/emit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020-2021] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -285,8 +285,8 @@ void Emitter::EmitAsmLabel(const MIRSymbol &mirSymbol, AsmLabel label) { MIRStorageClass storage = mirSymbol.GetStorageClass(); if (symName.find("classInitProtectRegion") == 0) { Emit(4096); - } else if ((kind == kTypeStruct || kind == kTypeClass || kind == kTypeArray || kind == kTypeUnion) && - (storage == kScGlobal || storage == kScPstatic || storage == kScFstatic)) { + } else if (((kind == kTypeStruct) || (kind == kTypeClass) || (kind == kTypeArray) || (kind == kTypeUnion)) && + ((storage == kScGlobal) || (storage == kScPstatic) || (storage == kScFstatic))) { Emit(std::to_string(k8ByteSize)); } else { Emit(std::to_string(Globals::GetInstance()->GetBECommon()->GetTypeAlign(mirType->GetTypeIndex()))); diff --git a/src/mapleall/maple_ir/include/mir_type.h b/src/mapleall/maple_ir/include/mir_type.h index 1856f5443b6ef354001885c39c560a2d8d2146ae..39955b0306d482dfe8b48f3900dafea9fb314f28 100755 --- a/src/mapleall/maple_ir/include/mir_type.h +++ b/src/mapleall/maple_ir/include/mir_type.h @@ -628,15 +628,15 @@ class MIRArrayType : public MIRType { this->dim = dim; } - TypeAttrs GetTypeAttrs() const { + const TypeAttrs &GetTypeAttrs() const { return typeAttrs; } - TypeAttrs& GetTypeAttrs() { + TypeAttrs &GetTypeAttrs() { return typeAttrs; } - void SetTypeAttrs(TypeAttrs attrs) { + void SetTypeAttrs(const TypeAttrs &attrs) { typeAttrs = attrs; } @@ -672,7 +672,8 @@ class MIRArrayType : public MIRType { CHECK_FATAL(i < kMaxArrayDim, "array index out of range"); hIdx += (sizeArray[i] << i); } - hIdx += (typeAttrs.GetAttrFlag() << 3) + typeAttrs.GetAlignValue(); + constexpr uint8 attrShift = 3; + hIdx += (typeAttrs.GetAttrFlag() << attrShift) + typeAttrs.GetAlignValue(); return hIdx % kTypeHashLength; }