src/coreclr/src/jit/lsraxarch.cpp
int LinearScan::BuildCast(GenTreeCast* cast)
{
    GenTree* src = cast->gtGetOp1();

    const var_types srcType  = genActualType(src->TypeGet());
    const var_types castType = cast->gtCastType;

    regMaskTP candidates = RBM_NONE;
#ifdef TARGET_X86
    if (varTypeIsByte(castType))
    {
        candidates = allByteRegs();
    }

    assert(!varTypeIsLong(srcType) || (src->OperIs(GT_LONG) && src->isContained()));
#else
    // Overflow checking cast from TYP_(U)LONG to TYP_UINT requires a temporary
    // register to extract the upper 32 bits of the 64 bit source register.
    if (cast->gtOverflow() && varTypeIsLong(srcType) && (castType == TYP_UINT))
    {
        // Here we don't need internal register to be different from targetReg,
        // rather require it to be different from operand's reg.
        buildInternalIntRegisterDefForNode(cast);
    }
#endif

    int srcCount = BuildOperandUses(src, candidates);
    buildInternalRegisterUses();
    BuildDef(cast, candidates);
    return srcCount;
}
//------------------------------------------------------------------------
// BuildCast: Set the NodeInfo for a GT_CAST.
//
// Arguments:
//    cast - The GT_CAST node
//
// Return Value:
//    The number of sources consumed by this node.
//


Return Value:
The number of sources consumed by this node.
Return Value : The number of sources consumed by this node .
int LinearScan::BuildCast(GenTreeCast* cast)
{
    GenTree* src = cast->gtGetOp1();
    const var_types srcType  = genActualType(src->TypeGet());
    const var_types castType = cast->gtCastType;
    regMaskTP candidates = RBM_NONE;
#ifdef TARGET_X86
    if (varTypeIsByte(castType))
    {
        candidates = allByteRegs();
    }
    assert(!varTypeIsLong(srcType) || (src->OperIs(GT_LONG) && src->isContained()));
#else
    if (cast->gtOverflow() && varTypeIsLong(srcType) && (castType == TYP_UINT))
    {
        buildInternalIntRegisterDefForNode(cast);
    }
#endif
    int srcCount = BuildOperandUses(src, candidates);
    buildInternalRegisterUses();
    BuildDef(cast, candidates);
    return srcCount;
}
int LinearScan :: BuildCast ( GenTreeCast * cast ) { GenTree * src = cast -> gtGetOp1 ( ) ; const var_types srcType = genActualType ( src -> TypeGet ( ) ) ; const var_types castType = cast -> gtCastType ; regMaskTP candidates = RBM_NONE ; #ifdef TARGET_X86 if ( varTypeIsByte ( castType ) ) { candidates = allByteRegs ( ) ; } assert ( ! varTypeIsLong ( srcType ) || ( src -> OperIs ( GT_LONG ) && src -> isContained ( ) ) ) ; #else if ( cast -> gtOverflow ( ) && varTypeIsLong ( srcType ) && ( castType == TYP_UINT ) ) { buildInternalIntRegisterDefForNode ( cast ) ; } #endif int srcCount = BuildOperandUses ( src , candidates ) ; buildInternalRegisterUses ( ) ; BuildDef ( cast , candidates ) ; return srcCount ; }
BuildCast: Set the NodeInfo for a GT_CAST.
BuildCast : Set the NodeInfo for a GT_CAST .
// Overflow checking cast from TYP_(U)LONG to TYP_UINT requires a temporary // register to extract the upper 32 bits of the 64 bit source register. // Here we don't need internal register to be different from targetReg, // rather require it to be different from operand's reg.