aboutsummaryrefslogtreecommitdiff
path: root/test/LLC
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2002-08-01 14:21:05 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2002-08-01 14:21:05 +0000
commit747b3bdc8573d6fecebaa1ae9fa39491136033a4 (patch)
treeb7ae75551977afd672f836ef81355c73aeda8044 /test/LLC
parent2fd5b3da1e1c96e528f4c57ceaae2293fd541789 (diff)
Feature test for stack size bigger than immed. field of SAVE instruction.
Also tests code generation for code with mixed indices. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3197 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/LLC')
-rw-r--r--test/LLC/bigstack.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/test/LLC/bigstack.c b/test/LLC/bigstack.c
new file mode 100644
index 0000000000..eacb76a7c3
--- /dev/null
+++ b/test/LLC/bigstack.c
@@ -0,0 +1,79 @@
+/*===- test/Regression/Transforms/Scalar/DecomposeMultiDimRefs.cpp -----=*
+ *
+ * This is a feature test that checks for correct code generation
+ * of the SAVE instruction when the stack size does not fit in the
+ * immediate field of the SAVE instruction. This happens in main().
+ *===---------------------------------------------------------------------===*/
+
+#include <stdlib.h>
+#include <stdio.h>
+
+typedef struct Flat_struct {
+ char c;
+ float x;
+} Flat_t;
+
+typedef struct Mixed_struct {
+ int N;
+ double A[10];
+ double B[10][10];
+ Flat_t F[10];
+} Mixed_t;
+
+
+double
+AddMixed(Mixed_t* M)
+{
+ double sum = 0;
+ int i, j;
+
+ for (i=0; i < 10; ++i)
+ sum += M->A[i];
+
+ for (i=0; i < 10; ++i)
+ for (j=0; j < 10; ++j)
+ sum += M->B[i][j];
+
+ for (i=0; i < 10; ++i) {
+ sum += (double) M->F[i].c;
+ sum += M->F[i].x;
+ }
+
+ return sum;
+}
+
+void
+InitializeMixed(Mixed_t* M, int base)
+{
+ int i, j;
+
+ for (i=0; i < 10; ++i)
+ M->A[i] = i + base;
+
+ for (i=0; i < 10; ++i)
+ for (j=0; j < 10; ++j)
+ M->B[i][j] = i*10 + j + base;
+
+ for (i=0; i < 10; ++i) {
+ M->F[i].c = 'Q';
+ M->F[i].x = i / 10 + base;
+ }
+}
+
+int
+main(int argc, char** argv)
+{
+ Mixed_t M;
+ Mixed_t MA[4];
+ int i;
+
+ InitializeMixed(&M, 100);
+ printf("Sum(M) = %.2f\n", AddMixed(&M));
+
+ for (i=0; i < 4; i++) {
+ InitializeMixed(&MA[i], 100 * (i+2));
+ printf("Sum(MA[%d]) = %.2f\n", i, AddMixed(&MA[i]));
+ }
+
+ return 0;
+}