Polaris: Type Class Reference

Type Class Reference

type of an expression or variable More...

#include <Type.h>

List of all members.

Public Member Functions

 ~Type ()
 Type ()
 Constructor -- initializes to UNDEFINED_TYPE.
 Type (const char *type_name, int size, int rank)
 Set the type from a name of the type, the size plus the rank of the basic type.
 Type (const char *type_name, int size)
 Set the type from a name of the type plus the size.
 Type (const char *type_name)
 Set the type from just a name of the type The type is a scalar by default.
 Type (EXPR_TYPE type, int size, int rank)
 Set the type directly given an EXPR_TYPE, the size of the basic type and the rank.
 Type (EXPR_TYPE type, int size)
 Set the type directly given an EXPR_TYPE and the size.
 Type (EXPR_TYPE type)
 Set the type directly, but also select the default rank to be 0 and the default size for the specified type.
 Type (const Type &other)
 Set the type from a different Type object.
EXPR_TYPE data_type () const
 Return the type.
void rank_known (Boolean known)
 Set whether the rank of the Type is known.
bool size_defaulted ()
 returns true if the user did not specify an explicit size
Boolean rank_known () const
 Is the rank of the Type known?
int rank () const
 Return the rank of the Type-- returns -1 if the rank is unknown.
Boolean is_scalar () const
 Does the rank equal 0?
void redimension (int rank)
 Set the rank of the Type object to rank where -1 = unknown, 0 = scalar, 1 = 1, etc..
int size () const
 Return the size.
void set (const char *type_name, int size)
 Set the type from a name of the type plus a size.
void set (const char *type_name)
 Set the type from just a name of the type The size is chosen from a default value for the specified type.
void set (EXPR_TYPE type, int size)
 Set the type directly given an EXPR_TYPE and a size.
void set (EXPR_TYPE type)
 Set the type from just a name of the type The size is chosen from a default value for the specified type.
void set (int size)
 Set the size field and keep the EXPR_TYPE constant.
void format (String &str) const
 Convert to printable String form and place into str.
const char * name_ref () const
 Return the string corresponding to the type name.
int operator== (const Type &other) const
 Returns 1 iff the two types are equal, or if one or more of them is a UNKNOWN_TYPE.
int operator!= (const Type &other) const
 Returns 1 iff operator== would return 0.
int is_void () const
 Returns 1 if this type is a VOID_TYPE This is equivalent to "type() == VOID_TYPE".
int structures_OK () const
 Check the structure of the data for errors or inconsistency Return 0 and print error message if problems found, otherwise return 1 without message.

Friends

ostream & operator<< (ostream &o, const Type &type)


Detailed Description

type of an expression or variable

Polaris C++ VDL

See also:
Type.h

Type.h

Type.inline.h

Type.cc

Description

Class Type is simply the type of an expression, constant, function return, variable, etc. Each type contains the type of data (integer, real, etc..), a bit specifying whether the number of dimensions is known, the number of dimensions (0 - 7 where 0 represents a scalar) and a size. Note that because a size field is included, types such as INTEGER*4, etc. are allowed and differentiated. Thus it is important to make sure that the size field is set correctly and consistently.

Note that CHARACTER-type dummy variables of length (*) are represented with a size of 0

IMPORTANT -- Default Type Selection

If you are creating a Type and you do not know specifically the size of that type, NEVER give a default value yourself. For example, specifying "Type type(INTEGER_TYPE, 0)"--- which represents an integer scalar of the default size--- is generally MUCH preferable to specifying the size as in "Type type(INTEGER_TYPE, 0, 4)" (integer scalar of size 4), because the default sizes of expression types are subject to change, even on different runs (through possible command-line options). If you are copying the size from somewhere else, of course, then specifying the exact size from the other source is correct.

make_type functions

Along with the Type class, there are also stand-alone functions---"make_type" functions---which parallel all or most of the constructors, and which return a Type given the default parameters. These functions can be useful in passing new Type objects into a constructor for Expressions classes or other classes which require a Type parameter. For example, a new VariableSymbol of type INTEGER which will have 2 dimensions (using the default size for that INTEGER) can be created by the following code:

VariableSymbol *var = new VariableSymbol( "I", make_type(INTEGER_TYPE, 2), NOT_FORMAL, NOT_SAVED);

Definition at line 109 of file Type.h.


Constructor & Destructor Documentation

Type::~Type  )  [inline]
 

