1
Fork 0

Add clobber-only register classes for asm!

These are needed to properly express a function call ABI using a clobber
list, even though we don't support passing actual values into/out of
these registers.
This commit is contained in:
Amanieu d'Antras 2021-06-17 21:00:52 +01:00
parent 1e13a9bb33
commit e1c3f5e017
11 changed files with 241 additions and 30 deletions

View file

@ -199,6 +199,22 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
);
// Some register classes can only be used as clobbers. This
// means that we disallow passing a value in/out of the asm and
// require that the operand name an explicit register, not a
// register class.
if reg_class.is_clobber_only(asm_arch.unwrap())
&& !(is_clobber && matches!(reg, asm::InlineAsmRegOrRegClass::Reg(_)))
{
let msg = format!(
"register class `{}` can only be used as a clobber, \
not as an input or output",
reg_class.name()
);
sess.struct_span_err(op_sp, &msg).emit();
continue;
}
if !is_clobber {
// Validate register classes against currently enabled target
// features. We check that at least one type is available for