@@ -83,59 +83,31 @@ pub enum DLLStorageClass {
83
83
DllExport = 2 , // Function to be accessible from DLL.
84
84
}
85
85
86
- bitflags ! {
87
- #[ derive( Default , Debug ) ]
88
- flags Attribute : u64 {
89
- const ZExt = 1 << 0 ,
90
- const SExt = 1 << 1 ,
91
- const NoReturn = 1 << 2 ,
92
- const InReg = 1 << 3 ,
93
- const StructRet = 1 << 4 ,
94
- const NoUnwind = 1 << 5 ,
95
- const NoAlias = 1 << 6 ,
96
- const ByVal = 1 << 7 ,
97
- const Nest = 1 << 8 ,
98
- const ReadNone = 1 << 9 ,
99
- const ReadOnly = 1 << 10 ,
100
- const NoInline = 1 << 11 ,
101
- const AlwaysInline = 1 << 12 ,
102
- const OptimizeForSize = 1 << 13 ,
103
- const StackProtect = 1 << 14 ,
104
- const StackProtectReq = 1 << 15 ,
105
- const NoCapture = 1 << 21 ,
106
- const NoRedZone = 1 << 22 ,
107
- const NoImplicitFloat = 1 << 23 ,
108
- const Naked = 1 << 24 ,
109
- const InlineHint = 1 << 25 ,
110
- const ReturnsTwice = 1 << 29 ,
111
- const UWTable = 1 << 30 ,
112
- const NonLazyBind = 1 << 31 ,
113
-
114
- // Some of these are missing from the LLVM C API, the rest are
115
- // present, but commented out, and preceded by the following warning:
116
- // FIXME: These attributes are currently not included in the C API as
117
- // a temporary measure until the API/ABI impact to the C API is understood
118
- // and the path forward agreed upon.
119
- const SanitizeAddress = 1 << 32 ,
120
- const MinSize = 1 << 33 ,
121
- const NoDuplicate = 1 << 34 ,
122
- const StackProtectStrong = 1 << 35 ,
123
- const SanitizeThread = 1 << 36 ,
124
- const SanitizeMemory = 1 << 37 ,
125
- const NoBuiltin = 1 << 38 ,
126
- const Returned = 1 << 39 ,
127
- const Cold = 1 << 40 ,
128
- const Builtin = 1 << 41 ,
129
- const OptimizeNone = 1 << 42 ,
130
- const InAlloca = 1 << 43 ,
131
- const NonNull = 1 << 44 ,
132
- const JumpTable = 1 << 45 ,
133
- const Convergent = 1 << 46 ,
134
- const SafeStack = 1 << 47 ,
135
- const NoRecurse = 1 << 48 ,
136
- const InaccessibleMemOnly = 1 << 49 ,
137
- const InaccessibleMemOrArgMemOnly = 1 << 50 ,
138
- }
86
+ /// Matches LLVMRustAttribute in rustllvm.h
87
+ /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
88
+ /// though it is not ABI compatible (since it's a C++ enum)
89
+ #[ repr( C ) ]
90
+ #[ derive( Copy , Clone , Debug ) ]
91
+ pub enum Attribute {
92
+ AlwaysInline = 0 ,
93
+ ByVal = 1 ,
94
+ Cold = 2 ,
95
+ InlineHint = 3 ,
96
+ MinSize = 4 ,
97
+ Naked = 5 ,
98
+ NoAlias = 6 ,
99
+ NoCapture = 7 ,
100
+ NoInline = 8 ,
101
+ NonNull = 9 ,
102
+ NoRedZone = 10 ,
103
+ NoReturn = 11 ,
104
+ NoUnwind = 12 ,
105
+ OptimizeForSize = 13 ,
106
+ ReadOnly = 14 ,
107
+ SExt = 15 ,
108
+ StructRet = 16 ,
109
+ UWTable = 17 ,
110
+ ZExt = 18 ,
139
111
}
140
112
141
113
/// LLVMIntPredicate
@@ -423,6 +395,9 @@ pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
423
395
#[ allow( missing_copy_implementations) ]
424
396
pub enum OperandBundleDef_opaque { }
425
397
pub type OperandBundleDefRef = * mut OperandBundleDef_opaque ;
398
+ #[ allow( missing_copy_implementations) ]
399
+ pub enum Attribute_opaque { }
400
+ pub type AttributeRef = * mut Attribute_opaque ;
426
401
427
402
pub type DiagnosticHandler = unsafe extern "C" fn ( DiagnosticInfoRef , * mut c_void ) ;
428
403
pub type InlineAsmDiagHandler = unsafe extern "C" fn ( SMDiagnosticRef , * const c_void , c_uint ) ;
@@ -530,6 +505,9 @@ extern "C" {
530
505
/// See llvm::LLVMType::getContext.
531
506
pub fn LLVMGetTypeContext ( Ty : TypeRef ) -> ContextRef ;
532
507
508
+ /// See llvm::Value::getContext
509
+ pub fn LLVMRustGetValueContext ( V : ValueRef ) -> ContextRef ;
510
+
533
511
// Operations on integer types
534
512
pub fn LLVMInt1TypeInContext ( C : ContextRef ) -> TypeRef ;
535
513
pub fn LLVMInt8TypeInContext ( C : ContextRef ) -> TypeRef ;
@@ -792,6 +770,8 @@ extern "C" {
792
770
Name : * const c_char )
793
771
-> ValueRef ;
794
772
773
+ pub fn LLVMRustCreateAttribute ( C : ContextRef , kind : Attribute , val : u64 ) -> AttributeRef ;
774
+
795
775
// Operations on functions
796
776
pub fn LLVMAddFunction ( M : ModuleRef , Name : * const c_char , FunctionTy : TypeRef ) -> ValueRef ;
797
777
pub fn LLVMGetNamedFunction ( M : ModuleRef , Name : * const c_char ) -> ValueRef ;
@@ -810,16 +790,12 @@ extern "C" {
810
790
pub fn LLVMGetGC ( Fn : ValueRef ) -> * const c_char ;
811
791
pub fn LLVMSetGC ( Fn : ValueRef , Name : * const c_char ) ;
812
792
pub fn LLVMRustAddDereferenceableAttr ( Fn : ValueRef , index : c_uint , bytes : u64 ) ;
813
- pub fn LLVMRustAddFunctionAttribute ( Fn : ValueRef , index : c_uint , PA : u64 ) ;
814
- pub fn LLVMRustAddFunctionAttrString ( Fn : ValueRef , index : c_uint , Name : * const c_char ) ;
793
+ pub fn LLVMRustAddFunctionAttribute ( Fn : ValueRef , index : c_uint , attr : AttributeRef ) ;
815
794
pub fn LLVMRustAddFunctionAttrStringValue ( Fn : ValueRef ,
816
795
index : c_uint ,
817
796
Name : * const c_char ,
818
797
Value : * const c_char ) ;
819
- pub fn LLVMRustRemoveFunctionAttributes ( Fn : ValueRef , index : c_uint , attr : u64 ) ;
820
- pub fn LLVMRustRemoveFunctionAttrString ( Fn : ValueRef , index : c_uint , Name : * const c_char ) ;
821
- pub fn LLVMGetFunctionAttr ( Fn : ValueRef ) -> c_uint ;
822
- pub fn LLVMRemoveFunctionAttr ( Fn : ValueRef , val : c_uint ) ;
798
+ pub fn LLVMRustRemoveFunctionAttributes ( Fn : ValueRef , index : c_uint , attr : AttributeRef ) ;
823
799
824
800
// Operations on parameters
825
801
pub fn LLVMCountParams ( Fn : ValueRef ) -> c_uint ;
@@ -830,9 +806,8 @@ extern "C" {
830
806
pub fn LLVMGetLastParam ( Fn : ValueRef ) -> ValueRef ;
831
807
pub fn LLVMGetNextParam ( Arg : ValueRef ) -> ValueRef ;
832
808
pub fn LLVMGetPreviousParam ( Arg : ValueRef ) -> ValueRef ;
833
- pub fn LLVMAddAttribute ( Arg : ValueRef , PA : c_uint ) ;
834
- pub fn LLVMRemoveAttribute ( Arg : ValueRef , PA : c_uint ) ;
835
- pub fn LLVMGetAttribute ( Arg : ValueRef ) -> c_uint ;
809
+ pub fn LLVMAddAttribute ( Arg : ValueRef , attr : AttributeRef ) ;
810
+ pub fn LLVMRemoveAttribute ( Arg : ValueRef , attr : AttributeRef ) ;
836
811
pub fn LLVMSetParamAlignment ( Arg : ValueRef , align : c_uint ) ;
837
812
838
813
// Operations on basic blocks
@@ -876,7 +851,7 @@ extern "C" {
876
851
pub fn LLVMAddInstrAttribute ( Instr : ValueRef , index : c_uint , IA : c_uint ) ;
877
852
pub fn LLVMRemoveInstrAttribute ( Instr : ValueRef , index : c_uint , IA : c_uint ) ;
878
853
pub fn LLVMSetInstrParamAlignment ( Instr : ValueRef , index : c_uint , align : c_uint ) ;
879
- pub fn LLVMRustAddCallSiteAttribute ( Instr : ValueRef , index : c_uint , Val : u64 ) ;
854
+ pub fn LLVMRustAddCallSiteAttribute ( Instr : ValueRef , index : c_uint , attr : AttributeRef ) ;
880
855
pub fn LLVMRustAddDereferenceableCallSiteAttr ( Instr : ValueRef , index : c_uint , bytes : u64 ) ;
881
856
882
857
// Operations on call instructions (only)
0 commit comments