1 //===- subzero/crosstest/test_global.cpp - Global variable access tests ---===//
3 // The Subzero Code Generator
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Implementation for crosstesting global variable access operations.
12 //===----------------------------------------------------------------------===//
17 #include "test_global.h"
19 // Note: The following take advantage of the fact that external global
20 // names are not mangled with the --prefix CL argument. Hence, they
21 // should have the same relocation value for both llc and Subzero.
22 extern uint8_t *ExternName1;
23 extern uint8_t *ExternName2;
24 extern uint8_t *ExternName3;
25 extern uint8_t *ExternName4;
26 extern uint8_t *ExternName5;
28 // Partially initialized array
29 int ArrayInitPartial[10] = {60, 70, 80, 90, 100};
30 int ArrayInitFull[] = {10, 20, 30, 40, 50};
31 const int ArrayConst[] = {-10, -20, -30};
32 static double ArrayDouble[10] = { 0.5, 1.5, 2.5, 3.5 };
46 { 10, 20, 30, 40, 50 },
50 { ExternName3, {1000, 1010, 1020}, ExternName2 },
55 { (uint8_t *)(a), sizeof(a) }
57 // Note: By embedding the array addresses in this table, we are indirectly
58 // testing relocations (i.e. getArray would return the wrong address if
59 // relocations are broken).
61 uint8_t *ArrayAddress;
62 size_t ArraySizeInBytes;
64 ARRAY(ArrayInitPartial),
68 {(uint8_t *)(ArrayInitPartial + 2),
69 sizeof(ArrayInitPartial) - 2 * sizeof(int)},
70 { (uint8_t*)(&StructEx), sizeof(StructEx) },
72 size_t NumArraysElements = sizeof(Arrays) / sizeof(*Arrays);
74 size_t getNumArrays() { return NumArraysElements; }
76 const uint8_t *getArray(size_t WhichArray, size_t &Len) {
77 if (WhichArray >= NumArraysElements) {
81 Len = Arrays[WhichArray].ArraySizeInBytes;
82 return Arrays[WhichArray].ArrayAddress;