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

Method GetOperand

IDEHelper/Backend/BeMCContext.cpp:2155–2590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2153}
2154
2155BeMCOperand BeMCContext::GetOperand(BeValue* value, bool allowMetaResult, bool allowFail, bool skipForceVRegAddr)
2156{
2157 if (value == NULL)
2158 return BeMCOperand();
2159
2160 switch (value->GetTypeId())
2161 {
2162 case BeGlobalVariable::TypeId:
2163 {
2164 auto globalVar = (BeGlobalVariable*)value;
2165 if ((globalVar->mIsTLS) && (mTLSVRegIdx == -1))
2166 {
2167 auto tlsVReg = AllocVirtualReg(mNativeIntType);
2168 auto vregInfo = GetVRegInfo(tlsVReg);
2169 vregInfo->mMustExist = true;
2170 vregInfo->mForceReg = true;
2171 vregInfo->mDisableR12 = true;
2172 vregInfo->mDisableR13 = true;
2173 mTLSVRegIdx = tlsVReg.mVRegIdx;
2174 }
2175
2176 auto sym = mCOFFObject->GetSymbol(globalVar);
2177 if (sym != NULL)
2178 {
2179 BeMCOperand mcOperand;
2180 mcOperand.mKind = BeMCOperandKind_SymbolAddr;
2181 mcOperand.mSymbolIdx = sym->mIdx;
2182 return mcOperand;
2183 }
2184 }
2185 break;
2186 case BeCastConstant::TypeId:
2187 {
2188 auto constant = (BeCastConstant*)value;
2189
2190 BeMCOperand mcOperand;
2191 auto relTo = GetOperand(constant->mTarget);
2192 if (relTo.mKind == BeMCOperandKind_Immediate_Null)
2193 {
2194 mcOperand.mKind = BeMCOperandKind_Immediate_Null;
2195 mcOperand.mType = constant->mType;
2196 return mcOperand;
2197 }
2198
2199 mcOperand = AllocVirtualReg(constant->mType);
2200 auto vregInfo = GetVRegInfo(mcOperand);
2201 vregInfo->mDefOnFirstUse = true;
2202 vregInfo->mRelTo = relTo;
2203 vregInfo->mIsExpr = true;
2204
2205 return mcOperand;
2206 }
2207 break;
2208 case BeConstant::TypeId:
2209 {
2210 auto constant = (BeConstant*)value;
2211 BeMCOperand mcOperand;
2212 switch (constant->mType->mTypeCode)

Callers

nothing calls this directly

Calls 14

BeMCOperandClass · 0.85
FailFunction · 0.85
TryGetValueMethod · 0.80
GetTypeIdMethod · 0.45
GetSymbolMethod · 0.45
GetStrideMethod · 0.45
GetPointerToMethod · 0.45
GetTypeMethod · 0.45
ToStringMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected