|
| 1 | +/-! |
| 2 | +Check that the compiler correctly deals with `Float` in various situations. |
| 3 | +-/ |
| 4 | + |
| 5 | +-- If the output of `trace.Compiler.result` turns out to be too unstable, we'll have to |
| 6 | +-- assert this some other way. |
| 7 | + |
| 8 | +set_option trace.Compiler.result true |
| 9 | + |
| 10 | +namespace F |
| 11 | + |
| 12 | +/-- |
| 13 | +trace: [Compiler.result] size: 1 |
| 14 | + def F.f x.1 : UInt64 := |
| 15 | + let toModel.2 := Float.toModel x.1; |
| 16 | + return toModel.2 |
| 17 | +[Compiler.result] size: 4 |
| 18 | + def F.f._boxed x.1 : obj := |
| 19 | + let x.10.boxed := unbox x.1; |
| 20 | + dec[ref] x.1; |
| 21 | + let res := F.f x.10.boxed; |
| 22 | + let r := box res; |
| 23 | + return r |
| 24 | +-/ |
| 25 | +#guard_msgs in |
| 26 | +def f : Float → UInt64 |
| 27 | + | ⟨model⟩ => model.toBits |
| 28 | + |
| 29 | +/-- |
| 30 | +trace: [Compiler.result] size: 1 |
| 31 | + def F.g x.1 : Float := |
| 32 | + let _x.2 := Float.ofModel x.1; |
| 33 | + return _x.2 |
| 34 | +[Compiler.result] size: 4 |
| 35 | + def F.g._boxed x.1 : obj := |
| 36 | + let x.4.boxed := unbox x.1; |
| 37 | + dec[ref] x.1; |
| 38 | + let res := F.g x.4.boxed; |
| 39 | + let r := box res; |
| 40 | + return r |
| 41 | +-/ |
| 42 | +#guard_msgs in |
| 43 | +def g : Float.Model → Float |
| 44 | + | a => ⟨a⟩ |
| 45 | + |
| 46 | +structure Foo where |
| 47 | + foo : Float |
| 48 | + |
| 49 | +/-- |
| 50 | +trace: [Compiler.result] size: 0 |
| 51 | + def F.h x.1 : Float := |
| 52 | + return x.1 |
| 53 | +[Compiler.result] size: 4 |
| 54 | + def F.h._boxed x.1 : obj := |
| 55 | + let x.4.boxed := unbox x.1; |
| 56 | + dec[ref] x.1; |
| 57 | + let res := F.h x.4.boxed; |
| 58 | + let r := box res; |
| 59 | + return r |
| 60 | +-/ |
| 61 | +#guard_msgs in |
| 62 | +def h : Float → Foo |
| 63 | + | a => ⟨a⟩ |
| 64 | + |
| 65 | +end F |
| 66 | + |
| 67 | +namespace F32 |
| 68 | + |
| 69 | +/-- |
| 70 | +trace: [Compiler.result] size: 1 |
| 71 | + def F32.f x.1 : UInt32 := |
| 72 | + let toModel.2 := Float32.toModel x.1; |
| 73 | + return toModel.2 |
| 74 | +[Compiler.result] size: 4 |
| 75 | + def F32.f._boxed x.1 : tobj := |
| 76 | + let x.10.boxed := unbox x.1; |
| 77 | + dec[ref] x.1; |
| 78 | + let res := F32.f x.10.boxed; |
| 79 | + let r := box res; |
| 80 | + return r |
| 81 | +-/ |
| 82 | +#guard_msgs in |
| 83 | +def f : Float32 → UInt32 |
| 84 | + | ⟨model⟩ => model.toBits |
| 85 | + |
| 86 | +/-- |
| 87 | +trace: [Compiler.result] size: 1 |
| 88 | + def F32.g x.1 : Float32 := |
| 89 | + let _x.2 := Float32.ofModel x.1; |
| 90 | + return _x.2 |
| 91 | +[Compiler.result] size: 4 |
| 92 | + def F32.g._boxed x.1 : obj := |
| 93 | + let x.4.boxed := unbox x.1; |
| 94 | + dec x.1; |
| 95 | + let res := F32.g x.4.boxed; |
| 96 | + let r := box res; |
| 97 | + return r |
| 98 | +-/ |
| 99 | +#guard_msgs in |
| 100 | +def g : Float32.Model → Float32 |
| 101 | + | a => ⟨a⟩ |
| 102 | + |
| 103 | +structure Foo where |
| 104 | + foo : Float32 |
| 105 | + |
| 106 | +/-- |
| 107 | +trace: [Compiler.result] size: 0 |
| 108 | + def F32.h x.1 : Float32 := |
| 109 | + return x.1 |
| 110 | +[Compiler.result] size: 4 |
| 111 | + def F32.h._boxed x.1 : obj := |
| 112 | + let x.4.boxed := unbox x.1; |
| 113 | + dec[ref] x.1; |
| 114 | + let res := F32.h x.4.boxed; |
| 115 | + let r := box res; |
| 116 | + return r |
| 117 | +-/ |
| 118 | +#guard_msgs in |
| 119 | +def h : Float32 → Foo |
| 120 | + | a => ⟨a⟩ |
| 121 | + |
| 122 | +end F32 |
0 commit comments