diff options
author | Harald Welte <laforge@gnumonks.org> | 2015-10-25 21:00:20 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2015-10-25 21:00:20 +0100 |
commit | fca59bea770346cf1c1f9b0e00cb48a61b44a8f3 (patch) | |
tree | a2011270df48d3501892ac1a56015c8be57e8a7d /2005/flow-accounting-ols2005/OLS2005/EXAMPLE/complexCode/Figures |
import of old now defunct presentation slides svn repo
Diffstat (limited to '2005/flow-accounting-ols2005/OLS2005/EXAMPLE/complexCode/Figures')
-rw-r--r-- | 2005/flow-accounting-ols2005/OLS2005/EXAMPLE/complexCode/Figures/example.c | 18 | ||||
-rw-r--r-- | 2005/flow-accounting-ols2005/OLS2005/EXAMPLE/complexCode/Figures/example.ll | 22 |
2 files changed, 40 insertions, 0 deletions
diff --git a/2005/flow-accounting-ols2005/OLS2005/EXAMPLE/complexCode/Figures/example.c b/2005/flow-accounting-ols2005/OLS2005/EXAMPLE/complexCode/Figures/example.c new file mode 100644 index 0000000..34d1726 --- /dev/null +++ b/2005/flow-accounting-ols2005/OLS2005/EXAMPLE/complexCode/Figures/example.c @@ -0,0 +1,18 @@ +typedef struct QuadTree { + double Data; + struct QuadTree *Children[4]; +} QT; + +void Sum3rdChildren(QT *T, + double *Result) { + double Ret; + if (T == 0) { Ret = 0; + } else { + QT *Child3 = + T[0].Children[3]; + double V; + Sum3rdChildren(Child3, &V); + Ret = V + T[0].Data; + } + *Result = Ret; +} diff --git a/2005/flow-accounting-ols2005/OLS2005/EXAMPLE/complexCode/Figures/example.ll b/2005/flow-accounting-ols2005/OLS2005/EXAMPLE/complexCode/Figures/example.ll new file mode 100644 index 0000000..f9ce373 --- /dev/null +++ b/2005/flow-accounting-ols2005/OLS2005/EXAMPLE/complexCode/Figures/example.ll @@ -0,0 +1,22 @@ +%struct.QuadTree = type { double, [4 x %QT*] } +%QT = type %struct.QuadTree + +void %Sum3rdChildren(%QT* %T, double* %Result) { +entry: %V = alloca double ;; %V is type 'double*' + %tmp.0 = seteq %QT* %T, null ;; type 'bool' + br bool %tmp.0, label %endif, label %else + +else: ;;tmp.1 = &T[0].Children[3] 'Children' = Field #1 + %tmp.1 = getelementptr %QT* %T, long 0, ubyte 1, long 3 + %Child3 = load %QT** %tmp.1 + call void %Sum3rdChildren(%QT* %Child3, double* %V) + %tmp.2 = load double* %V + %tmp.3 = getelementptr %QT* %T, long 0, ubyte 0 + %tmp.4 = load double* %tmp.3 + %tmp.5 = add double %tmp.2, %tmp.4 + br label %endif + +endif: %Ret = phi double [ %tmp.5, %else ], [ 0.0, %entry ] + store double %Ret, double* %Result + ret void ;; Return with no value +} |