source: src/GenPoly/GenPoly.h @ 66f8528

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 66f8528 was 2c57025, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

add support for built-in sized trait which decouples size/alignment information from otype parameters, add test for sized trait

  • Property mode set to 100644
File size: 4.9 KB
RevLine 
[51587aa]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//
[33a7b6d]7// GenPoly.h --
[51587aa]8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
[bdf1954]11// Last Modified By : Rob Schluntz
12// Last Modified On : Tue Nov 24 15:24:38 2015
13// Update Count     : 6
[51587aa]14//
[51b7345]15
[b1a6d6b]16#ifndef GENPOLY_H
17#define GENPOLY_H
18
[51b7345]19#include <string>
20#include <iostream>
[8488c715]21#include <utility>
[ffad73a]22
[bfae637]23#include "ErasableScopedMap.h"
24
[adc6781]25#include "SymTab/Mangler.h"
26
[51b7345]27#include "SynTree/Declaration.h"
[aadc9a4]28#include "SynTree/Type.h"
[ffad73a]29#include "SynTree/TypeSubstitution.h"
[51b7345]30
31namespace GenPoly {
[2c57025]32        typedef ErasableScopedMap< std::string, TypeDecl::Data > TyVarMap;
[bdf1954]33
[c2ad3c9]34        /// Replaces a TypeInstType by its referrent in the environment, if applicable
35        Type* replaceTypeInst( Type* type, const TypeSubstitution* env );
[33a7b6d]36
[ffad73a]37        /// returns polymorphic type if is polymorphic type, NULL otherwise; will look up substitution in env if provided
[0f889a77]38        Type *isPolyType( Type *type, const TypeSubstitution *env = 0 );
[33a7b6d]39
[0f889a77]40        /// returns polymorphic type if is polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
[ffad73a]41        Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
42
[3bb195cb]43        /// returns dynamic-layout type if is dynamic-layout type in tyVars, NULL otherwise; will look up substitution in env if provided
[33a7b6d]44        ReferenceToType *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
[3bb195cb]45
46        /// true iff function has dynamic-layout return type under the given type variable map
47        ReferenceToType *isDynRet( FunctionType *function, const TyVarMap &tyVars );
48
49        /// true iff function has dynamic-layout return type under the type variable map generated from its forall-parameters
50        ReferenceToType *isDynRet( FunctionType *function );
51
52        /// A function needs an adapter if it returns a dynamic-layout value or if any of its parameters have dynamic-layout type
53        bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVarr );
54
[ffad73a]55        /// returns polymorphic type if is pointer to polymorphic type, NULL otherwise; will look up substitution in env if provided
[0f889a77]56        Type *isPolyPtr( Type *type, const TypeSubstitution *env = 0 );
[33a7b6d]57
[0f889a77]58        /// returns polymorphic type if is pointer to polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
[ffad73a]59        Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
60
[8488c715]61        /// if the base type (after dereferencing N >= 0 pointers) is a polymorphic type, returns the base type, NULL otherwise;
62        /// N will be stored in levels, if provided, will look up substitution in env if provided
63        Type *hasPolyBase( Type *type, int *levels = 0, const TypeSubstitution *env = 0 );
[05d47278]64
[8488c715]65        /// if the base type (after dereferencing N >= 0 pointers) is a polymorphic type in tyVars, returns the base type, NULL otherwise;
66        /// N will be stored in levels, if provided, will look up substitution in env if provided
67        Type *hasPolyBase( Type *type, const TyVarMap &tyVars, int *levels = 0, const TypeSubstitution *env = 0 );
[05d47278]68
[7754cde]69        /// Returns a pointer to the base FunctionType if ty is the type of a function (or pointer to one), NULL otherwise
[05d47278]70        FunctionType *getFunctionType( Type *ty );
71
[8488c715]72        /// If expr (after dereferencing N >= 0 pointers) is a variable expression, returns the variable expression, NULL otherwise;
73        /// N will be stored in levels, if provided
74        VariableExpr *getBaseVar( Expression *expr, int *levels = 0 );
[7754cde]75
[2c57025]76        /// Adds the type variable `tyVar` to `tyVarMap`
77        void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap );
78
[aadc9a4]79        /// Adds the declarations in the forall list of type (and its pointed-to type if it's a pointer type) to `tyVarMap`
80        void makeTyVarMap( Type *type, TyVarMap &tyVarMap );
[33a7b6d]81
[ffad73a]82        /// Prints type variable map
[01aeade]83        void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap );
[ffad73a]84
[adc6781]85        /// Gets the mangled name of this type; alias for SymTab::Mangler::mangleType().
86        inline std::string mangleType( Type *ty ) { return SymTab::Mangler::mangleType( ty ); }
[33a7b6d]87
[adc6781]88        /// Gets the name of the sizeof parameter for the type, given its mangled name
89        inline std::string sizeofName( const std::string &name ) { return std::string( "_sizeof_" ) + name; }
90
91        /// Gets the name of the alignof parameter for the type, given its mangled name
92        inline std::string alignofName( const std::string &name ) { return std::string( "_alignof_" ) + name; }
[ffad73a]93
[adc6781]94        /// Gets the name of the offsetof parameter for the type, given its mangled name
95        inline std::string offsetofName( const std::string &name ) { return std::string( "_offsetof_" ) + name; }
[05d47278]96
[adc6781]97        /// Gets the name of the layout function for a given aggregate type, given its declaration
98        inline std::string layoutofName( AggregateDecl *decl ) { return std::string( "_layoutof_" ) + decl->get_name(); }
[33a7b6d]99
[51b7345]100} // namespace GenPoly
[b1a6d6b]101
[01aeade]102#endif // GENPOLY_H
103
[51587aa]104// Local Variables: //
105// tab-width: 4 //
106// mode: c++ //
107// compile-command: "make install" //
108// End: //
Note: See TracBrowser for help on using the repository browser.