SHARE
TWEET

Untitled

a guest Dec 13th, 2018 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ModuleID = 'AP_PlusPlus'
  2. source_filename = "AP_PlusPlus"
  3.  
  4. @fmt = private unnamed_addr constant [4 x i8] c"%d\0A\00"
  5. @fmt.1 = private unnamed_addr constant [4 x i8] c"%g\0A\00"
  6. @fmt.2 = private unnamed_addr constant [4 x i8] c"%s\0A\00"
  7.  
  8. declare i32 @printf(i8*, ...)
  9.  
  10. define i32 @list_get_int32({ i32, i32, i32* }*, i32) {
  11. entry:
  12.   %list_ptr_alloc = alloca { i32, i32, i32* }*
  13.   store { i32, i32, i32* }* %0, { i32, i32, i32* }** %list_ptr_alloc
  14.   %idx_alloc = alloca i32
  15.   store i32 %1, i32* %idx_alloc
  16.   %list_load = load { i32, i32, i32* }*, { i32, i32, i32* }** %list_ptr_alloc
  17.   %list_array_ptr = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %list_load, i32 0, i32 2
  18.   %idx_load = load i32, i32* %idx_alloc
  19.   %list_arry_element_ptr = getelementptr i32*, i32** %list_array_ptr, i32 %idx_load
  20.   %list_array_element_ptr = load i32*, i32** %list_arry_element_ptr
  21.   %list_array_element = load i32, i32* %list_array_element_ptr
  22.   ret i32 %list_array_element
  23. }
  24.  
  25. define void @list_push_int32({ i32, i32, i32* }*, i32) {
  26. entry:
  27.   %list_ptr_alloc = alloca { i32, i32, i32* }*
  28.   store { i32, i32, i32* }* %0, { i32, i32, i32* }** %list_ptr_alloc
  29.   %val_alloc = alloca i32
  30.   store i32 %1, i32* %val_alloc
  31.   %list_load = load { i32, i32, i32* }*, { i32, i32, i32* }** %list_ptr_alloc
  32.   %list_array_ptr = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %list_load, i32 0, i32 2
  33.   %list_array_load = load i32*, i32** %list_array_ptr
  34.   %list_alloc_size = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %list_load, i32 0, i32 0
  35.   %list_size = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %list_load, i32 0, i32 1
  36.   %list_size1 = load i32, i32* %list_size
  37.   %list_arry_next_element_ptr = getelementptr i32, i32* %list_array_load, i32 %list_size1
  38.   %list_arry_next_element = load i32, i32* %list_arry_next_element_ptr
  39.   %inc_size = add i32 %list_size1, 1
  40.   store i32 %inc_size, i32* %list_size
  41.   %val = load i32, i32* %val_alloc
  42.   store i32 %val, i32* %list_arry_next_element_ptr
  43.   ret void
  44. }
  45.  
  46. define i32 @main() {
  47. entry:
  48.   %a = alloca { i32, i32, i32* }
  49.   %list.size = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %a, i32 0, i32 0
  50.   store i32 0, i32* %list.size
  51.   %list.size2 = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %a, i32 0, i32 1
  52.   store i32 0, i32* %list.size2
  53.   %list.arry = getelementptr inbounds { i32, i32, i32* }, { i32, i32, i32* }* %a, i32 0, i32 2
  54.   %p = alloca [3 x i32]
  55.   %p_cast = bitcast i32** %list.arry to [3 x i32]**
  56.   store [3 x i32]* %p, [3 x i32]** %p_cast
  57.   %list_get = call i32 @list_get_int32({ i32, i32, i32* }* %a, i32 0)
  58.   %printf = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @fmt, i32 0, i32 0), i32 %list_get)
  59.   ret i32 0
  60. }
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