Use the simplest expansion which materializes the bits of the floating point constant as an integer and then bit-casts to the floating point type. In the future, we may want to use constant pools instead. Either way, we need custom legalization. Also add a legalize_monomorphic() function to the Python targetISA class which permits the configuration of a default legalization action for monomorphic instructions, just like legalize_type() does for polymorphic instructions.
71 lines
1.2 KiB
Plaintext
71 lines
1.2 KiB
Plaintext
; Test the custom legalizations.
|
|
test legalizer
|
|
isa intel
|
|
set is_64bit
|
|
isa intel
|
|
|
|
; regex: V=v\d+
|
|
; regex: EBB=ebb\d+
|
|
|
|
function %cond_trap(i32) {
|
|
ebb0(v1: i32):
|
|
trapz v1
|
|
return
|
|
; check: $ebb0($v1: i32):
|
|
; nextln: brnz $v1, $(new=$EBB)
|
|
; nextln: trap
|
|
; check: $new:
|
|
; nextln: return
|
|
}
|
|
|
|
function %cond_trap2(i32) {
|
|
ebb0(v1: i32):
|
|
trapnz v1
|
|
return
|
|
; check: $ebb0($v1: i32):
|
|
; nextln: brz $v1, $(new=$EBB)
|
|
; nextln: trap
|
|
; check: $new:
|
|
; nextln: return
|
|
}
|
|
|
|
function %cond_trap_b1(i32) {
|
|
ebb0(v1: i32):
|
|
v2 = icmp_imm eq v1, 6
|
|
trapz v2
|
|
return
|
|
; check: $ebb0($v1: i32):
|
|
; check: brnz $v2, $(new=$EBB)
|
|
; nextln: trap
|
|
; check: $new:
|
|
; nextln: return
|
|
}
|
|
|
|
function %cond_trap2_b1(i32) {
|
|
ebb0(v1: i32):
|
|
v2 = icmp_imm eq v1, 6
|
|
trapnz v2
|
|
return
|
|
; check: $ebb0($v1: i32):
|
|
; check: brz $v2, $(new=$EBB)
|
|
; nextln: trap
|
|
; check: $new:
|
|
; nextln: return
|
|
}
|
|
|
|
function %f32const() -> f32 {
|
|
ebb0:
|
|
v1 = f32const 0x1.0p1
|
|
; check: $(tmp=$V) = iconst.i32
|
|
; check: $v1 = bitcast.f32 $tmp
|
|
return v1
|
|
}
|
|
|
|
function %f64const() -> f64 {
|
|
ebb0:
|
|
v1 = f64const 0x1.0p1
|
|
; check: $(tmp=$V) = iconst.i64
|
|
; check: $v1 = bitcast.f64 $tmp
|
|
return v1
|
|
}
|