GitLab will continue to be upgraded from 11.4.5-ce.0 on November 25th 2019 at 4.00pm (AEDT) to 5.00pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available.

basic-tests.uir 33.1 KB
Newer Older
Kunshan Wang's avatar
Kunshan Wang committed
1 2 3 4
// require "primitives.uir"

.funcsig @binops32_sig = (@i32 @i32) -> ()
.funcdef @binops32 VERSION %v1 <@binops32_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
5
    %entry(<@i32> %p0 <@i32> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19
        %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
        
Kunshan Wang's avatar
Kunshan Wang committed
20
        [%trap] TRAP <> KEEPALIVE (
Kunshan Wang's avatar
Kunshan Wang committed
21 22 23 24 25
            %add %sub %mul %udiv %sdiv %urem %srem
            %shl %lshr %ashr %and %or %xor
            )
            
        COMMINST @uvm.thread_exit
26 27
}

Kunshan Wang's avatar
Kunshan Wang committed
28 29
.funcsig @binops64_sig = (@i64 @i64) -> ()
.funcdef @binops64 VERSION %v1 <@binops64_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
30
    %entry(<@i64> %p0 <@i64> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
31 32 33 34 35 36 37 38 39 40 41 42 43
        %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
44
        
Kunshan Wang's avatar
Kunshan Wang committed
45
        [%trap] TRAP <> KEEPALIVE (
Kunshan Wang's avatar
Kunshan Wang committed
46 47 48 49 50
            %add %sub %mul %udiv %sdiv %urem %srem
            %shl %lshr %ashr %and %or %xor
            )
             
        COMMINST @uvm.thread_exit
51 52
}

Kunshan Wang's avatar
Kunshan Wang committed
53 54
.funcsig @binops64_div0_sig = (@i64 @i64 @i64 @i64 @i64) -> ()
.funcdef @binops64_div0 VERSION %v1 <@binops64_div0_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
55 56 57 58 59 60 61 62 63 64
    %entry(<@i64> %p0 <@i64> %p1 <@i64> %p2 <@i64> %p3 <@i64> %p4):
        %udiv = UDIV <@i64> %p0 %p1 EXC(%bb2(%p0 %p1 %p2 %p3 %p4) %exc())
    %bb2(<@i64> %p0 <@i64> %p1 <@i64> %p2 <@i64> %p3 <@i64> %p4):
        %sdiv = SDIV <@i64> %p0 %p2 EXC(%bb3(%p0 %p1 %p2 %p3 %p4) %exc())
    %bb3(<@i64> %p0 <@i64> %p1 <@i64> %p2 <@i64> %p3 <@i64> %p4):
        %urem = UREM <@i64> %p0 %p3 EXC(%bb4(%p0 %p1 %p2 %p3 %p4) %exc())
    %bb4(<@i64> %p0 <@i64> %p1 <@i64> %p2 <@i64> %p3 <@i64> %p4):
        %srem = SREM <@i64> %p0 %p4 EXC(%nor() %exc())

    %nor():
Kunshan Wang's avatar
Kunshan Wang committed
65
        [%trapnor] TRAP <>
66 67
        COMMINST @uvm.thread_exit

Kunshan Wang's avatar
Kunshan Wang committed
68
    %exc():
Kunshan Wang's avatar
Kunshan Wang committed
69
        [%trapexc] TRAP <>
Kunshan Wang's avatar
Kunshan Wang committed
70
        COMMINST @uvm.thread_exit
71 72
}

Kunshan Wang's avatar
Kunshan Wang committed
73 74
.funcsig @binops_f_sig = (@float @float) -> ()
.funcdef @binops_f VERSION %v1 <@binops_f_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
75
    %entry(<@float> %p0 <@float> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
76 77 78 79 80 81
        %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
        
Kunshan Wang's avatar
Kunshan Wang committed
82
        [%trap] TRAP <> KEEPALIVE (
Kunshan Wang's avatar
Kunshan Wang committed
83 84 85
            %fadd %fsub %fmul %fdiv %frem
            )
        COMMINST @uvm.thread_exit
86 87
}

Kunshan Wang's avatar
Kunshan Wang committed
88 89
.funcsig @binops_d_sig = (@double @double) -> ()
.funcdef @binops_d VERSION %v1 <@binops_d_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
90
    %entry(<@double> %p0 <@double> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
91 92 93 94 95 96
        %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
        
Kunshan Wang's avatar
Kunshan Wang committed
97
        [%trap] TRAP <> KEEPALIVE (
Kunshan Wang's avatar
Kunshan Wang committed
98 99 100
            %fadd %fsub %fmul %fdiv %frem
            )
        COMMINST @uvm.thread_exit
101 102
}

Kunshan Wang's avatar
Kunshan Wang committed
103 104
.funcsig @binops_vec_sig = (@4xi32 @4xi32 @4xfloat @4xfloat @2xdouble @2xdouble) -> ()
.funcdef @binops_vec VERSION %v1 <@binops_vec_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
105
    %entry(<@4xi32> %p0 <@4xi32> %p1 <@4xfloat> %p2 <@4xfloat> %p3 <@2xdouble> %p4 <@2xdouble> %p5):
Kunshan Wang's avatar
Kunshan Wang committed
106 107 108 109 110 111 112
        %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

Kunshan Wang's avatar
Kunshan Wang committed
113
        [%trap] TRAP <> KEEPALIVE (
Kunshan Wang's avatar
Kunshan Wang committed
114 115 116 117 118 119
            %addi %subi %addf %subf %addd %subd
            )
        COMMINST @uvm.thread_exit

}

Kunshan Wang's avatar
Kunshan Wang committed
120 121
.funcsig @cmp64_sig = (@i64 @i64) -> ()
.funcdef @cmp64 VERSION %v1 <@cmp64_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
122
    %entry(<@i64> %p0 <@i64> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
123 124 125 126 127 128 129 130 131 132 133
        %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
        
Kunshan Wang's avatar
Kunshan Wang committed
134
        [%trap] TRAP <> KEEPALIVE (
Kunshan Wang's avatar
Kunshan Wang committed
135
            %eq %ne %ult %ule %ugt %uge %slt %sle %sgt %sge
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
            )
        COMMINST @uvm.thread_exit
}

.funcsig @cmpptr_sig = (@ptri64 @ptri64) -> ()
.funcdef @cmpptr VERSION %v1 <@cmpptr_sig> {
    %entry(<@ptri64> %p0 <@ptri64> %p1):
        %eq  = EQ  <@ptri64> %p0 %p1
        %ne  = NE  <@ptri64> %p0 %p1
        %ult = ULT <@ptri64> %p0 %p1
        %ule = ULE <@ptri64> %p0 %p1
        %ugt = UGT <@ptri64> %p0 %p1
        %uge = UGE <@ptri64> %p0 %p1
        %slt = SLT <@ptri64> %p0 %p1
        %sle = SLE <@ptri64> %p0 %p1
        %sgt = SGT <@ptri64> %p0 %p1
        %sge = SGE <@ptri64> %p0 %p1
        
        [%trap] TRAP <> KEEPALIVE (
            %eq %ne %ult %ule %ugt %uge %slt %sle %sgt %sge
Kunshan Wang's avatar
Kunshan Wang committed
156 157
            )
        COMMINST @uvm.thread_exit
158 159
}

