@@ -82,59 +82,31 @@ pub enum DLLStorageClass {
82
82
DllExport = 2 , // Function to be accessible from DLL.
83
83
}
84
84
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 ,
138
110
}
139
111
140
112
/// LLVMIntPredicate
@@ -422,6 +394,9 @@ pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
422
394
#[ allow( missing_copy_implementations) ]
423
395
pub enum OperandBundleDef_opaque { }
424
396
pub type OperandBundleDefRef = * mut OperandBundleDef_opaque ;
397
+ #[ allow( missing_copy_implementations) ]
398
+ pub enum Attribute_opaque { }
399
+ pub type AttributeRef = * mut Attribute_opaque ;
425
400
426
401
pub type DiagnosticHandler = unsafe extern "C" fn ( DiagnosticInfoRef , * mut c_void ) ;
427
402
pub type InlineAsmDiagHandler = unsafe extern "C" fn ( SMDiagnosticRef , * const c_void , c_uint ) ;
@@ -521,6 +496,9 @@ extern "C" {
521
496
/// See llvm::LLVMType::getContext.
522
497
pub fn LLVMGetTypeContext ( Ty : TypeRef ) -> ContextRef ;
523
498
499
+ /// See llvm::Value::getContext
500
+ pub fn LLVMRustGetValueContext ( V : ValueRef ) -> ContextRef ;
501
+
524
502
// Operations on integer types
525
503
pub fn LLVMInt1TypeInContext ( C : ContextRef ) -> TypeRef ;
526
504
pub fn LLVMInt8TypeInContext ( C : ContextRef ) -> TypeRef ;
@@ -783,6 +761,8 @@ extern "C" {
783
761
Name : * const c_char )
784
762
-> ValueRef ;
785
763
764
+ pub fn LLVMRustCreateAttribute ( C : ContextRef , kind : Attribute , val : u64 ) -> AttributeRef ;
765
+
786
766
// Operations on functions
787
767
pub fn LLVMAddFunction ( M : ModuleRef , Name : * const c_char , FunctionTy : TypeRef ) -> ValueRef ;
788
768
pub fn LLVMGetNamedFunction ( M : ModuleRef , Name : * const c_char ) -> ValueRef ;
@@ -801,16 +781,12 @@ extern "C" {
801
781
pub fn LLVMGetGC ( Fn : ValueRef ) -> * const c_char ;
802
782
pub fn LLVMSetGC ( Fn : ValueRef , Name : * const c_char ) ;
803
783
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 ) ;
806
785
pub fn LLVMRustAddFunctionAttrStringValue ( Fn : ValueRef ,
807
786
index : c_uint ,
808
787
Name : * const c_char ,
809
788
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 ) ;
814
790
815
791
// Operations on parameters
816
792
pub fn LLVMCountParams ( Fn : ValueRef ) -> c_uint ;
@@ -821,9 +797,8 @@ extern "C" {
821
797
pub fn LLVMGetLastParam ( Fn : ValueRef ) -> ValueRef ;
822
798
pub fn LLVMGetNextParam ( Arg : ValueRef ) -> ValueRef ;
823
799
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 ) ;
827
802
pub fn LLVMSetParamAlignment ( Arg : ValueRef , align : c_uint ) ;
828
803
829
804
// Operations on basic blocks
@@ -867,7 +842,7 @@ extern "C" {
867
842
pub fn LLVMAddInstrAttribute ( Instr : ValueRef , index : c_uint , IA : c_uint ) ;
868
843
pub fn LLVMRemoveInstrAttribute ( Instr : ValueRef , index : c_uint , IA : c_uint ) ;
869
844
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 ) ;
871
846
pub fn LLVMRustAddDereferenceableCallSiteAttr ( Instr : ValueRef , index : c_uint , bytes : u64 ) ;
872
847
873
848
// Operations on call instructions (only)
0 commit comments