Changeset 9a1e509 for src/CodeGen
- Timestamp:
- Jul 13, 2017, 3:57:23 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- bf30ab3
- Parents:
- 1d776fd (diff), 3d4b23fa (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:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r1d776fd r9a1e509 14 14 // 15 15 16 #include <algorithm> 17 #include <iostream> 18 #include <cassert> 19 #include <list> 20 21 #include "Parser/ParseNode.h" 22 23 #include "SynTree/Declaration.h" 24 #include "SynTree/Expression.h" 25 #include "SynTree/Initializer.h" 26 #include "SynTree/Statement.h" 27 #include "SynTree/Type.h" 28 #include "SynTree/Attribute.h" 29 30 #include "Common/utility.h" 31 #include "Common/UnimplementedError.h" 16 #include <cassert> // for assert, assertf 17 #include <list> // for _List_iterator, list, list<>::it... 32 18 33 19 #include "CodeGenerator.h" 34 #include "OperatorTable.h" 35 #include "GenType.h" 36 37 #include "InitTweak/InitTweak.h" 20 #include "Common/SemanticError.h" // for SemanticError 21 #include "Common/UniqueName.h" // for UniqueName 22 #include "Common/utility.h" // for CodeLocation, toString 23 #include "GenType.h" // for genType 24 #include "InitTweak/InitTweak.h" // for getPointerBase 25 #include "OperatorTable.h" // for OperatorInfo, operatorLookup 26 #include "Parser/LinkageSpec.h" // for Spec, Intrinsic 27 #include "SynTree/Attribute.h" // for Attribute 28 #include "SynTree/BaseSyntaxNode.h" // for BaseSyntaxNode 29 #include "SynTree/Constant.h" // for Constant 30 #include "SynTree/Declaration.h" // for DeclarationWithType, TypeDecl 31 #include "SynTree/Expression.h" // for Expression, UntypedExpr, Applica... 32 #include "SynTree/Initializer.h" // for Initializer, ListInit, Designation 33 #include "SynTree/Label.h" // for Label, operator<< 34 #include "SynTree/Statement.h" // for Statement, AsmStmt, BranchStmt 35 #include "SynTree/Type.h" // for Type, Type::StorageClasses, Func... 38 36 39 37 using namespace std; -
src/CodeGen/CodeGenerator.h
r1d776fd r9a1e509 17 17 #define CODEGENV_H 18 18 19 #include <list> 19 #include <list> // for list 20 #include <ostream> // for ostream, operator<< 21 #include <string> // for string 20 22 21 #include "SynTree/Declaration.h" 22 #include "SynTree/SynTree.h" 23 #include "SynTree/Visitor.h" 24 25 #include "SymTab/Indexer.h" 26 27 #include "Common/Indenter.h" 28 #include "Common/utility.h" 23 #include "SynTree/Declaration.h" // for DeclarationWithType (ptr only), Fun... 24 #include "SynTree/Visitor.h" // for Visitor 25 #include "SynTree/SynTree.h" // for Visitor Nodes 29 26 30 27 namespace CodeGen { -
src/CodeGen/FixMain.cc
r1d776fd r9a1e509 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // FixMain.cc -- 7 // FixMain.cc -- 8 8 // 9 9 // Author : Thierry Delisle 10 10 // Created On : Thr Jan 12 14:11:09 2017 11 // Last Modified By : 12 // Last Modified On : 11 // Last Modified By : 12 // Last Modified On : 13 13 // Update Count : 0 14 14 // 15 15 16 16 17 #include "FixMain.h" 17 #include "FixMain.h" 18 18 19 #include <fstream> 20 #include <iostream> 19 #include <cassert> // for assert, assertf 20 #include <fstream> // for operator<<, basic_ostream::operator<< 21 #include <list> // for list 22 #include <string> // for operator<< 21 23 22 #include "Common/SemanticError.h" 23 #include "SynTree/Declaration.h" 24 #include "Common/SemanticError.h" // for SemanticError 25 #include "SynTree/Declaration.h" // for FunctionDecl, operator<< 26 #include "SynTree/Type.h" // for FunctionType 24 27 25 28 namespace CodeGen { 26 29 bool FixMain::replace_main = false; 27 30 std::unique_ptr<FunctionDecl> FixMain::main_signature = nullptr; 28 29 void FixMain::registerMain(FunctionDecl* functionDecl) 31 32 void FixMain::registerMain(FunctionDecl* functionDecl) 30 33 { 31 if(main_signature) { 32 throw SemanticError("Multiple definition of main routine\n", functionDecl); 34 if(main_signature) { 35 throw SemanticError("Multiple definition of main routine\n", functionDecl); 33 36 } 34 37 main_signature.reset( functionDecl->clone() ); -
src/CodeGen/FixNames.cc
r1d776fd r9a1e509 14 14 // 15 15 16 #include <memory>16 #include "FixNames.h" 17 17 18 #include "FixNames.h" 19 #include "SynTree/Declaration.h" 20 #include "SynTree/Expression.h" 21 #include "SynTree/Visitor.h" 22 #include "SymTab/Mangler.h" 23 #include "OperatorTable.h" 24 #include "FixMain.h" 18 #include <memory> // for unique_ptr 19 #include <string> // for string, operator!=, operator== 20 21 #include "Common/SemanticError.h" // for SemanticError 22 #include "FixMain.h" // for FixMain 23 #include "Parser/LinkageSpec.h" // for Cforall, isMangled 24 #include "SymTab/Mangler.h" // for Mangler 25 #include "SynTree/Constant.h" // for Constant 26 #include "SynTree/Declaration.h" // for FunctionDecl, ObjectDecl, Declarat... 27 #include "SynTree/Expression.h" // for ConstantExpr 28 #include "SynTree/Label.h" // for Label, noLabels 29 #include "SynTree/Statement.h" // for ReturnStmt, CompoundStmt 30 #include "SynTree/Type.h" // for Type, BasicType, Type::Qualifiers 31 #include "SynTree/Visitor.h" // for Visitor, acceptAll 25 32 26 33 namespace CodeGen { … … 42 49 main_type = new FunctionType( Type::Qualifiers(), true ), nullptr ) 43 50 }; 44 main_type->get_returnVals().push_back( 51 main_type->get_returnVals().push_back( 45 52 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 46 53 ); … … 52 59 std::string mangle_main_args() { 53 60 FunctionType* main_type; 54 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall, 61 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall, 55 62 main_type = new FunctionType( Type::Qualifiers(), false ), nullptr ) 56 63 }; 57 main_type->get_returnVals().push_back( 64 main_type->get_returnVals().push_back( 58 65 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 59 66 ); 60 67 61 mainDecl->get_functionType()->get_parameters().push_back( 68 mainDecl->get_functionType()->get_parameters().push_back( 62 69 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 63 70 ); 64 71 65 mainDecl->get_functionType()->get_parameters().push_back( 66 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, 67 new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::Char ) ) ), 72 mainDecl->get_functionType()->get_parameters().push_back( 73 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, 74 new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::Char ) ) ), 68 75 nullptr ) 69 76 ); … … 75 82 76 83 bool is_main(const std::string& name) { 77 static std::string mains[] = { 78 mangle_main(), 84 static std::string mains[] = { 85 mangle_main(), 79 86 mangle_main_args() 80 87 }; … … 112 119 int nargs = functionDecl->get_functionType()->get_parameters().size(); 113 120 if( !(nargs == 0 || nargs == 2 || nargs == 3) ) { 114 throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl); 121 throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl); 115 122 } 116 123 functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new ConstantExpr( Constant::from_int( 0 ) ) ) ); -
src/CodeGen/FixNames.h
r1d776fd r9a1e509 17 17 #define FIXNAMES_H 18 18 19 #include "SynTree/SynTree.h" 19 #include <list> // for list 20 21 class Declaration; 20 22 21 23 namespace CodeGen { -
src/CodeGen/GenType.cc
r1d776fd r9a1e509 14 14 // 15 15 16 #include <sstream> 17 #include <cassert> 18 16 #include <cassert> // for assert, assertf 17 #include <list> // for _List_iterator, _List_const_iterator 18 #include <sstream> // for operator<<, ostringstream, basic_os... 19 20 #include "CodeGenerator.h" // for CodeGenerator 19 21 #include "GenType.h" 20 #include "CodeGenerator.h" 21 22 #include "SynTree/Declaration.h" 23 #include "SynTree/Expression.h" 24 #include "SynTree/Type.h" 25 #include "SynTree/Visitor.h" 22 #include "SynTree/Declaration.h" // for DeclarationWithType 23 #include "SynTree/Expression.h" // for Expression 24 #include "SynTree/Type.h" // for PointerType, Type, FunctionType 25 #include "SynTree/Visitor.h" // for Visitor 26 26 27 27 namespace CodeGen { -
src/CodeGen/GenType.h
r1d776fd r9a1e509 17 17 #define _GENTYPE_H 18 18 19 #include <string> 20 #include "SynTree/SynTree.h" 19 #include <string> // for string 20 21 class Type; 21 22 22 23 namespace CodeGen { -
src/CodeGen/Generate.cc
r1d776fd r9a1e509 14 14 // 15 15 16 #include <algorithm> 17 #include <iostream> 18 #include <cassert> 19 #include <list> 16 #include <iostream> // for ostream, endl, operator<< 17 #include <list> // for list 18 #include <string> // for operator<< 20 19 20 #include "CodeGenerator.h" // for CodeGenerator, doSemicolon, oper... 21 #include "GenType.h" // for genPrettyType 21 22 #include "Generate.h" 22 #include "SynTree/Declaration.h" 23 #include "CodeGenerator.h" 24 #include "GenType.h" 25 #include "SynTree/SynTree.h" 26 #include "SynTree/Type.h" 27 #include "SynTree/BaseSyntaxNode.h" 28 // #include "Tuples/Tuples.h" 23 #include "Parser/LinkageSpec.h" // for isBuiltin, isGeneratable 24 #include "SynTree/BaseSyntaxNode.h" // for BaseSyntaxNode 25 #include "SynTree/Declaration.h" // for Declaration 26 #include "SynTree/Type.h" // for Type 29 27 30 28 using namespace std; -
src/CodeGen/Generate.h
r1d776fd r9a1e509 17 17 #define GENERATE_H 18 18 19 #include < list>20 #include < iostream>19 #include <iostream> // for ostream 20 #include <list> // for list 21 21 22 #include "SynTree/SynTree.h" 22 class BaseSyntaxNode; 23 class Declaration; 23 24 24 25 namespace CodeGen { -
src/CodeGen/OperatorTable.cc
r1d776fd r9a1e509 14 14 // 15 15 16 #include <map> 16 #include <map> // for map, _Rb_tree_const_iterator, map<>::const_iterator 17 #include <utility> // for pair 18 17 19 #include "OperatorTable.h" 18 20
Note: See TracChangeset
for help on using the changeset viewer.