Kunshan Wang's avatar
Kunshan Wang committed
160 161
.funcsig @cmp_f_sig = (@float @float) -> ()
.funcdef @cmp_f VERSION %v1 <@cmp_f_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
162
    %entry(<@float> %p0 <@float> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
        %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
    
Kunshan Wang's avatar
Kunshan Wang committed
180
        [%trap] TRAP <> KEEPALIVE (
Kunshan Wang's avatar
Kunshan Wang committed
181 182 183 184
            %ftrue %ffalse %ford %foeq %fone %folt %fole %fogt %foge
            %funo %fueq %fune %fult %fule %fugt %fuge
            )
        COMMINST @uvm.thread_exit
185 186
}

Kunshan Wang's avatar
Kunshan Wang committed
187 188
.funcsig @cmp_d_sig = (@double @double) -> ()
.funcdef @cmp_d VERSION %v1 <@cmp_d_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
189
    %entry(<@double> %p0 <@double> %p1):
Kunshan Wang's avatar
Kunshan Wang committed
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
        %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
    
Kunshan Wang's avatar
Kunshan Wang committed
207
        [%trap] TRAP <> KEEPALIVE (
Kunshan Wang's avatar
Kunshan Wang committed
208 209 210
            %ftrue %ffalse %ford %foeq %fone %folt %fole %fogt %foge
            %funo %fueq %fune %fult %fule %fugt %fuge
            )
211 212 213
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
214 215
.funcsig @cmp_vec_sig = (@4xi32 @4xi32 @4xfloat @4xfloat @2xdouble @2xdouble) -> ()
.funcdef @cmp_vec VERSION %v1 <@cmp_vec_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
216
    %entry(<@4xi32> %p0 <@4xi32> %p1 <@4xfloat> %p2 <@4xfloat> %p3 <@2xdouble> %p4 <@2xdouble> %p5):
217 218 219 220 221 222 223
        %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

Kunshan Wang's avatar
Kunshan Wang committed
224
        [%trap] TRAP <> KEEPALIVE (
225 226
            %eq %slt %foeqf %fultf %foeqd %fultd
            )
Kunshan Wang's avatar
Kunshan Wang committed
227 228
        COMMINST @uvm.thread_exit
}
229

230 231 232
.global @dummy_global1 <@i64>
.global @dummy_global2 <@i64>

Kunshan Wang's avatar
Kunshan Wang committed
233 234
.funcdecl @dummy_func1 <@v_v>
.funcdef @dummy_func2 VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
235
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
236
        RET ()
237 238
}

Kunshan Wang's avatar
Kunshan Wang committed
239 240
.funcsig @cmp_ref_sig = (@refi64 @refi64 @irefi64 @irefi64 @frv_v @frv_v @stack @stack) -> ()
.funcdef @cmp_ref VERSION %v1 <@cmp_ref_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
241
    %entry(<@refi64> %p0 <@refi64> %p1 <@irefi64> %p2 <@irefi64> %p3
Kunshan Wang's avatar
Kunshan Wang committed
242
           <@frv_v> %p4 <@frv_v> %p5 <@stack> %p6 <@stack> %p7):
243 244 245 246
        %req     = EQ   <@refi64>   %p0 %p1
        %rne     = NE   <@refi64>   %p0 %p1
        %ieq     = EQ   <@irefi64>  %p2 %p3
        %ine     = NE   <@irefi64>  %p2 %p3
Kunshan Wang's avatar
Kunshan Wang committed
247 248
        %feq     = EQ   <@frv_v>    %p4 %p5
        %fne     = NE   <@frv_v>    %p4 %p5
249 250 251
        %seq     = EQ   <@stack>    %p6 %p7
        %sne     = NE   <@stack>    %p6 %p7

Kunshan Wang's avatar
Kunshan Wang committed
252
        [%trap] TRAP <> KEEPALIVE (
253 254 255 256 257
            %req %rne %ieq %ine %feq %fne %seq %sne
            )
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
258 259
.funcsig @conv_sig = (@i32 @i64 @float @double) -> ()
.funcdef @conv VERSION %v1 <@conv_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
260
    %entry(<@i32> %p0 <@i64> %p1 <@float> %p2 <@double> %p3):
Kunshan Wang's avatar
Kunshan Wang committed
261 262 263 264 265 266 267
        %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
        
268 269 270 271
        %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
272 273 274
        %uitofp  = UITOFP  <@i64 @double> %p1
        %sitofp  = SITOFP  <@i64 @double> %p1
        
275 276 277 278
        %bitcast1 = BITCAST <@float  @i32> %p2
        %bitcast2 = BITCAST <@double @i64> %p3
        %bitcast3 = BITCAST <@i32 @float > %bitcast1
        %bitcast4 = BITCAST <@i64 @double> %bitcast2
279 280 281 282

        %ptrcast1 = PTRCAST <@i64 @ptrvoid> %p1
        %ptrcast2 = PTRCAST <@ptrvoid @fpi_i> %ptrcast1
        %ptrcast3 = PTRCAST <@fpi_i @i64> %ptrcast2
Kunshan Wang's avatar
Kunshan Wang committed
283
        
284 285 286 287 288
        // Testing constants.
        %ptrcast4 = PTRCAST <@ptrvoid @i64> @PTRVOID_DUMMY1
        %ptrcast5 = PTRCAST <@fpi_i @ptrvoid> @FPI_I_DUMMY2
        %ptrcast6 = PTRCAST <@ptrvoid @i32> @PTRVOID_DUMMY1
        
Kunshan Wang's avatar
Kunshan Wang committed
289
        [%trap] TRAP <> KEEPALIVE (
290 291 292
            %trunc %zext %sext %fptrunc %fpext
            %fptoui1 %fptosi1 %fptoui2 %fptosi2 %uitofp %sitofp
            %bitcast1 %bitcast2 %bitcast3 %bitcast4
293
            %ptrcast1 %ptrcast2 %ptrcast3 %ptrcast4 %ptrcast5 %ptrcast6
Kunshan Wang's avatar
Kunshan Wang committed
294 295
            )
        COMMINST @uvm.thread_exit
296 297
}

Kunshan Wang's avatar
Kunshan Wang committed
298 299
.funcsig @conv_vec_sig = (@4xi32 @4xfloat @2xdouble) -> ()
.funcdef @conv_vec VERSION %v1 <@conv_vec_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
300
    %entry(<@4xi32> %p0 <@4xfloat> %p1 <@2xdouble> %p2):
301 302 303 304 305 306 307
        %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

