forked from AbleOS/holey-bytes
forgot to mul by 8
This commit is contained in:
parent
aefa7e6405
commit
648bd24d0d
|
@ -553,7 +553,6 @@ main := fn(): int {
|
||||||
|
|
||||||
#### small_struct_assignment
|
#### small_struct_assignment
|
||||||
```hb
|
```hb
|
||||||
|
|
||||||
Color := struct {r: u8, g: u8, b: u8, a: u8}
|
Color := struct {r: u8, g: u8, b: u8, a: u8}
|
||||||
white := Color.(255, 255, 255, 255)
|
white := Color.(255, 255, 255, 255)
|
||||||
black := Color.(0, 0, 0, 0)
|
black := Color.(0, 0, 0, 0)
|
||||||
|
@ -564,6 +563,20 @@ main := fn(): int {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### intcast_store
|
||||||
|
```hb
|
||||||
|
SetMsg := packed struct {a: u8, count: u32, size: u32, src: ^u8, dest: ^u8}
|
||||||
|
set := fn($Expr: type, src: ^Expr, dest: ^Expr, count: uint): u32 {
|
||||||
|
l := SetMsg.(5, @intcast(count), @intcast(@sizeof(Expr)), @bitcast(src), @bitcast(dest))
|
||||||
|
return l.count
|
||||||
|
}
|
||||||
|
|
||||||
|
main := fn(): int {
|
||||||
|
return set(int, &0, &0, 1024)
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
#### wide_ret
|
#### wide_ret
|
||||||
```hb
|
```hb
|
||||||
OemIdent := struct {
|
OemIdent := struct {
|
||||||
|
|
|
@ -2514,7 +2514,7 @@ impl<'a> Codegen<'a> {
|
||||||
return Some(val);
|
return Some(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = (1i64 << self.tys.size_of(val.ty)) - 1;
|
let value = (1i64 << (self.tys.size_of(ty) * 8)) - 1;
|
||||||
let mask = self.ci.nodes.new_node_nop(val.ty, Kind::CInt { value }, [VOID]);
|
let mask = self.ci.nodes.new_node_nop(val.ty, Kind::CInt { value }, [VOID]);
|
||||||
let inps = [VOID, val.id, mask];
|
let inps = [VOID, val.id, mask];
|
||||||
Some(self.ci.nodes.new_node_lit(ty, Kind::BinOp { op: TokenKind::Band }, inps))
|
Some(self.ci.nodes.new_node_lit(ty, Kind::BinOp { op: TokenKind::Band }, inps))
|
||||||
|
@ -4282,15 +4282,13 @@ fn push_up(nodes: &mut Nodes) {
|
||||||
nodes
|
nodes
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(n, _)| n)
|
.map(|(n, _)| n)
|
||||||
.filter(|&n| !nodes.visited.get(n)
|
.filter(|&n| !nodes.visited.get(n) && !matches!(nodes[n].kind, Kind::Arg | Kind::Mem))
|
||||||
&& !matches!(nodes[n].kind, Kind::Arg | Kind::Mem | Kind::End))
|
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
vec![],
|
vec![],
|
||||||
"{:?}",
|
"{:?}",
|
||||||
nodes
|
nodes
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|&(n, nod)| !nodes.visited.get(n)
|
.filter(|&(n, nod)| !nodes.visited.get(n) && !matches!(nod.kind, Kind::Arg | Kind::Mem))
|
||||||
&& !matches!(nod.kind, Kind::Arg | Kind::Mem | Kind::End))
|
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -4468,6 +4466,7 @@ mod tests {
|
||||||
returning_global_struct;
|
returning_global_struct;
|
||||||
small_struct_bitcast;
|
small_struct_bitcast;
|
||||||
small_struct_assignment;
|
small_struct_assignment;
|
||||||
|
intcast_store;
|
||||||
wide_ret;
|
wide_ret;
|
||||||
comptime_min_reg_leak;
|
comptime_min_reg_leak;
|
||||||
different_types;
|
different_types;
|
||||||
|
|
|
@ -4,7 +4,7 @@ main:
|
||||||
LI64 r7, 4d
|
LI64 r7, 4d
|
||||||
LI64 r6, 1d
|
LI64 r6, 1d
|
||||||
LI64 r5, 2d
|
LI64 r5, 2d
|
||||||
LI64 r9, 3d
|
LI64 r9, 255d
|
||||||
LI64 r8, 1d
|
LI64 r8, 1d
|
||||||
LI64 r10, 0d
|
LI64 r10, 0d
|
||||||
ADDI64 r12, r254, 0d
|
ADDI64 r12, r254, 0d
|
||||||
|
|
32
lang/tests/son_tests_intcast_store.txt
Normal file
32
lang/tests/son_tests_intcast_store.txt
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
main:
|
||||||
|
ADDI64 r254, r254, -24d
|
||||||
|
ST r31, r254, 16a, 8h
|
||||||
|
LI64 r4, 1024d
|
||||||
|
LI64 r2, 0d
|
||||||
|
ADDI64 r3, r254, 0d
|
||||||
|
ADDI64 r5, r254, 8d
|
||||||
|
ST r2, r254, 8a, 8h
|
||||||
|
ST r2, r254, 0a, 8h
|
||||||
|
CP r2, r5
|
||||||
|
JAL r31, r0, :set
|
||||||
|
ANDI r1, r1, 4294967295d
|
||||||
|
LD r31, r254, 16a, 8h
|
||||||
|
ADDI64 r254, r254, 24d
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
set:
|
||||||
|
ADDI64 r254, r254, -25d
|
||||||
|
LI64 r9, 8d
|
||||||
|
LI64 r8, 5d
|
||||||
|
ANDI r10, r4, 4294967295d
|
||||||
|
ADDI64 r1, r254, 0d
|
||||||
|
ST r8, r254, 0a, 1h
|
||||||
|
ST r10, r254, 1a, 4h
|
||||||
|
ST r9, r254, 5a, 4h
|
||||||
|
ST r2, r254, 9a, 8h
|
||||||
|
ST r3, r254, 17a, 8h
|
||||||
|
LD r1, r254, 1a, 4h
|
||||||
|
ADDI64 r254, r254, 25d
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
code size: 309
|
||||||
|
ret: 1024
|
||||||
|
status: Ok(())
|
Loading…
Reference in a new issue