-
Notifications
You must be signed in to change notification settings - Fork 444
Expand file tree
/
Copy pathbasic.mlir
More file actions
590 lines (533 loc) · 21.9 KB
/
basic.mlir
File metadata and controls
590 lines (533 loc) · 21.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
// RUN: circt-opt --verify-diagnostics --verify-roundtrip %s | FileCheck %s
// CHECK-LABEL: moore.module @Empty()
moore.module @Empty() {
// CHECK: moore.output
}
// CHECK-LABEL: moore.module @Ports
moore.module @Ports(
// CHECK-SAME: in %a : !moore.string
in %a : !moore.string,
// CHECK-SAME: out b : !moore.string
out b : !moore.string,
// CHECK-SAME: in %c : !moore.event
in %c : !moore.event,
// CHECK-SAME: out d : !moore.event
out d : !moore.event
) {
// CHECK: moore.output %a, %c : !moore.string, !moore.event
moore.output %a, %c : !moore.string, !moore.event
}
// CHECK-LABEL: moore.module @Module
moore.module @Module() {
// CHECK: moore.instance "empty" @Empty() -> ()
moore.instance "empty" @Empty() -> ()
// CHECK: %[[I1_READ:.+]] = moore.read %i1
// CHECK: %[[I2_READ:.+]] = moore.read %i2
// CHECK: moore.instance "ports" @Ports(a: %[[I1_READ]]: !moore.string, c: %[[I2_READ]]: !moore.event) -> (b: !moore.string, d: !moore.event)
%i1 = moore.variable : <string>
%i2 = moore.variable : <event>
%5 = moore.read %i1 : <string>
%6 = moore.read %i2 : <event>
%o1, %o2 = moore.instance "ports" @Ports(a: %5: !moore.string, c: %6: !moore.event) -> (b: !moore.string, d: !moore.event)
// CHECK: %v1 = moore.variable : <i1>
%v1 = moore.variable : <i1>
%v2 = moore.variable : <i1>
// CHECK: %[[TMP1:.+]] = moore.read %v2
// CHECK: %[[TMP2:.+]] = moore.variable name "v1" %[[TMP1]] : <i1>
%0 = moore.read %v2 : <i1>
moore.variable name "v1" %0 : <i1>
// CHECK: %w0 = moore.net wire : <l1>
%w0 = moore.net wire : <l1>
// CHECK: %[[W0:.+]] = moore.read %w0
%1 = moore.read %w0 : <l1>
// CHECK: %w1 = moore.net wire %[[W0]] : <l1>
%w1 = moore.net wire %1 : <l1>
// CHECK: %w2 = moore.net uwire %[[W0]] : <l1>
%w2 = moore.net uwire %1 : <l1>
// CHECK: %w3 = moore.net tri %[[W0]] : <l1>
%w3 = moore.net tri %1 : <l1>
// CHECK: %w4 = moore.net triand %[[W0]] : <l1>
%w4 = moore.net triand %1 : <l1>
// CHECK: %w5 = moore.net trior %[[W0]] : <l1>
%w5 = moore.net trior %1 : <l1>
// CHECK: %w6 = moore.net wand %[[W0]] : <l1>
%w6 = moore.net wand %1 : <l1>
// CHECK: %w7 = moore.net wor %[[W0]] : <l1>
%w7 = moore.net wor %1 : <l1>
// CHECK: %w8 = moore.net trireg %[[W0]] : <l1>
%w8 = moore.net trireg %1 : <l1>
// CHECK: %w9 = moore.net tri0 %[[W0]] : <l1>
%w9 = moore.net tri0 %1 : <l1>
// CHECK: %w10 = moore.net tri1 %[[W0]] : <l1>
%w10 = moore.net tri1 %1 : <l1>
// CHECK: %w11 = moore.net supply0 : <l1>
%w11 = moore.net supply0 : <l1>
// CHECK: %w12 = moore.net supply1 : <l1>
%w12 = moore.net supply1 : <l1>
// CHECK: moore.procedure initial {
// CHECK: moore.procedure final {
// CHECK: moore.procedure always {
// CHECK: moore.procedure always_comb {
// CHECK: moore.procedure always_latch {
// CHECK: moore.procedure always_ff {
moore.procedure initial { moore.return }
moore.procedure final { moore.return }
moore.procedure always { moore.return }
moore.procedure always_comb { moore.return }
moore.procedure always_latch { moore.return }
moore.procedure always_ff { moore.return }
// CHECK: %[[TMP1:.+]] = moore.read %v2
// CHECK: moore.assign %v1, %[[TMP1]] : i1
%2 = moore.read %v2 : <i1>
moore.assign %v1, %2 : i1
moore.procedure always {
// CHECK: %a = moore.variable : <i32>
%a = moore.variable : <i32>
moore.return
}
}
// CHECK-LABEL: moore.module @ContinuousAssignments
moore.module @ContinuousAssignments(
in %arg0: !moore.ref<i42>,
in %arg1: !moore.i42,
in %arg2: !moore.time
) {
// CHECK: moore.assign %arg0, %arg1 : i42
moore.assign %arg0, %arg1 : i42
// CHECK: moore.delayed_assign %arg0, %arg1, %arg2 : i42
moore.delayed_assign %arg0, %arg1, %arg2 : i42
}
// CHECK-LABEL: func.func @ProceduralAssignments
func.func @ProceduralAssignments(
%arg0: !moore.ref<i42>,
%arg1: !moore.i42,
%arg2: !moore.time
) {
// CHECK: moore.blocking_assign %arg0, %arg1 : i42
moore.blocking_assign %arg0, %arg1 : i42
// CHECK: moore.nonblocking_assign %arg0, %arg1 : i42
moore.nonblocking_assign %arg0, %arg1 : i42
// CHECK: moore.delayed_nonblocking_assign %arg0, %arg1, %arg2 : i42
moore.delayed_nonblocking_assign %arg0, %arg1, %arg2 : i42
return
}
// CHECK-LABEL: moore.module @Expressions
moore.module @Expressions(
// CHECK-SAME: in [[A:%[^:]+]] : !moore.i32
// CHECK-SAME: in [[B:%[^:]+]] : !moore.i32
in %a: !moore.i32,
in %b: !moore.i32,
// CHECK-SAME: in [[C:%[^:]+]] : !moore.l32
// CHECK-SAME: in [[D:%[^:]+]] : !moore.l3
in %c: !moore.l32,
in %d: !moore.l32,
// CHECK-SAME: in [[X:%[^:]+]] : !moore.i1
in %x: !moore.i1,
// CHECK-SAME: in [[BA:%[^:]+]] : i1
in %ba : i1,
// CHECK-SAME: in [[BB:%[^:]+]] : i32
in %bb : i32,
// CHECK-SAME: in [[ARRAY1:%[^:]+]] : !moore.uarray<4 x i8>
in %array1: !moore.uarray<4 x i8>,
// CHECK-SAME: in [[ARRAY2:%[^:]+]] : !moore.uarray<2 x uarray<4 x i8>>
in %array2: !moore.uarray<2 x uarray<4 x i8>>,
// CHECK-SAME: in %s1 : !moore.string
in %s1 : !moore.string,
// CHECK-SAME: in %s2 : !moore.string
in %s2 : !moore.string,
// CHECK-SAME: in [[REF_A:%[^:]+]] : !moore.ref<i32>
in %refA: !moore.ref<i32>,
// CHECK-SAME: in [[REF_B:%[^:]+]] : !moore.ref<i32>
in %refB: !moore.ref<i32>,
// CHECK-SAME: in [[REF_C:%[^:]+]] : !moore.ref<l32>
in %refC: !moore.ref<l32>,
// CHECK-SAME: in [[REF_D:%[^:]+]] : !moore.ref<l32>
in %refD: !moore.ref<l32>,
// CHECK-SAME: in [[REF_ARRAY1:%[^:]+]] : !moore.ref<uarray<4 x i8>>
in %refArray1: !moore.ref<!moore.uarray<4 x i8>>,
// CHECK-SAME: in [[REF_ARRAY2:%[^:]+]] : !moore.ref<uarray<2 x uarray<4 x i8>>>
in %refArray2: !moore.ref<uarray<2 x uarray<4 x i8>>>,
// CHECK-SAME: in [[STRUCT1:%.+]] : !moore.struct<{a: i32, b: i32}>
in %struct1: !moore.struct<{a: i32, b: i32}>,
// CHECK-SAME: in [[REF_STRUCT1:%.+]] : !moore.ref<struct<{a: i32, b: i32}>>
in %refStruct1: !moore.ref<struct<{a: i32, b: i32}>>
) {
// CHECK: moore.constant 0 : i0
moore.constant 0 : i0
// CHECK: moore.constant 0 : i1
moore.constant 0 : i1
// CHECK: moore.constant 1 : i1
moore.constant 1 : i1
// CHECK: moore.constant 0 : i32
moore.constant 0 : i32
// CHECK: moore.constant -2 : i2
moore.constant 2 : i2
// CHECK: moore.constant -2 : i2
moore.constant -2 : i2
// CHECK: moore.constant 1311768467463790320 : i64
moore.constant h123456789ABCDEF0 : i64
// CHECK: moore.constant h123456789ABCDEF0XZ : l72
moore.constant h123456789ABCDEF0XZ : l72
// CHECK: moore.constant 10 : i8
moore.constant b1010 : i8
// CHECK: moore.constant b1010XZ : l8
moore.constant b1010XZ : l8
// CHECK: moore.conversion [[A]] : !moore.i32 -> !moore.l32
moore.conversion %a : !moore.i32 -> !moore.l32
// CHECK: moore.packed_to_sbv [[STRUCT1]] : struct<{a: i32, b: i32}>
moore.packed_to_sbv %struct1 : struct<{a: i32, b: i32}>
// CHECK: moore.sbv_to_packed [[C]] : struct<{u: l16, v: l16}>
moore.sbv_to_packed %c : struct<{u: l16, v: l16}>
// CHECK: moore.logic_to_int [[C]] : l32
moore.logic_to_int %c : l32
// CHECK: moore.int_to_logic [[A]] : i32
moore.int_to_logic %a : i32
// CHECK: moore.to_builtin_int [[X]] : i1
moore.to_builtin_int %x : i1
// CHECK: moore.to_builtin_int [[A]] : i32
moore.to_builtin_int %a : i32
// CHECK: moore.from_builtin_int [[BA]] : i1
moore.from_builtin_int %ba : i1
// CHECK: moore.from_builtin_int [[BB]] : i32
moore.from_builtin_int %bb : i32
// CHECK: moore.neg [[A]] : i32
moore.neg %a : i32
// CHECK: moore.not [[A]] : i32
moore.not %a : i32
// CHECK: moore.reduce_and [[A]] : i32 -> i1
moore.reduce_and %a : i32 -> i1
// CHECK: moore.reduce_or [[A]] : i32 -> i1
moore.reduce_or %a : i32 -> i1
// CHECK: moore.reduce_xor [[A]] : i32 -> i1
moore.reduce_xor %a : i32 -> i1
// CHECK: moore.reduce_xor [[C]] : l32 -> l1
moore.reduce_xor %c : l32 -> l1
// CHECK: moore.bool_cast [[A]] : i32 -> i1
moore.bool_cast %a : i32 -> i1
// CHECK: moore.bool_cast [[C]] : l32 -> l1
moore.bool_cast %c : l32 -> l1
// CHECK: moore.add [[A]], [[B]] : i32
moore.add %a, %b : i32
// CHECK: moore.sub [[A]], [[B]] : i32
moore.sub %a, %b : i32
// CHECK: moore.mul [[A]], [[B]] : i32
moore.mul %a, %b : i32
// CHECK: moore.divu [[A]], [[B]] : i32
moore.divu %a, %b : i32
// CHECK: moore.divs [[A]], [[B]] : i32
moore.divs %a, %b : i32
// CHECK: moore.modu [[A]], [[B]] : i32
moore.modu %a, %b : i32
// CHECK: moore.mods [[A]], [[B]] : i32
moore.mods %a, %b : i32
// CHECK: moore.and [[A]], [[B]] : i32
moore.and %a, %b : i32
// CHECK: moore.or [[A]], [[B]] : i32
moore.or %a, %b : i32
// CHECK: moore.xor [[A]], [[B]] : i32
moore.xor %a, %b : i32
// CHECK: moore.shl [[C]], [[A]] : l32, i32
moore.shl %c, %a : l32, i32
// CHECK: moore.shr [[C]], [[A]] : l32, i32
moore.shr %c, %a : l32, i32
// CHECK: moore.ashr [[C]], [[A]] : l32, i32
moore.ashr %c, %a : l32, i32
// CHECK: moore.eq [[A]], [[B]] : i32 -> i1
moore.eq %a, %b : i32 -> i1
// CHECK: moore.uarray_cmp eq [[ARRAY1]], [[ARRAY1]] : <4 x i8> -> i1
moore.uarray_cmp eq %array1, %array1 : <4 x i8> -> i1
// CHECK: moore.ne [[A]], [[B]] : i32 -> i1
moore.ne %a, %b : i32 -> i1
// CHECK: moore.ne [[C]], [[D]] : l32 -> l1
moore.ne %c, %d : l32 -> l1
// CHECK: moore.uarray_cmp ne [[ARRAY1]], [[ARRAY1]] : <4 x i8> -> i1
moore.uarray_cmp ne %array1, %array1 : <4 x i8> -> i1
// CHECK: moore.case_eq [[A]], [[B]] : i32
moore.case_eq %a, %b : i32
// CHECK: moore.case_ne [[A]], [[B]] : i32
moore.case_ne %a, %b : i32
// CHECK: moore.wildcard_eq [[A]], [[B]] : i32 -> i1
moore.wildcard_eq %a, %b : i32 -> i1
// CHECK: moore.wildcard_ne [[A]], [[B]] : i32 -> i1
moore.wildcard_ne %a, %b : i32 -> i1
// CHECK: moore.wildcard_ne [[C]], [[D]] : l32 -> l1
moore.wildcard_ne %c, %d : l32 -> l1
// CHECK: moore.ult [[A]], [[B]] : i32 -> i1
moore.ult %a, %b : i32 -> i1
// CHECK: moore.ule [[A]], [[B]] : i32 -> i1
moore.ule %a, %b : i32 -> i1
// CHECK: moore.ugt [[A]], [[B]] : i32 -> i1
moore.ugt %a, %b : i32 -> i1
// CHECK: moore.uge [[A]], [[B]] : i32 -> i1
moore.uge %a, %b : i32 -> i1
// CHECK: moore.slt [[A]], [[B]] : i32 -> i1
moore.slt %a, %b : i32 -> i1
// CHECK: moore.sle [[A]], [[B]] : i32 -> i1
moore.sle %a, %b : i32 -> i1
// CHECK: moore.sgt [[A]], [[B]] : i32 -> i1
moore.sgt %a, %b : i32 -> i1
// CHECK: moore.sge [[A]], [[B]] : i32 -> i1
moore.sge %a, %b : i32 -> i1
// CHECK: moore.uge [[C]], [[D]] : l32 -> l1
moore.uge %c, %d : l32 -> l1
// CHECK: moore.concat [[A]] : (!moore.i32) -> i32
moore.concat %a : (!moore.i32) -> i32
// CHECK: moore.concat [[A]], [[B]] : (!moore.i32, !moore.i32) -> i64
moore.concat %a, %b : (!moore.i32, !moore.i32) -> i64
// CHECK: moore.concat [[C]], [[D]], [[C]] : (!moore.l32, !moore.l32, !moore.l32) -> l96
moore.concat %c, %d, %c : (!moore.l32, !moore.l32, !moore.l32) -> l96
// CHECK: moore.concat_ref [[REF_A]] : (!moore.ref<i32>) -> <i32>
moore.concat_ref %refA : (!moore.ref<i32>) -> <i32>
// CHECK: moore.concat_ref [[REF_A]], [[REF_B]] : (!moore.ref<i32>, !moore.ref<i32>) -> <i64>
moore.concat_ref %refA, %refB : (!moore.ref<i32>, !moore.ref<i32>) -> <i64>
// CHECK: moore.concat_ref [[REF_C]], [[REF_D]], [[REF_C]] : (!moore.ref<l32>, !moore.ref<l32>, !moore.ref<l32>) -> <l96>
moore.concat_ref %refC, %refD, %refC : (!moore.ref<l32>, !moore.ref<l32>, !moore.ref<l32>) -> <l96>
// CHECK: moore.replicate [[X]] : i1 -> i4
moore.replicate %x : i1 -> i4
// CHECK: moore.dyn_extract [[A]] from [[B]] : i32, i32 -> i1
moore.dyn_extract %a from %b : i32, i32 -> i1
// CHECK: moore.dyn_extract [[ARRAY2]] from [[A]] : uarray<2 x uarray<4 x i8>>, i32 -> uarray<4 x i8>
moore.dyn_extract %array2 from %a : uarray<2 x uarray<4 x i8>>, i32 -> uarray<4 x i8>
// CHECK: moore.dyn_extract [[ARRAY1]] from [[A]] : uarray<4 x i8>, i32 -> i8
moore.dyn_extract %array1 from %a : uarray<4 x i8>, i32 -> i8
// CHECK: moore.dyn_extract_ref [[REF_A]] from [[B]] : <i32>, i32 -> <i1>
moore.dyn_extract_ref %refA from %b : <i32>, i32 -> <i1>
// CHECK: moore.dyn_extract_ref [[REF_ARRAY2]] from [[A]] : <uarray<2 x uarray<4 x i8>>>, i32 -> <uarray<4 x i8>>
moore.dyn_extract_ref %refArray2 from %a : <uarray<2 x uarray<4 x i8>>>, i32 -> <uarray<4 x i8>>
// CHECK: moore.dyn_extract_ref [[REF_ARRAY1]] from [[A]] : <uarray<4 x i8>>, i32 -> <i8>
moore.dyn_extract_ref %refArray1 from %a : <uarray<4 x i8>>, i32 -> <i8>
// CHECK: moore.conditional [[X]] : i1 -> i32 {
// CHECK: moore.yield [[A]] : i32
// CHECK: } {
// CHECK: moore.yield [[B]] : i32
// CHECK: }
moore.conditional %x : i1 -> i32 {
moore.yield %a : i32
} {
moore.yield %b : i32
}
// CHECK: moore.array_create [[A]], [[B]] : !moore.i32, !moore.i32 -> array<2 x i32>
moore.array_create %a, %b : !moore.i32, !moore.i32 -> array<2 x i32>
// CHECK: moore.struct_create [[A]], [[B]] : !moore.i32, !moore.i32 -> struct<{a: i32, b: i32}>
moore.struct_create %a, %b : !moore.i32, !moore.i32 -> struct<{a: i32, b: i32}>
// CHECK: moore.struct_extract [[STRUCT1]], "a" : struct<{a: i32, b: i32}> -> i32
moore.struct_extract %struct1, "a" : struct<{a: i32, b: i32}> -> i32
// CHECK: moore.struct_extract_ref [[REF_STRUCT1]], "a" : <struct<{a: i32, b: i32}>> -> <i32>
moore.struct_extract_ref %refStruct1, "a" : <struct<{a: i32, b: i32}>> -> <i32>
// CHECK: moore.struct_inject [[STRUCT1]], "a", [[B]] : struct<{a: i32, b: i32}>, i32
moore.struct_inject %struct1, "a", %b : struct<{a: i32, b: i32}>, i32
// CHECK: moore.constant_string "Test" : i128
moore.constant_string "Test" : i128
// CHECK: moore.constant_string "" : i128
moore.constant_string "" : i128
// CHECK: moore.string_cmp eq %s1, %s2 : string -> i1
moore.string_cmp eq %s1, %s2 : string -> i1
// CHECK: moore.string_cmp ne %s1, %s2 : string -> i1
moore.string_cmp ne %s1, %s2 : string -> i1
// CHECK: moore.string_cmp lt %s1, %s2 : string -> i1
moore.string_cmp lt %s1, %s2 : string -> i1
// CHECK: moore.string_cmp le %s1, %s2 : string -> i1
moore.string_cmp le %s1, %s2 : string -> i1
// CHECK: moore.string_cmp gt %s1, %s2 : string -> i1
moore.string_cmp gt %s1, %s2 : string -> i1
// CHECK: moore.string_cmp ge %s1, %s2 : string -> i1
moore.string_cmp ge %s1, %s2 : string -> i1
moore.output
}
// CHECK-LABEL: moore.module @GraphRegion
moore.module @GraphRegion() {
%1 = moore.add %0, %0 : i32
%0 = moore.constant 0 : i32
}
// CHECK-LABEL: func.func @WaitEvent
func.func @WaitEvent(%arg0: !moore.i1, %arg1: !moore.i1) {
// CHECK: moore.wait_event {
moore.wait_event {
// CHECK: moore.detect_event any %arg0 : i1
moore.detect_event any %arg0 : i1
// CHECK: moore.detect_event posedge %arg0 : i1
moore.detect_event posedge %arg0 : i1
// CHECK: moore.detect_event negedge %arg0 : i1
moore.detect_event negedge %arg0 : i1
// CHECK: moore.detect_event edge %arg0 : i1
moore.detect_event edge %arg0 : i1
// CHECK: moore.detect_event any %arg0 if %arg1 : i1
moore.detect_event any %arg0 if %arg1 : i1
}
// CHECK: }
return
}
// CHECK-LABEL: func.func @WaitDelay
func.func @WaitDelay(%arg0: !moore.time) {
// CHECK: moore.wait_delay %arg0
moore.wait_delay %arg0
return
}
// CHECK-LABEL: func.func @FormatStrings
// CHECK-SAME: %arg0: !moore.format_string
func.func @FormatStrings(%arg0: !moore.format_string, %arg1: !moore.i42, %arg2: !moore.f32, %arg3: !moore.f64) {
// CHECK: moore.fmt.literal "hello"
moore.fmt.literal "hello"
// CHECK: moore.fmt.concat ()
moore.fmt.concat ()
// CHECK: moore.fmt.concat (%arg0)
moore.fmt.concat (%arg0)
// CHECK: moore.fmt.concat (%arg0, %arg0)
moore.fmt.concat (%arg0, %arg0)
// CHECK: moore.fmt.int binary %arg1, align left, pad zero width 42 : i42
moore.fmt.int binary %arg1, align left, pad zero width 42 : i42
// CHECK: moore.fmt.int binary %arg1, align right, pad zero width 42 : i42
moore.fmt.int binary %arg1, align right, pad zero width 42 : i42
// CHECK: moore.fmt.int binary %arg1, align right, pad space width 42 : i42
moore.fmt.int binary %arg1, align right, pad space width 42 : i42
// CHECK: moore.fmt.int octal %arg1, align left, pad zero width 42 : i42
moore.fmt.int octal %arg1, align left, pad zero width 42 : i42
// CHECK: moore.fmt.int decimal %arg1, align left, pad zero width 42 signed : i42
moore.fmt.int decimal %arg1, align left, pad zero width 42 signed : i42
// CHECK: moore.fmt.int decimal %arg1, align left, pad zero signed : i42
moore.fmt.int decimal %arg1, align left, pad zero signed : i42
// CHECK: moore.fmt.int decimal %arg1, align left, pad zero width 42 : i42
moore.fmt.int decimal %arg1, align left, pad zero width 42 : i42
// CHECK: moore.fmt.int hex_lower %arg1, align left, pad zero width 42 : i42
moore.fmt.int hex_lower %arg1, align left, pad zero width 42 : i42
// CHECK: moore.fmt.int hex_upper %arg1, align left, pad zero width 42 : i42
moore.fmt.int hex_upper %arg1, align left, pad zero width 42 : i42
// CHECK: moore.fmt.real float %arg2, align left : f32
moore.fmt.real float %arg2, align left : f32
// CHECK: moore.fmt.real exponential %arg3, align left : f64
moore.fmt.real exponential %arg3, align left : f64
// CHECK: moore.fmt.real general %arg3, align right fieldWidth 9 fracDigits 8 : f64
moore.fmt.real general %arg3, align right fieldWidth 9 fracDigits 8 : f64
// CHECK: moore.fmt.real float %arg2, align right fieldWidth 12 : f32
moore.fmt.real float %arg2, align right fieldWidth 12 : f32
// CHECK: moore.fmt.real exponential %arg3, align right fracDigits 5 : f64
moore.fmt.real exponential %arg3, align right fracDigits 5 : f64
// CHECK: moore.fmt.hier_path
moore.fmt.hier_path
// CHECK: moore.fmt.hier_path escaped
moore.fmt.hier_path escaped
return
}
// CHECK-LABEL: func.func @SimulationControlBuiltins
func.func @SimulationControlBuiltins() {
// CHECK: moore.builtin.stop
moore.builtin.stop
// CHECK: moore.builtin.finish 42
moore.builtin.finish 42
// CHECK: moore.builtin.finish_message false
moore.builtin.finish_message false
// CHECK: moore.unreachable
moore.unreachable
}
// CHECK-LABEL: func.func @SeverityAndDisplayBuiltins
func.func @SeverityAndDisplayBuiltins(%arg0: !moore.format_string) {
// CHECK: moore.builtin.display %arg0
moore.builtin.display %arg0
// CHECK: moore.builtin.severity info %arg0
moore.builtin.severity info %arg0
// CHECK: moore.builtin.severity warning %arg0
moore.builtin.severity warning %arg0
// CHECK: moore.builtin.severity error %arg0
moore.builtin.severity error %arg0
// CHECK: moore.builtin.severity fatal %arg0
moore.builtin.severity fatal %arg0
return
}
// CHECK-LABEL: func.func @MathBuiltins
func.func @MathBuiltins(%arg0: !moore.i32, %arg1: !moore.l42) {
// CHECK: moore.builtin.clog2 %arg0 : i32
moore.builtin.clog2 %arg0 : i32
// CHECK: moore.builtin.clog2 %arg1 : l42
moore.builtin.clog2 %arg1 : l42
return
}
// CHECK-LABEL: func.func @TimeConversion
func.func @TimeConversion(%arg0: !moore.time, %arg1: !moore.l64) {
// CHECK: moore.packed_to_sbv %arg0 : time
moore.packed_to_sbv %arg0 : time
// CHECK: moore.sbv_to_packed %arg1 : time
moore.sbv_to_packed %arg1 : time
// CHECK: moore.time_to_logic %arg0
moore.time_to_logic %arg0
// CHECK: moore.logic_to_time %arg1
moore.logic_to_time %arg1
return
}
// CHECK-LABEL: func.func @RealConversion32(%arg0: !moore.f32, %arg1: !moore.i42, %arg2: !moore.f64)
func.func @RealConversion32(%arg0: !moore.f32, %arg1: !moore.i42, %arg2: !moore.f64) {
// CHECK: moore.real_to_int %arg0 : f32 -> i42
%0 = moore.real_to_int %arg0 : f32 -> i42
// CHECK: moore.sint_to_real %arg1 : i42 -> f32
%1 = moore.sint_to_real %arg1 : i42 -> f32
// CHECK: moore.convert_real %arg0 : f32 -> f64
%2 = moore.convert_real %arg0 : f32 -> f64
// CHECK: moore.convert_real %arg2 : f64 -> f32
%3 = moore.convert_real %arg2 : f64 -> f32
return
}
// CHECK-LABEL: func.func @RealConversion64(%arg0: !moore.f64, %arg1: !moore.i42)
func.func @RealConversion64(%arg0: !moore.f64, %arg1: !moore.i42) {
// CHECK: moore.real_to_int %arg0 : f64 -> i42
%0 = moore.real_to_int %arg0 : f64 -> i42
// CHECK: moore.uint_to_real %arg1 : i42 -> f64
%1 = moore.uint_to_real %arg1 : i42 -> f64
return
}
// CHECK-LABEL: moore.global_variable @GlobalVar1 : !moore.i42
moore.global_variable @GlobalVar1 : !moore.i42
// CHECK: moore.get_global_variable @GlobalVar1 : <i42>
moore.get_global_variable @GlobalVar1 : <i42>
// CHECK-LABEL: moore.global_variable @GlobalVar2 : !moore.i42
moore.global_variable @GlobalVar2 : !moore.i42 init {
// CHECK-NEXT: moore.constant
%0 = moore.constant 9001 : i42
// CHECK-NEXT: moore.yield
moore.yield %0 : !moore.i42
}
// CHECK: moore.get_global_variable @GlobalVar2 : <i42>
moore.get_global_variable @GlobalVar2 : <i42>
// CHECK-LABEL: func.func @StringConversion
// CHECK-SAME: [[A:%.+]]: !moore.i32
// CHECK-SAME: [[B:%.+]]: !moore.string
func.func @StringConversion(%a: !moore.i32, %b: !moore.string) {
// CHECK: moore.int_to_string [[A]] : i32
moore.int_to_string %a : i32
// CHECK: moore.string_to_int [[B]] : i32
moore.string_to_int %b : i32
return
}
// CHECK-LABEL: func.func @StringOperations
func.func @StringOperations(%arg0 : !moore.string, %arg1 : !moore.string) {
// CHECK: moore.string.concat ()
moore.string.concat ()
// CHECK: moore.string.concat (%arg0)
moore.string.concat (%arg0)
// CHECK: moore.string.concat (%arg0, %arg1)
moore.string.concat (%arg0, %arg1)
// CHECK: moore.string.len %arg0
moore.string.len %arg0
return
}
// CHECK-LABEL: moore.coroutine @myTask(%arg0: !moore.ref<l1>)
moore.coroutine @myTask(%arg0: !moore.ref<l1>) {
// CHECK: moore.wait_event
moore.wait_event {
%0 = moore.read %arg0 : <l1>
moore.detect_event posedge %0 : l1
}
// CHECK: moore.return
moore.return
}
// CHECK-LABEL: moore.coroutine private @privateTask()
moore.coroutine private @privateTask() {
moore.return
}
moore.module @CoroutineCallTest() {
%clk = moore.variable : <l1>
moore.procedure initial {
// CHECK: moore.call_coroutine @myTask(%clk) : (!moore.ref<l1>) -> ()
moore.call_coroutine @myTask(%clk) : (!moore.ref<l1>) -> ()
moore.return
}
moore.output
}