github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/compiler/testdata/float.ll (about) 1 ; ModuleID = 'float.go' 2 source_filename = "float.go" 3 target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20" 4 target triple = "wasm32-unknown-wasi" 5 6 ; Function Attrs: allockind("alloc,zeroed") allocsize(0) 7 declare noalias nonnull ptr @runtime.alloc(i32, ptr, ptr) #0 8 9 declare void @runtime.trackPointer(ptr nocapture readonly, ptr, ptr) #1 10 11 ; Function Attrs: nounwind 12 define hidden void @main.init(ptr %context) unnamed_addr #2 { 13 entry: 14 ret void 15 } 16 17 ; Function Attrs: nounwind 18 define hidden i32 @main.f32tou32(float %v, ptr %context) unnamed_addr #2 { 19 entry: 20 %positive = fcmp oge float %v, 0.000000e+00 21 %withinmax = fcmp ole float %v, 0x41EFFFFFC0000000 22 %inbounds = and i1 %positive, %withinmax 23 %saturated = sext i1 %positive to i32 24 %normal = fptoui float %v to i32 25 %0 = select i1 %inbounds, i32 %normal, i32 %saturated 26 ret i32 %0 27 } 28 29 ; Function Attrs: nounwind 30 define hidden float @main.maxu32f(ptr %context) unnamed_addr #2 { 31 entry: 32 ret float 0x41F0000000000000 33 } 34 35 ; Function Attrs: nounwind 36 define hidden i32 @main.maxu32tof32(ptr %context) unnamed_addr #2 { 37 entry: 38 ret i32 -1 39 } 40 41 ; Function Attrs: nounwind 42 define hidden { i32, i32, i32, i32 } @main.inftoi32(ptr %context) unnamed_addr #2 { 43 entry: 44 ret { i32, i32, i32, i32 } { i32 -1, i32 0, i32 2147483647, i32 -2147483648 } 45 } 46 47 ; Function Attrs: nounwind 48 define hidden i32 @main.u32tof32tou32(i32 %v, ptr %context) unnamed_addr #2 { 49 entry: 50 %0 = uitofp i32 %v to float 51 %withinmax = fcmp ole float %0, 0x41EFFFFFC0000000 52 %normal = fptoui float %0 to i32 53 %1 = select i1 %withinmax, i32 %normal, i32 -1 54 ret i32 %1 55 } 56 57 ; Function Attrs: nounwind 58 define hidden float @main.f32tou32tof32(float %v, ptr %context) unnamed_addr #2 { 59 entry: 60 %positive = fcmp oge float %v, 0.000000e+00 61 %withinmax = fcmp ole float %v, 0x41EFFFFFC0000000 62 %inbounds = and i1 %positive, %withinmax 63 %saturated = sext i1 %positive to i32 64 %normal = fptoui float %v to i32 65 %0 = select i1 %inbounds, i32 %normal, i32 %saturated 66 %1 = uitofp i32 %0 to float 67 ret float %1 68 } 69 70 ; Function Attrs: nounwind 71 define hidden i8 @main.f32tou8(float %v, ptr %context) unnamed_addr #2 { 72 entry: 73 %positive = fcmp oge float %v, 0.000000e+00 74 %withinmax = fcmp ole float %v, 2.550000e+02 75 %inbounds = and i1 %positive, %withinmax 76 %saturated = sext i1 %positive to i8 77 %normal = fptoui float %v to i8 78 %0 = select i1 %inbounds, i8 %normal, i8 %saturated 79 ret i8 %0 80 } 81 82 ; Function Attrs: nounwind 83 define hidden i8 @main.f32toi8(float %v, ptr %context) unnamed_addr #2 { 84 entry: 85 %abovemin = fcmp oge float %v, -1.280000e+02 86 %belowmax = fcmp ole float %v, 1.270000e+02 87 %inbounds = and i1 %abovemin, %belowmax 88 %saturated = select i1 %abovemin, i8 127, i8 -128 89 %isnan = fcmp uno float %v, 0.000000e+00 90 %remapped = select i1 %isnan, i8 0, i8 %saturated 91 %normal = fptosi float %v to i8 92 %0 = select i1 %inbounds, i8 %normal, i8 %remapped 93 ret i8 %0 94 } 95 96 attributes #0 = { allockind("alloc,zeroed") allocsize(0) "alloc-family"="runtime.alloc" "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" } 97 attributes #1 = { "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" } 98 attributes #2 = { nounwind "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }