]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_ast/src/expand/allocator.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / compiler / rustc_ast / src / expand / allocator.rs
CommitLineData
dfeec247 1use rustc_span::symbol::{sym, Symbol};
416331ca 2
136023e0 3#[derive(Clone, Debug, Copy, HashStable_Generic)]
416331ca
XL
4pub enum AllocatorKind {
5 Global,
60c5eb7d 6 Default,
416331ca
XL
7}
8
9impl AllocatorKind {
3dfed10e 10 pub fn fn_name(&self, base: Symbol) -> String {
416331ca 11 match *self {
f25598a0
FG
12 AllocatorKind::Global => format!("__rg_{base}"),
13 AllocatorKind::Default => format!("__rdl_{base}"),
416331ca
XL
14 }
15 }
16}
17
18pub enum AllocatorTy {
19 Layout,
20 Ptr,
21 ResultPtr,
22 Unit,
23 Usize,
24}
25
26pub struct AllocatorMethod {
3dfed10e 27 pub name: Symbol,
416331ca
XL
28 pub inputs: &'static [AllocatorTy],
29 pub output: AllocatorTy,
30}
31
32pub static ALLOCATOR_METHODS: &[AllocatorMethod] = &[
33 AllocatorMethod {
3dfed10e 34 name: sym::alloc,
416331ca
XL
35 inputs: &[AllocatorTy::Layout],
36 output: AllocatorTy::ResultPtr,
37 },
38 AllocatorMethod {
3dfed10e 39 name: sym::dealloc,
416331ca
XL
40 inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout],
41 output: AllocatorTy::Unit,
42 },
43 AllocatorMethod {
3dfed10e 44 name: sym::realloc,
416331ca
XL
45 inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Usize],
46 output: AllocatorTy::ResultPtr,
47 },
48 AllocatorMethod {
3dfed10e 49 name: sym::alloc_zeroed,
416331ca
XL
50 inputs: &[AllocatorTy::Layout],
51 output: AllocatorTy::ResultPtr,
52 },
53];