diff --git a/examples/c/sizeof4.c b/examples/c/sizeof4.c new file mode 100644 index 0000000..965e079 --- /dev/null +++ b/examples/c/sizeof4.c @@ -0,0 +1,6 @@ +int main() +{ + int a = 3; + int b = sizeof(!(a++)); + return a + b; +} diff --git a/examples/ir0/sizeof4.ir b/examples/ir0/sizeof4.ir new file mode 100644 index 0000000..dc2a337 --- /dev/null +++ b/examples/ir0/sizeof4.ir @@ -0,0 +1,20 @@ + +fun i32 @main () { +init: + bid: b0 + allocations: + %l0:i32:a + %l1:i32:b + +block b0: + %b0:i0:unit = store 3:i32 %l0:i32* + %b0:i1:i32 = typecast 4:u64 to i32 + %b0:i2:unit = store %b0:i1:i32 %l1:i32* + %b0:i3:i32 = load %l0:i32* + %b0:i4:i32 = load %l1:i32* + %b0:i5:i32 = add %b0:i3:i32 %b0:i4:i32 + ret %b0:i5:i32 + +block b1: + ret 0:i32 +} diff --git a/examples/ir0/struct.ir b/examples/ir0/struct.ir index 0aa9a80..3861106 100644 --- a/examples/ir0/struct.ir +++ b/examples/ir0/struct.ir @@ -1,5 +1,5 @@ -struct %t0 : { b:[4 x [5 x i32]] } struct %t1 : { a:i8, %anon:struct %t0, c:f64 } +struct %t0 : { b:[4 x [5 x i32]] } fun unit @init (i32, i32, [5 x i32]*) { init: diff --git a/examples/ir0/struct3.ir b/examples/ir0/struct3.ir index 94bc37e..45c87f8 100644 --- a/examples/ir0/struct3.ir +++ b/examples/ir0/struct3.ir @@ -1,5 +1,5 @@ -struct Sub : { m1:i64, m2:i64, m3:i64, m4:i64 } struct Big : { m1:struct Sub, m2:struct Sub, m3:struct Sub } +struct Sub : { m1:i64, m2:i64, m3:i64, m4:i64 } fun struct Big @foo (struct Big) { init: diff --git a/examples/ir1/sizeof4.ir b/examples/ir1/sizeof4.ir new file mode 100644 index 0000000..1c9dd89 --- /dev/null +++ b/examples/ir1/sizeof4.ir @@ -0,0 +1,17 @@ + +fun i32 @main () { +init: + bid: b0 + allocations: + %l0:i32:a + %l1:i32:b + +block b0: + %b0:i0:unit = store 3:i32 %l0:i32* + %b0:i1:i32 = typecast 4:u64 to i32 + %b0:i2:unit = store %b0:i1:i32 %l1:i32* + %b0:i3:i32 = load %l0:i32* + %b0:i4:i32 = load %l1:i32* + %b0:i5:i32 = add %b0:i3:i32 %b0:i4:i32 + ret %b0:i5:i32 +} diff --git a/examples/ir1/struct2.ir b/examples/ir1/struct2.ir index 34dfd17..1afa577 100644 --- a/examples/ir1/struct2.ir +++ b/examples/ir1/struct2.ir @@ -1,5 +1,5 @@ -struct %t1 : { a:i8, %anon:struct %t0, c:i64 } struct %t0 : { b:[4 x i32] } +struct %t1 : { a:i8, %anon:struct %t0, c:i64 } fun i32 @main () { init: diff --git a/examples/ir1/struct3.ir b/examples/ir1/struct3.ir index 81702b5..76bac9d 100644 --- a/examples/ir1/struct3.ir +++ b/examples/ir1/struct3.ir @@ -1,5 +1,5 @@ -struct Big : { m1:struct Sub, m2:struct Sub, m3:struct Sub } struct Sub : { m1:i64, m2:i64, m3:i64, m4:i64 } +struct Big : { m1:struct Sub, m2:struct Sub, m3:struct Sub } fun struct Big @foo (struct Big) { init: diff --git a/examples/ir2/sizeof4.ir b/examples/ir2/sizeof4.ir new file mode 100644 index 0000000..4c07aa5 --- /dev/null +++ b/examples/ir2/sizeof4.ir @@ -0,0 +1,17 @@ + +fun i32 @main () { +init: + bid: b0 + allocations: + %l0:i32:a + %l1:i32:b + +block b0: + %b0:i0:unit = nop + %b0:i1:i32 = typecast 4:u64 to i32 + %b0:i2:unit = nop + %b0:i3:unit = nop + %b0:i4:unit = nop + %b0:i5:i32 = add 3:i32 %b0:i1:i32 + ret %b0:i5:i32 +} diff --git a/examples/ir2/struct.ir b/examples/ir2/struct.ir index 3fd8b7c..bbb95ba 100644 --- a/examples/ir2/struct.ir +++ b/examples/ir2/struct.ir @@ -1,5 +1,5 @@ -struct %t0 : { b:[4 x [5 x i32]] } struct %t1 : { a:i8, %anon:struct %t0, c:f64 } +struct %t0 : { b:[4 x [5 x i32]] } fun unit @init (i32, i32, [5 x i32]*) { init: diff --git a/examples/ir2/struct3.ir b/examples/ir2/struct3.ir index 8d426b1..77f861f 100644 --- a/examples/ir2/struct3.ir +++ b/examples/ir2/struct3.ir @@ -1,5 +1,5 @@ -struct Sub : { m1:i64, m2:i64, m3:i64, m4:i64 } struct Big : { m1:struct Sub, m2:struct Sub, m3:struct Sub } +struct Sub : { m1:i64, m2:i64, m3:i64, m4:i64 } fun struct Big @foo (struct Big) { init: diff --git a/examples/ir3/sizeof4.ir b/examples/ir3/sizeof4.ir new file mode 100644 index 0000000..10560d5 --- /dev/null +++ b/examples/ir3/sizeof4.ir @@ -0,0 +1,12 @@ + +fun i32 @main () { +init: + bid: b0 + allocations: + + +block b0: + %b0:i0:i32 = typecast 4:u64 to i32 + %b0:i1:i32 = add 3:i32 %b0:i0:i32 + ret %b0:i1:i32 +} diff --git a/examples/ir3/struct.ir b/examples/ir3/struct.ir index 651acd7..f55ebf2 100644 --- a/examples/ir3/struct.ir +++ b/examples/ir3/struct.ir @@ -1,5 +1,5 @@ -struct %t0 : { b:[4 x [5 x i32]] } struct %t1 : { a:i8, %anon:struct %t0, c:f64 } +struct %t0 : { b:[4 x [5 x i32]] } fun unit @init (i32, i32, [5 x i32]*) { init: diff --git a/examples/ir3/struct2.ir b/examples/ir3/struct2.ir index 1f2f45b..d1c1273 100644 --- a/examples/ir3/struct2.ir +++ b/examples/ir3/struct2.ir @@ -1,5 +1,5 @@ -struct %t1 : { a:i8, %anon:struct %t0, c:i64 } struct %t0 : { b:[4 x i32] } +struct %t1 : { a:i8, %anon:struct %t0, c:i64 } fun i32 @main () { init: diff --git a/examples/ir4/sizeof4.ir b/examples/ir4/sizeof4.ir new file mode 100644 index 0000000..10560d5 --- /dev/null +++ b/examples/ir4/sizeof4.ir @@ -0,0 +1,12 @@ + +fun i32 @main () { +init: + bid: b0 + allocations: + + +block b0: + %b0:i0:i32 = typecast 4:u64 to i32 + %b0:i1:i32 = add 3:i32 %b0:i0:i32 + ret %b0:i1:i32 +} diff --git a/examples/ir4/struct3.ir b/examples/ir4/struct3.ir index 60e07fe..a5ba47a 100644 --- a/examples/ir4/struct3.ir +++ b/examples/ir4/struct3.ir @@ -1,5 +1,5 @@ -struct Sub : { m1:i64, m2:i64, m3:i64, m4:i64 } struct Big : { m1:struct Sub, m2:struct Sub, m3:struct Sub } +struct Sub : { m1:i64, m2:i64, m3:i64, m4:i64 } fun struct Big @foo (struct Big) { init: diff --git a/examples/opt/complete_cond.ir b/examples/opt/complete_cond.ir index 7c6a51f..973ccef 100644 --- a/examples/opt/complete_cond.ir +++ b/examples/opt/complete_cond.ir @@ -1,3 +1,4 @@ + fun i32 @func_0 () { init: bid: b0 diff --git a/examples/opt/sizeof4.ir b/examples/opt/sizeof4.ir new file mode 100644 index 0000000..10560d5 --- /dev/null +++ b/examples/opt/sizeof4.ir @@ -0,0 +1,12 @@ + +fun i32 @main () { +init: + bid: b0 + allocations: + + +block b0: + %b0:i0:i32 = typecast 4:u64 to i32 + %b0:i1:i32 = add 3:i32 %b0:i0:i32 + ret %b0:i1:i32 +} diff --git a/src/ir/mod.rs b/src/ir/mod.rs index 98aff4b..32b2b29 100644 --- a/src/ir/mod.rs +++ b/src/ir/mod.rs @@ -431,7 +431,7 @@ impl fmt::Display for JumpArg { self.bid, self.args .iter() - .format_with(", ", |a, f| f(&format_args!("{}:{}", a, a.dtype()))) + .format_with(", ", |a, f| f(&format_args!("{}", a))) ) } }