github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/compiler/testdata/basic.ll (about)

     1  ; ModuleID = 'basic.go'
     2  source_filename = "basic.go"
     3  target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20"
     4  target triple = "wasm32-unknown-wasi"
     5  
     6  %main.kv = type { float, i32, i32, i32 }
     7  %main.kv.0 = type { i8, i32, i32, i32 }
     8  
     9  @main.kvGlobal = hidden global %main.kv zeroinitializer, align 4
    10  @main.a = hidden global { ptr, i32, i32 } zeroinitializer, align 4
    11  @main.b = hidden global [2 x ptr] zeroinitializer, align 4
    12  
    13  ; Function Attrs: allockind("alloc,zeroed") allocsize(0)
    14  declare noalias nonnull ptr @runtime.alloc(i32, ptr, ptr) #0
    15  
    16  declare void @runtime.trackPointer(ptr nocapture readonly, ptr, ptr) #1
    17  
    18  ; Function Attrs: nounwind
    19  define hidden void @main.init(ptr %context) unnamed_addr #2 {
    20  entry:
    21    ret void
    22  }
    23  
    24  ; Function Attrs: nounwind
    25  define hidden i32 @main.addInt(i32 %x, i32 %y, ptr %context) unnamed_addr #2 {
    26  entry:
    27    %0 = add i32 %x, %y
    28    ret i32 %0
    29  }
    30  
    31  ; Function Attrs: nounwind
    32  define hidden i1 @main.equalInt(i32 %x, i32 %y, ptr %context) unnamed_addr #2 {
    33  entry:
    34    %0 = icmp eq i32 %x, %y
    35    ret i1 %0
    36  }
    37  
    38  ; Function Attrs: nounwind
    39  define hidden i32 @main.divInt(i32 %x, i32 %y, ptr %context) unnamed_addr #2 {
    40  entry:
    41    %0 = icmp eq i32 %y, 0
    42    br i1 %0, label %divbyzero.throw, label %divbyzero.next
    43  
    44  divbyzero.next:                                   ; preds = %entry
    45    %1 = icmp eq i32 %y, -1
    46    %2 = icmp eq i32 %x, -2147483648
    47    %3 = and i1 %1, %2
    48    %4 = select i1 %3, i32 1, i32 %y
    49    %5 = sdiv i32 %x, %4
    50    ret i32 %5
    51  
    52  divbyzero.throw:                                  ; preds = %entry
    53    call void @runtime.divideByZeroPanic(ptr undef) #3
    54    unreachable
    55  }
    56  
    57  declare void @runtime.divideByZeroPanic(ptr) #1
    58  
    59  ; Function Attrs: nounwind
    60  define hidden i32 @main.divUint(i32 %x, i32 %y, ptr %context) unnamed_addr #2 {
    61  entry:
    62    %0 = icmp eq i32 %y, 0
    63    br i1 %0, label %divbyzero.throw, label %divbyzero.next
    64  
    65  divbyzero.next:                                   ; preds = %entry
    66    %1 = udiv i32 %x, %y
    67    ret i32 %1
    68  
    69  divbyzero.throw:                                  ; preds = %entry
    70    call void @runtime.divideByZeroPanic(ptr undef) #3
    71    unreachable
    72  }
    73  
    74  ; Function Attrs: nounwind
    75  define hidden i32 @main.remInt(i32 %x, i32 %y, ptr %context) unnamed_addr #2 {
    76  entry:
    77    %0 = icmp eq i32 %y, 0
    78    br i1 %0, label %divbyzero.throw, label %divbyzero.next
    79  
    80  divbyzero.next:                                   ; preds = %entry
    81    %1 = icmp eq i32 %y, -1
    82    %2 = icmp eq i32 %x, -2147483648
    83    %3 = and i1 %1, %2
    84    %4 = select i1 %3, i32 1, i32 %y
    85    %5 = srem i32 %x, %4
    86    ret i32 %5
    87  
    88  divbyzero.throw:                                  ; preds = %entry
    89    call void @runtime.divideByZeroPanic(ptr undef) #3
    90    unreachable
    91  }
    92  
    93  ; Function Attrs: nounwind
    94  define hidden i32 @main.remUint(i32 %x, i32 %y, ptr %context) unnamed_addr #2 {
    95  entry:
    96    %0 = icmp eq i32 %y, 0
    97    br i1 %0, label %divbyzero.throw, label %divbyzero.next
    98  
    99  divbyzero.next:                                   ; preds = %entry
   100    %1 = urem i32 %x, %y
   101    ret i32 %1
   102  
   103  divbyzero.throw:                                  ; preds = %entry
   104    call void @runtime.divideByZeroPanic(ptr undef) #3
   105    unreachable
   106  }
   107  
   108  ; Function Attrs: nounwind
   109  define hidden i1 @main.floatEQ(float %x, float %y, ptr %context) unnamed_addr #2 {
   110  entry:
   111    %0 = fcmp oeq float %x, %y
   112    ret i1 %0
   113  }
   114  
   115  ; Function Attrs: nounwind
   116  define hidden i1 @main.floatNE(float %x, float %y, ptr %context) unnamed_addr #2 {
   117  entry:
   118    %0 = fcmp une float %x, %y
   119    ret i1 %0
   120  }
   121  
   122  ; Function Attrs: nounwind
   123  define hidden i1 @main.floatLower(float %x, float %y, ptr %context) unnamed_addr #2 {
   124  entry:
   125    %0 = fcmp olt float %x, %y
   126    ret i1 %0
   127  }
   128  
   129  ; Function Attrs: nounwind
   130  define hidden i1 @main.floatLowerEqual(float %x, float %y, ptr %context) unnamed_addr #2 {
   131  entry:
   132    %0 = fcmp ole float %x, %y
   133    ret i1 %0
   134  }
   135  
   136  ; Function Attrs: nounwind
   137  define hidden i1 @main.floatGreater(float %x, float %y, ptr %context) unnamed_addr #2 {
   138  entry:
   139    %0 = fcmp ogt float %x, %y
   140    ret i1 %0
   141  }
   142  
   143  ; Function Attrs: nounwind
   144  define hidden i1 @main.floatGreaterEqual(float %x, float %y, ptr %context) unnamed_addr #2 {
   145  entry:
   146    %0 = fcmp oge float %x, %y
   147    ret i1 %0
   148  }
   149  
   150  ; Function Attrs: nounwind
   151  define hidden float @main.complexReal(float %x.r, float %x.i, ptr %context) unnamed_addr #2 {
   152  entry:
   153    ret float %x.r
   154  }
   155  
   156  ; Function Attrs: nounwind
   157  define hidden float @main.complexImag(float %x.r, float %x.i, ptr %context) unnamed_addr #2 {
   158  entry:
   159    ret float %x.i
   160  }
   161  
   162  ; Function Attrs: nounwind
   163  define hidden { float, float } @main.complexAdd(float %x.r, float %x.i, float %y.r, float %y.i, ptr %context) unnamed_addr #2 {
   164  entry:
   165    %0 = fadd float %x.r, %y.r
   166    %1 = fadd float %x.i, %y.i
   167    %2 = insertvalue { float, float } undef, float %0, 0
   168    %3 = insertvalue { float, float } %2, float %1, 1
   169    ret { float, float } %3
   170  }
   171  
   172  ; Function Attrs: nounwind
   173  define hidden { float, float } @main.complexSub(float %x.r, float %x.i, float %y.r, float %y.i, ptr %context) unnamed_addr #2 {
   174  entry:
   175    %0 = fsub float %x.r, %y.r
   176    %1 = fsub float %x.i, %y.i
   177    %2 = insertvalue { float, float } undef, float %0, 0
   178    %3 = insertvalue { float, float } %2, float %1, 1
   179    ret { float, float } %3
   180  }
   181  
   182  ; Function Attrs: nounwind
   183  define hidden { float, float } @main.complexMul(float %x.r, float %x.i, float %y.r, float %y.i, ptr %context) unnamed_addr #2 {
   184  entry:
   185    %0 = fmul float %x.r, %y.r
   186    %1 = fmul float %x.i, %y.i
   187    %2 = fsub float %0, %1
   188    %3 = fmul float %x.r, %y.i
   189    %4 = fmul float %x.i, %y.r
   190    %5 = fadd float %3, %4
   191    %6 = insertvalue { float, float } undef, float %2, 0
   192    %7 = insertvalue { float, float } %6, float %5, 1
   193    ret { float, float } %7
   194  }
   195  
   196  ; Function Attrs: nounwind
   197  define hidden void @main.foo(ptr %context) unnamed_addr #2 {
   198  entry:
   199    call void @"main.foo$1"(%main.kv.0 zeroinitializer, ptr undef)
   200    ret void
   201  }
   202  
   203  ; Function Attrs: nounwind
   204  define internal void @"main.foo$1"(%main.kv.0 %b, ptr %context) unnamed_addr #2 {
   205  entry:
   206    ret void
   207  }
   208  
   209  attributes #0 = { allockind("alloc,zeroed") allocsize(0) "alloc-family"="runtime.alloc" "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }
   210  attributes #1 = { "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }
   211  attributes #2 = { nounwind "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }
   212  attributes #3 = { nounwind }