Changes in / [1319235:c0cc5da]
- Location:
- src/prelude
- Files:
-
- 3 edited
-
Makefile.am (modified) (2 diffs)
-
Makefile.in (modified) (2 diffs)
-
prelude-gen.cc (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/prelude/Makefile.am
r1319235 rc0cc5da 43 43 44 44 prelude.cf : prelude-gen.cc 45 ${AM_V_GEN}${CXX} ${AM_CXXFLAGS} ${CXXFLAGS} ${<} -o prelude-gen -Wall -Wextra -O2 -g -std=c++1445 ${AM_V_GEN}${CXX} ${AM_CXXFLAGS} ${CXXFLAGS} ${<} -o prelude-gen 46 46 @./prelude-gen > $@ 47 47 @rm ./prelude-gen … … 67 67 rm -rf $(DEPDIR) 68 68 69 MAINTAINERCLEANFILES = gcc-builtins.c gcc-builtins.cf builtins.cf extras.cf bootloader.c prelude.cf${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}69 MAINTAINERCLEANFILES = gcc-builtins.c gcc-builtins.cf builtins.cf extras.cf bootloader.c ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}} -
src/prelude/Makefile.in
r1319235 rc0cc5da 281 281 cfalib_DATA = gcc-builtins.cf builtins.cf extras.cf prelude.cf bootloader.c 282 282 noinst_DATA = ../libcfa/libcfa-prelude.c 283 MAINTAINERCLEANFILES = gcc-builtins.c gcc-builtins.cf builtins.cf extras.cf bootloader.c prelude.cf${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}283 MAINTAINERCLEANFILES = gcc-builtins.c gcc-builtins.cf builtins.cf extras.cf bootloader.c ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}} 284 284 all: all-am 285 285 … … 512 512 513 513 prelude.cf : prelude-gen.cc 514 ${AM_V_GEN}${CXX} ${AM_CXXFLAGS} ${CXXFLAGS} ${<} -o prelude-gen -Wall -Wextra -O2 -g -std=c++14514 ${AM_V_GEN}${CXX} ${AM_CXXFLAGS} ${CXXFLAGS} ${<} -o prelude-gen 515 515 @./prelude-gen > $@ 516 516 @rm ./prelude-gen -
src/prelude/prelude-gen.cc
r1319235 rc0cc5da 121 121 if(mask & (1 << i)) { 122 122 result += name; 123 } else {124 result.append(name.size(), ' ');125 123 } 126 124 i++; … … 150 148 cout << endl; 151 149 150 cout << "void ?{}( zero_t & );" << endl; 151 cout << "void ?{}( one_t & );" << endl; 152 cout << "void ?{}( zero_t &, zero_t );" << endl; 153 cout << "void ?{}( one_t &, one_t );" << endl; 154 cout << "void ^?{}( zero_t & );" << endl; 155 cout << "void ^?{}( one_t & );" << endl; 156 cout << "zero_t ?=?( zero_t &, zero_t );" << endl; 157 cout << "one_t ?=?( one_t &, one_t );" << endl; 152 158 cout << "signed int ?==?( zero_t, zero_t ), ?!=?( zero_t, zero_t );" << endl; 153 159 cout << "signed int ?==?( one_t, one_t ), ?!=?( one_t, one_t );" << endl; 160 154 161 cout << "signed int ?==?( _Bool, _Bool ), ?!=?( _Bool, _Bool );" << endl; 162 cout << "void ?{}( _Bool & );" << endl; 163 cout << "void ?{}( _Bool &, _Bool );" << endl; 164 cout << "void ^?{}( _Bool & );" << endl; 165 cout << "_Bool ?=?( _Bool &, _Bool ), ?=?( volatile _Bool &, _Bool );" << endl; 155 166 cout << "signed int !?( _Bool );" << endl; 167 168 cout << "void ^?{}( char & );" << endl; 169 cout << "void ^?{}( char unsigned & );" << endl; 170 cout << "void ^?{}( char signed & );" << endl; 171 cout << "void ?{}( char &, char );" << endl; 172 cout << "void ?{}( unsigned char &, unsigned char );" << endl; 173 cout << "void ?{}( char signed &, char signed );" << endl; 174 cout << "void ?{}( char & );" << endl; 175 cout << "void ?{}( unsigned char & );" << endl; 176 cout << "void ?{}( char signed & );" << endl; 177 cout << "char ?=?( char &, char ), ?=?( volatile char &, char );" << endl; 178 cout << "char signed ?=?( char signed &, char signed ), ?=?( volatile char signed &, char signed );" << endl; 179 cout << "char unsigned ?=?( char unsigned &, char unsigned ), ?=?( volatile char unsigned &, char unsigned );" << endl; 180 156 181 157 182 for (auto op : arithmeticOperators) { … … 188 213 cout << "// Arithmetic Constructors //" << endl; 189 214 cout << "/////////////////////////////" << endl; 190 auto otype = [](const std::string & type, bool do_volatile = false) {191 cout << "void \t?{} ( " << type << " & );" << endl;192 cout << "void \t?{} ( " << type << " &, " << type << " );" << endl;193 cout << type << " \t?=? ( " << type << " &, " << type << " )";194 if( do_volatile ) {195 cout << ", \t?=?( volatile " << type << " &, " << type << " )";196 }197 cout << ";" << endl;198 cout << "void \t^?{}( " << type << " & );" << endl;199 };200 201 otype("zero_t");202 otype("one_t");203 otype("_Bool", true);204 otype("char", true);205 otype("signed char", true);206 otype("unsigned char", true);207 208 215 for (auto type : basicTypes) { 209 216 cout << "void ?{}(" << type.name << " &);" << endl; … … 220 227 cout << "forall(ftype FT) void ?{}( FT * volatile &, FT * );" << endl; 221 228 222 // generate qualifiers 223 vector<string> qualifiersSingle; 229 // generate qualifiers for first and second parameters of copy constructors 224 230 vector<pair<const string, const string>> qualifiersPair; 225 231 const unsigned int NQ = 2; 226 232 for(unsigned int lhs = 0; lhs < (1<<NQ); lhs++) { 227 // for parameter of default constructor and destructor228 qualifiersSingle.push_back(mask2string(lhs, make_array("const "s, "volatile "s)));229 230 // for first and second parameters of copy constructors231 233 for(unsigned int rhs = 0; rhs < (1<<NQ); rhs++) { 232 234 if((lhs & rhs) == rhs) { … … 239 241 } 240 242 241 for (auto type : { " DT", "void" }) {242 for (auto cvq : qualifiersPair) {243 for (auto is_vol : { " ", "volatile" }) {244 cout << "forall(dtype DT) void ?{}(" << cvq.first << type << " * " << is_vol << " &, " << cvq.second << "DT *);" << endl;245 }246 } 247 for (auto cvq : qualifiersSingle) { 248 for (auto is_vol : { " ", "volatile" }) {249 cout << "forall(dtype DT) void ?{}(" << cvq << type << " * " << is_vol << " &);" << endl;250 }251 for (auto is_vol : { " ", "volatile" }) {252 cout << "forall(dtype DT) void ^?{}(" << cvq << type << " * " << is_vol << " &);" << endl;253 } 254 }255 }256 257 {258 auto type = " DT";259 for (auto is_vol : { " ", "volatile" }) {260 for (auto cvq : qualifiersSingle) {261 cout << "forall(dtype DT) void ?{}( " << cvq << type << " * " << is_vol << " &, zero_t);" << endl; 262 }263 }264 }265 266 cout << endl;267 243 for (auto type : { "DT", "void" }) { 244 for (auto q : qualifiersPair) { 245 cout << "forall(dtype DT) void ?{}(" << q.first << type << " *&, " << q.second << "DT *);" << endl; 246 } 247 } 248 249 250 // generate qualifiers for parameter of default constructor and destructor 251 vector<string> qualifiersSingle; 252 for (unsigned int lhs = 0; lhs < (1<<NQ); lhs++) { 253 qualifiersSingle.push_back(mask2string(lhs, make_array("const "s, "volatile "s))); 254 } 255 256 for (auto type : { "DT", "void" }) { 257 for (auto q : qualifiersSingle) { 258 cout << "forall(dtype DT) void ?{}(" << q << type << " *&);" << endl; 259 cout << "forall(dtype DT) void ^?{}(" << q << type << " *&);" << endl; 260 } 261 } 262 cout << endl; 263 264 cout << "forall(dtype DT) void ?{}( DT * &, zero_t );" << endl; 265 cout << "forall(dtype DT) void ?{}( DT * volatile &, zero_t );" << endl; 266 cout << "forall(dtype DT) void ?{}( const DT * &, zero_t );" << endl; 267 cout << "forall(dtype DT) void ?{}( volatile DT * &, zero_t );" << endl; 268 cout << "forall(dtype DT) void ?{}( volatile DT * volatile &, zero_t );" << endl; 269 cout << "forall(dtype DT) void ?{}( const volatile DT * &, zero_t );" << endl; 268 270 cout << "forall(ftype FT) void ?{}( FT * &, zero_t ); " << endl; 269 cout << "forall(ftype FT) FT * ?=?( FT * &, zero_t );" << endl;270 cout << "forall(ftype FT) FT * ?=?( FT * volatile &, zero_t );" << endl;271 271 cout << "forall( ftype FT ) void ?{}( FT * & );" << endl; 272 272 cout << "forall( ftype FT ) void ^?{}( FT * & );" << endl; … … 285 285 286 286 287 cout << "forall( dtype DT ) void * ?=?( void * &, DT * );" << endl; 288 cout << "forall( dtype DT ) void * ?=?( void * volatile &, DT * );" << endl; 289 cout << "forall( dtype DT ) const void * ?=?( const void * &, DT * );" << endl; 290 cout << "forall( dtype DT ) const void * ?=?( const void * volatile &, DT * );" << endl; 291 cout << "forall( dtype DT ) const void * ?=?( const void * &, const DT * );" << endl; 292 cout << "forall( dtype DT ) const void * ?=?( const void * volatile &, const DT * );" << endl; 293 cout << "forall( dtype DT ) volatile void * ?=?( volatile void * &, DT * );" << endl; 294 cout << "forall( dtype DT ) volatile void * ?=?( volatile void * volatile &, DT * );" << endl; 295 cout << "forall( dtype DT ) volatile void * ?=?( volatile void * &, volatile DT * );" << endl; 296 cout << "forall( dtype DT ) volatile void * ?=?( volatile void * volatile &, volatile DT * );" << endl; 297 cout << "forall( dtype DT ) const volatile void * ?=?( const volatile void * &, DT * );" << endl; 298 cout << "forall( dtype DT ) const volatile void * ?=?( const volatile void * volatile &, DT * );" << endl; 299 cout << "forall( dtype DT ) const volatile void * ?=?( const volatile void * &, const DT * );" << endl; 300 cout << "forall( dtype DT ) const volatile void * ?=?( const volatile void * volatile &, const DT * );" << endl; 301 cout << "forall( dtype DT ) const volatile void * ?=?( const volatile void * &, volatile DT * );" << endl; 302 cout << "forall( dtype DT ) const volatile void * ?=?( const volatile void * volatile &, volatile DT * );" << endl; 303 cout << "forall( dtype DT ) const volatile void * ?=?( const volatile void * &, const volatile DT * );" << endl; 304 cout << "forall( dtype DT ) const volatile void * ?=?( const volatile void * volatile &, const volatile DT * );" << endl; 305 287 306 for (auto op : pointerOperators) { 288 auto forall = [&op]() {289 cout << "forall(dtype DT" << op.sized << ") ";290 };291 307 for (auto type : { "DT"/*, "void"*/ } ) { 292 308 auto operands = count(op.name.begin(), op.name.end(), '?'); … … 297 313 if (operands == 1) { 298 314 for (auto q : qualifiersSingle){ 299 for (auto q2 : { " ", "volatile" }) {300 forall();315 for (auto q2 : { " ", " volatile " }) { 316 cout << "forall(dtype DT" << op.sized << ") "; 301 317 cout << q << type << " * " << op.name << "("; 302 cout << q << type << " * " << q2 << "&";318 cout << q << type << " *" << q2 << "&"; 303 319 cout << ");" << endl; 304 320 } … … 306 322 } else { 307 323 for (auto q : qualifiersPair){ 308 for (auto q2 : { " ", "volatile" }) {309 forall();324 for (auto q2 : { " ", " volatile " }) { 325 cout << "forall(dtype DT" << op.sized << ") "; 310 326 cout << q.first << type << " * " << op.name << "("; 311 cout << q.first << type << " * " << q2 << "&";327 cout << q.first << type << " *" << q2 << "&"; 312 328 313 329 for (int i = 1; i < operands; ++i) { … … 321 337 case PtrDiff: 322 338 for (auto q : qualifiersSingle){ 323 for (auto q2 : { " ", "volatile" }) {324 forall();339 for (auto q2 : { " ", " volatile " }) { 340 cout << "forall(dtype DT" << op.sized << ") "; 325 341 cout << q << type << " * " << op.name << "("; 326 cout << q << type << " * " << q2 << "&";342 cout << q << type << " *" << q2 << "&"; 327 343 328 344 for (int i = 1; i < operands; ++i) { … … 337 353 } 338 354 } else { 339 auto name_and_arg1 = [&op, &type](const std::string & q) {340 if (op.diffReturn == "&") cout << q << type << " &"; // -- qualifiers341 else if (op.diffReturn != "") cout << op.diffReturn;342 else cout << q << type << " *";343 cout << " " << op.name << "(";344 };345 355 switch(op.diffArg2) { 346 356 case Normal: 347 357 for (auto q : qualifiersSingle) { 348 forall(); 349 name_and_arg1( q ); 358 cout << "forall(dtype DT" << op.sized << ") "; 359 if (op.diffReturn == "&") cout << q << type << " &"; // -- qualifiers 360 else if (op.diffReturn != "") cout << op.diffReturn; 361 else cout << q << type << " *"; 362 cout << " " << op.name << "("; 350 363 for (int i = 0; i < operands; ++i) { 351 364 cout << q << type << " *"; … … 357 370 case CommPtrDiff: 358 371 for (auto q : qualifiersSingle) { 359 forall(); 360 name_and_arg1( q ); 361 cout << "ptrdiff_t, " << q << type << " *);" << endl; 372 cout << "forall(dtype DT" << op.sized << ") "; 373 if (op.diffReturn == "&") cout << q << type << " &"; // -- qualifiers 374 else if (op.diffReturn != "") cout << op.diffReturn; 375 else cout << q << type << " *"; 376 cout << " " << op.name << "(ptrdiff_t, " << q << type << " *);" << endl; 362 377 } 363 378 // fallthrough 364 379 case PtrDiff: 365 380 for (auto q : qualifiersSingle) { 366 forall(); 367 name_and_arg1( q ); 368 cout << q << type << " *, ptrdiff_t);" << endl; 381 cout << "forall(dtype DT" << op.sized << ") "; 382 if (op.diffReturn == "&") cout << q << type << " &"; // -- qualifiers 383 else if (op.diffReturn != "") cout << op.diffReturn; 384 else cout << q << type << " *"; 385 cout << " " << op.name << "(" << q << type << " *, ptrdiff_t);" << endl; 369 386 } 370 387 break; … … 376 393 cout << endl; 377 394 378 for (auto is_vol : { " ", "volatile" }) { 379 for (auto cvq : qualifiersPair) { 380 cout << "forall(dtype DT) " << cvq.first << "void * ?=?( " << cvq.first << "void * " << is_vol << " &, " << cvq.second << "DT *);" << endl; 381 } 382 for (auto cvq : qualifiersSingle) { 383 cout << "forall(dtype DT) " << cvq << " DT * ?=?( " << cvq << " DT * " << is_vol << " &, zero_t);" << endl; 384 } 385 } 386 cout << endl; 395 cout << "forall(dtype DT) DT * ?=?( DT * &, zero_t );" << endl; 396 cout << "forall(dtype DT) DT * ?=?( DT * volatile &, zero_t );" << endl; 397 cout << "forall(dtype DT) const DT * ?=?( const DT * &, zero_t );" << endl; 398 cout << "forall(dtype DT) const DT * ?=?( const DT * volatile &, zero_t );" << endl; 399 cout << "forall(dtype DT) volatile DT * ?=?( volatile DT * &, zero_t );" << endl; 400 cout << "forall(dtype DT) volatile DT * ?=?( volatile DT * volatile &, zero_t );" << endl; 401 cout << "forall(dtype DT) const volatile DT * ?=?( const volatile DT * &, zero_t );" << endl; 402 cout << "forall(dtype DT) const volatile DT * ?=?( const volatile DT * volatile &, zero_t );" << endl; 403 cout << "forall(ftype FT) FT * ?=?( FT * &, zero_t );" << endl; 404 cout << "forall(ftype FT) FT * ?=?( FT * volatile &, zero_t );" << endl; 387 405 } 388 406
Note:
See TracChangeset
for help on using the changeset viewer.