Skip to content

Commit 7f46074

Browse files
committed
Make _Bool 1 byte
#233
1 parent 35b8a3a commit 7f46074

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

src/cc/arch/x64/ir_x64.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,6 @@ static void ei_cond(IR *ir) {
833833
JE(fmt_name(skip_label));
834834
MOV(IM(cond != COND_EQ ? 1 : 0), dst);
835835
EMIT_LABEL(fmt_name(skip_label));
836-
837-
MOVSX(dst, kReg32s[ir->dst->phys]); // Assume bool is 4 byte.
838836
}
839837
return;
840838

@@ -867,7 +865,6 @@ static void ei_cond(IR *ir) {
867865
default: assert(false); break;
868866
}
869867
}
870-
MOVSX(dst, kReg32s[ir->dst->phys]); // Assume bool is 4 byte.
871868
}
872869

873870
static void ei_jmp(IR *ir) {

src/cc/backend/ir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "util.h"
1010

1111
static const enum VRegSize vtVoidPtr = VRegSize8;
12-
static const enum VRegSize vtBool = VRegSize4;
12+
static const enum VRegSize vtBool = VRegSize1;
1313

1414
Phi *new_phi(VReg *dst, Vector *params) {
1515
Phi *phi = malloc_or_die(sizeof(*phi));

src/cc/frontend/type.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Type tyInt = {.kind=TY_FIXNUM, .fixnum={.kind=FX_INT, .is_unsigned=f
1414
Type tyVoid = {.kind=TY_VOID};
1515
Type tyConstVoid = {.kind=TY_VOID, .qualifier=TQ_CONST};
1616
Type tyVoidPtr = {.kind=TY_PTR, .pa={.ptrof=&tyVoid}};
17-
Type tyBool = {.kind=TY_FIXNUM, .fixnum={.kind=FX_BOOL, .is_unsigned=false}};
17+
Type tyBool = {.kind=TY_FIXNUM, .fixnum={.kind=FX_BOOL, .is_unsigned=false}};
1818
Type tySize = {.kind=TY_FIXNUM, .fixnum={.kind=FX_LONG, .is_unsigned=true}};
1919
Type tySSize = {.kind=TY_FIXNUM, .fixnum={.kind=FX_LONG, .is_unsigned=false}};
2020
Type tyFloat = {.kind=TY_FLONUM, .flonum={.kind=FL_FLOAT}};
@@ -40,8 +40,8 @@ static Type kFixnumTypeTable[2][4][FX_LLONG + 1] = {
4040
};
4141
#undef FIXNUM_TABLE
4242

43-
size_t fixnum_size_table[] = {1, 2, 4, 8, 8, 4, 4};
44-
int fixnum_align_table[] = {1, 2, 4, 8, 8, 4, 4};
43+
size_t fixnum_size_table[] = {1, 2, 4, 8, 8, 4, 1};
44+
int fixnum_align_table[] = {1, 2, 4, 8, 8, 4, 1};
4545

4646
size_t flonum_size_table[] = {4, 8, 8};
4747
int flonum_align_table[] = {4, 8, 8};

tests/valtest.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ TEST(all) {
835835
}
836836

837837
{
838+
EXPECT("sizeof _Bool", 1, sizeof(_Bool));
838839
EXPECT("_Bool from int", true, ({int x = -123; (_Bool)x;}));
839840
EXPECT("_Bool from ulong", true, ({unsigned long x = 9876UL; (_Bool)x;}));
840841
#ifndef __NO_FLONUM

0 commit comments

Comments
 (0)