instructions.uir 16 KB
Newer Older
Kunshan Wang's avatar
Kunshan Wang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
.typedef @i1  = int<1>
.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

.typedef @rv  = ref<@void>
.typedef @irv = iref<@void>
.typedef @wrv = weakref<@void>

.typedef @ri32 = ref<@i32>
.typedef @ri64 = ref<@i64>
.typedef @ii32 = iref<@i32>
.typedef @ii64 = iref<@i64>

.typedef @ii8 = iref<@i8>
.typedef @iii8 = iref<@ii8>

Kunshan Wang's avatar
Kunshan Wang committed
24
.funcsig @npnr_sig  = () -> ()
Kunshan Wang's avatar
Kunshan Wang committed
25
.typedef @npnr_func = funcref<@npnr_sig>
Kunshan Wang's avatar
Kunshan Wang committed
26

Kunshan Wang's avatar
Kunshan Wang committed
27
.funcsig @iii_sig  = (@i64 @i64) -> (@i64)
Kunshan Wang's avatar
Kunshan Wang committed
28
.typedef @iii_func = funcref<@iii_sig>
Kunshan Wang's avatar
Kunshan Wang committed
29

Kunshan Wang's avatar
Kunshan Wang committed
30 31
.typedef @thread    = threadref
.typedef @stack     = stackref
Kunshan Wang's avatar
Kunshan Wang committed
32 33 34
.typedef @tagref64  = tagref64

.typedef @4xfloat   = vector <@float 4>
Kunshan Wang's avatar
Kunshan Wang committed
35
.typedef @4xi32     = vector <@i32 4>
Kunshan Wang's avatar
Kunshan Wang committed
36 37
.typedef @2xdouble  = vector <@double 2>

Kunshan Wang's avatar
Kunshan Wang committed
38 39 40 41 42
.typedef @pv    = uptr<@void>
.typedef @pi32  = uptr<@i32>
.typedef @pi64  = uptr<@i64>
.typedef @npnr_fp = ufuncptr<@npnr_sig>
.typedef @iii_fp  = ufuncptr<@iii_sig>
43

Kunshan Wang's avatar
Kunshan Wang committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
.const @I8_0    <@i8>       = 0
.const @I16_0   <@i16>      = 0
.const @I32_0   <@i32>      = 0
.const @I64_0   <@i64>      = 0
.const @F_0     <@float>    = 0.0f
.const @D_0     <@float>    = 0.0d
.const @I8_1    <@i8>       = 1
.const @I16_1   <@i16>      = 1
.const @I32_1   <@i32>      = 1
.const @I64_1   <@i64>      = 1
.const @F_1     <@float>    = 1.0f
.const @D_1     <@float>    = 1.0d

.const @I32_2   <@i32>      = 2
.const @I64_2   <@i32>      = 2

.const @I64_42  <@i32>      = 42
.const @I64_43  <@i32>      = 43

.const @FALSE <@i1> = 0
.const @TRUE  <@i1> = 1

.const @NULLREF <@rv> = NULL

