@@ -23,6 +23,7 @@ fn create_struct_ty<'ll>(
23
23
entry_struct
24
24
}
25
25
}
26
+ //const DATA_NULL: &[u8] = c"111111";
26
27
27
28
// We don't copy types from other functions because we generate a new module and context.
28
29
// Bringing in types from other contexts would likely cause issues.
@@ -100,10 +101,43 @@ pub(crate) fn gen_image_wrapper_module<'ll>(
100
101
llvm:: Visibility :: Default ,
101
102
mapper_fn_ty,
102
103
) ;
104
+ let baz = crate :: declare:: declare_simple_fn (
105
+ & cx,
106
+ & "atexit" ,
107
+ llvm:: CallConv :: CCallConv ,
108
+ llvm:: UnnamedAddr :: No ,
109
+ llvm:: Visibility :: Default ,
110
+ cx. type_func ( & [ tptr] , ti32) ,
111
+ ) ;
103
112
104
- // @__start_omp_offloading_entries = external hidden constant [0 x %struct.__tgt_offload_entry]
105
- // @__stop_omp_offloading_entries = external hidden constant [0 x %struct.__tgt_offload_entry]
106
- // @__dummy.omp_offloading_entries = internal constant [0 x %struct.__tgt_offload_entry] zeroinitializer, section "omp_offloading_entries"
113
+ let unknown_txt = "11111111111111" ;
114
+ let c_entry_name = CString :: new ( unknown_txt) . unwrap ( ) ;
115
+ let c_val = c_entry_name. as_bytes_with_nul ( ) ;
116
+ let initializer = crate :: common:: bytes_in_context ( cx. llcx , c_val) ;
117
+ let llglobal =
118
+ add_unnamed_global ( & cx, & ".omp_offloading.device_image" , initializer, InternalLinkage ) ;
119
+ let c_section_name = CString :: new ( ".llvm.offloading" ) . unwrap ( ) ;
120
+ llvm:: set_section ( llglobal, & c_section_name) ;
121
+ llvm:: set_alignment ( llglobal, Align :: EIGHT ) ;
122
+
123
+ //@.omp_offloading.device_image = internal unnamed_addr constant [4040 x i8] c"111111111", section ".llvm.offloading", align 8
124
+ // TODO
125
+ // @.omp_offloading.device_images = internal unnamed_addr constant [1 x %__tgt_device_image] [%__tgt_device_image { ptr getelementptr ([4040 x i8], ptr @.omp_offloading.device_image, i64 0, i64 144), ptr getelementptr ([4040 x i8], ptr @.omp_offloading.device_image, i64 0, i64 4040), ptr @__start_omp_offloading_entries, ptr @__stop_omp_offloading_entries }]
126
+ // @.omp_offloading.descriptor = internal constant %__tgt_bin_desc { i32 1, ptr @.omp_offloading.device_images, ptr @__start_omp_offloading_entries, ptr @__stop_omp_offloading_entries }
127
+ // @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 101, ptr @.omp_offloading.descriptor_reg, ptr null }]
128
+ //
129
+ // define internal void @.omp_offloading.descriptor_reg() section ".text.startup" {
130
+ // entry:
131
+ // call void @__tgt_register_lib(ptr @.omp_offloading.descriptor)
132
+ // %0 = call i32 @atexit(ptr @.omp_offloading.descriptor_unreg)
133
+ // ret void
134
+ // }
135
+ //
136
+ // define internal void @.omp_offloading.descriptor_unreg() section ".text.startup" {
137
+ // entry:
138
+ // call void @__tgt_unregister_lib(ptr @.omp_offloading.descriptor)
139
+ // ret void
140
+ // }
107
141
108
142
llvm:: LLVMPrintModuleToFile (
109
143
llmod,
0 commit comments