@@ -82,59 +82,31 @@ pub enum DLLStorageClass {
8282 DllExport = 2 , // Function to be accessible from DLL.
8383}
8484
85- bitflags ! {
86- #[ derive( Default , Debug ) ]
87- flags Attribute : u64 {
88- const ZExt = 1 << 0 ,
89- const SExt = 1 << 1 ,
90- const NoReturn = 1 << 2 ,
91- const InReg = 1 << 3 ,
92- const StructRet = 1 << 4 ,
93- const NoUnwind = 1 << 5 ,
94- const NoAlias = 1 << 6 ,
95- const ByVal = 1 << 7 ,
96- const Nest = 1 << 8 ,
97- const ReadNone = 1 << 9 ,
98- const ReadOnly = 1 << 10 ,
99- const NoInline = 1 << 11 ,
100- const AlwaysInline = 1 << 12 ,
101- const OptimizeForSize = 1 << 13 ,
102- const StackProtect = 1 << 14 ,
103- const StackProtectReq = 1 << 15 ,
104- const NoCapture = 1 << 21 ,
105- const NoRedZone = 1 << 22 ,
106- const NoImplicitFloat = 1 << 23 ,
107- const Naked = 1 << 24 ,
108- const InlineHint = 1 << 25 ,
109- const ReturnsTwice = 1 << 29 ,
110- const UWTable = 1 << 30 ,
111- const NonLazyBind = 1 << 31 ,
112-
113- // Some of these are missing from the LLVM C API, the rest are
114- // present, but commented out, and preceded by the following warning:
115- // FIXME: These attributes are currently not included in the C API as
116- // a temporary measure until the API/ABI impact to the C API is understood
117- // and the path forward agreed upon.
118- const SanitizeAddress = 1 << 32 ,
119- const MinSize = 1 << 33 ,
120- const NoDuplicate = 1 << 34 ,
121- const StackProtectStrong = 1 << 35 ,
122- const SanitizeThread = 1 << 36 ,
123- const SanitizeMemory = 1 << 37 ,
124- const NoBuiltin = 1 << 38 ,
125- const Returned = 1 << 39 ,
126- const Cold = 1 << 40 ,
127- const Builtin = 1 << 41 ,
128- const OptimizeNone = 1 << 42 ,
129- const InAlloca = 1 << 43 ,
130- const NonNull = 1 << 44 ,
131- const JumpTable = 1 << 45 ,
132- const Convergent = 1 << 46 ,
133- const SafeStack = 1 << 47 ,
134- const NoRecurse = 1 << 48 ,
135- const InaccessibleMemOnly = 1 << 49 ,
136- const InaccessibleMemOrArgMemOnly = 1 << 50 ,
137- }
85+ /// Matches LLVMRustAttribute in rustllvm.h
86+ /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
87+ /// though it is not ABI compatible (since it's a C++ enum)
88+ #[ repr( C ) ]
89+ #[ derive( Copy , Clone , Debug ) ]
90+ pub enum Attribute {
91+ AlwaysInline = 0 ,
92+ ByVal = 1 ,
93+ Cold = 2 ,
94+ InlineHint = 3 ,
95+ MinSize = 4 ,
96+ Naked = 5 ,
97+ NoAlias = 6 ,
98+ NoCapture = 7 ,
99+ NoInline = 8 ,
100+ NonNull = 9 ,
101+ NoRedZone = 10 ,
102+ NoReturn = 11 ,
103+ NoUnwind = 12 ,
104+ OptimizeForSize = 13 ,
105+ ReadOnly = 14 ,
106+ SExt = 15 ,
107+ StructRet = 16 ,
108+ UWTable = 17 ,
109+ ZExt = 18 ,
138110}
139111
140112/// LLVMIntPredicate
@@ -422,6 +394,9 @@ pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
422394#[ allow( missing_copy_implementations) ]
423395pub enum OperandBundleDef_opaque { }
424396pub type OperandBundleDefRef = * mut OperandBundleDef_opaque ;
397+ #[ allow( missing_copy_implementations) ]
398+ pub enum Attribute_opaque { }
399+ pub type AttributeRef = * mut Attribute_opaque ;
425400
426401pub type DiagnosticHandler = unsafe extern "C" fn ( DiagnosticInfoRef , * mut c_void ) ;
427402pub type InlineAsmDiagHandler = unsafe extern "C" fn ( SMDiagnosticRef , * const c_void , c_uint ) ;
@@ -521,6 +496,9 @@ extern "C" {
521496 /// See llvm::LLVMType::getContext.
522497 pub fn LLVMGetTypeContext ( Ty : TypeRef ) -> ContextRef ;
523498
499+ /// See llvm::Value::getContext
500+ pub fn LLVMRustGetValueContext ( V : ValueRef ) -> ContextRef ;
501+
524502 // Operations on integer types
525503 pub fn LLVMInt1TypeInContext ( C : ContextRef ) -> TypeRef ;
526504 pub fn LLVMInt8TypeInContext ( C : ContextRef ) -> TypeRef ;
@@ -783,6 +761,8 @@ extern "C" {
783761 Name : * const c_char )
784762 -> ValueRef ;
785763
764+ pub fn LLVMRustCreateAttribute ( C : ContextRef , kind : Attribute , val : u64 ) -> AttributeRef ;
765+
786766 // Operations on functions
787767 pub fn LLVMAddFunction ( M : ModuleRef , Name : * const c_char , FunctionTy : TypeRef ) -> ValueRef ;
788768 pub fn LLVMGetNamedFunction ( M : ModuleRef , Name : * const c_char ) -> ValueRef ;
@@ -801,16 +781,12 @@ extern "C" {
801781 pub fn LLVMGetGC ( Fn : ValueRef ) -> * const c_char ;
802782 pub fn LLVMSetGC ( Fn : ValueRef , Name : * const c_char ) ;
803783 pub fn LLVMRustAddDereferenceableAttr ( Fn : ValueRef , index : c_uint , bytes : u64 ) ;
804- pub fn LLVMRustAddFunctionAttribute ( Fn : ValueRef , index : c_uint , PA : u64 ) ;
805- pub fn LLVMRustAddFunctionAttrString ( Fn : ValueRef , index : c_uint , Name : * const c_char ) ;
784+ pub fn LLVMRustAddFunctionAttribute ( Fn : ValueRef , index : c_uint , attr : AttributeRef ) ;
806785 pub fn LLVMRustAddFunctionAttrStringValue ( Fn : ValueRef ,
807786 index : c_uint ,
808787 Name : * const c_char ,
809788 Value : * const c_char ) ;
810- pub fn LLVMRustRemoveFunctionAttributes ( Fn : ValueRef , index : c_uint , attr : u64 ) ;
811- pub fn LLVMRustRemoveFunctionAttrString ( Fn : ValueRef , index : c_uint , Name : * const c_char ) ;
812- pub fn LLVMGetFunctionAttr ( Fn : ValueRef ) -> c_uint ;
813- pub fn LLVMRemoveFunctionAttr ( Fn : ValueRef , val : c_uint ) ;
789+ pub fn LLVMRustRemoveFunctionAttributes ( Fn : ValueRef , index : c_uint , attr : AttributeRef ) ;
814790
815791 // Operations on parameters
816792 pub fn LLVMCountParams ( Fn : ValueRef ) -> c_uint ;
@@ -821,9 +797,8 @@ extern "C" {
821797 pub fn LLVMGetLastParam ( Fn : ValueRef ) -> ValueRef ;
822798 pub fn LLVMGetNextParam ( Arg : ValueRef ) -> ValueRef ;
823799 pub fn LLVMGetPreviousParam ( Arg : ValueRef ) -> ValueRef ;
824- pub fn LLVMAddAttribute ( Arg : ValueRef , PA : c_uint ) ;
825- pub fn LLVMRemoveAttribute ( Arg : ValueRef , PA : c_uint ) ;
826- pub fn LLVMGetAttribute ( Arg : ValueRef ) -> c_uint ;
800+ pub fn LLVMAddAttribute ( Arg : ValueRef , attr : AttributeRef ) ;
801+ pub fn LLVMRemoveAttribute ( Arg : ValueRef , attr : AttributeRef ) ;
827802 pub fn LLVMSetParamAlignment ( Arg : ValueRef , align : c_uint ) ;
828803
829804 // Operations on basic blocks
@@ -867,7 +842,7 @@ extern "C" {
867842 pub fn LLVMAddInstrAttribute ( Instr : ValueRef , index : c_uint , IA : c_uint ) ;
868843 pub fn LLVMRemoveInstrAttribute ( Instr : ValueRef , index : c_uint , IA : c_uint ) ;
869844 pub fn LLVMSetInstrParamAlignment ( Instr : ValueRef , index : c_uint , align : c_uint ) ;
870- pub fn LLVMRustAddCallSiteAttribute ( Instr : ValueRef , index : c_uint , Val : u64 ) ;
845+ pub fn LLVMRustAddCallSiteAttribute ( Instr : ValueRef , index : c_uint , attr : AttributeRef ) ;
871846 pub fn LLVMRustAddDereferenceableCallSiteAttr ( Instr : ValueRef , index : c_uint , bytes : u64 ) ;
872847
873848 // Operations on call instructions (only)
0 commit comments