Kunshan Wang's avatar
Kunshan Wang committed
68
.funcsig @intBinOpTest.sig = (@i32 @i32) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
69 70
.funcdef @intBinOpTest VERSION %v1 <@intBinOpTest.sig> {
    %entry(<@i32> %p0 <@i32> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
71 72 73 74 75 76 77 78 79 80 81 82 83
        %add_r  = [%add ] ADD  <@i32> %p0 %p1
        %sub_r  = [%sub ] SUB  <@i32> %p0 %p1
        %mul_r  = [%mul ] MUL  <@i32> %p0 %p1
        %udiv_r = [%udiv] UDIV <@i32> %p0 %p1
        %sdiv_r = [%sdiv] SDIV <@i32> %p0 %p1
        %urem_r = [%urem] UREM <@i32> %p0 %p1
        %srem_r = [%srem] SREM <@i32> %p0 %p1
        %shl_r  = [%shl ] SHL  <@i32> %p0 %p1
        %lshr_r = [%lshr] LSHR <@i32> %p0 %p1
        %ashr_r = [%ashr] ASHR <@i32> %p0 %p1
        %and_r  = [%and ] AND  <@i32> %p0 %p1
        %or_r   = [%or  ] OR   <@i32> %p0 %p1
        %xor_r  = [%xor ] XOR  <@i32> %p0 %p1
Kunshan Wang's avatar
Kunshan Wang committed
84
        
Kunshan Wang's avatar
Kunshan Wang committed
85
        RET ()
86 87
}

Kunshan Wang's avatar
Kunshan Wang committed
88
.funcsig @fpBinOpTest.sig = (@double @double) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
89 90
.funcdef @fpBinOpTest VERSION %v1 <@fpBinOpTest.sig> {
    %entry(<@double> %p0 <@double> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
91 92 93 94 95
        %fadd_r = [%fadd] FADD <@double> %p0 %p1
        %fsub_r = [%fsub] FSUB <@double> %p0 %p1
        %fmul_r = [%fmul] FMUL <@double> %p0 %p1
        %fdiv_r = [%fdiv] FDIV <@double> %p0 %p1
        %frem_r = [%frem] FREM <@double> %p0 %p1
Kunshan Wang's avatar
Kunshan Wang committed
96
        
Kunshan Wang's avatar
Kunshan Wang committed
97
        RET ()
98 99
}

Kunshan Wang's avatar
Kunshan Wang committed
100
.funcsig @intCmpTest.sig = (@i64 @i64) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
101 102
.funcdef @intCmpTest VERSION %v1 <@intCmpTest.sig> {
    %entry(<@i64> %p0 <@i64> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
103 104 105 106 107 108 109 110 111 112
        %eq_r  = [%eq ] EQ  <@i64> %p0 %p1
        %ne_r  = [%ne ] NE  <@i64> %p0 %p1
        %ult_r = [%ult] ULT <@i64> %p0 %p1
        %ule_r = [%ule] ULE <@i64> %p0 %p1
        %ugt_r = [%ugt] UGT <@i64> %p0 %p1
        %uge_r = [%uge] UGE <@i64> %p0 %p1
        %slt_r = [%slt] SLT <@i64> %p0 %p1
        %sle_r = [%sle] SLE <@i64> %p0 %p1
        %sgt_r = [%sgt] SGT <@i64> %p0 %p1
        %sge_r = [%sge] SGE <@i64> %p0 %p1
Kunshan Wang's avatar
Kunshan Wang committed
113
        
Kunshan Wang's avatar
Kunshan Wang committed
114
        RET ()
115 116
}

Kunshan Wang's avatar
Kunshan Wang committed
117
.funcsig @fpCmpTest.sig = (@float @float) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
118 119
.funcdef @fpCmpTest VERSION %v1 <@fpCmpTest.sig> {
    %entry(<@float> %p0 <@float> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
        %ftrue_r  = [%ftrue ] FTRUE  <@float> %p0 %p1
        %ffalse_r = [%ffalse] FFALSE <@float> %p0 %p1
        %ford_r   = [%ford  ] FORD   <@float> %p0 %p1
        %foeq_r   = [%foeq  ] FOEQ   <@float> %p0 %p1
        %fone_r   = [%fone  ] FONE   <@float> %p0 %p1
        %folt_r   = [%folt  ] FOLT   <@float> %p0 %p1
        %fole_r   = [%fole  ] FOLE   <@float> %p0 %p1
        %fogt_r   = [%fogt  ] FOGT   <@float> %p0 %p1
        %foge_r   = [%foge  ] FOGE   <@float> %p0 %p1
        %funo_r   = [%funo  ] FUNO   <@float> %p0 %p1
        %fueq_r   = [%fueq  ] FUEQ   <@float> %p0 %p1
        %fune_r   = [%fune  ] FUNE   <@float> %p0 %p1
        %fult_r   = [%fult  ] FULT   <@float> %p0 %p1
        %fule_r   = [%fule  ] FULE   <@float> %p0 %p1
        %fugt_r   = [%fugt  ] FUGT   <@float> %p0 %p1
        %fuge_r   = [%fuge  ] FUGE   <@float> %p0 %p1
Kunshan Wang's avatar
Kunshan Wang committed
136
        
Kunshan Wang's avatar
Kunshan Wang committed
137
        RET ()
138 139
}

Kunshan Wang's avatar
Kunshan Wang committed
140
.funcsig @convTest.sig = (@i32 @i64 @float @double) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
141 142
.funcdef @convTest VERSION %v1 <@convTest.sig> {
    %entry(<@i32> %p0 <@i64> %p1 <@float> %p2 <@double> %p3):
Kunshan Wang's avatar
Kunshan Wang committed
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
        %trunc_r    = [%trunc   ] TRUNC <@i64 @i32> %p1
        %zext_r     = [%zext    ] ZEXT  <@i32 @i64> %p0
        %sext_r     = [%sext    ] SEXT  <@i32 @i64> %p0
                              
        %fptrunc_r  = [%fptrunc ] FPTRUNC <@double @float> %p3
        %fpext_r    = [%fpext   ] FPEXT   <@float @double> %p2
                              
        %fptoui_r   = [%fptoui  ] FPTOUI <@double @i64> %p3
        %fptosi_r   = [%fptosi  ] FPTOSI <@double @i64> %p3
        %uitofp_r   = [%uitofp  ] UITOFP <@i64 @double> %p1
        %sitofp_r   = [%sitofp  ] SITOFP <@i64 @double> %p1
                              
        %bitcast0_r = [%bitcast0] BITCAST <@i32 @float>  %p0
        %bitcast1_r = [%bitcast1] BITCAST <@i64 @double> %p1
        %bitcast2_r = [%bitcast2] BITCAST <@float @i32>  %p2
        %bitcast3_r = [%bitcast3] BITCAST <@double @i64> %p3

        RET ()
161 162
}

Kunshan Wang's avatar
Kunshan Wang committed
163
.funcsig @refCastTest.sig = (@rv @irv @npnr_func) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
164 165
.funcdef @refCastTest VERSION %v1 <@refCastTest.sig> {
    %entry(<@rv> %p0 <@irv> %p1 <@npnr_func> %p2):
Kunshan Wang's avatar
Kunshan Wang committed
166 167 168
        %refcast_r  = [%refcast ] REFCAST <@rv @ri32> %p0
        %irefcast_r = [%irefcast] REFCAST <@irv @ii64> %p1
        %funccast_r = [%funccast] REFCAST <@npnr_func @iii_func> %p2
Kunshan Wang's avatar
Kunshan Wang committed
169
        
Kunshan Wang's avatar
Kunshan Wang committed
170
        RET ()
171 172
}

Kunshan Wang's avatar
Kunshan Wang committed
173
.funcsig @ptrCastTest.sig = (@i64) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
174 175
.funcdef @ptrCastTest VERSION %v1 <@ptrCastTest.sig> {
    %entry(<@i64> %p0):
Kunshan Wang's avatar
Kunshan Wang committed
176
        %ptrcast_r = [%ptrcast] PTRCAST <@i64 @pi64> %p0
177
        
Kunshan Wang's avatar
Kunshan Wang committed
178
        RET ()
179 180
}

Kunshan Wang's avatar
Kunshan Wang committed
181
.funcsig @select.sig = () -> ()
Kunshan Wang's avatar
Kunshan Wang committed
182 183
.funcdef @select VERSION %v1 <@select.sig> {
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
184
        %select_r  = [%select] SELECT <@i1 @i32> @TRUE @I32_0 @I32_1
185

Kunshan Wang's avatar
Kunshan Wang committed
186
        RET ()
187 188
}

Kunshan Wang's avatar
Kunshan Wang committed
189
.funcsig @ctrlFlow.sig = (@i32) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
190 191
.funcdef @ctrlFlow VERSION %v1 <@ctrlFlow.sig> {
    %entry(<@i32> %p0):
Kunshan Wang's avatar
Kunshan Wang committed
192
                [%br1] BRANCH %head(%p0)
193
    
Kunshan Wang's avatar
Kunshan Wang committed
194
    %head(<@i32> %x):
Kunshan Wang's avatar
Kunshan Wang committed
195 196
        %zero = [%eq]  EQ <@i32> %x @I32_0
                [%br2] BRANCH2 %zero %body(%x) %exit()
197
        
Kunshan Wang's avatar
Kunshan Wang committed
198
    %body(<@i32> %x):
Kunshan Wang's avatar
Kunshan Wang committed
199
                [%switch] SWITCH <@i32> %x %other(%x) { @I32_1 %one(%x) @I32_2 %two(%x) }
Kunshan Wang's avatar
Kunshan Wang committed
200
    %one(<@i32> %x):
Kunshan Wang's avatar
Kunshan Wang committed
201
                [%br3] BRANCH %next(%x)
Kunshan Wang's avatar
Kunshan Wang committed
202
    %two(<@i32> %x):
Kunshan Wang's avatar
Kunshan Wang committed
203
                [%br4] BRANCH %next(%x)
Kunshan Wang's avatar
Kunshan Wang committed
204
    %other(<@i32> %x):
Kunshan Wang's avatar
Kunshan Wang committed
205
                [%br5] BRANCH %next(%x)
Kunshan Wang's avatar
Kunshan Wang committed
206
    %next(<@i32> %x):
Kunshan Wang's avatar
Kunshan Wang committed
207 208
        %i2 =   [%sub] SUB <@i32> %x @I32_1
                [%br6] BRANCH %head(%i2)
209
        
Kunshan Wang's avatar
Kunshan Wang committed
210
    %exit():
Kunshan Wang's avatar
Kunshan Wang committed
211
                RET ()
212 213
}

Kunshan Wang's avatar
Kunshan Wang committed
214
.funcdecl @callee1 <@npnr_sig>
215

Kunshan Wang's avatar
Kunshan Wang committed
216 217
.funcdef @callee2 VERSION %v1 <@iii_sig> {
    %entry(<@i64> %p0 <@i64> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
218
        %rv = ADD <@i64> %p0 %p1
Kunshan Wang's avatar
Kunshan Wang committed
219
        [%ret] RET %rv
220 221
}

Kunshan Wang's avatar
Kunshan Wang committed
222 223
.funcdef @callee3 VERSION %v1 <@iii_sig> {
    %entry(<@i64> %p0 <@i64> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
224
        %exc = NEW <@double>
Kunshan Wang's avatar
Kunshan Wang committed
225
        [%throw] THROW %exc
226 227
}

Kunshan Wang's avatar
Kunshan Wang committed
228 229
.funcdef @caller1 VERSION %v1 <@npnr_sig> {
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
230 231 232
        %v1 = [%call1] CALL <@npnr_sig> @callee1 ()
        %v2 = [%call2] CALL <@iii_sig> @callee2 (@I64_1 @I64_2)
        %v3 = [%call3] CALL <@iii_sig> @callee3 (@I64_1 @I64_2) EXC(%cont(%v2 %v3) %catch())
233

Kunshan Wang's avatar
Kunshan Wang committed
234
    %cont(<@i64> %v2 <@i64> %v3):
Kunshan Wang's avatar
Kunshan Wang committed
235 236
        %v4 = [%call4] CALL <@npnr_sig> @callee1 () KEEPALIVE(%v2 %v3)
        %v5 = [%call5] CALL <@iii_sig> @callee3 (%v3 %v3) EXC(%cont2() %catch()) KEEPALIVE(%v2)
237

Kunshan Wang's avatar
Kunshan Wang committed
238
    %cont2():
Kunshan Wang's avatar
Kunshan Wang committed
239
        [%retv] RET ()
240

Kunshan Wang's avatar
Kunshan Wang committed
241
    %catch() [%exc]:
Kunshan Wang's avatar
Kunshan Wang committed
242
        RET ()
243 244
}

Kunshan Wang's avatar
Kunshan Wang committed
245 246
.funcdef @caller2 VERSION %v1 <@iii_sig> {
    %entry(<@i64> %p0 <@i64> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
247
        [%tc] TAILCALL <@iii_sig> @callee2 (%p0 %p1)
248 249
}

Kunshan Wang's avatar
Kunshan Wang committed
250 251 252 253 254 255 256 257 258 259 260 261 262
.typedef @sid = struct <@i64 @double>
.typedef @rsid = ref<@sid>
.const @sid1 <@sid> = {@I64_1 @D_1}

.const @v1 <@4xfloat> = {@F_0 @F_0 @F_0 @F_0}
.const @v2 <@4xfloat> = {@F_1 @F_1 @F_1 @F_1}

.const @I32_4 <@i32> = 4
.const @I32_6 <@i32> = 6
.const @vshf <@4xi32> = {@I32_0 @I32_2 @I32_4 @I32_6}

.funcdef @aggregate VERSION %v1 <@npnr_sig> {
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
263 264 265 266 267 268 269
        %e0_r  = [%e0 ] EXTRACTVALUE <@sid 0> @sid1
        %e1_r  = [%e1 ] EXTRACTVALUE <@sid 1> @sid1
        %i0_r  = [%i0 ] INSERTVALUE  <@sid 0> @sid1 @I64_0
        %i1_r  = [%i1 ] INSERTVALUE  <@sid 1> @sid1 @D_0
        %ee0_r = [%ee0] EXTRACTELEMENT <@4xfloat @i32> @v1 @I32_0
        %ie0_r = [%ie0] INSERTELEMENT  <@4xfloat @i32> @v1 @I32_1 @F_1
        %sv0_r = [%sv0] SHUFFLEVECTOR  <@4xfloat @4xi32> @v1 @v2 @vshf
Kunshan Wang's avatar
Kunshan Wang committed
270
    
Kunshan Wang's avatar
Kunshan Wang committed
271
        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
272 273 274 275 276 277 278 279 280 281
}

.typedef @al = array <@i64 10>
.typedef @ral = ref<@al>
.typedef @hic = hybrid <@i64 @i8>
.typedef @rhic = ref<@hic>

.typedef @irefi64 = iref<@i64>
.typedef @irhic = iref<@hic>

Kunshan Wang's avatar
Kunshan Wang committed
282 283 284
.global @i64loc <@i64>

.funcsig @memops.sig = () -> ()
Kunshan Wang's avatar
Kunshan Wang committed
285
.funcdef @memops VERSION %v1 <@memops.sig> {
Kunshan Wang's avatar
Kunshan Wang committed
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
    %entry():
        %r1  = [%new         ] NEW <@i64>
        %r2  = [%newhybrid   ] NEWHYBRID <@hic @i64> @I64_43
        %r3  = [%alloca      ] ALLOCA <@i64>

        %r5 = [%new_s       ] NEW <@i64> EXC(%bb2() %handler())
    %bb2():
        %r6 = [%newhybrid_s ] NEWHYBRID <@hic @i64> @I64_43 EXC(%bb3() %handler())
    %bb3():
        %r7 = [%alloca_s    ] ALLOCA <@i64 > EXC(%bb4() %handler())
    %bb4():
        %r8 = [%allocahybrid_s] ALLOCAHYBRID <@hic @i64> @I64_43 EXC(%bb5() %handler())
    %bb5():

        %r9  = [%new2          ] NEW <@sid>
        %r10 = [%alloca2       ] ALLOCA <@al>

        %r11 = [%getiref       ] GETIREF <@sid> %r9

        %r12 = [%getfieldiref  ] GETFIELDIREF <@sid 0> %r11
        %r13 = [%getelemiref   ] GETELEMIREF <@al @i64> %r10 @I64_1

        %r4  = [%allocahybrid] ALLOCAHYBRID <@hic @i64> @I64_43

        %r14 = [%getvarpartiref] GETVARPARTIREF <@hic> %r4

        %r15 = [%shiftiref     ] SHIFTIREF <@i8 @i64> %r14 @I64_1
Kunshan Wang's avatar
Kunshan Wang committed
313
        
Kunshan Wang's avatar
Kunshan Wang committed
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
        %r16 = [%load     ] LOAD  <@i64> @i64loc
        [%store    ] STORE <@i64> @i64loc @I64_42

        (%r18_0 %r18_1) = [%cmpxchg  ] CMPXCHG SEQ_CST SEQ_CST <@i64> @i64loc @I64_42 @I64_0
        (%r19_0 %r19_1) = [%cmpxchg_w] CMPXCHG WEAK SEQ_CST SEQ_CST <@i64> @i64loc @I64_42 @I64_0

        %r20 = [%atomicrmw] ATOMICRMW SEQ_CST ADD <@i64> @i64loc @I64_43
                                        
        %r21 = [%load_s]    LOAD  <@i64> @i64loc EXC(%bb6() %handler())
    %bb6():
        [%store_s]   STORE <@i64> @i64loc @I64_42 EXC(%bb7() %handler())
    %bb7():
        (%r23_0 %r23_1) = [%cmpxchg_s] CMPXCHG SEQ_CST SEQ_CST <@i64> @i64loc @I64_42 @I64_0 EXC(%bb8() %handler())
    %bb8():
        %r24 = [%atomicrmw_s] ATOMICRMW SEQ_CST ADD <@i64> @i64loc @I64_43 EXC(%bb9() %handler())
Kunshan Wang's avatar
Kunshan Wang committed
329 330

    %bb9():
Kunshan Wang's avatar
Kunshan Wang committed
331
        [%fence] FENCE SEQ_CST
Kunshan Wang's avatar
Kunshan Wang committed
332
        
Kunshan Wang's avatar
Kunshan Wang committed
333
        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
334 335

    %handler() [%exc]:
Kunshan Wang's avatar
Kunshan Wang committed
336
        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
337 338
}

Kunshan Wang's avatar
Kunshan Wang committed
339
.funcsig @memops_ptr.sig = (@i64 @i64) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
340 341
.funcdef @memops_ptr VERSION %v1 <@memops_ptr.sig> {
    %entry(<@i64> %p0 <@i64> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
        %o  = [%new           ] NEW <@i64>
        %oh = [%newhybrid     ] NEWHYBRID <@hic @i64> %p0
        %o2 = [%new2          ] NEW <@sid>
        %o3 = [%new3          ] NEW <@al>
                                          
        %p  = [%pin           ] COMMINST @uvm.native.pin <@ri64> (%o )
        %ph = [%pinh          ] COMMINST @uvm.native.pin <@rhic> (%oh)
        %p2 = [%pin2          ] COMMINST @uvm.native.pin <@rsid> (%o2)
        %p3 = [%pin3          ] COMMINST @uvm.native.pin <@ral>  (%o3)
                           
        %pf = [%getfieldiref  ] GETFIELDIREF PTR <@sid 0>   %p2
        %pe = [%getelemiref   ] GETELEMIREF  PTR <@al @i64> %p3 %p1
                           
        %pv = [%getvarpartiref] GETVARPARTIREF   PTR <@hic> %ph
                           
        %ps = [%shiftiref     ] SHIFTIREF PTR <@i8 @i64> %pv %p1
Kunshan Wang's avatar
Kunshan Wang committed
358
        
Kunshan Wang's avatar
Kunshan Wang committed
359 360 361 362
        %rl =       [%load     ] LOAD  PTR <@i64> %p
                    [%store    ] STORE PTR <@i64> %p @I64_42
        (%c1 %c2) = [%cmpxchg  ] CMPXCHG PTR SEQ_CST SEQ_CST <@i64> %p @I64_42 @I64_0
        %ar =       [%atomicrmw] ATOMICRMW PTR SEQ_CST ADD <@i64> %p @I64_43
Kunshan Wang's avatar
Kunshan Wang committed
363
        
Kunshan Wang's avatar
Kunshan Wang committed
364
        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
365 366 367
}


Kunshan Wang's avatar
Kunshan Wang committed
368
.funcsig @memorder.sig = (@ii64) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
369 370
.funcdef @memorder VERSION %v1 <@memorder.sig> {
    %entry(<@ii64> %p0):
Kunshan Wang's avatar
Kunshan Wang committed
371 372 373 374 375 376 377 378 379
        %r1 = [%l0] LOAD NOT_ATOMIC   <@i64> %p0
        %r2 = [%l1] LOAD RELAXED      <@i64> %p0
        %r3 = [%l2] LOAD CONSUME      <@i64> %p0
        %r4 = [%l3] LOAD ACQUIRE      <@i64> %p0
              [%s4] STORE RELEASE     <@i64> %p0 @I64_42
        (%r5_0 %r5_1) = [%c5] CMPXCHG ACQ_REL ACQUIRE   <@i64> %p0 @I64_42 @I64_43
        %r6 = [%l6] LOAD SEQ_CST      <@i64> %p0

        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
380 381
}

Kunshan Wang's avatar
Kunshan Wang committed
382
.funcsig @atomicrmwops.sig = (@ii64 @i64) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
383 384
.funcdef @atomicrmwops VERSION %v1 <@atomicrmwops.sig> {
    %entry(<@ii64> %p0 <@i64> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
385 386 387 388 389 390 391 392 393 394 395 396 397
        %old0 = [%rmw0] ATOMICRMW ACQ_REL XCHG  <@i64> %p0 %p1
        %old1 = [%rmw1] ATOMICRMW ACQ_REL ADD   <@i64> %p0 %p1
        %old2 = [%rmw2] ATOMICRMW ACQ_REL SUB   <@i64> %p0 %p1
        %old3 = [%rmw3] ATOMICRMW ACQ_REL AND   <@i64> %p0 %p1
        %old4 = [%rmw4] ATOMICRMW ACQ_REL NAND  <@i64> %p0 %p1
        %old5 = [%rmw5] ATOMICRMW ACQ_REL OR    <@i64> %p0 %p1
        %old6 = [%rmw6] ATOMICRMW ACQ_REL XOR   <@i64> %p0 %p1
        %old7 = [%rmw7] ATOMICRMW ACQ_REL MAX   <@i64> %p0 %p1
        %old8 = [%rmw8] ATOMICRMW ACQ_REL MIN   <@i64> %p0 %p1
        %old9 = [%rmw9] ATOMICRMW ACQ_REL UMAX  <@i64> %p0 %p1
        %olda = [%rmwa] ATOMICRMW ACQ_REL UMIN  <@i64> %p0 %p1

        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
398 399 400 401 402 403 404 405
}

.funcdef @traps VERSION %v1 <@npnr_sig> {
    %entry():
        %a  = ADD <@i64> @I64_42 @I64_43
        %b  = SUB <@i64> @I64_42 @I64_43
        %c  = MUL <@i64> @I64_42 @I64_43

Kunshan Wang's avatar
Kunshan Wang committed
406 407 408
        %r1         = [%t ] TRAP <@i32> KEEPALIVE(%a)
        ()          = [%t0] TRAP <>
        (%r2 %r3)   = [%ts] TRAP <@i64 @float> EXC(%tp_s_cont(%a %b) %tp_s_exc()) KEEPALIVE(%b)
Kunshan Wang's avatar
Kunshan Wang committed
409 410

    %tp_s_cont(<@i64> %a <@i64> %b):
Kunshan Wang's avatar
Kunshan Wang committed
411
                      [%wp] WATCHPOINT 1 <> %wp_dis_cont(%b) %wp_ena_cont() KEEPALIVE(%a)
Kunshan Wang's avatar
Kunshan Wang committed
412 413
    
    %wp_dis_cont(<@i64> %b):
Kunshan Wang's avatar
Kunshan Wang committed
414
        %r4         = [%wp_s] WATCHPOINT 2 <@double> %wp_s_dis_cont() %wp_s_ena_cont() WPEXC(%wp_s_exc()) KEEPALIVE(%b)
Kunshan Wang's avatar
Kunshan Wang committed
415 416

    %wp_ena_cont():
Kunshan Wang's avatar
Kunshan Wang committed
417
        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
418 419

    %wp_s_dis_cont():
Kunshan Wang's avatar
Kunshan Wang committed
420 421 422 423 424 425 426
        [%wpbr] WPBRANCH 3 %wpbr_t() %wpbr_f()        
        
    %wpbr_t():
        RET ()

    %wpbr_f():
        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
427 428

    %wp_s_ena_cont():
Kunshan Wang's avatar
Kunshan Wang committed
429
        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
430 431 432 433 434 435 436 437
    
    %tp_s_exc() [%exc]:
        THROW %exc
        
    %wp_s_exc() [%exc]:
        THROW %exc
}

Kunshan Wang's avatar
Kunshan Wang committed
438
.funcsig @ccall_callee_sig = (@double) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
439 440
.typedef @ccall_callee_fp = ufuncptr<@ccall_callee_sig>

Kunshan Wang's avatar
Kunshan Wang committed
441
.funcsig @ccall.sig = (@ccall_callee_fp) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
442 443
.funcdef @ccall VERSION %v1 <@ccall.sig> {
    %entry(<@ccall_callee_fp> %p0):
Kunshan Wang's avatar
Kunshan Wang committed
444
        %rv = [%ccall] CCALL #DEFAULT <@ccall_callee_fp @ccall_callee_sig> %p0 (@D_1)
Kunshan Wang's avatar
Kunshan Wang committed
445
        
Kunshan Wang's avatar
Kunshan Wang committed
446
        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
447 448
}

Kunshan Wang's avatar
Kunshan Wang committed
449
.funcsig @gen.sig = (@stack) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
450 451
.funcdef @gen VERSION %v1 <@npnr_sig> {
    %entry(<@stack> %main):
Kunshan Wang's avatar
Kunshan Wang committed
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
        [%ss1] SWAPSTACK %main RET_WITH <> PASS_VALUES <@i64> (@I64_0)
        [%ss2] SWAPSTACK %main KILL_OLD THROW_EXC @NULLREF
}

.funcdef @newthread VERSION %v1 <@npnr_sig> {
    %entry():
        %s1 = COMMINST @uvm.new_stack <[@iii_sig]> (@callee2)
        %t1 = [%nt1] NEWTHREAD %s1 PASS_VALUES <@i64 @i64> (@I64_0 @I64_1)

        %s2 = COMMINST @uvm.new_stack <[@iii_sig]> (@callee2)
        %t2 = [%nt2] NEWTHREAD %s2 THROW_EXC @NULLREF EXC(%nor() %exc())

    %nor():
        RET ()

    %exc() [%e]:
        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
469 470 471 472 473
}

.funcdef @swapstack VERSION %v1 <@npnr_sig> {
    %entry():
        %curstack = COMMINST @uvm.current_stack
Kunshan Wang's avatar
Kunshan Wang committed
474 475 476 477
        %coro = COMMINST @uvm.new_stack <[@iii_sig]> (@gen)

        %r1 = [%ss1] SWAPSTACK %coro RET_WITH <@i64> PASS_VALUES <> () KEEPALIVE(%curstack)
        %r2 = [%ss2] SWAPSTACK %coro RET_WITH <@i64> PASS_VALUES <> () EXC(%nor() %exc())
Kunshan Wang's avatar
Kunshan Wang committed
478 479

    %nor():
Kunshan Wang's avatar
Kunshan Wang committed
480
        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
481
    %exc() [%exc]:
Kunshan Wang's avatar
Kunshan Wang committed
482
        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
483 484 485 486
}

.funcdef @comminst VERSION %v1 <@npnr_sig> {
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
487 488 489
        %curstack = [%ci1] COMMINST @uvm.current_stack
        %sta = [%ci2] COMMINST @uvm.new_stack <[@iii_sig]> (@callee2)
        %thr = NEWTHREAD %sta PASS_VALUES <@stack> (%sta)
Kunshan Wang's avatar
Kunshan Wang committed
490

Kunshan Wang's avatar
Kunshan Wang committed
491
        %ex = [%ci3] COMMINST @uvm.native.expose [#DEFAULT] <[@npnr_sig]> (@swapstack)
Kunshan Wang's avatar
Kunshan Wang committed
492

Kunshan Wang's avatar
Kunshan Wang committed
493 494
        [%ci4] COMMINST @uvm.thread_exit
        RET ()
Kunshan Wang's avatar
Kunshan Wang committed
495
}