github.com/goplus/llgo@v0.8.3/cl/_testrt/intgen/out.ll (about)

     1  ; ModuleID = 'main'
     2  source_filename = "main"
     3  
     4  %"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
     5  %main.generator = type { i32 }
     6  
     7  @"main.init$guard" = global ptr null
     8  @__llgo_argc = global ptr null
     9  @__llgo_argv = global ptr null
    10  @0 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
    11  @1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
    12  @2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
    13  
    14  define %"github.com/goplus/llgo/internal/runtime.Slice" @main.genInts(i64 %0, { ptr, ptr } %1) {
    15  _llgo_0:
    16    %2 = mul i64 %0, 4
    17    %3 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 %2)
    18    %4 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice"(ptr %3, i64 %0, i64 %0)
    19    %5 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %4, 1
    20    br label %_llgo_1
    21  
    22  _llgo_1:                                          ; preds = %_llgo_2, %_llgo_0
    23    %6 = phi i64 [ -1, %_llgo_0 ], [ %7, %_llgo_2 ]
    24    %7 = add i64 %6, 1
    25    %8 = icmp slt i64 %7, %5
    26    br i1 %8, label %_llgo_2, label %_llgo_3
    27  
    28  _llgo_2:                                          ; preds = %_llgo_1
    29    %9 = extractvalue { ptr, ptr } %1, 1
    30    %10 = extractvalue { ptr, ptr } %1, 0
    31    %11 = call i32 %10(ptr %9)
    32    %12 = icmp slt i64 %7, 0
    33    call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %12)
    34    %13 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %4, 0
    35    %14 = getelementptr inbounds i32, ptr %13, i64 %7
    36    store i32 %11, ptr %14, align 4
    37    br label %_llgo_1
    38  
    39  _llgo_3:                                          ; preds = %_llgo_1
    40    ret %"github.com/goplus/llgo/internal/runtime.Slice" %4
    41  }
    42  
    43  define i32 @"(*main.generator).next"(ptr %0) {
    44  _llgo_0:
    45    %1 = getelementptr inbounds %main.generator, ptr %0, i32 0, i32 0
    46    %2 = load i32, ptr %1, align 4
    47    %3 = add i32 %2, 1
    48    %4 = getelementptr inbounds %main.generator, ptr %0, i32 0, i32 0
    49    store i32 %3, ptr %4, align 4
    50    %5 = getelementptr inbounds %main.generator, ptr %0, i32 0, i32 0
    51    %6 = load i32, ptr %5, align 4
    52    ret i32 %6
    53  }
    54  
    55  define void @main.init() {
    56  _llgo_0:
    57    %0 = load i1, ptr @"main.init$guard", align 1
    58    br i1 %0, label %_llgo_2, label %_llgo_1
    59  
    60  _llgo_1:                                          ; preds = %_llgo_0
    61    store i1 true, ptr @"main.init$guard", align 1
    62    br label %_llgo_2
    63  
    64  _llgo_2:                                          ; preds = %_llgo_1, %_llgo_0
    65    ret void
    66  }
    67  
    68  define i32 @main(i32 %0, ptr %1) {
    69  _llgo_0:
    70    store i32 %0, ptr @__llgo_argc, align 4
    71    store ptr %1, ptr @__llgo_argv, align 8
    72    call void @"github.com/goplus/llgo/internal/runtime.init"()
    73    call void @main.init()
    74    %2 = alloca { ptr, ptr }, align 8
    75    %3 = getelementptr inbounds { ptr, ptr }, ptr %2, i32 0, i32 0
    76    store ptr @__llgo_stub.rand, ptr %3, align 8
    77    %4 = getelementptr inbounds { ptr, ptr }, ptr %2, i32 0, i32 1
    78    store ptr null, ptr %4, align 8
    79    %5 = load { ptr, ptr }, ptr %2, align 8
    80    %6 = call %"github.com/goplus/llgo/internal/runtime.Slice" @main.genInts(i64 5, { ptr, ptr } %5)
    81    %7 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %6, 1
    82    br label %_llgo_1
    83  
    84  _llgo_1:                                          ; preds = %_llgo_2, %_llgo_0
    85    %8 = phi i64 [ -1, %_llgo_0 ], [ %9, %_llgo_2 ]
    86    %9 = add i64 %8, 1
    87    %10 = icmp slt i64 %9, %7
    88    br i1 %10, label %_llgo_2, label %_llgo_3
    89  
    90  _llgo_2:                                          ; preds = %_llgo_1
    91    %11 = icmp slt i64 %9, 0
    92    call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %11)
    93    %12 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %6, 0
    94    %13 = getelementptr inbounds i32, ptr %12, i64 %9
    95    %14 = load i32, ptr %13, align 4
    96    %15 = call i32 (ptr, ...) @printf(ptr @0, i32 %14)
    97    br label %_llgo_1
    98  
    99  _llgo_3:                                          ; preds = %_llgo_1
   100    %16 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 4)
   101    store i32 1, ptr %16, align 4
   102    %17 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
   103    %18 = getelementptr inbounds { ptr }, ptr %17, i32 0, i32 0
   104    store ptr %16, ptr %18, align 8
   105    %19 = alloca { ptr, ptr }, align 8
   106    %20 = getelementptr inbounds { ptr, ptr }, ptr %19, i32 0, i32 0
   107    store ptr @"main.main$1", ptr %20, align 8
   108    %21 = getelementptr inbounds { ptr, ptr }, ptr %19, i32 0, i32 1
   109    store ptr %17, ptr %21, align 8
   110    %22 = load { ptr, ptr }, ptr %19, align 8
   111    %23 = call %"github.com/goplus/llgo/internal/runtime.Slice" @main.genInts(i64 5, { ptr, ptr } %22)
   112    %24 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %23, 1
   113    br label %_llgo_4
   114  
   115  _llgo_4:                                          ; preds = %_llgo_5, %_llgo_3
   116    %25 = phi i64 [ -1, %_llgo_3 ], [ %26, %_llgo_5 ]
   117    %26 = add i64 %25, 1
   118    %27 = icmp slt i64 %26, %24
   119    br i1 %27, label %_llgo_5, label %_llgo_6
   120  
   121  _llgo_5:                                          ; preds = %_llgo_4
   122    %28 = icmp slt i64 %26, 0
   123    call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %28)
   124    %29 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %23, 0
   125    %30 = getelementptr inbounds i32, ptr %29, i64 %26
   126    %31 = load i32, ptr %30, align 4
   127    %32 = call i32 (ptr, ...) @printf(ptr @1, i32 %31)
   128    br label %_llgo_4
   129  
   130  _llgo_6:                                          ; preds = %_llgo_4
   131    %33 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 4)
   132    %34 = getelementptr inbounds %main.generator, ptr %33, i32 0, i32 0
   133    store i32 1, ptr %34, align 4
   134    %35 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
   135    %36 = getelementptr inbounds { ptr }, ptr %35, i32 0, i32 0
   136    store ptr %33, ptr %36, align 8
   137    %37 = alloca { ptr, ptr }, align 8
   138    %38 = getelementptr inbounds { ptr, ptr }, ptr %37, i32 0, i32 0
   139    store ptr @"main.next$bound", ptr %38, align 8
   140    %39 = getelementptr inbounds { ptr, ptr }, ptr %37, i32 0, i32 1
   141    store ptr %35, ptr %39, align 8
   142    %40 = load { ptr, ptr }, ptr %37, align 8
   143    %41 = call %"github.com/goplus/llgo/internal/runtime.Slice" @main.genInts(i64 5, { ptr, ptr } %40)
   144    %42 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %41, 1
   145    br label %_llgo_7
   146  
   147  _llgo_7:                                          ; preds = %_llgo_8, %_llgo_6
   148    %43 = phi i64 [ -1, %_llgo_6 ], [ %44, %_llgo_8 ]
   149    %44 = add i64 %43, 1
   150    %45 = icmp slt i64 %44, %42
   151    br i1 %45, label %_llgo_8, label %_llgo_9
   152  
   153  _llgo_8:                                          ; preds = %_llgo_7
   154    %46 = icmp slt i64 %44, 0
   155    call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %46)
   156    %47 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %41, 0
   157    %48 = getelementptr inbounds i32, ptr %47, i64 %44
   158    %49 = load i32, ptr %48, align 4
   159    %50 = call i32 (ptr, ...) @printf(ptr @2, i32 %49)
   160    br label %_llgo_7
   161  
   162  _llgo_9:                                          ; preds = %_llgo_7
   163    ret i32 0
   164  }
   165  
   166  declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
   167  
   168  declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice"(ptr, i64, i64)
   169  
   170  declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1)
   171  
   172  declare void @"github.com/goplus/llgo/internal/runtime.init"()
   173  
   174  declare i32 @rand()
   175  
   176  define linkonce i32 @__llgo_stub.rand(ptr %0) {
   177  _llgo_0:
   178    %1 = tail call i32 @rand()
   179    ret i32 %1
   180  }
   181  
   182  declare i32 @printf(ptr, ...)
   183  
   184  define i32 @"main.main$1"(ptr %0) {
   185  _llgo_0:
   186    %1 = load { ptr }, ptr %0, align 8
   187    %2 = extractvalue { ptr } %1, 0
   188    %3 = load i32, ptr %2, align 4
   189    %4 = mul i32 %3, 2
   190    %5 = extractvalue { ptr } %1, 0
   191    store i32 %4, ptr %5, align 4
   192    %6 = extractvalue { ptr } %1, 0
   193    %7 = load i32, ptr %6, align 4
   194    ret i32 %7
   195  }
   196  
   197  declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
   198  
   199  define i32 @"main.next$bound"(ptr %0) {
   200  _llgo_0:
   201    %1 = load { ptr }, ptr %0, align 8
   202    %2 = extractvalue { ptr } %1, 0
   203    %3 = call i32 @"(*main.generator).next"(ptr %2)
   204    ret i32 %3
   205  }