Skip to content

Commit

Permalink
Add SLJIT_ATOMIC_USE_LS/CAS support to LoongArch (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
lrzlin authored Jul 22, 2024
1 parent 728db20 commit 8099661
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sljit_src/sljitNativeLOONGARCH_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ static sljit_u32 hwcap_feature_list = 0;
#define GET_CFG2 0
#define GET_HWCAP 1

#define LOONGARCH_SUPPORT_AMCAS (LOONGARCH_CFG2_LAMCAS & get_cpu_features(GET_CFG2))

static SLJIT_INLINE sljit_u32 get_cpu_features(sljit_u32 feature_type)
{
if (cfg2_feature_list == 0)
Expand Down Expand Up @@ -3625,7 +3627,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_atomic_load(struct sljit_compiler
CHECK_ERROR();
CHECK(check_sljit_emit_atomic_load(compiler, op, dst_reg, mem_reg));

if (!(LOONGARCH_CFG2_LAMCAS & get_cpu_features(GET_CFG2))) {
if ((op & SLJIT_ATOMIC_USE_LS) || !LOONGARCH_SUPPORT_AMCAS) {
if (op & SLJIT_ATOMIC_USE_CAS)
return SLJIT_ERR_UNSUPPORTED;

switch (GET_OPCODE(op)) {
case SLJIT_MOV:
case SLJIT_MOV_P:
Expand Down Expand Up @@ -3690,7 +3695,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_atomic_store(struct sljit_compiler
CHECK_ERROR();
CHECK(check_sljit_emit_atomic_store(compiler, op, src_reg, mem_reg, temp_reg));

if (!(LOONGARCH_CFG2_LAMCAS & get_cpu_features(GET_CFG2))) {
if ((op & SLJIT_ATOMIC_USE_LS) || !LOONGARCH_SUPPORT_AMCAS) {
if (op & SLJIT_ATOMIC_USE_CAS)
return SLJIT_ERR_UNSUPPORTED;

switch (GET_OPCODE(op)) {
case SLJIT_MOV:
case SLJIT_MOV_P:
Expand Down

0 comments on commit 8099661

Please sign in to comment.