Kunshan Wang's avatar
Kunshan Wang committed
308
        [%trap] TRAP <> KEEPALIVE (
309 310 311 312 313 314
            %trunc %zext %sext %fptrunc %fpext
            )
        COMMINST @uvm.thread_exit
}


Kunshan Wang's avatar
Kunshan Wang committed
315
.const @4xI1_COND <@4xi1> = {@TRUE @FALSE @FALSE @TRUE}
316

Kunshan Wang's avatar
Kunshan Wang committed
317
.funcdef @select VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
318
    %entry():
319 320 321 322 323 324 325
        %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
326
    
Kunshan Wang's avatar
Kunshan Wang committed
327
        [%trap] TRAP <> KEEPALIVE (
328
            %sel1 %sel2 %sel3 %sel4 %sel5
329 330
            )
        COMMINST @uvm.thread_exit
331 332
}

Kunshan Wang's avatar
Kunshan Wang committed
333 334
.funcsig @branch_sig = (@i64) -> ()
.funcdef @branch VERSION %v1 <@branch_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
335 336
    %entry(<@i64> %p0):
        BRANCH %head(%p0)
337

Kunshan Wang's avatar
Kunshan Wang committed
338
    %head(<@i64> %p0):
339
        %cmpz = EQ <@i64> %p0 @I64_0
Kunshan Wang's avatar
Kunshan Wang committed
340
        BRANCH2 %cmpz %iftrue() %iffalse()
341
        
Kunshan Wang's avatar
Kunshan Wang committed
342
    %iftrue():
Kunshan Wang's avatar
Kunshan Wang committed
343
        [%traptrue] TRAP <>
344 345
        COMMINST @uvm.thread_exit
        
Kunshan Wang's avatar
Kunshan Wang committed
346
    %iffalse():
Kunshan Wang's avatar
Kunshan Wang committed
347
        [%trapfalse] TRAP <>
348 349 350 351
        COMMINST @uvm.thread_exit
}


