2 Jan 2012 10:44
Encoding of immediates different to label addresses
Julius Baxter <juliusbaxter <at> gmail.com>
2012-01-02 09:44:16 GMT
2012-01-02 09:44:16 GMT
Hi, I'm working on fixing up the OpenRISC 1000 CGEN port and have come across something I find I can't quite do with CGEN. For the jump and branch instructions, if we use immediate value number specified in the assembly, we need that encoded into the instruction without any shifting occurring to it. Eg. "l.bf 1" should become 0x10000001, "l.bf 4" should become 0x10000004 etc. These target addresses are shifted-left by two during decoding, and so "l.bf 1" is actually a branch of 4 bytes. If we use a label for an address, though, I'm seeing that we're getting the offset in bytes during encoding, which then needs to be shifted right by two before being put in the instruction. But it seems we can have the shifting on both numerical immediates and labels, or neither. (Pardon my incorrect use of terminology, I have a feeling I'm not quite calling everything its right name!) Upon inspecttion, it looks like the binutils port we have been using for the past few years (not CGEN-based) has a right-shift of 2 in the md_apply_fix() function in binutils/gas/config/tc-or32.c ( http://sourceware.org/git/?p=binutils.git;a=blob;f=gas/config/tc-or32.c;h=7234fb837e006f979c255f62206e39a9822046d2;hb=HEAD#l603 ) when the instruction had the actual value of the label inserted into it. Is there any way to handle this using the CGEN description?(Continue reading)
RSS Feed