MCPcopy Create free account
hub / github.com/beefytech/Beef / ExtractSplatValue

Method ExtractSplatValue

IDEHelper/Compiler/BfModule.cpp:13864–13941  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13862}
13863
13864BfIRValue BfModule::ExtractSplatValue(BfTypedValue typedValue, int componentIdx, BfType* wantType, bool* isAddr)
13865{
13866 BF_ASSERT(!mIsComptimeModule);
13867
13868 BfIRValue val;
13869 if (typedValue.mValue.IsArg())
13870 {
13871 val = mBfIRBuilder->GetArgument(typedValue.mValue.mId + componentIdx);
13872 if (isAddr != NULL)
13873 {
13874 if (wantType != NULL)
13875 *isAddr = wantType->IsComposite();
13876 else
13877 *isAddr = false;
13878 }
13879 else if (wantType->IsComposite())
13880 val = mBfIRBuilder->CreateLoad(val);
13881 }
13882
13883 if (!val)
13884 {
13885 auto checkMethodState = mCurMethodState;
13886 while (checkMethodState != NULL)
13887 {
13888 for (int idx = 0; idx < (int)checkMethodState->mSplatDecompAddrs.size(); idx++)
13889 {
13890 auto decompAddr = checkMethodState->mSplatDecompAddrs[idx];
13891 if (decompAddr == typedValue.mValue)
13892 {
13893 val = checkMethodState->mSplatDecompAddrs[idx + componentIdx];
13894
13895 if ((wantType->IsComposite()) && (typedValue.mType->IsMethodRef()))
13896 {
13897 // This is really backing for a POINTER to a composite inside a methodRef
13898 val = mBfIRBuilder->CreateLoad(val);
13899 }
13900
13901 if ((isAddr != NULL) && (typedValue.mKind != BfTypedValueKind_SplatHead_NeedsCasting))
13902 {
13903 *isAddr = true;
13904 return val;
13905 }
13906 else
13907 {
13908 val = mBfIRBuilder->CreateAlignedLoad(val, wantType->mAlign);
13909 break;
13910 }
13911 }
13912 }
13913
13914 if (val)
13915 break;
13916
13917 if ((checkMethodState->mClosureState != NULL) && (checkMethodState->mClosureState->mCapturing))
13918 {
13919 BF_ASSERT(mBfIRBuilder->mIgnoreWrites);
13920 return mBfIRBuilder->GetFakeVal();
13921 }

Callers 2

SplatArgsMethod · 0.80
DoImplicitArgCaptureMethod · 0.80

Calls 11

BfIRValueClass · 0.85
IsArgMethod · 0.80
GetFakeValMethod · 0.80
MapTypeMethod · 0.80
GetArgumentMethod · 0.45
IsCompositeMethod · 0.45
CreateLoadMethod · 0.45
sizeMethod · 0.45
IsMethodRefMethod · 0.45
CreateAlignedLoadMethod · 0.45
CreateBitCastMethod · 0.45

Tested by

no test coverage detected