The following instructions have simple encodings: - bitcast.f32.i32 - bitcast.i32.f32 - bitcast.f64.i64 - bitcast.i64.f64 - fpromote.f64.f32 - fdemote.f32.f64 Also add helper functions enc_flt() and enc_i32_i64 to intel.encodings.py for generating the common set of encodings for an instruction: I32, I64 w/REX, I64 w/o REX.
95 lines
1.7 KiB
Plaintext
95 lines
1.7 KiB
Plaintext
; Test code generation for WebAssembly type conversion operators.
|
|
test compile
|
|
|
|
set is_64bit=1
|
|
isa intel haswell
|
|
|
|
function %i32_wrap_i64(i64) -> i32 {
|
|
ebb0(v0: i64):
|
|
v1 = ireduce.i32 v0
|
|
return v1
|
|
}
|
|
|
|
function %i64_extend_s_i32(i32) -> i64 {
|
|
ebb0(v0: i32):
|
|
v1 = sextend.i64 v0
|
|
return v1
|
|
}
|
|
|
|
function %i64_extend_u_i32(i32) -> i64 {
|
|
ebb0(v0: i32):
|
|
v1 = uextend.i64 v0
|
|
return v1
|
|
}
|
|
|
|
; function %i32_trunc_s_f32(f32) -> i32
|
|
; function %i32_trunc_u_f32(f32) -> i32
|
|
; function %i32_trunc_s_f64(f64) -> i32
|
|
; function %i32_trunc_u_f64(f64) -> i32
|
|
; function %i64_trunc_s_f32(f32) -> i64
|
|
; function %i64_trunc_u_f32(f32) -> i64
|
|
; function %i64_trunc_s_f64(f64) -> i64
|
|
; function %i64_trunc_u_f64(f64) -> i64
|
|
|
|
function %f32_trunc_f64(f64) -> f32 {
|
|
ebb0(v0: f64):
|
|
v1 = fdemote.f32 v0
|
|
return v1
|
|
}
|
|
|
|
function %f64_promote_f32(f32) -> f64 {
|
|
ebb0(v0: f32):
|
|
v1 = fpromote.f64 v0
|
|
return v1
|
|
}
|
|
|
|
function %f32_convert_s_i32(i32) -> f32 {
|
|
ebb0(v0: i32):
|
|
v1 = fcvt_from_sint.f32 v0
|
|
return v1
|
|
}
|
|
|
|
function %f64_convert_s_i32(i32) -> f64 {
|
|
ebb0(v0: i32):
|
|
v1 = fcvt_from_sint.f64 v0
|
|
return v1
|
|
}
|
|
|
|
function %f32_convert_s_i64(i64) -> f32 {
|
|
ebb0(v0: i64):
|
|
v1 = fcvt_from_sint.f32 v0
|
|
return v1
|
|
}
|
|
|
|
function %f64_convert_s_i64(i64) -> f64 {
|
|
ebb0(v0: i64):
|
|
v1 = fcvt_from_sint.f64 v0
|
|
return v1
|
|
}
|
|
|
|
; TODO: f*_convert_u_i* (Don't exist on Intel).
|
|
|
|
function %i32_reinterpret_f32(f32) -> i32 {
|
|
ebb0(v0: f32):
|
|
v1 = bitcast.i32 v0
|
|
return v1
|
|
}
|
|
|
|
function %f32_reinterpret_i32(i32) -> f32 {
|
|
ebb0(v0: i32):
|
|
v1 = bitcast.f32 v0
|
|
return v1
|
|
}
|
|
|
|
function %i64_reinterpret_f64(f64) -> i64 {
|
|
ebb0(v0: f64):
|
|
v1 = bitcast.i64 v0
|
|
return v1
|
|
}
|
|
|
|
function %f64_reinterpret_i64(i64) -> f64 {
|
|
ebb0(v0: i64):
|
|
v1 = bitcast.f64 v0
|
|
return v1
|
|
}
|