This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add new INSN_* into mips.h


2008/12/25 Eric Fisher <joefoxreal@gmail.com>:
> Hello,
>
> I notice that MIPS port uses bit masks for specific CPUs, from
>
>  #define INSN_DSP  0x00001000
>
> to
>
>  #define INSN_LOONGSON_2F  0x80000000
>
> The problem is what I should do if I attempt to add a new INSN_* for a
> specific CPU. Seems there're no available value to use.
>

Hi,

I have two solutions for this problem. One is to add a new field
"membership2" into struct mips_opcode, just like what "pinfo2" does.

Another way is to change the "membership" field from bit collection to
a function address. So mips_builtin_opcodes will look like this,

/* name,    args,       match,      mask,           pinfo,
     pinfo2,               is_member_of */
{"pref",    "k,o(b)",   0xcc000000, 0xfc000000, RD_b,
 0,                   membership_pref_1 },
{"prefx",   "h,t(b)",   0x4c00000f,  0xfc0007ff,   RD_b|RD_t,
 0,                   membership_prefx_1 },
{"nop",     "",          0x00000000, 0xffffffff,        0,
         INSN2_ALIAS,    membership_nop_1 }, /* sll */
{"ssnop",  "",         0x00000040,  0xffffffff,        0,
       INSN2_ALIAS,    membership_ssnop_1}, /* sll */

Then, I would like to generate these membership_* test functions
automatically according to the original descriptions like this

/* name,    args,       match,      mask,           pinfo,
     pinfo2,               is_member_of */
{"pref",    "k,o(b)",   0xcc000000, 0xfc000000, RD_b,
 0,                   "ISA(I4_32|G3)" },
{"prefx",   "h,t(b)",   0x4c00000f,  0xfc0007ff,   RD_b|RD_t,
 0,                   "ISA(I4_33)"    },
{"nop",     "",          0x00000000, 0xffffffff,        0,
         INSN2_ALIAS,    "ISA(I1)"       }, /* sll */
{"ssnop",  "",         0x00000040,  0xffffffff,        0,
       INSN2_ALIAS,    "ISA(I32) || INSN_5500"}, /* sll */

Just like a predication. Keep the isa INSN_* as bitmask, so

#define ISA(isa)
         \
    ((mips_isa & INSN_ISA_MASK) != 0                                        \
      && (isa & INSN_ISA_MASK) != 0                      \
      && ((mips_isa_table [(mips_isa & INSN_ISA_MASK) - 1] >>                \
           ((isa & INSN_ISA_MASK) - 1)) & 1) != 0)

change the cpu INSN_* defination as

#define INSN_5500 (mips_cpu == CPU_VR5500)

Then, the test function will be

static inline int
membership_ssnop_1 (void)
{
  return (ISA (I32) || INSN_5500);
}

Ah, how about it? Any suggestions?

Eric Fisher
Dec 30, 2008


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]