Skip to content

Commit 2f46122

Browse files
committed
Mark RISC-V vector state as clobbered in inline assembly
1 parent e9fb7ba commit 2f46122

File tree

2 files changed

+9
-1
lines changed
  • compiler/rustc_codegen_llvm/src
  • src/doc/unstable-book/src/library-features

2 files changed

+9
-1
lines changed

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,14 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
302302
"~{flags}".to_string(),
303303
]);
304304
}
305-
InlineAsmArch::RiscV32 | InlineAsmArch::RiscV64 => {}
305+
InlineAsmArch::RiscV32 | InlineAsmArch::RiscV64 => {
306+
constraints.extend_from_slice(&[
307+
"~{vtype}".to_string(),
308+
"~{vl}".to_string(),
309+
"~{vxsat}".to_string(),
310+
"~{vxrm}".to_string(),
311+
]);
312+
}
306313
InlineAsmArch::Nvptx64 => {}
307314
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => {}
308315
InlineAsmArch::Hexagon => {}

src/doc/unstable-book/src/library-features/asm.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ The compiler performs some additional checks on options:
842842
- Floating-point status (`FPSR` register).
843843
- RISC-V
844844
- Floating-point exception flags in `fcsr` (`fflags`).
845+
- Vector extension state (`vtype`, `vl`, `vcsr`).
845846
- On x86, the direction flag (DF in `EFLAGS`) is clear on entry to an asm block and must be clear on exit.
846847
- Behavior is undefined if the direction flag is set on exiting an asm block.
847848
- The requirement of restoring the stack pointer and non-output registers to their original value only applies when exiting an `asm!` block.

0 commit comments

Comments
 (0)