Changes in / [cde1bf9:af333e3]
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/Makefile
rcde1bf9 raf333e3 31 31 ${GLOSSARY} ${BUILD}/${BASE} 32 32 ${LATEX} ${BASE} 33 ${LATEX} ${BASE} 33 34 34 35 ${DOC}: ${BUILD}/${DOC} -
doc/theses/andrew_beach_MMath/cfalab.sty
rcde1bf9 raf333e3 27 27 % Cforall with the forall symbol. 28 28 \newsymbolcmd\CFA{\textsf{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}} 29 % C++ with kerning. (No standard number support.)30 \newsymbolcmd\CPP{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}}31 32 % This is executed very early in the \begin{document} code.33 \AtEndPreamble{34 \@ifpackageloaded{hyperref}{35 % Convert symbols to pdf compatable forms when required.36 \pdfstringdefDisableCommands{37 \def\CFA{CFA}38 \def\CPP{C++}39 }40 }{}41 }42 29 43 30 % The CFA listings language. Based off of ANCI C and including GCC extensions. … … 85 72 \renewcommand\textunderscore{\csuse{cfalab@textunderscore@#1}}} 86 73 74 % This is executed very early in the \begin{document} code. 75 \AtEndPreamble{ 76 \@ifpackageloaded{hyperref}{ 77 % Convert symbols to pdf compatable forms when required. 78 \pdfstringdefDisableCommands{ 79 \def\CFA{CFA} 80 } 81 }{} 82 } 83 87 84 \endinput -
doc/theses/andrew_beach_MMath/thesis.tex
rcde1bf9 raf333e3 50 50 % MAIN BODY 51 51 %---------------------------------------------------------------------- 52 \input{existing}53 \input{features}54 52 \input{unwinding} 55 \input{future}56 53 57 54 %====================================================================== -
src/SymTab/Mangler.cc
rcde1bf9 raf333e3 10 10 // Created On : Sun May 17 21:40:29 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Nov 18 12:01:38202013 // Update Count : 6412 // Last Modified On : Sat Feb 15 13:55:12 2020 13 // Update Count : 33 14 14 // 15 15 #include "Mangler.h" … … 65 65 void postvisit( const QualifiedType * qualType ); 66 66 67 std::string get_mangleName() { return mangleName ; }67 std::string get_mangleName() { return mangleName.str(); } 68 68 private: 69 std:: string mangleName;///< Mangled name being constructed69 std::ostringstream mangleName; ///< Mangled name being constructed 70 70 typedef std::map< std::string, std::pair< int, int > > VarMapType; 71 71 VarMapType varNums; ///< Map of type variables to indices … … 127 127 isTopLevel = false; 128 128 } // if 129 mangleName +=Encoding::manglePrefix;129 mangleName << Encoding::manglePrefix; 130 130 const CodeGen::OperatorInfo * opInfo = CodeGen::operatorLookup( declaration->get_name() ); 131 131 if ( opInfo ) { 132 mangleName += std::to_string( opInfo->outputName.size() ) +opInfo->outputName;132 mangleName << opInfo->outputName.size() << opInfo->outputName; 133 133 } else { 134 mangleName += std::to_string( declaration->name.size() ) +declaration->name;134 mangleName << declaration->name.size() << declaration->name; 135 135 } // if 136 136 maybeAccept( declaration->get_type(), *visitor ); … … 139 139 // so they need a different name mangling 140 140 if ( declaration->get_linkage() == LinkageSpec::AutoGen ) { 141 mangleName +=Encoding::autogen;141 mangleName << Encoding::autogen; 142 142 } else if ( declaration->get_linkage() == LinkageSpec::Intrinsic ) { 143 mangleName +=Encoding::intrinsic;143 mangleName << Encoding::intrinsic; 144 144 } else { 145 145 // if we add another kind of overridable function, this has to change … … 160 160 void Mangler_old::postvisit( const VoidType * voidType ) { 161 161 printQualifiers( voidType ); 162 mangleName +=Encoding::void_t;162 mangleName << Encoding::void_t; 163 163 } 164 164 … … 166 166 printQualifiers( basicType ); 167 167 assertf( basicType->kind < BasicType::NUMBER_OF_BASIC_TYPES, "Unhandled basic type: %d", basicType->kind ); 168 mangleName +=Encoding::basicTypes[ basicType->kind ];168 mangleName << Encoding::basicTypes[ basicType->kind ]; 169 169 } 170 170 … … 172 172 printQualifiers( pointerType ); 173 173 // mangle void (*f)() and void f() to the same name to prevent overloading on functions and function pointers 174 if ( ! dynamic_cast<FunctionType *>( pointerType->base ) ) mangleName +=Encoding::pointer;174 if ( ! dynamic_cast<FunctionType *>( pointerType->base ) ) mangleName << Encoding::pointer; 175 175 maybeAccept( pointerType->base, *visitor ); 176 176 } … … 179 179 // TODO: encode dimension 180 180 printQualifiers( arrayType ); 181 mangleName += Encoding::array +"0";181 mangleName << Encoding::array << "0"; 182 182 maybeAccept( arrayType->base, *visitor ); 183 183 } … … 204 204 void Mangler_old::postvisit( const FunctionType * functionType ) { 205 205 printQualifiers( functionType ); 206 mangleName +=Encoding::function;206 mangleName << Encoding::function; 207 207 // turn on inFunctionType so that printQualifiers does not print most qualifiers for function parameters, 208 208 // since qualifiers on outermost parameter type do not differentiate function types, e.g., … … 211 211 inFunctionType = true; 212 212 std::list< Type* > returnTypes = getTypes( functionType->returnVals ); 213 if (returnTypes.empty()) mangleName +=Encoding::void_t;213 if (returnTypes.empty()) mangleName << Encoding::void_t; 214 214 else acceptAll( returnTypes, *visitor ); 215 mangleName +="_";215 mangleName << "_"; 216 216 std::list< Type* > paramTypes = getTypes( functionType->parameters ); 217 217 acceptAll( paramTypes, *visitor ); 218 mangleName +="_";218 mangleName << "_"; 219 219 } 220 220 … … 222 222 printQualifiers( refType ); 223 223 224 mangleName += prefix + std::to_string( refType->name.length() ) +refType->name;224 mangleName << prefix << refType->name.length() << refType->name; 225 225 226 226 if ( mangleGenericParams ) { 227 227 const std::list< Expression* > & params = refType->parameters; 228 228 if ( ! params.empty() ) { 229 mangleName +="_";229 mangleName << "_"; 230 230 for ( const Expression * param : params ) { 231 231 const TypeExpr * paramType = dynamic_cast< const TypeExpr * >( param ); … … 233 233 maybeAccept( paramType->type, *visitor ); 234 234 } 235 mangleName +="_";235 mangleName << "_"; 236 236 } 237 237 } … … 262 262 // are first found and prefixing with the appropriate encoding for the type class. 263 263 assertf( varNum->second.second < TypeDecl::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", varNum->second.second ); 264 mangleName += Encoding::typeVariables[varNum->second.second] + std::to_string( varNum->second.first );264 mangleName << Encoding::typeVariables[varNum->second.second] << varNum->second.first; 265 265 } // if 266 266 } … … 268 268 void Mangler_old::postvisit( const TraitInstType * inst ) { 269 269 printQualifiers( inst ); 270 mangleName += std::to_string( inst->name.size() ) +inst->name;270 mangleName << inst->name.size() << inst->name; 271 271 } 272 272 273 273 void Mangler_old::postvisit( const TupleType * tupleType ) { 274 274 printQualifiers( tupleType ); 275 mangleName += Encoding::tuple + std::to_string( tupleType->types.size());275 mangleName << Encoding::tuple << tupleType->types.size(); 276 276 acceptAll( tupleType->types, *visitor ); 277 277 } … … 280 280 printQualifiers( varArgsType ); 281 281 static const std::string vargs = "__builtin_va_list"; 282 mangleName += Encoding::type + std::to_string( vargs.size() ) +vargs;282 mangleName << Encoding::type << vargs.size() << vargs; 283 283 } 284 284 285 285 void Mangler_old::postvisit( const ZeroType * ) { 286 mangleName +=Encoding::zero;286 mangleName << Encoding::zero; 287 287 } 288 288 289 289 void Mangler_old::postvisit( const OneType * ) { 290 mangleName +=Encoding::one;290 mangleName << Encoding::one; 291 291 } 292 292 … … 296 296 // N marks the start of a qualified type 297 297 inQualifiedType = true; 298 mangleName +=Encoding::qualifiedTypeStart;298 mangleName << Encoding::qualifiedTypeStart; 299 299 } 300 300 maybeAccept( qualType->parent, *visitor ); … … 303 303 // E marks the end of a qualified type 304 304 inQualifiedType = false; 305 mangleName +=Encoding::qualifiedTypeEnd;305 mangleName << Encoding::qualifiedTypeEnd; 306 306 } 307 307 } … … 315 315 assertf(false, "Mangler_old should not visit typedecl: %s", toCString(decl)); 316 316 assertf( decl->kind < TypeDecl::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->kind ); 317 mangleName += Encoding::typeVariables[ decl->kind ] + std::to_string( decl->name.length() ) +decl->name;317 mangleName << Encoding::typeVariables[ decl->kind ] << ( decl->name.length() ) << decl->name; 318 318 } 319 319 … … 330 330 std::list< std::string > assertionNames; 331 331 int dcount = 0, fcount = 0, vcount = 0, acount = 0; 332 mangleName +=Encoding::forall;332 mangleName << Encoding::forall; 333 333 for ( const TypeDecl * i : type->forall ) { 334 334 switch ( i->kind ) { … … 354 354 } // for 355 355 } // for 356 mangleName += std::to_string( dcount ) + "_" + std::to_string( fcount ) + "_" + std::to_string( vcount ) + "_" + std::to_string( acount ) + "_"; 357 for(const auto & a : assertionNames) mangleName += a; 358 // std::copy( assertionNames.begin(), assertionNames.end(), std::ostream_iterator< std::string >( mangleName, "" ) ); 359 mangleName += "_"; 356 mangleName << dcount << "_" << fcount << "_" << vcount << "_" << acount << "_"; 357 std::copy( assertionNames.begin(), assertionNames.end(), std::ostream_iterator< std::string >( mangleName, "" ) ); 358 mangleName << "_"; 360 359 } // if 361 360 if ( ! inFunctionType ) { 362 361 // these qualifiers do not distinguish the outermost type of a function parameter 363 362 if ( type->get_const() ) { 364 mangleName +=Encoding::qualifiers.at(Type::Const);363 mangleName << Encoding::qualifiers.at(Type::Const); 365 364 } // if 366 365 if ( type->get_volatile() ) { 367 mangleName +=Encoding::qualifiers.at(Type::Volatile);366 mangleName << Encoding::qualifiers.at(Type::Volatile); 368 367 } // if 369 368 // Removed due to restrict not affecting function compatibility in GCC 370 369 // if ( type->get_isRestrict() ) { 371 // mangleName +="E";370 // mangleName << "E"; 372 371 // } // if 373 372 if ( type->get_atomic() ) { 374 mangleName +=Encoding::qualifiers.at(Type::Atomic);373 mangleName << Encoding::qualifiers.at(Type::Atomic); 375 374 } // if 376 375 } 377 376 if ( type->get_mutex() ) { 378 mangleName +=Encoding::qualifiers.at(Type::Mutex);377 mangleName << Encoding::qualifiers.at(Type::Mutex); 379 378 } // if 380 379 if ( inFunctionType ) { … … 384 383 } 385 384 } 386 } 385 } // namespace 387 386 } // namespace Mangler 388 387 } // namespace SymTab … … 418 417 void postvisit( const ast::QualifiedType * qualType ); 419 418 420 std::string get_mangleName() { return mangleName ; }419 std::string get_mangleName() { return mangleName.str(); } 421 420 private: 422 std:: string mangleName;///< Mangled name being constructed421 std::ostringstream mangleName; ///< Mangled name being constructed 423 422 typedef std::map< std::string, std::pair< int, int > > VarMapType; 424 423 VarMapType varNums; ///< Map of type variables to indices … … 471 470 isTopLevel = false; 472 471 } // if 473 mangleName +=Encoding::manglePrefix;472 mangleName << Encoding::manglePrefix; 474 473 const CodeGen::OperatorInfo * opInfo = CodeGen::operatorLookup( decl->name ); 475 474 if ( opInfo ) { 476 mangleName += std::to_string( opInfo->outputName.size() ) +opInfo->outputName;475 mangleName << opInfo->outputName.size() << opInfo->outputName; 477 476 } else { 478 mangleName += std::to_string( decl->name.size() ) +decl->name;477 mangleName << decl->name.size() << decl->name; 479 478 } // if 480 479 maybeAccept( decl->get_type(), *visitor ); … … 483 482 // so they need a different name mangling 484 483 if ( decl->linkage == ast::Linkage::AutoGen ) { 485 mangleName +=Encoding::autogen;484 mangleName << Encoding::autogen; 486 485 } else if ( decl->linkage == ast::Linkage::Intrinsic ) { 487 mangleName +=Encoding::intrinsic;486 mangleName << Encoding::intrinsic; 488 487 } else { 489 488 // if we add another kind of overridable function, this has to change … … 504 503 void Mangler_new::postvisit( const ast::VoidType * voidType ) { 505 504 printQualifiers( voidType ); 506 mangleName +=Encoding::void_t;505 mangleName << Encoding::void_t; 507 506 } 508 507 … … 510 509 printQualifiers( basicType ); 511 510 assertf( basicType->kind < ast::BasicType::NUMBER_OF_BASIC_TYPES, "Unhandled basic type: %d", basicType->kind ); 512 mangleName +=Encoding::basicTypes[ basicType->kind ];511 mangleName << Encoding::basicTypes[ basicType->kind ]; 513 512 } 514 513 … … 516 515 printQualifiers( pointerType ); 517 516 // mangle void (*f)() and void f() to the same name to prevent overloading on functions and function pointers 518 if ( ! pointerType->base.as<ast::FunctionType>() ) mangleName +=Encoding::pointer;517 if ( ! pointerType->base.as<ast::FunctionType>() ) mangleName << Encoding::pointer; 519 518 maybe_accept( pointerType->base.get(), *visitor ); 520 519 } … … 523 522 // TODO: encode dimension 524 523 printQualifiers( arrayType ); 525 mangleName += Encoding::array +"0";524 mangleName << Encoding::array << "0"; 526 525 maybeAccept( arrayType->base.get(), *visitor ); 527 526 } … … 546 545 void Mangler_new::postvisit( const ast::FunctionType * functionType ) { 547 546 printQualifiers( functionType ); 548 mangleName +=Encoding::function;547 mangleName << Encoding::function; 549 548 // turn on inFunctionType so that printQualifiers does not print most qualifiers for function parameters, 550 549 // since qualifiers on outermost parameter type do not differentiate function types, e.g., … … 552 551 GuardValue( inFunctionType ); 553 552 inFunctionType = true; 554 if (functionType->returns.empty()) mangleName +=Encoding::void_t;553 if (functionType->returns.empty()) mangleName << Encoding::void_t; 555 554 else accept_each( functionType->returns, *visitor ); 556 mangleName +="_";555 mangleName << "_"; 557 556 accept_each( functionType->params, *visitor ); 558 mangleName +="_";557 mangleName << "_"; 559 558 } 560 559 … … 562 561 printQualifiers( refType ); 563 562 564 mangleName += prefix + std::to_string( refType->name.length() ) +refType->name;563 mangleName << prefix << refType->name.length() << refType->name; 565 564 566 565 if ( mangleGenericParams ) { 567 566 if ( ! refType->params.empty() ) { 568 mangleName +="_";567 mangleName << "_"; 569 568 for ( const ast::Expr * param : refType->params ) { 570 569 auto paramType = dynamic_cast< const ast::TypeExpr * >( param ); … … 572 571 maybeAccept( paramType->type.get(), *visitor ); 573 572 } 574 mangleName +="_";573 mangleName << "_"; 575 574 } 576 575 } … … 601 600 // are first found and prefixing with the appropriate encoding for the type class. 602 601 assertf( varNum->second.second < TypeDecl::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", varNum->second.second ); 603 mangleName += Encoding::typeVariables[varNum->second.second] + std::to_string( varNum->second.first );602 mangleName << Encoding::typeVariables[varNum->second.second] << varNum->second.first; 604 603 } // if 605 604 } … … 607 606 void Mangler_new::postvisit( const ast::TraitInstType * inst ) { 608 607 printQualifiers( inst ); 609 mangleName += std::to_string( inst->name.size() ) +inst->name;608 mangleName << inst->name.size() << inst->name; 610 609 } 611 610 612 611 void Mangler_new::postvisit( const ast::TupleType * tupleType ) { 613 612 printQualifiers( tupleType ); 614 mangleName += Encoding::tuple + std::to_string( tupleType->types.size());613 mangleName << Encoding::tuple << tupleType->types.size(); 615 614 accept_each( tupleType->types, *visitor ); 616 615 } … … 619 618 printQualifiers( varArgsType ); 620 619 static const std::string vargs = "__builtin_va_list"; 621 mangleName += Encoding::type + std::to_string( vargs.size() ) +vargs;620 mangleName << Encoding::type << vargs.size() << vargs; 622 621 } 623 622 624 623 void Mangler_new::postvisit( const ast::ZeroType * ) { 625 mangleName +=Encoding::zero;624 mangleName << Encoding::zero; 626 625 } 627 626 628 627 void Mangler_new::postvisit( const ast::OneType * ) { 629 mangleName +=Encoding::one;628 mangleName << Encoding::one; 630 629 } 631 630 … … 635 634 // N marks the start of a qualified type 636 635 inQualifiedType = true; 637 mangleName +=Encoding::qualifiedTypeStart;636 mangleName << Encoding::qualifiedTypeStart; 638 637 } 639 638 maybeAccept( qualType->parent.get(), *visitor ); … … 642 641 // E marks the end of a qualified type 643 642 inQualifiedType = false; 644 mangleName +=Encoding::qualifiedTypeEnd;643 mangleName << Encoding::qualifiedTypeEnd; 645 644 } 646 645 } … … 654 653 assertf(false, "Mangler_new should not visit typedecl: %s", toCString(decl)); 655 654 assertf( decl->kind < ast::TypeDecl::Kind::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->kind ); 656 mangleName += Encoding::typeVariables[ decl->kind ] + std::to_string( decl->name.length() ) +decl->name;655 mangleName << Encoding::typeVariables[ decl->kind ] << ( decl->name.length() ) << decl->name; 657 656 } 658 657 … … 670 669 std::list< std::string > assertionNames; 671 670 int dcount = 0, fcount = 0, vcount = 0, acount = 0; 672 mangleName +=Encoding::forall;671 mangleName << Encoding::forall; 673 672 for ( const ast::TypeDecl * decl : ptype->forall ) { 674 673 switch ( decl->kind ) { … … 694 693 } // for 695 694 } // for 696 mangleName += std::to_string( dcount ) + "_" + std::to_string( fcount ) + "_" + std::to_string( vcount ) + "_" + std::to_string( acount ) + "_"; 697 for(const auto & a : assertionNames) mangleName += a; 698 // std::copy( assertionNames.begin(), assertionNames.end(), std::ostream_iterator< std::string >( mangleName, "" ) ); 699 mangleName += "_"; 695 mangleName << dcount << "_" << fcount << "_" << vcount << "_" << acount << "_"; 696 std::copy( assertionNames.begin(), assertionNames.end(), std::ostream_iterator< std::string >( mangleName, "" ) ); 697 mangleName << "_"; 700 698 } // if 701 699 } // if … … 703 701 // these qualifiers do not distinguish the outermost type of a function parameter 704 702 if ( type->is_const() ) { 705 mangleName +=Encoding::qualifiers.at(Type::Const);703 mangleName << Encoding::qualifiers.at(Type::Const); 706 704 } // if 707 705 if ( type->is_volatile() ) { 708 mangleName +=Encoding::qualifiers.at(Type::Volatile);706 mangleName << Encoding::qualifiers.at(Type::Volatile); 709 707 } // if 710 708 // Removed due to restrict not affecting function compatibility in GCC 711 709 // if ( type->get_isRestrict() ) { 712 // mangleName +="E";710 // mangleName << "E"; 713 711 // } // if 714 712 if ( type->is_atomic() ) { 715 mangleName +=Encoding::qualifiers.at(Type::Atomic);713 mangleName << Encoding::qualifiers.at(Type::Atomic); 716 714 } // if 717 715 } 718 716 if ( type->is_mutex() ) { 719 mangleName +=Encoding::qualifiers.at(Type::Mutex);717 mangleName << Encoding::qualifiers.at(Type::Mutex); 720 718 } // if 721 719 if ( inFunctionType ) {
Note: See TracChangeset
for help on using the changeset viewer.