Kunshan Wang's avatar
Kunshan Wang committed
352
.funcsig @switch_sig = (@i64) -> ()
Kunshan Wang's avatar
Kunshan Wang committed
353 354 355 356 357 358
.funcdef @switch VERSION %v1 <@switch_sig> {
    %entry(<@i64> %p0):
        SWITCH <@i64> %p0 %def() {
            @I64_1 %one()
            @I64_2 %two()
            @I64_3 %three()
359 360
        }
        
Kunshan Wang's avatar
Kunshan Wang committed
361
    %def():
Kunshan Wang's avatar
Kunshan Wang committed
362
        [%trapdef] TRAP <> EXC(%exit(@I64_4) %exit(@I64_4))
Kunshan Wang's avatar
Kunshan Wang committed
363 364
                                                                 
    %one():                                                      
Kunshan Wang's avatar
Kunshan Wang committed
365
        [%trapone] TRAP <> EXC(%exit(@I64_5) %exit(@I64_5))
Kunshan Wang's avatar
Kunshan Wang committed
366 367
                                                                 
    %two():                                                      
Kunshan Wang's avatar
Kunshan Wang committed
368
        [%traptwo] TRAP <> EXC(%exit(@I64_6) %exit(@I64_6))
Kunshan Wang's avatar
Kunshan Wang committed
369 370
                                                                 
    %three():                                                    
Kunshan Wang's avatar
Kunshan Wang committed
371
        [%trapthree] TRAP <> EXC(%exit(@I64_7) %exit(@I64_7))
372
        
Kunshan Wang's avatar
Kunshan Wang committed
373
    %exit(<@i64> %v):
Kunshan Wang's avatar
Kunshan Wang committed
374
        [%trapend] TRAP <> KEEPALIVE (%v)
375 376 377
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
378
.funcdef @edge_asgn_test VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
379 380
    %entry():
        BRANCH %head(@I64_1 @I64_2 @I64_0)
381

Kunshan Wang's avatar
Kunshan Wang committed
382
    %head(<@i64> %x <@i64> %y <@i64> %i):
383 384
        %i2 = ADD <@i64> %i @I64_1
        %lt = SLT <@i64> %i @I64_1
Kunshan Wang's avatar
Kunshan Wang committed
385
        BRANCH2 %lt %head(%y %x %i2) %end(%x %y)
386

Kunshan Wang's avatar
Kunshan Wang committed
387
    %end(<@i64> %x <@i64> %y):
Kunshan Wang's avatar
Kunshan Wang committed
388
        [%trap] TRAP <> KEEPALIVE (%x %y)
389 390 391
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
392
.funcdef @square_sum VERSION %v1 <@ii_i> {
Kunshan Wang's avatar
Kunshan Wang committed
393
    %entry (<@i64> %a <@i64> %b):
394 395 396
        %a2 = MUL <@i64> %a %a
        %b2 = MUL <@i64> %b %b
        %s  = ADD <@i64> %a2 %b2
Kunshan Wang's avatar
Kunshan Wang committed
397
        RET %s
398 399
}

Kunshan Wang's avatar
Kunshan Wang committed
400
.funcdef @call_ret VERSION %v1 <@ii_i> {
Kunshan Wang's avatar
Kunshan Wang committed
401
    %entry(<@i64> %a <@i64> %b):
Kunshan Wang's avatar
Kunshan Wang committed
402 403
        %ss = CALL <@ii_i> @square_sum (%a %b)
        [%trap] TRAP <> KEEPALIVE (%ss)
404 405 406
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
407
.funcdef @thrower VERSION %v1 <@i_i> {
Kunshan Wang's avatar
Kunshan Wang committed
408
    %entry(<@i64> %p0):
Kunshan Wang's avatar
Kunshan Wang committed
409
        %n0 = NE <@i64> %p0 @I64_0
Kunshan Wang's avatar
Kunshan Wang committed
410 411 412 413
        BRANCH2 %n0 %nz(%p0) %z()
    %nz(<@i64> %p0):
        RET %p0
    %z():
Kunshan Wang's avatar
Kunshan Wang committed
414 415 416
        THROW @NULLREF
}

Kunshan Wang's avatar
Kunshan Wang committed
417
.funcdef @call_throw VERSION %v1 <@i_i> {
Kunshan Wang's avatar
Kunshan Wang committed
418 419 420
    %entry(<@i64> %p0):
        %rv = CALL <@i_i> @thrower (%p0) EXC(%nor(%rv) %exc())
    %nor(<@i64> %rv):
Kunshan Wang's avatar
Kunshan Wang committed
421
        [%trapnor] TRAP <> EXC(%exit() %exit()) KEEPALIVE (%rv)
Kunshan Wang's avatar
Kunshan Wang committed
422
    %exc() [%the_exc]:
Kunshan Wang's avatar
Kunshan Wang committed
423
        [%trapexc] TRAP <> EXC(%exit() %exit()) KEEPALIVE (%the_exc)
Kunshan Wang's avatar
Kunshan Wang committed
424
    %exit():
Kunshan Wang's avatar
Kunshan Wang committed
425 426 427
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
.funcsig @swap.sig = (@i64 @i64) -> (@i64 @i64)
.funcdef @swap VERSION %v1 <@swap.sig> {
    %entry( <@i64> %a
            <@i64> %b):
        RET (%b %a)
}

.funcdef @checkpoint VERSION %v1 <@v_v> {
    %entry():
        [%trap] TRAP <>
        RET ()
}

.funcdef @call_multi_return VERSION %v1 <@v_v> {
    %entry():
        (%a %b) = CALL <@swap.sig> @swap (@I64_7 @I64_8)
        () = CALL <@v_v> @checkpoint ()
        [%trap] TRAP <> KEEPALIVE(%a %b)
        COMMINST @uvm.thread_exit
}


Kunshan Wang's avatar
Kunshan Wang committed
450 451 452 453 454 455
// Some simple struct constants

.typedef @StructFoo = struct <@i32 @i64 @float @double>

.const @STRUCT_FOO <@StructFoo> = {@I32_1 @I64_2 @F_3 @D_4}

Kunshan Wang's avatar
Kunshan Wang committed
456
.funcdef @aggregate_struct VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
457
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
458 459 460 461
        %f1  = EXTRACTVALUE <@StructFoo 1> @STRUCT_FOO
        %s2  = INSERTVALUE  <@StructFoo 1> @STRUCT_FOO @I64_7
        %f12 = EXTRACTVALUE <@StructFoo 1> %s2

Kunshan Wang's avatar
Kunshan Wang committed
462
        [%trapnor] TRAP <> KEEPALIVE (%f1 %f12)
Kunshan Wang's avatar
Kunshan Wang committed
463 464 465
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
466 467 468 469 470 471
.const @v1 <@4xfloat> = {@F_0 @F_1 @F_2 @F_3}
.const @v2 <@4xfloat> = {@F_4 @F_5 @F_6 @F_7}
.const @vshf <@4xi32> = {@I32_0 @I32_2 @I32_4 @I32_6}

.typedef @6xi32_ary = array<@i32 6>
.const @a1 <@6xi32_ary> = {@I32_0 @I32_2 @I32_4 @I32_6 @I32_7 @I32_3}
Kunshan Wang's avatar
Kunshan Wang committed
472

Kunshan Wang's avatar
Kunshan Wang committed
473
.funcdef @aggregate_seq VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
474
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
475 476 477 478
        %ee0 = EXTRACTELEMENT <@4xfloat @i32> @4xF_V1 @I32_0
        %ie0 = INSERTELEMENT  <@4xfloat @i32> @4xF_V1 @I32_1 @F_6
        %sv0 = SHUFFLEVECTOR  <@4xfloat @4xi32> @4xF_V1 @4xF_V2 @vshf

Kunshan Wang's avatar
Kunshan Wang committed
479 480 481
        %ee1 = EXTRACTELEMENT <@6xi32_ary @i64> @a1 @I64_4
        %ie1 = INSERTELEMENT  <@6xi32_ary @i64> @a1 @I64_5 @I32_1

Kunshan Wang's avatar
Kunshan Wang committed
482
        [%trapnor] TRAP <> KEEPALIVE (%ee0 %ie0 %sv0 %ee1 %ie1)
Kunshan Wang's avatar
Kunshan Wang committed
483 484 485
        COMMINST @uvm.thread_exit
}

486 487 488 489 490 491 492 493

.typedef @StructBar = struct <
    @i64 @i32 @i16 @i8 @float @double
    @refi64 @irefi64 @weakrefi64
>

.typedef @refBar = ref<@StructBar>
.typedef @irefBar = iref<@StructBar>
Kunshan Wang's avatar
Kunshan Wang committed
494
.typedef @ptrBar = uptr<@StructBar>
495 496 497

.typedef @hCharArray = hybrid<@i64 @i8>

Kunshan Wang's avatar
Kunshan Wang committed
498 499
.funcsig @allocs_sig = (@i64) -> ()
.funcdef @allocs VERSION %v1 <@allocs_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
500
    %entry(<@i64> %sz):
501 502 503 504 505
        %new = NEW <@StructBar>
        %newhybrid = NEWHYBRID <@hCharArray @i64> %sz
        %alloca = ALLOCA <@StructBar>
        %allocahybrid = ALLOCAHYBRID <@hCharArray @i64> %sz

Kunshan Wang's avatar
Kunshan Wang committed
506
        [%trap] TRAP <> KEEPALIVE (%new %newhybrid %alloca %allocahybrid)
507 508 509 510
        COMMINST @uvm.thread_exit
}

.typedef @ArrayBaz = array <@i16 1024>
Kunshan Wang's avatar
Kunshan Wang committed
511
.typedef @ptrBaz = uptr<@ArrayBaz>
512 513

.typedef @JavaLikeByteArray = hybrid <@i32 @i8>
Kunshan Wang's avatar
Kunshan Wang committed
514
.typedef @ptrJA = uptr<@JavaLikeByteArray>
515 516 517

.const @I64_1024 <@i64> = 1024

Kunshan Wang's avatar
Kunshan Wang committed
518
.funcdef @memAddressing VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
519
    %entry():
520 521 522 523 524 525 526 527 528 529 530 531
        %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 @i64> %baz_iref @I64_3
        %baz_6    = SHIFTIREF <@i16 @i64> %baz_3 @I64_3
        
        %ja_ref   = NEWHYBRID <@JavaLikeByteArray @i64> @I64_1024
        %ja_iref  = GETIREF <@JavaLikeByteArray> %ja_ref
        %ja_var   = GETVARPARTIREF <@JavaLikeByteArray> %ja_iref

Kunshan Wang's avatar
Kunshan Wang committed
532 533
        [%trap] TRAP <> KEEPALIVE (%bar_ref %bar_iref %bar_3
                    %baz_iref %baz_3 %baz_6 %ja_ref %ja_iref %ja_var)
534 535 536
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
537
.funcdef @memAddressingPtr VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
538
    %entry():
539 540 541 542 543 544 545 546 547 548 549
        %bar_ptr  = PTRCAST <@i64 @ptrBar> @I64_1024
        %baz_ptr  = PTRCAST <@i64 @ptrBaz> @I64_1024
        %ja_ptr   = PTRCAST <@i64 @ptrJA> @I64_1024

        %bar_3    = GETFIELDIREF PTR <@StructBar 3> %bar_ptr
        
        %baz_3    = GETELEMIREF PTR <@ArrayBaz @i64> %baz_ptr @I64_3
        %baz_6    = SHIFTIREF PTR <@i16 @i64> %baz_3 @I64_3
        
        %ja_var   = GETVARPARTIREF PTR <@JavaLikeByteArray> %ja_ptr

Kunshan Wang's avatar
Kunshan Wang committed
550 551
        [%trap] TRAP <> KEEPALIVE (%bar_ptr %baz_ptr %ja_ptr
                    %bar_3 %baz_3 %baz_6 %ja_var)
552 553 554
        COMMINST @uvm.thread_exit
}

