From 29a92a39a56a9c1bea0a4494289398e8afb3bf9e Mon Sep 17 00:00:00 2001 From: Brice Dobry Date: Fri, 4 Jun 2021 10:39:24 -0400 Subject: [PATCH] Assume a call insn for unspecified intrinsics The inliner needs to know how to estimate the cost of a node, so it needs to know about the C intrinsics we recently added. Any that generate a specific sequence should be defined in the switch and the default will handle all of the intrinsics that just generate a call. --- src/mapleall/maple_ipa/src/inline.cpp | 28 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/mapleall/maple_ipa/src/inline.cpp b/src/mapleall/maple_ipa/src/inline.cpp index 2d2aae4fb3..6173eee3fa 100644 --- a/src/mapleall/maple_ipa/src/inline.cpp +++ b/src/mapleall/maple_ipa/src/inline.cpp @@ -33,7 +33,6 @@ namespace maple { constexpr uint32 kHalfInsn = 1; constexpr uint32 kOneInsn = 2; constexpr uint32 kDoubleInsn = 4; -constexpr uint32 kQuadrupleInsn = 8; constexpr uint32 kPentupleInsn = 10; static bool IsFinalMethod(const MIRFunction *mirFunc) { @@ -990,20 +989,29 @@ FuncCostResultType MInline::GetFuncCost(const MIRFunction &func, const BaseNode case OP_intrinsicop: case OP_intrinsicopwithtype: { const IntrinsicopNode &node = static_cast(baseNode); - MIRIntrinsicID id = node.GetIntrinsic(); - if (id == INTRN_JAVA_CONST_CLASS || id == INTRN_JAVA_ARRAY_LENGTH) { + switch(node.GetIntrinsic()) { + case INTRN_JAVA_CONST_CLASS: + case INTRN_JAVA_ARRAY_LENGTH: cost += kOneInsn; - } else if (id == INTRN_JAVA_MERGE) { + break; + case INTRN_JAVA_MERGE: cost += kHalfInsn; - } else if (id == INTRN_JAVA_INSTANCE_OF) { + break; + case INTRN_JAVA_INSTANCE_OF: cost += kPentupleInsn; - } else if (id == INTRN_MPL_READ_OVTABLE_ENTRY) { + break; + case INTRN_MPL_READ_OVTABLE_ENTRY: cost += kDoubleInsn; - } else if (id == INTRN_C_ctz32 || id == INTRN_C_clz32 || id == INTRN_C_constant_p) { + break; + case INTRN_C_ctz32: + case INTRN_C_clz32: + case INTRN_C_constant_p: cost += kOneInsn; - } else { - CHECK_FATAL(false, "[IMPOSSIBLE] %s", func.GetName().c_str()); - cost += kQuadrupleInsn; + break; + default: + // Other intrinsics generate a call + cost += kPentupleInsn; + break; } break; } -- Gitee