Definition at line 134 of file Type.h.

References unregister_instance().

Type::Type  )  [inline]
 

Constructor -- initializes to UNDEFINED_TYPE.

< Set to an initial value anyway

Definition at line 294 of file Type.h.

References type_object::_rank, type_object::_rank_known, type_object::_type, False, register_instance(), and UNDEFINED_TYPE.

Type::Type const char *  type_name,
int  size,
int  rank
[inline]
 

Set the type from a name of the type, the size plus the rank of the basic type.

Definition at line 308 of file Type.h.

References redimension(), register_instance(), and set().

Type::Type const char *  type_name,
int  size
[inline]
 

Set the type from a name of the type plus the size.

< default = scalar

Definition at line 319 of file Type.h.

References redimension(), register_instance(), and set().

Type::Type const char *  type_name  )  [inline]
 

Set the type from just a name of the type The type is a scalar by default.

The size is chosen from a default value for the specified type. It is important to use this method (instead of Type::Type(const char * , int ) to set the size if the size is not specified otherwise because the defaults could change depending on command-line options. Using this method will keep the size consistent.

Definition at line 330 of file Type.h.

References redimension(), register_instance(), and set().

Type::Type EXPR_TYPE  type,
int  size,
int  rank
[inline]
 

Set the type directly given an EXPR_TYPE, the size of the basic type and the rank.

Definition at line 341 of file Type.h.

References redimension(), register_instance(), and set().

Type::Type EXPR_TYPE  type,
int  size
[inline]
 

Set the type directly given an EXPR_TYPE and the size.

< default = scalar

Definition at line 352 of file Type.h.

References redimension(), register_instance(), and set().

Type::Type EXPR_TYPE  type  )  [inline]
 

Set the type directly, but also select the default rank to be 0 and the default size for the specified type.

It is important to use this method (rather than Type::Type(EXPR_TYPE t , int ) to set the size if the size is not specified otherwise because the defaults could change depending on command-line options. Using this method will keep the size consistent.

Definition at line 363 of file Type.h.

References redimension(), register_instance(), and set().

Type::Type const Type other  )  [inline]
 

Set the type from a different Type object.

Definition at line 374 of file Type.h.

References register_instance().


Member Function Documentation

EXPR_TYPE Type::data_type  )  const [inline]
 

Return the type.

Definition at line 386 of file Type.h.

References type_object::_type.

Referenced by EvolutionGraph::_add_approximations(), _add_control_assigns(), EvolutionGraph::_add_evolutions(), EvolutionGraph::_build(), _collect_candidates(), EvolutionGraph::_compute_cyclic_evolutions(), EvolutionGraph::_contains_unknown_variants(), _create_data_assigns(), _filter_vars(), _make_nonlocals_modified_at_calls(), _p_r_o_of_add(), _subst_ints_in_expr(), arithmetic_result_type(), check_scalars_affine(), cleanup_program(), Expression::compare(), compute_intrinsic_type(), conformable_test(), constant(), SSAFullRangeDict::data_touch(), GSAFullRangeDict::data_touch(), expr_type(), GSAExpr::gate(), name_ref(), Expression::operator==(), precalc_loop(), print_gsa_data_range_stats(), SSAControlRangeDict::stats(), GSAControlRangeDict::stats(), subsume_relation(), SSAControlRangeDict::touch(), and GSAControlRangeDict::touch().

void Type::rank_known Boolean  known  )  [inline]
 

Set whether the rank of the Type is known.

Definition at line 412 of file Type.h.

References type_object::_rank_known.

Referenced by ProgramUnit::_propagate_symbol_dimensions(), compute_intrinsic_type(), and determine_root_expr_type().

bool Type::size_defaulted  ) 
 

returns true if the user did not specify an explicit size

Definition at line 279 of file Type.cc.

Boolean Type::rank_known  )  const [inline]
 

Is the rank of the Type known?

Definition at line 418 of file Type.h.

References type_object::_rank_known.

int Type::rank  )  const [inline]
 

Return the rank of the Type-- returns -1 if the rank is unknown.

Definition at line 399 of file Type.h.

References type_object::_rank.

Referenced by compute_intrinsic_type(), and compute_rank().

Boolean Type::is_scalar  )  const [inline]
 

Does the rank equal 0?

Definition at line 405 of file Type.h.

References type_object::_rank.

Referenced by cleanup_program().

void Type::redimension int  rank  ) 
 

Set the rank of the Type object to rank where -1 = unknown, 0 = scalar, 1 = 1, etc..

Definition at line 199 of file Type.cc.

References type_object::_rank, and type_object::_rank_known.

Referenced by ProgramUnit::_propagate_symbol_dimensions(), compute_intrinsic_type(), make_ranked_type(), propagate_expr_types(), SymbolicConstantSymbol::SymbolicConstantSymbol(), Type(), and VariableSymbol::VariableSymbol().

int Type::size  )  const [inline]
 

Return the size.

Definition at line 393 of file Type.h.

Referenced by arithmetic_result_type(), Expression::compare(), compute_abstract_access(), conformable_test(), expr_type(), move_saved_vars(), remap_args_precalc_expr(), and VariableSymbol::size().

void Type::set const char *  type_name,
int  given_size
 

Set the type from a name of the type plus a size.

... If given_size == 0, leave _size at the default

Definition at line 88 of file Type.cc.

Referenced by IDExpr::convert(), and Type().

void Type::set const char *  type_name  ) 
 

Set the type from just a name of the type The size is chosen from a default value for the specified type.

It is important to use this method (rather than Type::set(const char * , int ) to set the size if the size is not specified otherwise because the defaults could change depending on command-line options. Using this method will keep the size consistent.

Definition at line 111 of file Type.cc.

References type_object::_type, dbx_warn_use_def_size_for_Type, GENERIC_TYPE, UNDEFINED_TYPE, and VOID_TYPE.

void Type::set EXPR_TYPE  type,
int  size
 

Set the type directly given an EXPR_TYPE and a size.

Definition at line 180 of file Type.cc.

References type_object::_type.

void Type::set EXPR_TYPE  type  ) 
 

Set the type from just a name of the type The size is chosen from a default value for the specified type.

It is important to use this method (as opposed to Type::set(EXPR_TYPE , int ) to set the size if the size is not specified otherwise because the defaults could change depending on command-line options. Using this method will keep the size consistent.

Definition at line 170 of file Type.cc.

References type_object::_type, default_sizes, and NUM_EXPR_TYPES.

void Type::set int  size  ) 
 

Set the size field and keep the EXPR_TYPE constant.

Definition at line 190 of file Type.cc.

void Type::format String str  )  const
 

Convert to printable String form and place into str.

... For now, we assume DOUBLE PRECISION types must be 8 bytes int ... (the equivalence analysis depends on the size being known, and ... since types like "DOUBLE PRECISION*8" or "DOUBLE PRECISION*16" ... are not allowed, we assert here that the size is 8). Later ... this assertion may change, and some sort of compiler options ... may be used to override this.

... "DOUBLE PRECISION"

... Size wasn't specified by user

Definition at line 133 of file Type.cc.

References type_object::_type, CHARACTER_TYPE, DOUBLE_PRECISION_TYPE, GENERIC_TYPE, INT_OR_REAL_TYPES, NUM_EXPR_TYPES, output_size(), type_names, UNKNOWN_TYPE, and VOID_TYPE.

Referenced by _cannot_coerce(), and FunctionSymbol::print().

const char * Type::name_ref  )  const
 

Return the string corresponding to the type name.

Definition at line 58 of file Type.cc.

References data_type(), and type_names.

int Type::operator== const Type other  )  const
 

Returns 1 iff the two types are equal, or if one or more of them is a UNKNOWN_TYPE.

Definition at line 214 of file Type.cc.

References type_object::_rank, type_object::_rank_known, type_object::_type, and UNKNOWN_TYPE.

int Type::operator!= const Type other  )  const
 

Returns 1 iff operator== would return 0.

Definition at line 228 of file Type.cc.

int Type::is_void  )  const [inline]
 

Returns 1 if this type is a VOID_TYPE This is equivalent to "type() == VOID_TYPE".

Definition at line 424 of file Type.h.

References type_object::_type, and VOID_TYPE.

int Type::structures_OK  )  const
 

Check the structure of the data for errors or inconsistency Return 0 and print error message if problems found, otherwise return 1 without message.

Definition at line 249 of file Type.cc.

References type_object::_rank, type_object::_rank_known, type_object::_type, NUM_EXPR_TYPES, and UNDEFINED_TYPE.


Friends And Related Function Documentation

ostream& operator<< ostream &  o,
const Type type
[friend]
 

Definition at line 234 of file Type.cc.


The documentation for this class was generated from the following files:
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:08:33 2005