Skip to content

Commit

Permalink
MIPS: uasm: Remove needless ISA abstraction
Browse files Browse the repository at this point in the history
We always either target MIPS32/MIPS64 or microMIPS, and always include
one & only one of uasm-mips.c or uasm-micromips.c. Therefore the
abstraction of the ISA in asm/uasm.h declaring functions for either ISA
is redundant & needless. Remove it to simplify the code.

This is largely the result of the following:

  :%s/ISAOPC(\(.\{-}\))/uasm_i##\1/
  :%s/ISAFUNC(\(.\{-}\))/\1/

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: Paul Burton <paul.burton@imgtec.com>
Patchwork: https://patchwork.linux-mips.org/patch/15844/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Paul Burton authored and Ralf Baechle committed Apr 12, 2017
1 parent 828d1e4 commit 33679a5
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 137 deletions.
87 changes: 28 additions & 59 deletions arch/mips/include/asm/uasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,77 +21,46 @@
#define UASM_EXPORT_SYMBOL(sym)
#endif

#define _UASM_ISA_CLASSIC 0
#define _UASM_ISA_MICROMIPS 1

#ifndef UASM_ISA
#ifdef CONFIG_CPU_MICROMIPS
#define UASM_ISA _UASM_ISA_MICROMIPS
#else
#define UASM_ISA _UASM_ISA_CLASSIC
#endif
#endif

#if (UASM_ISA == _UASM_ISA_CLASSIC)
#ifdef CONFIG_CPU_MICROMIPS
#define ISAOPC(op) CL_uasm_i##op
#define ISAFUNC(x) CL_##x
#else
#define ISAOPC(op) uasm_i##op
#define ISAFUNC(x) x
#endif
#elif (UASM_ISA == _UASM_ISA_MICROMIPS)
#ifdef CONFIG_CPU_MICROMIPS
#define ISAOPC(op) uasm_i##op
#define ISAFUNC(x) x
#else
#define ISAOPC(op) MM_uasm_i##op
#define ISAFUNC(x) MM_##x
#endif
#else
#error Unsupported micro-assembler ISA!!!
#endif

#define Ip_u1u2u3(op) \
void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
void uasm_i##op(u32 **buf, unsigned int a, unsigned int b, unsigned int c)

#define Ip_u2u1u3(op) \
void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
void uasm_i##op(u32 **buf, unsigned int a, unsigned int b, unsigned int c)

#define Ip_u3u2u1(op) \
void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
void uasm_i##op(u32 **buf, unsigned int a, unsigned int b, unsigned int c)

#define Ip_u3u1u2(op) \
void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
void uasm_i##op(u32 **buf, unsigned int a, unsigned int b, unsigned int c)

#define Ip_u1u2s3(op) \
void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c)
void uasm_i##op(u32 **buf, unsigned int a, unsigned int b, signed int c)

#define Ip_u2s3u1(op) \
void ISAOPC(op)(u32 **buf, unsigned int a, signed int b, unsigned int c)
void uasm_i##op(u32 **buf, unsigned int a, signed int b, unsigned int c)

#define Ip_s3s1s2(op) \
void ISAOPC(op)(u32 **buf, int a, int b, int c)
void uasm_i##op(u32 **buf, int a, int b, int c)

#define Ip_u2u1s3(op) \
void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c)
void uasm_i##op(u32 **buf, unsigned int a, unsigned int b, signed int c)

#define Ip_u2u1msbu3(op) \
void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c, \
void uasm_i##op(u32 **buf, unsigned int a, unsigned int b, unsigned int c, \
unsigned int d)

#define Ip_u1u2(op) \
void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b)
void uasm_i##op(u32 **buf, unsigned int a, unsigned int b)

#define Ip_u2u1(op) \
void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b)
void uasm_i##op(u32 **buf, unsigned int a, unsigned int b)

#define Ip_u1s2(op) \
void ISAOPC(op)(u32 **buf, unsigned int a, signed int b)
void uasm_i##op(u32 **buf, unsigned int a, signed int b)

#define Ip_u1(op) void ISAOPC(op)(u32 **buf, unsigned int a)
#define Ip_u1(op) void uasm_i##op(u32 **buf, unsigned int a)

#define Ip_0(op) void ISAOPC(op)(u32 **buf)
#define Ip_0(op) void uasm_i##op(u32 **buf)

Ip_u2u1s3(_addiu);
Ip_u3u1u2(_addu);
Expand Down Expand Up @@ -191,20 +160,20 @@ struct uasm_label {
int lab;
};

void ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr,
void uasm_build_label(struct uasm_label **lab, u32 *addr,
int lid);
#ifdef CONFIG_64BIT
int ISAFUNC(uasm_in_compat_space_p)(long addr);
int uasm_in_compat_space_p(long addr);
#endif
int ISAFUNC(uasm_rel_hi)(long val);
int ISAFUNC(uasm_rel_lo)(long val);
void ISAFUNC(UASM_i_LA_mostly)(u32 **buf, unsigned int rs, long addr);
void ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr);
int uasm_rel_hi(long val);
int uasm_rel_lo(long val);
void UASM_i_LA_mostly(u32 **buf, unsigned int rs, long addr);
void UASM_i_LA(u32 **buf, unsigned int rs, long addr);

#define UASM_L_LA(lb) \
static inline void ISAFUNC(uasm_l##lb)(struct uasm_label **lab, u32 *addr) \
static inline void uasm_l##lb(struct uasm_label **lab, u32 *addr) \
{ \
ISAFUNC(uasm_build_label)(lab, addr, label##lb); \
uasm_build_label(lab, addr, label##lb); \
}

/* convenience macros for instructions */
Expand Down Expand Up @@ -256,27 +225,27 @@ static inline void uasm_i_drotr_safe(u32 **p, unsigned int a1,
unsigned int a2, unsigned int a3)
{
if (a3 < 32)
ISAOPC(_drotr)(p, a1, a2, a3);
uasm_i_drotr(p, a1, a2, a3);
else
ISAOPC(_drotr32)(p, a1, a2, a3 - 32);
uasm_i_drotr32(p, a1, a2, a3 - 32);
}

static inline void uasm_i_dsll_safe(u32 **p, unsigned int a1,
unsigned int a2, unsigned int a3)
{
if (a3 < 32)
ISAOPC(_dsll)(p, a1, a2, a3);
uasm_i_dsll(p, a1, a2, a3);
else
ISAOPC(_dsll32)(p, a1, a2, a3 - 32);
uasm_i_dsll32(p, a1, a2, a3 - 32);
}

static inline void uasm_i_dsrl_safe(u32 **p, unsigned int a1,
unsigned int a2, unsigned int a3)
{
if (a3 < 32)
ISAOPC(_dsrl)(p, a1, a2, a3);
uasm_i_dsrl(p, a1, a2, a3);
else
ISAOPC(_dsrl32)(p, a1, a2, a3 - 32);
uasm_i_dsrl32(p, a1, a2, a3 - 32);
}

/* Handle relocations. */
Expand Down
Loading

0 comments on commit 33679a5

Please sign in to comment.