@@ -100,42 +100,6 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
100100 }
101101 }
102102
103- /// Gets declared value by name.
104- pub ( crate ) fn get_declared_value ( & self , name : & str ) -> Option < & ' ll Value > {
105- debug ! ( "get_declared_value(name={:?})" , name) ;
106- unsafe { llvm:: LLVMRustGetNamedValue ( self . llmod ( ) , name. as_c_char_ptr ( ) , name. len ( ) ) }
107- }
108-
109- /// Gets defined or externally defined (AvailableExternally linkage) value by
110- /// name.
111- pub ( crate ) fn get_defined_value ( & self , name : & str ) -> Option < & ' ll Value > {
112- self . get_declared_value ( name) . and_then ( |val| {
113- let declaration = llvm:: is_declaration ( val) ;
114- if !declaration { Some ( val) } else { None }
115- } )
116- }
117-
118- /// Declare a global with an intention to define it.
119- ///
120- /// Use this function when you intend to define a global. This function will
121- /// return `None` if the name already has a definition associated with it. In that
122- /// case an error should be reported to the user, because it usually happens due
123- /// to user’s fault (e.g., misuse of `#[no_mangle]` or `#[export_name]` attributes).
124- pub ( crate ) fn define_global ( & self , name : & str , ty : & ' ll Type ) -> Option < & ' ll Value > {
125- if self . get_defined_value ( name) . is_some ( ) {
126- None
127- } else {
128- Some ( self . declare_global ( name, ty) )
129- }
130- }
131-
132- /// Declare a private global
133- ///
134- /// Use this function when you intend to define a global without a name.
135- pub ( crate ) fn define_private_global ( & self , ty : & ' ll Type ) -> & ' ll Value {
136- unsafe { llvm:: LLVMRustInsertPrivateGlobal ( self . llmod ( ) , ty) }
137- }
138-
139103}
140104
141105impl < ' ll , ' tcx > CodegenCx < ' ll , ' tcx > {
@@ -253,3 +217,41 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
253217 llfn
254218 }
255219}
220+
221+ impl < ' ll , CX : Borrow < SCx < ' ll > > > GenericCx < ' ll , CX > {
222+ /// Gets declared value by name.
223+ pub ( crate ) fn get_declared_value ( & self , name : & str ) -> Option < & ' ll Value > {
224+ debug ! ( "get_declared_value(name={:?})" , name) ;
225+ unsafe { llvm:: LLVMRustGetNamedValue ( self . llmod ( ) , name. as_c_char_ptr ( ) , name. len ( ) ) }
226+ }
227+
228+ /// Gets defined or externally defined (AvailableExternally linkage) value by
229+ /// name.
230+ pub ( crate ) fn get_defined_value ( & self , name : & str ) -> Option < & ' ll Value > {
231+ self . get_declared_value ( name) . and_then ( |val| {
232+ let declaration = llvm:: is_declaration ( val) ;
233+ if !declaration { Some ( val) } else { None }
234+ } )
235+ }
236+
237+ /// Declare a global with an intention to define it.
238+ ///
239+ /// Use this function when you intend to define a global. This function will
240+ /// return `None` if the name already has a definition associated with it. In that
241+ /// case an error should be reported to the user, because it usually happens due
242+ /// to user’s fault (e.g., misuse of `#[no_mangle]` or `#[export_name]` attributes).
243+ pub ( crate ) fn define_global ( & self , name : & str , ty : & ' ll Type ) -> Option < & ' ll Value > {
244+ if self . get_defined_value ( name) . is_some ( ) {
245+ None
246+ } else {
247+ Some ( self . declare_global ( name, ty) )
248+ }
249+ }
250+
251+ /// Declare a private global
252+ ///
253+ /// Use this function when you intend to define a global without a name.
254+ pub ( crate ) fn define_private_global ( & self , ty : & ' ll Type ) -> & ' ll Value {
255+ unsafe { llvm:: LLVMRustInsertPrivateGlobal ( self . llmod ( ) , ty) }
256+ }
257+ }
0 commit comments