Repository: dotnet/runtime
File: src/coreclr/jit/codegenwasm.cpp (C++)

Code before:
            NYI_WASM("genCodeForShift");
            break;
    }

    GetEmitter()->emitIns(ins);
    genProduceReg(treeNode);
}

//----------------------------------------------------------------------
// genCodeForBitCast - Generate code for a GT_BITCAST that is not contained
//
// Arguments
//    tree - the GT_BITCAST for which we're generating code
//
void CodeGen::genCodeForBitCast(GenTreeOp* tree)
{
    assert(tree->OperIs(GT_BITCAST));
    genConsumeOperands(tree);
    assert(tree->TypeGet() == genActualType(tree));

    var_types toType   = tree->TypeGet();
    var_types fromType = tree->gtGetOp1()->TypeGet();

    instruction ins = INS_none;
    switch (PackTypes(fromType, toType))
    {
        case PackTypes(TYP_INT, TYP_FLOAT):
            ins = INS_i32_reinterpret_f32;
            break;
        case PackTypes(TYP_FLOAT, TYP_INT):
            ins = INS_f32_reinterpret_i32;
            break;
        case PackTypes(TYP_LONG, TYP_DOUBLE):
            ins = INS_i64_reinterpret_f64;
            break;
        case PackTypes(TYP_DOUBLE, TYP_LONG):
            ins = INS_f64_reinterpret_i64;
            break;
        default:
            unreached();
            break;
    }

    GetEmitter()->emitIns(ins);
    genProduceReg(tree);
}

//------------------------------------------------------------------------
// genCodeForNegNot: Generate code for a neg/not
//
// Arguments:

Review comment (suggestion):
`fromType` is taken directly from the operand's `TypeGet()`, which can be unsigned (e.g., UInt32BitsToSingle maps to the same intrinsic as Int32BitsToSingle and can supply a TYP_UINT operand). Since Wasm reinterpret ops only care about the actual machine type/size, please normalize `fromType` (and optionally `toType`) via `genActualType(...)` (or equivalent) before packing/switching so TYP_UINT/TYP_ULONG don't hit the `unreached()` path.

Code after:
            NYI_WASM("genCodeForShift");
            break;
    }

    GetEmitter()->emitIns(ins);
    genProduceReg(treeNode);
}

//----------------------------------------------------------------------
// genCodeForBitCast - Generate code for a GT_BITCAST that is not contained
//
// Arguments
//    tree - the GT_BITCAST for which we're generating code
//
void CodeGen::genCodeForBitCast(GenTreeOp* tree)
{
    assert(tree->OperIs(GT_BITCAST));
    genConsumeOperands(tree);

    var_types toType   = tree->TypeGet();
    var_types fromType = genActualType(tree->gtGetOp1()->TypeGet());
    assert(toType == genActualType(tree));

    instruction ins = INS_none;
    switch (PackTypes(toType, fromType))
    {
        case PackTypes(TYP_INT, TYP_FLOAT):
            ins = INS_i32_reinterpret_f32;
            break;
        case PackTypes(TYP_FLOAT, TYP_INT):
            ins = INS_f32_reinterpret_i32;
            break;
        case PackTypes(TYP_LONG, TYP_DOUBLE):
            ins = INS_i64_reinterpret_f64;
            break;
        case PackTypes(TYP_DOUBLE, TYP_LONG):
            ins = INS_f64_reinterpret_i64;
            break;
        default:
            unreached();
            break;
    }

    GetEmitter()->emitIns(ins);
    genProduceReg(tree);
}

//------------------------------------------------------------------------
// genCodeForNegNot: Generate code for a neg/not
//
// Arguments: