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

     1  ; ModuleID = 'string.go'
     2  source_filename = "string.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  %runtime._string = type { ptr, i32 }
     7  
     8  @"main$string" = internal unnamed_addr constant [3 x i8] c"foo", align 1
     9  
    10  ; Function Attrs: allockind("alloc,zeroed") allocsize(0)
    11  declare noalias nonnull ptr @runtime.alloc(i32, ptr, ptr) #0
    12  
    13  declare void @runtime.trackPointer(ptr nocapture readonly, ptr, ptr) #1
    14  
    15  ; Function Attrs: nounwind
    16  define hidden void @main.init(ptr %context) unnamed_addr #2 {
    17  entry:
    18    ret void
    19  }
    20  
    21  ; Function Attrs: nounwind
    22  define hidden %runtime._string @main.someString(ptr %context) unnamed_addr #2 {
    23  entry:
    24    ret %runtime._string { ptr @"main$string", i32 3 }
    25  }
    26  
    27  ; Function Attrs: nounwind
    28  define hidden %runtime._string @main.zeroLengthString(ptr %context) unnamed_addr #2 {
    29  entry:
    30    ret %runtime._string zeroinitializer
    31  }
    32  
    33  ; Function Attrs: nounwind
    34  define hidden i32 @main.stringLen(ptr %s.data, i32 %s.len, ptr %context) unnamed_addr #2 {
    35  entry:
    36    ret i32 %s.len
    37  }
    38  
    39  ; Function Attrs: nounwind
    40  define hidden i8 @main.stringIndex(ptr %s.data, i32 %s.len, i32 %index, ptr %context) unnamed_addr #2 {
    41  entry:
    42    %.not = icmp ult i32 %index, %s.len
    43    br i1 %.not, label %lookup.next, label %lookup.throw
    44  
    45  lookup.next:                                      ; preds = %entry
    46    %0 = getelementptr inbounds i8, ptr %s.data, i32 %index
    47    %1 = load i8, ptr %0, align 1
    48    ret i8 %1
    49  
    50  lookup.throw:                                     ; preds = %entry
    51    call void @runtime.lookupPanic(ptr undef) #3
    52    unreachable
    53  }
    54  
    55  declare void @runtime.lookupPanic(ptr) #1
    56  
    57  ; Function Attrs: nounwind
    58  define hidden i1 @main.stringCompareEqual(ptr %s1.data, i32 %s1.len, ptr %s2.data, i32 %s2.len, ptr %context) unnamed_addr #2 {
    59  entry:
    60    %0 = call i1 @runtime.stringEqual(ptr %s1.data, i32 %s1.len, ptr %s2.data, i32 %s2.len, ptr undef) #3
    61    ret i1 %0
    62  }
    63  
    64  declare i1 @runtime.stringEqual(ptr, i32, ptr, i32, ptr) #1
    65  
    66  ; Function Attrs: nounwind
    67  define hidden i1 @main.stringCompareUnequal(ptr %s1.data, i32 %s1.len, ptr %s2.data, i32 %s2.len, ptr %context) unnamed_addr #2 {
    68  entry:
    69    %0 = call i1 @runtime.stringEqual(ptr %s1.data, i32 %s1.len, ptr %s2.data, i32 %s2.len, ptr undef) #3
    70    %1 = xor i1 %0, true
    71    ret i1 %1
    72  }
    73  
    74  ; Function Attrs: nounwind
    75  define hidden i1 @main.stringCompareLarger(ptr %s1.data, i32 %s1.len, ptr %s2.data, i32 %s2.len, ptr %context) unnamed_addr #2 {
    76  entry:
    77    %0 = call i1 @runtime.stringLess(ptr %s2.data, i32 %s2.len, ptr %s1.data, i32 %s1.len, ptr undef) #3
    78    ret i1 %0
    79  }
    80  
    81  declare i1 @runtime.stringLess(ptr, i32, ptr, i32, ptr) #1
    82  
    83  ; Function Attrs: nounwind
    84  define hidden i8 @main.stringLookup(ptr %s.data, i32 %s.len, i8 %x, ptr %context) unnamed_addr #2 {
    85  entry:
    86    %0 = zext i8 %x to i32
    87    %.not = icmp ult i32 %0, %s.len
    88    br i1 %.not, label %lookup.next, label %lookup.throw
    89  
    90  lookup.next:                                      ; preds = %entry
    91    %1 = getelementptr inbounds i8, ptr %s.data, i32 %0
    92    %2 = load i8, ptr %1, align 1
    93    ret i8 %2
    94  
    95  lookup.throw:                                     ; preds = %entry
    96    call void @runtime.lookupPanic(ptr undef) #3
    97    unreachable
    98  }
    99  
   100  attributes #0 = { allockind("alloc,zeroed") allocsize(0) "alloc-family"="runtime.alloc" "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }
   101  attributes #1 = { "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }
   102  attributes #2 = { nounwind "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }
   103  attributes #3 = { nounwind }