| 2153 | } |
| 2154 | |
| 2155 | BeMCOperand 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) |
nothing calls this directly
no test coverage detected