forked from AbleOS/holey-bytes
removing needless copy into ret register
This commit is contained in:
parent
ec4499e519
commit
baa70d3f12
|
@ -238,11 +238,11 @@ impl HbvmBackend {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.ty.loc(tys) == Loc::Stack
|
if node.ty.loc(tys) == Loc::Stack {
|
||||||
&& let Some(PLoc::Reg(r, ..) | PLoc::WideReg(r, ..) | PLoc::Ref(r, ..)) =
|
|
||||||
ret
|
|
||||||
{
|
|
||||||
alloc_buf.push(atr(*node.inputs.last().unwrap()));
|
alloc_buf.push(atr(*node.inputs.last().unwrap()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(PLoc::Ref(r, ..)) = ret {
|
||||||
self.emit(instrs::cp(r, *alloc_buf.last().unwrap()))
|
self.emit(instrs::cp(r, *alloc_buf.last().unwrap()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ main:
|
||||||
ADDI64 r254, r254, -160d
|
ADDI64 r254, r254, -160d
|
||||||
ST r31, r254, 80a, 80h
|
ST r31, r254, 80a, 80h
|
||||||
LRA r32, r0, :glob_stru
|
LRA r32, r0, :glob_stru
|
||||||
CP r1, r32
|
|
||||||
JAL r31, r0, :new_stru
|
JAL r31, r0, :new_stru
|
||||||
ST r1, r32, 0a, 16h
|
ST r1, r32, 0a, 16h
|
||||||
CP r33, r0
|
CP r33, r0
|
||||||
|
@ -65,7 +64,6 @@ main:
|
||||||
JMP :7
|
JMP :7
|
||||||
3: MULI64 r39, r32, 16d
|
3: MULI64 r39, r32, 16d
|
||||||
ADD64 r39, r37, r39
|
ADD64 r39, r37, r39
|
||||||
CP r1, r39
|
|
||||||
JAL r31, r0, :new_stru
|
JAL r31, r0, :new_stru
|
||||||
ST r1, r39, 0a, 16h
|
ST r1, r39, 0a, 16h
|
||||||
ADD64 r32, r32, r35
|
ADD64 r32, r32, r35
|
||||||
|
@ -83,6 +81,6 @@ new_stru:
|
||||||
LD r32, r254, 16a, 8h
|
LD r32, r254, 16a, 8h
|
||||||
ADDI64 r254, r254, 24d
|
ADDI64 r254, r254, 24d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 797
|
code size: 791
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -2,8 +2,7 @@ main:
|
||||||
ADDI64 r254, r254, -38d
|
ADDI64 r254, r254, -38d
|
||||||
ST r31, r254, 6a, 32h
|
ST r31, r254, 6a, 32h
|
||||||
ADDI64 r32, r254, 0d
|
ADDI64 r32, r254, 0d
|
||||||
2: CP r1, r32
|
2: JAL r31, r0, :return_fn
|
||||||
JAL r31, r0, :return_fn
|
|
||||||
ST r1, r32, 0a, 6h
|
ST r1, r32, 0a, 6h
|
||||||
LD r33, r254, 0a, 1h
|
LD r33, r254, 0a, 1h
|
||||||
ANDI r33, r33, 255d
|
ANDI r33, r33, 255d
|
||||||
|
@ -30,6 +29,6 @@ return_fn:
|
||||||
LD r32, r254, 6a, 16h
|
LD r32, r254, 6a, 16h
|
||||||
ADDI64 r254, r254, 22d
|
ADDI64 r254, r254, 22d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 317
|
code size: 314
|
||||||
ret: 1
|
ret: 1
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -4,7 +4,6 @@ foo:
|
||||||
ADDI64 r32, r254, 64d
|
ADDI64 r32, r254, 64d
|
||||||
LRA r33, r0, :some_file
|
LRA r33, r0, :some_file
|
||||||
CP r3, r33
|
CP r3, r33
|
||||||
CP r1, r32
|
|
||||||
JAL r31, r0, :get
|
JAL r31, r0, :get
|
||||||
ST r1, r32, 0a, 16h
|
ST r1, r32, 0a, 16h
|
||||||
LD r33, r254, 64a, 1h
|
LD r33, r254, 64a, 1h
|
||||||
|
@ -63,7 +62,6 @@ main:
|
||||||
ADDI64 r254, r254, -48d
|
ADDI64 r254, r254, -48d
|
||||||
ST r31, r254, 16a, 32h
|
ST r31, r254, 16a, 32h
|
||||||
ADDI64 r32, r254, 0d
|
ADDI64 r32, r254, 0d
|
||||||
CP r1, r32
|
|
||||||
JAL r31, r0, :foo
|
JAL r31, r0, :foo
|
||||||
ST r1, r32, 0a, 16h
|
ST r1, r32, 0a, 16h
|
||||||
LD r33, r254, 0a, 1h
|
LD r33, r254, 0a, 1h
|
||||||
|
@ -77,6 +75,6 @@ main:
|
||||||
1: LD r31, r254, 16a, 32h
|
1: LD r31, r254, 16a, 32h
|
||||||
ADDI64 r254, r254, 48d
|
ADDI64 r254, r254, 48d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 771
|
code size: 765
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -7,7 +7,6 @@ main:
|
||||||
CP r1, r33
|
CP r1, r33
|
||||||
JAL r31, r0, :returner_bn
|
JAL r31, r0, :returner_bn
|
||||||
ADDI64 r34, r254, 0d
|
ADDI64 r34, r254, 0d
|
||||||
CP r1, r34
|
|
||||||
JAL r31, r0, :returner_cn
|
JAL r31, r0, :returner_cn
|
||||||
ST r1, r34, 0a, 2h
|
ST r1, r34, 0a, 2h
|
||||||
LD r33, r254, 2a, 1h
|
LD r33, r254, 2a, 1h
|
||||||
|
@ -62,6 +61,6 @@ returner_fn:
|
||||||
LD r32, r254, 0a, 8h
|
LD r32, r254, 0a, 8h
|
||||||
ADDI64 r254, r254, 8d
|
ADDI64 r254, r254, 8d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 566
|
code size: 563
|
||||||
ret: 1
|
ret: 1
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -55,7 +55,6 @@ main:
|
||||||
CP r1, r32
|
CP r1, r32
|
||||||
JMP :3
|
JMP :3
|
||||||
9: ADDI64 r33, r254, 40d
|
9: ADDI64 r33, r254, 40d
|
||||||
CP r1, r33
|
|
||||||
JAL r31, r0, :new_foo
|
JAL r31, r0, :new_foo
|
||||||
ST r1, r33, 0a, 16h
|
ST r1, r33, 0a, 16h
|
||||||
LD r37, r254, 40a, 8h
|
LD r37, r254, 40a, 8h
|
||||||
|
@ -68,7 +67,6 @@ main:
|
||||||
LD r2, r33, 0a, 16h
|
LD r2, r33, 0a, 16h
|
||||||
JAL r31, r0, :use_foo
|
JAL r31, r0, :use_foo
|
||||||
ADDI64 r33, r254, 0d
|
ADDI64 r33, r254, 0d
|
||||||
CP r1, r33
|
|
||||||
JAL r31, r0, :no_foo
|
JAL r31, r0, :no_foo
|
||||||
ST r1, r33, 0a, 16h
|
ST r1, r33, 0a, 16h
|
||||||
JAL r31, r0, :decide
|
JAL r31, r0, :decide
|
||||||
|
@ -150,6 +148,6 @@ use_foo:
|
||||||
CP r0, r4
|
CP r0, r4
|
||||||
ADDI64 r254, r254, 16d
|
ADDI64 r254, r254, 16d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 1252
|
code size: 1246
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -6,7 +6,6 @@ main:
|
||||||
CP r4, r0
|
CP r4, r0
|
||||||
CP r5, r0
|
CP r5, r0
|
||||||
CP r6, r0
|
CP r6, r0
|
||||||
CP r1, r13
|
|
||||||
ECA
|
ECA
|
||||||
ST r1, r13, 0a, 16h
|
ST r1, r13, 0a, 16h
|
||||||
LD r14, r254, 0a, 1h
|
LD r14, r254, 0a, 1h
|
||||||
|
@ -19,6 +18,6 @@ main:
|
||||||
ADDI64 r254, r254, 32d
|
ADDI64 r254, r254, 32d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
unknown ecall: 0
|
unknown ecall: 0
|
||||||
code size: 153
|
code size: 150
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Err(Unreachable)
|
||||||
|
|
|
@ -7,7 +7,6 @@ main:
|
||||||
LI64 r34, 4d
|
LI64 r34, 4d
|
||||||
ST r34, r254, 0a, 8h
|
ST r34, r254, 0a, 8h
|
||||||
ST r33, r254, 8a, 8h
|
ST r33, r254, 8a, 8h
|
||||||
CP r1, r32
|
|
||||||
JAL r31, r0, :opaque
|
JAL r31, r0, :opaque
|
||||||
ST r1, r32, 0a, 16h
|
ST r1, r32, 0a, 16h
|
||||||
LD r34, r254, 8a, 8h
|
LD r34, r254, 8a, 8h
|
||||||
|
@ -31,6 +30,6 @@ opaque:
|
||||||
LD r32, r254, 16a, 16h
|
LD r32, r254, 16a, 16h
|
||||||
ADDI64 r254, r254, 32d
|
ADDI64 r254, r254, 32d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 339
|
code size: 336
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -2,7 +2,6 @@ main:
|
||||||
ADDI64 r254, r254, -60d
|
ADDI64 r254, r254, -60d
|
||||||
ST r31, r254, 4a, 56h
|
ST r31, r254, 4a, 56h
|
||||||
ADDI64 r32, r254, 0d
|
ADDI64 r32, r254, 0d
|
||||||
CP r1, r32
|
|
||||||
JAL r31, r0, :random_color
|
JAL r31, r0, :random_color
|
||||||
ST r1, r32, 0a, 4h
|
ST r1, r32, 0a, 4h
|
||||||
LD r34, r254, 0a, 1h
|
LD r34, r254, 0a, 1h
|
||||||
|
@ -28,6 +27,6 @@ random_color:
|
||||||
LD r32, r254, 0a, 8h
|
LD r32, r254, 0a, 8h
|
||||||
ADDI64 r254, r254, 8d
|
ADDI64 r254, r254, 8d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 295
|
code size: 292
|
||||||
ret: 1020
|
ret: 1020
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -15,7 +15,6 @@ main:
|
||||||
ADDI64 r254, r254, -48d
|
ADDI64 r254, r254, -48d
|
||||||
ST r31, r254, 16a, 32h
|
ST r31, r254, 16a, 32h
|
||||||
ADDI64 r32, r254, 0d
|
ADDI64 r32, r254, 0d
|
||||||
CP r1, r32
|
|
||||||
JAL r31, r0, :get_format
|
JAL r31, r0, :get_format
|
||||||
ST r1, r32, 0a, 16h
|
ST r1, r32, 0a, 16h
|
||||||
LD r33, r254, 0a, 1h
|
LD r33, r254, 0a, 1h
|
||||||
|
@ -29,6 +28,6 @@ main:
|
||||||
1: LD r31, r254, 16a, 32h
|
1: LD r31, r254, 16a, 32h
|
||||||
ADDI64 r254, r254, 48d
|
ADDI64 r254, r254, 48d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 304
|
code size: 301
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -17,7 +17,6 @@ main:
|
||||||
ST r31, r254, 16a, 24h
|
ST r31, r254, 16a, 24h
|
||||||
ADDI64 r32, r254, 0d
|
ADDI64 r32, r254, 0d
|
||||||
CP r3, r0
|
CP r3, r0
|
||||||
CP r1, r32
|
|
||||||
JAL r31, r0, :constructor
|
JAL r31, r0, :constructor
|
||||||
ST r1, r32, 0a, 16h
|
ST r1, r32, 0a, 16h
|
||||||
LD r31, r254, 16a, 24h
|
LD r31, r254, 16a, 24h
|
||||||
|
@ -35,6 +34,6 @@ opaque:
|
||||||
LD r32, r254, 0a, 16h
|
LD r32, r254, 0a, 16h
|
||||||
ADDI64 r254, r254, 16d
|
ADDI64 r254, r254, 16d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 330
|
code size: 327
|
||||||
ret: 255
|
ret: 255
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -5,7 +5,6 @@ main:
|
||||||
ADDI64 r33, r254, 0d
|
ADDI64 r33, r254, 0d
|
||||||
LD r32, r32, 0a, 4h
|
LD r32, r32, 0a, 4h
|
||||||
CP r2, r32
|
CP r2, r32
|
||||||
CP r1, r33
|
|
||||||
JAL r31, r0, :u32_to_color
|
JAL r31, r0, :u32_to_color
|
||||||
ST r1, r33, 0a, 4h
|
ST r1, r33, 0a, 4h
|
||||||
LD r32, r254, 0a, 1h
|
LD r32, r254, 0a, 1h
|
||||||
|
@ -35,6 +34,6 @@ u32_to_u32:
|
||||||
LD r32, r254, 0a, 8h
|
LD r32, r254, 0a, 8h
|
||||||
ADDI64 r254, r254, 8d
|
ADDI64 r254, r254, 8d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 332
|
code size: 329
|
||||||
ret: 255
|
ret: 255
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -28,7 +28,6 @@ main:
|
||||||
JAL r31, r0, :do_stuff
|
JAL r31, r0, :do_stuff
|
||||||
CP r32, r1
|
CP r32, r1
|
||||||
ADDI64 r33, r254, 0d
|
ADDI64 r33, r254, 0d
|
||||||
CP r1, r33
|
|
||||||
JAL r31, r0, :optional
|
JAL r31, r0, :optional
|
||||||
ST r1, r33, 0a, 16h
|
ST r1, r33, 0a, 16h
|
||||||
LD r33, r254, 0a, 1h
|
LD r33, r254, 0a, 1h
|
||||||
|
@ -76,6 +75,6 @@ optionala:
|
||||||
LD r32, r254, 48a, 32h
|
LD r32, r254, 48a, 32h
|
||||||
ADDI64 r254, r254, 80d
|
ADDI64 r254, r254, 80d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 673
|
code size: 670
|
||||||
ret: 100
|
ret: 100
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -15,15 +15,12 @@ main:
|
||||||
ADDI64 r254, r254, -96d
|
ADDI64 r254, r254, -96d
|
||||||
ST r31, r254, 48a, 48h
|
ST r31, r254, 48a, 48h
|
||||||
ADDI64 r32, r254, 32d
|
ADDI64 r32, r254, 32d
|
||||||
CP r1, r32
|
|
||||||
JAL r31, r0, :foo
|
JAL r31, r0, :foo
|
||||||
ST r1, r32, 0a, 16h
|
ST r1, r32, 0a, 16h
|
||||||
ADDI64 r33, r254, 16d
|
ADDI64 r33, r254, 16d
|
||||||
CP r1, r33
|
|
||||||
JAL r31, r0, :foo
|
JAL r31, r0, :foo
|
||||||
ST r1, r33, 0a, 16h
|
ST r1, r33, 0a, 16h
|
||||||
ADDI64 r34, r254, 0d
|
ADDI64 r34, r254, 0d
|
||||||
CP r1, r34
|
|
||||||
JAL r31, r0, :foo
|
JAL r31, r0, :foo
|
||||||
ST r1, r34, 0a, 16h
|
ST r1, r34, 0a, 16h
|
||||||
LD r33, r254, 24a, 4h
|
LD r33, r254, 24a, 4h
|
||||||
|
@ -39,6 +36,6 @@ main:
|
||||||
LD r31, r254, 48a, 48h
|
LD r31, r254, 48a, 48h
|
||||||
ADDI64 r254, r254, 96d
|
ADDI64 r254, r254, 96d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 393
|
code size: 384
|
||||||
ret: 0
|
ret: 0
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -7,7 +7,6 @@ main:
|
||||||
LI64 r32, 3d
|
LI64 r32, 3d
|
||||||
ST r32, r254, 24a, 8h
|
ST r32, r254, 24a, 8h
|
||||||
ADDI64 r34, r254, 0d
|
ADDI64 r34, r254, 0d
|
||||||
CP r1, r34
|
|
||||||
LD r3, r33, 0a, 16h
|
LD r3, r33, 0a, 16h
|
||||||
JAL r31, r0, :odher_pass
|
JAL r31, r0, :odher_pass
|
||||||
ST r1, r34, 0a, 16h
|
ST r1, r34, 0a, 16h
|
||||||
|
@ -41,6 +40,6 @@ pass:
|
||||||
LD r32, r254, 0a, 8h
|
LD r32, r254, 0a, 8h
|
||||||
ADDI64 r254, r254, 8d
|
ADDI64 r254, r254, 8d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 390
|
code size: 387
|
||||||
ret: 4
|
ret: 4
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
|
@ -4,7 +4,6 @@ main:
|
||||||
ADDI64 r32, r254, 0d
|
ADDI64 r32, r254, 0d
|
||||||
CP r3, r0
|
CP r3, r0
|
||||||
CP r4, r0
|
CP r4, r0
|
||||||
CP r1, r32
|
|
||||||
JAL r31, r0, :maina
|
JAL r31, r0, :maina
|
||||||
ST r1, r32, 0a, 16h
|
ST r1, r32, 0a, 16h
|
||||||
LD r34, r254, 12a, 1h
|
LD r34, r254, 12a, 1h
|
||||||
|
@ -21,7 +20,6 @@ maina:
|
||||||
CP r0, r3
|
CP r0, r3
|
||||||
CP r0, r4
|
CP r0, r4
|
||||||
ADDI64 r32, r254, 16d
|
ADDI64 r32, r254, 16d
|
||||||
CP r1, r32
|
|
||||||
JAL r31, r0, :small_struct
|
JAL r31, r0, :small_struct
|
||||||
ST r1, r32, 0a, 4h
|
ST r1, r32, 0a, 4h
|
||||||
ADDI64 r33, r254, 0d
|
ADDI64 r33, r254, 0d
|
||||||
|
@ -57,6 +55,6 @@ small_struct:
|
||||||
LD r32, r254, 4a, 8h
|
LD r32, r254, 4a, 8h
|
||||||
ADDI64 r254, r254, 12d
|
ADDI64 r254, r254, 12d
|
||||||
JALA r0, r31, 0a
|
JALA r0, r31, 0a
|
||||||
code size: 597
|
code size: 591
|
||||||
ret: 2
|
ret: 2
|
||||||
status: Ok(())
|
status: Ok(())
|
||||||
|
|
Loading…
Reference in a new issue