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/inline-assembly.md
+75-1Lines changed: 75 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,8 @@ Currently, all supported targets follow the assembly code syntax used by LLVM's
86
86
On x86, the `.intel_syntax noprefix` mode of GAS is used by default.
87
87
On ARM, the `.syntax unified` mode is used.
88
88
These targets impose an additional restriction on the assembly code: any assembler state (e.g. the current section which can be changed with `.section`) must be restored to its original value at the end of the asm string.
89
-
Assembly code that does not conform to the GAS syntax will result in assembler-specific behavior.
89
+
Assembly code that does not conform to the GAS syntax will result in assembler-specific behavior.
90
+
Further constraints on the directives used by the assembly are indicated by [Directives Support](#directives-support).
@@ -477,3 +478,76 @@ To avoid undefined behavior, these rules must be followed when using function-sc
477
478
- The compiler is currently unable to detect this due to the way inline assembly is compiled, but may catch and reject this in the future.
478
479
479
480
> **Note**: As a general rule, the flags covered by `preserves_flags` are those which are *not* preserved when performing a function call.
481
+
482
+
### Directives Support
483
+
484
+
Inline ASM supports a subset of the directives supported by both GNU AS and LLVM's internal assembler, given as follows.
485
+
The result of using other directives is assembler-specific (and may cause an error, or may be accepted as-is).
486
+
487
+
The following directives are guaranteed to be supported by the assembler:
488
+
489
+
```as
490
+
.2byte
491
+
.4byte
492
+
.8byte
493
+
.byte
494
+
.word
495
+
.long
496
+
.quad
497
+
.float
498
+
.double
499
+
.octa
500
+
.sleb128
501
+
.uleb128
502
+
.ascii
503
+
.asciz
504
+
.string
505
+
.skip
506
+
.space
507
+
.balign
508
+
.balignl
509
+
.balignw
510
+
.balign
511
+
.balignl
512
+
.balignw
513
+
.section
514
+
.pushsection
515
+
.popsection
516
+
.text
517
+
.bss
518
+
.data
519
+
.cfi_adjust_cfa_offset
520
+
.cfi_def_cfa
521
+
.cfi_def_cfa_offset
522
+
.cfi_def_cfa_register
523
+
.cfi_endproc
524
+
.cfi_escape
525
+
.cfi_lsda
526
+
.cfi_offset
527
+
.cfi_personality
528
+
.cfi_register
529
+
.cfi_rel_offset
530
+
.cfi_remember_state
531
+
.cfi_restore
532
+
.cfi_restore_state
533
+
.cfi_return_column
534
+
.cfi_same_value
535
+
.cfi_sections
536
+
.cfi_signal_frame
537
+
.cfi_startproc
538
+
.cfi_undefined
539
+
.cfi_window_save
540
+
.comm
541
+
.lcomm
542
+
```
543
+
544
+
On x86, the following additional directives are guaranteed to be supported:
545
+
```as
546
+
.nops
547
+
```
548
+
549
+
On x86 for `global_asm!` only, the following additional directives are guaranteed to be supported (it is unspecified whether `.code16` or `.code32` are supported for `asm!()`):
0 commit comments