powerpc: Use a datatype for instructions
Currently unsigned ints are used to represent instructions on powerpc. This has worked well as instructions have always been 4 byte words. However, ISA v3.1 introduces some changes to instructions that mean this scheme will no longer work as well. This change is Prefixed Instructions. A prefixed instruction is made up of a word prefix followed by a word suffix to make an 8 byte double word instruction. No matter the endianness of the system the prefix always comes first. Prefixed instructions are only planned for powerpc64. Introduce a ppc_inst type to represent both prefixed and word instructions on powerpc64 while keeping it possible to exclusively have word instructions on powerpc32. Signed-off-by: Jordan Niethe <jniethe5@gmail.com> [mpe: Fix compile error in emulate_spe()] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200506034050.24806-12-jniethe5@gmail.com
This commit is contained in:

committed by
Michael Ellerman

parent
217862d9b9
commit
94afd069d9
@@ -6,26 +6,30 @@
|
||||
* Instruction data type for POWER
|
||||
*/
|
||||
|
||||
#define ppc_inst(x) (x)
|
||||
struct ppc_inst {
|
||||
u32 val;
|
||||
} __packed;
|
||||
|
||||
static inline u32 ppc_inst_val(u32 x)
|
||||
#define ppc_inst(x) ((struct ppc_inst){ .val = x })
|
||||
|
||||
static inline u32 ppc_inst_val(struct ppc_inst x)
|
||||
{
|
||||
return x;
|
||||
return x.val;
|
||||
}
|
||||
|
||||
static inline int ppc_inst_primary_opcode(u32 x)
|
||||
static inline int ppc_inst_primary_opcode(struct ppc_inst x)
|
||||
{
|
||||
return ppc_inst_val(x) >> 26;
|
||||
}
|
||||
|
||||
static inline u32 ppc_inst_swab(u32 x)
|
||||
static inline struct ppc_inst ppc_inst_swab(struct ppc_inst x)
|
||||
{
|
||||
return ppc_inst(swab32(ppc_inst_val(x)));
|
||||
}
|
||||
|
||||
static inline bool ppc_inst_equal(u32 x, u32 y)
|
||||
static inline bool ppc_inst_equal(struct ppc_inst x, struct ppc_inst y)
|
||||
{
|
||||
return x == y;
|
||||
return ppc_inst_val(x) == ppc_inst_val(y);
|
||||
}
|
||||
|
||||
#endif /* _ASM_POWERPC_INST_H */
|
||||
|
Reference in New Issue
Block a user