From 1b5f875a0eee8df114ebae3d65055e6e5ef3d273 Mon Sep 17 00:00:00 2001 From: William Chen Date: Thu, 14 Jul 2022 08:45:58 -0700 Subject: [PATCH] Handle %GP in regread for inline asm --- .../maple_be/src/cg/aarch64/aarch64_cgfunc.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 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 1a5c595b48..96c78884d7 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -1262,14 +1262,19 @@ void AArch64CGFunc::SelectAsm(AsmNode &node) { case OP_regread: { auto ®readNode = static_cast(*node.Opnd(i)); PregIdx pregIdx = regreadNode.GetRegIdx(); - RegOperand &inOpnd = GetOrCreateVirtualRegisterOperand(GetVirtualRegNOFromPseudoRegIdx(pregIdx)); - listInputOpnd->PushOpnd(static_cast(inOpnd)); MIRPreg *preg = GetFunction().GetPregTab()->PregFromPregIdx(pregIdx); PrimType pType = preg->GetPrimType(); + RegOperand *inOpnd; + if (IsSpecialPseudoRegister(pregIdx)) { + inOpnd = &GetOrCreateSpecialRegisterOperand(-pregIdx, pType); + } else { + inOpnd = &GetOrCreateVirtualRegisterOperand(GetVirtualRegNOFromPseudoRegIdx(pregIdx)); + } + listInputOpnd->PushOpnd(static_cast(*inOpnd)); listInRegPrefix->stringList.push_back( - static_cast(&CreateStringOperand(GetRegPrefixFromPrimType(pType, inOpnd.GetSize(), str)))); + static_cast(&CreateStringOperand(GetRegPrefixFromPrimType(pType, inOpnd->GetSize(), str)))); if (isOutputTempNode) { - rPlusOpnd.emplace_back(std::make_pair(&static_cast(inOpnd), pType)); + rPlusOpnd.emplace_back(std::make_pair(&static_cast(*inOpnd), pType)); } break; } -- Gitee