This patch adds support for recognizing patterns to match DINS instruction. It replaces set of instructions with DINS instruction and one more instruction (add instruction or shift right depending of case).
Example:
#include <stdint.h>
struct buf_str {
struct { unsigned long long addr :37; unsigned long long addr1 :15; unsigned int length:14; uint64_t total_bytes:16; uint64_t segs : 6; } s;
};
void foo(volatile struct buf_str bufptr) {
bufptr.s.segs = 4;
}
Output (objdump) without patch:
Disassembly of section .text:
0000000000000000 <foo>:
0: 67bdfff0 daddiu sp,sp,-16 4: ffa50008 sd a1,8(sp) 8: 64010001 daddiu at,zero,1 c: 0001093c dsll32 at,at,0x4 10: 6421ffc1 daddiu at,at,-63 14: 00010f38 dsll at,at,0x1c 18: 6421ffff daddiu at,at,-1 1c: dfa20008 ld v0,8(sp) 20: 00410824 and at,v0,at 24: 3c024000 lui v0,0x4000 28: 00220825 or at,at,v0 2c: ffa10008 sd at,8(sp) 30: 03e00008 jr ra 34: 67bd0010 daddiu sp,sp,16
Output (objdump) with patch:
Disassembly of section .text:
0000000000000000 <foo>:
0: 67bdfff0 daddiu sp,sp,-16 4: ffa50008 sd a1,8(sp) 8: 64010004 daddiu at,zero,4 c: dfa20008 ld v0,8(sp) 10: 7c220f05 dins v0,at,0x1c,0x6 14: ffa20008 sd v0,8(sp) 18: 03e00008 jr ra 1c: 67bd0010 daddiu sp,sp,16