WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

basic-tests.uir 25.5 KB
Newer Older
Kunshan Wang's avatar
Kunshan Wang committed
1
.typedef @i1 = int<1>
Kunshan Wang's avatar
Kunshan Wang committed
2
3
4
5
6
7
8
9
10
11
12
.typedef @i8 = int<8>
.typedef @i16 = int<16>
.typedef @i32 = int<32>
.typedef @i64 = int<64>
.typedef @float = float
.typedef @double = double

.typedef @void = void

.funcsig @noparamsnoret = @void ()

Kunshan Wang's avatar
Kunshan Wang committed
13
14
15
16
17
18
.typedef @funcdumb = func<@noparamsnoret>

.typedef @thread = thread
.typedef @stack = stack
.typedef @tagref64 = tagref64

Kunshan Wang's avatar
Kunshan Wang committed
19
20
21
.const @TRUE <@i64> = 1
.const @FALSE <@i64> = 0

Kunshan Wang's avatar
Kunshan Wang committed
22
23
24
25
26
27
28
29
30
.const @I32_0 <@i32> = 0
.const @I32_1 <@i32> = 1
.const @I32_2 <@i32> = 2
.const @I32_3 <@i32> = 3
.const @I32_4 <@i32> = 4
.const @I32_5 <@i32> = 5
.const @I32_6 <@i32> = 6
.const @I32_7 <@i32> = 7

Kunshan Wang's avatar
Kunshan Wang committed
31
32
33
34
.const @I64_0 <@i64> = 0
.const @I64_1 <@i64> = 1
.const @I64_2 <@i64> = 2
.const @I64_3 <@i64> = 3
Kunshan Wang's avatar
Kunshan Wang committed
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
.const @I64_4 <@i64> = 4
.const @I64_5 <@i64> = 5
.const @I64_6 <@i64> = 6
.const @I64_7 <@i64> = 7

.const @F_0 <@float> = 0.0f
.const @F_1 <@float> = 1.0f
.const @F_2 <@float> = 2.0f
.const @F_3 <@float> = 3.0f
.const @F_4 <@float> = 4.0f
.const @F_5 <@float> = 5.0f
.const @F_6 <@float> = 6.0f
.const @F_7 <@float> = 7.0f

.const @D_0 <@double> = 0.0d
.const @D_1 <@double> = 1.0d
.const @D_2 <@double> = 2.0d
.const @D_3 <@double> = 3.0d
.const @D_4 <@double> = 4.0d
.const @D_5 <@double> = 5.0d
.const @D_6 <@double> = 6.0d
.const @D_7 <@double> = 7.0d

.typedef @4xfloat  = vector <@float 4>
.typedef @4xi32    = vector <@i32 4>
.typedef @2xdouble = vector <@double 2>

62
63
.const @4xI32_V1 <@4xi32> = VEC {@I32_0 @I32_1 @I32_2 @I32_3}
.const @4xI32_V2 <@4xi32> = VEC {@I32_4 @I32_5 @I32_6 @I32_7}
Kunshan Wang's avatar
Kunshan Wang committed
64

65
66
.const @4xF_V1 <@4xfloat> = VEC {@F_0 @F_1 @F_2 @F_3}
.const @4xF_V2 <@4xfloat> = VEC {@F_4 @F_5 @F_6 @F_7}
Kunshan Wang's avatar
Kunshan Wang committed
67

68
69
.const @2xD_V1 <@2xdouble> = VEC {@D_0 @D_1}
.const @2xD_V2 <@2xdouble> = VEC {@D_2 @D_3}
Kunshan Wang's avatar
Kunshan Wang committed
70

Kunshan Wang's avatar
Kunshan Wang committed
71
72
73
.funcsig @i_ii = @i64 (@i64 @i64)

.typedef @refvoid = ref<@void>
Kunshan Wang's avatar
Kunshan Wang committed
74
75
.typedef @irefvoid = iref<@void>
.typedef @weakrefvoid = weakref<@void>
Kunshan Wang's avatar
Kunshan Wang committed
76
77
.const @NULLREF <@refvoid> = NULL

Kunshan Wang's avatar
Kunshan Wang committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
.funcsig @binops32_sig = @void (@i32 @i32)
.funcdef @binops32 VERSION @binops32_v1 <@binops32_sig> (%p0 %p1) {
    %entry:
        %add  = ADD  <@i32> %p0 %p1
        %sub  = SUB  <@i32> %p0 %p1
        %mul  = MUL  <@i32> %p0 %p1
        %udiv = UDIV <@i32> %p0 %p1
        %sdiv = SDIV <@i32> %p0 %p1
        %urem = UREM <@i32> %p0 %p1
        %srem = SREM <@i32> %p0 %p1
        %shl  = SHL  <@i32> %p0 %p1
        %lshr = LSHR <@i32> %p0 %p1
        %ashr = ASHR <@i32> %p0 %p1
        %and  = AND  <@i32> %p0 %p1
        %or   = OR   <@i32> %p0 %p1
        %xor  = XOR  <@i32> %p0 %p1
        
        %trap = TRAP <@void> KEEPALIVE (
            %add %sub %mul %udiv %sdiv %urem %srem
            %shl %lshr %ashr %and %or %xor
            )
            
        COMMINST @uvm.thread_exit
Kunshan Wang's avatar
Kunshan Wang committed
101
102
}

