Changeset 821
- Timestamp:
- 12/27/10 07:46:27 (14 years ago)
- Files:
-
- branches/dmd-1.x/src/backend/cdef.h (modified) (1 diff)
- branches/dmd-1.x/src/backend/el.c (modified) (1 diff)
- branches/dmd-1.x/src/backend/el.h (modified) (1 diff)
- branches/dmd-1.x/src/backend/go.c (modified) (1 diff)
- trunk/src/backend/cdef.h (modified) (1 diff)
- trunk/src/backend/el.c (modified) (1 diff)
- trunk/src/backend/el.h (modified) (1 diff)
- trunk/src/backend/go.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/backend/cdef.h
r618 r821 120 120 */ 121 121 122 122 /* Solaris Version 123 123 * ------------- 124 124 * There are two main issues: hosting the compiler on Solaris, 125 125 * and generating (targetting) Solaris executables. 126 126 * The "__sun", "__SVR4" and "__GNUC__" macros control hosting issues 127 127 * for operating system and compiler dependencies, respectively. 128 128 * To target Solaris executables, use ELFOBJ for things specific to the 129 129 * ELF object file format, and TARGET_SOLARIS for things specific to 130 130 * the Solaris memory model. 131 131 * If this is all done right, one could generate a Solaris object file 132 132 * even when compiling on win32, and vice versa. 133 133 * The compiler source code currently uses these macros very inconsistently 134 134 * with these goals, and should be fixed. 135 135 */ 136 136 137 137 #ifndef CDEF_H 138 138 #define CDEF_H 1 139 139 140 #define VERSION "8.5 3.0" // for banner and imbedding in .OBJ file141 #define VERSIONHEX "0x85 3" // for __DMC__ macro142 #define VERSIONINT 0x85 3// for precompiled headers and DLL version140 #define VERSION "8.54.0" // for banner and imbedding in .OBJ file 141 #define VERSIONHEX "0x854" // for __DMC__ macro 142 #define VERSIONINT 0x854 // for precompiled headers and DLL version 143 143 144 144 145 145 /*********************************** 146 146 * Target machine types: 147 147 */ 148 148 149 149 #define TX86 1 // target is Intel 80X86 processor 150 150 #define TARGET_68K 0 // target is a 68K processor 151 151 #define TARGET_POWERPC 0 // target is a PPC processor 152 152 #define TARGET_MAC 0 // target is a macintosh 153 153 154 154 // Set to 1 using the makefile 155 155 #ifndef TARGET_LINUX 156 156 #define TARGET_LINUX 0 // target is a linux executable 157 157 #endif 158 158 159 159 // Set to 1 using the makefile 160 160 #ifndef TARGET_OSX 161 161 #define TARGET_OSX 0 // target is an OSX executable 162 162 #endif branches/dmd-1.x/src/backend/el.c
r807 r821 1870 1870 1871 1871 default: 1872 1872 break; 1873 1873 } 1874 1874 break; 1875 1875 } 1876 1876 return result; 1877 1877 } 1878 1878 1879 1879 /******************************** 1880 1880 * Scan down commas and return the controlling elem. 1881 1881 */ 1882 1882 1883 1883 elem *el_scancommas(elem *e) 1884 1884 { 1885 1885 while (e->Eoper == OPcomma) 1886 1886 e = e->E2; 1887 1887 return e; 1888 1888 } 1889 1889 1890 /*************************** 1891 * Count number of commas in the expression. 1892 */ 1893 1894 int el_countCommas(elem *e) 1895 { int ncommas = 0; 1896 while (1) 1897 { 1898 if (EBIN(e)) 1899 { 1900 ncommas += (e->Eoper == OPcomma) + el_countCommas(e->E2); 1901 } 1902 else if (EUNA(e)) 1903 { 1904 } 1905 else 1906 break; 1907 e = e->E1; 1908 } 1909 return ncommas; 1910 } 1911 1890 1912 #if (TARGET_POWERPC) 1891 1913 void el_convconst(elem *e) 1892 1914 { 1893 1915 1894 1916 int i; 1895 1917 symbol *s; 1896 1918 long * p; 1897 1919 targ_size_t len; 1898 1920 struct CONST_VALUE { 1899 1921 #if !DDRT 1900 1922 long val[2]; // Largest floating constant is 8 bytes 1901 1923 #else 1902 1924 fix!! 1903 1925 #endif 1904 1926 symbol *s; // Symbol for that floating constant 1905 1927 } *pcv; 1906 1928 1907 1929 static list_t value_list; 1908 1930 list_t pcl; 1909 1931 branches/dmd-1.x/src/backend/el.h
r807 r821 154 154 void el_term(void); 155 155 elem_p el_calloc(void); 156 156 void el_free(elem_p); 157 157 elem_p el_combine(elem_p ,elem_p); 158 158 elem_p el_param(elem_p ,elem_p); 159 159 elem_p el_params(elem_p , ...); 160 160 elem *el_params(void **args, int length); 161 161 int el_nparams(elem *e); 162 162 elem_p el_pair(tym_t, elem_p, elem_p); 163 163 #if TX86 || DEBUG 164 164 void el_copy(elem_p ,elem_p); 165 165 #else 166 166 #define el_copy(to,from) {*(to) = *(from);} 167 167 #endif 168 168 elem_p el_alloctmp(tym_t); 169 169 elem_p el_selecte1(elem_p); 170 170 elem_p el_selecte2(elem_p); 171 171 elem_p el_copytree(elem_p); 172 172 void el_replace_sym(elem *e,symbol *s1,symbol *s2); 173 173 elem_p el_scancommas(elem_p); 174 int el_countCommas(elem_p); 174 175 int el_sideeffect(elem_p); 175 176 #if TX86 176 177 int el_depends(elem *ea,elem *eb); 177 178 #endif 178 179 #if LONGLONG 179 180 targ_llong el_tolongt(elem_p); 180 181 targ_llong el_tolong(elem_p); 181 182 #else 182 183 targ_long el_tolongt(elem_p); 183 184 targ_long el_tolong(elem_p); 184 185 #endif 185 186 int el_allbits(elem_p,int); 186 187 int el_signx32(elem_p); 187 188 targ_ldouble el_toldouble(elem_p); 188 189 void el_toconst(elem_p); 189 190 elem_p el_same(elem_p *); 190 191 int el_match(elem_p ,elem_p); 191 192 int el_match2(elem_p ,elem_p); 192 193 int el_match3(elem_p ,elem_p); 193 194 int el_match4(elem_p ,elem_p); branches/dmd-1.x/src/backend/go.c
r428 r821 216 216 cmes ("optfunc()\n"); 217 217 dbg_optprint("optfunc\n"); 218 218 #ifdef DEBUG 219 219 if (debugb) 220 220 { 221 221 dbg_printf("................Before optimization.........\n"); 222 222 WRfunc(); 223 223 } 224 224 #endif 225 225 iter = 0; 226 226 227 227 if (localgot) 228 228 { // Initialize with: 229 229 // localgot = OPgot; 230 230 elem *e = el_long(TYnptr, 0); 231 231 e->Eoper = OPgot; 232 232 e = el_bin(OPeq, TYnptr, el_var(localgot), e); 233 233 startblock->Belem = el_combine(e, startblock->Belem); 234 234 } 235 235 236 // Each pass through the loop can reduce only one level of comma expression. 237 // The infinite loop check needs to take this into account. 238 int iterationLimit = 200; 239 for (b = startblock; b; b = b->Bnext) 240 { 241 if (!b->Belem) 242 continue; 243 int d = el_countCommas(b->Belem); 244 if (d > iterationLimit) 245 iterationLimit = d; 246 } 247 236 248 // Some functions can take enormous amounts of time to optimize. 237 249 // We try to put a lid on it. 238 250 starttime = clock(); 239 251 do 240 252 { 241 253 //printf("iter = %d\n", iter); 242 254 #if TX86 243 //assert(++iter < 80); /* infinite loop check */ 244 assert(++iter < 200); /* infinite loop check */ 255 assert(++iter < iterationLimit); // infinite loop check 245 256 #else 246 257 L1: 247 258 #endif 248 259 #if MARS 249 260 util_progress(); 250 261 #else 251 262 file_progress(); 252 263 #endif 253 264 254 265 //printf("optelem\n"); 255 266 /* canonicalize the trees */ 256 267 for (b = startblock; b; b = b->Bnext) 257 268 if (b->Belem) 258 269 { 259 270 #if DEBUG 260 271 if(debuge) 261 272 { 262 273 dbg_printf("before\n"); 263 274 elem_print(b->Belem); 264 275 //el_check(b->Belem); trunk/src/backend/cdef.h
r618 r821 120 120 */ 121 121 122 122 /* Solaris Version 123 123 * ------------- 124 124 * There are two main issues: hosting the compiler on Solaris, 125 125 * and generating (targetting) Solaris executables. 126 126 * The "__sun", "__SVR4" and "__GNUC__" macros control hosting issues 127 127 * for operating system and compiler dependencies, respectively. 128 128 * To target Solaris executables, use ELFOBJ for things specific to the 129 129 * ELF object file format, and TARGET_SOLARIS for things specific to 130 130 * the Solaris memory model. 131 131 * If this is all done right, one could generate a Solaris object file 132 132 * even when compiling on win32, and vice versa. 133 133 * The compiler source code currently uses these macros very inconsistently 134 134 * with these goals, and should be fixed. 135 135 */ 136 136 137 137 #ifndef CDEF_H 138 138 #define CDEF_H 1 139 139 140 #define VERSION "8.5 3.0" // for banner and imbedding in .OBJ file141 #define VERSIONHEX "0x85 3" // for __DMC__ macro142 #define VERSIONINT 0x85 3// for precompiled headers and DLL version140 #define VERSION "8.54.0" // for banner and imbedding in .OBJ file 141 #define VERSIONHEX "0x854" // for __DMC__ macro 142 #define VERSIONINT 0x854 // for precompiled headers and DLL version 143 143 144 144 145 145 /*********************************** 146 146 * Target machine types: 147 147 */ 148 148 149 149 #define TX86 1 // target is Intel 80X86 processor 150 150 #define TARGET_68K 0 // target is a 68K processor 151 151 #define TARGET_POWERPC 0 // target is a PPC processor 152 152 #define TARGET_MAC 0 // target is a macintosh 153 153 154 154 // Set to 1 using the makefile 155 155 #ifndef TARGET_LINUX 156 156 #define TARGET_LINUX 0 // target is a linux executable 157 157 #endif 158 158 159 159 // Set to 1 using the makefile 160 160 #ifndef TARGET_OSX 161 161 #define TARGET_OSX 0 // target is an OSX executable 162 162 #endif trunk/src/backend/el.c
r807 r821 1870 1870 1871 1871 default: 1872 1872 break; 1873 1873 } 1874 1874 break; 1875 1875 } 1876 1876 return result; 1877 1877 } 1878 1878 1879 1879 /******************************** 1880 1880 * Scan down commas and return the controlling elem. 1881 1881 */ 1882 1882 1883 1883 elem *el_scancommas(elem *e) 1884 1884 { 1885 1885 while (e->Eoper == OPcomma) 1886 1886 e = e->E2; 1887 1887 return e; 1888 1888 } 1889 1889 1890 /*************************** 1891 * Count number of commas in the expression. 1892 */ 1893 1894 int el_countCommas(elem *e) 1895 { int ncommas = 0; 1896 while (1) 1897 { 1898 if (EBIN(e)) 1899 { 1900 ncommas += (e->Eoper == OPcomma) + el_countCommas(e->E2); 1901 } 1902 else if (EUNA(e)) 1903 { 1904 } 1905 else 1906 break; 1907 e = e->E1; 1908 } 1909 return ncommas; 1910 } 1911 1890 1912 #if (TARGET_POWERPC) 1891 1913 void el_convconst(elem *e) 1892 1914 { 1893 1915 1894 1916 int i; 1895 1917 symbol *s; 1896 1918 long * p; 1897 1919 targ_size_t len; 1898 1920 struct CONST_VALUE { 1899 1921 #if !DDRT 1900 1922 long val[2]; // Largest floating constant is 8 bytes 1901 1923 #else 1902 1924 fix!! 1903 1925 #endif 1904 1926 symbol *s; // Symbol for that floating constant 1905 1927 } *pcv; 1906 1928 1907 1929 static list_t value_list; 1908 1930 list_t pcl; 1909 1931 trunk/src/backend/el.h
r807 r821 154 154 void el_term(void); 155 155 elem_p el_calloc(void); 156 156 void el_free(elem_p); 157 157 elem_p el_combine(elem_p ,elem_p); 158 158 elem_p el_param(elem_p ,elem_p); 159 159 elem_p el_params(elem_p , ...); 160 160 elem *el_params(void **args, int length); 161 161 int el_nparams(elem *e); 162 162 elem_p el_pair(tym_t, elem_p, elem_p); 163 163 #if TX86 || DEBUG 164 164 void el_copy(elem_p ,elem_p); 165 165 #else 166 166 #define el_copy(to,from) {*(to) = *(from);} 167 167 #endif 168 168 elem_p el_alloctmp(tym_t); 169 169 elem_p el_selecte1(elem_p); 170 170 elem_p el_selecte2(elem_p); 171 171 elem_p el_copytree(elem_p); 172 172 void el_replace_sym(elem *e,symbol *s1,symbol *s2); 173 173 elem_p el_scancommas(elem_p); 174 int el_countCommas(elem_p); 174 175 int el_sideeffect(elem_p); 175 176 #if TX86 176 177 int el_depends(elem *ea,elem *eb); 177 178 #endif 178 179 #if LONGLONG 179 180 targ_llong el_tolongt(elem_p); 180 181 targ_llong el_tolong(elem_p); 181 182 #else 182 183 targ_long el_tolongt(elem_p); 183 184 targ_long el_tolong(elem_p); 184 185 #endif 185 186 int el_allbits(elem_p,int); 186 187 int el_signx32(elem_p); 187 188 targ_ldouble el_toldouble(elem_p); 188 189 void el_toconst(elem_p); 189 190 elem_p el_same(elem_p *); 190 191 int el_match(elem_p ,elem_p); 191 192 int el_match2(elem_p ,elem_p); 192 193 int el_match3(elem_p ,elem_p); 193 194 int el_match4(elem_p ,elem_p); trunk/src/backend/go.c
r428 r821 216 216 cmes ("optfunc()\n"); 217 217 dbg_optprint("optfunc\n"); 218 218 #ifdef DEBUG 219 219 if (debugb) 220 220 { 221 221 dbg_printf("................Before optimization.........\n"); 222 222 WRfunc(); 223 223 } 224 224 #endif 225 225 iter = 0; 226 226 227 227 if (localgot) 228 228 { // Initialize with: 229 229 // localgot = OPgot; 230 230 elem *e = el_long(TYnptr, 0); 231 231 e->Eoper = OPgot; 232 232 e = el_bin(OPeq, TYnptr, el_var(localgot), e); 233 233 startblock->Belem = el_combine(e, startblock->Belem); 234 234 } 235 235 236 // Each pass through the loop can reduce only one level of comma expression. 237 // The infinite loop check needs to take this into account. 238 int iterationLimit = 200; 239 for (b = startblock; b; b = b->Bnext) 240 { 241 if (!b->Belem) 242 continue; 243 int d = el_countCommas(b->Belem); 244 if (d > iterationLimit) 245 iterationLimit = d; 246 } 247 236 248 // Some functions can take enormous amounts of time to optimize. 237 249 // We try to put a lid on it. 238 250 starttime = clock(); 239 251 do 240 252 { 241 253 //printf("iter = %d\n", iter); 242 254 #if TX86 243 //assert(++iter < 80); /* infinite loop check */ 244 assert(++iter < 200); /* infinite loop check */ 255 assert(++iter < iterationLimit); // infinite loop check 245 256 #else 246 257 L1: 247 258 #endif 248 259 #if MARS 249 260 util_progress(); 250 261 #else 251 262 file_progress(); 252 263 #endif 253 264 254 265 //printf("optelem\n"); 255 266 /* canonicalize the trees */ 256 267 for (b = startblock; b; b = b->Bnext) 257 268 if (b->Belem) 258 269 { 259 270 #if DEBUG 260 271 if(debuge) 261 272 { 262 273 dbg_printf("before\n"); 263 274 elem_print(b->Belem); 264 275 //el_check(b->Belem);
