Changes in / [1319235:c0cc5da]


Ignore:
Location:
src/prelude
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/prelude/Makefile.am

    r1319235 rc0cc5da  
    4343
    4444prelude.cf : prelude-gen.cc
    45         ${AM_V_GEN}${CXX} ${AM_CXXFLAGS} ${CXXFLAGS} ${<} -o prelude-gen -Wall -Wextra -O2 -g -std=c++14
     45        ${AM_V_GEN}${CXX} ${AM_CXXFLAGS} ${CXXFLAGS} ${<} -o prelude-gen
    4646        @./prelude-gen > $@
    4747        @rm ./prelude-gen
     
    6767        rm -rf $(DEPDIR)
    6868
    69 MAINTAINERCLEANFILES = gcc-builtins.c gcc-builtins.cf builtins.cf extras.cf bootloader.c prelude.cf ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}
     69MAINTAINERCLEANFILES = 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  
    281281cfalib_DATA = gcc-builtins.cf builtins.cf extras.cf prelude.cf bootloader.c
    282282noinst_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}}
     283MAINTAINERCLEANFILES = gcc-builtins.c gcc-builtins.cf builtins.cf extras.cf bootloader.c ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}
    284284all: all-am
    285285
     
    512512
    513513prelude.cf : prelude-gen.cc
    514         ${AM_V_GEN}${CXX} ${AM_CXXFLAGS} ${CXXFLAGS} ${<} -o prelude-gen -Wall -Wextra -O2 -g -std=c++14
     514        ${AM_V_GEN}${CXX} ${AM_CXXFLAGS} ${CXXFLAGS} ${<} -o prelude-gen
    515515        @./prelude-gen > $@
    516516        @rm ./prelude-gen
  • src/prelude/prelude-gen.cc

    r1319235 rc0cc5da  
    121121                if(mask & (1 << i)) {
    122122                        result += name;
    123                 } else {
    124                         result.append(name.size(), ' ');
    125123                }
    126124                i++;
     
    150148        cout << endl;
    151149
     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;
    152158        cout << "signed int ?==?( zero_t, zero_t ),                                                     ?!=?( zero_t, zero_t );" << endl;
    153159        cout << "signed int ?==?( one_t, one_t ),                                                       ?!=?( one_t, one_t );" << endl;
     160
    154161        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;
    155166        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
    156181
    157182        for (auto op : arithmeticOperators) {
     
    188213        cout << "// Arithmetic Constructors //" << endl;
    189214        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 
    208215        for (auto type : basicTypes) {
    209216                cout << "void  ?{}(" << type.name << " &);" << endl;
     
    220227        cout << "forall(ftype FT) void  ?{}( FT * volatile &, FT * );" << endl;
    221228
    222         // generate qualifiers
    223         vector<string> qualifiersSingle;
     229        // generate qualifiers for first and second parameters of copy constructors
    224230        vector<pair<const string, const string>> qualifiersPair;
    225231        const unsigned int NQ = 2;
    226232        for(unsigned int lhs = 0; lhs < (1<<NQ); lhs++) {
    227                 // for parameter of default constructor and destructor
    228                 qualifiersSingle.push_back(mask2string(lhs, make_array("const "s, "volatile "s)));
    229 
    230                 // for first and second parameters of copy constructors
    231233                for(unsigned int rhs = 0; rhs < (1<<NQ); rhs++) {
    232234                        if((lhs & rhs) == rhs) {
     
    239241        }
    240242
    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;
    268270        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;
    271271        cout << "forall( ftype FT ) void        ?{}( FT *          & );" << endl;
    272272        cout << "forall( ftype FT ) void        ^?{}( FT *         & );" << endl;
     
    285285
    286286
     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
    287306        for (auto op : pointerOperators) {
    288                 auto forall = [&op]() {
    289                         cout << "forall(dtype DT" << op.sized << ") ";
    290                 };
    291307                for (auto type : { "DT"/*, "void"*/ } ) {
    292308                        auto operands = count(op.name.begin(), op.name.end(), '?');
     
    297313                                                if (operands == 1) {
    298314                                                        for (auto q : qualifiersSingle){
    299                                                                 for (auto q2 : { "        ", "volatile" }) {
    300                                                                         forall();
     315                                                                for (auto q2 : { " ", " volatile " }) {
     316                                                                        cout << "forall(dtype DT" << op.sized <<  ") ";
    301317                                                                        cout << q << type << " * " << op.name << "(";
    302                                                                         cout << q << type << " * " << q2 << " &";
     318                                                                        cout << q << type << " *" << q2 << "&";
    303319                                                                        cout << ");" << endl;
    304320                                                                }
     
    306322                                                } else {
    307323                                                        for (auto q : qualifiersPair){
    308                                                                 for (auto q2 : { "        ", "volatile" }) {
    309                                                                         forall();
     324                                                                for (auto q2 : { " ", " volatile " }) {
     325                                                                        cout << "forall(dtype DT" << op.sized <<  ") ";
    310326                                                                        cout << q.first << type << " * " << op.name << "(";
    311                                                                         cout << q.first << type << " * " << q2 << " &";
     327                                                                        cout << q.first << type << " *" << q2 << "&";
    312328
    313329                                                                        for (int i = 1; i < operands; ++i) {
     
    321337                                        case PtrDiff:
    322338                                                for (auto q : qualifiersSingle){
    323                                                         for (auto q2 : { "        ", "volatile" }) {
    324                                                                 forall();
     339                                                        for (auto q2 : { " ", " volatile " }) {
     340                                                                cout << "forall(dtype DT" << op.sized << ") ";
    325341                                                                cout << q << type << " * " << op.name << "(";
    326                                                                 cout << q << type << " * " << q2 << " &";
     342                                                                cout << q << type << " *" << q2 << "&";
    327343
    328344                                                                for (int i = 1; i < operands; ++i) {
     
    337353                                        }
    338354                        } else {
    339                                 auto name_and_arg1 = [&op, &type](const std::string & q) {
    340                                         if (op.diffReturn == "&") cout << q << type << " &"; // -- qualifiers
    341                                         else if (op.diffReturn != "") cout << op.diffReturn;
    342                                         else cout << q << type << " *";
    343                                         cout << " " << op.name << "(";
    344                                 };
    345355                                switch(op.diffArg2) {
    346356                                        case Normal:
    347357                                                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 << "(";
    350363                                                        for (int i = 0; i < operands; ++i) {
    351364                                                                cout << q << type << " *";
     
    357370                                        case CommPtrDiff:
    358371                                                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;
    362377                                                }
    363378                                                // fallthrough
    364379                                        case PtrDiff:
    365380                                                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;
    369386                                                }
    370387                                                break;
     
    376393        cout << endl;
    377394
    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;
    387405}
    388406
Note: See TracChangeset for help on using the changeset viewer.