Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1 | #![allow(non_camel_case_types)] |
| 2 | #![allow(non_upper_case_globals)] |
| 3 | |
| 4 | use rustc_codegen_ssa::coverageinfo::map as coverage_map; |
| 5 | |
| 6 | use super::debuginfo::{ |
| 7 | DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator, |
Thiébaud Weksteen | 5bd94c1 | 2021-01-06 15:18:42 +0100 | [diff] [blame] | 8 | DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DINameSpace, |
| 9 | DISPFlags, DIScope, DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable, |
| 10 | DebugEmissionKind, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 11 | }; |
| 12 | |
| 13 | use libc::{c_char, c_int, c_uint, size_t}; |
| 14 | use libc::{c_ulonglong, c_void}; |
| 15 | |
| 16 | use std::marker::PhantomData; |
| 17 | |
| 18 | use super::RustString; |
| 19 | |
| 20 | pub type Bool = c_uint; |
| 21 | |
| 22 | pub const True: Bool = 1 as Bool; |
| 23 | pub const False: Bool = 0 as Bool; |
| 24 | |
| 25 | #[derive(Copy, Clone, PartialEq)] |
| 26 | #[repr(C)] |
| 27 | #[allow(dead_code)] // Variants constructed by C++. |
| 28 | pub enum LLVMRustResult { |
| 29 | Success, |
| 30 | Failure, |
| 31 | } |
Chris Wailes | 2f3fdfe | 2021-07-29 10:56:18 -0700 | [diff] [blame] | 32 | |
| 33 | // Rust version of the C struct with the same name in rustc_llvm/llvm-wrapper/RustWrapper.cpp. |
| 34 | #[repr(C)] |
| 35 | pub struct LLVMRustCOFFShortExport { |
| 36 | pub name: *const c_char, |
Chris Wailes | a153842 | 2021-12-02 10:37:12 -0800 | [diff] [blame^] | 37 | pub ordinal_present: bool, |
| 38 | // value of `ordinal` only important when `ordinal_present` is true |
| 39 | pub ordinal: u16, |
Chris Wailes | 2f3fdfe | 2021-07-29 10:56:18 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | impl LLVMRustCOFFShortExport { |
Chris Wailes | a153842 | 2021-12-02 10:37:12 -0800 | [diff] [blame^] | 43 | pub fn new(name: *const c_char, ordinal: Option<u16>) -> LLVMRustCOFFShortExport { |
| 44 | LLVMRustCOFFShortExport { |
| 45 | name, |
| 46 | ordinal_present: ordinal.is_some(), |
| 47 | ordinal: ordinal.unwrap_or(0), |
| 48 | } |
Chris Wailes | 2f3fdfe | 2021-07-29 10:56:18 -0700 | [diff] [blame] | 49 | } |
| 50 | } |
| 51 | |
| 52 | /// Translation of LLVM's MachineTypes enum, defined in llvm\include\llvm\BinaryFormat\COFF.h. |
| 53 | /// |
| 54 | /// We include only architectures supported on Windows. |
| 55 | #[derive(Copy, Clone, PartialEq)] |
| 56 | #[repr(C)] |
| 57 | pub enum LLVMMachineType { |
| 58 | AMD64 = 0x8664, |
| 59 | I386 = 0x14c, |
| 60 | ARM64 = 0xaa64, |
| 61 | ARM = 0x01c0, |
| 62 | } |
| 63 | |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 64 | // Consts for the LLVM CallConv type, pre-cast to usize. |
| 65 | |
| 66 | /// LLVM CallingConv::ID. Should we wrap this? |
| 67 | #[derive(Copy, Clone, PartialEq, Debug)] |
| 68 | #[repr(C)] |
| 69 | pub enum CallConv { |
| 70 | CCallConv = 0, |
| 71 | FastCallConv = 8, |
| 72 | ColdCallConv = 9, |
| 73 | X86StdcallCallConv = 64, |
| 74 | X86FastcallCallConv = 65, |
| 75 | ArmAapcsCallConv = 67, |
| 76 | Msp430Intr = 69, |
| 77 | X86_ThisCall = 70, |
| 78 | PtxKernel = 71, |
| 79 | X86_64_SysV = 78, |
| 80 | X86_64_Win64 = 79, |
| 81 | X86_VectorCall = 80, |
| 82 | X86_Intr = 83, |
| 83 | AvrNonBlockingInterrupt = 84, |
| 84 | AvrInterrupt = 85, |
| 85 | AmdGpuKernel = 91, |
| 86 | } |
| 87 | |
| 88 | /// LLVMRustLinkage |
Chris Wailes | 2f3fdfe | 2021-07-29 10:56:18 -0700 | [diff] [blame] | 89 | #[derive(Copy, Clone, PartialEq)] |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 90 | #[repr(C)] |
| 91 | pub enum Linkage { |
| 92 | ExternalLinkage = 0, |
| 93 | AvailableExternallyLinkage = 1, |
| 94 | LinkOnceAnyLinkage = 2, |
| 95 | LinkOnceODRLinkage = 3, |
| 96 | WeakAnyLinkage = 4, |
| 97 | WeakODRLinkage = 5, |
| 98 | AppendingLinkage = 6, |
| 99 | InternalLinkage = 7, |
| 100 | PrivateLinkage = 8, |
| 101 | ExternalWeakLinkage = 9, |
| 102 | CommonLinkage = 10, |
| 103 | } |
| 104 | |
| 105 | // LLVMRustVisibility |
| 106 | #[repr(C)] |
Chris Wailes | 2f3fdfe | 2021-07-29 10:56:18 -0700 | [diff] [blame] | 107 | #[derive(Copy, Clone, PartialEq)] |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 108 | pub enum Visibility { |
| 109 | Default = 0, |
| 110 | Hidden = 1, |
| 111 | Protected = 2, |
| 112 | } |
| 113 | |
| 114 | /// LLVMUnnamedAddr |
| 115 | #[repr(C)] |
| 116 | pub enum UnnamedAddr { |
| 117 | No, |
| 118 | Local, |
| 119 | Global, |
| 120 | } |
| 121 | |
| 122 | /// LLVMDLLStorageClass |
| 123 | #[derive(Copy, Clone)] |
| 124 | #[repr(C)] |
| 125 | pub enum DLLStorageClass { |
| 126 | #[allow(dead_code)] |
| 127 | Default = 0, |
| 128 | DllImport = 1, // Function to be imported from DLL. |
| 129 | #[allow(dead_code)] |
| 130 | DllExport = 2, // Function to be accessible from DLL. |
| 131 | } |
| 132 | |
| 133 | /// Matches LLVMRustAttribute in LLVMWrapper.h |
| 134 | /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind, |
| 135 | /// though it is not ABI compatible (since it's a C++ enum) |
| 136 | #[repr(C)] |
| 137 | #[derive(Copy, Clone, Debug)] |
| 138 | pub enum Attribute { |
| 139 | AlwaysInline = 0, |
| 140 | ByVal = 1, |
| 141 | Cold = 2, |
| 142 | InlineHint = 3, |
| 143 | MinSize = 4, |
| 144 | Naked = 5, |
| 145 | NoAlias = 6, |
| 146 | NoCapture = 7, |
| 147 | NoInline = 8, |
| 148 | NonNull = 9, |
| 149 | NoRedZone = 10, |
| 150 | NoReturn = 11, |
| 151 | NoUnwind = 12, |
| 152 | OptimizeForSize = 13, |
| 153 | ReadOnly = 14, |
| 154 | SExt = 15, |
| 155 | StructRet = 16, |
| 156 | UWTable = 17, |
| 157 | ZExt = 18, |
| 158 | InReg = 19, |
| 159 | SanitizeThread = 20, |
| 160 | SanitizeAddress = 21, |
| 161 | SanitizeMemory = 22, |
| 162 | NonLazyBind = 23, |
| 163 | OptimizeNone = 24, |
| 164 | ReturnsTwice = 25, |
| 165 | ReadNone = 26, |
| 166 | InaccessibleMemOnly = 27, |
Chris Wailes | e3116c4 | 2021-07-13 14:40:48 -0700 | [diff] [blame] | 167 | SanitizeHWAddress = 28, |
| 168 | WillReturn = 29, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | /// LLVMIntPredicate |
| 172 | #[derive(Copy, Clone)] |
| 173 | #[repr(C)] |
| 174 | pub enum IntPredicate { |
| 175 | IntEQ = 32, |
| 176 | IntNE = 33, |
| 177 | IntUGT = 34, |
| 178 | IntUGE = 35, |
| 179 | IntULT = 36, |
| 180 | IntULE = 37, |
| 181 | IntSGT = 38, |
| 182 | IntSGE = 39, |
| 183 | IntSLT = 40, |
| 184 | IntSLE = 41, |
| 185 | } |
| 186 | |
| 187 | impl IntPredicate { |
| 188 | pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self { |
| 189 | match intpre { |
| 190 | rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ, |
| 191 | rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE, |
| 192 | rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT, |
| 193 | rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE, |
| 194 | rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT, |
| 195 | rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE, |
| 196 | rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT, |
| 197 | rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE, |
| 198 | rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT, |
| 199 | rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE, |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | /// LLVMRealPredicate |
| 205 | #[derive(Copy, Clone)] |
| 206 | #[repr(C)] |
| 207 | pub enum RealPredicate { |
| 208 | RealPredicateFalse = 0, |
| 209 | RealOEQ = 1, |
| 210 | RealOGT = 2, |
| 211 | RealOGE = 3, |
| 212 | RealOLT = 4, |
| 213 | RealOLE = 5, |
| 214 | RealONE = 6, |
| 215 | RealORD = 7, |
| 216 | RealUNO = 8, |
| 217 | RealUEQ = 9, |
| 218 | RealUGT = 10, |
| 219 | RealUGE = 11, |
| 220 | RealULT = 12, |
| 221 | RealULE = 13, |
| 222 | RealUNE = 14, |
| 223 | RealPredicateTrue = 15, |
| 224 | } |
| 225 | |
Chris Wailes | a153842 | 2021-12-02 10:37:12 -0800 | [diff] [blame^] | 226 | impl RealPredicate { |
| 227 | pub fn from_generic(realp: rustc_codegen_ssa::common::RealPredicate) -> Self { |
| 228 | match realp { |
| 229 | rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => { |
| 230 | RealPredicate::RealPredicateFalse |
| 231 | } |
| 232 | rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ, |
| 233 | rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT, |
| 234 | rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE, |
| 235 | rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT, |
| 236 | rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE, |
| 237 | rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE, |
| 238 | rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD, |
| 239 | rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO, |
| 240 | rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ, |
| 241 | rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT, |
| 242 | rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE, |
| 243 | rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT, |
| 244 | rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE, |
| 245 | rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE, |
| 246 | rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => { |
| 247 | RealPredicate::RealPredicateTrue |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 253 | /// LLVMTypeKind |
| 254 | #[derive(Copy, Clone, PartialEq, Debug)] |
| 255 | #[repr(C)] |
| 256 | pub enum TypeKind { |
| 257 | Void = 0, |
| 258 | Half = 1, |
| 259 | Float = 2, |
| 260 | Double = 3, |
| 261 | X86_FP80 = 4, |
| 262 | FP128 = 5, |
| 263 | PPC_FP128 = 6, |
| 264 | Label = 7, |
| 265 | Integer = 8, |
| 266 | Function = 9, |
| 267 | Struct = 10, |
| 268 | Array = 11, |
| 269 | Pointer = 12, |
| 270 | Vector = 13, |
| 271 | Metadata = 14, |
| 272 | X86_MMX = 15, |
| 273 | Token = 16, |
| 274 | ScalableVector = 17, |
| 275 | BFloat = 18, |
Chris Wailes | e3116c4 | 2021-07-13 14:40:48 -0700 | [diff] [blame] | 276 | X86_AMX = 19, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | impl TypeKind { |
| 280 | pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind { |
| 281 | match self { |
| 282 | TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void, |
| 283 | TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half, |
| 284 | TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float, |
| 285 | TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double, |
| 286 | TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80, |
| 287 | TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128, |
| 288 | TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128, |
| 289 | TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label, |
| 290 | TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer, |
| 291 | TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function, |
| 292 | TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct, |
| 293 | TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array, |
| 294 | TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer, |
| 295 | TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector, |
| 296 | TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata, |
| 297 | TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX, |
| 298 | TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token, |
| 299 | TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector, |
| 300 | TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat, |
Chris Wailes | e3116c4 | 2021-07-13 14:40:48 -0700 | [diff] [blame] | 301 | TypeKind::X86_AMX => rustc_codegen_ssa::common::TypeKind::X86_AMX, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 302 | } |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | /// LLVMAtomicRmwBinOp |
| 307 | #[derive(Copy, Clone)] |
| 308 | #[repr(C)] |
| 309 | pub enum AtomicRmwBinOp { |
| 310 | AtomicXchg = 0, |
| 311 | AtomicAdd = 1, |
| 312 | AtomicSub = 2, |
| 313 | AtomicAnd = 3, |
| 314 | AtomicNand = 4, |
| 315 | AtomicOr = 5, |
| 316 | AtomicXor = 6, |
| 317 | AtomicMax = 7, |
| 318 | AtomicMin = 8, |
| 319 | AtomicUMax = 9, |
| 320 | AtomicUMin = 10, |
| 321 | } |
| 322 | |
| 323 | impl AtomicRmwBinOp { |
| 324 | pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self { |
| 325 | match op { |
| 326 | rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg, |
| 327 | rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd, |
| 328 | rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub, |
| 329 | rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd, |
| 330 | rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand, |
| 331 | rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr, |
| 332 | rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor, |
| 333 | rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax, |
| 334 | rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin, |
| 335 | rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax, |
| 336 | rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin, |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | /// LLVMAtomicOrdering |
| 342 | #[derive(Copy, Clone)] |
| 343 | #[repr(C)] |
| 344 | pub enum AtomicOrdering { |
| 345 | #[allow(dead_code)] |
| 346 | NotAtomic = 0, |
| 347 | Unordered = 1, |
| 348 | Monotonic = 2, |
| 349 | // Consume = 3, // Not specified yet. |
| 350 | Acquire = 4, |
| 351 | Release = 5, |
| 352 | AcquireRelease = 6, |
| 353 | SequentiallyConsistent = 7, |
| 354 | } |
| 355 | |
| 356 | impl AtomicOrdering { |
| 357 | pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self { |
| 358 | match ao { |
| 359 | rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic, |
| 360 | rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered, |
| 361 | rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic, |
| 362 | rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire, |
| 363 | rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release, |
| 364 | rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => { |
| 365 | AtomicOrdering::AcquireRelease |
| 366 | } |
| 367 | rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => { |
| 368 | AtomicOrdering::SequentiallyConsistent |
| 369 | } |
| 370 | } |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | /// LLVMRustSynchronizationScope |
| 375 | #[derive(Copy, Clone)] |
| 376 | #[repr(C)] |
| 377 | pub enum SynchronizationScope { |
| 378 | SingleThread, |
| 379 | CrossThread, |
| 380 | } |
| 381 | |
| 382 | impl SynchronizationScope { |
| 383 | pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self { |
| 384 | match sc { |
| 385 | rustc_codegen_ssa::common::SynchronizationScope::SingleThread => { |
| 386 | SynchronizationScope::SingleThread |
| 387 | } |
| 388 | rustc_codegen_ssa::common::SynchronizationScope::CrossThread => { |
| 389 | SynchronizationScope::CrossThread |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | /// LLVMRustFileType |
| 396 | #[derive(Copy, Clone)] |
| 397 | #[repr(C)] |
| 398 | pub enum FileType { |
| 399 | AssemblyFile, |
| 400 | ObjectFile, |
| 401 | } |
| 402 | |
| 403 | /// LLVMMetadataType |
| 404 | #[derive(Copy, Clone)] |
| 405 | #[repr(C)] |
| 406 | pub enum MetadataType { |
| 407 | MD_dbg = 0, |
| 408 | MD_tbaa = 1, |
| 409 | MD_prof = 2, |
| 410 | MD_fpmath = 3, |
| 411 | MD_range = 4, |
| 412 | MD_tbaa_struct = 5, |
| 413 | MD_invariant_load = 6, |
| 414 | MD_alias_scope = 7, |
| 415 | MD_noalias = 8, |
| 416 | MD_nontemporal = 9, |
| 417 | MD_mem_parallel_loop_access = 10, |
| 418 | MD_nonnull = 11, |
| 419 | } |
| 420 | |
| 421 | /// LLVMRustAsmDialect |
| 422 | #[derive(Copy, Clone)] |
| 423 | #[repr(C)] |
| 424 | pub enum AsmDialect { |
| 425 | Att, |
| 426 | Intel, |
| 427 | } |
| 428 | |
| 429 | impl AsmDialect { |
| 430 | pub fn from_generic(asm: rustc_ast::LlvmAsmDialect) -> Self { |
| 431 | match asm { |
| 432 | rustc_ast::LlvmAsmDialect::Att => AsmDialect::Att, |
| 433 | rustc_ast::LlvmAsmDialect::Intel => AsmDialect::Intel, |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | /// LLVMRustCodeGenOptLevel |
| 439 | #[derive(Copy, Clone, PartialEq)] |
| 440 | #[repr(C)] |
| 441 | pub enum CodeGenOptLevel { |
| 442 | None, |
| 443 | Less, |
| 444 | Default, |
| 445 | Aggressive, |
| 446 | } |
| 447 | |
| 448 | /// LLVMRustPassBuilderOptLevel |
| 449 | #[repr(C)] |
| 450 | pub enum PassBuilderOptLevel { |
| 451 | O0, |
| 452 | O1, |
| 453 | O2, |
| 454 | O3, |
| 455 | Os, |
| 456 | Oz, |
| 457 | } |
| 458 | |
| 459 | /// LLVMRustOptStage |
| 460 | #[derive(PartialEq)] |
| 461 | #[repr(C)] |
| 462 | pub enum OptStage { |
| 463 | PreLinkNoLTO, |
| 464 | PreLinkThinLTO, |
| 465 | PreLinkFatLTO, |
| 466 | ThinLTO, |
| 467 | FatLTO, |
| 468 | } |
| 469 | |
| 470 | /// LLVMRustSanitizerOptions |
| 471 | #[repr(C)] |
| 472 | pub struct SanitizerOptions { |
| 473 | pub sanitize_address: bool, |
| 474 | pub sanitize_address_recover: bool, |
| 475 | pub sanitize_memory: bool, |
| 476 | pub sanitize_memory_recover: bool, |
| 477 | pub sanitize_memory_track_origins: c_int, |
| 478 | pub sanitize_thread: bool, |
Chris Wailes | e3116c4 | 2021-07-13 14:40:48 -0700 | [diff] [blame] | 479 | pub sanitize_hwaddress: bool, |
| 480 | pub sanitize_hwaddress_recover: bool, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | /// LLVMRelocMode |
| 484 | #[derive(Copy, Clone, PartialEq)] |
| 485 | #[repr(C)] |
| 486 | pub enum RelocModel { |
| 487 | Static, |
| 488 | PIC, |
| 489 | DynamicNoPic, |
| 490 | ROPI, |
| 491 | RWPI, |
| 492 | ROPI_RWPI, |
| 493 | } |
| 494 | |
| 495 | /// LLVMRustCodeModel |
| 496 | #[derive(Copy, Clone)] |
| 497 | #[repr(C)] |
| 498 | pub enum CodeModel { |
| 499 | Tiny, |
| 500 | Small, |
| 501 | Kernel, |
| 502 | Medium, |
| 503 | Large, |
| 504 | None, |
| 505 | } |
| 506 | |
| 507 | /// LLVMRustDiagnosticKind |
| 508 | #[derive(Copy, Clone)] |
| 509 | #[repr(C)] |
| 510 | #[allow(dead_code)] // Variants constructed by C++. |
| 511 | pub enum DiagnosticKind { |
| 512 | Other, |
| 513 | InlineAsm, |
| 514 | StackSize, |
| 515 | DebugMetadataVersion, |
| 516 | SampleProfile, |
| 517 | OptimizationRemark, |
| 518 | OptimizationRemarkMissed, |
| 519 | OptimizationRemarkAnalysis, |
| 520 | OptimizationRemarkAnalysisFPCommute, |
| 521 | OptimizationRemarkAnalysisAliasing, |
| 522 | OptimizationRemarkOther, |
| 523 | OptimizationFailure, |
| 524 | PGOProfile, |
| 525 | Linker, |
| 526 | Unsupported, |
Chris Wailes | bcf972c | 2021-10-21 11:03:28 -0700 | [diff] [blame] | 527 | SrcMgr, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 528 | } |
| 529 | |
| 530 | /// LLVMRustDiagnosticLevel |
| 531 | #[derive(Copy, Clone)] |
| 532 | #[repr(C)] |
| 533 | #[allow(dead_code)] // Variants constructed by C++. |
| 534 | pub enum DiagnosticLevel { |
| 535 | Error, |
| 536 | Warning, |
| 537 | Note, |
| 538 | Remark, |
| 539 | } |
| 540 | |
| 541 | /// LLVMRustArchiveKind |
| 542 | #[derive(Copy, Clone)] |
| 543 | #[repr(C)] |
| 544 | pub enum ArchiveKind { |
| 545 | K_GNU, |
| 546 | K_BSD, |
| 547 | K_DARWIN, |
| 548 | K_COFF, |
| 549 | } |
| 550 | |
| 551 | /// LLVMRustPassKind |
| 552 | #[derive(Copy, Clone, PartialEq, Debug)] |
| 553 | #[repr(C)] |
| 554 | #[allow(dead_code)] // Variants constructed by C++. |
| 555 | pub enum PassKind { |
| 556 | Other, |
| 557 | Function, |
| 558 | Module, |
| 559 | } |
| 560 | |
| 561 | /// LLVMRustThinLTOData |
| 562 | extern "C" { |
| 563 | pub type ThinLTOData; |
| 564 | } |
| 565 | |
| 566 | /// LLVMRustThinLTOBuffer |
| 567 | extern "C" { |
| 568 | pub type ThinLTOBuffer; |
| 569 | } |
| 570 | |
| 571 | // LLVMRustModuleNameCallback |
| 572 | pub type ThinLTOModuleNameCallback = |
| 573 | unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char); |
| 574 | |
| 575 | /// LLVMRustThinLTOModule |
| 576 | #[repr(C)] |
| 577 | pub struct ThinLTOModule { |
| 578 | pub identifier: *const c_char, |
| 579 | pub data: *const u8, |
| 580 | pub len: usize, |
| 581 | } |
| 582 | |
| 583 | /// LLVMThreadLocalMode |
| 584 | #[derive(Copy, Clone)] |
| 585 | #[repr(C)] |
| 586 | pub enum ThreadLocalMode { |
| 587 | NotThreadLocal, |
| 588 | GeneralDynamic, |
| 589 | LocalDynamic, |
| 590 | InitialExec, |
| 591 | LocalExec, |
| 592 | } |
| 593 | |
| 594 | /// LLVMRustChecksumKind |
| 595 | #[derive(Copy, Clone)] |
| 596 | #[repr(C)] |
| 597 | pub enum ChecksumKind { |
| 598 | None, |
| 599 | MD5, |
| 600 | SHA1, |
Thiébaud Weksteen | 5bd94c1 | 2021-01-06 15:18:42 +0100 | [diff] [blame] | 601 | SHA256, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | extern "C" { |
| 605 | type Opaque; |
| 606 | } |
| 607 | #[repr(C)] |
| 608 | struct InvariantOpaque<'a> { |
| 609 | _marker: PhantomData<&'a mut &'a ()>, |
| 610 | _opaque: Opaque, |
| 611 | } |
| 612 | |
| 613 | // Opaque pointer types |
| 614 | extern "C" { |
| 615 | pub type Module; |
| 616 | } |
| 617 | extern "C" { |
| 618 | pub type Context; |
| 619 | } |
| 620 | extern "C" { |
| 621 | pub type Type; |
| 622 | } |
| 623 | extern "C" { |
| 624 | pub type Value; |
| 625 | } |
| 626 | extern "C" { |
| 627 | pub type ConstantInt; |
| 628 | } |
| 629 | extern "C" { |
| 630 | pub type Metadata; |
| 631 | } |
| 632 | extern "C" { |
| 633 | pub type BasicBlock; |
| 634 | } |
| 635 | #[repr(C)] |
| 636 | pub struct Builder<'a>(InvariantOpaque<'a>); |
| 637 | extern "C" { |
| 638 | pub type MemoryBuffer; |
| 639 | } |
| 640 | #[repr(C)] |
| 641 | pub struct PassManager<'a>(InvariantOpaque<'a>); |
| 642 | extern "C" { |
| 643 | pub type PassManagerBuilder; |
| 644 | } |
| 645 | extern "C" { |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 646 | pub type Pass; |
| 647 | } |
| 648 | extern "C" { |
| 649 | pub type TargetMachine; |
| 650 | } |
| 651 | extern "C" { |
| 652 | pub type Archive; |
| 653 | } |
| 654 | #[repr(C)] |
| 655 | pub struct ArchiveIterator<'a>(InvariantOpaque<'a>); |
| 656 | #[repr(C)] |
| 657 | pub struct ArchiveChild<'a>(InvariantOpaque<'a>); |
| 658 | extern "C" { |
| 659 | pub type Twine; |
| 660 | } |
| 661 | extern "C" { |
| 662 | pub type DiagnosticInfo; |
| 663 | } |
| 664 | extern "C" { |
| 665 | pub type SMDiagnostic; |
| 666 | } |
| 667 | #[repr(C)] |
| 668 | pub struct RustArchiveMember<'a>(InvariantOpaque<'a>); |
| 669 | #[repr(C)] |
| 670 | pub struct OperandBundleDef<'a>(InvariantOpaque<'a>); |
| 671 | #[repr(C)] |
| 672 | pub struct Linker<'a>(InvariantOpaque<'a>); |
| 673 | |
| 674 | pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void); |
| 675 | pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint); |
| 676 | |
| 677 | pub mod coverageinfo { |
| 678 | use super::coverage_map; |
| 679 | |
Jeff Vander Stoep | d59a287 | 2021-02-15 10:22:21 +0100 | [diff] [blame] | 680 | /// Aligns with [llvm::coverage::CounterMappingRegion::RegionKind](https://github.com/rust-lang/llvm-project/blob/rustc/11.0-2020-10-12/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h#L206-L222) |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 681 | #[derive(Copy, Clone, Debug)] |
| 682 | #[repr(C)] |
| 683 | pub enum RegionKind { |
| 684 | /// A CodeRegion associates some code with a counter |
| 685 | CodeRegion = 0, |
| 686 | |
| 687 | /// An ExpansionRegion represents a file expansion region that associates |
| 688 | /// a source range with the expansion of a virtual source file, such as |
| 689 | /// for a macro instantiation or #include file. |
| 690 | ExpansionRegion = 1, |
| 691 | |
| 692 | /// A SkippedRegion represents a source range with code that was skipped |
| 693 | /// by a preprocessor or similar means. |
| 694 | SkippedRegion = 2, |
| 695 | |
| 696 | /// A GapRegion is like a CodeRegion, but its count is only set as the |
| 697 | /// line execution count when its the only region in the line. |
| 698 | GapRegion = 3, |
| 699 | } |
| 700 | |
| 701 | /// This struct provides LLVM's representation of a "CoverageMappingRegion", encoded into the |
| 702 | /// coverage map, in accordance with the |
Jeff Vander Stoep | d59a287 | 2021-02-15 10:22:21 +0100 | [diff] [blame] | 703 | /// [LLVM Code Coverage Mapping Format](https://github.com/rust-lang/llvm-project/blob/rustc/11.0-2020-10-12/llvm/docs/CoverageMappingFormat.rst#llvm-code-coverage-mapping-format). |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 704 | /// The struct composes fields representing the `Counter` type and value(s) (injected counter |
| 705 | /// ID, or expression type and operands), the source file (an indirect index into a "filenames |
| 706 | /// array", encoded separately), and source location (start and end positions of the represented |
| 707 | /// code region). |
| 708 | /// |
Chris Wailes | e3116c4 | 2021-07-13 14:40:48 -0700 | [diff] [blame] | 709 | /// Matches LLVMRustCounterMappingRegion. |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 710 | #[derive(Copy, Clone, Debug)] |
| 711 | #[repr(C)] |
| 712 | pub struct CounterMappingRegion { |
| 713 | /// The counter type and type-dependent counter data, if any. |
| 714 | counter: coverage_map::Counter, |
| 715 | |
| 716 | /// An indirect reference to the source filename. In the LLVM Coverage Mapping Format, the |
| 717 | /// file_id is an index into a function-specific `virtual_file_mapping` array of indexes |
| 718 | /// that, in turn, are used to look up the filename for this region. |
| 719 | file_id: u32, |
| 720 | |
| 721 | /// If the `RegionKind` is an `ExpansionRegion`, the `expanded_file_id` can be used to find |
| 722 | /// the mapping regions created as a result of macro expansion, by checking if their file id |
| 723 | /// matches the expanded file id. |
| 724 | expanded_file_id: u32, |
| 725 | |
| 726 | /// 1-based starting line of the mapping region. |
| 727 | start_line: u32, |
| 728 | |
| 729 | /// 1-based starting column of the mapping region. |
| 730 | start_col: u32, |
| 731 | |
| 732 | /// 1-based ending line of the mapping region. |
| 733 | end_line: u32, |
| 734 | |
| 735 | /// 1-based ending column of the mapping region. If the high bit is set, the current |
| 736 | /// mapping region is a gap area. |
| 737 | end_col: u32, |
| 738 | |
| 739 | kind: RegionKind, |
| 740 | } |
| 741 | |
| 742 | impl CounterMappingRegion { |
Chris Wailes | 32f7835 | 2021-07-20 14:04:55 -0700 | [diff] [blame] | 743 | crate fn code_region( |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 744 | counter: coverage_map::Counter, |
| 745 | file_id: u32, |
| 746 | start_line: u32, |
| 747 | start_col: u32, |
| 748 | end_line: u32, |
| 749 | end_col: u32, |
| 750 | ) -> Self { |
| 751 | Self { |
| 752 | counter, |
| 753 | file_id, |
| 754 | expanded_file_id: 0, |
| 755 | start_line, |
| 756 | start_col, |
| 757 | end_line, |
| 758 | end_col, |
| 759 | kind: RegionKind::CodeRegion, |
| 760 | } |
| 761 | } |
| 762 | |
Chris Wailes | 32f7835 | 2021-07-20 14:04:55 -0700 | [diff] [blame] | 763 | // This function might be used in the future; the LLVM API is still evolving, as is coverage |
| 764 | // support. |
| 765 | #[allow(dead_code)] |
| 766 | crate fn expansion_region( |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 767 | file_id: u32, |
| 768 | expanded_file_id: u32, |
| 769 | start_line: u32, |
| 770 | start_col: u32, |
| 771 | end_line: u32, |
| 772 | end_col: u32, |
| 773 | ) -> Self { |
| 774 | Self { |
| 775 | counter: coverage_map::Counter::zero(), |
| 776 | file_id, |
| 777 | expanded_file_id, |
| 778 | start_line, |
| 779 | start_col, |
| 780 | end_line, |
| 781 | end_col, |
| 782 | kind: RegionKind::ExpansionRegion, |
| 783 | } |
| 784 | } |
| 785 | |
Chris Wailes | 32f7835 | 2021-07-20 14:04:55 -0700 | [diff] [blame] | 786 | // This function might be used in the future; the LLVM API is still evolving, as is coverage |
| 787 | // support. |
| 788 | #[allow(dead_code)] |
| 789 | crate fn skipped_region( |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 790 | file_id: u32, |
| 791 | start_line: u32, |
| 792 | start_col: u32, |
| 793 | end_line: u32, |
| 794 | end_col: u32, |
| 795 | ) -> Self { |
| 796 | Self { |
| 797 | counter: coverage_map::Counter::zero(), |
| 798 | file_id, |
| 799 | expanded_file_id: 0, |
| 800 | start_line, |
| 801 | start_col, |
| 802 | end_line, |
| 803 | end_col, |
| 804 | kind: RegionKind::SkippedRegion, |
| 805 | } |
| 806 | } |
| 807 | |
Chris Wailes | 32f7835 | 2021-07-20 14:04:55 -0700 | [diff] [blame] | 808 | // This function might be used in the future; the LLVM API is still evolving, as is coverage |
| 809 | // support. |
| 810 | #[allow(dead_code)] |
| 811 | crate fn gap_region( |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 812 | counter: coverage_map::Counter, |
| 813 | file_id: u32, |
| 814 | start_line: u32, |
| 815 | start_col: u32, |
| 816 | end_line: u32, |
| 817 | end_col: u32, |
| 818 | ) -> Self { |
| 819 | Self { |
| 820 | counter, |
| 821 | file_id, |
| 822 | expanded_file_id: 0, |
| 823 | start_line, |
| 824 | start_col, |
| 825 | end_line, |
Chris Wailes | a153842 | 2021-12-02 10:37:12 -0800 | [diff] [blame^] | 826 | end_col: (1_u32 << 31) | end_col, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 827 | kind: RegionKind::GapRegion, |
| 828 | } |
| 829 | } |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | pub mod debuginfo { |
| 834 | use super::{InvariantOpaque, Metadata}; |
| 835 | use bitflags::bitflags; |
| 836 | |
| 837 | #[repr(C)] |
| 838 | pub struct DIBuilder<'a>(InvariantOpaque<'a>); |
| 839 | |
| 840 | pub type DIDescriptor = Metadata; |
Thiébaud Weksteen | 5bd94c1 | 2021-01-06 15:18:42 +0100 | [diff] [blame] | 841 | pub type DILocation = Metadata; |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 842 | pub type DIScope = DIDescriptor; |
| 843 | pub type DIFile = DIScope; |
| 844 | pub type DILexicalBlock = DIScope; |
| 845 | pub type DISubprogram = DIScope; |
| 846 | pub type DINameSpace = DIScope; |
| 847 | pub type DIType = DIDescriptor; |
| 848 | pub type DIBasicType = DIType; |
| 849 | pub type DIDerivedType = DIType; |
| 850 | pub type DICompositeType = DIDerivedType; |
| 851 | pub type DIVariable = DIDescriptor; |
| 852 | pub type DIGlobalVariableExpression = DIDescriptor; |
| 853 | pub type DIArray = DIDescriptor; |
| 854 | pub type DISubrange = DIDescriptor; |
| 855 | pub type DIEnumerator = DIDescriptor; |
| 856 | pub type DITemplateTypeParameter = DIDescriptor; |
| 857 | |
| 858 | // These values **must** match with LLVMRustDIFlags!! |
| 859 | bitflags! { |
| 860 | #[repr(transparent)] |
| 861 | #[derive(Default)] |
| 862 | pub struct DIFlags: u32 { |
| 863 | const FlagZero = 0; |
| 864 | const FlagPrivate = 1; |
| 865 | const FlagProtected = 2; |
| 866 | const FlagPublic = 3; |
| 867 | const FlagFwdDecl = (1 << 2); |
| 868 | const FlagAppleBlock = (1 << 3); |
| 869 | const FlagBlockByrefStruct = (1 << 4); |
| 870 | const FlagVirtual = (1 << 5); |
| 871 | const FlagArtificial = (1 << 6); |
| 872 | const FlagExplicit = (1 << 7); |
| 873 | const FlagPrototyped = (1 << 8); |
| 874 | const FlagObjcClassComplete = (1 << 9); |
| 875 | const FlagObjectPointer = (1 << 10); |
| 876 | const FlagVector = (1 << 11); |
| 877 | const FlagStaticMember = (1 << 12); |
| 878 | const FlagLValueReference = (1 << 13); |
| 879 | const FlagRValueReference = (1 << 14); |
| 880 | const FlagExternalTypeRef = (1 << 15); |
| 881 | const FlagIntroducedVirtual = (1 << 18); |
| 882 | const FlagBitField = (1 << 19); |
| 883 | const FlagNoReturn = (1 << 20); |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | // These values **must** match with LLVMRustDISPFlags!! |
| 888 | bitflags! { |
| 889 | #[repr(transparent)] |
| 890 | #[derive(Default)] |
| 891 | pub struct DISPFlags: u32 { |
| 892 | const SPFlagZero = 0; |
| 893 | const SPFlagVirtual = 1; |
| 894 | const SPFlagPureVirtual = 2; |
| 895 | const SPFlagLocalToUnit = (1 << 2); |
| 896 | const SPFlagDefinition = (1 << 3); |
| 897 | const SPFlagOptimized = (1 << 4); |
| 898 | const SPFlagMainSubprogram = (1 << 5); |
| 899 | } |
| 900 | } |
| 901 | |
| 902 | /// LLVMRustDebugEmissionKind |
| 903 | #[derive(Copy, Clone)] |
| 904 | #[repr(C)] |
| 905 | pub enum DebugEmissionKind { |
| 906 | NoDebug, |
| 907 | FullDebug, |
| 908 | LineTablesOnly, |
| 909 | } |
| 910 | |
| 911 | impl DebugEmissionKind { |
| 912 | pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self { |
| 913 | use rustc_session::config::DebugInfo; |
| 914 | match kind { |
| 915 | DebugInfo::None => DebugEmissionKind::NoDebug, |
| 916 | DebugInfo::Limited => DebugEmissionKind::LineTablesOnly, |
| 917 | DebugInfo::Full => DebugEmissionKind::FullDebug, |
| 918 | } |
| 919 | } |
| 920 | } |
| 921 | } |
| 922 | |
| 923 | extern "C" { |
| 924 | pub type ModuleBuffer; |
| 925 | } |
| 926 | |
| 927 | pub type SelfProfileBeforePassCallback = |
| 928 | unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char); |
| 929 | pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void); |
| 930 | |
| 931 | extern "C" { |
| 932 | pub fn LLVMRustInstallFatalErrorHandler(); |
| 933 | |
| 934 | // Create and destroy contexts. |
| 935 | pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context; |
| 936 | pub fn LLVMContextDispose(C: &'static mut Context); |
| 937 | pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint; |
| 938 | |
| 939 | // Create modules. |
| 940 | pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module; |
| 941 | pub fn LLVMGetModuleContext(M: &Module) -> &Context; |
| 942 | pub fn LLVMCloneModule(M: &Module) -> &Module; |
| 943 | |
| 944 | /// Data layout. See Module::getDataLayout. |
| 945 | pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char; |
| 946 | pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char); |
| 947 | |
| 948 | /// See Module::setModuleInlineAsm. |
| 949 | pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t); |
| 950 | pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t); |
| 951 | |
| 952 | /// See llvm::LLVMTypeKind::getTypeID. |
| 953 | pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind; |
| 954 | |
| 955 | // Operations on integer types |
| 956 | pub fn LLVMInt1TypeInContext(C: &Context) -> &Type; |
| 957 | pub fn LLVMInt8TypeInContext(C: &Context) -> &Type; |
| 958 | pub fn LLVMInt16TypeInContext(C: &Context) -> &Type; |
| 959 | pub fn LLVMInt32TypeInContext(C: &Context) -> &Type; |
| 960 | pub fn LLVMInt64TypeInContext(C: &Context) -> &Type; |
| 961 | pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type; |
| 962 | |
| 963 | pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint; |
| 964 | |
| 965 | // Operations on real types |
| 966 | pub fn LLVMFloatTypeInContext(C: &Context) -> &Type; |
| 967 | pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type; |
| 968 | |
| 969 | // Operations on function types |
| 970 | pub fn LLVMFunctionType( |
| 971 | ReturnType: &'a Type, |
| 972 | ParamTypes: *const &'a Type, |
| 973 | ParamCount: c_uint, |
| 974 | IsVarArg: Bool, |
| 975 | ) -> &'a Type; |
| 976 | pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint; |
| 977 | pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type); |
| 978 | |
| 979 | // Operations on struct types |
| 980 | pub fn LLVMStructTypeInContext( |
| 981 | C: &'a Context, |
| 982 | ElementTypes: *const &'a Type, |
| 983 | ElementCount: c_uint, |
| 984 | Packed: Bool, |
| 985 | ) -> &'a Type; |
| 986 | |
| 987 | // Operations on array, pointer, and vector types (sequence types) |
| 988 | pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type; |
| 989 | pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type; |
| 990 | pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type; |
| 991 | |
| 992 | pub fn LLVMGetElementType(Ty: &Type) -> &Type; |
| 993 | pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint; |
| 994 | |
| 995 | // Operations on other types |
| 996 | pub fn LLVMVoidTypeInContext(C: &Context) -> &Type; |
| 997 | pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type; |
| 998 | |
| 999 | // Operations on all values |
| 1000 | pub fn LLVMTypeOf(Val: &Value) -> &Type; |
| 1001 | pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char; |
| 1002 | pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t); |
| 1003 | pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value); |
| 1004 | pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value); |
| 1005 | |
| 1006 | // Operations on constants of any type |
| 1007 | pub fn LLVMConstNull(Ty: &Type) -> &Value; |
| 1008 | pub fn LLVMGetUndef(Ty: &Type) -> &Value; |
| 1009 | |
| 1010 | // Operations on metadata |
| 1011 | pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value; |
| 1012 | pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value; |
| 1013 | pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value); |
| 1014 | |
| 1015 | // Operations on scalar constants |
| 1016 | pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value; |
| 1017 | pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value; |
| 1018 | pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value; |
| 1019 | pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong; |
| 1020 | pub fn LLVMRustConstInt128Get( |
| 1021 | ConstantVal: &ConstantInt, |
| 1022 | SExt: bool, |
| 1023 | high: &mut u64, |
| 1024 | low: &mut u64, |
| 1025 | ) -> bool; |
| 1026 | |
| 1027 | // Operations on composite constants |
| 1028 | pub fn LLVMConstStringInContext( |
| 1029 | C: &Context, |
| 1030 | Str: *const c_char, |
| 1031 | Length: c_uint, |
| 1032 | DontNullTerminate: Bool, |
| 1033 | ) -> &Value; |
| 1034 | pub fn LLVMConstStructInContext( |
| 1035 | C: &'a Context, |
| 1036 | ConstantVals: *const &'a Value, |
| 1037 | Count: c_uint, |
| 1038 | Packed: Bool, |
| 1039 | ) -> &'a Value; |
| 1040 | |
| 1041 | pub fn LLVMConstArray( |
| 1042 | ElementTy: &'a Type, |
| 1043 | ConstantVals: *const &'a Value, |
| 1044 | Length: c_uint, |
| 1045 | ) -> &'a Value; |
| 1046 | pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value; |
| 1047 | |
| 1048 | // Constant expressions |
Chris Wailes | bcf972c | 2021-10-21 11:03:28 -0700 | [diff] [blame] | 1049 | pub fn LLVMRustConstInBoundsGEP2( |
| 1050 | ty: &'a Type, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1051 | ConstantVal: &'a Value, |
| 1052 | ConstantIndices: *const &'a Value, |
| 1053 | NumIndices: c_uint, |
| 1054 | ) -> &'a Value; |
| 1055 | pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; |
| 1056 | pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; |
| 1057 | pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; |
| 1058 | pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; |
| 1059 | pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; |
| 1060 | pub fn LLVMConstExtractValue( |
| 1061 | AggConstant: &Value, |
| 1062 | IdxList: *const c_uint, |
| 1063 | NumIdx: c_uint, |
| 1064 | ) -> &Value; |
| 1065 | |
| 1066 | // Operations on global variables, functions, and aliases (globals) |
| 1067 | pub fn LLVMIsDeclaration(Global: &Value) -> Bool; |
| 1068 | pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage; |
| 1069 | pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage); |
| 1070 | pub fn LLVMSetSection(Global: &Value, Section: *const c_char); |
| 1071 | pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility; |
| 1072 | pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility); |
Chris Wailes | 32f7835 | 2021-07-20 14:04:55 -0700 | [diff] [blame] | 1073 | pub fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool); |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1074 | pub fn LLVMGetAlignment(Global: &Value) -> c_uint; |
| 1075 | pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint); |
| 1076 | pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass); |
| 1077 | |
| 1078 | // Operations on global variables |
| 1079 | pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>; |
| 1080 | pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value; |
| 1081 | pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>; |
| 1082 | pub fn LLVMRustGetOrInsertGlobal( |
| 1083 | M: &'a Module, |
| 1084 | Name: *const c_char, |
| 1085 | NameLen: size_t, |
| 1086 | T: &'a Type, |
| 1087 | ) -> &'a Value; |
| 1088 | pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value; |
| 1089 | pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>; |
| 1090 | pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>; |
| 1091 | pub fn LLVMDeleteGlobal(GlobalVar: &Value); |
| 1092 | pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>; |
| 1093 | pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value); |
Chris Wailes | 2f3fdfe | 2021-07-29 10:56:18 -0700 | [diff] [blame] | 1094 | pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool; |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1095 | pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool); |
| 1096 | pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode); |
| 1097 | pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool; |
| 1098 | pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool); |
| 1099 | pub fn LLVMRustGetNamedValue( |
| 1100 | M: &Module, |
| 1101 | Name: *const c_char, |
| 1102 | NameLen: size_t, |
| 1103 | ) -> Option<&Value>; |
| 1104 | pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool); |
| 1105 | |
| 1106 | // Operations on functions |
| 1107 | pub fn LLVMRustGetOrInsertFunction( |
| 1108 | M: &'a Module, |
| 1109 | Name: *const c_char, |
| 1110 | NameLen: size_t, |
| 1111 | FunctionTy: &'a Type, |
| 1112 | ) -> &'a Value; |
| 1113 | pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint); |
| 1114 | pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32); |
| 1115 | pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64); |
| 1116 | pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64); |
| 1117 | pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type); |
Chris Wailes | e3116c4 | 2021-07-13 14:40:48 -0700 | [diff] [blame] | 1118 | pub fn LLVMRustAddStructRetAttr(Fn: &Value, index: c_uint, ty: &Type); |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1119 | pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute); |
| 1120 | pub fn LLVMRustAddFunctionAttrStringValue( |
| 1121 | Fn: &Value, |
| 1122 | index: c_uint, |
| 1123 | Name: *const c_char, |
| 1124 | Value: *const c_char, |
| 1125 | ); |
| 1126 | pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute); |
| 1127 | |
| 1128 | // Operations on parameters |
| 1129 | pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>; |
| 1130 | pub fn LLVMCountParams(Fn: &Value) -> c_uint; |
| 1131 | pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value; |
| 1132 | |
| 1133 | // Operations on basic blocks |
| 1134 | pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value; |
| 1135 | pub fn LLVMAppendBasicBlockInContext( |
| 1136 | C: &'a Context, |
| 1137 | Fn: &'a Value, |
| 1138 | Name: *const c_char, |
| 1139 | ) -> &'a BasicBlock; |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1140 | |
| 1141 | // Operations on instructions |
| 1142 | pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>; |
| 1143 | pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock; |
| 1144 | |
| 1145 | // Operations on call sites |
| 1146 | pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint); |
| 1147 | pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute); |
Jeff Vander Stoep | 59fbe18 | 2021-03-29 10:17:52 +0200 | [diff] [blame] | 1148 | pub fn LLVMRustAddCallSiteAttrString(Instr: &Value, index: c_uint, Name: *const c_char); |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1149 | pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32); |
| 1150 | pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64); |
| 1151 | pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64); |
| 1152 | pub fn LLVMRustAddByValCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type); |
Chris Wailes | e3116c4 | 2021-07-13 14:40:48 -0700 | [diff] [blame] | 1153 | pub fn LLVMRustAddStructRetCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type); |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1154 | |
| 1155 | // Operations on load/store instructions (only) |
| 1156 | pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool); |
| 1157 | |
| 1158 | // Operations on phi nodes |
| 1159 | pub fn LLVMAddIncoming( |
| 1160 | PhiNode: &'a Value, |
| 1161 | IncomingValues: *const &'a Value, |
| 1162 | IncomingBlocks: *const &'a BasicBlock, |
| 1163 | Count: c_uint, |
| 1164 | ); |
| 1165 | |
| 1166 | // Instruction builders |
| 1167 | pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>; |
| 1168 | pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock); |
| 1169 | pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock; |
| 1170 | pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>); |
| 1171 | |
| 1172 | // Metadata |
| 1173 | pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value); |
| 1174 | |
| 1175 | // Terminators |
| 1176 | pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value; |
| 1177 | pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value; |
| 1178 | pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value; |
| 1179 | pub fn LLVMBuildCondBr( |
| 1180 | B: &Builder<'a>, |
| 1181 | If: &'a Value, |
| 1182 | Then: &'a BasicBlock, |
| 1183 | Else: &'a BasicBlock, |
| 1184 | ) -> &'a Value; |
| 1185 | pub fn LLVMBuildSwitch( |
| 1186 | B: &Builder<'a>, |
| 1187 | V: &'a Value, |
| 1188 | Else: &'a BasicBlock, |
| 1189 | NumCases: c_uint, |
| 1190 | ) -> &'a Value; |
| 1191 | pub fn LLVMRustBuildInvoke( |
| 1192 | B: &Builder<'a>, |
Chris Wailes | bcf972c | 2021-10-21 11:03:28 -0700 | [diff] [blame] | 1193 | Ty: &'a Type, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1194 | Fn: &'a Value, |
| 1195 | Args: *const &'a Value, |
| 1196 | NumArgs: c_uint, |
| 1197 | Then: &'a BasicBlock, |
| 1198 | Catch: &'a BasicBlock, |
| 1199 | Bundle: Option<&OperandBundleDef<'a>>, |
| 1200 | Name: *const c_char, |
| 1201 | ) -> &'a Value; |
| 1202 | pub fn LLVMBuildLandingPad( |
| 1203 | B: &Builder<'a>, |
| 1204 | Ty: &'a Type, |
Chris Wailes | 54272ac | 2021-09-09 16:08:13 -0700 | [diff] [blame] | 1205 | PersFn: Option<&'a Value>, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1206 | NumClauses: c_uint, |
| 1207 | Name: *const c_char, |
| 1208 | ) -> &'a Value; |
| 1209 | pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value; |
| 1210 | pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value; |
| 1211 | |
| 1212 | pub fn LLVMRustBuildCleanupPad( |
| 1213 | B: &Builder<'a>, |
| 1214 | ParentPad: Option<&'a Value>, |
| 1215 | ArgCnt: c_uint, |
| 1216 | Args: *const &'a Value, |
| 1217 | Name: *const c_char, |
| 1218 | ) -> Option<&'a Value>; |
| 1219 | pub fn LLVMRustBuildCleanupRet( |
| 1220 | B: &Builder<'a>, |
| 1221 | CleanupPad: &'a Value, |
| 1222 | UnwindBB: Option<&'a BasicBlock>, |
| 1223 | ) -> Option<&'a Value>; |
| 1224 | pub fn LLVMRustBuildCatchPad( |
| 1225 | B: &Builder<'a>, |
| 1226 | ParentPad: &'a Value, |
| 1227 | ArgCnt: c_uint, |
| 1228 | Args: *const &'a Value, |
| 1229 | Name: *const c_char, |
| 1230 | ) -> Option<&'a Value>; |
| 1231 | pub fn LLVMRustBuildCatchRet( |
| 1232 | B: &Builder<'a>, |
| 1233 | Pad: &'a Value, |
| 1234 | BB: &'a BasicBlock, |
| 1235 | ) -> Option<&'a Value>; |
| 1236 | pub fn LLVMRustBuildCatchSwitch( |
| 1237 | Builder: &Builder<'a>, |
| 1238 | ParentPad: Option<&'a Value>, |
| 1239 | BB: Option<&'a BasicBlock>, |
| 1240 | NumHandlers: c_uint, |
| 1241 | Name: *const c_char, |
| 1242 | ) -> Option<&'a Value>; |
| 1243 | pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock); |
| 1244 | pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value); |
| 1245 | |
| 1246 | // Add a case to the switch instruction |
| 1247 | pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock); |
| 1248 | |
| 1249 | // Add a clause to the landing pad instruction |
| 1250 | pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value); |
| 1251 | |
| 1252 | // Set the cleanup on a landing pad instruction |
| 1253 | pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool); |
| 1254 | |
| 1255 | // Arithmetic |
| 1256 | pub fn LLVMBuildAdd( |
| 1257 | B: &Builder<'a>, |
| 1258 | LHS: &'a Value, |
| 1259 | RHS: &'a Value, |
| 1260 | Name: *const c_char, |
| 1261 | ) -> &'a Value; |
| 1262 | pub fn LLVMBuildFAdd( |
| 1263 | B: &Builder<'a>, |
| 1264 | LHS: &'a Value, |
| 1265 | RHS: &'a Value, |
| 1266 | Name: *const c_char, |
| 1267 | ) -> &'a Value; |
| 1268 | pub fn LLVMBuildSub( |
| 1269 | B: &Builder<'a>, |
| 1270 | LHS: &'a Value, |
| 1271 | RHS: &'a Value, |
| 1272 | Name: *const c_char, |
| 1273 | ) -> &'a Value; |
| 1274 | pub fn LLVMBuildFSub( |
| 1275 | B: &Builder<'a>, |
| 1276 | LHS: &'a Value, |
| 1277 | RHS: &'a Value, |
| 1278 | Name: *const c_char, |
| 1279 | ) -> &'a Value; |
| 1280 | pub fn LLVMBuildMul( |
| 1281 | B: &Builder<'a>, |
| 1282 | LHS: &'a Value, |
| 1283 | RHS: &'a Value, |
| 1284 | Name: *const c_char, |
| 1285 | ) -> &'a Value; |
| 1286 | pub fn LLVMBuildFMul( |
| 1287 | B: &Builder<'a>, |
| 1288 | LHS: &'a Value, |
| 1289 | RHS: &'a Value, |
| 1290 | Name: *const c_char, |
| 1291 | ) -> &'a Value; |
| 1292 | pub fn LLVMBuildUDiv( |
| 1293 | B: &Builder<'a>, |
| 1294 | LHS: &'a Value, |
| 1295 | RHS: &'a Value, |
| 1296 | Name: *const c_char, |
| 1297 | ) -> &'a Value; |
| 1298 | pub fn LLVMBuildExactUDiv( |
| 1299 | B: &Builder<'a>, |
| 1300 | LHS: &'a Value, |
| 1301 | RHS: &'a Value, |
| 1302 | Name: *const c_char, |
| 1303 | ) -> &'a Value; |
| 1304 | pub fn LLVMBuildSDiv( |
| 1305 | B: &Builder<'a>, |
| 1306 | LHS: &'a Value, |
| 1307 | RHS: &'a Value, |
| 1308 | Name: *const c_char, |
| 1309 | ) -> &'a Value; |
| 1310 | pub fn LLVMBuildExactSDiv( |
| 1311 | B: &Builder<'a>, |
| 1312 | LHS: &'a Value, |
| 1313 | RHS: &'a Value, |
| 1314 | Name: *const c_char, |
| 1315 | ) -> &'a Value; |
| 1316 | pub fn LLVMBuildFDiv( |
| 1317 | B: &Builder<'a>, |
| 1318 | LHS: &'a Value, |
| 1319 | RHS: &'a Value, |
| 1320 | Name: *const c_char, |
| 1321 | ) -> &'a Value; |
| 1322 | pub fn LLVMBuildURem( |
| 1323 | B: &Builder<'a>, |
| 1324 | LHS: &'a Value, |
| 1325 | RHS: &'a Value, |
| 1326 | Name: *const c_char, |
| 1327 | ) -> &'a Value; |
| 1328 | pub fn LLVMBuildSRem( |
| 1329 | B: &Builder<'a>, |
| 1330 | LHS: &'a Value, |
| 1331 | RHS: &'a Value, |
| 1332 | Name: *const c_char, |
| 1333 | ) -> &'a Value; |
| 1334 | pub fn LLVMBuildFRem( |
| 1335 | B: &Builder<'a>, |
| 1336 | LHS: &'a Value, |
| 1337 | RHS: &'a Value, |
| 1338 | Name: *const c_char, |
| 1339 | ) -> &'a Value; |
| 1340 | pub fn LLVMBuildShl( |
| 1341 | B: &Builder<'a>, |
| 1342 | LHS: &'a Value, |
| 1343 | RHS: &'a Value, |
| 1344 | Name: *const c_char, |
| 1345 | ) -> &'a Value; |
| 1346 | pub fn LLVMBuildLShr( |
| 1347 | B: &Builder<'a>, |
| 1348 | LHS: &'a Value, |
| 1349 | RHS: &'a Value, |
| 1350 | Name: *const c_char, |
| 1351 | ) -> &'a Value; |
| 1352 | pub fn LLVMBuildAShr( |
| 1353 | B: &Builder<'a>, |
| 1354 | LHS: &'a Value, |
| 1355 | RHS: &'a Value, |
| 1356 | Name: *const c_char, |
| 1357 | ) -> &'a Value; |
| 1358 | pub fn LLVMBuildNSWAdd( |
| 1359 | B: &Builder<'a>, |
| 1360 | LHS: &'a Value, |
| 1361 | RHS: &'a Value, |
| 1362 | Name: *const c_char, |
| 1363 | ) -> &'a Value; |
| 1364 | pub fn LLVMBuildNUWAdd( |
| 1365 | B: &Builder<'a>, |
| 1366 | LHS: &'a Value, |
| 1367 | RHS: &'a Value, |
| 1368 | Name: *const c_char, |
| 1369 | ) -> &'a Value; |
| 1370 | pub fn LLVMBuildNSWSub( |
| 1371 | B: &Builder<'a>, |
| 1372 | LHS: &'a Value, |
| 1373 | RHS: &'a Value, |
| 1374 | Name: *const c_char, |
| 1375 | ) -> &'a Value; |
| 1376 | pub fn LLVMBuildNUWSub( |
| 1377 | B: &Builder<'a>, |
| 1378 | LHS: &'a Value, |
| 1379 | RHS: &'a Value, |
| 1380 | Name: *const c_char, |
| 1381 | ) -> &'a Value; |
| 1382 | pub fn LLVMBuildNSWMul( |
| 1383 | B: &Builder<'a>, |
| 1384 | LHS: &'a Value, |
| 1385 | RHS: &'a Value, |
| 1386 | Name: *const c_char, |
| 1387 | ) -> &'a Value; |
| 1388 | pub fn LLVMBuildNUWMul( |
| 1389 | B: &Builder<'a>, |
| 1390 | LHS: &'a Value, |
| 1391 | RHS: &'a Value, |
| 1392 | Name: *const c_char, |
| 1393 | ) -> &'a Value; |
| 1394 | pub fn LLVMBuildAnd( |
| 1395 | B: &Builder<'a>, |
| 1396 | LHS: &'a Value, |
| 1397 | RHS: &'a Value, |
| 1398 | Name: *const c_char, |
| 1399 | ) -> &'a Value; |
| 1400 | pub fn LLVMBuildOr( |
| 1401 | B: &Builder<'a>, |
| 1402 | LHS: &'a Value, |
| 1403 | RHS: &'a Value, |
| 1404 | Name: *const c_char, |
| 1405 | ) -> &'a Value; |
| 1406 | pub fn LLVMBuildXor( |
| 1407 | B: &Builder<'a>, |
| 1408 | LHS: &'a Value, |
| 1409 | RHS: &'a Value, |
| 1410 | Name: *const c_char, |
| 1411 | ) -> &'a Value; |
| 1412 | pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value; |
| 1413 | pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value; |
| 1414 | pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value; |
Chris Wailes | 32f7835 | 2021-07-20 14:04:55 -0700 | [diff] [blame] | 1415 | pub fn LLVMRustSetFastMath(Instr: &Value); |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1416 | |
| 1417 | // Memory |
| 1418 | pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value; |
| 1419 | pub fn LLVMBuildArrayAlloca( |
| 1420 | B: &Builder<'a>, |
| 1421 | Ty: &'a Type, |
| 1422 | Val: &'a Value, |
| 1423 | Name: *const c_char, |
| 1424 | ) -> &'a Value; |
Chris Wailes | 54272ac | 2021-09-09 16:08:13 -0700 | [diff] [blame] | 1425 | pub fn LLVMBuildLoad2( |
| 1426 | B: &Builder<'a>, |
| 1427 | Ty: &'a Type, |
| 1428 | PointerVal: &'a Value, |
| 1429 | Name: *const c_char, |
| 1430 | ) -> &'a Value; |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1431 | |
| 1432 | pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value; |
| 1433 | |
Chris Wailes | bcf972c | 2021-10-21 11:03:28 -0700 | [diff] [blame] | 1434 | pub fn LLVMBuildGEP2( |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1435 | B: &Builder<'a>, |
Chris Wailes | bcf972c | 2021-10-21 11:03:28 -0700 | [diff] [blame] | 1436 | Ty: &'a Type, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1437 | Pointer: &'a Value, |
| 1438 | Indices: *const &'a Value, |
| 1439 | NumIndices: c_uint, |
| 1440 | Name: *const c_char, |
| 1441 | ) -> &'a Value; |
Chris Wailes | bcf972c | 2021-10-21 11:03:28 -0700 | [diff] [blame] | 1442 | pub fn LLVMBuildInBoundsGEP2( |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1443 | B: &Builder<'a>, |
Chris Wailes | bcf972c | 2021-10-21 11:03:28 -0700 | [diff] [blame] | 1444 | Ty: &'a Type, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1445 | Pointer: &'a Value, |
| 1446 | Indices: *const &'a Value, |
| 1447 | NumIndices: c_uint, |
| 1448 | Name: *const c_char, |
| 1449 | ) -> &'a Value; |
Chris Wailes | bcf972c | 2021-10-21 11:03:28 -0700 | [diff] [blame] | 1450 | pub fn LLVMBuildStructGEP2( |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1451 | B: &Builder<'a>, |
Chris Wailes | bcf972c | 2021-10-21 11:03:28 -0700 | [diff] [blame] | 1452 | Ty: &'a Type, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1453 | Pointer: &'a Value, |
| 1454 | Idx: c_uint, |
| 1455 | Name: *const c_char, |
| 1456 | ) -> &'a Value; |
| 1457 | |
| 1458 | // Casts |
| 1459 | pub fn LLVMBuildTrunc( |
| 1460 | B: &Builder<'a>, |
| 1461 | Val: &'a Value, |
| 1462 | DestTy: &'a Type, |
| 1463 | Name: *const c_char, |
| 1464 | ) -> &'a Value; |
| 1465 | pub fn LLVMBuildZExt( |
| 1466 | B: &Builder<'a>, |
| 1467 | Val: &'a Value, |
| 1468 | DestTy: &'a Type, |
| 1469 | Name: *const c_char, |
| 1470 | ) -> &'a Value; |
| 1471 | pub fn LLVMBuildSExt( |
| 1472 | B: &Builder<'a>, |
| 1473 | Val: &'a Value, |
| 1474 | DestTy: &'a Type, |
| 1475 | Name: *const c_char, |
| 1476 | ) -> &'a Value; |
| 1477 | pub fn LLVMBuildFPToUI( |
| 1478 | B: &Builder<'a>, |
| 1479 | Val: &'a Value, |
| 1480 | DestTy: &'a Type, |
| 1481 | Name: *const c_char, |
| 1482 | ) -> &'a Value; |
| 1483 | pub fn LLVMBuildFPToSI( |
| 1484 | B: &Builder<'a>, |
| 1485 | Val: &'a Value, |
| 1486 | DestTy: &'a Type, |
| 1487 | Name: *const c_char, |
| 1488 | ) -> &'a Value; |
| 1489 | pub fn LLVMBuildUIToFP( |
| 1490 | B: &Builder<'a>, |
| 1491 | Val: &'a Value, |
| 1492 | DestTy: &'a Type, |
| 1493 | Name: *const c_char, |
| 1494 | ) -> &'a Value; |
| 1495 | pub fn LLVMBuildSIToFP( |
| 1496 | B: &Builder<'a>, |
| 1497 | Val: &'a Value, |
| 1498 | DestTy: &'a Type, |
| 1499 | Name: *const c_char, |
| 1500 | ) -> &'a Value; |
| 1501 | pub fn LLVMBuildFPTrunc( |
| 1502 | B: &Builder<'a>, |
| 1503 | Val: &'a Value, |
| 1504 | DestTy: &'a Type, |
| 1505 | Name: *const c_char, |
| 1506 | ) -> &'a Value; |
| 1507 | pub fn LLVMBuildFPExt( |
| 1508 | B: &Builder<'a>, |
| 1509 | Val: &'a Value, |
| 1510 | DestTy: &'a Type, |
| 1511 | Name: *const c_char, |
| 1512 | ) -> &'a Value; |
| 1513 | pub fn LLVMBuildPtrToInt( |
| 1514 | B: &Builder<'a>, |
| 1515 | Val: &'a Value, |
| 1516 | DestTy: &'a Type, |
| 1517 | Name: *const c_char, |
| 1518 | ) -> &'a Value; |
| 1519 | pub fn LLVMBuildIntToPtr( |
| 1520 | B: &Builder<'a>, |
| 1521 | Val: &'a Value, |
| 1522 | DestTy: &'a Type, |
| 1523 | Name: *const c_char, |
| 1524 | ) -> &'a Value; |
| 1525 | pub fn LLVMBuildBitCast( |
| 1526 | B: &Builder<'a>, |
| 1527 | Val: &'a Value, |
| 1528 | DestTy: &'a Type, |
| 1529 | Name: *const c_char, |
| 1530 | ) -> &'a Value; |
| 1531 | pub fn LLVMBuildPointerCast( |
| 1532 | B: &Builder<'a>, |
| 1533 | Val: &'a Value, |
| 1534 | DestTy: &'a Type, |
| 1535 | Name: *const c_char, |
| 1536 | ) -> &'a Value; |
| 1537 | pub fn LLVMRustBuildIntCast( |
| 1538 | B: &Builder<'a>, |
| 1539 | Val: &'a Value, |
| 1540 | DestTy: &'a Type, |
| 1541 | IsSized: bool, |
| 1542 | ) -> &'a Value; |
| 1543 | |
| 1544 | // Comparisons |
| 1545 | pub fn LLVMBuildICmp( |
| 1546 | B: &Builder<'a>, |
| 1547 | Op: c_uint, |
| 1548 | LHS: &'a Value, |
| 1549 | RHS: &'a Value, |
| 1550 | Name: *const c_char, |
| 1551 | ) -> &'a Value; |
| 1552 | pub fn LLVMBuildFCmp( |
| 1553 | B: &Builder<'a>, |
| 1554 | Op: c_uint, |
| 1555 | LHS: &'a Value, |
| 1556 | RHS: &'a Value, |
| 1557 | Name: *const c_char, |
| 1558 | ) -> &'a Value; |
| 1559 | |
| 1560 | // Miscellaneous instructions |
| 1561 | pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value; |
| 1562 | pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &'a Value; |
| 1563 | pub fn LLVMRustBuildCall( |
| 1564 | B: &Builder<'a>, |
Chris Wailes | bcf972c | 2021-10-21 11:03:28 -0700 | [diff] [blame] | 1565 | Ty: &'a Type, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1566 | Fn: &'a Value, |
| 1567 | Args: *const &'a Value, |
| 1568 | NumArgs: c_uint, |
| 1569 | Bundle: Option<&OperandBundleDef<'a>>, |
| 1570 | ) -> &'a Value; |
| 1571 | pub fn LLVMRustBuildMemCpy( |
| 1572 | B: &Builder<'a>, |
| 1573 | Dst: &'a Value, |
| 1574 | DstAlign: c_uint, |
| 1575 | Src: &'a Value, |
| 1576 | SrcAlign: c_uint, |
| 1577 | Size: &'a Value, |
| 1578 | IsVolatile: bool, |
| 1579 | ) -> &'a Value; |
| 1580 | pub fn LLVMRustBuildMemMove( |
| 1581 | B: &Builder<'a>, |
| 1582 | Dst: &'a Value, |
| 1583 | DstAlign: c_uint, |
| 1584 | Src: &'a Value, |
| 1585 | SrcAlign: c_uint, |
| 1586 | Size: &'a Value, |
| 1587 | IsVolatile: bool, |
| 1588 | ) -> &'a Value; |
| 1589 | pub fn LLVMRustBuildMemSet( |
| 1590 | B: &Builder<'a>, |
| 1591 | Dst: &'a Value, |
| 1592 | DstAlign: c_uint, |
| 1593 | Val: &'a Value, |
| 1594 | Size: &'a Value, |
| 1595 | IsVolatile: bool, |
| 1596 | ) -> &'a Value; |
| 1597 | pub fn LLVMBuildSelect( |
| 1598 | B: &Builder<'a>, |
| 1599 | If: &'a Value, |
| 1600 | Then: &'a Value, |
| 1601 | Else: &'a Value, |
| 1602 | Name: *const c_char, |
| 1603 | ) -> &'a Value; |
| 1604 | pub fn LLVMBuildVAArg( |
| 1605 | B: &Builder<'a>, |
| 1606 | list: &'a Value, |
| 1607 | Ty: &'a Type, |
| 1608 | Name: *const c_char, |
| 1609 | ) -> &'a Value; |
| 1610 | pub fn LLVMBuildExtractElement( |
| 1611 | B: &Builder<'a>, |
| 1612 | VecVal: &'a Value, |
| 1613 | Index: &'a Value, |
| 1614 | Name: *const c_char, |
| 1615 | ) -> &'a Value; |
| 1616 | pub fn LLVMBuildInsertElement( |
| 1617 | B: &Builder<'a>, |
| 1618 | VecVal: &'a Value, |
| 1619 | EltVal: &'a Value, |
| 1620 | Index: &'a Value, |
| 1621 | Name: *const c_char, |
| 1622 | ) -> &'a Value; |
| 1623 | pub fn LLVMBuildShuffleVector( |
| 1624 | B: &Builder<'a>, |
| 1625 | V1: &'a Value, |
| 1626 | V2: &'a Value, |
| 1627 | Mask: &'a Value, |
| 1628 | Name: *const c_char, |
| 1629 | ) -> &'a Value; |
| 1630 | pub fn LLVMBuildExtractValue( |
| 1631 | B: &Builder<'a>, |
| 1632 | AggVal: &'a Value, |
| 1633 | Index: c_uint, |
| 1634 | Name: *const c_char, |
| 1635 | ) -> &'a Value; |
| 1636 | pub fn LLVMBuildInsertValue( |
| 1637 | B: &Builder<'a>, |
| 1638 | AggVal: &'a Value, |
| 1639 | EltVal: &'a Value, |
| 1640 | Index: c_uint, |
| 1641 | Name: *const c_char, |
| 1642 | ) -> &'a Value; |
| 1643 | |
| 1644 | pub fn LLVMRustBuildVectorReduceFAdd( |
| 1645 | B: &Builder<'a>, |
| 1646 | Acc: &'a Value, |
| 1647 | Src: &'a Value, |
| 1648 | ) -> &'a Value; |
| 1649 | pub fn LLVMRustBuildVectorReduceFMul( |
| 1650 | B: &Builder<'a>, |
| 1651 | Acc: &'a Value, |
| 1652 | Src: &'a Value, |
| 1653 | ) -> &'a Value; |
| 1654 | pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>, Src: &'a Value) -> &'a Value; |
| 1655 | pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>, Src: &'a Value) -> &'a Value; |
| 1656 | pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>, Src: &'a Value) -> &'a Value; |
| 1657 | pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>, Src: &'a Value) -> &'a Value; |
| 1658 | pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>, Src: &'a Value) -> &'a Value; |
| 1659 | pub fn LLVMRustBuildVectorReduceMin( |
| 1660 | B: &Builder<'a>, |
| 1661 | Src: &'a Value, |
| 1662 | IsSigned: bool, |
| 1663 | ) -> &'a Value; |
| 1664 | pub fn LLVMRustBuildVectorReduceMax( |
| 1665 | B: &Builder<'a>, |
| 1666 | Src: &'a Value, |
| 1667 | IsSigned: bool, |
| 1668 | ) -> &'a Value; |
| 1669 | pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>, Src: &'a Value, IsNaN: bool) |
| 1670 | -> &'a Value; |
| 1671 | pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>, Src: &'a Value, IsNaN: bool) |
| 1672 | -> &'a Value; |
| 1673 | |
| 1674 | pub fn LLVMRustBuildMinNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value; |
| 1675 | pub fn LLVMRustBuildMaxNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value; |
| 1676 | |
| 1677 | // Atomic Operations |
| 1678 | pub fn LLVMRustBuildAtomicLoad( |
| 1679 | B: &Builder<'a>, |
Chris Wailes | 54272ac | 2021-09-09 16:08:13 -0700 | [diff] [blame] | 1680 | ElementType: &'a Type, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1681 | PointerVal: &'a Value, |
| 1682 | Name: *const c_char, |
| 1683 | Order: AtomicOrdering, |
| 1684 | ) -> &'a Value; |
| 1685 | |
| 1686 | pub fn LLVMRustBuildAtomicStore( |
| 1687 | B: &Builder<'a>, |
| 1688 | Val: &'a Value, |
| 1689 | Ptr: &'a Value, |
| 1690 | Order: AtomicOrdering, |
| 1691 | ) -> &'a Value; |
| 1692 | |
| 1693 | pub fn LLVMRustBuildAtomicCmpXchg( |
| 1694 | B: &Builder<'a>, |
| 1695 | LHS: &'a Value, |
| 1696 | CMP: &'a Value, |
| 1697 | RHS: &'a Value, |
| 1698 | Order: AtomicOrdering, |
| 1699 | FailureOrder: AtomicOrdering, |
| 1700 | Weak: Bool, |
| 1701 | ) -> &'a Value; |
| 1702 | |
| 1703 | pub fn LLVMBuildAtomicRMW( |
| 1704 | B: &Builder<'a>, |
| 1705 | Op: AtomicRmwBinOp, |
| 1706 | LHS: &'a Value, |
| 1707 | RHS: &'a Value, |
| 1708 | Order: AtomicOrdering, |
| 1709 | SingleThreaded: Bool, |
| 1710 | ) -> &'a Value; |
| 1711 | |
| 1712 | pub fn LLVMRustBuildAtomicFence( |
| 1713 | B: &Builder<'_>, |
| 1714 | Order: AtomicOrdering, |
| 1715 | Scope: SynchronizationScope, |
| 1716 | ); |
| 1717 | |
| 1718 | /// Writes a module to the specified path. Returns 0 on success. |
| 1719 | pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int; |
| 1720 | |
| 1721 | /// Creates a pass manager. |
| 1722 | pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>; |
| 1723 | |
| 1724 | /// Creates a function-by-function pass manager |
| 1725 | pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>; |
| 1726 | |
| 1727 | /// Disposes a pass manager. |
| 1728 | pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>); |
| 1729 | |
| 1730 | /// Runs a pass manager on a module. |
| 1731 | pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool; |
| 1732 | |
| 1733 | pub fn LLVMInitializePasses(); |
| 1734 | |
| 1735 | pub fn LLVMTimeTraceProfilerInitialize(); |
| 1736 | |
| 1737 | pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char); |
| 1738 | |
| 1739 | pub fn LLVMAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>); |
| 1740 | |
| 1741 | pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder; |
| 1742 | pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder); |
| 1743 | pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool); |
| 1744 | pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool); |
| 1745 | pub fn LLVMPassManagerBuilderUseInlinerWithThreshold( |
| 1746 | PMB: &PassManagerBuilder, |
| 1747 | threshold: c_uint, |
| 1748 | ); |
| 1749 | pub fn LLVMPassManagerBuilderPopulateModulePassManager( |
| 1750 | PMB: &PassManagerBuilder, |
| 1751 | PM: &PassManager<'_>, |
| 1752 | ); |
| 1753 | |
| 1754 | pub fn LLVMPassManagerBuilderPopulateFunctionPassManager( |
| 1755 | PMB: &PassManagerBuilder, |
| 1756 | PM: &PassManager<'_>, |
| 1757 | ); |
| 1758 | pub fn LLVMPassManagerBuilderPopulateLTOPassManager( |
| 1759 | PMB: &PassManagerBuilder, |
| 1760 | PM: &PassManager<'_>, |
| 1761 | Internalize: Bool, |
| 1762 | RunInliner: Bool, |
| 1763 | ); |
| 1764 | pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager( |
| 1765 | PMB: &PassManagerBuilder, |
| 1766 | PM: &PassManager<'_>, |
| 1767 | ); |
| 1768 | |
Jeff Vander Stoep | 59fbe18 | 2021-03-29 10:17:52 +0200 | [diff] [blame] | 1769 | pub fn LLVMGetHostCPUFeatures() -> *mut c_char; |
| 1770 | |
| 1771 | pub fn LLVMDisposeMessage(message: *mut c_char); |
| 1772 | |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1773 | pub fn LLVMStartMultithreaded() -> Bool; |
| 1774 | |
| 1775 | /// Returns a string describing the last error caused by an LLVMRust* call. |
| 1776 | pub fn LLVMRustGetLastError() -> *const c_char; |
| 1777 | |
| 1778 | /// Print the pass timings since static dtors aren't picking them up. |
| 1779 | pub fn LLVMRustPrintPassTimings(); |
| 1780 | |
| 1781 | pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type; |
| 1782 | |
| 1783 | pub fn LLVMStructSetBody( |
| 1784 | StructTy: &'a Type, |
| 1785 | ElementTypes: *const &'a Type, |
| 1786 | ElementCount: c_uint, |
| 1787 | Packed: Bool, |
| 1788 | ); |
| 1789 | |
| 1790 | /// Prepares inline assembly. |
| 1791 | pub fn LLVMRustInlineAsm( |
| 1792 | Ty: &Type, |
| 1793 | AsmString: *const c_char, |
| 1794 | AsmStringLen: size_t, |
| 1795 | Constraints: *const c_char, |
| 1796 | ConstraintsLen: size_t, |
| 1797 | SideEffects: Bool, |
| 1798 | AlignStack: Bool, |
| 1799 | Dialect: AsmDialect, |
| 1800 | ) -> &Value; |
| 1801 | pub fn LLVMRustInlineAsmVerify( |
| 1802 | Ty: &Type, |
| 1803 | Constraints: *const c_char, |
| 1804 | ConstraintsLen: size_t, |
| 1805 | ) -> bool; |
| 1806 | |
| 1807 | #[allow(improper_ctypes)] |
| 1808 | pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer( |
| 1809 | Filenames: *const *const c_char, |
| 1810 | FilenamesLen: size_t, |
| 1811 | BufferOut: &RustString, |
| 1812 | ); |
| 1813 | |
| 1814 | #[allow(improper_ctypes)] |
| 1815 | pub fn LLVMRustCoverageWriteMappingToBuffer( |
| 1816 | VirtualFileMappingIDs: *const c_uint, |
| 1817 | NumVirtualFileMappingIDs: c_uint, |
| 1818 | Expressions: *const coverage_map::CounterExpression, |
| 1819 | NumExpressions: c_uint, |
Chris Wailes | e3116c4 | 2021-07-13 14:40:48 -0700 | [diff] [blame] | 1820 | MappingRegions: *const coverageinfo::CounterMappingRegion, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1821 | NumMappingRegions: c_uint, |
| 1822 | BufferOut: &RustString, |
| 1823 | ); |
| 1824 | |
| 1825 | pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &'a Value, FuncName: *const c_char) |
| 1826 | -> &'a Value; |
Jeff Vander Stoep | d59a287 | 2021-02-15 10:22:21 +0100 | [diff] [blame] | 1827 | pub fn LLVMRustCoverageHashCString(StrVal: *const c_char) -> u64; |
| 1828 | pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64; |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1829 | |
| 1830 | #[allow(improper_ctypes)] |
Jeff Vander Stoep | d59a287 | 2021-02-15 10:22:21 +0100 | [diff] [blame] | 1831 | pub fn LLVMRustCoverageWriteMapSectionNameToString(M: &Module, Str: &RustString); |
| 1832 | |
| 1833 | #[allow(improper_ctypes)] |
| 1834 | pub fn LLVMRustCoverageWriteFuncSectionNameToString(M: &Module, Str: &RustString); |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1835 | |
| 1836 | #[allow(improper_ctypes)] |
| 1837 | pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString); |
| 1838 | |
| 1839 | pub fn LLVMRustCoverageMappingVersion() -> u32; |
| 1840 | pub fn LLVMRustDebugMetadataVersion() -> u32; |
| 1841 | pub fn LLVMRustVersionMajor() -> u32; |
| 1842 | pub fn LLVMRustVersionMinor() -> u32; |
Jeff Vander Stoep | 59fbe18 | 2021-03-29 10:17:52 +0200 | [diff] [blame] | 1843 | pub fn LLVMRustVersionPatch() -> u32; |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1844 | |
| 1845 | pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32); |
| 1846 | |
| 1847 | pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value; |
| 1848 | |
| 1849 | pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>; |
| 1850 | |
| 1851 | pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>); |
| 1852 | |
| 1853 | pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>); |
| 1854 | |
| 1855 | pub fn LLVMRustDIBuilderCreateCompileUnit( |
| 1856 | Builder: &DIBuilder<'a>, |
| 1857 | Lang: c_uint, |
| 1858 | File: &'a DIFile, |
| 1859 | Producer: *const c_char, |
| 1860 | ProducerLen: size_t, |
| 1861 | isOptimized: bool, |
| 1862 | Flags: *const c_char, |
| 1863 | RuntimeVer: c_uint, |
| 1864 | SplitName: *const c_char, |
| 1865 | SplitNameLen: size_t, |
| 1866 | kind: DebugEmissionKind, |
Jeff Vander Stoep | d59a287 | 2021-02-15 10:22:21 +0100 | [diff] [blame] | 1867 | DWOId: u64, |
| 1868 | SplitDebugInlining: bool, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1869 | ) -> &'a DIDescriptor; |
| 1870 | |
| 1871 | pub fn LLVMRustDIBuilderCreateFile( |
| 1872 | Builder: &DIBuilder<'a>, |
| 1873 | Filename: *const c_char, |
| 1874 | FilenameLen: size_t, |
| 1875 | Directory: *const c_char, |
| 1876 | DirectoryLen: size_t, |
| 1877 | CSKind: ChecksumKind, |
| 1878 | Checksum: *const c_char, |
| 1879 | ChecksumLen: size_t, |
| 1880 | ) -> &'a DIFile; |
| 1881 | |
| 1882 | pub fn LLVMRustDIBuilderCreateSubroutineType( |
| 1883 | Builder: &DIBuilder<'a>, |
| 1884 | ParameterTypes: &'a DIArray, |
| 1885 | ) -> &'a DICompositeType; |
| 1886 | |
| 1887 | pub fn LLVMRustDIBuilderCreateFunction( |
| 1888 | Builder: &DIBuilder<'a>, |
| 1889 | Scope: &'a DIDescriptor, |
| 1890 | Name: *const c_char, |
| 1891 | NameLen: size_t, |
| 1892 | LinkageName: *const c_char, |
| 1893 | LinkageNameLen: size_t, |
| 1894 | File: &'a DIFile, |
| 1895 | LineNo: c_uint, |
| 1896 | Ty: &'a DIType, |
| 1897 | ScopeLine: c_uint, |
| 1898 | Flags: DIFlags, |
| 1899 | SPFlags: DISPFlags, |
Thiébaud Weksteen | 5bd94c1 | 2021-01-06 15:18:42 +0100 | [diff] [blame] | 1900 | MaybeFn: Option<&'a Value>, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 1901 | TParam: &'a DIArray, |
| 1902 | Decl: Option<&'a DIDescriptor>, |
| 1903 | ) -> &'a DISubprogram; |
| 1904 | |
| 1905 | pub fn LLVMRustDIBuilderCreateBasicType( |
| 1906 | Builder: &DIBuilder<'a>, |
| 1907 | Name: *const c_char, |
| 1908 | NameLen: size_t, |
| 1909 | SizeInBits: u64, |
| 1910 | Encoding: c_uint, |
| 1911 | ) -> &'a DIBasicType; |
| 1912 | |
| 1913 | pub fn LLVMRustDIBuilderCreateTypedef( |
| 1914 | Builder: &DIBuilder<'a>, |
| 1915 | Type: &'a DIBasicType, |
| 1916 | Name: *const c_char, |
| 1917 | NameLen: size_t, |
| 1918 | File: &'a DIFile, |
| 1919 | LineNo: c_uint, |
| 1920 | Scope: Option<&'a DIScope>, |
| 1921 | ) -> &'a DIDerivedType; |
| 1922 | |
| 1923 | pub fn LLVMRustDIBuilderCreatePointerType( |
| 1924 | Builder: &DIBuilder<'a>, |
| 1925 | PointeeTy: &'a DIType, |
| 1926 | SizeInBits: u64, |
| 1927 | AlignInBits: u32, |
| 1928 | AddressSpace: c_uint, |
| 1929 | Name: *const c_char, |
| 1930 | NameLen: size_t, |
| 1931 | ) -> &'a DIDerivedType; |
| 1932 | |
| 1933 | pub fn LLVMRustDIBuilderCreateStructType( |
| 1934 | Builder: &DIBuilder<'a>, |
| 1935 | Scope: Option<&'a DIDescriptor>, |
| 1936 | Name: *const c_char, |
| 1937 | NameLen: size_t, |
| 1938 | File: &'a DIFile, |
| 1939 | LineNumber: c_uint, |
| 1940 | SizeInBits: u64, |
| 1941 | AlignInBits: u32, |
| 1942 | Flags: DIFlags, |
| 1943 | DerivedFrom: Option<&'a DIType>, |
| 1944 | Elements: &'a DIArray, |
| 1945 | RunTimeLang: c_uint, |
| 1946 | VTableHolder: Option<&'a DIType>, |
| 1947 | UniqueId: *const c_char, |
| 1948 | UniqueIdLen: size_t, |
| 1949 | ) -> &'a DICompositeType; |
| 1950 | |
| 1951 | pub fn LLVMRustDIBuilderCreateMemberType( |
| 1952 | Builder: &DIBuilder<'a>, |
| 1953 | Scope: &'a DIDescriptor, |
| 1954 | Name: *const c_char, |
| 1955 | NameLen: size_t, |
| 1956 | File: &'a DIFile, |
| 1957 | LineNo: c_uint, |
| 1958 | SizeInBits: u64, |
| 1959 | AlignInBits: u32, |
| 1960 | OffsetInBits: u64, |
| 1961 | Flags: DIFlags, |
| 1962 | Ty: &'a DIType, |
| 1963 | ) -> &'a DIDerivedType; |
| 1964 | |
| 1965 | pub fn LLVMRustDIBuilderCreateVariantMemberType( |
| 1966 | Builder: &DIBuilder<'a>, |
| 1967 | Scope: &'a DIScope, |
| 1968 | Name: *const c_char, |
| 1969 | NameLen: size_t, |
| 1970 | File: &'a DIFile, |
| 1971 | LineNumber: c_uint, |
| 1972 | SizeInBits: u64, |
| 1973 | AlignInBits: u32, |
| 1974 | OffsetInBits: u64, |
| 1975 | Discriminant: Option<&'a Value>, |
| 1976 | Flags: DIFlags, |
| 1977 | Ty: &'a DIType, |
| 1978 | ) -> &'a DIType; |
| 1979 | |
| 1980 | pub fn LLVMRustDIBuilderCreateLexicalBlock( |
| 1981 | Builder: &DIBuilder<'a>, |
| 1982 | Scope: &'a DIScope, |
| 1983 | File: &'a DIFile, |
| 1984 | Line: c_uint, |
| 1985 | Col: c_uint, |
| 1986 | ) -> &'a DILexicalBlock; |
| 1987 | |
| 1988 | pub fn LLVMRustDIBuilderCreateLexicalBlockFile( |
| 1989 | Builder: &DIBuilder<'a>, |
| 1990 | Scope: &'a DIScope, |
| 1991 | File: &'a DIFile, |
| 1992 | ) -> &'a DILexicalBlock; |
| 1993 | |
| 1994 | pub fn LLVMRustDIBuilderCreateStaticVariable( |
| 1995 | Builder: &DIBuilder<'a>, |
| 1996 | Context: Option<&'a DIScope>, |
| 1997 | Name: *const c_char, |
| 1998 | NameLen: size_t, |
| 1999 | LinkageName: *const c_char, |
| 2000 | LinkageNameLen: size_t, |
| 2001 | File: &'a DIFile, |
| 2002 | LineNo: c_uint, |
| 2003 | Ty: &'a DIType, |
| 2004 | isLocalToUnit: bool, |
| 2005 | Val: &'a Value, |
| 2006 | Decl: Option<&'a DIDescriptor>, |
| 2007 | AlignInBits: u32, |
| 2008 | ) -> &'a DIGlobalVariableExpression; |
| 2009 | |
| 2010 | pub fn LLVMRustDIBuilderCreateVariable( |
| 2011 | Builder: &DIBuilder<'a>, |
| 2012 | Tag: c_uint, |
| 2013 | Scope: &'a DIDescriptor, |
| 2014 | Name: *const c_char, |
| 2015 | NameLen: size_t, |
| 2016 | File: &'a DIFile, |
| 2017 | LineNo: c_uint, |
| 2018 | Ty: &'a DIType, |
| 2019 | AlwaysPreserve: bool, |
| 2020 | Flags: DIFlags, |
| 2021 | ArgNo: c_uint, |
| 2022 | AlignInBits: u32, |
| 2023 | ) -> &'a DIVariable; |
| 2024 | |
| 2025 | pub fn LLVMRustDIBuilderCreateArrayType( |
| 2026 | Builder: &DIBuilder<'a>, |
| 2027 | Size: u64, |
| 2028 | AlignInBits: u32, |
| 2029 | Ty: &'a DIType, |
| 2030 | Subscripts: &'a DIArray, |
| 2031 | ) -> &'a DIType; |
| 2032 | |
| 2033 | pub fn LLVMRustDIBuilderGetOrCreateSubrange( |
| 2034 | Builder: &DIBuilder<'a>, |
| 2035 | Lo: i64, |
| 2036 | Count: i64, |
| 2037 | ) -> &'a DISubrange; |
| 2038 | |
| 2039 | pub fn LLVMRustDIBuilderGetOrCreateArray( |
| 2040 | Builder: &DIBuilder<'a>, |
| 2041 | Ptr: *const Option<&'a DIDescriptor>, |
| 2042 | Count: c_uint, |
| 2043 | ) -> &'a DIArray; |
| 2044 | |
| 2045 | pub fn LLVMRustDIBuilderInsertDeclareAtEnd( |
| 2046 | Builder: &DIBuilder<'a>, |
| 2047 | Val: &'a Value, |
| 2048 | VarInfo: &'a DIVariable, |
| 2049 | AddrOps: *const i64, |
| 2050 | AddrOpsCount: c_uint, |
Thiébaud Weksteen | 5bd94c1 | 2021-01-06 15:18:42 +0100 | [diff] [blame] | 2051 | DL: &'a DILocation, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2052 | InsertAtEnd: &'a BasicBlock, |
| 2053 | ) -> &'a Value; |
| 2054 | |
| 2055 | pub fn LLVMRustDIBuilderCreateEnumerator( |
| 2056 | Builder: &DIBuilder<'a>, |
| 2057 | Name: *const c_char, |
| 2058 | NameLen: size_t, |
| 2059 | Value: i64, |
| 2060 | IsUnsigned: bool, |
| 2061 | ) -> &'a DIEnumerator; |
| 2062 | |
| 2063 | pub fn LLVMRustDIBuilderCreateEnumerationType( |
| 2064 | Builder: &DIBuilder<'a>, |
| 2065 | Scope: &'a DIScope, |
| 2066 | Name: *const c_char, |
| 2067 | NameLen: size_t, |
| 2068 | File: &'a DIFile, |
| 2069 | LineNumber: c_uint, |
| 2070 | SizeInBits: u64, |
| 2071 | AlignInBits: u32, |
| 2072 | Elements: &'a DIArray, |
| 2073 | ClassType: &'a DIType, |
| 2074 | IsScoped: bool, |
| 2075 | ) -> &'a DIType; |
| 2076 | |
| 2077 | pub fn LLVMRustDIBuilderCreateUnionType( |
| 2078 | Builder: &DIBuilder<'a>, |
Chris Wailes | 2f3fdfe | 2021-07-29 10:56:18 -0700 | [diff] [blame] | 2079 | Scope: Option<&'a DIScope>, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2080 | Name: *const c_char, |
| 2081 | NameLen: size_t, |
| 2082 | File: &'a DIFile, |
| 2083 | LineNumber: c_uint, |
| 2084 | SizeInBits: u64, |
| 2085 | AlignInBits: u32, |
| 2086 | Flags: DIFlags, |
| 2087 | Elements: Option<&'a DIArray>, |
| 2088 | RunTimeLang: c_uint, |
| 2089 | UniqueId: *const c_char, |
| 2090 | UniqueIdLen: size_t, |
| 2091 | ) -> &'a DIType; |
| 2092 | |
| 2093 | pub fn LLVMRustDIBuilderCreateVariantPart( |
| 2094 | Builder: &DIBuilder<'a>, |
| 2095 | Scope: &'a DIScope, |
| 2096 | Name: *const c_char, |
| 2097 | NameLen: size_t, |
| 2098 | File: &'a DIFile, |
| 2099 | LineNo: c_uint, |
| 2100 | SizeInBits: u64, |
| 2101 | AlignInBits: u32, |
| 2102 | Flags: DIFlags, |
| 2103 | Discriminator: Option<&'a DIDerivedType>, |
| 2104 | Elements: &'a DIArray, |
| 2105 | UniqueId: *const c_char, |
| 2106 | UniqueIdLen: size_t, |
| 2107 | ) -> &'a DIDerivedType; |
| 2108 | |
| 2109 | pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr); |
| 2110 | |
| 2111 | pub fn LLVMRustDIBuilderCreateTemplateTypeParameter( |
| 2112 | Builder: &DIBuilder<'a>, |
| 2113 | Scope: Option<&'a DIScope>, |
| 2114 | Name: *const c_char, |
| 2115 | NameLen: size_t, |
| 2116 | Ty: &'a DIType, |
| 2117 | ) -> &'a DITemplateTypeParameter; |
| 2118 | |
| 2119 | pub fn LLVMRustDIBuilderCreateNameSpace( |
| 2120 | Builder: &DIBuilder<'a>, |
| 2121 | Scope: Option<&'a DIScope>, |
| 2122 | Name: *const c_char, |
| 2123 | NameLen: size_t, |
| 2124 | ExportSymbols: bool, |
| 2125 | ) -> &'a DINameSpace; |
| 2126 | |
| 2127 | pub fn LLVMRustDICompositeTypeReplaceArrays( |
| 2128 | Builder: &DIBuilder<'a>, |
| 2129 | CompositeType: &'a DIType, |
| 2130 | Elements: Option<&'a DIArray>, |
| 2131 | Params: Option<&'a DIArray>, |
| 2132 | ); |
| 2133 | |
| 2134 | pub fn LLVMRustDIBuilderCreateDebugLocation( |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2135 | Line: c_uint, |
| 2136 | Column: c_uint, |
| 2137 | Scope: &'a DIScope, |
Thiébaud Weksteen | 5bd94c1 | 2021-01-06 15:18:42 +0100 | [diff] [blame] | 2138 | InlinedAt: Option<&'a DILocation>, |
| 2139 | ) -> &'a DILocation; |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2140 | pub fn LLVMRustDIBuilderCreateOpDeref() -> i64; |
| 2141 | pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64; |
| 2142 | |
| 2143 | #[allow(improper_ctypes)] |
| 2144 | pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString); |
| 2145 | #[allow(improper_ctypes)] |
| 2146 | pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString); |
| 2147 | |
| 2148 | pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>; |
| 2149 | |
| 2150 | pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind; |
| 2151 | pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>; |
| 2152 | pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass; |
| 2153 | pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass; |
| 2154 | pub fn LLVMRustCreateMemorySanitizerPass( |
| 2155 | TrackOrigins: c_int, |
| 2156 | Recover: bool, |
| 2157 | ) -> &'static mut Pass; |
| 2158 | pub fn LLVMRustCreateThreadSanitizerPass() -> &'static mut Pass; |
Chris Wailes | e3116c4 | 2021-07-13 14:40:48 -0700 | [diff] [blame] | 2159 | pub fn LLVMRustCreateHWAddressSanitizerPass(Recover: bool) -> &'static mut Pass; |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2160 | pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass); |
| 2161 | pub fn LLVMRustAddLastExtensionPasses( |
| 2162 | PMB: &PassManagerBuilder, |
| 2163 | Passes: *const &'static mut Pass, |
| 2164 | NumPasses: size_t, |
| 2165 | ); |
| 2166 | |
| 2167 | pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool; |
| 2168 | |
| 2169 | pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine); |
Chris Wailes | 32f7835 | 2021-07-20 14:04:55 -0700 | [diff] [blame] | 2170 | pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t; |
| 2171 | pub fn LLVMRustGetTargetFeature( |
| 2172 | T: &TargetMachine, |
| 2173 | Index: size_t, |
| 2174 | Feature: &mut *const c_char, |
| 2175 | Desc: &mut *const c_char, |
| 2176 | ); |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2177 | |
| 2178 | pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char; |
| 2179 | pub fn LLVMRustCreateTargetMachine( |
| 2180 | Triple: *const c_char, |
| 2181 | CPU: *const c_char, |
| 2182 | Features: *const c_char, |
| 2183 | Abi: *const c_char, |
| 2184 | Model: CodeModel, |
| 2185 | Reloc: RelocModel, |
| 2186 | Level: CodeGenOptLevel, |
| 2187 | UseSoftFP: bool, |
| 2188 | FunctionSections: bool, |
| 2189 | DataSections: bool, |
| 2190 | TrapUnreachable: bool, |
| 2191 | Singlethread: bool, |
| 2192 | AsmComments: bool, |
| 2193 | EmitStackSizeSection: bool, |
| 2194 | RelaxELFRelocations: bool, |
| 2195 | UseInitArray: bool, |
Jeff Vander Stoep | d59a287 | 2021-02-15 10:22:21 +0100 | [diff] [blame] | 2196 | SplitDwarfFile: *const c_char, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2197 | ) -> Option<&'static mut TargetMachine>; |
| 2198 | pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine); |
| 2199 | pub fn LLVMRustAddBuilderLibraryInfo( |
| 2200 | PMB: &'a PassManagerBuilder, |
| 2201 | M: &'a Module, |
| 2202 | DisableSimplifyLibCalls: bool, |
| 2203 | ); |
| 2204 | pub fn LLVMRustConfigurePassManagerBuilder( |
| 2205 | PMB: &PassManagerBuilder, |
| 2206 | OptLevel: CodeGenOptLevel, |
| 2207 | MergeFunctions: bool, |
| 2208 | SLPVectorize: bool, |
| 2209 | LoopVectorize: bool, |
| 2210 | PrepareForThinLTO: bool, |
| 2211 | PGOGenPath: *const c_char, |
| 2212 | PGOUsePath: *const c_char, |
Chris Wailes | a153842 | 2021-12-02 10:37:12 -0800 | [diff] [blame^] | 2213 | PGOSampleUsePath: *const c_char, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2214 | ); |
| 2215 | pub fn LLVMRustAddLibraryInfo( |
| 2216 | PM: &PassManager<'a>, |
| 2217 | M: &'a Module, |
| 2218 | DisableSimplifyLibCalls: bool, |
| 2219 | ); |
| 2220 | pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module); |
| 2221 | pub fn LLVMRustWriteOutputFile( |
| 2222 | T: &'a TargetMachine, |
| 2223 | PM: &PassManager<'a>, |
| 2224 | M: &'a Module, |
| 2225 | Output: *const c_char, |
Jeff Vander Stoep | d59a287 | 2021-02-15 10:22:21 +0100 | [diff] [blame] | 2226 | DwoOutput: *const c_char, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2227 | FileType: FileType, |
| 2228 | ) -> LLVMRustResult; |
| 2229 | pub fn LLVMRustOptimizeWithNewPassManager( |
| 2230 | M: &'a Module, |
| 2231 | TM: &'a TargetMachine, |
| 2232 | OptLevel: PassBuilderOptLevel, |
| 2233 | OptStage: OptStage, |
| 2234 | NoPrepopulatePasses: bool, |
| 2235 | VerifyIR: bool, |
| 2236 | UseThinLTOBuffers: bool, |
| 2237 | MergeFunctions: bool, |
| 2238 | UnrollLoops: bool, |
| 2239 | SLPVectorize: bool, |
| 2240 | LoopVectorize: bool, |
| 2241 | DisableSimplifyLibCalls: bool, |
| 2242 | EmitLifetimeMarkers: bool, |
| 2243 | SanitizerOptions: Option<&SanitizerOptions>, |
| 2244 | PGOGenPath: *const c_char, |
| 2245 | PGOUsePath: *const c_char, |
Chris Wailes | 2f3fdfe | 2021-07-29 10:56:18 -0700 | [diff] [blame] | 2246 | InstrumentCoverage: bool, |
| 2247 | InstrumentGCOV: bool, |
Chris Wailes | a153842 | 2021-12-02 10:37:12 -0800 | [diff] [blame^] | 2248 | PGOSampleUsePath: *const c_char, |
| 2249 | DebugInfoForProfiling: bool, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2250 | llvm_selfprofiler: *mut c_void, |
| 2251 | begin_callback: SelfProfileBeforePassCallback, |
| 2252 | end_callback: SelfProfileAfterPassCallback, |
Chris Wailes | 2f3fdfe | 2021-07-29 10:56:18 -0700 | [diff] [blame] | 2253 | ExtraPasses: *const c_char, |
| 2254 | ExtraPassesLen: size_t, |
| 2255 | ) -> LLVMRustResult; |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2256 | pub fn LLVMRustPrintModule( |
| 2257 | M: &'a Module, |
| 2258 | Output: *const c_char, |
| 2259 | Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t, |
| 2260 | ) -> LLVMRustResult; |
| 2261 | pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char); |
| 2262 | pub fn LLVMRustPrintPasses(); |
| 2263 | pub fn LLVMRustGetInstructionCount(M: &Module) -> u32; |
| 2264 | pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char); |
| 2265 | pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool); |
| 2266 | pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t); |
| 2267 | pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module); |
| 2268 | |
| 2269 | pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>; |
| 2270 | pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>; |
| 2271 | pub fn LLVMRustArchiveIteratorNext( |
| 2272 | AIR: &ArchiveIterator<'a>, |
| 2273 | ) -> Option<&'a mut ArchiveChild<'a>>; |
| 2274 | pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char; |
| 2275 | pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char; |
| 2276 | pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>); |
| 2277 | pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>); |
| 2278 | pub fn LLVMRustDestroyArchive(AR: &'static mut Archive); |
| 2279 | |
| 2280 | #[allow(improper_ctypes)] |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2281 | pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString); |
| 2282 | |
| 2283 | pub fn LLVMContextSetDiagnosticHandler( |
| 2284 | C: &Context, |
| 2285 | Handler: DiagnosticHandler, |
| 2286 | DiagnosticContext: *mut c_void, |
| 2287 | ); |
| 2288 | |
| 2289 | #[allow(improper_ctypes)] |
| 2290 | pub fn LLVMRustUnpackOptimizationDiagnostic( |
| 2291 | DI: &'a DiagnosticInfo, |
| 2292 | pass_name_out: &RustString, |
| 2293 | function_out: &mut Option<&'a Value>, |
| 2294 | loc_line_out: &mut c_uint, |
| 2295 | loc_column_out: &mut c_uint, |
| 2296 | loc_filename_out: &RustString, |
| 2297 | message_out: &RustString, |
| 2298 | ); |
| 2299 | |
| 2300 | pub fn LLVMRustUnpackInlineAsmDiagnostic( |
| 2301 | DI: &'a DiagnosticInfo, |
| 2302 | level_out: &mut DiagnosticLevel, |
| 2303 | cookie_out: &mut c_uint, |
| 2304 | message_out: &mut Option<&'a Twine>, |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2305 | ); |
| 2306 | |
| 2307 | #[allow(improper_ctypes)] |
| 2308 | pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString); |
| 2309 | pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind; |
| 2310 | |
Chris Wailes | bcf972c | 2021-10-21 11:03:28 -0700 | [diff] [blame] | 2311 | pub fn LLVMRustGetSMDiagnostic( |
| 2312 | DI: &'a DiagnosticInfo, |
| 2313 | cookie_out: &mut c_uint, |
| 2314 | ) -> &'a SMDiagnostic; |
| 2315 | |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2316 | pub fn LLVMRustSetInlineAsmDiagnosticHandler( |
| 2317 | C: &Context, |
| 2318 | H: InlineAsmDiagHandler, |
| 2319 | CX: *mut c_void, |
| 2320 | ); |
| 2321 | |
| 2322 | #[allow(improper_ctypes)] |
| 2323 | pub fn LLVMRustUnpackSMDiagnostic( |
| 2324 | d: &SMDiagnostic, |
| 2325 | message_out: &RustString, |
| 2326 | buffer_out: &RustString, |
| 2327 | level_out: &mut DiagnosticLevel, |
| 2328 | loc_out: &mut c_uint, |
| 2329 | ranges_out: *mut c_uint, |
| 2330 | num_ranges: &mut usize, |
| 2331 | ) -> bool; |
| 2332 | |
| 2333 | pub fn LLVMRustWriteArchive( |
| 2334 | Dst: *const c_char, |
| 2335 | NumMembers: size_t, |
| 2336 | Members: *const &RustArchiveMember<'_>, |
| 2337 | WriteSymbtab: bool, |
| 2338 | Kind: ArchiveKind, |
| 2339 | ) -> LLVMRustResult; |
| 2340 | pub fn LLVMRustArchiveMemberNew( |
| 2341 | Filename: *const c_char, |
| 2342 | Name: *const c_char, |
| 2343 | Child: Option<&ArchiveChild<'a>>, |
| 2344 | ) -> &'a mut RustArchiveMember<'a>; |
| 2345 | pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>); |
| 2346 | |
Chris Wailes | 2f3fdfe | 2021-07-29 10:56:18 -0700 | [diff] [blame] | 2347 | pub fn LLVMRustWriteImportLibrary( |
| 2348 | ImportName: *const c_char, |
| 2349 | Path: *const c_char, |
| 2350 | Exports: *const LLVMRustCOFFShortExport, |
| 2351 | NumExports: usize, |
| 2352 | Machine: u16, |
| 2353 | MinGW: bool, |
| 2354 | ) -> LLVMRustResult; |
| 2355 | |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2356 | pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine); |
| 2357 | |
| 2358 | pub fn LLVMRustBuildOperandBundleDef( |
| 2359 | Name: *const c_char, |
| 2360 | Inputs: *const &'a Value, |
| 2361 | NumInputs: c_uint, |
| 2362 | ) -> &'a mut OperandBundleDef<'a>; |
| 2363 | pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>); |
| 2364 | |
| 2365 | pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock); |
| 2366 | |
| 2367 | pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t); |
| 2368 | pub fn LLVMRustUnsetComdat(V: &Value); |
| 2369 | pub fn LLVMRustSetModulePICLevel(M: &Module); |
| 2370 | pub fn LLVMRustSetModulePIELevel(M: &Module); |
Chris Wailes | e3116c4 | 2021-07-13 14:40:48 -0700 | [diff] [blame] | 2371 | pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel); |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2372 | pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer; |
| 2373 | pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8; |
| 2374 | pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize; |
| 2375 | pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer); |
| 2376 | pub fn LLVMRustModuleCost(M: &Module) -> u64; |
| 2377 | |
| 2378 | pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer; |
| 2379 | pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer); |
| 2380 | pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char; |
| 2381 | pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t; |
| 2382 | pub fn LLVMRustCreateThinLTOData( |
| 2383 | Modules: *const ThinLTOModule, |
| 2384 | NumModules: c_uint, |
| 2385 | PreservedSymbols: *const *const c_char, |
| 2386 | PreservedSymbolsLen: c_uint, |
| 2387 | ) -> Option<&'static mut ThinLTOData>; |
| 2388 | pub fn LLVMRustPrepareThinLTORename( |
| 2389 | Data: &ThinLTOData, |
| 2390 | Module: &Module, |
| 2391 | Target: &TargetMachine, |
| 2392 | ) -> bool; |
| 2393 | pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool; |
| 2394 | pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool; |
| 2395 | pub fn LLVMRustPrepareThinLTOImport( |
| 2396 | Data: &ThinLTOData, |
| 2397 | Module: &Module, |
| 2398 | Target: &TargetMachine, |
| 2399 | ) -> bool; |
| 2400 | pub fn LLVMRustGetThinLTOModuleImports( |
| 2401 | Data: *const ThinLTOData, |
| 2402 | ModuleNameCallback: ThinLTOModuleNameCallback, |
| 2403 | CallbackPayload: *mut c_void, |
| 2404 | ); |
| 2405 | pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData); |
| 2406 | pub fn LLVMRustParseBitcodeForLTO( |
| 2407 | Context: &Context, |
| 2408 | Data: *const u8, |
| 2409 | len: usize, |
| 2410 | Identifier: *const c_char, |
| 2411 | ) -> Option<&Module>; |
| 2412 | pub fn LLVMRustGetBitcodeSliceFromObjectData( |
| 2413 | Data: *const u8, |
| 2414 | len: usize, |
| 2415 | out_len: &mut usize, |
| 2416 | ) -> *const u8; |
Chris Wailes | a153842 | 2021-12-02 10:37:12 -0800 | [diff] [blame^] | 2417 | pub fn LLVMRustLTOGetDICompileUnit(M: &Module, CU1: &mut *mut c_void, CU2: &mut *mut c_void); |
| 2418 | pub fn LLVMRustLTOPatchDICompileUnit(M: &Module, CU: *mut c_void); |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2419 | |
| 2420 | pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>; |
| 2421 | pub fn LLVMRustLinkerAdd( |
| 2422 | linker: &Linker<'_>, |
| 2423 | bytecode: *const c_char, |
| 2424 | bytecode_len: usize, |
| 2425 | ) -> bool; |
| 2426 | pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>); |
Thiébaud Weksteen | 5bd94c1 | 2021-01-06 15:18:42 +0100 | [diff] [blame] | 2427 | #[allow(improper_ctypes)] |
| 2428 | pub fn LLVMRustComputeLTOCacheKey( |
| 2429 | key_out: &RustString, |
| 2430 | mod_id: *const c_char, |
| 2431 | data: &ThinLTOData, |
| 2432 | ); |
Thiébaud Weksteen | 3b664ca | 2020-11-26 14:41:59 +0100 | [diff] [blame] | 2433 | } |