SHARE
TWEET

Untitled

a guest Dec 13th, 2018 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ○ → cat test-list01.ll
  2. ; ModuleID = 'AP_PlusPlus'
  3. source_filename = "AP_PlusPlus"
  4.  
  5. @fmt = private unnamed_addr constant [4 x i8] c"%d\0A\00"
  6. @fmt.1 = private unnamed_addr constant [4 x i8] c"%g\0A\00"
  7. @fmt.2 = private unnamed_addr constant [4 x i8] c"%s\0A\00"
  8.  
  9. declare i32 @printf(i8*, ...)
  10.  
  11. define i32 @list_get_int32({ i32, i32, i32* }*, i32) {
  12. entry:
  13.   %list_ptr_alloc = alloca { i32, i32, i32* }*
  14.   store { i32, i32, i32* }* %0, { i32, i32, i32* }** %list_ptr_alloc
  15.   %idx_alloc = alloca i32
  16.   store i32 %1, i32* %idx_alloc
  17.   %list_load = load { i32, i32, i32* }*, { i32, i32, i32* }** %list_ptr_alloc
  18.   %list_array_ptr = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %list_load, i32 0, i32 2
  19.   %idx_load = load i32, i32* %idx_alloc
  20.   %list_arry_element_ptr = getelementptr i32*, i32** %list_array_ptr, i32 %idx_load
  21.   %list_array_element_ptr = load i32*, i32** %list_arry_element_ptr
  22.   %list_array_element = load i32, i32* %list_array_element_ptr
  23.   ret i32 %list_array_element
  24. }
  25.  
  26. define void @list_push_int32({ i32, i32, i32* }*, i32) {
  27. entry:
  28.   %list_ptr_alloc = alloca { i32, i32, i32* }*
  29.   store { i32, i32, i32* }* %0, { i32, i32, i32* }** %list_ptr_alloc
  30.   %val_alloc = alloca i32
  31.   store i32 %1, i32* %val_alloc
  32.   %list_load = load { i32, i32, i32* }*, { i32, i32, i32* }** %list_ptr_alloc
  33.   %list_array_ptr = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %list_load, i32 0, i32 2
  34.   %list_array_load = load i32*, i32** %list_array_ptr
  35.   %list_alloc_size = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %list_load, i32 0, i32 0
  36.   %list_size = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %list_load, i32 0, i32 1
  37.   %list_size1 = load i32, i32* %list_size
  38.   %list_arry_next_element_ptr = getelementptr i32, i32* %list_array_load, i32 %list_size1
  39.   %list_arry_next_element = load i32, i32* %list_arry_next_element_ptr
  40.   %inc_size = add i32 %list_size1, 1
  41.   store i32 %inc_size, i32* %list_size
  42.   %val = load i32, i32* %val_alloc
  43.   store i32 %val, i32* %list_arry_next_element_ptr
  44.   ret void
  45. }
  46.  
  47. define i32 @main() {
  48. entry:
  49.   %a = alloca { i32, i32, i32* }
  50.   %list.size = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %a, i32 0, i32 0
  51.   store i32 0, i32* %list.size
  52.   %list.size2 = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %a, i32 0, i32 1
  53.   store i32 0, i32* %list.size2
  54.   %list.arry = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %a, i32 0, i32 2
  55.   %p = alloca i32, i32 1000
  56.   store i32* %p, i32** %list.arry
  57.   call void @list_push_int32({ i32, i32, i32* }* %a, i32 42)
  58.   call void @list_push_int32({ i32, i32, i32* }* %a, i32 42)
  59.   call void @list_push_int32({ i32, i32, i32* }* %a, i32 42)
  60.   %list_get = call i32 @list_get_int32({ i32, i32, i32* }* %a, i32 0)
  61.   %printf = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @fmt, i32 0, i32 0), i32 %list_get)
  62.   ret i32 0
  63. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top