forked from AbleOS/holey-bytes
allowing eca in inline functions
This commit is contained in:
parent
c701eb7b6d
commit
9949086011
|
@ -446,9 +446,12 @@ pass := fn(arr: ^[uint; 3]): uint {
|
||||||
#### inline
|
#### inline
|
||||||
```hb
|
```hb
|
||||||
main := fn(): uint {
|
main := fn(): uint {
|
||||||
|
some_eca()
|
||||||
return @inline(foo, 1, 2, 3) - bar(3)
|
return @inline(foo, 1, 2, 3) - bar(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$some_eca := fn(): void return @eca(8)
|
||||||
|
|
||||||
// only for functions with no control flow (if, loop)
|
// only for functions with no control flow (if, loop)
|
||||||
$bar := fn(a: uint): uint return a * 2
|
$bar := fn(a: uint): uint return a * 2
|
||||||
|
|
||||||
|
|
|
@ -3849,7 +3849,13 @@ impl<'a> Codegen<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let (v, ctrl, scope) = mem::replace(&mut self.ci.inline_ret, prev_inline_ret)?;
|
let (v, ctrl, scope) = mem::replace(&mut self.ci.inline_ret, prev_inline_ret)?;
|
||||||
if is_inline && ctrl.get() != prev_ctrl {
|
if is_inline
|
||||||
|
&& (ctrl.get() != prev_ctrl
|
||||||
|
&& (!matches!(self.ci.nodes[ctrl.get()].kind, Kind::Call {
|
||||||
|
func: ty::Func::ECA,
|
||||||
|
..
|
||||||
|
}) || self.ci.nodes[ctrl.get()].inputs[0] != prev_ctrl))
|
||||||
|
{
|
||||||
self.report(body.pos(), "function is makred inline but it contains controlflow");
|
self.report(body.pos(), "function is makred inline but it contains controlflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
main:
|
main:
|
||||||
LI64 r7, 6d
|
LI64 r2, 8d
|
||||||
LRA r3, r0, :gb
|
ECA
|
||||||
LI64 r6, 0d
|
LI64 r10, 6d
|
||||||
LD r8, r3, 0a, 8h
|
LRA r6, r0, :gb
|
||||||
CMPU r9, r8, r6
|
LI64 r9, 0d
|
||||||
CMPUI r9, r9, 0d
|
LD r11, r6, 0a, 8h
|
||||||
ORI r11, r9, 0d
|
CMPU r12, r11, r9
|
||||||
ANDI r11, r11, 255d
|
CMPUI r12, r12, 0d
|
||||||
JNE r11, r0, :0
|
ORI r2, r12, 0d
|
||||||
CP r4, r7
|
ANDI r2, r2, 255d
|
||||||
|
JNE r2, r0, :0
|
||||||
|
CP r7, r10
|
||||||
JMP :1
|
JMP :1
|
||||||
0: LI64 r4, 1d
|
0: LI64 r7, 1d
|
||||||
1: SUB64 r1, r4, r7
|
1: SUB64 r1, r7, r10
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 131
|
code size: 142
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
decide:
|
||||||
|
ADDI64 r254, r254, -24d
|
||||||
|
ADDI64 r5, r254, 0d
|
||||||
|
ST r2, r254, 0a, 8h
|
||||||
|
LI64 r8, 0d
|
||||||
|
ST r8, r254, 8a, 8h
|
||||||
|
ST r8, r254, 16a, 8h
|
||||||
|
BMC r5, r1, 24h
|
||||||
|
ADDI64 r254, r254, 24d
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
main:
|
||||||
|
ADDI64 r254, r254, -112d
|
||||||
|
ST r31, r254, 72a, 40h
|
||||||
|
ADDI64 r32, r254, 48d
|
||||||
|
LI64 r2, 0d
|
||||||
|
CP r1, r32
|
||||||
|
JAL r31, r0, :decide
|
||||||
|
ADDI64 r1, r254, 24d
|
||||||
|
BMC r32, r1, 24h
|
||||||
|
LI64 r2, 1d
|
||||||
|
JAL r31, r0, :decide
|
||||||
|
ADDI64 r33, r254, 0d
|
||||||
|
BMC r32, r33, 24h
|
||||||
|
LD r34, r254, 24a, 8h
|
||||||
|
LD r35, r254, 0a, 8h
|
||||||
|
ADD64 r1, r35, r34
|
||||||
|
LD r31, r254, 72a, 40h
|
||||||
|
ADDI64 r254, r254, 112d
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
code size: 275
|
||||||
|
ret: 1
|
||||||
|
status: Ok(())
|
Loading…
Reference in a new issue