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

Code before:
            break;
        case PackOperAndType(GT_ROR, TYP_LONG):
            ins = INS_i64_rotr;
            break;

        default:
            ins = INS_none;
            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);

Review comment (suggestion):
This adds a TARGET_WASM-specific definition of CodeGen::genCodeForBitCast, but there is already a non-target-guarded definition in codegencommon.cpp. Both translation units are compiled for WASM (see src/coreclr/jit/CMakeLists.txt), so this will cause a multiple-definition linker error. Please move the WASM implementation behind an appropriate target guard by either excluding the common implementation for TARGET_WASM or making the WASM implementation the only one compiled for that target.

Code after:
            break;
        case PackOperAndType(GT_ROR, TYP_LONG):
            ins = INS_i64_rotr;
            break;

        default:
            ins = INS_none;
            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);