Kunshan Wang's avatar
Kunshan Wang committed
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
.funcsig @binops64_sig = @void (@i64 @i64)
.funcdef @binops64 VERSION @binops64_v1 <@binops64_sig> (%p0 %p1) {
    %entry:
        %add  = ADD  <@i64> %p0 %p1
        %sub  = SUB  <@i64> %p0 %p1
        %mul  = MUL  <@i64> %p0 %p1
        %udiv = UDIV <@i64> %p0 %p1
        %sdiv = SDIV <@i64> %p0 %p1
        %urem = UREM <@i64> %p0 %p1
        %srem = SREM <@i64> %p0 %p1
        %shl  = SHL  <@i64> %p0 %p1
        %lshr = LSHR <@i64> %p0 %p1
        %ashr = ASHR <@i64> %p0 %p1
        %and  = AND  <@i64> %p0 %p1
        %or   = OR   <@i64> %p0 %p1
        %xor  = XOR  <@i64> %p0 %p1
Kunshan Wang's avatar
Kunshan Wang committed
119
        
Kunshan Wang's avatar
Kunshan Wang committed
120
121
122
123
124
125
        %trap = TRAP <@void> KEEPALIVE (
            %add %sub %mul %udiv %sdiv %urem %srem
            %shl %lshr %ashr %and %or %xor
            )
             
        COMMINST @uvm.thread_exit
Kunshan Wang's avatar
Kunshan Wang committed
126
127
}

Kunshan Wang's avatar
Kunshan Wang committed
128
129
.funcsig @binops64_div0_sig = @void (@i64 @i64 @i64 @i64 @i64)
.funcdef @binops64_div0 VERSION @binops64_div0_v1 <@binops64_div0_sig> (%p0 %p1 %p2 %p3 %p4) {
Kunshan Wang's avatar
Kunshan Wang committed
130
    %entry:
Kunshan Wang's avatar
Kunshan Wang committed
131
132
133
134
135
136
137
138
139
140
141
142
143
144
        %udiv = UDIV <@i64> %p0 %p1 EXC(%bb2 %exc)
    %bb2:
        %sdiv = SDIV <@i64> %p0 %p2 EXC(%bb3 %exc)
    %bb3:
        %urem = UREM <@i64> %p0 %p3 EXC(%bb4 %exc)
    %bb4:
        %srem = SREM <@i64> %p0 %p4 EXC(%nor %exc)

    %nor:
        %trapnor = TRAP <@void>
        COMMINST @uvm.thread_exit

    %exc:
        %trapexc = TRAP <@void>
Kunshan Wang's avatar
Kunshan Wang committed
145
        COMMINST @uvm.thread_exit
Kunshan Wang's avatar
Kunshan Wang committed
146
147
}

Kunshan Wang's avatar
Kunshan Wang committed
148
149
150
151
152
153
154
155
156
157
158
159
160
.funcsig @binops_f_sig = @void (@float @float)
.funcdef @binops_f VERSION @binops_f_v1 <@binops_f_sig> (%p0 %p1) {
    %entry:
        %fadd = FADD <@float> %p0 %p1
        %fsub = FSUB <@float> %p0 %p1
        %fmul = FMUL <@float> %p0 %p1
        %fdiv = FDIV <@float> %p0 %p1
        %frem = FREM <@float> %p0 %p1
        
        %trap = TRAP <@void> KEEPALIVE (
            %fadd %fsub %fmul %fdiv %frem
            )
        COMMINST @uvm.thread_exit
Kunshan Wang's avatar
Kunshan Wang committed
161
162
}

Kunshan Wang's avatar
Kunshan Wang committed
163
164
165
166
167
168
169
170
171
172
173
174
175
.funcsig @binops_d_sig = @void (@double @double)
.funcdef @binops_d VERSION @binops_d_v1 <@binops_d_sig> (%p0 %p1) {
    %entry:
        %fadd = FADD <@double> %p0 %p1
        %fsub = FSUB <@double> %p0 %p1
        %fmul = FMUL <@double> %p0 %p1
        %fdiv = FDIV <@double> %p0 %p1
        %frem = FREM <@double> %p0 %p1
        
        %trap = TRAP <@void> KEEPALIVE (
            %fadd %fsub %fmul %fdiv %frem
            )
        COMMINST @uvm.thread_exit
Kunshan Wang's avatar
Kunshan Wang committed
176
177
}

Kunshan Wang's avatar
Kunshan Wang committed
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
.funcsig @binops_vec_sig = @void (@4xi32 @4xi32 @4xfloat @4xfloat @2xdouble @2xdouble)
.funcdef @binops_vec VERSION @binops_vec_v1 <@binops_vec_sig> (%p0 %p1 %p2 %p3 %p4 %p5) {
    %entry:
        %addi = ADD  <@4xi32>    %p0 %p1
        %subi = SUB  <@4xi32>    %p0 %p1
        %addf = FADD <@4xfloat>  %p2 %p3
        %subf = FSUB <@4xfloat>  %p2 %p3
        %addd = FADD <@2xdouble> %p4 %p5
        %subd = FSUB <@2xdouble> %p4 %p5

        %trap = TRAP <@void> KEEPALIVE (
            %addi %subi %addf %subf %addd %subd
            )
        COMMINST @uvm.thread_exit

}

