1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
; ModuleID = 'LFortran'
source_filename = "LFortran"
%base_class = type <{ i32 (...)**, %base* }>
%base = type { i32 }
%string_descriptor = type <{ i8*, i64 }>
@_Name_base = private unnamed_addr constant [5 x i8] c"base\00", align 1
@_Type_Info_base = linkonce_odr unnamed_addr constant { i8* } { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @_Name_base, i32 0, i32 0) }, align 8
@_VTable_base = linkonce_odr unnamed_addr constant { [5 x i8*] } { [5 x i8*] [i8* null, i8* bitcast ({ i8* }* @_Type_Info_base to i8*), i8* bitcast (void (i8*, i8*)* @_copy_xx_base to i8*), i8* bitcast (void (i8**)* @_allocate_struct_xx_base to i8*), i8* bitcast (void (%base_class*)* @__module_xx_show_x to i8*)] }, align 8
@0 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
@serialization_info = private unnamed_addr constant [3 x i8] c"I4\00", align 1
@1 = private unnamed_addr constant [5 x i8] c"%s%s\00", align 1
@"ERROR STOP" = private unnamed_addr constant [11 x i8] c"ERROR STOP\00", align 1
@2 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
@3 = private unnamed_addr constant [5 x i8] c"%s%s\00", align 1
define void @__module_xx_show_x(%base_class* %this) {
.entry:
%0 = getelementptr %base_class, %base_class* %this, i32 0, i32 1
%1 = load %base*, %base** %0, align 8
%2 = getelementptr %base, %base* %1, i32 0, i32 0
store i32 12, i32* %2, align 4
br label %return
return: ; preds = %.entry
br label %FINALIZE_SYMTABLE_show_x
FINALIZE_SYMTABLE_show_x: ; preds = %return
ret void
}
define i32 @main(i32 %0, i8** %1) {
.entry:
call void @_lpython_call_initial_functions(i32 %0, i8** %1)
%b = alloca %base, align 8
%2 = getelementptr %base, %base* %b, i32 0, i32 0
%3 = getelementptr %base, %base* %b, i32 0, i32 0
store i32 10, i32* %3, align 4
%4 = alloca %base_class, align 8
%5 = getelementptr %base_class, %base_class* %4, i32 0, i32 0
store i32 (...)** bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* @_VTable_base, i32 0, i32 0, i32 2) to i32 (...)**), i32 (...)*** %5, align 8
%6 = getelementptr %base_class, %base_class* %4, i32 0, i32 1
store %base* %b, %base** %6, align 8
call void @__module_xx_show_x(%base_class* %4)
%7 = alloca i64, align 8
%8 = getelementptr %base, %base* %b, i32 0, i32 0
%9 = load i32, i32* %8, align 4
%10 = alloca i32, align 4
store i32 %9, i32* %10, align 4
%11 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @serialization_info, i32 0, i32 0), i64* %7, i32 0, i32 0, i32* %10)
%12 = load i64, i64* %7, align 4
%stringFormat_desc = alloca %string_descriptor, align 8
%13 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc, i32 0, i32 0
store i8* %11, i8** %13, align 8
%14 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc, i32 0, i32 1
store i64 %12, i64* %14, align 4
%15 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc, i32 0, i32 0
%16 = load i8*, i8** %15, align 8
%17 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc, i32 0, i32 1
%18 = load i64, i64* %17, align 4
%19 = trunc i64 %18 to i32
call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @1, i32 0, i32 0), i8* %16, i32 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0), i32 1)
call void @_lfortran_free(i8* %11)
%20 = getelementptr %base, %base* %b, i32 0, i32 0
%21 = load i32, i32* %20, align 4
%22 = icmp ne i32 %21, 12
br i1 %22, label %then, label %else
then: ; preds = %.entry
call void (i8*, ...) @_lcompilers_print_error(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @3, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @"ERROR STOP", i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @2, i32 0, i32 0))
call void @exit(i32 1)
br label %ifcont
else: ; preds = %.entry
br label %ifcont
ifcont: ; preds = %else, %then
call void @_lpython_free_argv()
br label %return
return: ; preds = %ifcont
br label %FINALIZE_SYMTABLE_main
FINALIZE_SYMTABLE_main: ; preds = %return
ret i32 0
}
declare void @_lpython_call_initial_functions(i32, i8**)
define linkonce_odr void @_copy_xx_base(i8* %0, i8* %1) {
entry:
%2 = bitcast i8* %0 to %base*
%3 = bitcast i8* %1 to %base*
%4 = getelementptr %base, %base* %2, i32 0, i32 0
%5 = load i32, i32* %4, align 4
%6 = getelementptr %base, %base* %3, i32 0, i32 0
br i1 true, label %then, label %else
then: ; preds = %entry
store i32 %5, i32* %6, align 4
br label %ifcont
else: ; preds = %entry
br label %ifcont
ifcont: ; preds = %else, %then
ret void
}
define linkonce_odr void @_allocate_struct_xx_base(i8** %0) {
entry:
%1 = call i8* @_lfortran_malloc(i64 16)
call void @llvm.memset.p0i8.i32(i8* %1, i8 0, i32 16, i1 false)
store i8* %1, i8** %0, align 8
%2 = load i8*, i8** %0, align 8
%3 = bitcast i8* %2 to %base_class*
%4 = bitcast %base_class* %3 to i32 (...)***
store i32 (...)** bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* @_VTable_base, i32 0, i32 0, i32 2) to i32 (...)**), i32 (...)*** %4, align 8
%5 = getelementptr %base_class, %base_class* %3, i32 0, i32 1
%6 = call i8* @_lfortran_malloc(i64 4)
call void @llvm.memset.p0i8.i32(i8* %6, i8 0, i32 4, i1 false)
%7 = bitcast i8* %6 to %base*
store %base* %7, %base** %5, align 8
%8 = getelementptr %base, %base* %7, i32 0, i32 0
ret void
}
declare i8* @_lfortran_malloc(i64)
; Function Attrs: argmemonly nounwind willreturn writeonly
declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1 immarg) #0
declare i8* @_lcompilers_string_format_fortran(i8*, i64, i8*, i64*, i32, i32, ...)
declare void @_lfortran_printf(i8*, i8*, i32, i8*, i32)
declare void @_lfortran_free(i8*)
declare void @_lcompilers_print_error(i8*, ...)
declare void @exit(i32)
declare void @_lpython_free_argv()
attributes #0 = { argmemonly nounwind willreturn writeonly }
|