555 556 557 558 559 560 561 562 563 564
.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>
    
Kunshan Wang's avatar
Kunshan Wang committed
565
.global @g_func <@frv_v>
566 567 568 569 570 571 572 573
    
.global @g_thr  <@thread>
.global @g_sta  <@stack>
.global @g_tr64 <@tagref64>

.const @I8_41  <@i8>     = 41
.const @I16_42 <@i16>    = 42
.const @I32_43 <@i32>    = 43
574 575
.const @I32_53 <@i32>    = 53
.const @I32_63 <@i32>    = 63
576
.const @I64_44 <@i64>    = 44
577 578
.const @I64_54 <@i64>    = 54
.const @I64_64 <@i64>    = 64
579 580 581
.const @F_45   <@float>  = 45.0f
.const @D_46   <@double> = 46.0d

Kunshan Wang's avatar
Kunshan Wang committed
582
.funcdef @memAccessing VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
583
    %entry():
584 585 586 587 588 589 590 591 592 593 594 595 596 597
        STORE <@i8>     @g_i8   @I8_41
        STORE <@i16>    @g_i16  @I16_42
        STORE <@i32>    @g_i32  @I32_43
        STORE <@i64>    @g_i64  @I64_44
        STORE <@float>  @g_f    @F_45
        STORE <@double> @g_d    @D_46
        
        %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

Kunshan Wang's avatar
Kunshan Wang committed
598
        STORE <@frv_v> @g_func @memAccessing
599 600 601 602 603 604 605 606 607 608 609 610
        
        %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

Kunshan Wang's avatar
Kunshan Wang committed
611
        %lfunc = LOAD <@frv_v> @g_func
612

Kunshan Wang's avatar
Kunshan Wang committed
613
        [%trap] TRAP <> KEEPALIVE (%void_r %void_ir %li8 %li16
614
                    %li32 %li64 %lf %ld %lr %lir %lwr %lfunc)
615 616 617
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
618 619 620 621 622 623 624 625 626
.const @I64_0x55ab              <@i64> = 0x55ab
.const @I64_0x5a5a              <@i64> = 0x5a5a
.const @I64_0x5000              <@i64> = 0x5000
.const @I64_0x55aa              <@i64> = 0x55aa
.const @I64_N0x7fffffffffffffde <@i64> = -0x7fffffffffffffde
.const @I64_42                  <@i64> = 42
.const @I64_11                  <@i64> = 11
.const @I64_0xffffffffffffffde  <@i64> = 0xffffffffffffffde

Kunshan Wang's avatar
Kunshan Wang committed
627 628 629
.funcsig @memAccessingPtr_sig = (@ptri8 @ptri16 @ptri32 @ptri64
                @ptrfloat @ptrdouble @ptrptrvoid @ptrfpi_i) -> ()
.funcdef @memAccessingPtr VERSION %v1 <@memAccessingPtr_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
630 631
    %entry(<@ptri8> %p0 <@ptri16> %p1 <@ptri32> %p2 <@ptri64> %p3
           <@ptrfloat> %p4 <@ptrdouble> %p5 <@ptrptrvoid> %p6 <@ptrfpi_i> %p7):
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
        STORE PTR <@i8>     %p0  @I8_41
        STORE PTR <@i16>    %p1  @I16_42
        STORE PTR <@i32>    %p2  @I32_43
        STORE PTR <@i64>    %p3  @I64_44
        STORE PTR <@float>  %p4  @F_45
        STORE PTR <@double> %p5  @D_46
        
        %my_p   = PTRCAST <@i64 @ptrptrvoid> @I64_0x55aa
        %my_fp  = PTRCAST <@i64 @ptrfpi_i>   @I64_0x55aa
        
        STORE PTR <@ptrvoid>    %p6  %my_p
        STORE PTR <@fpi_i>      %p7  %my_fp
        
        %li8  = LOAD PTR <@i8>      %p0
        %li16 = LOAD PTR <@i16>     %p1
        %li32 = LOAD PTR <@i32>     %p2
        %li64 = LOAD PTR <@i64>     %p3
        %lf   = LOAD PTR <@float>   %p4
        %ld   = LOAD PTR <@double>  %p5
        
        %lp   = LOAD PTR <@ptrvoid> %p6
        %lfp  = LOAD PTR <@fpi_i>   %p7

Kunshan Wang's avatar
Kunshan Wang committed
655
        [%trap] TRAP <> KEEPALIVE (%li8 %li16
656 657 658 659
                    %li32 %li64 %lf %ld %lp %lfp)
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
660
.funcdef @memAccessingAtomic VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
661
    %entry():
662 663 664 665 666 667 668
        STORE SEQ_CST <@i32> @g_i32 @I32_43
        STORE SEQ_CST <@i64> @g_i64 @I64_44

        %void_r   = NEW <@void>
        %void_r2  = NEW <@void>
        %void_r3  = NEW <@void>
        
669
        STORE SEQ_CST <@refvoid>     @g_r  %void_r
670

Kunshan Wang's avatar
Kunshan Wang committed
671 672 673 674
        (%cx32_1 %succ32_1) = CMPXCHG SEQ_CST RELAXED <@i32> @g_i32 @I32_43 @I32_53
        (%cx32_2 %succ32_2) = CMPXCHG SEQ_CST RELAXED <@i32> @g_i32 @I32_43 @I32_63
        (%cx64_1 %succ64_1) = CMPXCHG SEQ_CST RELAXED <@i64> @g_i64 @I64_44 @I64_54
        (%cx64_2 %succ64_2) = CMPXCHG SEQ_CST RELAXED <@i64> @g_i64 @I64_44 @I64_64
675 676 677 678
        
        %l32 = LOAD SEQ_CST <@i32> @g_i32
        %l64 = LOAD SEQ_CST <@i64> @g_i64
        
Kunshan Wang's avatar
Kunshan Wang committed
679 680
        (%cxr_1 %succr_1) = CMPXCHG SEQ_CST RELAXED <@refvoid> @g_r %void_r %void_r2
        (%cxr_2 %succr_2) = CMPXCHG SEQ_CST RELAXED <@refvoid> @g_r %void_r %void_r3
681
        
682
        %lr   = LOAD SEQ_CST <@refvoid>     @g_r
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699
        
        STORE <@i64> @g_i64 @I64_1
        
        %rmw0 = ATOMICRMW SEQ_CST XCHG  <@i64> @g_i64 @I64_0x55ab  // 1 -> 0x55ab
        %rmw1 = ATOMICRMW SEQ_CST ADD   <@i64> @g_i64 @I64_3       // 0x55ab -> 0x55ae 
        %rmw2 = ATOMICRMW SEQ_CST SUB   <@i64> @g_i64 @I64_4       // 0x55ae -> 0x55aa
        %rmw3 = ATOMICRMW SEQ_CST AND   <@i64> @g_i64 @I64_0x5a5a  // 0x55aa -> 0x500a
        %rmw4 = ATOMICRMW SEQ_CST NAND  <@i64> @g_i64 @I64_0x5a5a  // 0x500a -> ~0x500a
        %rmw5 = ATOMICRMW SEQ_CST OR    <@i64> @g_i64 @I64_0x5000  // ~0x500a -> ~0x000a
        %rmw6 = ATOMICRMW SEQ_CST XOR   <@i64> @g_i64 @I64_0x55aa  // ~0x000a -> ~0x55a0 
        %rmw7 = ATOMICRMW SEQ_CST MIN   <@i64> @g_i64 @I64_N0x7fffffffffffffde // ~0x55a0 -> -0x7fffffffffffffde
        %rmw8 = ATOMICRMW SEQ_CST MAX   <@i64> @g_i64 @I64_42      // -0x7fffffffffffffde -> 42
        %rmw9 = ATOMICRMW SEQ_CST UMIN  <@i64> @g_i64 @I64_11      // 42 -> 11
        %rmwA = ATOMICRMW SEQ_CST UMAX  <@i64> @g_i64 @I64_0xffffffffffffffde // 11 -> 0xffffffffffffffde
        
        %l64_2 = LOAD SEQ_CST <@i64> @g_i64

Kunshan Wang's avatar
Kunshan Wang committed
700 701 702 703 704 705 706
        [%trap] TRAP <> KEEPALIVE (%void_r %void_r2 %void_r3
                    %cx32_1 %succ32_1 %cx32_2 %succ32_2 %cx64_1 %succ64_1 %cx64_2 %succ64_2
                    %l32 %l64
                    %cxr_1 %succr_1 %cxr_2 %succr_2
                    %lr
                    %rmw0 %rmw1 %rmw2 %rmw3 %rmw4 %rmw5 %rmw6 %rmw7 %rmw8 %rmw9 %rmwA
                    %l64_2)
707 708 709
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
710 711 712
.funcsig @memAccessingAtomicPtr_sig = (@ptri8 @ptri16 @ptri32 @ptri64
                @ptrfloat @ptrdouble @ptrptrvoid @ptrfpi_i) -> ()
.funcdef @memAccessingAtomicPtr VERSION %v1 <@memAccessingAtomicPtr_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
713 714
    %entry(<@ptri8> %p0 <@ptri16> %p1 <@ptri32> %p2 <@ptri64> %p3
           <@ptrfloat> %p4 <@ptrdouble> %p5 <@ptrptrvoid> %p6 <@ptrfpi_i> %p7):
715 716 717 718 719 720 721 722 723 724 725 726 727
        STORE PTR SEQ_CST <@i32> %p2 @I32_43
        STORE PTR SEQ_CST <@i64> %p3 @I64_44

        %ptr0  = PTRCAST <@i64 @ptrvoid> @I64_0x55ab
        %ptr1  = PTRCAST <@i64 @ptrvoid> @I64_0x5a5a
        %ptr2  = PTRCAST <@i64 @ptrvoid> @I64_0x5000
        %fp0   = PTRCAST <@i64 @fpi_i>   @I64_0x55ab
        %fp1   = PTRCAST <@i64 @fpi_i>   @I64_0x5a5a
        %fp2   = PTRCAST <@i64 @fpi_i>   @I64_0x5000
        
        STORE PTR SEQ_CST <@ptrvoid> %p6  %ptr0
        STORE PTR SEQ_CST <@fpi_i>   %p7  %fp0

Kunshan Wang's avatar
Kunshan Wang committed
728 729 730 731
        (%cx32_1 %succ32_1) = CMPXCHG PTR SEQ_CST RELAXED <@i32> %p2 @I32_43 @I32_53
        (%cx32_2 %succ32_2) = CMPXCHG PTR SEQ_CST RELAXED <@i32> %p2 @I32_43 @I32_63
        (%cx64_1 %succ64_1) = CMPXCHG PTR SEQ_CST RELAXED <@i64> %p3 @I64_44 @I64_54
        (%cx64_2 %succ64_2) = CMPXCHG PTR SEQ_CST RELAXED <@i64> %p3 @I64_44 @I64_64
732 733 734 735
        
        %l32 = LOAD PTR SEQ_CST <@i32> %p2
        %l64 = LOAD PTR SEQ_CST <@i64> %p3
        
Kunshan Wang's avatar
Kunshan Wang committed
736 737 738 739
        (%cxp_1  %succp_1 ) = CMPXCHG PTR SEQ_CST RELAXED <@ptrvoid> %p6 %ptr0 %ptr1
        (%cxp_2  %succp_2 ) = CMPXCHG PTR SEQ_CST RELAXED <@ptrvoid> %p6 %ptr0 %ptr2
        (%cxfp_1 %succfp_1) = CMPXCHG PTR SEQ_CST RELAXED <@fpi_i>   %p7 %fp0 %fp1
        (%cxfp_2 %succfp_2) = CMPXCHG PTR SEQ_CST RELAXED <@fpi_i>   %p7 %fp0 %fp2
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759
        
        %lp   = LOAD PTR SEQ_CST <@ptrvoid> %p6
        %lfp  = LOAD PTR SEQ_CST <@fpi_i>   %p7
        
        STORE PTR <@i64> %p3 @I64_1
        
        %rmw0 = ATOMICRMW PTR SEQ_CST XCHG  <@i64> %p3 @I64_0x55ab  // 1 -> 0x55ab
        %rmw1 = ATOMICRMW PTR SEQ_CST ADD   <@i64> %p3 @I64_3       // 0x55ab -> 0x55ae 
        %rmw2 = ATOMICRMW PTR SEQ_CST SUB   <@i64> %p3 @I64_4       // 0x55ae -> 0x55aa
        %rmw3 = ATOMICRMW PTR SEQ_CST AND   <@i64> %p3 @I64_0x5a5a  // 0x55aa -> 0x500a
        %rmw4 = ATOMICRMW PTR SEQ_CST NAND  <@i64> %p3 @I64_0x5a5a  // 0x500a -> ~0x500a
        %rmw5 = ATOMICRMW PTR SEQ_CST OR    <@i64> %p3 @I64_0x5000  // ~0x500a -> ~0x000a
        %rmw6 = ATOMICRMW PTR SEQ_CST XOR   <@i64> %p3 @I64_0x55aa  // ~0x000a -> ~0x55a0 
        %rmw7 = ATOMICRMW PTR SEQ_CST MIN   <@i64> %p3 @I64_N0x7fffffffffffffde // ~0x55a0 -> -0x7fffffffffffffde
        %rmw8 = ATOMICRMW PTR SEQ_CST MAX   <@i64> %p3 @I64_42      // -0x7fffffffffffffde -> 42
        %rmw9 = ATOMICRMW PTR SEQ_CST UMIN  <@i64> %p3 @I64_11      // 42 -> 11
        %rmwA = ATOMICRMW PTR SEQ_CST UMAX  <@i64> %p3 @I64_0xffffffffffffffde // 11 -> 0xffffffffffffffde
        
        %l64_2 = LOAD PTR SEQ_CST <@i64> %p3

Kunshan Wang's avatar
Kunshan Wang committed
760 761 762 763 764 765 766
        [%trap] TRAP <> KEEPALIVE (
                    %cx32_1 %succ32_1 %cx32_2 %succ32_2 %cx64_1 %succ64_1 %cx64_2 %succ64_2
                    %l32 %l64
                    %cxp_1 %succp_1 %cxp_2 %succp_2 %cxfp_1 %succfp_1 %cxfp_2 %succfp_2
                    %lp %lfp
                    %rmw0 %rmw1 %rmw2 %rmw3 %rmw4 %rmw5 %rmw6 %rmw7 %rmw8 %rmw9 %rmwA
                    %l64_2)
767 768 769
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
770
.funcdef @memAccessingNull VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
771 772
    %entry():
        %l = LOAD <@i64> @NULLIREF_I64 EXC(%unreachable() %bb2())
773

Kunshan Wang's avatar
Kunshan Wang committed
774
    %bb2():
Kunshan Wang's avatar
Kunshan Wang committed
775
        STORE <@i64> @NULLIREF_I64 @I64_0 EXC(%unreachable() %bb3())
776

Kunshan Wang's avatar
Kunshan Wang committed
777
    %bb3():
Kunshan Wang's avatar
Kunshan Wang committed
778
        (%c %sc) = CMPXCHG SEQ_CST RELAXED <@i64> @NULLIREF_I64 @I64_0 @I64_1 EXC(%unreachable() %bb4())
779

Kunshan Wang's avatar
Kunshan Wang committed
780 781
    %bb4():
        %a = ATOMICRMW SEQ_CST XCHG <@i64> @NULLIREF_I64 @I64_0 EXC(%unreachable() %exit())
782

Kunshan Wang's avatar
Kunshan Wang committed
783
    %exit():
Kunshan Wang's avatar
Kunshan Wang committed
784
        [%trap_exit] TRAP <>
785 786
        COMMINST @uvm.thread_exit

Kunshan Wang's avatar
Kunshan Wang committed
787
    %unreachable():
Kunshan Wang's avatar
Kunshan Wang committed
788
        [%trap_unreachable] TRAP <>
789 790 791
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
792
.funcdef @traptest VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
793
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
794 795
        %v1 = [%t1] TRAP <@i64>
        (%v2 %v3) = [%t2] TRAP <@float @double> EXC(%bb2(%v1 %v2 %v3) %unreachable())
796

Kunshan Wang's avatar
Kunshan Wang committed
797 798
    %bb2(<@i64> %v1 <@float> %v2 <@double> %v3):
        [%t3] TRAP <> EXC(%unreachable() %exit(%v1 %v2 %v3))
799

Kunshan Wang's avatar
Kunshan Wang committed
800 801
    %exit(<@i64> %v1 <@float> %v2 <@double> %v3) [%exc]:
        [%trap_exit] TRAP <> KEEPALIVE (%v1 %v2 %v3 %exc)
802 803
        COMMINST @uvm.thread_exit

Kunshan Wang's avatar
Kunshan Wang committed
804
    %unreachable():
Kunshan Wang's avatar
Kunshan Wang committed
805
        [%trap_unreachable] TRAP <>
806 807 808
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
809
.funcdef @wptest VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
810
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
811
        %v1 = [%w1] WATCHPOINT 1 <@i64> %dis() %bb2(%v1)
812

Kunshan Wang's avatar
Kunshan Wang committed
813 814
    %bb2(<@i64> %v1):
        %v2 = [%w2] WATCHPOINT 1 <@double> %dis() %bb3(%v1 %v2) WPEXC(%unreachable())
815

Kunshan Wang's avatar
Kunshan Wang committed
816 817
    %bb3(<@i64> %v1 <@double> %v2):
        [%w3] WATCHPOINT 1 <> %dis() %unreachable() WPEXC(%exit(%v1 %v2))
818

Kunshan Wang's avatar
Kunshan Wang committed
819 820
    %exit(<@i64> %v1 <@double> %v2) [%exc]:
        [%trap_exit] TRAP <> KEEPALIVE (%v1 %v2 %exc)
821 822
        COMMINST @uvm.thread_exit

Kunshan Wang's avatar
Kunshan Wang committed
823
    %unreachable():
Kunshan Wang's avatar
Kunshan Wang committed
824
        [%trap_unreachable] TRAP <>
825 826
        COMMINST @uvm.thread_exit

Kunshan Wang's avatar
Kunshan Wang committed
827
    %dis():
Kunshan Wang's avatar
Kunshan Wang committed
828
        [%trap_dis] TRAP <>
829 830 831
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
832
.funcdef @trapThrow VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
833
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
834 835
        [%t] TRAP <>
        [%trap_unreachable] TRAP <>
Kunshan Wang's avatar
Kunshan Wang committed
836 837 838
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
839
.funcdef @wpThrow VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
840
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
841
        [%w] WATCHPOINT 2 <> %dis() %ena()
Kunshan Wang's avatar
Kunshan Wang committed
842

Kunshan Wang's avatar
Kunshan Wang committed
843
    %dis():
Kunshan Wang's avatar
Kunshan Wang committed
844
        [%trap_unreachable] TRAP <>
Kunshan Wang's avatar
Kunshan Wang committed
845 846
        COMMINST @uvm.thread_exit

Kunshan Wang's avatar
Kunshan Wang committed
847
    %ena():
Kunshan Wang's avatar
Kunshan Wang committed
848
        [%trap_unreachable2] TRAP <>
Kunshan Wang's avatar
Kunshan Wang committed
849 850 851
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
852
.funcdef @trapExc VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
853
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
854
        CALL <@v_v> @trapThrow () EXC(%unreachable() %bb2())
Kunshan Wang's avatar
Kunshan Wang committed
855

Kunshan Wang's avatar
Kunshan Wang committed
856
    %bb2() [%exc]:
Kunshan Wang's avatar
Kunshan Wang committed
857
        CALL <@v_v> @wpThrow () EXC(%unreachable() %exit(%exc))
Kunshan Wang's avatar
Kunshan Wang committed
858

Kunshan Wang's avatar
Kunshan Wang committed
859
    %exit(<@refvoid> %exc1) [%exc2]:
Kunshan Wang's avatar
Kunshan Wang committed
860
        [%trap_exit] TRAP <> KEEPALIVE (%exc1 %exc2)
Kunshan Wang's avatar
Kunshan Wang committed
861 862
        COMMINST @uvm.thread_exit

Kunshan Wang's avatar
Kunshan Wang committed
863
    %unreachable():
Kunshan Wang's avatar
Kunshan Wang committed
864
        [%trap_unreachable] TRAP <>
Kunshan Wang's avatar
Kunshan Wang committed
865 866 867
        COMMINST @uvm.thread_exit
}

