[a488783] | 1 | //
|
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
|
---|
| 3 | //
|
---|
| 4 | // The contents of this file are covered under the licence agreement in the
|
---|
| 5 | // file "LICENCE" distributed with Cforall.
|
---|
| 6 | //
|
---|
| 7 | // Autogen.cpp -- Generate automatic routines for data types.
|
---|
| 8 | //
|
---|
| 9 | // Author : Andrew Beach
|
---|
| 10 | // Created On : Thu Dec 2 13:44:00 2021
|
---|
| 11 | // Last Modified By : Andrew Beach
|
---|
[20737104] | 12 | // Last Modified On : Tue Sep 20 16:00:00 2022
|
---|
| 13 | // Update Count : 2
|
---|
[a488783] | 14 | //
|
---|
| 15 |
|
---|
| 16 | #include "Autogen.hpp"
|
---|
| 17 |
|
---|
[c92bdcc] | 18 | #include <algorithm> // for count_if
|
---|
| 19 | #include <cassert> // for strict_dynamic_cast, assert, a...
|
---|
| 20 | #include <iterator> // for back_insert_iterator, back_ins...
|
---|
| 21 | #include <list> // for list, _List_iterator, list<>::...
|
---|
| 22 | #include <set> // for set, _Rb_tree_const_iterator
|
---|
| 23 | #include <utility> // for pair
|
---|
| 24 | #include <vector> // for vector
|
---|
[a488783] | 25 |
|
---|
| 26 | #include "AST/Attribute.hpp"
|
---|
[bccd70a] | 27 | #include "AST/Copy.hpp"
|
---|
[20737104] | 28 | #include "AST/Create.hpp"
|
---|
[a488783] | 29 | #include "AST/Decl.hpp"
|
---|
| 30 | #include "AST/DeclReplacer.hpp"
|
---|
| 31 | #include "AST/Expr.hpp"
|
---|
[91715ce1] | 32 | #include "AST/Inspect.hpp"
|
---|
[a488783] | 33 | #include "AST/Pass.hpp"
|
---|
| 34 | #include "AST/Stmt.hpp"
|
---|
| 35 | #include "AST/SymbolTable.hpp"
|
---|
[c92bdcc] | 36 | #include "CodeGen/OperatorTable.hpp" // for isCtorDtor, isCtorDtorAssign
|
---|
| 37 | #include "Common/ScopedMap.hpp" // for ScopedMap<>::const_iterator, S...
|
---|
| 38 | #include "Common/Utility.hpp" // for cloneAll, operator+
|
---|
| 39 | #include "GenPoly/ScopedSet.hpp" // for ScopedSet, ScopedSet<>::iterator
|
---|
| 40 | #include "InitTweak/GenInit.hpp" // for fixReturnStatements
|
---|
| 41 | #include "InitTweak/InitTweak.hpp" // for isAssignment, isCopyConstructor
|
---|
[fb4dc28] | 42 | #include "SymTab/GenImplicitCall.hpp" // for genImplicitCall
|
---|
[c92bdcc] | 43 | #include "SymTab/Mangler.hpp" // for Mangler
|
---|
[b2ea0cd] | 44 | #include "CompilationState.hpp"
|
---|
[a488783] | 45 |
|
---|
| 46 | namespace Validate {
|
---|
| 47 |
|
---|
| 48 | namespace {
|
---|
| 49 |
|
---|
| 50 | // --------------------------------------------------------------------------
|
---|
[0bd3faf] | 51 | struct AutogenerateRoutines final :
|
---|
[ed96731] | 52 | public ast::WithDeclsToAdd,
|
---|
[a488783] | 53 | public ast::WithShortCircuiting {
|
---|
| 54 | void previsit( const ast::EnumDecl * enumDecl );
|
---|
| 55 | void previsit( const ast::StructDecl * structDecl );
|
---|
| 56 | void previsit( const ast::UnionDecl * structDecl );
|
---|
| 57 | void previsit( const ast::TypeDecl * typeDecl );
|
---|
| 58 | void previsit( const ast::TraitDecl * traitDecl );
|
---|
| 59 | void previsit( const ast::FunctionDecl * functionDecl );
|
---|
| 60 | void postvisit( const ast::FunctionDecl * functionDecl );
|
---|
| 61 |
|
---|
| 62 | private:
|
---|
| 63 | // Current level of nested functions.
|
---|
| 64 | unsigned int functionNesting = 0;
|
---|
| 65 | };
|
---|
| 66 |
|
---|
| 67 | // --------------------------------------------------------------------------
|
---|
| 68 | /// Class used to generate functions for a particular declaration.
|
---|
| 69 | /// Note it isn't really stored, it is just a class for organization and to
|
---|
| 70 | /// help pass around some of the common arguments.
|
---|
| 71 | class FuncGenerator {
|
---|
| 72 | public:
|
---|
| 73 | std::list<ast::ptr<ast::Decl>> definitions;
|
---|
| 74 |
|
---|
| 75 | FuncGenerator( const ast::Type * type, unsigned int functionNesting ) :
|
---|
| 76 | type( type ), functionNesting( functionNesting )
|
---|
| 77 | {}
|
---|
| 78 |
|
---|
| 79 | /// Generate functions (and forward decls.) and append them to the list.
|
---|
| 80 | void generateAndAppendFunctions( std::list<ast::ptr<ast::Decl>> & );
|
---|
| 81 |
|
---|
| 82 | virtual bool shouldAutogen() const = 0;
|
---|
| 83 | protected:
|
---|
| 84 | const ast::Type * type;
|
---|
| 85 | unsigned int functionNesting;
|
---|
| 86 | ast::Linkage::Spec proto_linkage = ast::Linkage::AutoGen;
|
---|
| 87 |
|
---|
| 88 | // Internal helpers:
|
---|
[bb336a6] | 89 | virtual void genStandardFuncs();
|
---|
[a488783] | 90 | void produceDecl( const ast::FunctionDecl * decl );
|
---|
| 91 |
|
---|
| 92 | const CodeLocation& getLocation() const { return getDecl()->location; }
|
---|
[8913de4] | 93 | ast::FunctionDecl * genProto( std::string&& name,
|
---|
[a488783] | 94 | std::vector<ast::ptr<ast::DeclWithType>>&& params,
|
---|
| 95 | std::vector<ast::ptr<ast::DeclWithType>>&& returns ) const;
|
---|
| 96 |
|
---|
| 97 | ast::ObjectDecl * dstParam() const;
|
---|
| 98 | ast::ObjectDecl * srcParam() const;
|
---|
| 99 | ast::FunctionDecl * genCtorProto() const;
|
---|
| 100 | ast::FunctionDecl * genCopyProto() const;
|
---|
| 101 | ast::FunctionDecl * genDtorProto() const;
|
---|
| 102 | ast::FunctionDecl * genAssignProto() const;
|
---|
| 103 | ast::FunctionDecl * genFieldCtorProto( unsigned int fields ) const;
|
---|
| 104 |
|
---|
| 105 | // Internal Hooks:
|
---|
| 106 | virtual void genFuncBody( ast::FunctionDecl * decl ) = 0;
|
---|
| 107 | virtual void genFieldCtors() = 0;
|
---|
| 108 | virtual bool isConcurrentType() const { return false; }
|
---|
| 109 | virtual const ast::Decl * getDecl() const = 0;
|
---|
| 110 | };
|
---|
| 111 |
|
---|
| 112 | class StructFuncGenerator final : public FuncGenerator {
|
---|
| 113 | const ast::StructDecl * decl;
|
---|
| 114 | public:
|
---|
| 115 | StructFuncGenerator( const ast::StructDecl * decl,
|
---|
| 116 | const ast::StructInstType * type,
|
---|
| 117 | unsigned int functionNesting ) :
|
---|
| 118 | FuncGenerator( type, functionNesting ), decl( decl )
|
---|
| 119 | {}
|
---|
| 120 |
|
---|
| 121 | // Built-ins do not use autogeneration.
|
---|
[91715ce1] | 122 | bool shouldAutogen() const final { return !decl->linkage.is_builtin && !structHasFlexibleArray(decl); }
|
---|
[a488783] | 123 | private:
|
---|
| 124 | void genFuncBody( ast::FunctionDecl * decl ) final;
|
---|
| 125 | void genFieldCtors() final;
|
---|
| 126 | bool isConcurrentType() const final {
|
---|
| 127 | return decl->is_thread() || decl->is_monitor();
|
---|
| 128 | }
|
---|
| 129 | virtual const ast::Decl * getDecl() const final { return decl; }
|
---|
| 130 |
|
---|
| 131 | /// Generates a single struct member operation.
|
---|
| 132 | /// (constructor call, destructor call, assignment call)
|
---|
[4e2f1b2] | 133 | const ast::Stmt * makeMemberOp(
|
---|
[a488783] | 134 | const CodeLocation& location,
|
---|
| 135 | const ast::ObjectDecl * dstParam, const ast::Expr * src,
|
---|
| 136 | const ast::ObjectDecl * field, ast::FunctionDecl * func,
|
---|
| 137 | SymTab::LoopDirection direction );
|
---|
| 138 |
|
---|
| 139 | /// Generates the body of a struct function by iterating the struct members
|
---|
| 140 | /// (via parameters). Generates default constructor, copy constructor,
|
---|
| 141 | /// copy assignment, and destructor bodies. No field constructor bodies.
|
---|
| 142 | template<typename Iterator>
|
---|
| 143 | void makeFunctionBody( Iterator member, Iterator end,
|
---|
| 144 | ast::FunctionDecl * func, SymTab::LoopDirection direction );
|
---|
| 145 |
|
---|
| 146 | /// Generate the body of a constructor which takes parameters that match
|
---|
| 147 | /// fields. (With arguments for one to all of the fields.)
|
---|
| 148 | template<typename Iterator>
|
---|
| 149 | void makeFieldCtorBody( Iterator member, Iterator end,
|
---|
| 150 | ast::FunctionDecl * func );
|
---|
| 151 | };
|
---|
| 152 |
|
---|
| 153 | class UnionFuncGenerator final : public FuncGenerator {
|
---|
| 154 | const ast::UnionDecl * decl;
|
---|
| 155 | public:
|
---|
| 156 | UnionFuncGenerator( const ast::UnionDecl * decl,
|
---|
| 157 | const ast::UnionInstType * type,
|
---|
| 158 | unsigned int functionNesting ) :
|
---|
| 159 | FuncGenerator( type, functionNesting ), decl( decl )
|
---|
| 160 | {}
|
---|
| 161 |
|
---|
| 162 | // Built-ins do not use autogeneration.
|
---|
| 163 | bool shouldAutogen() const final { return !decl->linkage.is_builtin; }
|
---|
| 164 | private:
|
---|
| 165 | void genFuncBody( ast::FunctionDecl * decl ) final;
|
---|
| 166 | void genFieldCtors() final;
|
---|
| 167 | const ast::Decl * getDecl() const final { return decl; }
|
---|
| 168 |
|
---|
| 169 | /// Generate a single union assignment expression (using memcpy).
|
---|
| 170 | ast::ExprStmt * makeAssignOp( const CodeLocation& location,
|
---|
| 171 | const ast::ObjectDecl * dstParam, const ast::ObjectDecl * srcParam );
|
---|
| 172 | };
|
---|
| 173 |
|
---|
| 174 | class EnumFuncGenerator final : public FuncGenerator {
|
---|
| 175 | const ast::EnumDecl * decl;
|
---|
| 176 | public:
|
---|
| 177 | EnumFuncGenerator( const ast::EnumDecl * decl,
|
---|
| 178 | const ast::EnumInstType * type,
|
---|
| 179 | unsigned int functionNesting ) :
|
---|
| 180 | FuncGenerator( type, functionNesting ), decl( decl )
|
---|
| 181 | {
|
---|
| 182 | // TODO: These functions are somewhere between instrinsic and autogen,
|
---|
[3322180] | 183 | // could possibly use a new linkage type. For now we just make the
|
---|
| 184 | // basic ones intrinsic to code-gen them as C assignments.
|
---|
[59c8dff] | 185 | // const auto & real_type = decl->base;
|
---|
| 186 | // const auto & basic = real_type.as<ast::BasicType>();
|
---|
| 187 |
|
---|
| 188 | // if(!real_type || (basic && basic->isInteger())) proto_linkage = ast::Linkage::Intrinsic;
|
---|
| 189 |
|
---|
| 190 | // Turns other enumeration type into Intrinstic as well to temporarily fix the recursive
|
---|
| 191 | // construction bug
|
---|
| 192 | proto_linkage = ast::Linkage::Intrinsic;
|
---|
[a488783] | 193 | }
|
---|
| 194 |
|
---|
| 195 | bool shouldAutogen() const final { return true; }
|
---|
| 196 | private:
|
---|
| 197 | void genFuncBody( ast::FunctionDecl * decl ) final;
|
---|
| 198 | void genFieldCtors() final;
|
---|
| 199 | const ast::Decl * getDecl() const final { return decl; }
|
---|
[bb336a6] | 200 | protected:
|
---|
| 201 | void genStandardFuncs() override;
|
---|
[a488783] | 202 | };
|
---|
| 203 |
|
---|
| 204 | class TypeFuncGenerator final : public FuncGenerator {
|
---|
| 205 | const ast::TypeDecl * decl;
|
---|
| 206 | public:
|
---|
| 207 | TypeFuncGenerator( const ast::TypeDecl * decl,
|
---|
| 208 | ast::TypeInstType * type,
|
---|
| 209 | unsigned int functionNesting ) :
|
---|
| 210 | FuncGenerator( type, functionNesting ), decl( decl )
|
---|
| 211 | {}
|
---|
| 212 |
|
---|
| 213 | bool shouldAutogen() const final { return true; }
|
---|
| 214 | void genFieldCtors() final;
|
---|
| 215 | private:
|
---|
| 216 | void genFuncBody( ast::FunctionDecl * decl ) final;
|
---|
| 217 | const ast::Decl * getDecl() const final { return decl; }
|
---|
| 218 | };
|
---|
| 219 |
|
---|
| 220 | // --------------------------------------------------------------------------
|
---|
| 221 | const std::vector<ast::ptr<ast::TypeDecl>>& getGenericParams( const ast::Type * t ) {
|
---|
| 222 | if ( auto inst = dynamic_cast< const ast::StructInstType * >( t ) ) {
|
---|
| 223 | return inst->base->params;
|
---|
| 224 | } else if ( auto inst = dynamic_cast< const ast::UnionInstType * >( t ) ) {
|
---|
| 225 | return inst->base->params;
|
---|
| 226 | }
|
---|
| 227 | static std::vector<ast::ptr<ast::TypeDecl>> const empty;
|
---|
| 228 | return empty;
|
---|
| 229 | }
|
---|
| 230 |
|
---|
[35cc6d4] | 231 | /// Changes the freshly-constructed (non-const) decl so that it has the unused attribute.
|
---|
| 232 | ast::ObjectDecl * addUnusedAttribute( ast::ObjectDecl * decl ) {
|
---|
[a488783] | 233 | decl->attributes.push_back( new ast::Attribute( "unused" ) );
|
---|
[35cc6d4] | 234 | return decl;
|
---|
[a488783] | 235 | }
|
---|
| 236 |
|
---|
| 237 | // --------------------------------------------------------------------------
|
---|
[0bd3faf] | 238 | void AutogenerateRoutines::previsit( const ast::EnumDecl * enumDecl ) {
|
---|
[a488783] | 239 | if ( !enumDecl->body ) return;
|
---|
| 240 |
|
---|
| 241 | ast::EnumInstType enumInst( enumDecl->name );
|
---|
| 242 | enumInst.base = enumDecl;
|
---|
[bb336a6] | 243 |
|
---|
[5d3d281] | 244 | EnumFuncGenerator gen( enumDecl, &enumInst, functionNesting );
|
---|
| 245 | gen.generateAndAppendFunctions( declsToAddAfter );
|
---|
[a488783] | 246 | }
|
---|
| 247 |
|
---|
[0bd3faf] | 248 | void AutogenerateRoutines::previsit( const ast::StructDecl * structDecl ) {
|
---|
[a488783] | 249 | visit_children = false;
|
---|
| 250 | if ( !structDecl->body ) return;
|
---|
| 251 |
|
---|
| 252 | ast::StructInstType structInst( structDecl->name );
|
---|
| 253 | structInst.base = structDecl;
|
---|
| 254 | for ( const ast::TypeDecl * typeDecl : structDecl->params ) {
|
---|
| 255 | structInst.params.push_back( new ast::TypeExpr(
|
---|
| 256 | typeDecl->location,
|
---|
[b230091] | 257 | new ast::TypeInstType( typeDecl )
|
---|
[a488783] | 258 | ) );
|
---|
| 259 | }
|
---|
| 260 | StructFuncGenerator gen( structDecl, &structInst, functionNesting );
|
---|
| 261 | gen.generateAndAppendFunctions( declsToAddAfter );
|
---|
| 262 | }
|
---|
| 263 |
|
---|
[0bd3faf] | 264 | void AutogenerateRoutines::previsit( const ast::UnionDecl * unionDecl ) {
|
---|
[a488783] | 265 | visit_children = false;
|
---|
| 266 | if ( !unionDecl->body ) return;
|
---|
| 267 |
|
---|
| 268 | ast::UnionInstType unionInst( unionDecl->name );
|
---|
| 269 | unionInst.base = unionDecl;
|
---|
| 270 | for ( const ast::TypeDecl * typeDecl : unionDecl->params ) {
|
---|
| 271 | unionInst.params.push_back( new ast::TypeExpr(
|
---|
| 272 | unionDecl->location,
|
---|
[b230091] | 273 | new ast::TypeInstType( typeDecl )
|
---|
[a488783] | 274 | ) );
|
---|
| 275 | }
|
---|
| 276 | UnionFuncGenerator gen( unionDecl, &unionInst, functionNesting );
|
---|
| 277 | gen.generateAndAppendFunctions( declsToAddAfter );
|
---|
| 278 | }
|
---|
| 279 |
|
---|
| 280 | /// Generate ctor/dtors/assign for typedecls, e.g., otype T = int *;
|
---|
[0bd3faf] | 281 | void AutogenerateRoutines::previsit( const ast::TypeDecl * typeDecl ) {
|
---|
[a488783] | 282 | if ( !typeDecl->base ) return;
|
---|
| 283 |
|
---|
| 284 | ast::TypeInstType refType( typeDecl->name, typeDecl );
|
---|
| 285 | TypeFuncGenerator gen( typeDecl, &refType, functionNesting );
|
---|
| 286 | gen.generateAndAppendFunctions( declsToAddAfter );
|
---|
| 287 | }
|
---|
| 288 |
|
---|
[0bd3faf] | 289 | void AutogenerateRoutines::previsit( const ast::TraitDecl * ) {
|
---|
[a488783] | 290 | // Ensure that we don't add assignment ops for types defined as part of the trait
|
---|
| 291 | visit_children = false;
|
---|
| 292 | }
|
---|
| 293 |
|
---|
[0bd3faf] | 294 | void AutogenerateRoutines::previsit( const ast::FunctionDecl * ) {
|
---|
[a488783] | 295 | // Track whether we're currently in a function.
|
---|
| 296 | // Can ignore function type idiosyncrasies, because function type can never
|
---|
| 297 | // declare a new type.
|
---|
| 298 | functionNesting += 1;
|
---|
| 299 | }
|
---|
| 300 |
|
---|
[0bd3faf] | 301 | void AutogenerateRoutines::postvisit( const ast::FunctionDecl * ) {
|
---|
[a488783] | 302 | functionNesting -= 1;
|
---|
| 303 | }
|
---|
| 304 |
|
---|
| 305 | void FuncGenerator::generateAndAppendFunctions(
|
---|
| 306 | std::list<ast::ptr<ast::Decl>> & decls ) {
|
---|
| 307 | if ( !shouldAutogen() ) return;
|
---|
| 308 |
|
---|
| 309 | // Generate the functions (they go into forwards and definitions).
|
---|
| 310 | genStandardFuncs();
|
---|
| 311 | genFieldCtors();
|
---|
| 312 |
|
---|
| 313 | // Now export the lists contents.
|
---|
[5d3d281] | 314 | // decls.splice( decls.end(), forwards ); // mlb wip: delete me
|
---|
[a488783] | 315 | decls.splice( decls.end(), definitions );
|
---|
| 316 | }
|
---|
| 317 |
|
---|
| 318 | void FuncGenerator::produceDecl( const ast::FunctionDecl * decl ) {
|
---|
| 319 | assert( nullptr != decl->stmts );
|
---|
[b1e21da] | 320 | assert( decl->type_params.size() == getGenericParams( type ).size() );
|
---|
[a488783] | 321 |
|
---|
| 322 | definitions.push_back( decl );
|
---|
| 323 | }
|
---|
| 324 |
|
---|
[8913de4] | 325 | void replaceAll( std::vector<ast::ptr<ast::DeclWithType>> & dwts,
|
---|
| 326 | const ast::DeclReplacer::TypeMap & map ) {
|
---|
| 327 | for ( auto & dwt : dwts ) {
|
---|
| 328 | dwt = strict_dynamic_cast<const ast::DeclWithType *>(
|
---|
| 329 | ast::DeclReplacer::replace( dwt, map ) );
|
---|
| 330 | }
|
---|
| 331 | }
|
---|
| 332 |
|
---|
[a488783] | 333 | /// Generates a basic prototype function declaration.
|
---|
[8913de4] | 334 | ast::FunctionDecl * FuncGenerator::genProto( std::string&& name,
|
---|
[a488783] | 335 | std::vector<ast::ptr<ast::DeclWithType>>&& params,
|
---|
| 336 | std::vector<ast::ptr<ast::DeclWithType>>&& returns ) const {
|
---|
| 337 |
|
---|
| 338 | // Handle generic prameters and assertions, if any.
|
---|
| 339 | auto const & old_type_params = getGenericParams( type );
|
---|
[8913de4] | 340 | ast::DeclReplacer::TypeMap oldToNew;
|
---|
[a488783] | 341 | std::vector<ast::ptr<ast::TypeDecl>> type_params;
|
---|
| 342 | std::vector<ast::ptr<ast::DeclWithType>> assertions;
|
---|
| 343 | for ( auto & old_param : old_type_params ) {
|
---|
| 344 | ast::TypeDecl * decl = ast::deepCopy( old_param );
|
---|
[8913de4] | 345 | decl->init = nullptr;
|
---|
| 346 | splice( assertions, decl->assertions );
|
---|
[b1e21da] | 347 | oldToNew.emplace( old_param, decl );
|
---|
[a488783] | 348 | type_params.push_back( decl );
|
---|
| 349 | }
|
---|
[8913de4] | 350 | replaceAll( params, oldToNew );
|
---|
| 351 | replaceAll( returns, oldToNew );
|
---|
| 352 | replaceAll( assertions, oldToNew );
|
---|
[a488783] | 353 |
|
---|
| 354 | ast::FunctionDecl * decl = new ast::FunctionDecl(
|
---|
| 355 | // Auto-generated routines use the type declaration's location.
|
---|
| 356 | getLocation(),
|
---|
[8913de4] | 357 | std::move( name ),
|
---|
[a488783] | 358 | std::move( type_params ),
|
---|
[7edd5c1] | 359 | std::move( assertions ),
|
---|
[a488783] | 360 | std::move( params ),
|
---|
| 361 | std::move( returns ),
|
---|
| 362 | // Only a prototype, no body.
|
---|
| 363 | nullptr,
|
---|
| 364 | // Use static storage if we are at the top level.
|
---|
| 365 | (0 < functionNesting) ? ast::Storage::Classes() : ast::Storage::Static,
|
---|
| 366 | proto_linkage,
|
---|
| 367 | std::vector<ast::ptr<ast::Attribute>>(),
|
---|
| 368 | // Auto-generated routines are inline to avoid conflicts.
|
---|
| 369 | ast::Function::Specs( ast::Function::Inline ) );
|
---|
| 370 | decl->fixUniqueId();
|
---|
| 371 | return decl;
|
---|
| 372 | }
|
---|
| 373 |
|
---|
| 374 | ast::ObjectDecl * FuncGenerator::dstParam() const {
|
---|
[35cc6d4] | 375 | return addUnusedAttribute(
|
---|
| 376 | new ast::ObjectDecl( getLocation(), "_dst",
|
---|
| 377 | new ast::ReferenceType( ast::deepCopy( type ) ) ) );
|
---|
[a488783] | 378 | }
|
---|
| 379 |
|
---|
| 380 | ast::ObjectDecl * FuncGenerator::srcParam() const {
|
---|
[35cc6d4] | 381 | return addUnusedAttribute(
|
---|
| 382 | new ast::ObjectDecl( getLocation(), "_src",
|
---|
| 383 | ast::deepCopy( type ) ) );
|
---|
[a488783] | 384 | }
|
---|
| 385 |
|
---|
| 386 | /// Use the current type T to create `void ?{}(T & _dst)`.
|
---|
| 387 | ast::FunctionDecl * FuncGenerator::genCtorProto() const {
|
---|
| 388 | return genProto( "?{}", { dstParam() }, {} );
|
---|
| 389 | }
|
---|
| 390 |
|
---|
| 391 | /// Use the current type T to create `void ?{}(T & _dst, T _src)`.
|
---|
| 392 | ast::FunctionDecl * FuncGenerator::genCopyProto() const {
|
---|
| 393 | return genProto( "?{}", { dstParam(), srcParam() }, {} );
|
---|
| 394 | }
|
---|
| 395 |
|
---|
[af746cc] | 396 | /// Use the current type T to create `void ^?{}(T & _dst)`.
|
---|
[a488783] | 397 | ast::FunctionDecl * FuncGenerator::genDtorProto() const {
|
---|
| 398 | // The destructor must be mutex on a concurrent type.
|
---|
| 399 | auto dst = dstParam();
|
---|
| 400 | if ( isConcurrentType() ) {
|
---|
| 401 | add_qualifiers( dst->type, ast::CV::Qualifiers( ast::CV::Mutex ) );
|
---|
| 402 | }
|
---|
| 403 | return genProto( "^?{}", { dst }, {} );
|
---|
| 404 | }
|
---|
| 405 |
|
---|
[85855b0] | 406 | /// Use the current type T to create `T ?=?(T & _dst, T _src)`.
|
---|
[a488783] | 407 | ast::FunctionDecl * FuncGenerator::genAssignProto() const {
|
---|
| 408 | // Only the name is different, so just reuse the generation function.
|
---|
| 409 | auto retval = srcParam();
|
---|
| 410 | retval->name = "_ret";
|
---|
| 411 | return genProto( "?=?", { dstParam(), srcParam() }, { retval } );
|
---|
| 412 | }
|
---|
| 413 |
|
---|
| 414 | // This one can return null if the last field is an unnamed bitfield.
|
---|
| 415 | ast::FunctionDecl * FuncGenerator::genFieldCtorProto(
|
---|
| 416 | unsigned int fields ) const {
|
---|
| 417 | assert( 0 < fields );
|
---|
| 418 | auto aggr = strict_dynamic_cast<const ast::AggregateDecl *>( getDecl() );
|
---|
| 419 |
|
---|
| 420 | std::vector<ast::ptr<ast::DeclWithType>> params = { dstParam() };
|
---|
| 421 | for ( unsigned int index = 0 ; index < fields ; ++index ) {
|
---|
| 422 | auto member = aggr->members[index].strict_as<ast::DeclWithType>();
|
---|
[fb4dc28] | 423 | if ( ast::isUnnamedBitfield(
|
---|
[a488783] | 424 | dynamic_cast<const ast::ObjectDecl *>( member ) ) ) {
|
---|
| 425 | if ( index == fields - 1 ) {
|
---|
| 426 | return nullptr;
|
---|
| 427 | }
|
---|
| 428 | continue;
|
---|
| 429 | }
|
---|
| 430 |
|
---|
| 431 | auto * paramType = ast::deepCopy( member->get_type() );
|
---|
[b262cb3] | 432 | erase_if( paramType->attributes, []( ast::Attribute const * attr ){
|
---|
| 433 | return !attr->isValidOnFuncParam();
|
---|
| 434 | } );
|
---|
[a488783] | 435 | ast::ObjectDecl * param = new ast::ObjectDecl(
|
---|
| 436 | getLocation(), member->name, paramType );
|
---|
| 437 | for ( auto & attr : member->attributes ) {
|
---|
| 438 | if ( attr->isValidOnFuncParam() ) {
|
---|
| 439 | param->attributes.push_back( attr );
|
---|
| 440 | }
|
---|
| 441 | }
|
---|
| 442 | params.emplace_back( param );
|
---|
| 443 | }
|
---|
| 444 | return genProto( "?{}", std::move( params ), {} );
|
---|
| 445 | }
|
---|
| 446 |
|
---|
| 447 | void appendReturnThis( ast::FunctionDecl * decl ) {
|
---|
| 448 | assert( 1 <= decl->params.size() );
|
---|
| 449 | assert( 1 == decl->returns.size() );
|
---|
| 450 | assert( decl->stmts );
|
---|
| 451 |
|
---|
| 452 | const CodeLocation& location = (decl->stmts->kids.empty())
|
---|
| 453 | ? decl->stmts->location : decl->stmts->kids.back()->location;
|
---|
| 454 | const ast::DeclWithType * thisParam = decl->params.front();
|
---|
| 455 | decl->stmts.get_and_mutate()->push_back(
|
---|
| 456 | new ast::ReturnStmt( location,
|
---|
| 457 | new ast::VariableExpr( location, thisParam )
|
---|
| 458 | )
|
---|
| 459 | );
|
---|
| 460 | }
|
---|
| 461 |
|
---|
| 462 | void FuncGenerator::genStandardFuncs() {
|
---|
| 463 | // The order here determines the order that these functions are generated.
|
---|
| 464 | // Assignment should come last since it uses copy constructor in return.
|
---|
| 465 | ast::FunctionDecl *(FuncGenerator::*standardProtos[4])() const = {
|
---|
| 466 | &FuncGenerator::genCtorProto, &FuncGenerator::genCopyProto,
|
---|
| 467 | &FuncGenerator::genDtorProto, &FuncGenerator::genAssignProto };
|
---|
| 468 | for ( auto & generator : standardProtos ) {
|
---|
| 469 | ast::FunctionDecl * decl = (this->*generator)();
|
---|
| 470 | genFuncBody( decl );
|
---|
| 471 | if ( CodeGen::isAssignment( decl->name ) ) {
|
---|
| 472 | appendReturnThis( decl );
|
---|
| 473 | }
|
---|
| 474 | produceDecl( decl );
|
---|
| 475 | }
|
---|
| 476 | }
|
---|
| 477 |
|
---|
| 478 | void StructFuncGenerator::genFieldCtors() {
|
---|
| 479 | // The field constructors are only generated if the default constructor
|
---|
| 480 | // and copy constructor are both generated, since the need both.
|
---|
| 481 | unsigned numCtors = std::count_if( definitions.begin(), definitions.end(),
|
---|
| 482 | [](const ast::Decl * decl){ return CodeGen::isConstructor( decl->name ); }
|
---|
| 483 | );
|
---|
| 484 | if ( 2 != numCtors ) return;
|
---|
| 485 |
|
---|
| 486 | for ( unsigned int num = 1 ; num <= decl->members.size() ; ++num ) {
|
---|
| 487 | ast::FunctionDecl * ctor = genFieldCtorProto( num );
|
---|
| 488 | if ( nullptr == ctor ) {
|
---|
| 489 | continue;
|
---|
| 490 | }
|
---|
| 491 | makeFieldCtorBody( decl->members.begin(), decl->members.end(), ctor );
|
---|
| 492 | produceDecl( ctor );
|
---|
| 493 | }
|
---|
| 494 | }
|
---|
| 495 |
|
---|
| 496 | void StructFuncGenerator::genFuncBody( ast::FunctionDecl * functionDecl ) {
|
---|
| 497 | // Generate appropriate calls to member constructors and assignment.
|
---|
| 498 | // Destructor needs to do everything in reverse,
|
---|
| 499 | // so pass "forward" based on whether the function is a destructor
|
---|
| 500 | if ( CodeGen::isDestructor( functionDecl->name ) ) {
|
---|
| 501 | makeFunctionBody( decl->members.rbegin(), decl->members.rend(),
|
---|
| 502 | functionDecl, SymTab::LoopBackward );
|
---|
| 503 | } else {
|
---|
| 504 | makeFunctionBody( decl->members.begin(), decl->members.end(),
|
---|
| 505 | functionDecl, SymTab::LoopForward );
|
---|
| 506 | }
|
---|
| 507 | }
|
---|
| 508 |
|
---|
[4e2f1b2] | 509 | const ast::Stmt * StructFuncGenerator::makeMemberOp(
|
---|
[a488783] | 510 | const CodeLocation& location, const ast::ObjectDecl * dstParam,
|
---|
| 511 | const ast::Expr * src, const ast::ObjectDecl * field,
|
---|
| 512 | ast::FunctionDecl * func, SymTab::LoopDirection direction ) {
|
---|
[0bd3faf] | 513 | InitTweak::InitExpander srcParam( src );
|
---|
[a488783] | 514 | // Assign to destination.
|
---|
[24d6572] | 515 | ast::MemberExpr * dstSelect = new ast::MemberExpr(
|
---|
[a488783] | 516 | location,
|
---|
| 517 | field,
|
---|
| 518 | new ast::CastExpr(
|
---|
| 519 | location,
|
---|
| 520 | new ast::VariableExpr( location, dstParam ),
|
---|
| 521 | dstParam->type.strict_as<ast::ReferenceType>()->base
|
---|
| 522 | )
|
---|
| 523 | );
|
---|
[4e2f1b2] | 524 | const ast::Stmt * stmt = genImplicitCall(
|
---|
[a488783] | 525 | srcParam, dstSelect, location, func->name,
|
---|
| 526 | field, direction
|
---|
| 527 | );
|
---|
[14c0f7b] | 528 | // This could return the above directly, except the generated code is
|
---|
| 529 | // built using the structure's members and that means all the scoped
|
---|
| 530 | // names (the forall parameters) are incorrect. This corrects them.
|
---|
| 531 | if ( stmt && !decl->params.empty() ) {
|
---|
| 532 | ast::DeclReplacer::TypeMap oldToNew;
|
---|
| 533 | for ( auto pair : group_iterate( decl->params, func->type_params ) ) {
|
---|
| 534 | oldToNew.emplace( std::get<0>(pair), std::get<1>(pair) );
|
---|
| 535 | }
|
---|
| 536 | auto node = ast::DeclReplacer::replace( stmt, oldToNew );
|
---|
| 537 | stmt = strict_dynamic_cast<const ast::Stmt *>( node );
|
---|
| 538 | }
|
---|
| 539 | return stmt;
|
---|
[a488783] | 540 | }
|
---|
| 541 |
|
---|
| 542 | template<typename Iterator>
|
---|
| 543 | void StructFuncGenerator::makeFunctionBody( Iterator current, Iterator end,
|
---|
| 544 | ast::FunctionDecl * func, SymTab::LoopDirection direction ) {
|
---|
| 545 | // Trying to get the best code location. Should probably use a helper or
|
---|
| 546 | // just figure out what that would be given where this is called.
|
---|
| 547 | assert( nullptr == func->stmts );
|
---|
| 548 | const CodeLocation& location = func->location;
|
---|
| 549 |
|
---|
| 550 | ast::CompoundStmt * stmts = new ast::CompoundStmt( location );
|
---|
| 551 |
|
---|
| 552 | for ( ; current != end ; ++current ) {
|
---|
| 553 | const ast::ptr<ast::Decl> & member = *current;
|
---|
| 554 | auto field = member.as<ast::ObjectDecl>();
|
---|
| 555 | if ( nullptr == field ) {
|
---|
| 556 | continue;
|
---|
| 557 | }
|
---|
| 558 |
|
---|
| 559 | // Don't assign to constant members (but do construct/destruct them).
|
---|
| 560 | if ( CodeGen::isAssignment( func->name ) ) {
|
---|
| 561 | // For array types we need to strip off the array layers.
|
---|
| 562 | const ast::Type * type = field->get_type();
|
---|
| 563 | while ( auto at = dynamic_cast<const ast::ArrayType *>( type ) ) {
|
---|
| 564 | type = at->base;
|
---|
| 565 | }
|
---|
| 566 | if ( type->is_const() ) {
|
---|
| 567 | continue;
|
---|
| 568 | }
|
---|
| 569 | }
|
---|
| 570 |
|
---|
| 571 | assert( !func->params.empty() );
|
---|
| 572 | const ast::ObjectDecl * dstParam =
|
---|
| 573 | func->params.front().strict_as<ast::ObjectDecl>();
|
---|
| 574 | const ast::ObjectDecl * srcParam = nullptr;
|
---|
| 575 | if ( 2 == func->params.size() ) {
|
---|
| 576 | srcParam = func->params.back().strict_as<ast::ObjectDecl>();
|
---|
| 577 | }
|
---|
| 578 |
|
---|
[24d6572] | 579 | ast::MemberExpr * srcSelect = (srcParam) ? new ast::MemberExpr(
|
---|
[a488783] | 580 | location, field, new ast::VariableExpr( location, srcParam )
|
---|
| 581 | ) : nullptr;
|
---|
[4e2f1b2] | 582 | const ast::Stmt * stmt =
|
---|
[a488783] | 583 | makeMemberOp( location, dstParam, srcSelect, field, func, direction );
|
---|
| 584 |
|
---|
| 585 | if ( nullptr != stmt ) {
|
---|
[4e2f1b2] | 586 | stmts->kids.emplace_back( stmt );
|
---|
[a488783] | 587 | }
|
---|
| 588 | }
|
---|
| 589 |
|
---|
| 590 | func->stmts = stmts;
|
---|
| 591 | }
|
---|
| 592 |
|
---|
| 593 | template<typename Iterator>
|
---|
| 594 | void StructFuncGenerator::makeFieldCtorBody( Iterator current, Iterator end,
|
---|
| 595 | ast::FunctionDecl * func ) {
|
---|
| 596 | const CodeLocation& location = func->location;
|
---|
| 597 | auto & params = func->params;
|
---|
| 598 | // Need at least the constructed parameter and one field parameter.
|
---|
| 599 | assert( 2 <= params.size() );
|
---|
| 600 |
|
---|
| 601 | ast::CompoundStmt * stmts = new ast::CompoundStmt( location );
|
---|
| 602 |
|
---|
| 603 | auto dstParam = params.front().strict_as<ast::ObjectDecl>();
|
---|
| 604 | // Skip over the 'this' parameter.
|
---|
| 605 | for ( auto param = params.begin() + 1 ; current != end ; ++current ) {
|
---|
| 606 | const ast::ptr<ast::Decl> & member = *current;
|
---|
[4e2f1b2] | 607 | const ast::Stmt * stmt = nullptr;
|
---|
[a488783] | 608 | auto field = member.as<ast::ObjectDecl>();
|
---|
| 609 | // Not sure why it could be null.
|
---|
| 610 | // Don't make a function for a parameter that is an unnamed bitfield.
|
---|
[fb4dc28] | 611 | if ( nullptr == field || ast::isUnnamedBitfield( field ) ) {
|
---|
[a488783] | 612 | continue;
|
---|
| 613 | // Matching Parameter: Initialize the field by copy.
|
---|
| 614 | } else if ( params.end() != param ) {
|
---|
| 615 | const ast::Expr *srcSelect = new ast::VariableExpr(
|
---|
| 616 | func->location, param->get() );
|
---|
| 617 | stmt = makeMemberOp( location, dstParam, srcSelect, field, func, SymTab::LoopForward );
|
---|
| 618 | ++param;
|
---|
| 619 | // No Matching Parameter: Initialize the field by default constructor.
|
---|
| 620 | } else {
|
---|
| 621 | stmt = makeMemberOp( location, dstParam, nullptr, field, func, SymTab::LoopForward );
|
---|
| 622 | }
|
---|
| 623 |
|
---|
| 624 | if ( nullptr != stmt ) {
|
---|
[4e2f1b2] | 625 | stmts->kids.emplace_back( stmt );
|
---|
[a488783] | 626 | }
|
---|
| 627 | }
|
---|
| 628 | func->stmts = stmts;
|
---|
| 629 | }
|
---|
| 630 |
|
---|
| 631 | void UnionFuncGenerator::genFieldCtors() {
|
---|
| 632 | // Field constructors are only generated if default and copy constructor
|
---|
| 633 | // are generated, since they need access to both
|
---|
| 634 | unsigned numCtors = std::count_if( definitions.begin(), definitions.end(),
|
---|
| 635 | []( const ast::Decl * d ){ return CodeGen::isConstructor( d->name ); }
|
---|
| 636 | );
|
---|
| 637 | if ( 2 != numCtors ) {
|
---|
| 638 | return;
|
---|
| 639 | }
|
---|
| 640 |
|
---|
| 641 | // Create a constructor which takes the first member type as a
|
---|
| 642 | // parameter. For example for `union A { int x; char y; };` generate
|
---|
| 643 | // a function with signature `void ?{}(A *, int)`. This mimics C's
|
---|
| 644 | // behaviour which initializes the first member of the union.
|
---|
| 645 |
|
---|
| 646 | // Still, there must be some members.
|
---|
| 647 | if ( !decl->members.empty() ) {
|
---|
| 648 | ast::FunctionDecl * ctor = genFieldCtorProto( 1 );
|
---|
| 649 | if ( nullptr == ctor ) {
|
---|
| 650 | return;
|
---|
| 651 | }
|
---|
| 652 | auto params = ctor->params;
|
---|
| 653 | auto dstParam = params.front().strict_as<ast::ObjectDecl>();
|
---|
| 654 | auto srcParam = params.back().strict_as<ast::ObjectDecl>();
|
---|
| 655 | ctor->stmts = new ast::CompoundStmt( getLocation(),
|
---|
| 656 | { makeAssignOp( getLocation(), dstParam, srcParam ) }
|
---|
| 657 | );
|
---|
| 658 | produceDecl( ctor );
|
---|
| 659 | }
|
---|
| 660 | }
|
---|
| 661 |
|
---|
| 662 | void UnionFuncGenerator::genFuncBody( ast::FunctionDecl * functionDecl ) {
|
---|
| 663 | const CodeLocation& location = functionDecl->location;
|
---|
| 664 | auto & params = functionDecl->params;
|
---|
| 665 | if ( InitTweak::isCopyConstructor( functionDecl )
|
---|
| 666 | || InitTweak::isAssignment( functionDecl ) ) {
|
---|
| 667 | assert( 2 == params.size() );
|
---|
| 668 | auto dstParam = params.front().strict_as<ast::ObjectDecl>();
|
---|
| 669 | auto srcParam = params.back().strict_as<ast::ObjectDecl>();
|
---|
| 670 | functionDecl->stmts = new ast::CompoundStmt( location,
|
---|
| 671 | { makeAssignOp( location, dstParam, srcParam ) }
|
---|
| 672 | );
|
---|
| 673 | } else {
|
---|
| 674 | assert( 1 == params.size() );
|
---|
| 675 | // Default constructor and destructor is empty.
|
---|
| 676 | functionDecl->stmts = new ast::CompoundStmt( location );
|
---|
| 677 | }
|
---|
| 678 | }
|
---|
| 679 |
|
---|
| 680 | ast::ExprStmt * UnionFuncGenerator::makeAssignOp( const CodeLocation& location,
|
---|
| 681 | const ast::ObjectDecl * dstParam, const ast::ObjectDecl * srcParam ) {
|
---|
| 682 | return new ast::ExprStmt( location, new ast::UntypedExpr(
|
---|
| 683 | location,
|
---|
| 684 | new ast::NameExpr( location, "__builtin_memcpy" ),
|
---|
| 685 | {
|
---|
| 686 | new ast::AddressExpr( location,
|
---|
| 687 | new ast::VariableExpr( location, dstParam ) ),
|
---|
| 688 | new ast::AddressExpr( location,
|
---|
| 689 | new ast::VariableExpr( location, srcParam ) ),
|
---|
| 690 | new ast::SizeofExpr( location, srcParam->type ),
|
---|
| 691 | } ) );
|
---|
| 692 | }
|
---|
| 693 |
|
---|
[bb336a6] | 694 | void EnumFuncGenerator::genStandardFuncs() {
|
---|
| 695 | // do everything FuncGenerator does except not make ForwardDecls
|
---|
| 696 | ast::FunctionDecl *(FuncGenerator::*standardProtos[4])() const = {
|
---|
| 697 | &EnumFuncGenerator::genCtorProto, &EnumFuncGenerator::genCopyProto,
|
---|
| 698 | &EnumFuncGenerator::genDtorProto, &EnumFuncGenerator::genAssignProto };
|
---|
| 699 |
|
---|
| 700 | for ( auto & generator : standardProtos ) {
|
---|
| 701 | ast::FunctionDecl * decl = (this->*generator)();
|
---|
| 702 | genFuncBody( decl );
|
---|
| 703 | if ( CodeGen::isAssignment( decl->name ) ) {
|
---|
| 704 | appendReturnThis( decl );
|
---|
| 705 | }
|
---|
| 706 | produceDecl( decl );
|
---|
| 707 | }
|
---|
| 708 | }
|
---|
| 709 |
|
---|
[a488783] | 710 | void EnumFuncGenerator::genFieldCtors() {
|
---|
| 711 | // Enumerations to not have field constructors.
|
---|
| 712 | }
|
---|
| 713 |
|
---|
| 714 | void EnumFuncGenerator::genFuncBody( ast::FunctionDecl * functionDecl ) {
|
---|
| 715 | const CodeLocation& location = functionDecl->location;
|
---|
| 716 | auto & params = functionDecl->params;
|
---|
| 717 | if ( InitTweak::isCopyConstructor( functionDecl )
|
---|
| 718 | || InitTweak::isAssignment( functionDecl ) ) {
|
---|
| 719 | assert( 2 == params.size() );
|
---|
| 720 | auto dstParam = params.front().strict_as<ast::ObjectDecl>();
|
---|
| 721 | auto srcParam = params.back().strict_as<ast::ObjectDecl>();
|
---|
| 722 |
|
---|
| 723 | /* This looks like a recursive call, but code-gen will turn it into
|
---|
| 724 | * a C-style assignment.
|
---|
| 725 | *
|
---|
| 726 | * This is still before function pointer type conversion,
|
---|
| 727 | * so this will have to do it manually.
|
---|
| 728 | *
|
---|
| 729 | * It will also reference the parent function declaration, creating
|
---|
| 730 | * a cycle for references. This also means that the ref-counts are
|
---|
| 731 | * now non-zero and the declaration will be deleted if it ever
|
---|
| 732 | * returns to zero.
|
---|
| 733 | */
|
---|
| 734 | auto callExpr = new ast::ApplicationExpr( location,
|
---|
| 735 | ast::VariableExpr::functionPointer( location, functionDecl ),
|
---|
| 736 | {
|
---|
[496ffc17] | 737 | new ast::VariableExpr( location, dstParam ),
|
---|
| 738 | new ast::VariableExpr( location, srcParam )
|
---|
[a488783] | 739 | }
|
---|
| 740 | );
|
---|
[c75b30a] | 741 |
|
---|
[a488783] | 742 | functionDecl->stmts = new ast::CompoundStmt( location,
|
---|
| 743 | { new ast::ExprStmt( location, callExpr ) }
|
---|
| 744 | );
|
---|
| 745 | } else {
|
---|
| 746 | assert( 1 == params.size() );
|
---|
| 747 | // Default constructor and destructor is empty.
|
---|
| 748 | functionDecl->stmts = new ast::CompoundStmt( location );
|
---|
| 749 | }
|
---|
| 750 | }
|
---|
| 751 |
|
---|
| 752 | void TypeFuncGenerator::genFieldCtors() {
|
---|
| 753 | // Opaque types do not have field constructors.
|
---|
| 754 | }
|
---|
| 755 |
|
---|
| 756 | void TypeFuncGenerator::genFuncBody( ast::FunctionDecl * functionDecl ) {
|
---|
| 757 | const CodeLocation& location = functionDecl->location;
|
---|
| 758 | auto & params = functionDecl->type->params;
|
---|
| 759 | assertf( 1 == params.size() || 2 == params.size(),
|
---|
| 760 | "Incorrect number of parameters in autogenerated typedecl function: %zd",
|
---|
| 761 | params.size() );
|
---|
| 762 | auto dstParam = params.front().strict_as<ast::ObjectDecl>();
|
---|
| 763 | auto srcParam = (2 == params.size())
|
---|
| 764 | ? params.back().strict_as<ast::ObjectDecl>() : nullptr;
|
---|
| 765 | // Generate appropriate calls to member constructor and assignment.
|
---|
| 766 | ast::UntypedExpr * expr = new ast::UntypedExpr( location,
|
---|
| 767 | new ast::NameExpr( location, functionDecl->name )
|
---|
| 768 | );
|
---|
| 769 | expr->args.push_back( new ast::CastExpr( location,
|
---|
| 770 | new ast::VariableExpr( location, dstParam ),
|
---|
| 771 | new ast::ReferenceType( decl->base )
|
---|
| 772 | ) );
|
---|
| 773 | if ( srcParam ) {
|
---|
| 774 | expr->args.push_back( new ast::CastExpr( location,
|
---|
| 775 | new ast::VariableExpr( location, srcParam ),
|
---|
| 776 | decl->base
|
---|
| 777 | ) );
|
---|
| 778 | }
|
---|
| 779 | functionDecl->stmts = new ast::CompoundStmt( location,
|
---|
| 780 | { new ast::ExprStmt( location, expr ) }
|
---|
| 781 | );
|
---|
| 782 | }
|
---|
| 783 |
|
---|
| 784 | } // namespace
|
---|
| 785 |
|
---|
| 786 | void autogenerateRoutines( ast::TranslationUnit & translationUnit ) {
|
---|
[0bd3faf] | 787 | ast::Pass<AutogenerateRoutines>::run( translationUnit );
|
---|
[a488783] | 788 | }
|
---|
| 789 |
|
---|
| 790 | } // Validate
|
---|
| 791 |
|
---|
| 792 | // Local Variables: //
|
---|
| 793 | // tab-width: 4 //
|
---|
| 794 | // mode: c++ //
|
---|
| 795 | // compile-command: "make install" //
|
---|
| 796 | // End: //
|
---|