forked from AbleOS/holey-bytes
saving
This commit is contained in:
parent
7448339605
commit
ea628c1278
|
@ -943,11 +943,51 @@ impl Nodes {
|
||||||
return Some(self.new_node(self[lhs].ty, Kind::Stre, vc));
|
return Some(self.new_node(self[lhs].ty, Kind::Stre, vc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
K::Stck => {
|
||||||
|
if let &[mut a, mut b] = self[target].outputs.as_slice() {
|
||||||
|
if self[a].kind == Kind::Load {
|
||||||
|
mem::swap(&mut a, &mut b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if matches!(self[a].kind, Kind::Call { .. })
|
||||||
|
&& self[a].inputs.last() == Some(&target)
|
||||||
|
&& self[b].kind == Kind::Load
|
||||||
|
&& let &[store] = self[b].outputs.as_slice()
|
||||||
|
&& self[store].kind == Kind::Stre
|
||||||
|
{
|
||||||
|
let len = self[a].inputs.len();
|
||||||
|
let stre = self[store].inputs[3];
|
||||||
|
if stre != MEM {
|
||||||
|
self[a].inputs.push(stre);
|
||||||
|
self[a].inputs.swap(len - 2, len - 1);
|
||||||
|
self[stre].outputs.push(a);
|
||||||
|
}
|
||||||
|
return Some(self[store].inputs[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
K::Stre => {
|
K::Stre => {
|
||||||
let &[_, value, region, store, ..] = self[target].inputs.as_slice() else {
|
let &[_, value, region, store, ..] = self[target].inputs.as_slice() else {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if self[value].kind == Kind::Load && self[value].inputs[1] == region {
|
||||||
|
return Some(store);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut cursor = target;
|
||||||
|
while self[cursor].kind == Kind::Stre
|
||||||
|
&& self[cursor].inputs[1] != VOID
|
||||||
|
&& let &[next_store] = self[cursor].outputs.as_slice()
|
||||||
|
{
|
||||||
|
if self[next_store].inputs[2] == region
|
||||||
|
&& self[next_store].ty == self[target].ty
|
||||||
|
{
|
||||||
|
return Some(store);
|
||||||
|
}
|
||||||
|
cursor = next_store;
|
||||||
|
}
|
||||||
|
|
||||||
'eliminate: {
|
'eliminate: {
|
||||||
if self[target].outputs.is_empty() {
|
if self[target].outputs.is_empty() {
|
||||||
break 'eliminate;
|
break 'eliminate;
|
||||||
|
|
|
@ -1,20 +1,17 @@
|
||||||
deinit:
|
deinit:
|
||||||
ADDI64 r254, r254, -48d
|
ADDI64 r254, r254, -16d
|
||||||
ST r31, r254, 24a, 24h
|
ST r31, r254, 0a, 16h
|
||||||
LD r5, r2, 16a, 8h
|
|
||||||
CP r32, r2
|
CP r32, r2
|
||||||
|
LD r5, r2, 16a, 8h
|
||||||
LI64 r4, 8d
|
LI64 r4, 8d
|
||||||
MUL64 r3, r5, r4
|
MUL64 r3, r5, r4
|
||||||
CP r5, r32
|
CP r5, r32
|
||||||
LD r2, r5, 0a, 8h
|
LD r2, r5, 0a, 8h
|
||||||
JAL r31, r0, :free
|
JAL r31, r0, :free
|
||||||
ADDI64 r33, r254, 0d
|
CP r1, r32
|
||||||
CP r1, r33
|
|
||||||
JAL r31, r0, :new
|
JAL r31, r0, :new
|
||||||
CP r2, r32
|
LD r31, r254, 0a, 16h
|
||||||
BMC r33, r2, 24h
|
ADDI64 r254, r254, 16d
|
||||||
LD r31, r254, 24a, 24h
|
|
||||||
ADDI64 r254, r254, 48d
|
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
free:
|
free:
|
||||||
CP r10, r2
|
CP r10, r2
|
||||||
|
@ -26,23 +23,21 @@ free:
|
||||||
ECA
|
ECA
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -80d
|
ADDI64 r254, r254, -48d
|
||||||
ST r31, r254, 48a, 32h
|
ST r31, r254, 24a, 24h
|
||||||
ADDI64 r32, r254, 24d
|
ADDI64 r32, r254, 0d
|
||||||
CP r1, r32
|
CP r1, r32
|
||||||
JAL r31, r0, :new
|
JAL r31, r0, :new
|
||||||
ADDI64 r33, r254, 0d
|
|
||||||
BMC r32, r33, 24h
|
|
||||||
LI64 r3, 69d
|
LI64 r3, 69d
|
||||||
CP r2, r33
|
CP r2, r32
|
||||||
JAL r31, r0, :push
|
JAL r31, r0, :push
|
||||||
LD r12, r254, 0a, 8h
|
LD r9, r254, 0a, 8h
|
||||||
LD r34, r12, 0a, 8h
|
LD r33, r9, 0a, 8h
|
||||||
CP r2, r33
|
CP r2, r32
|
||||||
JAL r31, r0, :deinit
|
JAL r31, r0, :deinit
|
||||||
CP r1, r34
|
CP r1, r33
|
||||||
LD r31, r254, 48a, 32h
|
LD r31, r254, 24a, 24h
|
||||||
ADDI64 r254, r254, 80d
|
ADDI64 r254, r254, 48d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
malloc:
|
malloc:
|
||||||
CP r9, r2
|
CP r9, r2
|
||||||
|
@ -126,6 +121,6 @@ push:
|
||||||
4: LD r31, r254, 0a, 72h
|
4: LD r31, r254, 0a, 72h
|
||||||
ADDI64 r254, r254, 72d
|
ADDI64 r254, r254, 72d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 980
|
code size: 945
|
||||||
ret: 69
|
ret: 69
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,25 +1,22 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -72d
|
ADDI64 r254, r254, -56d
|
||||||
ST r31, r254, 56a, 16h
|
ST r31, r254, 40a, 16h
|
||||||
ADDI64 r32, r254, 0d
|
LI64 r4, 4d
|
||||||
|
ADDI64 r3, r254, 24d
|
||||||
|
ADDI64 r6, r254, 0d
|
||||||
|
ST r4, r254, 24a, 8h
|
||||||
|
LI64 r32, 1d
|
||||||
|
ST r32, r254, 32a, 8h
|
||||||
|
ST r32, r254, 16a, 8h
|
||||||
|
BMC r3, r6, 16h
|
||||||
JAL r31, r0, :opaque
|
JAL r31, r0, :opaque
|
||||||
ST r1, r254, 0a, 16h
|
ST r1, r254, 0a, 16h
|
||||||
LI64 r6, 4d
|
LD r4, r254, 8a, 8h
|
||||||
ADDI64 r5, r254, 40d
|
ADD64 r7, r4, r32
|
||||||
ADDI64 r8, r254, 16d
|
LD r5, r254, 0a, 8h
|
||||||
ST r6, r254, 40a, 8h
|
SUB64 r1, r5, r7
|
||||||
LI64 r7, 1d
|
LD r31, r254, 40a, 16h
|
||||||
ST r7, r254, 48a, 8h
|
ADDI64 r254, r254, 56d
|
||||||
ST r7, r254, 32a, 8h
|
|
||||||
BMC r5, r8, 16h
|
|
||||||
BMC r32, r8, 16h
|
|
||||||
LD r7, r254, 24a, 8h
|
|
||||||
LD r9, r254, 32a, 8h
|
|
||||||
ADD64 r11, r9, r7
|
|
||||||
LD r9, r254, 16a, 8h
|
|
||||||
SUB64 r1, r9, r11
|
|
||||||
LD r31, r254, 56a, 16h
|
|
||||||
ADDI64 r254, r254, 72d
|
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
opaque:
|
opaque:
|
||||||
ADDI64 r254, r254, -16d
|
ADDI64 r254, r254, -16d
|
||||||
|
@ -31,6 +28,6 @@ opaque:
|
||||||
LD r1, r2, 0a, 16h
|
LD r1, r2, 0a, 16h
|
||||||
ADDI64 r254, r254, 16d
|
ADDI64 r254, r254, 16d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 339
|
code size: 310
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,29 +1,27 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -24d
|
ADDI64 r254, r254, -12d
|
||||||
ST r31, r254, 8a, 16h
|
ST r31, r254, 4a, 8h
|
||||||
ADDI64 r32, r254, 4d
|
ADDI64 r2, r254, 0d
|
||||||
JAL r31, r0, :random_color
|
JAL r31, r0, :random_color
|
||||||
ST r1, r254, 4a, 4h
|
ST r1, r254, 0a, 4h
|
||||||
ADDI64 r5, r254, 0d
|
LD r5, r254, 0a, 1h
|
||||||
BMC r32, r5, 4h
|
LD r8, r254, 1a, 1h
|
||||||
LD r8, r254, 0a, 1h
|
LD r12, r254, 2a, 1h
|
||||||
LD r11, r254, 1a, 1h
|
ANDI r9, r5, 255d
|
||||||
LD r3, r254, 2a, 1h
|
ANDI r1, r8, 255d
|
||||||
ANDI r12, r8, 255d
|
LD r6, r254, 3a, 1h
|
||||||
ANDI r4, r11, 255d
|
ANDI r5, r12, 255d
|
||||||
LD r9, r254, 3a, 1h
|
ADD64 r4, r1, r9
|
||||||
ANDI r8, r3, 255d
|
ANDI r10, r6, 255d
|
||||||
ADD64 r7, r4, r12
|
ADD64 r9, r4, r5
|
||||||
ANDI r1, r9, 255d
|
ADD64 r1, r9, r10
|
||||||
ADD64 r12, r7, r8
|
LD r31, r254, 4a, 8h
|
||||||
ADD64 r1, r12, r1
|
ADDI64 r254, r254, 12d
|
||||||
LD r31, r254, 8a, 16h
|
|
||||||
ADDI64 r254, r254, 24d
|
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
random_color:
|
random_color:
|
||||||
LRA r1, r0, :white
|
LRA r1, r0, :white
|
||||||
LD r1, r1, 0a, 4h
|
LD r1, r1, 0a, 4h
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 257
|
code size: 241
|
||||||
ret: 1020
|
ret: 1020
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -4d
|
ADDI64 r254, r254, -4d
|
||||||
LRA r1, r0, :black
|
LRA r2, r0, :white
|
||||||
ADDI64 r3, r254, 0d
|
ADDI64 r3, r254, 0d
|
||||||
LRA r5, r0, :white
|
BMC r2, r3, 4h
|
||||||
BMC r1, r3, 4h
|
LD r6, r254, 3a, 1h
|
||||||
BMC r5, r3, 4h
|
ANDI r1, r6, 255d
|
||||||
LD r9, r254, 3a, 1h
|
|
||||||
ANDI r1, r9, 255d
|
|
||||||
ADDI64 r254, r254, 4d
|
ADDI64 r254, r254, 4d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 108
|
code size: 92
|
||||||
ret: 255
|
ret: 255
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -72d
|
ADDI64 r254, r254, -56d
|
||||||
ST r31, r254, 48a, 24h
|
ST r31, r254, 32a, 24h
|
||||||
LI64 r3, 4d
|
LI64 r3, 4d
|
||||||
ADDI64 r2, r254, 32d
|
ADDI64 r2, r254, 16d
|
||||||
ST r3, r254, 32a, 8h
|
ST r3, r254, 16a, 8h
|
||||||
LI64 r32, 3d
|
LI64 r32, 3d
|
||||||
ST r32, r254, 40a, 8h
|
ST r32, r254, 24a, 8h
|
||||||
ADDI64 r33, r254, 16d
|
ADDI64 r33, r254, 0d
|
||||||
LD r3, r2, 0a, 16h
|
LD r3, r2, 0a, 16h
|
||||||
JAL r31, r0, :odher_pass
|
JAL r31, r0, :odher_pass
|
||||||
ST r1, r254, 16a, 16h
|
ST r1, r254, 0a, 16h
|
||||||
ADDI64 r2, r254, 0d
|
LD r2, r254, 8a, 8h
|
||||||
BMC r33, r2, 16h
|
JNE r2, r32, :0
|
||||||
LD r4, r254, 8a, 8h
|
CP r2, r33
|
||||||
JNE r4, r32, :0
|
|
||||||
JAL r31, r0, :pass
|
JAL r31, r0, :pass
|
||||||
JMP :1
|
JMP :1
|
||||||
0: LI64 r1, 0d
|
0: LI64 r1, 0d
|
||||||
1: LD r31, r254, 48a, 24h
|
1: LD r31, r254, 32a, 24h
|
||||||
ADDI64 r254, r254, 72d
|
ADDI64 r254, r254, 56d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
odher_pass:
|
odher_pass:
|
||||||
ADDI64 r254, r254, -16d
|
ADDI64 r254, r254, -16d
|
||||||
|
@ -30,6 +29,6 @@ odher_pass:
|
||||||
pass:
|
pass:
|
||||||
LD r1, r2, 0a, 8h
|
LD r1, r2, 0a, 8h
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 318
|
code size: 305
|
||||||
ret: 4
|
ret: 4
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
main:
|
main:
|
||||||
ADDI64 r254, r254, -48d
|
ADDI64 r254, r254, -24d
|
||||||
ST r31, r254, 32a, 16h
|
ST r31, r254, 16a, 8h
|
||||||
ADDI64 r32, r254, 16d
|
ADDI64 r3, r254, 0d
|
||||||
LI64 r4, 0d
|
LI64 r4, 0d
|
||||||
CP r3, r4
|
CP r3, r4
|
||||||
JAL r31, r0, :maina
|
JAL r31, r0, :maina
|
||||||
ST r1, r254, 16a, 16h
|
ST r1, r254, 0a, 16h
|
||||||
ADDI64 r7, r254, 0d
|
LD r8, r254, 12a, 1h
|
||||||
BMC r32, r7, 16h
|
LD r9, r254, 3a, 1h
|
||||||
LD r11, r254, 12a, 1h
|
SUB8 r11, r9, r8
|
||||||
LD r12, r254, 3a, 1h
|
ANDI r1, r11, 255d
|
||||||
SUB8 r2, r12, r11
|
LD r31, r254, 16a, 8h
|
||||||
ANDI r1, r2, 255d
|
ADDI64 r254, r254, 24d
|
||||||
LD r31, r254, 32a, 16h
|
|
||||||
ADDI64 r254, r254, 48d
|
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
maina:
|
maina:
|
||||||
ADDI64 r254, r254, -36d
|
ADDI64 r254, r254, -36d
|
||||||
|
@ -50,6 +48,6 @@ small_struct:
|
||||||
LD r1, r3, 0a, 4h
|
LD r1, r3, 0a, 4h
|
||||||
ADDI64 r254, r254, 4d
|
ADDI64 r254, r254, 4d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 514
|
code size: 498
|
||||||
ret: 2
|
ret: 2
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
Loading…
Reference in a new issue