forked from AbleOS/holey-bytes
adding pointer edgecase
This commit is contained in:
parent
f1e715e9bd
commit
4ec88e3397
|
@ -2936,7 +2936,15 @@ impl<'a> Codegen<'a> {
|
||||||
self.implicit_unwrap(right.pos(), &mut rhs);
|
self.implicit_unwrap(right.pos(), &mut rhs);
|
||||||
let (ty, aclass) = self.binop_ty(pos, &mut lhs, &mut rhs, op);
|
let (ty, aclass) = self.binop_ty(pos, &mut lhs, &mut rhs, op);
|
||||||
let fty = ty.bin_ret(op);
|
let fty = ty.bin_ret(op);
|
||||||
if fty == ty::Id::BOOL {
|
if matches!(
|
||||||
|
op,
|
||||||
|
TokenKind::Lt
|
||||||
|
| TokenKind::Gt
|
||||||
|
| TokenKind::Ge
|
||||||
|
| TokenKind::Le
|
||||||
|
| TokenKind::Ne
|
||||||
|
| TokenKind::Eq
|
||||||
|
) {
|
||||||
if lhs.ty.is_float() {
|
if lhs.ty.is_float() {
|
||||||
} else {
|
} else {
|
||||||
self.ci.nodes.lock(rhs.id);
|
self.ci.nodes.lock(rhs.id);
|
||||||
|
@ -4236,6 +4244,8 @@ impl<'a> Codegen<'a> {
|
||||||
self.pool.push_ci(file, Some(sig.ret), 0, &mut self.ci);
|
self.pool.push_ci(file, Some(sig.ret), 0, &mut self.ci);
|
||||||
let prev_err_len = self.errors.borrow().len();
|
let prev_err_len = self.errors.borrow().len();
|
||||||
|
|
||||||
|
log::info!("{}", self.ast_display(expr));
|
||||||
|
|
||||||
let &Expr::Closure { body, args, pos, .. } = expr else {
|
let &Expr::Closure { body, args, pos, .. } = expr else {
|
||||||
unreachable!("{}", self.ast_display(expr))
|
unreachable!("{}", self.ast_display(expr))
|
||||||
};
|
};
|
||||||
|
|
|
@ -584,14 +584,19 @@ impl TokenKind {
|
||||||
Self::Number if src.is_float() && dst.is_integer() => {
|
Self::Number if src.is_float() && dst.is_integer() => {
|
||||||
[|a, b| instrs::fti32(a, b, 1), |a, b| instrs::fti64(a, b, 1)][src_idx - 2]
|
[|a, b| instrs::fti32(a, b, 1), |a, b| instrs::fti64(a, b, 1)][src_idx - 2]
|
||||||
}
|
}
|
||||||
Self::Number if src.is_signed() && dst.is_integer() => {
|
Self::Number if src.is_signed() && (dst.is_integer() || dst.is_pointer()) => {
|
||||||
[instrs::sxt8, instrs::sxt16, instrs::sxt32][src_idx]
|
[instrs::sxt8, instrs::sxt16, instrs::sxt32][src_idx]
|
||||||
}
|
}
|
||||||
Self::Number if (src.is_unsigned() || src == ty::Id::BOOL) && dst.is_integer() => [
|
Self::Number
|
||||||
|
if (src.is_unsigned() || src == ty::Id::BOOL)
|
||||||
|
&& (dst.is_integer() || dst.is_pointer()) =>
|
||||||
|
{
|
||||||
|
[
|
||||||
|a, b| instrs::andi(a, b, 0xff),
|
|a, b| instrs::andi(a, b, 0xff),
|
||||||
|a, b| instrs::andi(a, b, 0xffff),
|
|a, b| instrs::andi(a, b, 0xffff),
|
||||||
|a, b| instrs::andi(a, b, 0xffffffff),
|
|a, b| instrs::andi(a, b, 0xffffffff),
|
||||||
][src_idx],
|
][src_idx]
|
||||||
|
}
|
||||||
Self::Float if dst.is_float() && src.is_float() => {
|
Self::Float if dst.is_float() && src.is_float() => {
|
||||||
[instrs::fc32t64, |a, b| instrs::fc64t32(a, b, 1)][src_idx - 2]
|
[instrs::fc32t64, |a, b| instrs::fc64t32(a, b, 1)][src_idx - 2]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
main:
|
main:
|
||||||
LI64 r2, 8d
|
LI64 r2, 8d
|
||||||
ECA
|
ECA
|
||||||
LI64 r11, 6d
|
LI64 r10, 6d
|
||||||
LRA r6, r0, :gb
|
LRA r6, r0, :gb
|
||||||
LI64 r9, 0d
|
LI64 r9, 0d
|
||||||
LD r10, r6, 0a, 8h
|
LD r11, r6, 0a, 8h
|
||||||
CMPU r12, r10, r9
|
CMPU r12, r11, r9
|
||||||
CMPUI r12, r12, 0d
|
CMPUI r12, r12, 0d
|
||||||
ANDI r2, r12, 255d
|
ORI r2, r12, 0d
|
||||||
OR r4, r2, r9
|
ANDI r2, r2, 255d
|
||||||
ANDI r4, r4, 255d
|
JNE r2, r0, :0
|
||||||
JNE r4, r0, :0
|
CP r7, r10
|
||||||
CP r9, r11
|
|
||||||
JMP :1
|
JMP :1
|
||||||
0: LI64 r9, 1d
|
0: LI64 r7, 1d
|
||||||
1: SUB64 r1, r9, r11
|
1: SUB64 r1, r7, r10
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 146
|
code size: 142
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -138d
|
ADDI64 r254, r254, -122d
|
||||||
ST r31, r254, 26a, 112h
|
ST r31, r254, 26a, 96h
|
||||||
JAL r31, r0, :returner_fn
|
JAL r31, r0, :returner_fn
|
||||||
CP r32, r1
|
CP r32, r1
|
||||||
ADDI64 r1, r254, 2d
|
ADDI64 r1, r254, 2d
|
||||||
|
@ -9,28 +9,25 @@ main:
|
||||||
JAL r31, r0, :returner_cn
|
JAL r31, r0, :returner_cn
|
||||||
ST r1, r254, 0a, 2h
|
ST r1, r254, 0a, 2h
|
||||||
LI8 r34, 0b
|
LI8 r34, 0b
|
||||||
|
LI8 r35, 0b
|
||||||
|
LD r36, r254, 2a, 1h
|
||||||
CP r1, r32
|
CP r1, r32
|
||||||
CMPU r35, r1, r34
|
CMPU r37, r1, r34
|
||||||
CMPUI r35, r35, 0d
|
CMPUI r37, r37, 0d
|
||||||
LI8 r36, 0b
|
CMPU r38, r36, r35
|
||||||
LD r37, r254, 2a, 1h
|
CMPUI r38, r38, 0d
|
||||||
ANDI r38, r35, 255d
|
LD r39, r254, 0a, 1h
|
||||||
CMPU r32, r37, r36
|
AND r40, r38, r37
|
||||||
CMPUI r32, r32, 0d
|
CMPU r41, r39, r35
|
||||||
AND r39, r32, r38
|
CMPUI r41, r41, 0d
|
||||||
LD r40, r254, 0a, 1h
|
AND r42, r41, r40
|
||||||
ANDI r41, r39, 255d
|
ANDI r42, r42, 255d
|
||||||
CMPU r42, r40, r36
|
JNE r42, r0, :0
|
||||||
CMPUI r42, r42, 0d
|
|
||||||
AND r43, r42, r41
|
|
||||||
ANDI r44, r43, 255d
|
|
||||||
ANDI r44, r44, 255d
|
|
||||||
JNE r44, r0, :0
|
|
||||||
LI64 r1, 0d
|
LI64 r1, 0d
|
||||||
JMP :1
|
JMP :1
|
||||||
0: LI64 r1, 1d
|
0: LI64 r1, 1d
|
||||||
1: LD r31, r254, 26a, 112h
|
1: LD r31, r254, 26a, 96h
|
||||||
ADDI64 r254, r254, 138d
|
ADDI64 r254, r254, 122d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
returner_bn:
|
returner_bn:
|
||||||
ADDI64 r254, r254, -24d
|
ADDI64 r254, r254, -24d
|
||||||
|
@ -57,6 +54,6 @@ returner_fn:
|
||||||
LD r1, r254, 0a, 0h
|
LD r1, r254, 0a, 0h
|
||||||
ORI r1, r1, 128d
|
ORI r1, r1, 128d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 513
|
code size: 480
|
||||||
ret: 1
|
ret: 1
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,31 +1,29 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -1d
|
ADDI64 r254, r254, -1d
|
||||||
LI64 r7, 0d
|
LI64 r7, 0d
|
||||||
LI64 r5, 255d
|
LI64 r6, 255d
|
||||||
LI8 r4, 1b
|
LI8 r2, 1b
|
||||||
LI8 r6, 0b
|
LI8 r4, 0b
|
||||||
ST r6, r254, 0a, 1h
|
ST r4, r254, 0a, 1h
|
||||||
2: LD r9, r254, 0a, 1h
|
2: LD r9, r254, 0a, 1h
|
||||||
AND r12, r9, r5
|
ANDI r11, r9, 255d
|
||||||
CMPU r2, r12, r5
|
CMPU r3, r11, r6
|
||||||
CMPUI r2, r2, 0d
|
CMPUI r3, r3, 0d
|
||||||
NOT r2, r2
|
NOT r3, r3
|
||||||
CMPU r6, r12, r7
|
CMPU r5, r11, r7
|
||||||
CMPUI r6, r6, 0d
|
CMPUI r5, r5, 0d
|
||||||
NOT r6, r6
|
NOT r5, r5
|
||||||
AND r8, r2, r5
|
OR r8, r5, r3
|
||||||
AND r10, r6, r5
|
ANDI r8, r8, 255d
|
||||||
OR r11, r10, r8
|
JNE r8, r0, :0
|
||||||
ANDI r11, r11, 255d
|
|
||||||
JNE r11, r0, :0
|
|
||||||
JMP :1
|
JMP :1
|
||||||
0: SUB8 r4, r0, r4
|
0: SUB8 r2, r0, r2
|
||||||
1: ADD8 r8, r9, r4
|
1: ADD8 r4, r9, r2
|
||||||
ST r8, r254, 0a, 1h
|
ST r4, r254, 0a, 1h
|
||||||
JMP :2
|
JMP :2
|
||||||
ADDI64 r254, r254, 1d
|
ADDI64 r254, r254, 1d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
timed out
|
timed out
|
||||||
code size: 192
|
code size: 191
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
Loading…
Reference in a new issue