Commit 85dfaf08 authored by Ralf Baechle's avatar Ralf Baechle

MIPS: inst.h: Eleminate per endianess structure definitions.

This makes space for further growth of the header without excessive bloat.
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 90e8cacd
...@@ -196,154 +196,100 @@ enum lx_func { ...@@ -196,154 +196,100 @@ enum lx_func {
* Damn ... bitfields depend from byteorder :-( * Damn ... bitfields depend from byteorder :-(
*/ */
#ifdef __MIPSEB__ #ifdef __MIPSEB__
struct j_format { /* Jump format */ #define BITFIELD_FIELD(field, more) \
unsigned int opcode : 6; field; \
unsigned int target : 26; more
};
struct i_format { /* Immediate format (addi, lw, ...) */
unsigned int opcode : 6;
unsigned int rs : 5;
unsigned int rt : 5;
signed int simmediate : 16;
};
struct u_format { /* Unsigned immediate format (ori, xori, ...) */
unsigned int opcode : 6;
unsigned int rs : 5;
unsigned int rt : 5;
unsigned int uimmediate : 16;
};
struct c_format { /* Cache (>= R6000) format */
unsigned int opcode : 6;
unsigned int rs : 5;
unsigned int c_op : 3;
unsigned int cache : 2;
unsigned int simmediate : 16;
};
struct r_format { /* Register format */
unsigned int opcode : 6;
unsigned int rs : 5;
unsigned int rt : 5;
unsigned int rd : 5;
unsigned int re : 5;
unsigned int func : 6;
};
struct p_format { /* Performance counter format (R10000) */
unsigned int opcode : 6;
unsigned int rs : 5;
unsigned int rt : 5;
unsigned int rd : 5;
unsigned int re : 5;
unsigned int func : 6;
};
struct f_format { /* FPU register format */
unsigned int opcode : 6;
unsigned int : 1;
unsigned int fmt : 4;
unsigned int rt : 5;
unsigned int rd : 5;
unsigned int re : 5;
unsigned int func : 6;
};
struct ma_format { /* FPU multiply and add format (MIPS IV) */ #elif defined(__MIPSEL__)
unsigned int opcode : 6;
unsigned int fr : 5;
unsigned int ft : 5;
unsigned int fs : 5;
unsigned int fd : 5;
unsigned int func : 4;
unsigned int fmt : 2;
};
struct b_format { /* BREAK and SYSCALL */ #define BITFIELD_FIELD(field, more) \
unsigned int opcode:6; more \
unsigned int code:20; field;
unsigned int func:6;
};
#elif defined(__MIPSEL__) #else /* !defined (__MIPSEB__) && !defined (__MIPSEL__) */
#error "MIPS but neither __MIPSEL__ nor __MIPSEB__?"
#endif
struct j_format { /* Jump format */ struct j_format {
unsigned int target : 26; BITFIELD_FIELD(unsigned int opcode : 6, /* Jump format */
unsigned int opcode : 6; BITFIELD_FIELD(unsigned int target : 26,
;))
}; };
struct i_format { /* Immediate format */ struct i_format { /* signed immediate format */
signed int simmediate : 16; BITFIELD_FIELD(unsigned int opcode : 6,
unsigned int rt : 5; BITFIELD_FIELD(unsigned int rs : 5,
unsigned int rs : 5; BITFIELD_FIELD(unsigned int rt : 5,
unsigned int opcode : 6; BITFIELD_FIELD(signed int simmediate : 16,
;))))
}; };
struct u_format { /* Unsigned immediate format */ struct u_format { /* unsigned immediate format */
unsigned int uimmediate : 16; BITFIELD_FIELD(unsigned int opcode : 6,
unsigned int rt : 5; BITFIELD_FIELD(unsigned int rs : 5,
unsigned int rs : 5; BITFIELD_FIELD(unsigned int rt : 5,
unsigned int opcode : 6; BITFIELD_FIELD(unsigned int uimmediate : 16,
;))))
}; };
struct c_format { /* Cache (>= R6000) format */ struct c_format { /* Cache (>= R6000) format */
unsigned int simmediate : 16; BITFIELD_FIELD(unsigned int opcode : 6,
unsigned int cache : 2; BITFIELD_FIELD(unsigned int rs : 5,
unsigned int c_op : 3; BITFIELD_FIELD(unsigned int c_op : 3,
unsigned int rs : 5; BITFIELD_FIELD(unsigned int cache : 2,
unsigned int opcode : 6; BITFIELD_FIELD(unsigned int simmediate : 16,
;)))))
}; };
struct r_format { /* Register format */ struct r_format { /* Register format */
unsigned int func : 6; BITFIELD_FIELD(unsigned int opcode : 6,
unsigned int re : 5; BITFIELD_FIELD(unsigned int rs : 5,
unsigned int rd : 5; BITFIELD_FIELD(unsigned int rt : 5,
unsigned int rt : 5; BITFIELD_FIELD(unsigned int rd : 5,
unsigned int rs : 5; BITFIELD_FIELD(unsigned int re : 5,
unsigned int opcode : 6; BITFIELD_FIELD(unsigned int func : 6,
;))))))
}; };
struct p_format { /* Performance counter format (R10000) */ struct p_format { /* Performance counter format (R10000) */
unsigned int func : 6; BITFIELD_FIELD(unsigned int opcode : 6,
unsigned int re : 5; BITFIELD_FIELD(unsigned int rs : 5,
unsigned int rd : 5; BITFIELD_FIELD(unsigned int rt : 5,
unsigned int rt : 5; BITFIELD_FIELD(unsigned int rd : 5,
unsigned int rs : 5; BITFIELD_FIELD(unsigned int re : 5,
unsigned int opcode : 6; BITFIELD_FIELD(unsigned int func : 6,
;))))))
}; };
struct f_format { /* FPU register format */ struct f_format { /* FPU register format */
unsigned int func : 6; BITFIELD_FIELD(unsigned int opcode : 6,
unsigned int re : 5; BITFIELD_FIELD(unsigned int : 1,
unsigned int rd : 5; BITFIELD_FIELD(unsigned int fmt : 4,
unsigned int rt : 5; BITFIELD_FIELD(unsigned int rt : 5,
unsigned int fmt : 4; BITFIELD_FIELD(unsigned int rd : 5,
unsigned int : 1; BITFIELD_FIELD(unsigned int re : 5,
unsigned int opcode : 6; BITFIELD_FIELD(unsigned int func : 6,
;)))))))
}; };
struct ma_format { /* FPU multiply and add format (MIPS IV) */ struct ma_format { /* FPU multiply and add format (MIPS IV) */
unsigned int fmt : 2; BITFIELD_FIELD(unsigned int opcode : 6,
unsigned int func : 4; BITFIELD_FIELD(unsigned int fr : 5,
unsigned int fd : 5; BITFIELD_FIELD(unsigned int ft : 5,
unsigned int fs : 5; BITFIELD_FIELD(unsigned int fs : 5,
unsigned int ft : 5; BITFIELD_FIELD(unsigned int fd : 5,
unsigned int fr : 5; BITFIELD_FIELD(unsigned int func : 4,
unsigned int opcode : 6; BITFIELD_FIELD(unsigned int fmt : 2,
;)))))))
}; };
struct b_format { /* BREAK and SYSCALL */ struct b_format { /* BREAK and SYSCALL */
unsigned int func:6; BITFIELD_FIELD(unsigned int opcode : 6,
unsigned int code:20; BITFIELD_FIELD(unsigned int code : 20,
unsigned int opcode:6; BITFIELD_FIELD(unsigned int func : 6,
;)))
}; };
#else /* !defined (__MIPSEB__) && !defined (__MIPSEL__) */
#error "MIPS but neither __MIPSEL__ nor __MIPSEB__?"
#endif
union mips_instruction { union mips_instruction {
unsigned int word; unsigned int word;
unsigned short halfword[2]; unsigned short halfword[2];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment