]>
git.proxmox.com Git - rustc.git/blob - src/librustc_codegen_ssa/traits/declare.rs
1 use super::BackendTypes
;
2 use rustc_hir
::def_id
::DefId
;
3 use rustc_middle
::mir
::mono
::{Linkage, Visibility}
;
4 use rustc_middle
::ty
::{Instance, Ty}
;
5 use rustc_target
::abi
::call
::FnAbi
;
7 pub trait DeclareMethods
<'tcx
>: BackendTypes
{
8 /// Declare a global value.
10 /// If there’s a value with the same name already declared, the function will
11 /// return its Value instead.
12 fn declare_global(&self, name
: &str, ty
: Self::Type
) -> Self::Value
;
14 /// Declare a C ABI function.
16 /// Only use this for foreign function ABIs and glue. For Rust functions use
17 /// `declare_fn` instead.
19 /// If there’s a value with the same name already declared, the function will
20 /// update the declaration and return existing Value instead.
21 fn declare_cfn(&self, name
: &str, fn_type
: Self::Type
) -> Self::Function
;
23 /// Declare a Rust function.
25 /// If there’s a value with the same name already declared, the function will
26 /// update the declaration and return existing Value instead.
27 fn declare_fn(&self, name
: &str, fn_abi
: &FnAbi
<'tcx
, Ty
<'tcx
>>) -> Self::Function
;
29 /// Declare a global with an intention to define it.
31 /// Use this function when you intend to define a global. This function will
32 /// return `None` if the name already has a definition associated with it. In that
33 /// case an error should be reported to the user, because it usually happens due
34 /// to user’s fault (e.g., misuse of #[no_mangle] or #[export_name] attributes).
35 fn define_global(&self, name
: &str, ty
: Self::Type
) -> Option
<Self::Value
>;
37 /// Declare a private global
39 /// Use this function when you intend to define a global without a name.
40 fn define_private_global(&self, ty
: Self::Type
) -> Self::Value
;
42 /// Gets declared value by name.
43 fn get_declared_value(&self, name
: &str) -> Option
<Self::Value
>;
45 /// Gets defined or externally defined (AvailableExternally linkage) value by
47 fn get_defined_value(&self, name
: &str) -> Option
<Self::Value
>;
50 pub trait PreDefineMethods
<'tcx
>: BackendTypes
{
55 visibility
: Visibility
,
60 instance
: Instance
<'tcx
>,
62 visibility
: Visibility
,