Restore compatibility with LLVM 3.7 and 3.8
This commit is contained in:
parent
fc2373c5a2
commit
c45f3dee10
3 changed files with 15 additions and 27 deletions
|
@ -395,9 +395,6 @@ pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
|
||||||
#[allow(missing_copy_implementations)]
|
#[allow(missing_copy_implementations)]
|
||||||
pub enum OperandBundleDef_opaque {}
|
pub enum OperandBundleDef_opaque {}
|
||||||
pub type OperandBundleDefRef = *mut OperandBundleDef_opaque;
|
pub type OperandBundleDefRef = *mut OperandBundleDef_opaque;
|
||||||
#[allow(missing_copy_implementations)]
|
|
||||||
pub enum Attribute_opaque {}
|
|
||||||
pub type AttributeRef = *mut Attribute_opaque;
|
|
||||||
|
|
||||||
pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
|
pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
|
||||||
pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
|
pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
|
||||||
|
@ -770,8 +767,6 @@ extern "C" {
|
||||||
Name: *const c_char)
|
Name: *const c_char)
|
||||||
-> ValueRef;
|
-> ValueRef;
|
||||||
|
|
||||||
pub fn LLVMRustCreateAttribute(C: ContextRef, kind: Attribute, val: u64) -> AttributeRef;
|
|
||||||
|
|
||||||
// Operations on functions
|
// Operations on functions
|
||||||
pub fn LLVMAddFunction(M: ModuleRef, Name: *const c_char, FunctionTy: TypeRef) -> ValueRef;
|
pub fn LLVMAddFunction(M: ModuleRef, Name: *const c_char, FunctionTy: TypeRef) -> ValueRef;
|
||||||
pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
|
pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
|
||||||
|
@ -790,12 +785,12 @@ extern "C" {
|
||||||
pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
|
pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
|
||||||
pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
|
pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
|
||||||
pub fn LLVMRustAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: u64);
|
pub fn LLVMRustAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: u64);
|
||||||
pub fn LLVMRustAddFunctionAttribute(Fn: ValueRef, index: c_uint, attr: AttributeRef);
|
pub fn LLVMRustAddFunctionAttribute(Fn: ValueRef, index: c_uint, attr: Attribute);
|
||||||
pub fn LLVMRustAddFunctionAttrStringValue(Fn: ValueRef,
|
pub fn LLVMRustAddFunctionAttrStringValue(Fn: ValueRef,
|
||||||
index: c_uint,
|
index: c_uint,
|
||||||
Name: *const c_char,
|
Name: *const c_char,
|
||||||
Value: *const c_char);
|
Value: *const c_char);
|
||||||
pub fn LLVMRustRemoveFunctionAttributes(Fn: ValueRef, index: c_uint, attr: AttributeRef);
|
pub fn LLVMRustRemoveFunctionAttributes(Fn: ValueRef, index: c_uint, attr: Attribute);
|
||||||
|
|
||||||
// Operations on parameters
|
// Operations on parameters
|
||||||
pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
|
pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
|
||||||
|
@ -806,8 +801,6 @@ extern "C" {
|
||||||
pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
|
pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
|
||||||
pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
|
pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
|
||||||
pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
|
pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
|
||||||
pub fn LLVMAddAttribute(Arg: ValueRef, attr: AttributeRef);
|
|
||||||
pub fn LLVMRemoveAttribute(Arg: ValueRef, attr: AttributeRef);
|
|
||||||
pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
|
pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
|
||||||
|
|
||||||
// Operations on basic blocks
|
// Operations on basic blocks
|
||||||
|
@ -851,7 +844,7 @@ extern "C" {
|
||||||
pub fn LLVMAddInstrAttribute(Instr: ValueRef, index: c_uint, IA: c_uint);
|
pub fn LLVMAddInstrAttribute(Instr: ValueRef, index: c_uint, IA: c_uint);
|
||||||
pub fn LLVMRemoveInstrAttribute(Instr: ValueRef, index: c_uint, IA: c_uint);
|
pub fn LLVMRemoveInstrAttribute(Instr: ValueRef, index: c_uint, IA: c_uint);
|
||||||
pub fn LLVMSetInstrParamAlignment(Instr: ValueRef, index: c_uint, align: c_uint);
|
pub fn LLVMSetInstrParamAlignment(Instr: ValueRef, index: c_uint, align: c_uint);
|
||||||
pub fn LLVMRustAddCallSiteAttribute(Instr: ValueRef, index: c_uint, attr: AttributeRef);
|
pub fn LLVMRustAddCallSiteAttribute(Instr: ValueRef, index: c_uint, attr: Attribute);
|
||||||
pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: ValueRef, index: c_uint, bytes: u64);
|
pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: ValueRef, index: c_uint, bytes: u64);
|
||||||
|
|
||||||
// Operations on call instructions (only)
|
// Operations on call instructions (only)
|
||||||
|
|
|
@ -176,20 +176,16 @@ pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Attribute {
|
impl Attribute {
|
||||||
fn as_object(&self, value: ValueRef) -> AttributeRef {
|
|
||||||
unsafe { LLVMRustCreateAttribute(LLVMRustGetValueContext(value), *self, 0) }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn apply_llfn(&self, idx: AttributePlace, llfn: ValueRef) {
|
pub fn apply_llfn(&self, idx: AttributePlace, llfn: ValueRef) {
|
||||||
unsafe { LLVMRustAddFunctionAttribute(llfn, idx.as_uint(), self.as_object(llfn)) }
|
unsafe { LLVMRustAddFunctionAttribute(llfn, idx.as_uint(), *self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_callsite(&self, idx: AttributePlace, callsite: ValueRef) {
|
pub fn apply_callsite(&self, idx: AttributePlace, callsite: ValueRef) {
|
||||||
unsafe { LLVMRustAddCallSiteAttribute(callsite, idx.as_uint(), self.as_object(callsite)) }
|
unsafe { LLVMRustAddCallSiteAttribute(callsite, idx.as_uint(), *self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unapply_llfn(&self, idx: AttributePlace, llfn: ValueRef) {
|
pub fn unapply_llfn(&self, idx: AttributePlace, llfn: ValueRef) {
|
||||||
unsafe { LLVMRustRemoveFunctionAttributes(llfn, idx.as_uint(), self.as_object(llfn)) }
|
unsafe { LLVMRustRemoveFunctionAttributes(llfn, idx.as_uint(), *self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_llfn(&self, idx: AttributePlace, llfn: ValueRef, set: bool) {
|
pub fn toggle_llfn(&self, idx: AttributePlace, llfn: ValueRef, set: bool) {
|
||||||
|
|
|
@ -155,13 +155,10 @@ from_rust(LLVMRustAttribute kind) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMAttributeRef LLVMRustCreateAttribute(LLVMContextRef C, LLVMRustAttribute Kind, uint64_t Val) {
|
extern "C" void LLVMRustAddCallSiteAttribute(LLVMValueRef Instr, unsigned index, LLVMRustAttribute attr) {
|
||||||
return wrap(Attribute::get(*unwrap(C), from_rust(Kind), Val));
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void LLVMRustAddCallSiteAttribute(LLVMValueRef Instr, unsigned index, LLVMAttributeRef attr) {
|
|
||||||
CallSite Call = CallSite(unwrap<Instruction>(Instr));
|
CallSite Call = CallSite(unwrap<Instruction>(Instr));
|
||||||
AttrBuilder B(unwrap(attr));
|
Attribute Attr = Attribute::get(Call->getContext(), from_rust(attr));
|
||||||
|
AttrBuilder B(Attr);
|
||||||
Call.setAttributes(
|
Call.setAttributes(
|
||||||
Call.getAttributes().addAttributes(Call->getContext(), index,
|
Call.getAttributes().addAttributes(Call->getContext(), index,
|
||||||
AttributeSet::get(Call->getContext(),
|
AttributeSet::get(Call->getContext(),
|
||||||
|
@ -183,10 +180,11 @@ extern "C" void LLVMRustAddDereferenceableCallSiteAttr(LLVMValueRef Instr,
|
||||||
|
|
||||||
extern "C" void LLVMRustAddFunctionAttribute(LLVMValueRef Fn,
|
extern "C" void LLVMRustAddFunctionAttribute(LLVMValueRef Fn,
|
||||||
unsigned index,
|
unsigned index,
|
||||||
LLVMAttributeRef attr)
|
LLVMRustAttribute attr)
|
||||||
{
|
{
|
||||||
Function *A = unwrap<Function>(Fn);
|
Function *A = unwrap<Function>(Fn);
|
||||||
AttrBuilder B(unwrap(attr));
|
Attribute Attr = Attribute::get(A->getContext(), from_rust(attr));
|
||||||
|
AttrBuilder B(Attr);
|
||||||
A->addAttributes(index, AttributeSet::get(A->getContext(), index, B));
|
A->addAttributes(index, AttributeSet::get(A->getContext(), index, B));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,11 +210,12 @@ extern "C" void LLVMRustAddFunctionAttrStringValue(LLVMValueRef Fn,
|
||||||
|
|
||||||
extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
|
extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
|
||||||
unsigned index,
|
unsigned index,
|
||||||
LLVMAttributeRef attr)
|
LLVMRustAttribute attr)
|
||||||
{
|
{
|
||||||
Function *F = unwrap<Function>(Fn);
|
Function *F = unwrap<Function>(Fn);
|
||||||
const AttributeSet PAL = F->getAttributes();
|
const AttributeSet PAL = F->getAttributes();
|
||||||
AttrBuilder B(unwrap(attr));
|
Attribute Attr = Attribute::get(F->getContext(), from_rust(attr));
|
||||||
|
AttrBuilder B(Attr);
|
||||||
const AttributeSet PALnew =
|
const AttributeSet PALnew =
|
||||||
PAL.removeAttributes(F->getContext(), index,
|
PAL.removeAttributes(F->getContext(), index,
|
||||||
AttributeSet::get(F->getContext(), index, B));
|
AttributeSet::get(F->getContext(), index, B));
|
||||||
|
|
Loading…
Add table
Reference in a new issue