@@ -59,35 +59,35 @@ pub enum Linkage {
5959}
6060
6161pub enum Attribute {
62- ZExtAttribute = 1 ,
63- SExtAttribute = 2 ,
64- NoReturnAttribute = 4 ,
65- InRegAttribute = 8 ,
66- StructRetAttribute = 16 ,
67- NoUnwindAttribute = 32 ,
68- NoAliasAttribute = 64 ,
69- ByValAttribute = 128 ,
70- NestAttribute = 256 ,
71- ReadNoneAttribute = 512 ,
72- ReadOnlyAttribute = 1024 ,
73- NoInlineAttribute = 2048 ,
74- AlwaysInlineAttribute = 4096 ,
75- OptimizeForSizeAttribute = 8192 ,
76- StackProtectAttribute = 16384 ,
77- StackProtectReqAttribute = 32768 ,
78- // 31 << 16
79- AlignmentAttribute = 2031616 ,
80- NoCaptureAttribute = 2097152 ,
81- NoRedZoneAttribute = 4194304 ,
82- NoImplicitFloatAttribute = 8388608 ,
83- NakedAttribute = 16777216 ,
84- InlineHintAttribute = 33554432 ,
85- // 7 << 26
86- StackAttribute = 469762048 ,
87- ReturnsTwiceAttribute = 536870912 ,
88- // 1 << 30
89- UWTableAttribute = 1073741824 ,
90- NonLazyBindAttribute = 2147483648 ,
62+ ZExtAttribute = 1 << 0 ,
63+ SExtAttribute = 1 << 1 ,
64+ NoReturnAttribute = 1 << 2 ,
65+ InRegAttribute = 1 << 3 ,
66+ StructRetAttribute = 1 << 4 ,
67+ NoUnwindAttribute = 1 << 5 ,
68+ NoAliasAttribute = 1 << 6 ,
69+ ByValAttribute = 1 << 7 ,
70+ NestAttribute = 1 << 8 ,
71+ ReadNoneAttribute = 1 << 9 ,
72+ ReadOnlyAttribute = 1 << 10 ,
73+ NoInlineAttribute = 1 << 11 ,
74+ AlwaysInlineAttribute = 1 << 12 ,
75+ OptimizeForSizeAttribute = 1 << 13 ,
76+ StackProtectAttribute = 1 << 14 ,
77+ StackProtectReqAttribute = 1 << 15 ,
78+ AlignmentAttribute = 31 << 16 ,
79+ NoCaptureAttribute = 1 << 21 ,
80+ NoRedZoneAttribute = 1 << 22 ,
81+ NoImplicitFloatAttribute = 1 << 23 ,
82+ NakedAttribute = 1 << 24 ,
83+ InlineHintAttribute = 1 << 25 ,
84+ StackAttribute = 7 << 26 ,
85+ ReturnsTwiceAttribute = 1 << 29 ,
86+ UWTableAttribute = 1 << 30 ,
87+ NonLazyBindAttribute = 1 << 31 ,
88+
89+ // Not added to LLVM yet, so may need to stay updated if LLVM changes.
90+ FixedStackSegment = 1 << 41 ,
9191}
9292
9393// enum for the LLVM IntPredicate type
@@ -274,9 +274,7 @@ pub mod llvm {
274274 #[ abi = "cdecl" ]
275275 pub extern {
276276 /* Create and destroy contexts. */
277- #[ fast_ffi]
278277 pub unsafe fn LLVMContextCreate ( ) -> ContextRef ;
279- #[ fast_ffi]
280278 pub unsafe fn LLVMContextDispose ( C : ContextRef ) ;
281279 #[ fast_ffi]
282280 pub unsafe fn LLVMGetMDKindIDInContext ( C : ContextRef ,
@@ -285,13 +283,11 @@ pub mod llvm {
285283 -> c_uint ;
286284
287285 /* Create and destroy modules. */
288- #[ fast_ffi]
289286 pub unsafe fn LLVMModuleCreateWithNameInContext ( ModuleID : * c_char ,
290287 C : ContextRef )
291288 -> ModuleRef ;
292289 #[ fast_ffi]
293290 pub unsafe fn LLVMGetModuleContext ( M : ModuleRef ) -> ContextRef ;
294- #[ fast_ffi]
295291 pub unsafe fn LLVMDisposeModule ( M : ModuleRef ) ;
296292
297293 /** Data layout. See Module::getDataLayout. */
@@ -307,7 +303,6 @@ pub mod llvm {
307303 pub unsafe fn LLVMSetTarget ( M : ModuleRef , Triple : * c_char ) ;
308304
309305 /** See Module::dump. */
310- #[ fast_ffi]
311306 pub unsafe fn LLVMDumpModule ( M : ModuleRef ) ;
312307
313308 /** See Module::setModuleInlineAsm. */
@@ -1589,15 +1584,15 @@ pub mod llvm {
15891584 Op : AtomicBinOp ,
15901585 LHS : ValueRef ,
15911586 RHS : ValueRef ,
1592- Order : AtomicOrdering )
1587+ Order : AtomicOrdering ,
1588+ SingleThreaded : Bool )
15931589 -> ValueRef ;
15941590
15951591 /* Selected entries from the downcasts. */
15961592 #[ fast_ffi]
15971593 pub unsafe fn LLVMIsATerminatorInst ( Inst : ValueRef ) -> ValueRef ;
15981594
15991595 /** Writes a module to the specified path. Returns 0 on success. */
1600- #[ fast_ffi]
16011596 pub unsafe fn LLVMWriteBitcodeToFile ( M : ModuleRef ,
16021597 Path : * c_char ) -> c_int ;
16031598
@@ -1647,40 +1642,30 @@ pub mod llvm {
16471642 pub unsafe fn LLVMDisposeTargetData ( TD : TargetDataRef ) ;
16481643
16491644 /** Creates a pass manager. */
1650- #[ fast_ffi]
16511645 pub unsafe fn LLVMCreatePassManager ( ) -> PassManagerRef ;
16521646 /** Creates a function-by-function pass manager */
1653- #[ fast_ffi]
16541647 pub unsafe fn LLVMCreateFunctionPassManagerForModule ( M : ModuleRef ) -> PassManagerRef ;
16551648
16561649 /** Disposes a pass manager. */
1657- #[ fast_ffi]
16581650 pub unsafe fn LLVMDisposePassManager ( PM : PassManagerRef ) ;
16591651
16601652 /** Runs a pass manager on a module. */
1661- #[ fast_ffi]
16621653 pub unsafe fn LLVMRunPassManager ( PM : PassManagerRef ,
16631654 M : ModuleRef ) -> Bool ;
16641655
16651656 /** Runs the function passes on the provided function. */
1666- #[ fast_ffi]
16671657 pub unsafe fn LLVMRunFunctionPassManager ( FPM : PassManagerRef , F : ValueRef ) -> Bool ;
16681658
16691659 /** Initializes all the function passes scheduled in the manager */
1670- #[ fast_ffi]
16711660 pub unsafe fn LLVMInitializeFunctionPassManager ( FPM : PassManagerRef ) -> Bool ;
16721661
16731662 /** Finalizes all the function passes scheduled in the manager */
1674- #[ fast_ffi]
16751663 pub unsafe fn LLVMFinalizeFunctionPassManager ( FPM : PassManagerRef ) -> Bool ;
16761664
1677- #[ fast_ffi]
16781665 pub unsafe fn LLVMInitializePasses ( ) ;
16791666
1680- #[ fast_ffi]
16811667 pub unsafe fn LLVMAddPass ( PM : PassManagerRef , P : PassRef ) ;
16821668
1683- #[ fast_ffi]
16841669 pub unsafe fn LLVMCreatePass ( PassName : * c_char ) -> PassRef ;
16851670
16861671 #[ fast_ffi]
@@ -1762,9 +1747,7 @@ pub mod llvm {
17621747 #[ fast_ffi]
17631748 pub unsafe fn LLVMAddBasicAliasAnalysisPass ( PM : PassManagerRef ) ;
17641749
1765- #[ fast_ffi]
17661750 pub unsafe fn LLVMPassManagerBuilderCreate ( ) -> PassManagerBuilderRef ;
1767- #[ fast_ffi]
17681751 pub unsafe fn LLVMPassManagerBuilderDispose ( PMB :
17691752 PassManagerBuilderRef ) ;
17701753 #[ fast_ffi]
@@ -1801,19 +1784,17 @@ pub mod llvm {
18011784 /* Stuff that's in rustllvm/ because it's not upstream yet. */
18021785
18031786 /** Opens an object file. */
1804- #[ fast_ffi]
18051787 pub unsafe fn LLVMCreateObjectFile ( MemBuf : MemoryBufferRef )
18061788 -> ObjectFileRef ;
18071789 /** Closes an object file. */
1808- #[ fast_ffi]
18091790 pub unsafe fn LLVMDisposeObjectFile ( ObjFile : ObjectFileRef ) ;
18101791
18111792 /** Enumerates the sections in an object file. */
18121793 #[ fast_ffi]
18131794 pub unsafe fn LLVMGetSections ( ObjFile : ObjectFileRef )
18141795 -> SectionIteratorRef ;
18151796 /** Destroys a section iterator. */
1816- # [ fast_ffi ]
1797+
18171798 pub unsafe fn LLVMDisposeSectionIterator ( SI : SectionIteratorRef ) ;
18181799 /** Returns true if the section iterator is at the end of the section
18191800 list: */
@@ -1842,7 +1823,6 @@ pub mod llvm {
18421823 Path : * c_char )
18431824 -> MemoryBufferRef ;
18441825
1845- #[ fast_ffi]
18461826 pub unsafe fn LLVMRustWriteOutputFile ( PM : PassManagerRef ,
18471827 M : ModuleRef ,
18481828 Triple : * c_char ,
@@ -1893,11 +1873,9 @@ pub mod llvm {
18931873 Output : * c_char ) ;
18941874
18951875 /** Turn on LLVM pass-timing. */
1896- #[ fast_ffi]
18971876 pub unsafe fn LLVMRustEnableTimePasses ( ) ;
18981877
18991878 /// Print the pass timings since static dtors aren't picking them up.
1900- #[ fast_ffi]
19011879 pub unsafe fn LLVMRustPrintPassTimings ( ) ;
19021880
19031881 #[ fast_ffi]
@@ -2117,6 +2095,15 @@ pub fn ConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
21172095 llvm:: LLVMConstFCmp ( Pred as c_ushort , V1 , V2 )
21182096 }
21192097}
2098+
2099+ pub fn SetFunctionAttribute ( Fn : ValueRef , attr : Attribute ) {
2100+ unsafe {
2101+ let attr = attr as u64 ;
2102+ let lower = attr & 0xffffffff ;
2103+ let upper = ( attr >> 32 ) & 0xffffffff ;
2104+ llvm:: LLVMAddFunctionAttr ( Fn , lower as c_uint , upper as c_uint ) ;
2105+ }
2106+ }
21202107/* Memory-managed object interface to type handles. */
21212108
21222109pub struct TypeNames {
0 commit comments