Advertisement
adilima

Gtk 3.0 Application Using LLVM Assembly

Dec 30th, 2014
3,359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
LLVM 3.11 KB | None | 0 0
  1.  
  2. @strTitle = private unnamed_addr constant [21 x i8] c"Gtk+-3.0 - LLVM Test\00"
  3. @strDestroy = private unnamed_addr constant [8 x i8] c"destroy\00"
  4. @strQuit = private unnamed_addr constant [5 x i8] c"Quit\00"
  5. @strPrompt = private unnamed_addr constant [104 x i8] c"This is an example of\0aLLVM program using Gtk+-3.0 Library\0awith GtkGrid holding a GtkLabel and GtkButton\00"
  6. @strClicked = private unnamed_addr constant [8 x i8] c"clicked\00"
  7. @strMargin = private unnamed_addr constant [7 x i8] c"margin\00"
  8.  
  9. define i32 @main(i32 %argc, i8** %argv) {
  10.   %arg1 = alloca i32
  11.   %arg2 = alloca i8**
  12.   store i32 %argc, i32* %arg1
  13.   store i8** %argv, i8*** %arg2
  14.   call void @gtk_init(i32* %arg1, i8*** %arg2)
  15.  
  16.   %window = call i8* @gtk_window_new(i32 0)  ; GTK_WINDOW_TOPLEVEL = 0
  17.   ; call void @gtk_window_set_default_size(i8* %window, i32 640, i32 480)
  18.   call void @gtk_window_set_title(i8* %window,
  19.     i8* getelementptr inbounds([21 x i8]* @strTitle, i32 0, i32 0))
  20.   %nRes = call i64 @g_signal_connect_data(i8* %window,
  21.     i8* getelementptr inbounds([8 x i8]* @strDestroy, i32 0, i32 0),
  22.     i8* bitcast(void ()* @gtk_main_quit to i8*),
  23.     i8* null,
  24.     i8* null,
  25.     i32 0)
  26.  
  27.   ; Grid container
  28.   %grid = call i8* @gtk_grid_new()
  29.   call void @gtk_container_add(i8* %window, i8* %grid)
  30.  
  31.   ; Button
  32.   %btn1 = call i8* @gtk_button_new_with_label(i8* getelementptr inbounds([5 x i8]* @strQuit, i32 0, i32 0))
  33.   %label = call i8* @gtk_label_new(i8* getelementptr inbounds([104 x i8]* @strPrompt, i32 0, i32 0))
  34.  
  35.   call void @gtk_grid_attach(i8* %grid, i8* %label,
  36.     i32 0, i32 0,
  37.     i32 5, i32 5)
  38.   call void @gtk_grid_attach(i8* %grid, i8* %btn1,
  39.     i32 4, i32 8,
  40.     i32 1, i32 1)
  41.  
  42.   call void @gtk_grid_set_row_spacing(i8* %grid, i32 5)
  43.   call void @gtk_grid_set_column_spacing(i8* %grid, i32 5)
  44.  
  45.   call void @g_object_set(i8* %label,
  46.     i8* getelementptr inbounds([7 x i8]* @strMargin, i32 0, i32 0),
  47.     i32 10, i8* null)
  48.  
  49.   ; Connect button_clicked to gtk_widget_destroy(window)
  50.   ; 3 == G_CONNECT_SWAPPED
  51.   ; The same as a macro g_signal_connect_swapped()
  52.   %tmp1 = call i64 @g_signal_connect_data(i8* %btn1,
  53.     i8* getelementptr inbounds([8 x i8]* @strClicked, i32 0, i32 0),
  54.     i8* bitcast(void (i8*)* @gtk_widget_destroy to i8*),
  55.     i8* %window,
  56.     i8* null,
  57.     i32 3)
  58.  
  59.   call void @gtk_widget_show_all(i8* %window)
  60.   call void @gtk_main()
  61.   ret i32 0
  62. }
  63.  
  64. declare void @gtk_init(i32*, i8***)
  65. declare void @gtk_window_set_title(i8*, i8*)
  66. declare i64 @g_signal_connect_data(i8*, i8*, i8*, i8*, i8*, i32)
  67. declare void @gtk_widget_show_all(i8*)
  68. declare void @gtk_main()
  69. declare void @gtk_main_quit()
  70. declare i8*  @gtk_grid_new()
  71. declare i8*  @gtk_label_new(i8*)
  72. declare void @gtk_grid_attach(i8*, i8*, i32, i32, i32, i32)
  73. declare void @gtk_container_add(i8*, i8*)
  74. declare void @gtk_widget_destroy(i8*)
  75.  
  76. declare void @g_object_set(i8*, i8*, i32, i8*)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement