Skip to content

Commit c2a4a88

Browse files
committed
reformat
1 parent ab26660 commit c2a4a88

3 files changed

Lines changed: 78 additions & 47 deletions

File tree

src/builder.h

Lines changed: 69 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -664,23 +664,57 @@ static inline const char *builder_x86_reg8(const char *name) {
664664

665665
static inline void builder_x86_setcc(cj_ctx *ctx, cj_operand r8, cj_condition cond) {
666666
switch (cond) {
667-
case CJ_COND_O: cj_seto(ctx, r8); break;
668-
case CJ_COND_NO: cj_setno(ctx, r8); break;
669-
case CJ_COND_B: cj_setb(ctx, r8); break;
670-
case CJ_COND_NB: cj_setnb(ctx, r8); break;
671-
case CJ_COND_Z: cj_setz(ctx, r8); break;
672-
case CJ_COND_NZ: cj_setnz(ctx, r8); break;
673-
case CJ_COND_BE: cj_setbe(ctx, r8); break;
674-
case CJ_COND_A: cj_seta(ctx, r8); break;
675-
case CJ_COND_S: cj_sets(ctx, r8); break;
676-
case CJ_COND_NS: cj_setns(ctx, r8); break;
677-
case CJ_COND_P: cj_setp(ctx, r8); break;
678-
case CJ_COND_NP: cj_setnp(ctx, r8); break;
679-
case CJ_COND_L: cj_setl(ctx, r8); break;
680-
case CJ_COND_GE: cj_setge(ctx, r8); break;
681-
case CJ_COND_LE: cj_setle(ctx, r8); break;
682-
case CJ_COND_G: cj_setg(ctx, r8); break;
683-
default: assert(0 && "unsupported condition for setcc"); break;
667+
case CJ_COND_O:
668+
cj_seto(ctx, r8);
669+
break;
670+
case CJ_COND_NO:
671+
cj_setno(ctx, r8);
672+
break;
673+
case CJ_COND_B:
674+
cj_setb(ctx, r8);
675+
break;
676+
case CJ_COND_NB:
677+
cj_setnb(ctx, r8);
678+
break;
679+
case CJ_COND_Z:
680+
cj_setz(ctx, r8);
681+
break;
682+
case CJ_COND_NZ:
683+
cj_setnz(ctx, r8);
684+
break;
685+
case CJ_COND_BE:
686+
cj_setbe(ctx, r8);
687+
break;
688+
case CJ_COND_A:
689+
cj_seta(ctx, r8);
690+
break;
691+
case CJ_COND_S:
692+
cj_sets(ctx, r8);
693+
break;
694+
case CJ_COND_NS:
695+
cj_setns(ctx, r8);
696+
break;
697+
case CJ_COND_P:
698+
cj_setp(ctx, r8);
699+
break;
700+
case CJ_COND_NP:
701+
cj_setnp(ctx, r8);
702+
break;
703+
case CJ_COND_L:
704+
cj_setl(ctx, r8);
705+
break;
706+
case CJ_COND_GE:
707+
cj_setge(ctx, r8);
708+
break;
709+
case CJ_COND_LE:
710+
cj_setle(ctx, r8);
711+
break;
712+
case CJ_COND_G:
713+
cj_setg(ctx, r8);
714+
break;
715+
default:
716+
assert(0 && "unsupported condition for setcc");
717+
break;
684718
}
685719
}
686720

@@ -690,22 +724,22 @@ static inline void builder_x86_setcc(cj_ctx *ctx, cj_operand r8, cj_condition co
690724
Index = cj_condition value (x86-ordered), value = ARM64 code. */
691725
static inline int builder_arm64_cond_code(cj_condition cond) {
692726
static const int table[16] = {
693-
6, /* CJ_COND_O (0) → VS (6) */
694-
7, /* CJ_COND_NO (1) → VC (7) */
695-
3, /* CJ_COND_B (2) → CC (3) */
696-
2, /* CJ_COND_NB (3) → CS (2) */
697-
0, /* CJ_COND_Z (4) → EQ (0) */
698-
1, /* CJ_COND_NZ (5) → NE (1) */
699-
9, /* CJ_COND_BE (6) → LS (9) */
700-
8, /* CJ_COND_A (7) → HI (8) */
701-
4, /* CJ_COND_S (8) → MI (4) */
702-
5, /* CJ_COND_NS (9) → PL (5) */
703-
6, /* CJ_COND_P (10) → VS (6) */
704-
7, /* CJ_COND_NP (11) → VC (7) */
705-
11, /* CJ_COND_L (12) → LT (11) */
706-
10, /* CJ_COND_GE (13) → GE (10) */
707-
13, /* CJ_COND_LE (14) → LE (13) */
708-
12, /* CJ_COND_G (15) → GT (12) */
727+
6, /* CJ_COND_O (0) → VS (6) */
728+
7, /* CJ_COND_NO (1) → VC (7) */
729+
3, /* CJ_COND_B (2) → CC (3) */
730+
2, /* CJ_COND_NB (3) → CS (2) */
731+
0, /* CJ_COND_Z (4) → EQ (0) */
732+
1, /* CJ_COND_NZ (5) → NE (1) */
733+
9, /* CJ_COND_BE (6) → LS (9) */
734+
8, /* CJ_COND_A (7) → HI (8) */
735+
4, /* CJ_COND_S (8) → MI (4) */
736+
5, /* CJ_COND_NS (9) → PL (5) */
737+
6, /* CJ_COND_P (10) → VS (6) */
738+
7, /* CJ_COND_NP (11) → VC (7) */
739+
11, /* CJ_COND_L (12) → LT (11) */
740+
10, /* CJ_COND_GE (13) → GE (10) */
741+
13, /* CJ_COND_LE (14) → LE (13) */
742+
12, /* CJ_COND_G (15) → GT (12) */
709743
};
710744
return table[cond & 0xf];
711745
}
@@ -723,11 +757,8 @@ static inline void cj_builder_shl(cj_ctx *ctx, cj_operand dst, int shift) {
723757
int immr = (-shift) & (size - 1);
724758
int imms = size - 1 - shift;
725759
uint32_t base = is64 ? 0xD3400000u : 0x53000000u;
726-
uint32_t instr = base
727-
| (uint32_t)(rd & 0x1f)
728-
| ((uint32_t)(rd & 0x1f) << 5)
729-
| ((uint32_t)(imms & 0x3f) << 10)
730-
| ((uint32_t)(immr & 0x3f) << 16);
760+
uint32_t instr = base | (uint32_t)(rd & 0x1f) | ((uint32_t)(rd & 0x1f) << 5) |
761+
((uint32_t)(imms & 0x3f) << 10) | ((uint32_t)(immr & 0x3f) << 16);
731762
cj_add_u32(ctx, instr);
732763
#endif
733764
}

tests/test_harness_arm64.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,9 +1698,9 @@ static void test_cset_backend(void) {
16981698
typedef uint64_t (*fn_t)(int64_t, int64_t);
16991699
fn_t fn = (fn_t)create_cj_fn(cj);
17001700

1701-
assert(fn(3, 5) == 1); /* 3 < 5 → true */
1702-
assert(fn(5, 3) == 0); /* 5 < 3 → false */
1703-
assert(fn(4, 4) == 0); /* 4 == 4 → false */
1701+
assert(fn(3, 5) == 1); /* 3 < 5 → true */
1702+
assert(fn(5, 3) == 0); /* 5 < 3 → false */
1703+
assert(fn(4, 4) == 0); /* 4 == 4 → false */
17041704

17051705
destroy_cj_fn(cj, (cj_fn)fn);
17061706
destroy_cj_ctx(cj);

tests/test_harness_builder.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ static void test_sar(void) {
217217
fn1_t fn = (fn1_t)create_cj_fn(cj);
218218
assert(fn);
219219
assert(fn(-16) == -4);
220-
assert(fn(-1) == -1); /* all-ones stays all-ones */
221-
assert(fn(16) == 4); /* positive values shift normally */
220+
assert(fn(-1) == -1); /* all-ones stays all-ones */
221+
assert(fn(16) == 4); /* positive values shift normally */
222222

223223
destroy_cj_fn(cj, (cj_fn)fn);
224224
destroy_cj_ctx(cj);
@@ -239,10 +239,10 @@ static void test_cset(void) {
239239

240240
fn2_t fn = (fn2_t)create_cj_fn(cj);
241241
assert(fn);
242-
assert(fn(3, 5) == 1); /* 3 < 5 → true */
243-
assert(fn(5, 3) == 0); /* 5 < 3 → false */
244-
assert(fn(4, 4) == 0); /* 4 < 4 → false */
245-
assert(fn(-1, 1) == 1); /* -1 < 1 → true (signed) */
242+
assert(fn(3, 5) == 1); /* 3 < 5 → true */
243+
assert(fn(5, 3) == 0); /* 5 < 3 → false */
244+
assert(fn(4, 4) == 0); /* 4 < 4 → false */
245+
assert(fn(-1, 1) == 1); /* -1 < 1 → true (signed) */
246246

247247
destroy_cj_fn(cj, (cj_fn)fn);
248248
destroy_cj_ctx(cj);

0 commit comments

Comments
 (0)