868 869 870 871 872 873 874 875 876 877 878 879 880
.funcdef @wpbranch VERSION %v1 <@v_v> {
    %entry():
        WPBRANCH 42 %dis() %ena()
    %dis():
        [%trap] TRAP <>
        BRANCH %exit()
    %ena():
        [%trap] TRAP <>
        BRANCH %exit()
    %exit():
        COMMINST @uvm.thread_exit
}

Kunshan Wang's avatar
Kunshan Wang committed
881 882
.funcsig @corostackfunc_sig = (@stack @i64) -> ()
.funcdef @corostackfunc VERSION %v1 <@corostackfunc_sig> {
Kunshan Wang's avatar
Kunshan Wang committed
883
    %entry(<@stack> %fromsta <@i64> %p):
Kunshan Wang's avatar
Kunshan Wang committed
884
        [%trap_coro1] TRAP <> KEEPALIVE(%fromsta %p)
Kunshan Wang's avatar
Kunshan Wang committed
885 886 887

        %pp1 = ADD <@i64> %p @I64_1

Kunshan Wang's avatar
Kunshan Wang committed
888
        %v1 = [%css1] SWAPSTACK %fromsta RET_WITH <@double> PASS_VALUES <@i64> (%pp1)
Kunshan Wang's avatar
Kunshan Wang committed
889

Kunshan Wang's avatar
Kunshan Wang committed
890
        [%trap_coro2] TRAP <> KEEPALIVE(%v1)
Kunshan Wang's avatar
Kunshan Wang committed
891

Kunshan Wang's avatar
Kunshan Wang committed
892
        [%css2] SWAPSTACK %fromsta RET_WITH <> PASS_VALUES <> () KEEPALIVE(%v1)
Kunshan Wang's avatar
Kunshan Wang committed
893 894 895 896 897

        %excref = NEW <@i64>
        %exciref = GETIREF <@i64> %excref
        STORE <@i64> %exciref @I64_7    // Does not need to be atomic. It is single threaded.

Kunshan Wang's avatar
Kunshan Wang committed
898
        [%css3] SWAPSTACK %fromsta KILL_OLD THROW_EXC %excref
Kunshan Wang's avatar
Kunshan Wang committed
899 900
}

Kunshan Wang's avatar
Kunshan Wang committed
901
.funcdef @testswapstack VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
902
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
903 904
        %thisstack = COMMINST @uvm.current_stack ()
        
Kunshan Wang's avatar
Kunshan Wang committed
905
        %coro = COMMINST @uvm.new_stack <[@corostackfunc_sig]> (@corostackfunc)
Kunshan Wang's avatar
Kunshan Wang committed
906

Kunshan Wang's avatar
Kunshan Wang committed
907
        %v1 = [%mss1] SWAPSTACK %coro RET_WITH <@i64> PASS_VALUES <@stack @i64> (%thisstack @I64_2)
Kunshan Wang's avatar
Kunshan Wang committed
908

Kunshan Wang's avatar
Kunshan Wang committed
909
        [%trap_main1] TRAP <> KEEPALIVE(%v1)
Kunshan Wang's avatar
Kunshan Wang committed
910

Kunshan Wang's avatar
Kunshan Wang committed
911
        [%mss2] SWAPSTACK %coro RET_WITH <> PASS_VALUES <@double> (@D_3)
Kunshan Wang's avatar
Kunshan Wang committed
912

Kunshan Wang's avatar
Kunshan Wang committed
913
        [%mss3] SWAPSTACK %coro RET_WITH <> PASS_VALUES <> () EXC(%unreachable() %exit())
Kunshan Wang's avatar
Kunshan Wang committed
914

Kunshan Wang's avatar
Kunshan Wang committed
915
    %exit() [%exc]:
Kunshan Wang's avatar
Kunshan Wang committed
916 917 918
        %excref = REFCAST <@refvoid @refi64> %exc
        %exciref = GETIREF <@i64> %excref
        %excval = LOAD <@i64> %exciref
Kunshan Wang's avatar
Kunshan Wang committed
919
        [%trap_main2] TRAP <> KEEPALIVE(%excval)
Kunshan Wang's avatar
Kunshan Wang committed
920 921
        COMMINST @uvm.thread_exit

Kunshan Wang's avatar
Kunshan Wang committed
922
    %unreachable():
Kunshan Wang's avatar
Kunshan Wang committed
923
        [%trap_unreachable] TRAP <>
Kunshan Wang's avatar
Kunshan Wang committed
924 925 926
        COMMINST @uvm.thread_exit
}

927 928 929 930
.const @I6_31 <@i6> = 31
.const @I52_SAMPLE <@i52> = 0xfedcba9876543
.const @D_42 <@double> = 42.0d

Kunshan Wang's avatar
Kunshan Wang committed
931
.funcdef @testtr64 VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
932
    %entry():
933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954
        %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)
        
Kunshan Wang's avatar
Kunshan Wang committed
955
        [%trap] TRAP <> KEEPALIVE (%rv %f %i %r %f_is_f %f_is_i %f_is_r
956 957 958
                %i_is_f %i_is_i %i_is_r %r_is_f %r_is_i %r_is_r %fb %ib %rb %rt)
        COMMINST @uvm.thread_exit
}
Kunshan Wang's avatar
Kunshan Wang committed
959

Kunshan Wang's avatar
Kunshan Wang committed
960
.funcdef @testdependency VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
961
    %entry():
962 963
        %a = ADD <@i64> @I64_1 @I64_2
        %b = COMMINST @uvm.kill_dependency <@i64> (%a)
Kunshan Wang's avatar
Kunshan Wang committed
964
        [%trap] TRAP <> KEEPALIVE (%b)
965 966
        COMMINST @uvm.thread_exit
}
Kunshan Wang's avatar
Kunshan Wang committed
967

Kunshan Wang's avatar
Kunshan Wang committed
968
.funcdef @objectpinning VERSION %v1 <@v_v> {
Kunshan Wang's avatar
Kunshan Wang committed
969
    %entry():
Kunshan Wang's avatar
Kunshan Wang committed
970 971 972 973 974 975 976 977 978 979 980
        %a = NEW <@i64>
        %b = GETIREF <@i64> %a

        %c = COMMINST @uvm.native.pin <@refi64> (%a)
        %d = COMMINST @uvm.native.pin <@irefi64> (%b)

        STORE PTR <@i64> %c @I64_42
        
        %e = LOAD PTR <@i64> %d
        %f = LOAD <@i64> %b

Kunshan Wang's avatar
Kunshan Wang committed
981
        [%trap] TRAP <> KEEPALIVE (%a %b %c %d %e %f)
Kunshan Wang's avatar
Kunshan Wang committed
982 983 984 985 986 987

        COMMINST @uvm.native.unpin <@refi64>  (%a)
        COMMINST @uvm.native.unpin <@irefi64> (%b)

        COMMINST @uvm.thread_exit
}