1
Fork 0

Mark condition/carry bit as clobbered in C-SKY inline assembly

This commit is contained in:
Taiki Endo 2025-01-29 06:46:05 +09:00
parent fdd1a3b026
commit 93465e6c31
3 changed files with 29 additions and 1 deletions

View file

@ -286,7 +286,9 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
InlineAsmArch::M68k => {
constraints.push("~{ccr}".to_string());
}
InlineAsmArch::CSKY => {}
InlineAsmArch::CSKY => {
constraints.push("~{psr}".to_string());
}
}
}
if !options.contains(InlineAsmOptions::NOMEM) {

View file

@ -199,3 +199,5 @@ These flags registers must be restored upon exiting the asm block if the `preser
- SPARC
- Integer condition codes (`icc` and `xcc`)
- Floating-point condition codes (`fcc[0-3]`)
- CSKY
- Condition/carry bit (C) in `PSR`.

View file

@ -0,0 +1,24 @@
//@ add-core-stubs
//@ compile-flags: --target csky-unknown-linux-gnuabiv2
//@ needs-llvm-components: csky
#![crate_type = "rlib"]
#![feature(no_core, asm_experimental_arch)]
#![no_core]
extern crate minicore;
use minicore::*;
// CHECK-LABEL: @flags_clobber
// CHECK: call void asm sideeffect "", "~{psr}"()
#[no_mangle]
pub unsafe fn flags_clobber() {
asm!("", options(nostack, nomem));
}
// CHECK-LABEL: @no_clobber
// CHECK: call void asm sideeffect "", ""()
#[no_mangle]
pub unsafe fn no_clobber() {
asm!("", options(nostack, nomem, preserves_flags));
}