You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/attributes/codegen.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -668,3 +668,26 @@ Using the `instruction_set` attribute has the following effects:
668
668
669
669
* If the address of the function is taken as a function pointer, the low bit of the address will be set to 0 (arm) or 1 (thumb) depending on the instruction set.
670
670
* Any inline assembly in the function must use the specified instruction set instead of the target default.
671
+
672
+
r[attributes.codegen.align]
673
+
## The `align` attribute
674
+
675
+
r[attributes.codegen.align.allowed-positions]
676
+
The *`align`[attribute]* may be applied to function items.
677
+
678
+
r[attributes.codegen.align.behavior]
679
+
This attribute raises the aligmnent of a function's generated code.
680
+
681
+
```rust
682
+
#[align(32)]
683
+
fnaligned_to_32_bytes() {}
684
+
```
685
+
686
+
> [!NOTE]
687
+
> Some targets use pointer tagging on function pointers. Consequently, on those targets, a function's address may not be a multiple of its alignment.
688
+
689
+
r[attributes.codegen.align.minimum]
690
+
The alignment value that is specified is a minimum. The actual alignment may be higher.
691
+
692
+
r[attributes.codegen.align.syntax]
693
+
The alignment is specified as an integer parameter in the form of `#[align(x)]`. The alignment value must be a power of two from 1 up to 2<sup>29</sup>.
0 commit comments