Skip to content

Commit d96167f

Browse files
committed
Implement ppc/ppc64 preserves_flags option for inline asm
Implemented preserves_flags on powerpc by making it do nothing. This prevents having two different ways to mark `cr0` as clobbered. clang and gcc alias `cr0` to `cc`. The gcc inline documentation does not state what this does on powerpc* targets, but inspection of the source shows it is equivalent to condition register field `cr0`, so it should not be added.
1 parent 2064793 commit d96167f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/asm.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,16 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
546546
}
547547

548548
if !options.contains(InlineAsmOptions::PRESERVES_FLAGS) {
549-
// TODO(@Commeownist): I'm not 100% sure this one clobber is sufficient
550-
// on all architectures. For instance, what about FP stack?
551-
extended_asm.add_clobber("cc");
549+
match asm_arch {
550+
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => {
551+
// "cc" is cr0 on powerpc.
552+
}
553+
// TODO(@Commeownist): I'm not 100% sure this one clobber is sufficient
554+
// on all architectures. For instance, what about FP stack?
555+
_ => {
556+
extended_asm.add_clobber("cc");
557+
}
558+
}
552559
}
553560
if !options.contains(InlineAsmOptions::NOMEM) {
554561
extended_asm.add_clobber("memory");

0 commit comments

Comments
 (0)