@@ -59,35 +59,37 @@ pub enum Linkage {
5959
6060#[ deriving( Clone ) ]
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+ // FIXME(#8199): if this changes, be sure to change the relevant constant
91+ // down below
92+ // FixedStackSegment = 1 << 41,
9193}
9294
9395// enum for the LLVM IntPredicate type
@@ -1541,7 +1543,8 @@ pub mod llvm {
15411543 Op : AtomicBinOp ,
15421544 LHS : ValueRef ,
15431545 RHS : ValueRef ,
1544- Order : AtomicOrdering )
1546+ Order : AtomicOrdering ,
1547+ SingleThreaded : Bool )
15451548 -> ValueRef ;
15461549
15471550 pub fn LLVMBuildAtomicFence ( B : BuilderRef , Order : AtomicOrdering ) ;
@@ -2106,6 +2109,28 @@ pub fn ConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
21062109 llvm:: LLVMConstFCmp ( Pred as c_ushort , V1 , V2 )
21072110 }
21082111}
2112+
2113+ pub fn SetFunctionAttribute ( Fn : ValueRef , attr : Attribute ) {
2114+ unsafe {
2115+ let attr = attr as u64 ;
2116+ let lower = attr & 0xffffffff ;
2117+ let upper = ( attr >> 32 ) & 0xffffffff ;
2118+ llvm:: LLVMAddFunctionAttr ( Fn , lower as c_uint , upper as c_uint ) ;
2119+ }
2120+ }
2121+
2122+ // FIXME(#8199): this shouldn't require this hackery. On i686
2123+ // (FixedStackSegment as u64) will return 0 instead of 1 << 41.
2124+ // Furthermore, if we use a match of any sort then an LLVM
2125+ // assertion is generated!
2126+ pub fn SetFixedStackSegmentAttribute ( Fn : ValueRef ) {
2127+ unsafe {
2128+ let attr = 1u64 << 41 ;
2129+ let lower = attr & 0xffffffff ;
2130+ let upper = ( attr >> 32 ) & 0xffffffff ;
2131+ llvm:: LLVMAddFunctionAttr ( Fn , lower as c_uint , upper as c_uint ) ;
2132+ }
2133+ }
21092134/* Memory-managed object interface to type handles. */
21102135
21112136pub struct TypeNames {
0 commit comments