mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-16 07:28:52 +00:00
Hotfix mem2reg examples
This commit is contained in:
11
examples/bench/fibonacci.c
Normal file
11
examples/bench/fibonacci.c
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
int fibo(int x) {
|
||||||
|
if (x < 2) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fibo(x - 1) + fibo(x - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int job() {
|
||||||
|
return fibo(25);
|
||||||
|
}
|
||||||
24
examples/bench/meta/driver.c
Normal file
24
examples/bench/meta/driver.c
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
unsigned long read_cycles()
|
||||||
|
{
|
||||||
|
unsigned long cycles;
|
||||||
|
asm volatile ("rdcycle %0" : "=r" (cycles));
|
||||||
|
return cycles;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int job();
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
unsigned long start, end;
|
||||||
|
int answer;
|
||||||
|
|
||||||
|
start = read_cycles();
|
||||||
|
answer = job();
|
||||||
|
end = read_cycles();
|
||||||
|
|
||||||
|
printf("cycles: %lu\n", end - start);
|
||||||
|
printf("answer: %d\n", answer);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -113,7 +113,7 @@ init:
|
|||||||
%l3:i8:w
|
%l3:i8:w
|
||||||
|
|
||||||
block b666:
|
block b666:
|
||||||
%b666:i0:unit = store %l3:*i8 42:i8
|
%b666:i0:unit = store 42:i8 %l3:*i8
|
||||||
%b666:i1:unit = call @sinkptr:*[ret:unit params:(*i8)](%l3:*i8)
|
%b666:i1:unit = call @sinkptr:*[ret:unit params:(*i8)](%l3:*i8)
|
||||||
%b666:i2:i8 = load %l3:*i8
|
%b666:i2:i8 = load %l3:*i8
|
||||||
j b0()
|
j b0()
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ init:
|
|||||||
%l3:i8:w
|
%l3:i8:w
|
||||||
|
|
||||||
block b666:
|
block b666:
|
||||||
%b666:i0:unit = store %l3:*i8 42:i8
|
%b666:i0:unit = store 42:i8 %l3:*i8
|
||||||
%b666:i1:unit = call @sinkptr:*[ret:unit params:(*i8)](%l3:*i8)
|
%b666:i1:unit = call @sinkptr:*[ret:unit params:(*i8)](%l3:*i8)
|
||||||
%b666:i2:i8 = load %l3:*i8
|
%b666:i2:i8 = load %l3:*i8
|
||||||
j b0(undef:i32, undef:i16, undef:i64)
|
j b0(undef:i32, undef:i16, undef:i64)
|
||||||
|
|||||||
Reference in New Issue
Block a user