Skip to content

PowerPC64 inline assembly doesn't support clobbering xer and cr #88315

@programmerjake

Description

@programmerjake

I'm working on porting power-instruction-analyzer to use the new asm! macro instead of llvm_asm!, however I can't translate clobbers for xer and cr (which aren't included by not specifying preserve_flags).

llvm_asm! example (generated by a proc-macro, so excuse the naming):

llvm_asm!(
    "mfxer $0\n\
    and $0, $0, $2\n\
    or $0, $0, $3\n\
    mtxer $0\n\
    cmplw $4, $5\n\
    mfxer $0\n\
    mfcr $1"
    : "=&b"(xer_out), "=&b"(cr)
    : "b"(xer_mask_in), "b"(xer_in), "b"(ra), "b"(rb)
    : "xer", "cr"
);

attempted asm! translation:

asm!(
    "mfxer {0}",
    "and {0}, {0}, {2}",
    "or {0}, {0}, {3}",
    "mtxer {0}",
    "cmplw {4}, {5}",
    "mfxer {0}",
    "mfcr {1}",
    out(reg_nonzero) xer_out,
    out(reg_nonzero) cr,
    in(reg_nonzero) xer_mask_in,
    in(reg_nonzero) xer_in,
    in(reg_nonzero) ra,
    in(reg_nonzero) rb,
    out("xer") _,
    out("cr") _
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions