1use super::*;
4use super::c_api::*;
5
6pub fn create_named_struct<S>(name: S) -> Type where S: AsRef<str> {
8 Type {
9 ty: unsafe {
10 LLVMStructCreateNamed(context(), into_c(name).as_ptr())
11 }
12 }
13}
14
15pub fn ty_array(ty: Type, count: u32) -> Type {
17 Type {
18 ty: unsafe {
19 LLVMArrayType(ty.ty, count)
20 }
21 }
22}
23
24pub fn ty_struct(elements: Vec<Type>, packed: bool) -> Type {
26 Type {
27 ty: unsafe {
28 LLVMStructTypeInContext(context(), ty_vec(&elements).as_mut_ptr(), elements.len() as u32, packed as i32)
29 }
30 }
31}
32
33pub fn ty_void() -> Type {
35 Type {
36 ty: unsafe {
37 LLVMVoidTypeInContext(context())
38 }
39 }
40}
41
42pub fn ty_i1() -> Type {
44 Type {
45 ty: unsafe {
46 LLVMInt1TypeInContext(context())
47 }
48 }
49}
50
51pub fn ty_i8() -> Type {
53 Type {
54 ty: unsafe {
55 LLVMInt8TypeInContext(context())
56 }
57 }
58}
59
60pub fn ty_i16() -> Type {
62 Type {
63 ty: unsafe {
64 LLVMInt16TypeInContext(context())
65 }
66 }
67}
68
69pub fn ty_i32() -> Type {
71 Type {
72 ty: unsafe {
73 LLVMInt32TypeInContext(context())
74 }
75 }
76}
77
78pub fn ty_i64() -> Type {
80 Type {
81 ty: unsafe {
82 LLVMInt64TypeInContext(context())
83 }
84 }
85}
86
87pub fn ty_i128() -> Type {
89 Type {
90 ty: unsafe {
91 LLVMInt128TypeInContext(context())
92 }
93 }
94}
95
96pub fn ty_isize(data: &target::TargetData) -> Type {
98 Type {
99 ty: unsafe {
100 llvm_sys::target::LLVMIntPtrTypeInContext(context(), data.data)
101 }
102 }
103}
104
105pub fn ty_i(bits: u32) -> Type {
107 Type {
108 ty: unsafe {
109 LLVMIntTypeInContext(context(), bits)
110 }
111 }
112}
113
114pub fn ty_half() -> Type {
116 Type {
117 ty: unsafe {
118 LLVMHalfTypeInContext(context())
119 }
120 }
121}
122
123pub fn ty_float() -> Type {
125 Type {
126 ty: unsafe {
127 LLVMFloatTypeInContext(context())
128 }
129 }
130}
131
132pub fn ty_double() -> Type {
134 Type {
135 ty: unsafe {
136 LLVMDoubleTypeInContext(context())
137 }
138 }
139}
140
141pub fn ty_fp128() -> Type {
143 Type {
144 ty: unsafe {
145 LLVMFP128TypeInContext(context())
146 }
147 }
148}