@@ -59,35 +59,35 @@ pub enum Linkage {
59
59
}
60
60
61
61
pub 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 ,
91
91
}
92
92
93
93
// enum for the LLVM IntPredicate type
@@ -274,9 +274,7 @@ pub mod llvm {
274
274
#[ abi = "cdecl" ]
275
275
pub extern {
276
276
/* Create and destroy contexts. */
277
- #[ fast_ffi]
278
277
pub unsafe fn LLVMContextCreate ( ) -> ContextRef ;
279
- #[ fast_ffi]
280
278
pub unsafe fn LLVMContextDispose ( C : ContextRef ) ;
281
279
#[ fast_ffi]
282
280
pub unsafe fn LLVMGetMDKindIDInContext ( C : ContextRef ,
@@ -285,13 +283,11 @@ pub mod llvm {
285
283
-> c_uint ;
286
284
287
285
/* Create and destroy modules. */
288
- #[ fast_ffi]
289
286
pub unsafe fn LLVMModuleCreateWithNameInContext ( ModuleID : * c_char ,
290
287
C : ContextRef )
291
288
-> ModuleRef ;
292
289
#[ fast_ffi]
293
290
pub unsafe fn LLVMGetModuleContext ( M : ModuleRef ) -> ContextRef ;
294
- #[ fast_ffi]
295
291
pub unsafe fn LLVMDisposeModule ( M : ModuleRef ) ;
296
292
297
293
/** Data layout. See Module::getDataLayout. */
@@ -307,7 +303,6 @@ pub mod llvm {
307
303
pub unsafe fn LLVMSetTarget ( M : ModuleRef , Triple : * c_char ) ;
308
304
309
305
/** See Module::dump. */
310
- #[ fast_ffi]
311
306
pub unsafe fn LLVMDumpModule ( M : ModuleRef ) ;
312
307
313
308
/** See Module::setModuleInlineAsm. */
@@ -1589,15 +1584,15 @@ pub mod llvm {
1589
1584
Op : AtomicBinOp ,
1590
1585
LHS : ValueRef ,
1591
1586
RHS : ValueRef ,
1592
- Order : AtomicOrdering )
1587
+ Order : AtomicOrdering ,
1588
+ SingleThreaded : Bool )
1593
1589
-> ValueRef ;
1594
1590
1595
1591
/* Selected entries from the downcasts. */
1596
1592
#[ fast_ffi]
1597
1593
pub unsafe fn LLVMIsATerminatorInst ( Inst : ValueRef ) -> ValueRef ;
1598
1594
1599
1595
/** Writes a module to the specified path. Returns 0 on success. */
1600
- #[ fast_ffi]
1601
1596
pub unsafe fn LLVMWriteBitcodeToFile ( M : ModuleRef ,
1602
1597
Path : * c_char ) -> c_int ;
1603
1598
@@ -1647,40 +1642,30 @@ pub mod llvm {
1647
1642
pub unsafe fn LLVMDisposeTargetData ( TD : TargetDataRef ) ;
1648
1643
1649
1644
/** Creates a pass manager. */
1650
- #[ fast_ffi]
1651
1645
pub unsafe fn LLVMCreatePassManager ( ) -> PassManagerRef ;
1652
1646
/** Creates a function-by-function pass manager */
1653
- #[ fast_ffi]
1654
1647
pub unsafe fn LLVMCreateFunctionPassManagerForModule ( M : ModuleRef ) -> PassManagerRef ;
1655
1648
1656
1649
/** Disposes a pass manager. */
1657
- #[ fast_ffi]
1658
1650
pub unsafe fn LLVMDisposePassManager ( PM : PassManagerRef ) ;
1659
1651
1660
1652
/** Runs a pass manager on a module. */
1661
- #[ fast_ffi]
1662
1653
pub unsafe fn LLVMRunPassManager ( PM : PassManagerRef ,
1663
1654
M : ModuleRef ) -> Bool ;
1664
1655
1665
1656
/** Runs the function passes on the provided function. */
1666
- #[ fast_ffi]
1667
1657
pub unsafe fn LLVMRunFunctionPassManager ( FPM : PassManagerRef , F : ValueRef ) -> Bool ;
1668
1658
1669
1659
/** Initializes all the function passes scheduled in the manager */
1670
- #[ fast_ffi]
1671
1660
pub unsafe fn LLVMInitializeFunctionPassManager ( FPM : PassManagerRef ) -> Bool ;
1672
1661
1673
1662
/** Finalizes all the function passes scheduled in the manager */
1674
- #[ fast_ffi]
1675
1663
pub unsafe fn LLVMFinalizeFunctionPassManager ( FPM : PassManagerRef ) -> Bool ;
1676
1664
1677
- #[ fast_ffi]
1678
1665
pub unsafe fn LLVMInitializePasses ( ) ;
1679
1666
1680
- #[ fast_ffi]
1681
1667
pub unsafe fn LLVMAddPass ( PM : PassManagerRef , P : PassRef ) ;
1682
1668
1683
- #[ fast_ffi]
1684
1669
pub unsafe fn LLVMCreatePass ( PassName : * c_char ) -> PassRef ;
1685
1670
1686
1671
#[ fast_ffi]
@@ -1762,9 +1747,7 @@ pub mod llvm {
1762
1747
#[ fast_ffi]
1763
1748
pub unsafe fn LLVMAddBasicAliasAnalysisPass ( PM : PassManagerRef ) ;
1764
1749
1765
- #[ fast_ffi]
1766
1750
pub unsafe fn LLVMPassManagerBuilderCreate ( ) -> PassManagerBuilderRef ;
1767
- #[ fast_ffi]
1768
1751
pub unsafe fn LLVMPassManagerBuilderDispose ( PMB :
1769
1752
PassManagerBuilderRef ) ;
1770
1753
#[ fast_ffi]
@@ -1801,19 +1784,17 @@ pub mod llvm {
1801
1784
/* Stuff that's in rustllvm/ because it's not upstream yet. */
1802
1785
1803
1786
/** Opens an object file. */
1804
- #[ fast_ffi]
1805
1787
pub unsafe fn LLVMCreateObjectFile ( MemBuf : MemoryBufferRef )
1806
1788
-> ObjectFileRef ;
1807
1789
/** Closes an object file. */
1808
- #[ fast_ffi]
1809
1790
pub unsafe fn LLVMDisposeObjectFile ( ObjFile : ObjectFileRef ) ;
1810
1791
1811
1792
/** Enumerates the sections in an object file. */
1812
1793
#[ fast_ffi]
1813
1794
pub unsafe fn LLVMGetSections ( ObjFile : ObjectFileRef )
1814
1795
-> SectionIteratorRef ;
1815
1796
/** Destroys a section iterator. */
1816
- # [ fast_ffi ]
1797
+
1817
1798
pub unsafe fn LLVMDisposeSectionIterator ( SI : SectionIteratorRef ) ;
1818
1799
/** Returns true if the section iterator is at the end of the section
1819
1800
list: */
@@ -1842,7 +1823,6 @@ pub mod llvm {
1842
1823
Path : * c_char )
1843
1824
-> MemoryBufferRef ;
1844
1825
1845
- #[ fast_ffi]
1846
1826
pub unsafe fn LLVMRustWriteOutputFile ( PM : PassManagerRef ,
1847
1827
M : ModuleRef ,
1848
1828
Triple : * c_char ,
@@ -1893,11 +1873,9 @@ pub mod llvm {
1893
1873
Output : * c_char ) ;
1894
1874
1895
1875
/** Turn on LLVM pass-timing. */
1896
- #[ fast_ffi]
1897
1876
pub unsafe fn LLVMRustEnableTimePasses ( ) ;
1898
1877
1899
1878
/// Print the pass timings since static dtors aren't picking them up.
1900
- #[ fast_ffi]
1901
1879
pub unsafe fn LLVMRustPrintPassTimings ( ) ;
1902
1880
1903
1881
#[ fast_ffi]
@@ -2117,6 +2095,15 @@ pub fn ConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
2117
2095
llvm:: LLVMConstFCmp ( Pred as c_ushort , V1 , V2 )
2118
2096
}
2119
2097
}
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
+ }
2120
2107
/* Memory-managed object interface to type handles. */
2121
2108
2122
2109
pub struct TypeNames {
0 commit comments