mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-14 22:38:46 +00:00
Update skeleton
This commit is contained in:
50
examples/mem2reg/mem2reg.input.ir
Normal file
50
examples/mem2reg/mem2reg.input.ir
Normal file
@@ -0,0 +1,50 @@
|
||||
fun unit @sink {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
|
||||
block b0:
|
||||
%b0:p0:i32
|
||||
ret unit:unit
|
||||
}
|
||||
|
||||
fun i32 @single_block {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
%l0:i32:x
|
||||
|
||||
block b0:
|
||||
%b0:i0:unit = store 42:i32 %l0:*i32
|
||||
%b0:i1:i32 = load %l0:*i32
|
||||
|
||||
%b0:i2:unit = store 37:i32 %l0:*i32
|
||||
%b0:i3:i32 = load %l0:*i32
|
||||
|
||||
%b0:i4:unit = call @sink(%b0:i1:i32)
|
||||
%b0:i5:unit = call @sink(%b0:i3:i32)
|
||||
|
||||
ret 0:i32
|
||||
}
|
||||
|
||||
fun i32 @multi_block {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
%l0:i32:x
|
||||
|
||||
block b0:
|
||||
%b0:i0:unit = store 42:i32 %l0:*i32
|
||||
%b0:i1:i32 = load %l0:*i32
|
||||
|
||||
%b0:i2:unit = store 37:i32 %l0:*i32
|
||||
%b0:i3:i32 = load %l0:*i32
|
||||
|
||||
j b1()
|
||||
|
||||
block b1:
|
||||
%b1:i0:unit = call @sink(%b0:i1:i32)
|
||||
%b1:i1:unit = call @sink(%b0:i3:i32)
|
||||
|
||||
j b0()
|
||||
}
|
||||
50
examples/mem2reg/mem2reg.output.ir
Normal file
50
examples/mem2reg/mem2reg.output.ir
Normal file
@@ -0,0 +1,50 @@
|
||||
fun unit @sink {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
|
||||
block b0:
|
||||
%b0:p0:i32
|
||||
ret unit:unit
|
||||
}
|
||||
|
||||
fun i32 @single_block {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
%l0:i32:x
|
||||
|
||||
block b0:
|
||||
%b0:i0:unit = nop
|
||||
%b0:i1:i32 = load %l0:*i32
|
||||
|
||||
%b0:i2:unit = nop
|
||||
%b0:i3:i32 = load %l0:*i32
|
||||
|
||||
%b0:i4:unit = call @sink(42:i32)
|
||||
%b0:i5:unit = call @sink(37:i32)
|
||||
|
||||
ret 0:i32
|
||||
}
|
||||
|
||||
fun i32 @multi_block {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
%l0:i32:x
|
||||
|
||||
block b0:
|
||||
%b0:i0:unit = nop
|
||||
%b0:i1:i32 = load %l0:*i32
|
||||
|
||||
%b0:i2:unit = nop
|
||||
%b0:i3:i32 = load %l0:*i32
|
||||
|
||||
j b1()
|
||||
|
||||
block b1:
|
||||
%b1:i0:unit = call @sink(42:i32)
|
||||
%b1:i1:unit = call @sink(37:i32)
|
||||
|
||||
j b0()
|
||||
}
|
||||
26
examples/struct.c
Normal file
26
examples/struct.c
Normal file
@@ -0,0 +1,26 @@
|
||||
typedef struct {
|
||||
char a;
|
||||
struct {
|
||||
int b[4][5];
|
||||
};
|
||||
double c;
|
||||
} Temp;
|
||||
|
||||
void init(int row, int col, int arr[4][5]) {
|
||||
for (int i = 0; i < row; i++) {
|
||||
for (int j = 0; j < col; j++) {
|
||||
arr[i][j] = i * j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
Temp temp;
|
||||
int row = 4, col = 5;
|
||||
init(row, col, temp.b);
|
||||
|
||||
Temp temp2;
|
||||
temp2 = temp;
|
||||
|
||||
return temp2.b[2][3] == 6;
|
||||
}
|
||||
18
examples/struct2.c
Normal file
18
examples/struct2.c
Normal file
@@ -0,0 +1,18 @@
|
||||
typedef struct {
|
||||
char a;
|
||||
struct {
|
||||
int b[4];
|
||||
};
|
||||
long c;
|
||||
} Temp;
|
||||
|
||||
int main() {
|
||||
const Temp temp = {1, {{2, 3, 4, 5}}, 6};
|
||||
|
||||
Temp temp2;
|
||||
temp2 = temp;
|
||||
|
||||
int sum = temp2.a + temp2.b[2] + temp2.c;
|
||||
|
||||
return sum == 11;
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
struct color { int number; char name; };
|
||||
|
||||
int f(int i, int const a[i]) {
|
||||
int temp = 0;
|
||||
const float temp2 = 0.f, temp3 = 0.f;
|
||||
temp = sizeof(unsigned char);
|
||||
temp = _Alignof(unsigned char);
|
||||
|
||||
struct color { int number; char name; } c;
|
||||
struct color c;
|
||||
c.name;
|
||||
struct color *cp = &c;
|
||||
cp->name;
|
||||
Reference in New Issue
Block a user