I have tried to add the LEON CASArr instruction as part of a Sparc Subtarget to the Sparc instructions. Almost all the tests I've written have worked without problem, but when I try to encode the instruction, it doesn't work.
I modelled it on the CASrr instruction which it basically mimics in every regard except the ASI.
// The CAS instruction, unlike other instructions, only comes in a
// form which requires an ASI be provided. The ASI value hardcoded
// here is ASI_PRIMARY, the default unprivileged ASI for SparcV9.
let Predicates = [HasV9], Constraints = "$swap = $rd", asi = 0b10000000 in
leon-atomic-instructions.s:4:15: error: invalid operand for instruction
casa [%i0], %l6, %o2
The only operative line in leon-atomic-instructions is the one that throws the error.
gr712rc is the name of the CPU I've added, which switches on the "CASASupported" feature that you can see in the instruction definition above. All this part of the system works, so it's almost
certainly nothing there - plus I've performed many tests to verify this.
I've also run the pre-existing test in test/MC/Sparc: llvm-mc sparcv9-atomic-instructions -arch=sparc -show-encoding. This works fine and I don't get any such error ("invalid operand for instruction") on
"cas [%i0], %l6, %o2".
Can anyone explain why I get a difference between the two and what I need to change?