[llvm-commits] CVS: llvm/test/Regression/LLC/globalrefs.c
Vikram Adve
vadve at cs.uiuc.edu
Sat Oct 12 18:48:01 PDT 2002
Changes in directory llvm/test/Regression/LLC:
globalrefs.c updated: 1.1 -> 1.2
---
Log message:
Added inline constant expressions, including uses in binary subtract.
---
Diffs of the changes:
Index: llvm/test/Regression/LLC/globalrefs.c
diff -u llvm/test/Regression/LLC/globalrefs.c:1.1 llvm/test/Regression/LLC/globalrefs.c:1.2
--- llvm/test/Regression/LLC/globalrefs.c:1.1 Fri Sep 27 08:27:14 2002
+++ llvm/test/Regression/LLC/globalrefs.c Sat Oct 12 18:47:36 2002
@@ -1,5 +1,6 @@
-/* globalrefs.c - Test constant expressions constructed from global
- * addresses and index expressions into global addresses.
+/* globalrefs.c - Test symbolic constant expressions constructed from
+ * global addresses and index expressions into global addresses.
+ * Do this both with global constants and with inline constant.
* Instead of printing absolute addresses, print out the differences in
* memory addresses to get output that matches that of the native compiler.
*/
@@ -18,23 +19,51 @@
struct test TestArray[10];
struct test Test1;
-struct test* TestArrayPtr = TestArray;
+/* Create global symbolic constants from the addresses of the above globals */
+
+struct test* TestArrayPtr = &TestArray[3];
long* Aptr = &Test1.A;
-unsigned* Xptr = &Test1.S.X;
+unsigned* Yptr = &Test1.S.Y;
+struct test** NextPtr = &Test1.next;
+
+void
+printdiff(void* p1, void* p2)
+{
+ printf(" 0x%lx", (unsigned long) p1 - (unsigned long) p2);
+}
int
main(int argc, char** argv)
{
- void* a1 = (void*) TestArrayPtr;
- void* a2 = (void*) Aptr;
- void* a3 = (void*) Xptr;
-
-#ifdef WANT_ABSOLUTE_ADDRESSES
- printf("Aptr = 0x%lx, Xptr = 0x%lx, TestArrayPtr = 0x%lx\n",
- Aptr, Xptr, TestArrayPtr);
-#endif
+ unsigned long diff1, diff2, diff3, diff4;
+
+ printf("sizeof(struct Test) = %llu\n\n", sizeof(struct test));
+
+ printdiff(&TestArray[3], TestArray);
+ printdiff(&Test1.A, &TestArray[3]);
+ printdiff(&Test1.S.Y, &Test1.A);
+ printdiff(&Test1.next, &Test1.S.Y);
+ printf("\n");
+
+ diff1 = (unsigned long) &TestArray[3] - (unsigned long) TestArray;
+ diff2 = (unsigned long) &Test1.A - (unsigned long) &TestArray[3];
+ diff3 = (unsigned long) &Test1.S.Y - (unsigned long) &Test1.A;
+ diff4 = (unsigned long) &Test1.next - (unsigned long) &Test1.S.Y;
+
+ printf("&TestArray[3] - TestArray = 0x%lx\n", diff1);
+ printf("Aptr - &TestArray[3] = 0x%lx\n", diff2);
+ printf("Xptr - Aptr = 0x%lx\n", diff3);
+ printf("NextPtr - Xptr = 0x%lx\n\n", diff4);
+
+ diff1 = (unsigned long) TestArrayPtr - (unsigned long) TestArray;
+ diff2 = (unsigned long) Aptr - (unsigned long) TestArrayPtr;
+ diff3 = (unsigned long) Yptr - (unsigned long) Aptr;
+ diff4 = (unsigned long) NextPtr - (unsigned long) Yptr;
+
+ printf("&TestArray[3] - TestArray = 0x%lx\n", diff1);
+ printf("Aptr - &TestArray[3] = 0x%lx\n", diff2);
+ printf("Xptr - Aptr = 0x%lx\n", diff3);
+ printf("NextPtr - Xptr = 0x%lx\n\n", diff4);
- printf("Aptr - TestArrayPtr = 0x%lx, Xptr - Aptr = 0x%lx\n",
- (uint64_t) a2 - (uint64_t) a1, (uint64_t) a3 - (uint64_t) a2);
return 0;
}
More information about the llvm-commits
mailing list