@@ -192,6 +192,77 @@ hw.module @constant_fold5(out res: !sim.fstring) {
192192 hw.output %cat : !sim.fstring
193193}
194194
195+ // CHECK-LABEL: hw.module @constant_fold_real_formats
196+ // CHECK: sim.fmt.literal "5.0e-01 ,0.500000, 0.5;1.6e+00, 1.6,2;9.999990e+05,999999.000000,999999;1.000000e+126,999999999999999924867761618992882042544670869834838461439225972225294199975793026603163493762817653751530058413655532282839040.000000,1e+126"
197+ hw.module @constant_fold_real_formats (out res : !sim.fstring ) {
198+ %comma = sim.fmt.literal " ,"
199+ %semicolon = sim.fmt.literal " ;"
200+ %cst_05 = arith.constant 5.000000e-01 : f64
201+ %e0 = sim.fmt.exp %cst_05 {fieldWidth = 20 : i32 , fracDigits = 1 : i32 , isLeftAligned = true } : f64
202+ %f0 = sim.fmt.flt %cst_05 : f64
203+ %g0 = sim.fmt.gen %cst_05 {fieldWidth = 10 : i32 , fracDigits = 9 : i32 } : f64
204+ %cst_05_comma = sim.fmt.concat (%e0 , %comma , %f0 , %comma , %g0 )
205+ %cst_165 = arith.constant 1.650000e+00 : f64
206+ %e1 = sim.fmt.exp %cst_165 {fracDigits = 1 : i32 } : f64
207+ %f1 = sim.fmt.flt %cst_165 {fieldWidth = 30 : i32 , fracDigits = 1 : i32 } : f64
208+ %g1 = sim.fmt.gen %cst_165 {fracDigits = 1 : i32 } : f64
209+ %cst_165_comma = sim.fmt.concat (%e1 , %comma , %f1 , %comma , %g1 )
210+ %cst_999999 = arith.constant 9.999990e+05 : f64
211+ %e2 = sim.fmt.exp %cst_999999 : f64
212+ %f2 = sim.fmt.flt %cst_999999 : f64
213+ %g2 = sim.fmt.gen %cst_999999 : f64
214+ %cst_999999_comma = sim.fmt.concat (%e2 , %comma , %f2 , %comma , %g2 )
215+ %cst_big = arith.constant 1.000000e+126 : f64
216+ %e3 = sim.fmt.exp %cst_big : f64
217+ %f3 = sim.fmt.flt %cst_big : f64
218+ %g3 = sim.fmt.gen %cst_big : f64
219+ %cst_big_comma = sim.fmt.concat (%e3 , %comma , %f3 , %comma , %g3 )
220+ %res = sim.fmt.concat (%cst_05_comma , %semicolon , %cst_165_comma , %semicolon , %cst_999999_comma , %semicolon , %cst_big_comma )
221+ hw.output %res : !sim.fstring
222+ }
223+
224+ // CHECK-LABEL: hw.module @constant_fold_real_gen_precision
225+ // CHECK: sim.fmt.literal "0.001,0.001,0.0012,0.00123,0.001235,0.001235,0.001235,0.001235;1e-07,1e-07,1.2e-07,1.23e-07,1.235e-07,1.235e-07,1.235e-07,1.235e-07;1e+06,1e+06,1.2e+06,1.24e+06,1.235e+06,1.235e+06,1.235e+06,1235000"
226+ hw.module @constant_fold_real_gen_precision (out res : !sim.fstring ) {
227+ %comma = sim.fmt.literal " ,"
228+ %semicolon = sim.fmt.literal " ;"
229+ %cst_a = arith.constant 1.235000e-03 : f64
230+ %a0 = sim.fmt.gen %cst_a {fracDigits = 0 : i32 } : f64
231+ %a1 = sim.fmt.gen %cst_a {fracDigits = 1 : i32 } : f64
232+ %a2 = sim.fmt.gen %cst_a {fracDigits = 2 : i32 } : f64
233+ %a3 = sim.fmt.gen %cst_a {fracDigits = 3 : i32 } : f64
234+ %a4 = sim.fmt.gen %cst_a {fracDigits = 4 : i32 } : f64
235+ %a5 = sim.fmt.gen %cst_a {fracDigits = 5 : i32 } : f64
236+ %a6 = sim.fmt.gen %cst_a {fracDigits = 6 : i32 } : f64
237+ %a7 = sim.fmt.gen %cst_a {fracDigits = 7 : i32 } : f64
238+ %grp_a = sim.fmt.concat (%a0 , %comma , %a1 , %comma , %a2 , %comma , %a3 , %comma , %a4 , %comma , %a5 , %comma , %a6 , %comma , %a7 )
239+
240+ %cst_b = arith.constant 1.235000e-07 : f64
241+ %b0 = sim.fmt.gen %cst_b {fracDigits = 0 : i32 } : f64
242+ %b1 = sim.fmt.gen %cst_b {fracDigits = 1 : i32 } : f64
243+ %b2 = sim.fmt.gen %cst_b {fracDigits = 2 : i32 } : f64
244+ %b3 = sim.fmt.gen %cst_b {fracDigits = 3 : i32 } : f64
245+ %b4 = sim.fmt.gen %cst_b {fracDigits = 4 : i32 } : f64
246+ %b5 = sim.fmt.gen %cst_b {fracDigits = 5 : i32 } : f64
247+ %b6 = sim.fmt.gen %cst_b {fracDigits = 6 : i32 } : f64
248+ %b7 = sim.fmt.gen %cst_b {fracDigits = 7 : i32 } : f64
249+ %grp_b = sim.fmt.concat (%b0 , %comma , %b1 , %comma , %b2 , %comma , %b3 , %comma , %b4 , %comma , %b5 , %comma , %b6 , %comma , %b7 )
250+
251+ %cst_c = arith.constant 1.235000e+06 : f64
252+ %c0 = sim.fmt.gen %cst_c {fracDigits = 0 : i32 } : f64
253+ %c1 = sim.fmt.gen %cst_c {fracDigits = 1 : i32 } : f64
254+ %c2 = sim.fmt.gen %cst_c {fracDigits = 2 : i32 } : f64
255+ %c3 = sim.fmt.gen %cst_c {fracDigits = 3 : i32 } : f64
256+ %c4 = sim.fmt.gen %cst_c {fracDigits = 4 : i32 } : f64
257+ %c5 = sim.fmt.gen %cst_c {fracDigits = 5 : i32 } : f64
258+ %c6 = sim.fmt.gen %cst_c {fracDigits = 6 : i32 } : f64
259+ %c7 = sim.fmt.gen %cst_c {fracDigits = 7 : i32 } : f64
260+ %grp_c = sim.fmt.concat (%c0 , %comma , %c1 , %comma , %c2 , %comma , %c3 , %comma , %c4 , %comma , %c5 , %comma , %c6 , %comma , %c7 )
261+
262+ %res = sim.fmt.concat (%grp_a , %semicolon , %grp_b , %semicolon , %grp_c )
263+ hw.output %res : !sim.fstring
264+ }
265+
195266// CHECK-LABEL: hw.module @flatten_concat1
196267// CHECK-DAG: %[[LHL:.+]] = sim.fmt.literal "HexLower: "
197268// CHECK-DAG: %[[LHU:.+]] = sim.fmt.literal "HexUpper: "
0 commit comments