1
0
mirror of https://github.com/janet-lang/janet synced 2025-07-09 05:22:53 +00:00
This commit is contained in:
Calvin Rose 2025-04-11 22:44:36 -05:00
parent 3cbdf26aa2
commit c9305a0a42
2 changed files with 49 additions and 50 deletions

View File

@ -1087,8 +1087,7 @@ static int check_const_valid(JanetSysIR *sysir, Janet constant, uint32_t t) {
switch (janet_type(constant)) {
default:
return 0;
case JANET_TUPLE:
{
case JANET_TUPLE: {
const Janet *elements = janet_unwrap_tuple(constant);
int32_t len = janet_tuple_length(elements);
if (p != JANET_PRIM_ARRAY) return 0;
@ -1104,8 +1103,7 @@ static int check_const_valid(JanetSysIR *sysir, Janet constant, uint32_t t) {
case JANET_SYMBOL:
case JANET_POINTER:
return p == JANET_PRIM_POINTER;
case JANET_NUMBER:
{
case JANET_NUMBER: {
double x = janet_unwrap_number(constant);
if (p == JANET_PRIM_F64) return 1;
if (p == JANET_PRIM_F32) return 1;
@ -1120,8 +1118,7 @@ static int check_const_valid(JanetSysIR *sysir, Janet constant, uint32_t t) {
if (p == JANET_PRIM_S64 && (x >= INT64_MIN && x <= INT64_MAX)) return 1;
return 0;
}
case JANET_ABSTRACT:
{
case JANET_ABSTRACT: {
void *point = janet_unwrap_abstract(constant);
const JanetAbstractType *at = janet_abstract_type(point);
if (at == &janet_s64_type && p == JANET_PRIM_S64) return 1;

View File

@ -363,12 +363,14 @@ static void e_mov_to_reg(JanetSysx64Context *ctx, x64Reg d, x64Reg s, MoveMode m
return;
}
if (mm == MOV_LOAD || s.storage != JANET_SYSREG_REGISTER) {
x64Reg t = d; d = s; s = t; /* swap */
x64Reg t = d;
d = s;
s = t; /* swap */
flip = 1;
}
assert(s.storage == JANET_SYSREG_REGISTER);
opcode = 0x88;
mod_rm |= (uint8_t) (s.index & 7) << 3;
mod_rm |= (uint8_t)(s.index & 7) << 3;
if (s.index >= 8) rex |= REX_R;
if (s.kind >= JANET_SYSREG_64) rex |= REX_W;
if (d.storage == JANET_SYSREG_REGISTER) {
@ -376,7 +378,7 @@ static void e_mov_to_reg(JanetSysx64Context *ctx, x64Reg d, x64Reg s, MoveMode m
if (mm == MOV_FLAT) {
mod_rm |= 0xC0u; /* mod = b11, reg, reg mode */
}
mod_rm |= (uint8_t) (d.index & 7);
mod_rm |= (uint8_t)(d.index & 7);
} else {
assert(mm == MOV_FLAT);
/* d is memory */