[LLVMdev] SparcV9 casa instruction

Misha Brukman brukman at uiuc.edu
Fri Feb 25 15:13:08 PST 2005


On Fri, Feb 25, 2005 at 04:33:34PM -0600, Brent Monroe wrote:
> I need to implement the compare and swap instruction in the
> Sparc backend.  It has the form:
> 
> casa [reg]imm, reg, reg
> 
> I believe I have specified it correctly in SparcV9Instr.def:
> 
> I(CASAi, "casa", 4, -1, B12, true, 0, 1, SPARC_SINGLE,
> M_LOAD_FLAG|M_STORE_FLAG)
> 
> Is this correct?  And how do I specify the above syntax in
> SparcV9InstrInfo.td?

I don't have a V9 manual handy at the moment so I can't verify
correctness, but to add it to the InstrInfo.td, you need to encode the
binary format of the instruction such that given the 3 parameters, it's
possible for the JIT to emit the binary encoding for the instruction.

If you look in the instruction manual, each instruction has a "format"
which is F1, F2, F3 or F4, so your instruction needs to inherit from one
of those base classes and designate where its operands map in the
instruction.  Just pick an instruction in the same group and see how
it's encoded in the .td file, and follow the same format.

-- 
Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu




More information about the llvm-dev mailing list