Kunshan Wang's avatar
Kunshan Wang committed
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
.funcsig @cmp64_sig = @void (@i64 @i64)
.funcdef @cmp64 VERSION @cmp64_v1 <@cmp64_sig> (%p0 %p1) {
    %entry:
        %eq  = EQ  <@i64> %p0 %p1
        %ne  = NE  <@i64> %p0 %p1
        %ult = ULT <@i64> %p0 %p1
        %ule = ULE <@i64> %p0 %p1
        %ugt = UGT <@i64> %p0 %p1
        %uge = UGE <@i64> %p0 %p1
        %slt = SLT <@i64> %p0 %p1
        %sle = SLE <@i64> %p0 %p1
        %sgt = SGT <@i64> %p0 %p1
        %sge = SGE <@i64> %p0 %p1
        
        %trap = TRAP <@void> KEEPALIVE (
            %eq %ne %ult %ule %ugt %uge %slt %sle %sgt %sge
            )
        COMMINST @uvm.thread_exit
Kunshan Wang's avatar
Kunshan Wang committed
213
214
}

Kunshan Wang's avatar
Kunshan Wang committed
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
.funcsig @cmp_f_sig = @void (@float @float)
.funcdef @cmp_f VERSION @cmp_f_v1 <@cmp_f_sig> (%p0 %p1) {
    %entry:
        %ftrue  = FTRUE  <@float> %p0 %p1
        %ffalse = FFALSE <@float> %p0 %p1
        %ford   = FORD   <@float> %p0 %p1
        %foeq   = FOEQ   <@float> %p0 %p1
        %fone   = FONE   <@float> %p0 %p1
        %folt   = FOLT   <@float> %p0 %p1
        %fole   = FOLE   <@float> %p0 %p1
        %fogt   = FOGT   <@float> %p0 %p1
        %foge   = FOGE   <@float> %p0 %p1
        %funo   = FUNO   <@float> %p0 %p1
        %fueq   = FUEQ   <@float> %p0 %p1
        %fune   = FUNE   <@float> %p0 %p1
        %fult   = FULT   <@float> %p0 %p1
        %fule   = FULE   <@float> %p0 %p1
        %fugt   = FUGT   <@float> %p0 %p1
        %fuge   = FUGE   <@float> %p0 %p1
    
        %trap = TRAP <@void> KEEPALIVE (
            %ftrue %ffalse %ford %foeq %fone %folt %fole %fogt %foge
            %funo %fueq %fune %fult %fule %fugt %fuge
            )
        COMMINST @uvm.thread_exit
Kunshan Wang's avatar
Kunshan Wang committed
240
241
}

Kunshan Wang's avatar
Kunshan Wang committed
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
.funcsig @cmp_d_sig = @void (@double @double)
.funcdef @cmp_d VERSION @cmp_d_v1 <@cmp_d_sig> (%p0 %p1) {
    %entry:
        %ftrue  = FTRUE  <@double> %p0 %p1
        %ffalse = FFALSE <@double> %p0 %p1
        %ford   = FORD   <@double> %p0 %p1
        %foeq   = FOEQ   <@double> %p0 %p1
        %fone   = FONE   <@double> %p0 %p1
        %folt   = FOLT   <@double> %p0 %p1
        %fole   = FOLE   <@double> %p0 %p1
        %fogt   = FOGT   <@double> %p0 %p1
        %foge   = FOGE   <@double> %p0 %p1
        %funo   = FUNO   <@double> %p0 %p1
        %fueq   = FUEQ   <@double> %p0 %p1
        %fune   = FUNE   <@double> %p0 %p1
        %fult   = FULT   <@double> %p0 %p1
        %fule   = FULE   <@double> %p0 %p1
        %fugt   = FUGT   <@double> %p0 %p1
        %fuge   = FUGE   <@double> %p0 %p1
    
        %trap = TRAP <@void> KEEPALIVE (
            %ftrue %ffalse %ford %foeq %fone %folt %fole %fogt %foge
            %funo %fueq %fune %fult %fule %fugt %fuge
            )
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
        COMMINST @uvm.thread_exit
}

.funcsig @cmp_vec_sig = @void (@4xi32 @4xi32 @4xfloat @4xfloat @2xdouble @2xdouble)
.funcdef @cmp_vec VERSION @cmp_vec_v1 <@cmp_vec_sig> (%p0 %p1 %p2 %p3 %p4 %p5) {
    %entry:
        %eq      = EQ   <@4xi32>    %p0 %p1
        %slt     = SLT  <@4xi32>    %p0 %p1
        %foeqf   = FOEQ <@4xfloat>  %p2 %p3
        %fultf   = FULT <@4xfloat>  %p2 %p3
        %foeqd   = FOEQ <@2xdouble> %p4 %p5
        %fultd   = FULT <@2xdouble> %p4 %p5

        %trap = TRAP <@void> KEEPALIVE (
            %eq %slt %foeqf %fultf %foeqd %fultd
            )
Kunshan Wang's avatar
Kunshan Wang committed
282
283
        COMMINST @uvm.thread_exit
}
Kunshan Wang's avatar
Kunshan Wang committed
284

Kunshan Wang's avatar
Kunshan Wang committed
285
286
287
288
289
290
291
292
293
294
.funcsig @conv_sig = @void (@i32 @i64 @float @double)
.funcdef @conv VERSION @conv_v1 <@conv_sig> (%p0 %p1 %p2 %p3) {
    %entry:
        %trunc = TRUNC <@i64 @i32> %p1
        %zext  = ZEXT  <@i32 @i64> %p0
        %sext  = SEXT  <@i32 @i64> %p0
        
        %fptrunc = FPTRUNC <@double @float> %p3
        %fpext   = FPEXT   <@float @double> %p2
        
295
296
297
298
        %fptoui1 = FPTOUI  <@double @i64> %p3
        %fptosi1 = FPTOSI  <@double @i64> %p3
        %fptoui2 = FPTOUI  <@float @i32> %p2
        %fptosi2 = FPTOSI  <@float @i32> %p2
Kunshan Wang's avatar
Kunshan Wang committed
299
300
301
        %uitofp  = UITOFP  <@i64 @double> %p1
        %sitofp  = SITOFP  <@i64 @double> %p1
        
302
303
304
305
        %bitcast1 = BITCAST <@float  @i32> %p2
        %bitcast2 = BITCAST <@double @i64> %p3
        %bitcast3 = BITCAST <@i32 @float > %bitcast1
        %bitcast4 = BITCAST <@i64 @double> %bitcast2
Kunshan Wang's avatar
Kunshan Wang committed
306
307
        
        %trap = TRAP <@void> KEEPALIVE (
308
309
310
            %trunc %zext %sext %fptrunc %fpext
            %fptoui1 %fptosi1 %fptoui2 %fptosi2 %uitofp %sitofp
            %bitcast1 %bitcast2 %bitcast3 %bitcast4
Kunshan Wang's avatar
Kunshan Wang committed
311
312
            )
        COMMINST @uvm.thread_exit
Kunshan Wang's avatar
Kunshan Wang committed
313
314
}

315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
.typedef @4xi16    = vector <@i16 4>
.typedef @4xi64    = vector <@i64 4>
.typedef @4xdouble = vector <@double 4>
.typedef @2xfloat  = vector <@float 2>

.funcsig @conv_vec_sig = @void (@4xi32 @4xfloat @2xdouble)
.funcdef @conv_vec VERSION @conv_vec_v1 <@conv_vec_sig> (%p0 %p1 %p2) {
    %entry:
        %trunc = TRUNC <@4xi32 @4xi16> %p0
        %zext  = ZEXT  <@4xi32 @4xi64> %p0
        %sext  = SEXT  <@4xi32 @4xi64> %p0
        
        %fptrunc = FPTRUNC <@2xdouble @2xfloat> %p2
        %fpext   = FPEXT   <@4xfloat @4xdouble> %p1

        %trap = TRAP <@void> KEEPALIVE (
            %trunc %zext %sext %fptrunc %fpext
            )
        COMMINST @uvm.thread_exit
}


Kunshan Wang's avatar
Kunshan Wang committed
337
338
.typedef @4xi1 = vector <@i1 4>

339
.const @4xI1_COND <@4xi1> = VEC {@TRUE @FALSE @FALSE @TRUE}
Kunshan Wang's avatar
Kunshan Wang committed
340
341

