From 83aa4822d42787fc22949c8101506994a239904e Mon Sep 17 00:00:00 2001 From: William Chen Date: Wed, 24 Mar 2021 08:28:51 -0700 Subject: [PATCH 1/2] OP_retype does not use the fromPrimType field --- src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ae4ddad5a4..85201fc7d3 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -3698,7 +3698,7 @@ static bool LIsPrimitivePointer(PrimType ptype) { } Operand *AArch64CGFunc::SelectRetype(TypeCvtNode &node, Operand &opnd0) { - PrimType fromType = node.FromType(); + PrimType fromType = node.Opnd(0)->GetPrimType(); PrimType toType = node.GetPrimType(); ASSERT(GetPrimTypeSize(fromType) == GetPrimTypeSize(toType), "retype bit widith doesn' match"); if (LIsPrimitivePointer(fromType) && LIsPrimitivePointer(toType)) { -- Gitee From ae83d6646f66416decf2f8be9a285c08b3fbdb68 Mon Sep 17 00:00:00 2001 From: William Chen Date: Wed, 24 Mar 2021 09:15:52 -0700 Subject: [PATCH 2/2] fix return type conversion to/from int/fp --- .../maple_be/src/cg/aarch64/aarch64_cgfunc.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 85201fc7d3..bf1224478b 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -3742,11 +3742,16 @@ Operand *AArch64CGFunc::SelectRetype(TypeCvtNode &node, Operand &opnd0) { } else { newOpnd0 = &LoadIntoRegister(opnd0, itype); } - uint32 mopFmov = + if ((IsPrimitiveFloat(fromType) && IsPrimitiveInteger(toType)) || + (IsPrimitiveFloat(toType) && IsPrimitiveInteger(fromType))) { + MOperator mopFmov = isImm ? is64Bits ? MOP_xdfmovri : MOP_wsfmovri : isFromInt ? (is64Bits ? MOP_xvmovdr : MOP_xvmovsr) : (is64Bits ? MOP_xvmovrd : MOP_xvmovrs); - GetCurBB()->AppendInsn(GetCG()->BuildInstruction(mopFmov, *resOpnd, *newOpnd0)); - return resOpnd; + GetCurBB()->AppendInsn(GetCG()->BuildInstruction(mopFmov, *resOpnd, *newOpnd0)); + return resOpnd; + } else { + return newOpnd0; + } } else { CHECK_FATAL(false, "NYI retype"); } -- Gitee