2019-07-23 17:34:17 +00:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
#![allow(non_upper_case_globals)]
|
|
|
|
|
2020-07-25 04:14:28 +00:00
|
|
|
use crate::coverageinfo::CounterMappingRegion;
|
2020-07-02 18:27:15 +00:00
|
|
|
|
2018-05-29 17:41:36 +00:00
|
|
|
use super::debuginfo::{
|
2019-12-22 22:42:04 +00:00
|
|
|
DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
|
|
|
|
DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DINameSpace, DISPFlags, DIScope,
|
|
|
|
DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind,
|
2018-05-29 17:41:36 +00:00
|
|
|
};
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
use libc::{c_char, c_int, c_uint, size_t};
|
2018-07-10 15:00:02 +00:00
|
|
|
use libc::{c_ulonglong, c_void};
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-16 13:02:31 +00:00
|
|
|
use std::marker::PhantomData;
|
2018-06-27 10:12:47 +00:00
|
|
|
|
2018-07-13 11:43:12 +00:00
|
|
|
use super::RustString;
|
2016-08-02 21:25:19 +00:00
|
|
|
|
2016-08-02 20:10:10 +00:00
|
|
|
pub type Bool = c_uint;
|
|
|
|
|
|
|
|
pub const True: Bool = 1 as Bool;
|
|
|
|
pub const False: Bool = 0 as Bool;
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
2018-07-10 15:00:02 +00:00
|
|
|
#[allow(dead_code)] // Variants constructed by C++.
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum LLVMRustResult {
|
|
|
|
Success,
|
|
|
|
Failure,
|
|
|
|
}
|
|
|
|
// Consts for the LLVM CallConv type, pre-cast to usize.
|
|
|
|
|
|
|
|
/// LLVM CallingConv::ID. Should we wrap this?
|
2016-12-31 02:55:29 +00:00
|
|
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
2016-08-02 20:10:10 +00:00
|
|
|
#[repr(C)]
|
|
|
|
pub enum CallConv {
|
|
|
|
CCallConv = 0,
|
|
|
|
FastCallConv = 8,
|
|
|
|
ColdCallConv = 9,
|
|
|
|
X86StdcallCallConv = 64,
|
|
|
|
X86FastcallCallConv = 65,
|
2016-11-16 22:33:23 +00:00
|
|
|
ArmAapcsCallConv = 67,
|
2016-12-19 04:45:20 +00:00
|
|
|
Msp430Intr = 69,
|
2017-05-17 13:40:46 +00:00
|
|
|
X86_ThisCall = 70,
|
2016-12-22 21:24:29 +00:00
|
|
|
PtxKernel = 71,
|
2016-06-27 00:34:02 +00:00
|
|
|
X86_64_SysV = 78,
|
2016-08-02 20:10:10 +00:00
|
|
|
X86_64_Win64 = 79,
|
2016-10-22 13:07:35 +00:00
|
|
|
X86_VectorCall = 80,
|
2017-02-14 20:39:42 +00:00
|
|
|
X86_Intr = 83,
|
2016-05-06 13:32:10 +00:00
|
|
|
AvrNonBlockingInterrupt = 84,
|
|
|
|
AvrInterrupt = 85,
|
2018-07-02 03:42:00 +00:00
|
|
|
AmdGpuKernel = 91,
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|
|
|
|
|
2016-09-01 18:52:33 +00:00
|
|
|
/// LLVMRustLinkage
|
2019-10-20 04:54:53 +00:00
|
|
|
#[derive(PartialEq)]
|
2016-08-02 20:10:10 +00:00
|
|
|
#[repr(C)]
|
|
|
|
pub enum Linkage {
|
|
|
|
ExternalLinkage = 0,
|
|
|
|
AvailableExternallyLinkage = 1,
|
|
|
|
LinkOnceAnyLinkage = 2,
|
|
|
|
LinkOnceODRLinkage = 3,
|
2016-09-01 18:52:33 +00:00
|
|
|
WeakAnyLinkage = 4,
|
|
|
|
WeakODRLinkage = 5,
|
|
|
|
AppendingLinkage = 6,
|
|
|
|
InternalLinkage = 7,
|
|
|
|
PrivateLinkage = 8,
|
|
|
|
ExternalWeakLinkage = 9,
|
|
|
|
CommonLinkage = 10,
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|
|
|
|
|
2016-11-28 22:44:51 +00:00
|
|
|
// LLVMRustVisibility
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum Visibility {
|
|
|
|
Default = 0,
|
|
|
|
Hidden = 1,
|
|
|
|
Protected = 2,
|
|
|
|
}
|
|
|
|
|
2020-03-11 00:00:00 +00:00
|
|
|
/// LLVMUnnamedAddr
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum UnnamedAddr {
|
|
|
|
No,
|
|
|
|
Local,
|
|
|
|
Global,
|
|
|
|
}
|
|
|
|
|
2016-08-02 21:25:19 +00:00
|
|
|
/// LLVMDLLStorageClass
|
2016-08-02 20:10:10 +00:00
|
|
|
#[derive(Copy, Clone)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
|
|
|
pub enum DLLStorageClass {
|
2018-07-10 15:00:02 +00:00
|
|
|
#[allow(dead_code)]
|
2016-10-22 13:07:35 +00:00
|
|
|
Default = 0,
|
|
|
|
DllImport = 1, // Function to be imported from DLL.
|
2018-07-10 15:00:02 +00:00
|
|
|
#[allow(dead_code)]
|
2016-10-22 13:07:35 +00:00
|
|
|
DllExport = 2, // Function to be accessible from DLL.
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|
|
|
|
|
2016-11-16 22:36:08 +00:00
|
|
|
/// Matches LLVMRustAttribute in rustllvm.h
|
|
|
|
/// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
|
|
|
|
/// though it is not ABI compatible (since it's a C++ enum)
|
|
|
|
#[repr(C)]
|
|
|
|
#[derive(Copy, Clone, Debug)]
|
|
|
|
pub enum Attribute {
|
2019-12-22 22:42:04 +00:00
|
|
|
AlwaysInline = 0,
|
|
|
|
ByVal = 1,
|
|
|
|
Cold = 2,
|
|
|
|
InlineHint = 3,
|
|
|
|
MinSize = 4,
|
|
|
|
Naked = 5,
|
|
|
|
NoAlias = 6,
|
|
|
|
NoCapture = 7,
|
|
|
|
NoInline = 8,
|
|
|
|
NonNull = 9,
|
|
|
|
NoRedZone = 10,
|
|
|
|
NoReturn = 11,
|
|
|
|
NoUnwind = 12,
|
2016-11-16 22:36:08 +00:00
|
|
|
OptimizeForSize = 13,
|
2019-12-22 22:42:04 +00:00
|
|
|
ReadOnly = 14,
|
|
|
|
SExt = 15,
|
|
|
|
StructRet = 16,
|
|
|
|
UWTable = 17,
|
|
|
|
ZExt = 18,
|
|
|
|
InReg = 19,
|
|
|
|
SanitizeThread = 20,
|
2017-02-03 23:58:47 +00:00
|
|
|
SanitizeAddress = 21,
|
2019-12-22 22:42:04 +00:00
|
|
|
SanitizeMemory = 22,
|
|
|
|
NonLazyBind = 23,
|
|
|
|
OptimizeNone = 24,
|
|
|
|
ReturnsTwice = 25,
|
2020-02-17 21:36:01 +00:00
|
|
|
ReadNone = 26,
|
|
|
|
InaccessibleMemOnly = 27,
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// LLVMIntPredicate
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum IntPredicate {
|
|
|
|
IntEQ = 32,
|
|
|
|
IntNE = 33,
|
|
|
|
IntUGT = 34,
|
|
|
|
IntUGE = 35,
|
|
|
|
IntULT = 36,
|
|
|
|
IntULE = 37,
|
|
|
|
IntSGT = 38,
|
|
|
|
IntSGE = 39,
|
|
|
|
IntSLT = 40,
|
|
|
|
IntSLE = 41,
|
|
|
|
}
|
|
|
|
|
2018-08-21 14:31:36 +00:00
|
|
|
impl IntPredicate {
|
2018-10-01 16:07:04 +00:00
|
|
|
pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
|
2018-08-20 16:16:51 +00:00
|
|
|
match intpre {
|
2018-10-01 16:07:04 +00:00
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
|
2018-08-20 16:16:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 20:10:10 +00:00
|
|
|
/// LLVMRealPredicate
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum RealPredicate {
|
|
|
|
RealPredicateFalse = 0,
|
|
|
|
RealOEQ = 1,
|
|
|
|
RealOGT = 2,
|
|
|
|
RealOGE = 3,
|
|
|
|
RealOLT = 4,
|
|
|
|
RealOLE = 5,
|
|
|
|
RealONE = 6,
|
|
|
|
RealORD = 7,
|
|
|
|
RealUNO = 8,
|
|
|
|
RealUEQ = 9,
|
|
|
|
RealUGT = 10,
|
|
|
|
RealUGE = 11,
|
|
|
|
RealULT = 12,
|
|
|
|
RealULE = 13,
|
|
|
|
RealUNE = 14,
|
|
|
|
RealPredicateTrue = 15,
|
|
|
|
}
|
|
|
|
|
2018-08-21 14:31:36 +00:00
|
|
|
impl RealPredicate {
|
2018-10-01 16:07:04 +00:00
|
|
|
pub fn from_generic(realpred: rustc_codegen_ssa::common::RealPredicate) -> Self {
|
2018-08-21 11:54:41 +00:00
|
|
|
match realpred {
|
2019-12-22 22:42:04 +00:00
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
|
|
|
|
RealPredicate::RealPredicateFalse
|
|
|
|
}
|
2018-10-01 16:07:04 +00:00
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
|
2019-12-22 22:42:04 +00:00
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
|
2018-09-28 10:18:03 +00:00
|
|
|
RealPredicate::RealPredicateTrue
|
2019-12-22 22:42:04 +00:00
|
|
|
}
|
2018-08-21 11:54:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 21:25:19 +00:00
|
|
|
/// LLVMTypeKind
|
2016-08-02 20:10:10 +00:00
|
|
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum TypeKind {
|
2016-10-22 13:07:35 +00:00
|
|
|
Void = 0,
|
|
|
|
Half = 1,
|
|
|
|
Float = 2,
|
|
|
|
Double = 3,
|
|
|
|
X86_FP80 = 4,
|
|
|
|
FP128 = 5,
|
2018-09-28 10:18:03 +00:00
|
|
|
PPC_FP128 = 6,
|
2016-10-22 13:07:35 +00:00
|
|
|
Label = 7,
|
|
|
|
Integer = 8,
|
|
|
|
Function = 9,
|
|
|
|
Struct = 10,
|
|
|
|
Array = 11,
|
|
|
|
Pointer = 12,
|
|
|
|
Vector = 13,
|
|
|
|
Metadata = 14,
|
|
|
|
X86_MMX = 15,
|
|
|
|
Token = 16,
|
2020-06-26 01:52:41 +00:00
|
|
|
ScalableVector = 17,
|
|
|
|
BFloat = 18,
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|
|
|
|
|
2018-09-07 20:25:50 +00:00
|
|
|
impl TypeKind {
|
2018-10-01 16:07:04 +00:00
|
|
|
pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
|
2018-09-07 20:25:50 +00:00
|
|
|
match self {
|
2018-10-01 16:07:04 +00:00
|
|
|
TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
|
|
|
|
TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
|
|
|
|
TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
|
|
|
|
TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
|
|
|
|
TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
|
|
|
|
TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
|
|
|
|
TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
|
|
|
|
TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
|
|
|
|
TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
|
|
|
|
TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
|
|
|
|
TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
|
|
|
|
TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
|
|
|
|
TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
|
|
|
|
TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
|
|
|
|
TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
|
|
|
|
TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
|
|
|
|
TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
|
2020-06-26 01:52:41 +00:00
|
|
|
TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
|
|
|
|
TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
|
2018-09-07 20:25:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 20:10:10 +00:00
|
|
|
/// LLVMAtomicRmwBinOp
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum AtomicRmwBinOp {
|
|
|
|
AtomicXchg = 0,
|
2016-10-22 13:07:35 +00:00
|
|
|
AtomicAdd = 1,
|
|
|
|
AtomicSub = 2,
|
|
|
|
AtomicAnd = 3,
|
2016-08-02 20:10:10 +00:00
|
|
|
AtomicNand = 4,
|
2016-10-22 13:07:35 +00:00
|
|
|
AtomicOr = 5,
|
|
|
|
AtomicXor = 6,
|
|
|
|
AtomicMax = 7,
|
|
|
|
AtomicMin = 8,
|
2016-08-02 20:10:10 +00:00
|
|
|
AtomicUMax = 9,
|
|
|
|
AtomicUMin = 10,
|
|
|
|
}
|
|
|
|
|
2018-08-21 15:54:12 +00:00
|
|
|
impl AtomicRmwBinOp {
|
2018-10-01 16:07:04 +00:00
|
|
|
pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
|
2018-08-21 15:54:12 +00:00
|
|
|
match op {
|
2018-10-01 16:07:04 +00:00
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
|
2019-12-22 22:42:04 +00:00
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
|
2018-08-21 15:54:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 20:10:10 +00:00
|
|
|
/// LLVMAtomicOrdering
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum AtomicOrdering {
|
2018-07-10 15:00:02 +00:00
|
|
|
#[allow(dead_code)]
|
2016-08-02 20:10:10 +00:00
|
|
|
NotAtomic = 0,
|
|
|
|
Unordered = 1,
|
|
|
|
Monotonic = 2,
|
|
|
|
// Consume = 3, // Not specified yet.
|
|
|
|
Acquire = 4,
|
|
|
|
Release = 5,
|
|
|
|
AcquireRelease = 6,
|
2016-10-22 13:07:35 +00:00
|
|
|
SequentiallyConsistent = 7,
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 16:08:20 +00:00
|
|
|
impl AtomicOrdering {
|
2018-10-01 16:07:04 +00:00
|
|
|
pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
|
2018-08-21 16:08:20 +00:00
|
|
|
match ao {
|
2018-10-01 16:07:04 +00:00
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
|
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
|
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
|
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
|
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
|
2019-12-22 22:42:04 +00:00
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
|
|
|
|
AtomicOrdering::AcquireRelease
|
|
|
|
}
|
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
|
2018-08-21 16:08:20 +00:00
|
|
|
AtomicOrdering::SequentiallyConsistent
|
2019-12-22 22:42:04 +00:00
|
|
|
}
|
2018-08-21 16:08:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 20:10:10 +00:00
|
|
|
/// LLVMRustSynchronizationScope
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum SynchronizationScope {
|
2018-07-10 15:00:02 +00:00
|
|
|
// FIXME: figure out if this variant is needed at all.
|
|
|
|
#[allow(dead_code)]
|
2016-08-02 20:10:10 +00:00
|
|
|
Other,
|
|
|
|
SingleThread,
|
|
|
|
CrossThread,
|
|
|
|
}
|
|
|
|
|
2018-08-21 16:15:29 +00:00
|
|
|
impl SynchronizationScope {
|
2018-10-01 16:07:04 +00:00
|
|
|
pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
|
2018-08-21 16:15:29 +00:00
|
|
|
match sc {
|
2018-10-01 16:07:04 +00:00
|
|
|
rustc_codegen_ssa::common::SynchronizationScope::Other => SynchronizationScope::Other,
|
2019-12-22 22:42:04 +00:00
|
|
|
rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
|
|
|
|
SynchronizationScope::SingleThread
|
|
|
|
}
|
|
|
|
rustc_codegen_ssa::common::SynchronizationScope::CrossThread => {
|
|
|
|
SynchronizationScope::CrossThread
|
|
|
|
}
|
2018-08-21 16:15:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 20:10:10 +00:00
|
|
|
/// LLVMRustFileType
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum FileType {
|
2018-07-10 15:00:02 +00:00
|
|
|
// FIXME: figure out if this variant is needed at all.
|
|
|
|
#[allow(dead_code)]
|
2016-08-02 20:10:10 +00:00
|
|
|
Other,
|
|
|
|
AssemblyFile,
|
|
|
|
ObjectFile,
|
|
|
|
}
|
|
|
|
|
2016-09-01 18:52:33 +00:00
|
|
|
/// LLVMMetadataType
|
2016-08-02 20:10:10 +00:00
|
|
|
#[derive(Copy, Clone)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum MetadataType {
|
|
|
|
MD_dbg = 0,
|
|
|
|
MD_tbaa = 1,
|
|
|
|
MD_prof = 2,
|
|
|
|
MD_fpmath = 3,
|
|
|
|
MD_range = 4,
|
|
|
|
MD_tbaa_struct = 5,
|
|
|
|
MD_invariant_load = 6,
|
|
|
|
MD_alias_scope = 7,
|
|
|
|
MD_noalias = 8,
|
|
|
|
MD_nontemporal = 9,
|
|
|
|
MD_mem_parallel_loop_access = 10,
|
|
|
|
MD_nonnull = 11,
|
|
|
|
}
|
|
|
|
|
2016-08-02 21:25:19 +00:00
|
|
|
/// LLVMRustAsmDialect
|
2016-08-02 20:10:10 +00:00
|
|
|
#[derive(Copy, Clone)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum AsmDialect {
|
2018-07-10 15:00:02 +00:00
|
|
|
// FIXME: figure out if this variant is needed at all.
|
|
|
|
#[allow(dead_code)]
|
2016-08-02 21:25:19 +00:00
|
|
|
Other,
|
|
|
|
Att,
|
|
|
|
Intel,
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 16:22:29 +00:00
|
|
|
impl AsmDialect {
|
2020-01-14 13:40:42 +00:00
|
|
|
pub fn from_generic(asm: rustc_ast::ast::LlvmAsmDialect) -> Self {
|
2018-08-21 16:22:29 +00:00
|
|
|
match asm {
|
2020-01-14 13:40:42 +00:00
|
|
|
rustc_ast::ast::LlvmAsmDialect::Att => AsmDialect::Att,
|
|
|
|
rustc_ast::ast::LlvmAsmDialect::Intel => AsmDialect::Intel,
|
2018-08-21 16:22:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 20:10:10 +00:00
|
|
|
/// LLVMRustCodeGenOptLevel
|
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum CodeGenOptLevel {
|
2018-07-10 15:00:02 +00:00
|
|
|
// FIXME: figure out if this variant is needed at all.
|
|
|
|
#[allow(dead_code)]
|
2016-08-02 20:10:10 +00:00
|
|
|
Other,
|
|
|
|
None,
|
|
|
|
Less,
|
|
|
|
Default,
|
|
|
|
Aggressive,
|
|
|
|
}
|
|
|
|
|
2020-01-05 18:16:58 +00:00
|
|
|
/// LLVMRustPassBuilderOptLevel
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum PassBuilderOptLevel {
|
|
|
|
O0,
|
|
|
|
O1,
|
|
|
|
O2,
|
|
|
|
O3,
|
|
|
|
Os,
|
|
|
|
Oz,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// LLVMRustOptStage
|
|
|
|
#[derive(PartialEq)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum OptStage {
|
|
|
|
PreLinkNoLTO,
|
|
|
|
PreLinkThinLTO,
|
|
|
|
PreLinkFatLTO,
|
|
|
|
ThinLTO,
|
|
|
|
FatLTO,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// LLVMRustSanitizerOptions
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct SanitizerOptions {
|
|
|
|
pub sanitize_address: bool,
|
2020-06-14 00:00:00 +00:00
|
|
|
pub sanitize_address_recover: bool,
|
|
|
|
pub sanitize_memory: bool,
|
|
|
|
pub sanitize_memory_recover: bool,
|
2020-01-05 18:16:58 +00:00
|
|
|
pub sanitize_memory_track_origins: c_int,
|
2020-06-14 00:00:00 +00:00
|
|
|
pub sanitize_thread: bool,
|
2020-01-05 18:16:58 +00:00
|
|
|
}
|
|
|
|
|
2016-08-02 20:10:10 +00:00
|
|
|
/// LLVMRelocMode
|
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
|
|
|
#[repr(C)]
|
2020-04-23 17:49:00 +00:00
|
|
|
pub enum RelocModel {
|
2017-04-28 22:21:59 +00:00
|
|
|
Static,
|
|
|
|
PIC,
|
|
|
|
DynamicNoPic,
|
|
|
|
ROPI,
|
|
|
|
RWPI,
|
|
|
|
ROPI_RWPI,
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// LLVMRustCodeModel
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum CodeModel {
|
2020-05-07 00:34:27 +00:00
|
|
|
Tiny,
|
2016-08-02 20:10:10 +00:00
|
|
|
Small,
|
|
|
|
Kernel,
|
|
|
|
Medium,
|
|
|
|
Large,
|
2018-01-23 01:01:36 +00:00
|
|
|
None,
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// LLVMRustDiagnosticKind
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
2018-07-10 15:00:02 +00:00
|
|
|
#[allow(dead_code)] // Variants constructed by C++.
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum DiagnosticKind {
|
|
|
|
Other,
|
|
|
|
InlineAsm,
|
|
|
|
StackSize,
|
|
|
|
DebugMetadataVersion,
|
|
|
|
SampleProfile,
|
|
|
|
OptimizationRemark,
|
|
|
|
OptimizationRemarkMissed,
|
|
|
|
OptimizationRemarkAnalysis,
|
|
|
|
OptimizationRemarkAnalysisFPCommute,
|
|
|
|
OptimizationRemarkAnalysisAliasing,
|
|
|
|
OptimizationRemarkOther,
|
|
|
|
OptimizationFailure,
|
2018-03-12 17:11:59 +00:00
|
|
|
PGOProfile,
|
2018-07-17 23:20:51 +00:00
|
|
|
Linker,
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|
|
|
|
|
2020-06-09 13:37:59 +00:00
|
|
|
/// LLVMRustDiagnosticLevel
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[repr(C)]
|
|
|
|
#[allow(dead_code)] // Variants constructed by C++.
|
|
|
|
pub enum DiagnosticLevel {
|
|
|
|
Error,
|
|
|
|
Warning,
|
|
|
|
Note,
|
|
|
|
Remark,
|
|
|
|
}
|
|
|
|
|
2016-08-02 20:10:10 +00:00
|
|
|
/// LLVMRustArchiveKind
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-02 21:25:19 +00:00
|
|
|
#[repr(C)]
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum ArchiveKind {
|
2018-07-10 15:00:02 +00:00
|
|
|
// FIXME: figure out if this variant is needed at all.
|
|
|
|
#[allow(dead_code)]
|
2016-08-02 20:10:10 +00:00
|
|
|
Other,
|
|
|
|
K_GNU,
|
|
|
|
K_BSD,
|
2020-02-12 11:06:14 +00:00
|
|
|
K_DARWIN,
|
2016-08-02 20:10:10 +00:00
|
|
|
K_COFF,
|
|
|
|
}
|
2016-08-02 21:25:19 +00:00
|
|
|
|
2016-08-02 20:10:10 +00:00
|
|
|
/// LLVMRustPassKind
|
|
|
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
|
|
|
#[repr(C)]
|
2018-07-10 15:00:02 +00:00
|
|
|
#[allow(dead_code)] // Variants constructed by C++.
|
2016-08-02 20:10:10 +00:00
|
|
|
pub enum PassKind {
|
|
|
|
Other,
|
|
|
|
Function,
|
|
|
|
Module,
|
|
|
|
}
|
|
|
|
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 15:14:38 +00:00
|
|
|
/// LLVMRustThinLTOData
|
2019-12-22 22:42:04 +00:00
|
|
|
extern "C" {
|
|
|
|
pub type ThinLTOData;
|
|
|
|
}
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 15:14:38 +00:00
|
|
|
|
|
|
|
/// LLVMRustThinLTOBuffer
|
2019-12-22 22:42:04 +00:00
|
|
|
extern "C" {
|
|
|
|
pub type ThinLTOBuffer;
|
|
|
|
}
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 15:14:38 +00:00
|
|
|
|
2018-08-17 13:25:46 +00:00
|
|
|
// LLVMRustModuleNameCallback
|
|
|
|
pub type ThinLTOModuleNameCallback =
|
|
|
|
unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
|
|
|
|
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 15:14:38 +00:00
|
|
|
/// LLVMRustThinLTOModule
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct ThinLTOModule {
|
|
|
|
pub identifier: *const c_char,
|
|
|
|
pub data: *const u8,
|
|
|
|
pub len: usize,
|
|
|
|
}
|
|
|
|
|
2017-10-31 18:24:04 +00:00
|
|
|
/// LLVMThreadLocalMode
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum ThreadLocalMode {
|
2019-12-22 22:42:04 +00:00
|
|
|
NotThreadLocal,
|
|
|
|
GeneralDynamic,
|
|
|
|
LocalDynamic,
|
|
|
|
InitialExec,
|
|
|
|
LocalExec,
|
2017-10-31 18:24:04 +00:00
|
|
|
}
|
|
|
|
|
2020-03-31 05:17:15 +00:00
|
|
|
/// LLVMRustChecksumKind
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum ChecksumKind {
|
|
|
|
None,
|
|
|
|
MD5,
|
|
|
|
SHA1,
|
|
|
|
}
|
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
extern "C" {
|
|
|
|
type Opaque;
|
|
|
|
}
|
2018-07-17 12:02:11 +00:00
|
|
|
#[repr(C)]
|
2018-07-16 13:02:31 +00:00
|
|
|
struct InvariantOpaque<'a> {
|
|
|
|
_marker: PhantomData<&'a mut &'a ()>,
|
|
|
|
_opaque: Opaque,
|
|
|
|
}
|
|
|
|
|
2016-08-02 20:10:10 +00:00
|
|
|
// Opaque pointer types
|
2019-12-22 22:42:04 +00:00
|
|
|
extern "C" {
|
|
|
|
pub type Module;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type Context;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type Type;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type Value;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type ConstantInt;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type Metadata;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type BasicBlock;
|
|
|
|
}
|
2018-07-17 15:33:09 +00:00
|
|
|
#[repr(C)]
|
|
|
|
pub struct Builder<'a>(InvariantOpaque<'a>);
|
2019-12-22 22:42:04 +00:00
|
|
|
extern "C" {
|
|
|
|
pub type MemoryBuffer;
|
|
|
|
}
|
2018-07-17 12:02:11 +00:00
|
|
|
#[repr(C)]
|
2018-07-17 11:17:47 +00:00
|
|
|
pub struct PassManager<'a>(InvariantOpaque<'a>);
|
2019-12-22 22:42:04 +00:00
|
|
|
extern "C" {
|
|
|
|
pub type PassManagerBuilder;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type ObjectFile;
|
|
|
|
}
|
2018-07-17 12:02:11 +00:00
|
|
|
#[repr(C)]
|
2018-07-17 11:22:02 +00:00
|
|
|
pub struct SectionIterator<'a>(InvariantOpaque<'a>);
|
2019-12-22 22:42:04 +00:00
|
|
|
extern "C" {
|
|
|
|
pub type Pass;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type TargetMachine;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type Archive;
|
|
|
|
}
|
2018-07-17 12:02:11 +00:00
|
|
|
#[repr(C)]
|
2018-07-17 11:31:06 +00:00
|
|
|
pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
|
2018-07-17 12:02:11 +00:00
|
|
|
#[repr(C)]
|
|
|
|
pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
|
2019-12-22 22:42:04 +00:00
|
|
|
extern "C" {
|
|
|
|
pub type Twine;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type DiagnosticInfo;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type SMDiagnostic;
|
|
|
|
}
|
2018-07-17 13:00:10 +00:00
|
|
|
#[repr(C)]
|
|
|
|
pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
|
2018-07-17 12:02:11 +00:00
|
|
|
#[repr(C)]
|
2018-07-16 13:02:31 +00:00
|
|
|
pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
|
2018-07-17 12:02:11 +00:00
|
|
|
#[repr(C)]
|
2018-07-17 11:26:22 +00:00
|
|
|
pub struct Linker<'a>(InvariantOpaque<'a>);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-13 10:59:41 +00:00
|
|
|
pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
|
|
|
|
pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
pub mod debuginfo {
|
2018-07-17 15:45:33 +00:00
|
|
|
use super::{InvariantOpaque, Metadata};
|
2019-10-22 15:51:35 +00:00
|
|
|
use bitflags::bitflags;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-17 15:45:33 +00:00
|
|
|
#[repr(C)]
|
|
|
|
pub struct DIBuilder<'a>(InvariantOpaque<'a>);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-04 13:36:49 +00:00
|
|
|
pub type DIDescriptor = Metadata;
|
|
|
|
pub type DIScope = DIDescriptor;
|
2016-08-02 20:10:10 +00:00
|
|
|
pub type DIFile = DIScope;
|
|
|
|
pub type DILexicalBlock = DIScope;
|
|
|
|
pub type DISubprogram = DIScope;
|
|
|
|
pub type DINameSpace = DIScope;
|
2018-07-04 13:36:49 +00:00
|
|
|
pub type DIType = DIDescriptor;
|
2016-08-02 20:10:10 +00:00
|
|
|
pub type DIBasicType = DIType;
|
|
|
|
pub type DIDerivedType = DIType;
|
|
|
|
pub type DICompositeType = DIDerivedType;
|
|
|
|
pub type DIVariable = DIDescriptor;
|
2018-09-14 16:06:45 +00:00
|
|
|
pub type DIGlobalVariableExpression = DIDescriptor;
|
2018-07-04 13:36:49 +00:00
|
|
|
pub type DIArray = DIDescriptor;
|
2016-08-02 20:10:10 +00:00
|
|
|
pub type DISubrange = DIDescriptor;
|
|
|
|
pub type DIEnumerator = DIDescriptor;
|
|
|
|
pub type DITemplateTypeParameter = DIDescriptor;
|
|
|
|
|
2016-11-18 22:15:14 +00:00
|
|
|
// These values **must** match with LLVMRustDIFlags!!
|
|
|
|
bitflags! {
|
2019-06-16 00:53:33 +00:00
|
|
|
#[repr(transparent)]
|
2017-09-08 19:08:01 +00:00
|
|
|
#[derive(Default)]
|
2019-06-01 12:21:38 +00:00
|
|
|
pub struct DIFlags: u32 {
|
2017-09-08 19:08:01 +00:00
|
|
|
const FlagZero = 0;
|
|
|
|
const FlagPrivate = 1;
|
|
|
|
const FlagProtected = 2;
|
|
|
|
const FlagPublic = 3;
|
|
|
|
const FlagFwdDecl = (1 << 2);
|
|
|
|
const FlagAppleBlock = (1 << 3);
|
|
|
|
const FlagBlockByrefStruct = (1 << 4);
|
|
|
|
const FlagVirtual = (1 << 5);
|
|
|
|
const FlagArtificial = (1 << 6);
|
|
|
|
const FlagExplicit = (1 << 7);
|
|
|
|
const FlagPrototyped = (1 << 8);
|
|
|
|
const FlagObjcClassComplete = (1 << 9);
|
|
|
|
const FlagObjectPointer = (1 << 10);
|
|
|
|
const FlagVector = (1 << 11);
|
|
|
|
const FlagStaticMember = (1 << 12);
|
|
|
|
const FlagLValueReference = (1 << 13);
|
|
|
|
const FlagRValueReference = (1 << 14);
|
2018-01-20 20:32:33 +00:00
|
|
|
const FlagExternalTypeRef = (1 << 15);
|
|
|
|
const FlagIntroducedVirtual = (1 << 18);
|
|
|
|
const FlagBitField = (1 << 19);
|
|
|
|
const FlagNoReturn = (1 << 20);
|
2016-11-18 22:15:14 +00:00
|
|
|
}
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|
2019-01-16 17:59:03 +00:00
|
|
|
|
|
|
|
// These values **must** match with LLVMRustDISPFlags!!
|
|
|
|
bitflags! {
|
2019-06-16 00:53:33 +00:00
|
|
|
#[repr(transparent)]
|
2019-01-16 17:59:03 +00:00
|
|
|
#[derive(Default)]
|
2019-06-01 12:21:38 +00:00
|
|
|
pub struct DISPFlags: u32 {
|
2019-01-16 17:59:03 +00:00
|
|
|
const SPFlagZero = 0;
|
|
|
|
const SPFlagVirtual = 1;
|
|
|
|
const SPFlagPureVirtual = 2;
|
|
|
|
const SPFlagLocalToUnit = (1 << 2);
|
|
|
|
const SPFlagDefinition = (1 << 3);
|
|
|
|
const SPFlagOptimized = (1 << 4);
|
2019-04-04 20:05:41 +00:00
|
|
|
const SPFlagMainSubprogram = (1 << 5);
|
2019-01-16 17:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-22 21:01:14 +00:00
|
|
|
|
|
|
|
/// LLVMRustDebugEmissionKind
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum DebugEmissionKind {
|
|
|
|
NoDebug,
|
|
|
|
FullDebug,
|
|
|
|
LineTablesOnly,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DebugEmissionKind {
|
2020-03-11 11:49:08 +00:00
|
|
|
pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
|
|
|
|
use rustc_session::config::DebugInfo;
|
2019-01-22 21:01:14 +00:00
|
|
|
match kind {
|
|
|
|
DebugInfo::None => DebugEmissionKind::NoDebug,
|
|
|
|
DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
|
|
|
|
DebugInfo::Full => DebugEmissionKind::FullDebug,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
extern "C" {
|
|
|
|
pub type ModuleBuffer;
|
|
|
|
}
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2020-02-11 21:37:16 +00:00
|
|
|
pub type SelfProfileBeforePassCallback =
|
|
|
|
unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
|
|
|
|
pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
|
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
extern "C" {
|
2018-10-12 19:35:55 +00:00
|
|
|
pub fn LLVMRustInstallFatalErrorHandler();
|
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Create and destroy contexts.
|
2018-06-27 14:57:25 +00:00
|
|
|
pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
|
|
|
|
pub fn LLVMContextDispose(C: &'static mut Context);
|
|
|
|
pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-06-27 14:57:25 +00:00
|
|
|
// Create modules.
|
|
|
|
pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
|
|
|
|
pub fn LLVMGetModuleContext(M: &Module) -> &Context;
|
|
|
|
pub fn LLVMCloneModule(M: &Module) -> &Module;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
/// Data layout. See Module::getDataLayout.
|
2020-03-11 00:00:00 +00:00
|
|
|
pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
|
2018-06-27 14:57:25 +00:00
|
|
|
pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
/// See Module::setModuleInlineAsm.
|
2020-03-11 00:00:00 +00:00
|
|
|
pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t);
|
2020-03-10 00:00:00 +00:00
|
|
|
pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
/// See llvm::LLVMTypeKind::getTypeID.
|
2018-07-02 14:52:53 +00:00
|
|
|
pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on integer types
|
2018-07-02 14:52:53 +00:00
|
|
|
pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-02 14:52:53 +00:00
|
|
|
pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on real types
|
2018-07-02 14:52:53 +00:00
|
|
|
pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on function types
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMFunctionType(
|
|
|
|
ReturnType: &'a Type,
|
|
|
|
ParamTypes: *const &'a Type,
|
|
|
|
ParamCount: c_uint,
|
|
|
|
IsVarArg: Bool,
|
|
|
|
) -> &'a Type;
|
2018-07-02 14:52:53 +00:00
|
|
|
pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
|
|
|
|
pub fn LLVMGetParamTypes(FunctionTy: &'a Type, Dest: *mut &'a Type);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on struct types
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMStructTypeInContext(
|
|
|
|
C: &'a Context,
|
|
|
|
ElementTypes: *const &'a Type,
|
|
|
|
ElementCount: c_uint,
|
|
|
|
Packed: Bool,
|
|
|
|
) -> &'a Type;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on array, pointer, and vector types (sequence types)
|
2018-07-02 14:52:53 +00:00
|
|
|
pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
|
|
|
|
pub fn LLVMPointerType(ElementType: &Type, AddressSpace: c_uint) -> &Type;
|
|
|
|
pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-02 14:52:53 +00:00
|
|
|
pub fn LLVMGetElementType(Ty: &Type) -> &Type;
|
|
|
|
pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on other types
|
2018-07-02 14:52:53 +00:00
|
|
|
pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMX86MMXTypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMRustMetadataTypeInContext(C: &Context) -> &Type;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on all values
|
2018-07-05 10:38:44 +00:00
|
|
|
pub fn LLVMTypeOf(Val: &Value) -> &Type;
|
2019-12-04 20:00:28 +00:00
|
|
|
pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
|
|
|
|
pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMReplaceAllUsesWith(OldVal: &'a Value, NewVal: &'a Value);
|
|
|
|
pub fn LLVMSetMetadata(Val: &'a Value, KindID: c_uint, Node: &'a Value);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on constants of any type
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMConstNull(Ty: &Type) -> &Value;
|
|
|
|
pub fn LLVMGetUndef(Ty: &Type) -> &Value;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on metadata
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
|
|
|
|
pub fn LLVMMDNodeInContext(C: &'a Context, Vals: *const &'a Value, Count: c_uint) -> &'a Value;
|
|
|
|
pub fn LLVMAddNamedMetadataOperand(M: &'a Module, Name: *const c_char, Val: &'a Value);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on scalar constants
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
|
|
|
|
pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
|
2019-07-07 17:08:40 +00:00
|
|
|
pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
|
2019-10-13 10:19:14 +00:00
|
|
|
pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustConstInt128Get(
|
|
|
|
ConstantVal: &ConstantInt,
|
|
|
|
SExt: bool,
|
|
|
|
high: &mut u64,
|
|
|
|
low: &mut u64,
|
|
|
|
) -> bool;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on composite constants
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMConstStringInContext(
|
|
|
|
C: &Context,
|
|
|
|
Str: *const c_char,
|
|
|
|
Length: c_uint,
|
|
|
|
DontNullTerminate: Bool,
|
|
|
|
) -> &Value;
|
|
|
|
pub fn LLVMConstStructInContext(
|
|
|
|
C: &'a Context,
|
|
|
|
ConstantVals: *const &'a Value,
|
|
|
|
Count: c_uint,
|
|
|
|
Packed: Bool,
|
|
|
|
) -> &'a Value;
|
|
|
|
|
|
|
|
pub fn LLVMConstArray(
|
|
|
|
ElementTy: &'a Type,
|
|
|
|
ConstantVals: *const &'a Value,
|
|
|
|
Length: c_uint,
|
|
|
|
) -> &'a Value;
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Constant expressions
|
2018-01-16 08:31:48 +00:00
|
|
|
pub fn LLVMConstInBoundsGEP(
|
2018-07-10 10:28:39 +00:00
|
|
|
ConstantVal: &'a Value,
|
|
|
|
ConstantIndices: *const &'a Value,
|
2018-01-16 08:31:48 +00:00
|
|
|
NumIndices: c_uint,
|
2018-07-10 10:28:39 +00:00
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMConstZExt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
|
|
|
pub fn LLVMConstPtrToInt(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
|
|
|
pub fn LLVMConstIntToPtr(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
|
|
|
pub fn LLVMConstBitCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
|
|
|
pub fn LLVMConstPointerCast(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMConstExtractValue(
|
|
|
|
AggConstant: &Value,
|
|
|
|
IdxList: *const c_uint,
|
|
|
|
NumIdx: c_uint,
|
|
|
|
) -> &Value;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on global variables, functions, and aliases (globals)
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
|
|
|
|
pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
|
|
|
|
pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
|
|
|
|
pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
|
|
|
|
pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
|
|
|
|
pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
|
|
|
|
pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
|
|
|
|
pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
|
|
|
|
pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on global variables
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
|
|
|
|
pub fn LLVMAddGlobal(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
|
|
|
|
pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustGetOrInsertGlobal(
|
|
|
|
M: &'a Module,
|
|
|
|
Name: *const c_char,
|
|
|
|
NameLen: size_t,
|
|
|
|
T: &'a Type,
|
|
|
|
) -> &'a Value;
|
2018-05-23 19:19:07 +00:00
|
|
|
pub fn LLVMRustInsertPrivateGlobal(M: &'a Module, T: &'a Type) -> &'a Value;
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
|
|
|
|
pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
|
|
|
|
pub fn LLVMDeleteGlobal(GlobalVar: &Value);
|
|
|
|
pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
|
|
|
|
pub fn LLVMSetInitializer(GlobalVar: &'a Value, ConstantVal: &'a Value);
|
|
|
|
pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
|
|
|
|
pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
|
|
|
|
pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
|
|
|
|
pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
|
2020-03-10 00:00:00 +00:00
|
|
|
pub fn LLVMRustGetNamedValue(
|
|
|
|
M: &Module,
|
|
|
|
Name: *const c_char,
|
|
|
|
NameLen: size_t,
|
|
|
|
) -> Option<&Value>;
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on functions
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustGetOrInsertFunction(
|
|
|
|
M: &'a Module,
|
|
|
|
Name: *const c_char,
|
2020-03-10 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
FunctionTy: &'a Type,
|
|
|
|
) -> &'a Value;
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
|
|
|
|
pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32);
|
|
|
|
pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64);
|
|
|
|
pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64);
|
2019-07-06 19:52:25 +00:00
|
|
|
pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type);
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustAddFunctionAttrStringValue(
|
|
|
|
Fn: &Value,
|
|
|
|
index: c_uint,
|
|
|
|
Name: *const c_char,
|
|
|
|
Value: *const c_char,
|
|
|
|
);
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on parameters
|
2019-09-04 12:21:46 +00:00
|
|
|
pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMCountParams(Fn: &Value) -> c_uint;
|
|
|
|
pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on basic blocks
|
2018-07-10 11:34:34 +00:00
|
|
|
pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMAppendBasicBlockInContext(
|
|
|
|
C: &'a Context,
|
|
|
|
Fn: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a BasicBlock;
|
2018-07-10 11:34:34 +00:00
|
|
|
pub fn LLVMDeleteBasicBlock(BB: &BasicBlock);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on instructions
|
2019-09-04 12:21:46 +00:00
|
|
|
pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
|
2018-07-10 11:34:34 +00:00
|
|
|
pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on call sites
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
|
|
|
|
pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute);
|
|
|
|
pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32);
|
|
|
|
pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64);
|
2019-07-06 19:52:25 +00:00
|
|
|
pub fn LLVMRustAddByValCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type);
|
2016-10-22 13:07:35 +00:00
|
|
|
|
|
|
|
// Operations on load/store instructions (only)
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Operations on phi nodes
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMAddIncoming(
|
|
|
|
PhiNode: &'a Value,
|
|
|
|
IncomingValues: *const &'a Value,
|
|
|
|
IncomingBlocks: *const &'a BasicBlock,
|
|
|
|
Count: c_uint,
|
|
|
|
);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Instruction builders
|
2018-07-17 15:33:09 +00:00
|
|
|
pub fn LLVMCreateBuilderInContext(C: &'a Context) -> &'a mut Builder<'a>;
|
|
|
|
pub fn LLVMPositionBuilderAtEnd(Builder: &Builder<'a>, Block: &'a BasicBlock);
|
|
|
|
pub fn LLVMGetInsertBlock(Builder: &Builder<'a>) -> &'a BasicBlock;
|
|
|
|
pub fn LLVMDisposeBuilder(Builder: &'a mut Builder<'a>);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Metadata
|
2020-02-08 16:27:49 +00:00
|
|
|
pub fn LLVMSetCurrentDebugLocation(Builder: &Builder<'a>, L: &'a Value);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Terminators
|
2018-07-17 15:33:09 +00:00
|
|
|
pub fn LLVMBuildRetVoid(B: &Builder<'a>) -> &'a Value;
|
|
|
|
pub fn LLVMBuildRet(B: &Builder<'a>, V: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMBuildBr(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMBuildCondBr(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
If: &'a Value,
|
|
|
|
Then: &'a BasicBlock,
|
|
|
|
Else: &'a BasicBlock,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildSwitch(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
V: &'a Value,
|
|
|
|
Else: &'a BasicBlock,
|
|
|
|
NumCases: c_uint,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildInvoke(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Fn: &'a Value,
|
|
|
|
Args: *const &'a Value,
|
|
|
|
NumArgs: c_uint,
|
|
|
|
Then: &'a BasicBlock,
|
|
|
|
Catch: &'a BasicBlock,
|
|
|
|
Bundle: Option<&OperandBundleDef<'a>>,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildLandingPad(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Ty: &'a Type,
|
|
|
|
PersFn: &'a Value,
|
|
|
|
NumClauses: c_uint,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2018-07-17 15:33:09 +00:00
|
|
|
pub fn LLVMBuildResume(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMBuildUnreachable(B: &Builder<'a>) -> &'a Value;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustBuildCleanupPad(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
ParentPad: Option<&'a Value>,
|
|
|
|
ArgCnt: c_uint,
|
|
|
|
Args: *const &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> Option<&'a Value>;
|
|
|
|
pub fn LLVMRustBuildCleanupRet(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
CleanupPad: &'a Value,
|
|
|
|
UnwindBB: Option<&'a BasicBlock>,
|
|
|
|
) -> Option<&'a Value>;
|
|
|
|
pub fn LLVMRustBuildCatchPad(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
ParentPad: &'a Value,
|
|
|
|
ArgCnt: c_uint,
|
|
|
|
Args: *const &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> Option<&'a Value>;
|
2018-07-17 15:26:58 +00:00
|
|
|
pub fn LLVMRustBuildCatchRet(
|
2018-07-17 15:33:09 +00:00
|
|
|
B: &Builder<'a>,
|
2018-07-17 15:26:58 +00:00
|
|
|
Pad: &'a Value,
|
|
|
|
BB: &'a BasicBlock,
|
|
|
|
) -> Option<&'a Value>;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustBuildCatchSwitch(
|
|
|
|
Builder: &Builder<'a>,
|
|
|
|
ParentPad: Option<&'a Value>,
|
|
|
|
BB: Option<&'a BasicBlock>,
|
|
|
|
NumHandlers: c_uint,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> Option<&'a Value>;
|
2018-07-10 11:34:34 +00:00
|
|
|
pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Add a case to the switch instruction
|
2018-07-10 11:34:34 +00:00
|
|
|
pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Add a clause to the landing pad instruction
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Set the cleanup on a landing pad instruction
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Arithmetic
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMBuildAdd(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildFAdd(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildSub(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildFSub(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildMul(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildFMul(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildUDiv(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildExactUDiv(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildSDiv(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildExactSDiv(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildFDiv(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildURem(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildSRem(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildFRem(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildShl(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildLShr(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildAShr(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildNSWAdd(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildNUWAdd(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildNSWSub(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildNUWSub(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildNSWMul(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildNUWMul(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildAnd(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildOr(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildXor(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2018-07-17 15:33:09 +00:00
|
|
|
pub fn LLVMBuildNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
|
|
|
|
pub fn LLVMBuildFNeg(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
|
|
|
|
pub fn LLVMBuildNot(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMRustSetHasUnsafeAlgebra(Instr: &Value);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Memory
|
2018-07-17 15:33:09 +00:00
|
|
|
pub fn LLVMBuildAlloca(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMBuildArrayAlloca(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Ty: &'a Type,
|
|
|
|
Val: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2018-07-17 15:33:09 +00:00
|
|
|
pub fn LLVMBuildLoad(B: &Builder<'a>, PointerVal: &'a Value, Name: *const c_char) -> &'a Value;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-17 15:33:09 +00:00
|
|
|
pub fn LLVMBuildStore(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMBuildGEP(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Pointer: &'a Value,
|
|
|
|
Indices: *const &'a Value,
|
|
|
|
NumIndices: c_uint,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildInBoundsGEP(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Pointer: &'a Value,
|
|
|
|
Indices: *const &'a Value,
|
|
|
|
NumIndices: c_uint,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildStructGEP(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Pointer: &'a Value,
|
|
|
|
Idx: c_uint,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Casts
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMBuildTrunc(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildZExt(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildSExt(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildFPToUI(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildFPToSI(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildUIToFP(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildSIToFP(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildFPTrunc(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildFPExt(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildPtrToInt(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildIntToPtr(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildBitCast(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildPointerCast(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildIntCast(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
DestTy: &'a Type,
|
|
|
|
IsSized: bool,
|
|
|
|
) -> &'a Value;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Comparisons
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMBuildICmp(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Op: c_uint,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildFCmp(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Op: c_uint,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Miscellaneous instructions
|
2018-07-17 15:33:09 +00:00
|
|
|
pub fn LLVMBuildPhi(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
|
2020-07-02 18:27:15 +00:00
|
|
|
pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &'a Value;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustBuildCall(
|
2018-07-17 15:33:09 +00:00
|
|
|
B: &Builder<'a>,
|
2019-12-22 22:42:04 +00:00
|
|
|
Fn: &'a Value,
|
|
|
|
Args: *const &'a Value,
|
|
|
|
NumArgs: c_uint,
|
|
|
|
Bundle: Option<&OperandBundleDef<'a>>,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildMemCpy(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Dst: &'a Value,
|
|
|
|
DstAlign: c_uint,
|
|
|
|
Src: &'a Value,
|
|
|
|
SrcAlign: c_uint,
|
|
|
|
Size: &'a Value,
|
|
|
|
IsVolatile: bool,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildMemMove(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Dst: &'a Value,
|
|
|
|
DstAlign: c_uint,
|
|
|
|
Src: &'a Value,
|
|
|
|
SrcAlign: c_uint,
|
|
|
|
Size: &'a Value,
|
|
|
|
IsVolatile: bool,
|
|
|
|
) -> &'a Value;
|
2020-01-05 21:32:15 +00:00
|
|
|
pub fn LLVMRustBuildMemSet(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Dst: &'a Value,
|
|
|
|
DstAlign: c_uint,
|
|
|
|
Val: &'a Value,
|
|
|
|
Size: &'a Value,
|
|
|
|
IsVolatile: bool,
|
|
|
|
) -> &'a Value;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMBuildSelect(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
If: &'a Value,
|
|
|
|
Then: &'a Value,
|
|
|
|
Else: &'a Value,
|
|
|
|
Name: *const c_char,
|
2018-12-09 10:20:20 +00:00
|
|
|
) -> &'a Value;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMBuildVAArg(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
list: &'a Value,
|
|
|
|
Ty: &'a Type,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildExtractElement(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
VecVal: &'a Value,
|
|
|
|
Index: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildInsertElement(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
VecVal: &'a Value,
|
|
|
|
EltVal: &'a Value,
|
|
|
|
Index: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildShuffleVector(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
V1: &'a Value,
|
|
|
|
V2: &'a Value,
|
|
|
|
Mask: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildExtractValue(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
AggVal: &'a Value,
|
|
|
|
Index: c_uint,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMBuildInsertValue(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
AggVal: &'a Value,
|
|
|
|
EltVal: &'a Value,
|
|
|
|
Index: c_uint,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
|
|
|
|
pub fn LLVMRustBuildVectorReduceFAdd(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Acc: &'a Value,
|
|
|
|
Src: &'a Value,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceFMul(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Acc: &'a Value,
|
|
|
|
Src: &'a Value,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceMin(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Src: &'a Value,
|
|
|
|
IsSigned: bool,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceMax(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Src: &'a Value,
|
|
|
|
IsSigned: bool,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
|
|
|
|
-> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>, Src: &'a Value, IsNaN: bool)
|
|
|
|
-> &'a Value;
|
|
|
|
|
|
|
|
pub fn LLVMRustBuildMinNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildMaxNum(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
|
|
|
|
|
|
|
|
// Atomic Operations
|
|
|
|
pub fn LLVMRustBuildAtomicLoad(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
PointerVal: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
Order: AtomicOrdering,
|
|
|
|
) -> &'a Value;
|
|
|
|
|
|
|
|
pub fn LLVMRustBuildAtomicStore(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
Ptr: &'a Value,
|
|
|
|
Order: AtomicOrdering,
|
|
|
|
) -> &'a Value;
|
|
|
|
|
|
|
|
pub fn LLVMRustBuildAtomicCmpXchg(
|
2018-07-17 15:33:09 +00:00
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
2019-12-22 22:42:04 +00:00
|
|
|
CMP: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Order: AtomicOrdering,
|
|
|
|
FailureOrder: AtomicOrdering,
|
|
|
|
Weak: Bool,
|
|
|
|
) -> &'a Value;
|
|
|
|
|
|
|
|
pub fn LLVMBuildAtomicRMW(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Op: AtomicRmwBinOp,
|
2018-07-17 15:33:09 +00:00
|
|
|
LHS: &'a Value,
|
2019-12-22 22:42:04 +00:00
|
|
|
RHS: &'a Value,
|
|
|
|
Order: AtomicOrdering,
|
|
|
|
SingleThreaded: Bool,
|
2018-12-09 10:20:20 +00:00
|
|
|
) -> &'a Value;
|
2018-03-21 20:49:22 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustBuildAtomicFence(
|
|
|
|
B: &Builder<'_>,
|
|
|
|
Order: AtomicOrdering,
|
|
|
|
Scope: SynchronizationScope,
|
|
|
|
);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
/// Writes a module to the specified path. Returns 0 on success.
|
2018-06-27 14:57:25 +00:00
|
|
|
pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
/// Creates a pass manager.
|
2018-07-17 11:17:47 +00:00
|
|
|
pub fn LLVMCreatePassManager() -> &'a mut PassManager<'a>;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
/// Creates a function-by-function pass manager
|
2018-07-17 11:17:47 +00:00
|
|
|
pub fn LLVMCreateFunctionPassManagerForModule(M: &'a Module) -> &'a mut PassManager<'a>;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
/// Disposes a pass manager.
|
2018-07-17 11:17:47 +00:00
|
|
|
pub fn LLVMDisposePassManager(PM: &'a mut PassManager<'a>);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
/// Runs a pass manager on a module.
|
2018-07-17 11:17:47 +00:00
|
|
|
pub fn LLVMRunPassManager(PM: &PassManager<'a>, M: &'a Module) -> Bool;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
pub fn LLVMInitializePasses();
|
|
|
|
|
2020-01-31 23:58:28 +00:00
|
|
|
pub fn LLVMTimeTraceProfilerInitialize();
|
|
|
|
|
|
|
|
pub fn LLVMTimeTraceProfilerFinish(FileName: *const c_char);
|
|
|
|
|
2019-11-29 03:31:09 +00:00
|
|
|
pub fn LLVMAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>);
|
|
|
|
|
2018-07-12 13:24:09 +00:00
|
|
|
pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
|
|
|
|
pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
|
|
|
|
pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
|
|
|
|
pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
|
|
|
|
PMB: &PassManagerBuilder,
|
|
|
|
threshold: c_uint,
|
|
|
|
);
|
|
|
|
pub fn LLVMPassManagerBuilderPopulateModulePassManager(
|
|
|
|
PMB: &PassManagerBuilder,
|
|
|
|
PM: &PassManager<'_>,
|
|
|
|
);
|
|
|
|
|
|
|
|
pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
|
|
|
|
PMB: &PassManagerBuilder,
|
|
|
|
PM: &PassManager<'_>,
|
|
|
|
);
|
|
|
|
pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
|
|
|
|
PMB: &PassManagerBuilder,
|
|
|
|
PM: &PassManager<'_>,
|
|
|
|
Internalize: Bool,
|
|
|
|
RunInliner: Bool,
|
|
|
|
);
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 15:14:38 +00:00
|
|
|
pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
|
2018-07-12 13:24:09 +00:00
|
|
|
PMB: &PassManagerBuilder,
|
2019-12-22 22:42:04 +00:00
|
|
|
PM: &PassManager<'_>,
|
|
|
|
);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2016-10-22 13:07:35 +00:00
|
|
|
// Stuff that's in rustllvm/ because it's not upstream yet.
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
/// Opens an object file.
|
2018-07-10 16:19:17 +00:00
|
|
|
pub fn LLVMCreateObjectFile(
|
|
|
|
MemBuf: &'static mut MemoryBuffer,
|
|
|
|
) -> Option<&'static mut ObjectFile>;
|
2016-08-02 20:10:10 +00:00
|
|
|
/// Closes an object file.
|
2018-07-10 16:19:17 +00:00
|
|
|
pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
/// Enumerates the sections in an object file.
|
2018-07-17 11:22:02 +00:00
|
|
|
pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
|
2016-08-02 20:10:10 +00:00
|
|
|
/// Destroys a section iterator.
|
2018-07-17 11:22:02 +00:00
|
|
|
pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
|
2019-02-08 13:53:55 +00:00
|
|
|
/// Returns `true` if the section iterator is at the end of the section
|
2016-08-02 20:10:10 +00:00
|
|
|
/// list:
|
2018-07-17 11:22:02 +00:00
|
|
|
pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
|
2016-08-02 20:10:10 +00:00
|
|
|
/// Moves the section iterator to point to the next section.
|
2019-02-25 07:40:18 +00:00
|
|
|
pub fn LLVMMoveToNextSection(SI: &SectionIterator<'_>);
|
2016-08-02 20:10:10 +00:00
|
|
|
/// Returns the current section size.
|
2019-02-25 07:40:18 +00:00
|
|
|
pub fn LLVMGetSectionSize(SI: &SectionIterator<'_>) -> c_ulonglong;
|
2016-08-02 20:10:10 +00:00
|
|
|
/// Returns the current section contents as a string buffer.
|
2019-02-25 07:40:18 +00:00
|
|
|
pub fn LLVMGetSectionContents(SI: &SectionIterator<'_>) -> *const c_char;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
/// Reads the given file and returns it as a memory buffer. Use
|
|
|
|
/// LLVMDisposeMemoryBuffer() to get rid of it.
|
2018-07-10 16:19:17 +00:00
|
|
|
pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(
|
|
|
|
Path: *const c_char,
|
|
|
|
) -> Option<&'static mut MemoryBuffer>;
|
2016-11-28 16:31:42 +00:00
|
|
|
|
2016-08-02 20:10:10 +00:00
|
|
|
pub fn LLVMStartMultithreaded() -> Bool;
|
|
|
|
|
|
|
|
/// Returns a string describing the last error caused by an LLVMRust* call.
|
|
|
|
pub fn LLVMRustGetLastError() -> *const c_char;
|
|
|
|
|
|
|
|
/// Print the pass timings since static dtors aren't picking them up.
|
|
|
|
pub fn LLVMRustPrintPassTimings();
|
|
|
|
|
2018-07-02 14:52:53 +00:00
|
|
|
pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMStructSetBody(
|
|
|
|
StructTy: &'a Type,
|
|
|
|
ElementTypes: *const &'a Type,
|
|
|
|
ElementCount: c_uint,
|
|
|
|
Packed: Bool,
|
|
|
|
);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
|
|
|
/// Prepares inline assembly.
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustInlineAsm(
|
|
|
|
Ty: &Type,
|
|
|
|
AsmString: *const c_char,
|
2020-03-10 00:00:00 +00:00
|
|
|
AsmStringLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
Constraints: *const c_char,
|
2020-03-10 00:00:00 +00:00
|
|
|
ConstraintsLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
SideEffects: Bool,
|
|
|
|
AlignStack: Bool,
|
|
|
|
Dialect: AsmDialect,
|
|
|
|
) -> &Value;
|
2020-03-10 00:00:00 +00:00
|
|
|
pub fn LLVMRustInlineAsmVerify(
|
|
|
|
Ty: &Type,
|
|
|
|
Constraints: *const c_char,
|
|
|
|
ConstraintsLen: size_t,
|
|
|
|
) -> bool;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2020-07-02 18:27:15 +00:00
|
|
|
#[allow(improper_ctypes)]
|
|
|
|
pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
|
|
|
|
Filenames: *const *const c_char,
|
|
|
|
FilenamesLen: size_t,
|
|
|
|
BufferOut: &RustString,
|
|
|
|
);
|
|
|
|
|
|
|
|
#[allow(improper_ctypes)]
|
|
|
|
pub fn LLVMRustCoverageWriteMappingToBuffer(
|
|
|
|
VirtualFileMappingIDs: *const c_uint,
|
|
|
|
NumVirtualFileMappingIDs: c_uint,
|
2020-07-25 04:14:28 +00:00
|
|
|
Expressions: *const rustc_codegen_ssa::coverageinfo::map::CounterExpression,
|
|
|
|
NumExpressions: c_uint,
|
|
|
|
MappingRegions: *mut CounterMappingRegion,
|
|
|
|
NumMappingRegions: c_uint,
|
2020-07-02 18:27:15 +00:00
|
|
|
BufferOut: &RustString,
|
|
|
|
);
|
|
|
|
|
|
|
|
pub fn LLVMRustCoverageComputeHash(Name: *const c_char) -> u64;
|
|
|
|
|
|
|
|
#[allow(improper_ctypes)]
|
|
|
|
pub fn LLVMRustCoverageWriteSectionNameToString(M: &Module, Str: &RustString);
|
|
|
|
|
|
|
|
#[allow(improper_ctypes)]
|
|
|
|
pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
|
|
|
|
|
|
|
|
pub fn LLVMRustCoverageMappingVersion() -> u32;
|
2016-08-02 20:10:10 +00:00
|
|
|
pub fn LLVMRustDebugMetadataVersion() -> u32;
|
|
|
|
pub fn LLVMRustVersionMajor() -> u32;
|
|
|
|
pub fn LLVMRustVersionMinor() -> u32;
|
|
|
|
|
2018-06-27 14:57:25 +00:00
|
|
|
pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMRustMetadataAsValue(C: &'a Context, MD: &'a Metadata) -> &'a Value;
|
2017-02-13 09:57:50 +00:00
|
|
|
|
2018-07-17 15:45:33 +00:00
|
|
|
pub fn LLVMRustDIBuilderCreate(M: &'a Module) -> &'a mut DIBuilder<'a>;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-17 15:45:33 +00:00
|
|
|
pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-02-25 07:40:18 +00:00
|
|
|
pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustDIBuilderCreateCompileUnit(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Lang: c_uint,
|
|
|
|
File: &'a DIFile,
|
|
|
|
Producer: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
ProducerLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
isOptimized: bool,
|
|
|
|
Flags: *const c_char,
|
|
|
|
RuntimeVer: c_uint,
|
|
|
|
SplitName: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
SplitNameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
kind: DebugEmissionKind,
|
|
|
|
) -> &'a DIDescriptor;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateFile(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Filename: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
FilenameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
Directory: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
DirectoryLen: size_t,
|
2020-03-31 05:17:15 +00:00
|
|
|
CSKind: ChecksumKind,
|
|
|
|
Checksum: *const c_char,
|
|
|
|
ChecksumLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
) -> &'a DIFile;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateSubroutineType(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
ParameterTypes: &'a DIArray,
|
|
|
|
) -> &'a DICompositeType;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateFunction(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: &'a DIDescriptor,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
LinkageName: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
LinkageNameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
File: &'a DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
Ty: &'a DIType,
|
|
|
|
ScopeLine: c_uint,
|
|
|
|
Flags: DIFlags,
|
|
|
|
SPFlags: DISPFlags,
|
|
|
|
Fn: &'a Value,
|
|
|
|
TParam: &'a DIArray,
|
|
|
|
Decl: Option<&'a DIDescriptor>,
|
|
|
|
) -> &'a DISubprogram;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateBasicType(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
SizeInBits: u64,
|
|
|
|
Encoding: c_uint,
|
|
|
|
) -> &'a DIBasicType;
|
|
|
|
|
2020-06-25 06:28:00 +00:00
|
|
|
pub fn LLVMRustDIBuilderCreateTypedef(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Type: &'a DIBasicType,
|
|
|
|
Name: *const c_char,
|
|
|
|
NameLen: size_t,
|
|
|
|
File: &'a DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
Scope: Option<&'a DIScope>,
|
|
|
|
) -> &'a DIDerivedType;
|
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustDIBuilderCreatePointerType(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
PointeeTy: &'a DIType,
|
|
|
|
SizeInBits: u64,
|
|
|
|
AlignInBits: u32,
|
2020-03-06 00:00:00 +00:00
|
|
|
AddressSpace: c_uint,
|
2019-12-22 22:42:04 +00:00
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
) -> &'a DIDerivedType;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateStructType(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: Option<&'a DIDescriptor>,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
File: &'a DIFile,
|
|
|
|
LineNumber: c_uint,
|
|
|
|
SizeInBits: u64,
|
|
|
|
AlignInBits: u32,
|
|
|
|
Flags: DIFlags,
|
|
|
|
DerivedFrom: Option<&'a DIType>,
|
|
|
|
Elements: &'a DIArray,
|
|
|
|
RunTimeLang: c_uint,
|
|
|
|
VTableHolder: Option<&'a DIType>,
|
|
|
|
UniqueId: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
UniqueIdLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
) -> &'a DICompositeType;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateMemberType(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: &'a DIDescriptor,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
File: &'a DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
SizeInBits: u64,
|
|
|
|
AlignInBits: u32,
|
|
|
|
OffsetInBits: u64,
|
|
|
|
Flags: DIFlags,
|
|
|
|
Ty: &'a DIType,
|
|
|
|
) -> &'a DIDerivedType;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateVariantMemberType(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: &'a DIScope,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
File: &'a DIFile,
|
|
|
|
LineNumber: c_uint,
|
|
|
|
SizeInBits: u64,
|
|
|
|
AlignInBits: u32,
|
|
|
|
OffsetInBits: u64,
|
|
|
|
Discriminant: Option<&'a Value>,
|
|
|
|
Flags: DIFlags,
|
|
|
|
Ty: &'a DIType,
|
|
|
|
) -> &'a DIType;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateLexicalBlock(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: &'a DIScope,
|
|
|
|
File: &'a DIFile,
|
|
|
|
Line: c_uint,
|
|
|
|
Col: c_uint,
|
|
|
|
) -> &'a DILexicalBlock;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateLexicalBlockFile(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: &'a DIScope,
|
|
|
|
File: &'a DIFile,
|
|
|
|
) -> &'a DILexicalBlock;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateStaticVariable(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Context: Option<&'a DIScope>,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
LinkageName: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
LinkageNameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
File: &'a DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
Ty: &'a DIType,
|
|
|
|
isLocalToUnit: bool,
|
|
|
|
Val: &'a Value,
|
|
|
|
Decl: Option<&'a DIDescriptor>,
|
|
|
|
AlignInBits: u32,
|
|
|
|
) -> &'a DIGlobalVariableExpression;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateVariable(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Tag: c_uint,
|
|
|
|
Scope: &'a DIDescriptor,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
File: &'a DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
Ty: &'a DIType,
|
|
|
|
AlwaysPreserve: bool,
|
|
|
|
Flags: DIFlags,
|
|
|
|
ArgNo: c_uint,
|
|
|
|
AlignInBits: u32,
|
|
|
|
) -> &'a DIVariable;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateArrayType(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Size: u64,
|
|
|
|
AlignInBits: u32,
|
|
|
|
Ty: &'a DIType,
|
|
|
|
Subscripts: &'a DIArray,
|
|
|
|
) -> &'a DIType;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderGetOrCreateSubrange(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Lo: i64,
|
|
|
|
Count: i64,
|
|
|
|
) -> &'a DISubrange;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderGetOrCreateArray(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Ptr: *const Option<&'a DIDescriptor>,
|
|
|
|
Count: c_uint,
|
|
|
|
) -> &'a DIArray;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderInsertDeclareAtEnd(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Val: &'a Value,
|
|
|
|
VarInfo: &'a DIVariable,
|
|
|
|
AddrOps: *const i64,
|
|
|
|
AddrOpsCount: c_uint,
|
|
|
|
DL: &'a Value,
|
|
|
|
InsertAtEnd: &'a BasicBlock,
|
|
|
|
) -> &'a Value;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateEnumerator(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Name: *const c_char,
|
2020-03-05 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
|
|
|
Value: i64,
|
|
|
|
IsUnsigned: bool,
|
2019-12-22 22:42:04 +00:00
|
|
|
) -> &'a DIEnumerator;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateEnumerationType(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: &'a DIScope,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
File: &'a DIFile,
|
|
|
|
LineNumber: c_uint,
|
|
|
|
SizeInBits: u64,
|
|
|
|
AlignInBits: u32,
|
|
|
|
Elements: &'a DIArray,
|
|
|
|
ClassType: &'a DIType,
|
|
|
|
IsScoped: bool,
|
|
|
|
) -> &'a DIType;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateUnionType(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: &'a DIScope,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
File: &'a DIFile,
|
|
|
|
LineNumber: c_uint,
|
|
|
|
SizeInBits: u64,
|
|
|
|
AlignInBits: u32,
|
|
|
|
Flags: DIFlags,
|
|
|
|
Elements: Option<&'a DIArray>,
|
|
|
|
RunTimeLang: c_uint,
|
|
|
|
UniqueId: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
UniqueIdLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
) -> &'a DIType;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateVariantPart(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: &'a DIScope,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
File: &'a DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
SizeInBits: u64,
|
|
|
|
AlignInBits: u32,
|
|
|
|
Flags: DIFlags,
|
|
|
|
Discriminator: Option<&'a DIDerivedType>,
|
|
|
|
Elements: &'a DIArray,
|
|
|
|
UniqueId: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
UniqueIdLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
) -> &'a DIDerivedType;
|
2017-11-29 21:42:25 +00:00
|
|
|
|
2020-03-11 00:00:00 +00:00
|
|
|
pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: Option<&'a DIScope>,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2019-12-22 22:42:04 +00:00
|
|
|
Ty: &'a DIType,
|
|
|
|
) -> &'a DITemplateTypeParameter;
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateNameSpace(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: Option<&'a DIScope>,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
|
|
|
ExportSymbols: bool,
|
2019-12-22 22:42:04 +00:00
|
|
|
) -> &'a DINameSpace;
|
|
|
|
|
|
|
|
pub fn LLVMRustDICompositeTypeReplaceArrays(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
CompositeType: &'a DIType,
|
|
|
|
Elements: Option<&'a DIArray>,
|
|
|
|
Params: Option<&'a DIArray>,
|
|
|
|
);
|
|
|
|
|
|
|
|
pub fn LLVMRustDIBuilderCreateDebugLocation(
|
|
|
|
Context: &'a Context,
|
|
|
|
Line: c_uint,
|
|
|
|
Column: c_uint,
|
|
|
|
Scope: &'a DIScope,
|
|
|
|
InlinedAt: Option<&'a Metadata>,
|
|
|
|
) -> &'a Value;
|
2016-08-02 20:10:10 +00:00
|
|
|
pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
|
2018-01-20 05:43:53 +00:00
|
|
|
pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-12-18 18:58:15 +00:00
|
|
|
#[allow(improper_ctypes)]
|
2018-07-13 11:43:12 +00:00
|
|
|
pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
|
2018-12-18 18:58:15 +00:00
|
|
|
#[allow(improper_ctypes)]
|
2018-07-13 11:43:12 +00:00
|
|
|
pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-10-13 10:19:14 +00:00
|
|
|
pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-12 15:00:49 +00:00
|
|
|
pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
|
|
|
|
pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
|
2019-11-18 00:00:00 +00:00
|
|
|
pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
|
|
|
|
pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustCreateMemorySanitizerPass(
|
|
|
|
TrackOrigins: c_int,
|
|
|
|
Recover: bool,
|
|
|
|
) -> &'static mut Pass;
|
2019-11-18 00:00:00 +00:00
|
|
|
pub fn LLVMRustCreateThreadSanitizerPass() -> &'static mut Pass;
|
2019-02-25 07:40:18 +00:00
|
|
|
pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass);
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustAddLastExtensionPasses(
|
|
|
|
PMB: &PassManagerBuilder,
|
|
|
|
Passes: *const &'static mut Pass,
|
|
|
|
NumPasses: size_t,
|
|
|
|
);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-12 15:34:59 +00:00
|
|
|
pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-12 15:34:59 +00:00
|
|
|
pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
|
|
|
|
pub fn LLVMRustPrintTargetFeatures(T: &TargetMachine);
|
2016-08-06 05:50:48 +00:00
|
|
|
|
2018-08-23 18:03:22 +00:00
|
|
|
pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustCreateTargetMachine(
|
|
|
|
Triple: *const c_char,
|
|
|
|
CPU: *const c_char,
|
|
|
|
Features: *const c_char,
|
|
|
|
Abi: *const c_char,
|
|
|
|
Model: CodeModel,
|
2020-04-23 17:49:00 +00:00
|
|
|
Reloc: RelocModel,
|
2019-12-22 22:42:04 +00:00
|
|
|
Level: CodeGenOptLevel,
|
|
|
|
UseSoftFP: bool,
|
|
|
|
FunctionSections: bool,
|
|
|
|
DataSections: bool,
|
|
|
|
TrapUnreachable: bool,
|
|
|
|
Singlethread: bool,
|
|
|
|
AsmComments: bool,
|
|
|
|
EmitStackSizeSection: bool,
|
|
|
|
RelaxELFRelocations: bool,
|
2020-04-17 02:40:11 +00:00
|
|
|
UseInitArray: bool,
|
2019-12-22 22:42:04 +00:00
|
|
|
) -> Option<&'static mut TargetMachine>;
|
2018-06-27 14:57:25 +00:00
|
|
|
pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustAddBuilderLibraryInfo(
|
|
|
|
PMB: &'a PassManagerBuilder,
|
|
|
|
M: &'a Module,
|
|
|
|
DisableSimplifyLibCalls: bool,
|
|
|
|
);
|
|
|
|
pub fn LLVMRustConfigurePassManagerBuilder(
|
|
|
|
PMB: &PassManagerBuilder,
|
|
|
|
OptLevel: CodeGenOptLevel,
|
|
|
|
MergeFunctions: bool,
|
|
|
|
SLPVectorize: bool,
|
|
|
|
LoopVectorize: bool,
|
|
|
|
PrepareForThinLTO: bool,
|
|
|
|
PGOGenPath: *const c_char,
|
|
|
|
PGOUsePath: *const c_char,
|
|
|
|
);
|
|
|
|
pub fn LLVMRustAddLibraryInfo(
|
|
|
|
PM: &PassManager<'a>,
|
|
|
|
M: &'a Module,
|
|
|
|
DisableSimplifyLibCalls: bool,
|
|
|
|
);
|
2018-07-17 11:17:47 +00:00
|
|
|
pub fn LLVMRustRunFunctionPassManager(PM: &PassManager<'a>, M: &'a Module);
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustWriteOutputFile(
|
|
|
|
T: &'a TargetMachine,
|
|
|
|
PM: &PassManager<'a>,
|
|
|
|
M: &'a Module,
|
|
|
|
Output: *const c_char,
|
|
|
|
FileType: FileType,
|
|
|
|
) -> LLVMRustResult;
|
2020-01-05 18:16:58 +00:00
|
|
|
pub fn LLVMRustOptimizeWithNewPassManager(
|
|
|
|
M: &'a Module,
|
|
|
|
TM: &'a TargetMachine,
|
|
|
|
OptLevel: PassBuilderOptLevel,
|
|
|
|
OptStage: OptStage,
|
|
|
|
NoPrepopulatePasses: bool,
|
|
|
|
VerifyIR: bool,
|
|
|
|
UseThinLTOBuffers: bool,
|
|
|
|
MergeFunctions: bool,
|
|
|
|
UnrollLoops: bool,
|
|
|
|
SLPVectorize: bool,
|
|
|
|
LoopVectorize: bool,
|
|
|
|
DisableSimplifyLibCalls: bool,
|
2020-05-13 00:00:00 +00:00
|
|
|
EmitLifetimeMarkers: bool,
|
2020-01-05 18:16:58 +00:00
|
|
|
SanitizerOptions: Option<&SanitizerOptions>,
|
|
|
|
PGOGenPath: *const c_char,
|
|
|
|
PGOUsePath: *const c_char,
|
2020-02-11 21:37:16 +00:00
|
|
|
llvm_selfprofiler: *mut c_void,
|
|
|
|
begin_callback: SelfProfileBeforePassCallback,
|
|
|
|
end_callback: SelfProfileAfterPassCallback,
|
2020-01-05 18:16:58 +00:00
|
|
|
);
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustPrintModule(
|
|
|
|
M: &'a Module,
|
|
|
|
Output: *const c_char,
|
|
|
|
Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
|
|
|
|
) -> LLVMRustResult;
|
2016-08-02 20:10:10 +00:00
|
|
|
pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
|
|
|
|
pub fn LLVMRustPrintPasses();
|
2019-10-23 13:08:26 +00:00
|
|
|
pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
|
2018-06-27 14:57:25 +00:00
|
|
|
pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
|
2018-07-12 13:24:09 +00:00
|
|
|
pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
|
2018-06-27 14:57:25 +00:00
|
|
|
pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
|
|
|
|
pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-13 10:06:06 +00:00
|
|
|
pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
|
2018-07-17 11:31:06 +00:00
|
|
|
pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
|
2018-07-17 15:26:58 +00:00
|
|
|
pub fn LLVMRustArchiveIteratorNext(
|
|
|
|
AIR: &ArchiveIterator<'a>,
|
|
|
|
) -> Option<&'a mut ArchiveChild<'a>>;
|
2019-02-25 07:40:18 +00:00
|
|
|
pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
|
|
|
|
pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
|
2018-07-17 12:02:11 +00:00
|
|
|
pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);
|
2018-07-17 11:31:06 +00:00
|
|
|
pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>);
|
2018-07-13 10:06:06 +00:00
|
|
|
pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-03-27 14:57:14 +00:00
|
|
|
#[allow(improper_ctypes)]
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustGetSectionName(
|
|
|
|
SI: &SectionIterator<'_>,
|
|
|
|
data: &mut Option<std::ptr::NonNull<c_char>>,
|
|
|
|
) -> size_t;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-12-18 18:58:15 +00:00
|
|
|
#[allow(improper_ctypes)]
|
2018-07-13 11:43:12 +00:00
|
|
|
pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMContextSetDiagnosticHandler(
|
|
|
|
C: &Context,
|
|
|
|
Handler: DiagnosticHandler,
|
|
|
|
DiagnosticContext: *mut c_void,
|
|
|
|
);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-12-18 18:58:15 +00:00
|
|
|
#[allow(improper_ctypes)]
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustUnpackOptimizationDiagnostic(
|
|
|
|
DI: &'a DiagnosticInfo,
|
|
|
|
pass_name_out: &RustString,
|
|
|
|
function_out: &mut Option<&'a Value>,
|
|
|
|
loc_line_out: &mut c_uint,
|
|
|
|
loc_column_out: &mut c_uint,
|
|
|
|
loc_filename_out: &RustString,
|
|
|
|
message_out: &RustString,
|
|
|
|
);
|
|
|
|
|
|
|
|
pub fn LLVMRustUnpackInlineAsmDiagnostic(
|
|
|
|
DI: &'a DiagnosticInfo,
|
2020-06-09 13:37:59 +00:00
|
|
|
level_out: &mut DiagnosticLevel,
|
2019-12-22 22:42:04 +00:00
|
|
|
cookie_out: &mut c_uint,
|
|
|
|
message_out: &mut Option<&'a Twine>,
|
|
|
|
instruction_out: &mut Option<&'a Value>,
|
|
|
|
);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-12-18 18:58:15 +00:00
|
|
|
#[allow(improper_ctypes)]
|
2018-07-13 11:43:12 +00:00
|
|
|
pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
|
2018-07-13 10:59:41 +00:00
|
|
|
pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustSetInlineAsmDiagnosticHandler(
|
|
|
|
C: &Context,
|
|
|
|
H: InlineAsmDiagHandler,
|
|
|
|
CX: *mut c_void,
|
|
|
|
);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-12-18 18:58:15 +00:00
|
|
|
#[allow(improper_ctypes)]
|
2020-05-26 19:07:59 +00:00
|
|
|
pub fn LLVMRustUnpackSMDiagnostic(
|
|
|
|
d: &SMDiagnostic,
|
|
|
|
message_out: &RustString,
|
|
|
|
buffer_out: &RustString,
|
2020-06-09 13:37:59 +00:00
|
|
|
level_out: &mut DiagnosticLevel,
|
2020-05-26 19:07:59 +00:00
|
|
|
loc_out: &mut c_uint,
|
|
|
|
ranges_out: *mut c_uint,
|
|
|
|
num_ranges: &mut usize,
|
|
|
|
) -> bool;
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustWriteArchive(
|
|
|
|
Dst: *const c_char,
|
|
|
|
NumMembers: size_t,
|
|
|
|
Members: *const &RustArchiveMember<'_>,
|
|
|
|
WriteSymbtab: bool,
|
|
|
|
Kind: ArchiveKind,
|
|
|
|
) -> LLVMRustResult;
|
|
|
|
pub fn LLVMRustArchiveMemberNew(
|
|
|
|
Filename: *const c_char,
|
|
|
|
Name: *const c_char,
|
|
|
|
Child: Option<&ArchiveChild<'a>>,
|
|
|
|
) -> &'a mut RustArchiveMember<'a>;
|
2018-07-17 13:00:10 +00:00
|
|
|
pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-12 15:34:59 +00:00
|
|
|
pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustBuildOperandBundleDef(
|
|
|
|
Name: *const c_char,
|
|
|
|
Inputs: *const &'a Value,
|
|
|
|
NumInputs: c_uint,
|
|
|
|
) -> &'a mut OperandBundleDef<'a>;
|
2018-07-16 13:02:31 +00:00
|
|
|
pub fn LLVMRustFreeOperandBundleDef(Bundle: &'a mut OperandBundleDef<'a>);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2018-07-17 15:33:09 +00:00
|
|
|
pub fn LLVMRustPositionBuilderAtStart(B: &Builder<'a>, BB: &'a BasicBlock);
|
2016-08-02 20:10:10 +00:00
|
|
|
|
2019-12-04 20:00:28 +00:00
|
|
|
pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
|
2018-07-10 10:28:39 +00:00
|
|
|
pub fn LLVMRustUnsetComdat(V: &Value);
|
2019-11-03 16:52:00 +00:00
|
|
|
pub fn LLVMRustSetModulePICLevel(M: &Module);
|
2018-06-27 14:57:25 +00:00
|
|
|
pub fn LLVMRustSetModulePIELevel(M: &Module);
|
2018-07-17 13:08:25 +00:00
|
|
|
pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
|
|
|
|
pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
|
|
|
|
pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
|
|
|
|
pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
|
2018-06-27 14:57:25 +00:00
|
|
|
pub fn LLVMRustModuleCost(M: &Module) -> u64;
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 15:14:38 +00:00
|
|
|
|
2018-07-17 13:31:09 +00:00
|
|
|
pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
|
|
|
|
pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
|
|
|
|
pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
|
|
|
|
pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 15:14:38 +00:00
|
|
|
pub fn LLVMRustCreateThinLTOData(
|
|
|
|
Modules: *const ThinLTOModule,
|
|
|
|
NumModules: c_uint,
|
|
|
|
PreservedSymbols: *const *const c_char,
|
|
|
|
PreservedSymbolsLen: c_uint,
|
2018-07-17 13:43:49 +00:00
|
|
|
) -> Option<&'static mut ThinLTOData>;
|
2020-06-26 01:52:41 +00:00
|
|
|
pub fn LLVMRustPrepareThinLTORename(
|
|
|
|
Data: &ThinLTOData,
|
|
|
|
Module: &Module,
|
|
|
|
Target: &TargetMachine,
|
|
|
|
) -> bool;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
|
|
|
|
pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
|
2020-06-26 01:52:41 +00:00
|
|
|
pub fn LLVMRustPrepareThinLTOImport(
|
|
|
|
Data: &ThinLTOData,
|
|
|
|
Module: &Module,
|
|
|
|
Target: &TargetMachine,
|
|
|
|
) -> bool;
|
2018-08-17 13:25:46 +00:00
|
|
|
pub fn LLVMRustGetThinLTOModuleImports(
|
|
|
|
Data: *const ThinLTOData,
|
|
|
|
ModuleNameCallback: ThinLTOModuleNameCallback,
|
|
|
|
CallbackPayload: *mut c_void,
|
|
|
|
);
|
2018-07-17 13:43:49 +00:00
|
|
|
pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
|
2019-02-11 15:46:04 +00:00
|
|
|
pub fn LLVMRustParseBitcodeForLTO(
|
2018-06-27 14:57:25 +00:00
|
|
|
Context: &Context,
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 15:14:38 +00:00
|
|
|
Data: *const u8,
|
|
|
|
len: usize,
|
|
|
|
Identifier: *const c_char,
|
2018-06-27 14:57:25 +00:00
|
|
|
) -> Option<&Module>;
|
2020-04-23 18:45:55 +00:00
|
|
|
pub fn LLVMRustGetBitcodeSliceFromObjectData(
|
|
|
|
Data: *const u8,
|
|
|
|
len: usize,
|
|
|
|
out_len: &mut usize,
|
|
|
|
) -> *const u8;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustThinLTOGetDICompileUnit(
|
|
|
|
M: &Module,
|
|
|
|
CU1: &mut *mut c_void,
|
|
|
|
CU2: &mut *mut c_void,
|
|
|
|
);
|
2018-06-27 14:57:25 +00:00
|
|
|
pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
|
2018-02-12 16:38:46 +00:00
|
|
|
|
2018-07-17 11:26:22 +00:00
|
|
|
pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn LLVMRustLinkerAdd(
|
|
|
|
linker: &Linker<'_>,
|
|
|
|
bytecode: *const c_char,
|
|
|
|
bytecode_len: usize,
|
|
|
|
) -> bool;
|
2018-07-17 11:26:22 +00:00
|
|
|
pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);
|
2016-08-02 20:10:10 +00:00
|
|
|
}
|