.funcdef @select VERSION @select_v1 <@noparamsnoret> () {
342
    %entry:
Kunshan Wang's avatar
Kunshan Wang committed
343
344
345
346
347
348
349
        %sel1 = SELECT <@i1 @i64> @TRUE  @I64_2 @I64_3
        %sel2 = SELECT <@i1 @i64> @FALSE @I64_2 @I64_3

        %sel3 = SELECT <@4xi1 @4xi32> @4xI1_COND @4xI32_V1 @4xI32_V2

        %sel4 = SELECT <@i1 @4xi32> @TRUE  @4xI32_V1 @4xI32_V2
        %sel5 = SELECT <@i1 @4xi32> @FALSE @4xI32_V1 @4xI32_V2
Kunshan Wang's avatar
Kunshan Wang committed
350
    
351
        %trap = TRAP <@void> KEEPALIVE (
Kunshan Wang's avatar
Kunshan Wang committed
352
            %sel1 %sel2 %sel3 %sel4 %sel5
353
354
            )
        COMMINST @uvm.thread_exit
Kunshan Wang's avatar
Kunshan Wang committed
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
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
// .funcsig @branch_sig = @void (@i64)
// .funcdef @branch VERSION @branch_v1 <@branch_sig> (%p0) {
// %entry:
//     %cmpz = EQ <@i64> %p0 0
//     BRANCH2 %cmpz %iftrue %iffalse
//     
// %iftrue:
//     %traptrue = TRAP <@void> %exit %exit KEEPALIVE ()
//     
// %iffalse:
//     %trapfalse = TRAP <@void> %exit %exit KEEPALIVE ()
//     
// %exit:
//     COMMINST @uvm.thread_exit
//     RETVOID // unreachable
// }
// 
// .funcsig @switch_phi_sig = @void (@i64)
// .funcdef @switch_phi VERSION @switch_phi_v1 <@switch_phi_sig> (%p0) {
// %entry:
//     SWITCH <@i64> %p0 %def {
//         1: %one;
//         2: %two;
//         3: %three;
//     }
//     
// %def:
//     %trapdef = TRAP <@void> %exit %exit KEEPALIVE ()
//     
// %one:
//     %trapone = TRAP <@void> %exit %exit KEEPALIVE ()
//     
// %two:
//     %traptwo = TRAP <@void> %exit %exit KEEPALIVE ()
//     
// %three:
//     %trapthree = TRAP <@void> %exit %exit KEEPALIVE ()
//     
// %exit:
//     %phi = PHI <@i64> {
//         %def: 10;
//         %one: 11;
//         %two: 12;
//         %three: 13;
//     }
//     %trapend = TRAP <@void> %exit2 %exit2 KEEPALIVE (%phi)
// %exit2:
//     COMMINST @uvm.thread_exit
//     RETVOID // unreachable
// }
// 
// .funcsig @square_sum_sig = @i_ii
// .funcdef @square_sum VERSION @square_sum_v1 <@square_sum_sig> (%a %b) {
// %entry:
//     %a2 = MUL <@i64> %a %a
//     %b2 = MUL <@i64> %b %b
//     %s  = ADD <@i64> %a2 %b2
//     RET <@i64> %s
// }
// 
// .funcsig @call_ret_sig = @i_ii
// .funcdef @call_ret VERSION @call_ret_v1 <@call_ret_sig> (%a %b) {
// %entry:
//     %ss = CALL <@i_ii> @square_sum (%a %b)
//     %trap = TRAP <@void> KEEPALIVE (%ss)
// %exit:
//     COMMINST @uvm.thread_exit
// }
// 
// .funcsig @thrower_sig = @noparamsnoret
// .funcdef @thrower VERSION @thrower_v1 <@thrower_sig> () {
// %entry:
//     THROW @NULLREF
// }
// 
// .funcsig @invoke_landingpad_sig = @noparamsnoret
// .funcdef @invoke_landingpad VERSION @invoke_landingpad_v1 <@invoke_landingpad_sig> () {
// %entry:
//     %ss = INVOKE <@noparamsnoret> @thrower () %nor %exc
// %nor:
//     %trapnor = TRAP <@void> %exit %exit KEEPALIVE ()
// %exc:
//     %lp = LANDINGPAD
//     %trapexc = TRAP <@void> %exit %exit KEEPALIVE (%lp)
// %exit:
//     COMMINST @uvm.thread_exit
// }
// 
// // Some simple struct constants
// 
// .typedef @StructFoo = struct <@i32 @i64 @float @double>
// 
// .const @STRUCT_FOO <@StructFoo> = {1 2 3.0f 4.0d}
// 
// .funcsig @aggregate_sig = @noparamsnoret
// .funcdef @aggregate VERSION @aggregate_v1 <@aggregate_sig> () {
// %entry:
//     %f1 = EXTRACTVALUE <@StructFoo 1> @STRUCT_FOO
//     %s2 = INSERTVALUE <@StructFoo 1> @STRUCT_FOO 222
//     %f12 = EXTRACTVALUE <@StructFoo 1> %s2
//     %trapnor = TRAP <@void> KEEPALIVE (%f1 %f12)
// %exit:
//     COMMINST @uvm.thread_exit
// }
// 
// .typedef @refi64 = ref<@i64>
// .typedef @irefi64 = iref<@i64>
// .typedef @weakrefi64 = weakref<@i64>
// 
// .typedef @StructBar = struct <
//     @i64 @i32 @i16 @i8 @float @double
//     @refi64 @irefi64 @weakrefi64
// >
// 
// .typedef @refBar = ref<@StructBar>
// .typedef @irefBar = iref<@StructBar>
// 
// .typedef @hCharArray = hybrid<@i64 @i8>
// 
// .funcsig @allocs_sig = @void (@i64)
// .funcdef @allocs VERSION @allocs_v1 <@allocs_sig> (%sz) {
// %entry:
//     %new = NEW <@StructBar>
//     %newhybrid = NEWHYBRID <@hCharArray> %sz
//     %alloca = ALLOCA <@StructBar>
//     %allocahybrid = ALLOCAHYBRID <@hCharArray> %sz
// 
//     %trap = TRAP <@void> KEEPALIVE (%new %newhybrid %alloca %allocahybrid)
// %exit:
//     COMMINST @uvm.thread_exit
// }
// 
// .typedef @ArrayBaz = array <@i16 1024>
// .const @THREE <@i64> = 3
// 
// .typedef @JavaLikeByteArray = hybrid <@i32 @i8>
// 
// .const @I64_1024 <@i64> = 1024
// 
// .funcsig @memAddressing_sig = @noparamsnoret
// .funcdef @memAddressing VERSION @memAddressing_v1 <@memAddressing_sig> () {
// %entry:
//     %bar_ref  = NEW <@StructBar>
//     %bar_iref = GETIREF <@StructBar> %bar_ref
//     %bar_3    = GETFIELDIREF <@StructBar 3> %bar_iref
//     
//     %baz_iref = ALLOCA <@ArrayBaz>
//     %baz_3    = GETELEMIREF <@ArrayBaz> %baz_iref @THREE
//     %baz_6    = SHIFTIREF <@i16> %baz_3 @THREE
//     
//     %ja_ref   = NEWHYBRID <@JavaLikeByteArray> @I64_1024
//     %ja_iref  = GETIREF <@JavaLikeByteArray> %ja_ref
//     %ja_fix   = GETFIXEDPARTIREF <@JavaLikeByteArray> %ja_iref
//     %ja_var   = GETVARPARTIREF <@JavaLikeByteArray> %ja_iref
// 
//     %trap = TRAP <@void> KEEPALIVE (%bar_ref %bar_iref %bar_3
//                 %baz_iref %baz_3 %baz_6 %ja_ref %ja_iref %ja_fix %ja_var)
// %exit:
//     COMMINST @uvm.thread_exit
//     
// }
// 
// .global @g_i8   <@i8>
// .global @g_i16  <@i16>
// .global @g_i32  <@i32>
// .global @g_i64  <@i64>
// .global @g_f    <@float>
// .global @g_d    <@double>
// .global @g_r    <@refvoid>
// .global @g_ir   <@irefvoid>
// .global @g_wr   <@weakrefvoid>
//     
// .global @g_func <@funcdumb>
//     
// .global @g_thr  <@thread>
// .global @g_sta  <@stack>
// .global @g_tr64 <@tagref64>
// 
// .funcsig @memAccessing_sig = @noparamsnoret
// .funcdef @memAccessing VERSION @memAccessing_v1 <@memAccessing_sig> () {
// %entry:
//     STORE <@i8>  @g_i8  41
//     STORE <@i16> @g_i16 42
//     STORE <@i32> @g_i32 43
//     STORE <@i64> @g_i64 44
//     STORE <@float>  @g_f 45.0f
//     STORE <@double> @g_d 46.0d
//     
//     %void_r  = NEW <@void>
//     %void_ir = ALLOCA <@void>
//     
//     STORE <@refvoid>     @g_r  %void_r
//     STORE <@irefvoid>    @g_ir %void_ir
//     STORE <@weakrefvoid> @g_wr %void_r
// 
//     STORE <@funcdumb> @g_func @memAccessing
//     
//     %li8  = LOAD <@i8>  @g_i8
//     %li16 = LOAD <@i16> @g_i16
//     %li32 = LOAD <@i32> @g_i32
//     %li64 = LOAD <@i64> @g_i64
//     %lf   = LOAD <@float>  @g_f
//     %ld   = LOAD <@double> @g_d
//     
//     %lr   = LOAD <@refvoid>     @g_r
//     %lir  = LOAD <@irefvoid>    @g_ir
//     %lwr  = LOAD <@weakrefvoid> @g_wr
// 
//     %lfunc = LOAD <@funcdumb> @g_func
// 
//     %trap = TRAP <@void> KEEPALIVE (%void_r %void_ir %li8 %li16
//                 %li32 %li64 %lf %ld %lr %lir %lwr %lfunc)
// %exit:
//     COMMINST @uvm.thread_exit
// }
// 
// .funcsig @memAccessingAtomic_sig = @noparamsnoret
// .funcdef @memAccessingAtomic VERSION @memAccessingAtomic_v1 <@memAccessingAtomic_sig> () {
// %entry:
//     STORE SEQ_CST <@i32> @g_i32 43
//     STORE SEQ_CST <@i64> @g_i64 44
// 
//     %void_r   = NEW <@void>
//     %void_r2  = NEW <@void>
//     %void_r3  = NEW <@void>
//     
//     STORE <@refvoid>     @g_r  %void_r
// 
//     %cx32_1 = CMPXCHG SEQ_CST UNORDERED <@i32> @g_i32 43 53
//     %cx32_2 = CMPXCHG SEQ_CST UNORDERED <@i32> @g_i32 43 63
//     %cx64_1 = CMPXCHG SEQ_CST UNORDERED <@i64> @g_i64 44 54
//     %cx64_2 = CMPXCHG SEQ_CST UNORDERED <@i64> @g_i64 44 64
//     
//     %l32 = LOAD SEQ_CST <@i32> @g_i32
//     %l64 = LOAD SEQ_CST <@i64> @g_i64
//     
//     %cxr_1 = CMPXCHG SEQ_CST UNORDERED <@refvoid> @g_r %void_r %void_r2
//     %cxr_2 = CMPXCHG SEQ_CST UNORDERED <@refvoid> @g_r %void_r %void_r3
//     
//     %lr   = LOAD <@refvoid>     @g_r
//     
//     STORE <@i64> @g_i64 1
//     
//     %rmw0 = ATOMICRMW SEQ_CST XCHG  <@i64> @g_i64 0x55ab  // 1 -> 0x55ab
//     %rmw1 = ATOMICRMW SEQ_CST ADD   <@i64> @g_i64 3       // 0x55ab -> 0x55ae 
//     %rmw2 = ATOMICRMW SEQ_CST SUB   <@i64> @g_i64 4       // 0x55ae -> 0x55aa
//     %rmw3 = ATOMICRMW SEQ_CST AND   <@i64> @g_i64 0x5a5a  // 0x55aa -> 0x500a
//     %rmw4 = ATOMICRMW SEQ_CST NAND  <@i64> @g_i64 0x5a5a  // 0x500a -> ~0x500a
//     %rmw5 = ATOMICRMW SEQ_CST OR    <@i64> @g_i64 0x5000  // ~0x500a -> ~0x000a
//     %rmw6 = ATOMICRMW SEQ_CST XOR   <@i64> @g_i64 0x55aa  // ~0x000a -> ~0x55a0 
//     %rmw7 = ATOMICRMW SEQ_CST MIN   <@i64> @g_i64 -0x7fffffffffffffde // ~0x55a0 -> -0x7fffffffffffffde
//     %rmw8 = ATOMICRMW SEQ_CST MAX   <@i64> @g_i64 42      // -0x7fffffffffffffde -> 42
//     %rmw9 = ATOMICRMW SEQ_CST UMIN  <@i64> @g_i64 11      // 42 -> 11
//     %rmwA = ATOMICRMW SEQ_CST UMAX  <@i64> @g_i64 0xffffffffffffffde // 11 -> 0xffffffffffffffde
//     
//     %l64_2 = LOAD SEQ_CST <@i64> @g_i64
// 
//     %trap = TRAP <@void> KEEPALIVE (%void_r %void_r2 %void_r3
//                 %cx32_1 %cx32_2 %cx64_1 %cx64_2 %l32 %l64 %cxr_1 %cxr_2 %lr
//                 %rmw0 %rmw1 %rmw2 %rmw3 %rmw4 %rmw5 %rmw6 %rmw7 %rmw8 %rmw9 %rmwA %l64_2)
// %exit:
//     COMMINST @uvm.thread_exit
// }
// 
// .funcsig @watchpointtest_sig = @noparamsnoret
// .funcdef @watchpointtest VERSION @watchpointtest_v1 <@watchpointtest_sig> () {
// %entry:
//     BRANCH %head
//     
// %head:
//     %wp = WATCHPOINT 42 <@i64> %dis %ena %enaexc KEEPALIVE ()
// 
// %dis:
//     %trapdis = TRAP <@void> %exit %exit KEEPALIVE ()
// 
// %ena:
//     %trapena = TRAP <@void> %exit %exit KEEPALIVE (%wp)
// 
// %enaexc:
//     %exc = LANDINGPAD
//     %trapena = TRAP <@void> %exit %exit KEEPALIVE (%exc)
// 
// %exit:
//     COMMINST @uvm.thread_exit
// }
// 
// .funcsig @testswapstack_sig = @noparamsnoret
// .funcdef @testswapstack VERSION @testswapstack_v1 <@testswapstack_sig> () {
// %entry:
//     %valueret = ALLOCA <@i64>
//     %shouldstop = ALLOCA <@i64> // initially zeroed
//     %thisstack = COMMINST @uvm.current_stack ()
//     
//     %iter = NEWSTACK <@itersig> @rangeiter (3 %thisstack %valueret %shouldstop)
//     COMMINST @uvm.swap_stack (%iter)
//     BRANCH %head
//     
// %head:
//     %value = LOAD <@i64> %valueret
//     %stop  = LOAD <@i64> %shouldstop
//     TRAP <@void> %head2 %head2 KEEPALIVE (%value %stop)
// 
// %head2:
//     %eq = EQ <@i64> %stop 0
//     BRANCH2 %eq %body %exit
// 
// %body:
//     COMMINST @uvm.swap_stack (%iter)
//     BRANCH %head
// 
// %exit:
//     COMMINST @uvm.thread_exit
// }
// 
// .typedef @irefi64 = iref<@i64>
// 
// .typedef @irefstack = iref<@stack>
// 
// .funcsig @itersig = @void (@i64 @stack @irefi64 @irefi64)
// 
// .funcsig @rangeiter_sig = @itersig
// .funcdef @rangeiter VERSION @rangeiter_v1 <@rangeiter_sig> (%n %src %valueret %shouldstop) {
// %entry:
//     BRANCH %head
// 
// %head:
//     %i = PHI <@i64> {
//         %entry: 0;
//         %body: %i2;
//         }
//     %lt = SLT <@i64> %i %n
//     BRANCH2 %lt %body %exit
//     
// %body:
//     STORE <@i64> %valueret %i
//     COMMINST @uvm.swap_stack (%src)
//     %i2 = ADD <@i64> %i 1
//     BRANCH %head
// 
// %exit:
//     STORE <@i64> %shouldstop 1
//     COMMINST @uvm.swap_and_kill (%src)
// }
// 
// .const @I64_100 <@i64> = 100
// .const @I64_50 <@i64> = 50
// .const @I64_0 <@i64> = 0
// .typedef @LongAry = hybrid <@void @i64>
// 
// .funcsig @testmultithreading_sig = @noparamsnoret
// .funcdef @testmultithreading VERSION @testmultithreading_v1 <@testmultithreading_sig> () {
// %entry:
//     %ary_r = NEWHYBRID <@LongAry> @I64_100
//     %ary_ir = GETIREF <@LongAry> %ary_r
//     %ary0_ir = GETVARPARTIREF <@LongAry> %ary_ir
//     BRANCH %head
// 
// %head:
//     %i = PHI <@i64> { %entry: 0; %body: %i2; }
//     %cmp = SLT <@i64> %i @I64_100
//     BRANCH2 %cmp %body %next
// 
// %body:
//     %aryi_ir = SHIFTIREF <@i64> %ary0_ir %i
//     STORE <@i64> %aryi_ir %i
//     %i2 = ADD <@i64> %i 1
//     BRANCH %head
//     
// %next:
//     %result0 = ALLOCA <@i64>
//     %sta0 = NEWSTACK <@summingslavesig> @summingslave (%ary0_ir @I64_50 %result0)
//     %result1 = ALLOCA <@i64>
//     %ary50_ir = SHIFTIREF <@i64> %ary0_ir @I64_50
//     %sta1 = NEWSTACK <@summingslavesig> @summingslave (%ary50_ir @I64_50 %result1)
//     
//     %thr0 = COMMINST @uvm.new_thread (%sta0)
//     %thr1 = COMMINST @uvm.new_thread (%sta1)
//     
//     BRANCH %wait0
// 
// %wait0:
//     %res0val = LOAD SEQ_CST <@i64> %result0
//     %cz0 = EQ <@i64> %res0val @I64_0
//     BRANCH2 %cz0 %wait0 %wait1
//     
// %wait1:
//     %res1val = LOAD SEQ_CST <@i64> %result1
//     %cz1 = EQ <@i64> %res1val @I64_0
//     BRANCH2 %cz1 %wait1 %getresult
//     
// %getresult:
//     %sum = ADD <@i64> %res0val %res1val
//     TRAP <@void> KEEPALIVE (%sum)
//     
// %exit:
//     COMMINST @uvm.thread_exit
// }
// 
// .funcsig @summingslavesig = @void (@irefi64 @i64 @irefi64)
// 
// .funcsig @summingslave_sig = @summingslavesig
// .funcdef @summingslave VERSION @summingslave_v1 <@summingslave_sig> (%ary %sz %result) {
// %entry:
//     BRANCH %head
//     
// %head:
//     %sum = PHI <@i64> { %entry: 0; %body: %sum2; }
//     %i = PHI <@i64> { %entry: 0; %body: %i2; }
//     %cmp = SLT <@i64> %i %sz
//     BRANCH2 %cmp %body %exit
// 
// %body:
//     %curptr = SHIFTIREF <@i64> %ary %i
//     %curnum = LOAD <@i64> %curptr
//     %sum2 = ADD <@i64> %sum %curnum
//     %i2 = ADD <@i64> %i 1
//     BRANCH %head
// 
// %exit:
//     STORE SEQ_CST <@i64> %result %sum
//     COMMINST @uvm.thread_exit
// }
// 
// .typedef @i6 = int<6>
// .typedef @i52 = int<52>
// 
// .const @I6_31 <@i6> = 31
// .const @I52_SAMPLE <@i52> = 0xfedcba9876543
// .const @D_42 <@double> = 42.0d
// 
// .funcsig @testtr64_sig = @noparamsnoret
// .funcdef @testtr64 VERSION @testtr64_v1 <@testtr64_sig> () {
//     %someobj = NEW <@i64>
//     %rv = REFCAST <@refi64 @refvoid> %someobj
// 
//     %f = COMMINST @uvm.tr64.from_fp  (@D_42)
//     %i = COMMINST @uvm.tr64.from_int (@I52_SAMPLE)
//     %r = COMMINST @uvm.tr64.from_ref (%rv @I6_31)
//     
//     %f_is_f = COMMINST @uvm.tr64.is_fp  (%f)
//     %f_is_i = COMMINST @uvm.tr64.is_int (%f)
//     %f_is_r = COMMINST @uvm.tr64.is_ref (%f)
//     %i_is_f = COMMINST @uvm.tr64.is_fp  (%i)
//     %i_is_i = COMMINST @uvm.tr64.is_int (%i)
//     %i_is_r = COMMINST @uvm.tr64.is_ref (%i)
//     %r_is_f = COMMINST @uvm.tr64.is_fp  (%r)
//     %r_is_i = COMMINST @uvm.tr64.is_int (%r)
//     %r_is_r = COMMINST @uvm.tr64.is_ref (%r)
//     
//     %fb = COMMINST @uvm.tr64.to_fp  (%f)
//     %ib = COMMINST @uvm.tr64.to_int (%i)
//     %rb = COMMINST @uvm.tr64.to_ref (%r)
//     %rt = COMMINST @uvm.tr64.to_tag (%r)
//     
//     TRAP <@void> KEEPALIVE (%rv %f %i %r %f_is_f %f_is_i %f_is_r
//             %i_is_f %i_is_i %i_is_r %r_is_f %r_is_i %r_is_r %fb %ib %rb %rt)
//             
// %exit:
//     COMMINST @uvm.thread_exit
// }
// 
// ///////////////////////// Simple sum
// 
// .funcsig @simplesum_sig = @void (@i64 @i64)
// .funcdef @simplesum VERSION @simplesum_v1 <@simplesum_sig> (%from %to) {
// %entry:
//     //BRANCH %head
//     %starttrap = TRAP <@void> %head %head KEEPALIVE ()
// 
// %head:
//     %sum = PHI <@i64> { %entry: 0; %body: %sum2; }
//     %i   = PHI <@i64> { %entry: %from; %body: %i2; }
//     %le  = SLE <@i64> %i %to
//     BRANCH2 %le %body %exit
//     
// %body:
//     %sum2 = ADD <@i64> %sum %i
//     %i2   = ADD <@i64> %i 1
//     BRANCH %head
//     //%montrap = TRAP <@void> %head %head KEEPALIVE (%from %to %sum %i %le %sum2 %i2)
// 
// %exit:
//     %exittrap = TRAP <@void> KEEPALIVE (%sum) // should stop thread
//     COMMINST @uvm.thread_exit
Kunshan Wang's avatar
Kunshan Wang committed
841
// }