Skip to content

Commit

Permalink
loongarch: fix FTBFS when building pcre2test as part of PCRE2 (zhercz…
Browse files Browse the repository at this point in the history
…eg#220)

When `sljit_u32 cpu_feature_list` was introduced, it wasn't set as
static and therefore would fail linking if multiple copies of it
were used as is done by pcre2test.

Make it static (as used everywhere) and while at it, rename the
`dst` parameter in `sljit_emit_fop2r` as well as other styling
changes for consistency.
  • Loading branch information
carenas committed Nov 25, 2023
1 parent 3faacd4 commit 57c212f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions sljit_src/sljitNativeLOONGARCH_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

SLJIT_API_FUNC_ATTRIBUTE const char* sljit_get_platform_name(void)
{
#if (defined SLJIT_CONFIG_LOONGARCH_64 && SLJIT_CONFIG_LOONGARCH_64)
return "LOONGARCH" SLJIT_CPUINFO;
#endif /* SLJIT_CONFIG_LOONGARCH_64 */
}

typedef sljit_u32 sljit_ins;
Expand Down Expand Up @@ -61,7 +59,7 @@ static const sljit_u8 freg_map[SLJIT_NUMBER_OF_FLOAT_REGISTERS + 3] = {
/*
LoongArch instructions are 32 bits wide, belonging to 9 basic instruction formats (and variants of them):
| Format name | Composition |
| Format name | Composition |
| 2R | Opcode + Rj + Rd |
| 3R | Opcode + Rk + Rj + Rd |
| 4R | Opcode + Ra + Rk + Rj + Rd |
Expand Down Expand Up @@ -338,10 +336,10 @@ lower parts in the instruction word, denoted by the “L” and “H” suffixes
#define INST(inst, type) ((sljit_ins)((type & SLJIT_32) ? inst##_W : inst##_D))

/* LoongArch CPUCFG register for feature detection */
#define LOONGARCH_CFG2 0x02
#define LOONGARCH_CFG2 0x02
#define LOONGARCH_FEATURE_LAMCAS (1 << 28)

sljit_u32 cpu_feature_list = 0;
static sljit_u32 cpu_feature_list = 0;

static SLJIT_INLINE sljit_u32 get_cpu_features(void)
{
Expand Down Expand Up @@ -2393,14 +2391,14 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop2(struct sljit_compiler *compil
}

SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop2r(struct sljit_compiler *compiler, sljit_s32 op,
sljit_s32 dst,
sljit_s32 dst_freg,
sljit_s32 src1, sljit_sw src1w,
sljit_s32 src2, sljit_sw src2w)
{
sljit_s32 reg;

CHECK_ERROR();
CHECK(check_sljit_emit_fop2r(compiler, op, dst, src1, src1w, src2, src2w));
CHECK(check_sljit_emit_fop2r(compiler, op, dst_freg, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);

Expand All @@ -2410,12 +2408,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop2r(struct sljit_compiler *compi
}

if (src1 & SLJIT_MEM) {
reg = (dst == src2) ? TMP_FREG1 : dst;
reg = (dst_freg == src2) ? TMP_FREG1 : dst_freg;
FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, reg, src1, src1w, 0, 0));
src1 = reg;
}

return push_inst(compiler, FINST(FCOPYSIGN, op) | FRD(dst) | FRJ(src1) | FRK(src2));
return push_inst(compiler, FINST(FCOPYSIGN, op) | FRD(dst_freg) | FRJ(src1) | FRK(src2));
}

SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fset32(struct sljit_compiler *compiler,
Expand Down

0 comments on commit 57c212f

Please sign in to comment.