| 2912 | } |
| 2913 | |
| 2914 | static bool NeedsDecompose(BeConstant* constant) |
| 2915 | { |
| 2916 | if (auto arrayConst = BeValueDynCast<BeStructConstant>(constant)) |
| 2917 | { |
| 2918 | for (auto& val : arrayConst->mMemberValues) |
| 2919 | { |
| 2920 | if (NeedsDecompose(val)) |
| 2921 | return true; |
| 2922 | } |
| 2923 | return false; |
| 2924 | } |
| 2925 | |
| 2926 | if (auto globalVar = BeValueDynCast<BeGlobalVariable>(constant)) |
| 2927 | { |
| 2928 | return true; |
| 2929 | } |
| 2930 | else if (auto castConst = BeValueDynCast<BeCastConstant>(constant)) |
| 2931 | { |
| 2932 | return true; |
| 2933 | } |
| 2934 | else if (auto castConst = BeValueDynCast<BeBitCastInst>(constant)) |
| 2935 | { |
| 2936 | if (auto targetConstant = BeValueDynCast<BeConstant>(castConst->mValue)) |
| 2937 | return NeedsDecompose(targetConstant); |
| 2938 | } |
| 2939 | else if (auto castConst = BeValueDynCast<BeGEP1Constant>(constant)) |
| 2940 | { |
| 2941 | return NeedsDecompose(castConst->mTarget); |
| 2942 | } |
| 2943 | else if (auto castConst = BeValueDynCast<BeGEP2Constant>(constant)) |
| 2944 | { |
| 2945 | return NeedsDecompose(castConst->mTarget); |
| 2946 | } |
| 2947 | |
| 2948 | return false; |
| 2949 | } |
| 2950 | |
| 2951 | void BeMCContext::CreateStore(BeMCInstKind instKind, const BeMCOperand& val, const BeMCOperand& ptr) |
| 2952 | { |