mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-20 04:11:32 +00:00
Infer #clobber memory and #clobber cc from the mnemonics directly
This commit is contained in:
@@ -403,6 +403,7 @@ struct lbAsmGenerate_amd64 : lbAsmGenerate {
|
||||
}
|
||||
}
|
||||
|
||||
bool memory_clobbered_already = false;
|
||||
// Pass 3: clobbers
|
||||
// Only the Scratch group. Unpinned register scratch was already emitted as an
|
||||
// output in Pass 1, so it is skipped here.
|
||||
@@ -427,12 +428,27 @@ struct lbAsmGenerate_amd64 : lbAsmGenerate {
|
||||
break;
|
||||
case AsmTemplateEntityDecl_Memory: // general memory clobber
|
||||
raw("~{memory}");
|
||||
memory_clobbered_already = true;
|
||||
break;
|
||||
default:
|
||||
GB_PANIC("asm: invalid scratch operand kind");
|
||||
}
|
||||
}
|
||||
|
||||
// Template-level clobbers derived from #clobber cc / #clobber memory.
|
||||
if (tmpl_entity->AsmTemplate.clobber_cc) {
|
||||
sep();
|
||||
if (build_context.metrics.arch == TargetArch_amd64) {
|
||||
raw("~{flags}"); // x86 EFLAGS condition codes
|
||||
} else {
|
||||
raw("~{cc}"); // AArch64 uses ~{cc}
|
||||
}
|
||||
}
|
||||
if (tmpl_entity->AsmTemplate.clobber_memory && memory_clobbered_already) {
|
||||
sep();
|
||||
raw("~{memory}");
|
||||
}
|
||||
|
||||
// Build the callee type
|
||||
// NOTE(bill): Even though the user has given a signature, this might not actually match what
|
||||
// LLVM requires it to be due to the scratch parameters and more, so many of the results might
|
||||
|
||||
Reference in New Issue
Block a user