Changeset ffec1bf for src/CodeGen
- Timestamp:
- Jul 25, 2022, 2:23:28 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 4c48be0, 5cf1228, def751f
- Parents:
- 9e23b446 (diff), 1f950c3b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/CodeGen
- Files:
-
- 5 edited
-
CodeGenerator.cc (modified) (5 diffs)
-
CodeGenerator.h (modified) (3 diffs)
-
FixNames.cc (modified) (4 diffs)
-
FixNames.h (modified) (2 diffs)
-
GenType.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r9e23b446 rffec1bf 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Feb 2 20:30:30 202213 // Update Count : 54 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 29 14:34:00 2022 13 // Update Count : 542 14 14 // 15 15 #include "CodeGenerator.h" … … 18 18 #include <list> // for _List_iterator, list, list<>::it... 19 19 20 #include "AST/Decl.hpp" // for DeclWithType 20 21 #include "Common/UniqueName.h" // for UniqueName 21 22 #include "Common/utility.h" // for CodeLocation, toString … … 294 295 } else { 295 296 if ( obj->get_init() ) { 296 obj->get_init()->accept( *visitor ); 297 obj->get_init()->accept( *visitor ); 297 298 } else { 298 299 // Should not reach here! … … 683 684 extension( variableExpr ); 684 685 const OperatorInfo * opInfo; 685 if ( variableExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && (opInfo = operatorLookup( variableExpr->get_var()->get_name() )) && opInfo->type == OT_CONSTANT ) { 686 if( dynamic_cast<ZeroType*>( variableExpr->get_var()->get_type() ) ) { 687 output << "0"; 688 } else if ( variableExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && (opInfo = operatorLookup( variableExpr->get_var()->get_name() )) && opInfo->type == OT_CONSTANT ) { 686 689 output << opInfo->symbol; 687 690 } else { 688 // if (dynamic_cast<EnumInstType *>(variableExpr->get_var()->get_type()) 691 // if (dynamic_cast<EnumInstType *>(variableExpr->get_var()->get_type()) 689 692 // && dynamic_cast<EnumInstType *>(variableExpr->get_var()->get_type())->baseEnum->base) { 690 693 // output << '(' <<genType(dynamic_cast<EnumInstType *>(variableExpr->get_var()->get_type())->baseEnum->base, "", options) << ')'; … … 1236 1239 } // if 1237 1240 } 1241 1242 std::string genName( ast::DeclWithType const * decl ) { 1243 if ( const OperatorInfo * opInfo = operatorLookup( decl->name ) ) { 1244 return opInfo->outputName; 1245 } else { 1246 return decl->name; 1247 } 1248 } 1249 1238 1250 } // namespace CodeGen 1239 1251 -
src/CodeGen/CodeGenerator.h
r9e23b446 rffec1bf 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Feb 1 09:23:21202213 // Update Count : 6 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 29 14:32:00 2022 13 // Update Count : 65 14 14 // 15 15 … … 26 26 #include "SynTree/Visitor.h" // for Visitor 27 27 #include "SynTree/SynTree.h" // for Visitor Nodes 28 29 namespace ast { 30 class DeclWithType; 31 } 28 32 29 33 namespace CodeGen { … … 182 186 /// returns C-compatible name of declaration 183 187 std::string genName( DeclarationWithType * decl ); 188 std::string genName( ast::DeclWithType const * decl ); 184 189 185 190 inline std::ostream & operator<<( std::ostream & os, const CodeGenerator::LineEnder & endl ) { -
src/CodeGen/FixNames.cc
r9e23b446 rffec1bf 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // FixNames.cc -- 7 // FixNames.cc -- Adjustments to typed declarations. 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Oct 29 15:49:00 202113 // Update Count : 2 312 // Last Modified On : Wed Jul 20 11:49:00 2022 13 // Update Count : 24 14 14 // 15 15 … … 87 87 88 88 /// Does work with the main function and scopeLevels. 89 class FixNames_new : public ast::WithGuards{89 class FixNames_new final { 90 90 int scopeLevel = 1; 91 91 … … 103 103 104 104 const ast::FunctionDecl *postvisit( const ast::FunctionDecl *functionDecl ) { 105 // This store is used to ensure a maximum of one call to mutate.106 ast::FunctionDecl * mutDecl = nullptr;105 if ( FixMain::isMain( functionDecl ) ) { 106 auto mutDecl = ast::mutate( functionDecl ); 107 107 108 if ( shouldSetScopeLevel( functionDecl ) ) { 109 mutDecl = ast::mutate( functionDecl ); 110 mutDecl->scopeLevel = scopeLevel; 111 } 112 113 if ( FixMain::isMain( functionDecl ) ) { 114 if ( !mutDecl ) { mutDecl = ast::mutate( functionDecl ); } 108 if ( shouldSetScopeLevel( mutDecl ) ) { 109 mutDecl->scopeLevel = scopeLevel; 110 } 115 111 116 112 int nargs = mutDecl->params.size(); … … 124 120 ) 125 121 ); 122 123 return mutDecl; 124 } else if ( shouldSetScopeLevel( functionDecl ) ) { 125 return ast::mutate_field( functionDecl, &ast::FunctionDecl::scopeLevel, scopeLevel ); 126 } else { 127 return functionDecl; 126 128 } 127 return mutDecl ? mutDecl : functionDecl;128 129 } 129 130 130 131 void previsit( const ast::CompoundStmt * ) { 131 GuardValue( scopeLevel ) += 1; 132 scopeLevel += 1; 133 } 134 135 void postvisit( const ast::CompoundStmt * ) { 136 scopeLevel -= 1; 132 137 } 133 138 }; -
src/CodeGen/FixNames.h
r9e23b446 rffec1bf 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // FixNames.h -- 7 // FixNames.h -- Adjustments to typed declarations. 8 8 // 9 9 // Author : Richard C. Bilson … … 26 26 /// mangles object and function names 27 27 void fixNames( std::list< Declaration* > & translationUnit ); 28 void fixNames( ast::TranslationUnit & translationUnit ); 28 /// Sets scope levels and fills in main's default return. 29 void fixNames( ast::TranslationUnit & translationUnit ); 29 30 } // namespace CodeGen 30 31 -
src/CodeGen/GenType.cc
r9e23b446 rffec1bf 254 254 255 255 void GenType::postvisit( EnumInstType * enumInst ) { 256 if ( enumInst->baseEnum ->base ) {256 if ( enumInst->baseEnum && enumInst->baseEnum->base ) { 257 257 typeString = genType(enumInst->baseEnum->base, "", options) + typeString; 258 258 } else {
Note:
See TracChangeset
for help on using the changeset viewer.