scale.backend
Class SpaceAllocation

java.lang.Object
  extended by scale.backend.SpaceAllocation

public class SpaceAllocation
extends java.lang.Object

This class represents statically allocated memory.

$Id: SpaceAllocation.java,v 1.27 2007-10-04 19:57:49 burrill Exp $

Copyright 2008 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.

Typically memory is statically allocated in different areas or sections. Different systems use different rules for what can be allocated where. One section might be for addresses and another for floating point values. There is typically one area for un-initialized memory. An instance of this class represents an individually statically allocated chunk of memory. This chunk is allocated in an area and has a size. It may also have a set of values to be used to statically initialize it.


Field Summary
static int DAT_ADDRESS
          The data area initializer contains address data.
static int DAT_BYTE
          The data area initializer contains 8-bit integers.
static int DAT_DBL
          The data area initializer contains 64-bit floating point values.
static int DAT_FLT
          The data area initializer contains 32-bit floating point values.
static int DAT_INT
          The data area initializer contains 32-bit integer values.
static int DAT_LDBL
          The data area initializer contains 64-bit floating point values.
static int DAT_LONG
          The data area initializer contains 64-bit integer values.
static int DAT_NONE
          The data area is not initialized.
static int DAT_SHORT
          The data area initializer 16-bit integer.
static int DAT_TEXT
          The data area initializer contains instructions.
static byte DAV_EXTERN
          The memory is in another module.
static byte DAV_GLOBAL
          The memory has global visibility.
static byte DAV_LOCAL
          The memory has local visibility.
static java.lang.String[] types
          Map from data type to displayable name.
static java.lang.String[] visibilities
          map from visibility to displayable name.
 
Constructor Summary
SpaceAllocation(java.lang.String name, int area, int type, boolean readOnly, long size, int reps, int alignment, java.lang.Object value)
          Create an object to represent static allocation of memory.
SpaceAllocation(java.lang.String name, int area, int type, boolean readOnly, long size, int reps, java.lang.Object value)
          Create an object to represent static allocation of memory.
SpaceAllocation(java.lang.String name, int area, int type, boolean readOnly, long size, java.lang.Object value)
          Create an object to represent static allocation of memory.
 
Method Summary
 boolean containsAddress()
          Return true if the memory is initialized with address data.
 boolean containsData()
          Return true if the memory is initialized.
 int getAlignment()
          Return the alignment boundary required.
 int getArea()
          Return the index of the area in which this memory is allocated.
 Displacement getDisplacement()
          Return the displacement associated with this space allocation or null
 java.lang.String getName()
          Return the name of the memory area.
 int getReps()
          Return the number of times the value is repeated.
 long getSize()
          Return the size of the memory in bytes.
 int getType()
          Return the type of data this memory contains.
 java.lang.Object getValue()
          Return the initilizer.
 int getVisibility()
          Return the visibility of the memory.
 boolean isWeak()
          Return true if the area is weakly linked.
 boolean matches(int area, int type, long size, boolean readOnly)
          Return true if this space allocation has the specified attributes.
 boolean readOnly()
          Return true if the memory is read-only.
protected  void setAlignment(int alignment)
          Set the alignment boundary required.
 void setDisplacement(Displacement disp)
          Associate the displacement with this space allocation.
 void setValue(java.lang.Object value)
          Set the initilizer
 void setVisibility(byte visibility)
          Set the visibility of the memory area.
 void setWeak(boolean weak)
          Specify if the symbol is weakly linked..
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DAT_NONE

public static final int DAT_NONE
The data area is not initialized.

See Also:
Constant Field Values

DAT_BYTE

public static final int DAT_BYTE
The data area initializer contains 8-bit integers.

See Also:
Constant Field Values

DAT_SHORT

public static final int DAT_SHORT
The data area initializer 16-bit integer.

See Also:
Constant Field Values

DAT_INT

public static final int DAT_INT
The data area initializer contains 32-bit integer values.

See Also:
Constant Field Values

DAT_LONG

public static final int DAT_LONG
The data area initializer contains 64-bit integer values.

See Also:
Constant Field Values

DAT_FLT

public static final int DAT_FLT
The data area initializer contains 32-bit floating point values.

See Also:
Constant Field Values

DAT_DBL

public static final int DAT_DBL
The data area initializer contains 64-bit floating point values.

See Also:
Constant Field Values

DAT_ADDRESS

public static final int DAT_ADDRESS
The data area initializer contains address data.

See Also:
Constant Field Values

DAT_TEXT

public static final int DAT_TEXT
The data area initializer contains instructions.

See Also:
Constant Field Values

DAT_LDBL

public static final int DAT_LDBL
The data area initializer contains 64-bit floating point values.

See Also:
Constant Field Values

types

public static final java.lang.String[] types
Map from data type to displayable name.


DAV_LOCAL

public static final byte DAV_LOCAL
The memory has local visibility.

See Also:
Constant Field Values

DAV_GLOBAL

public static final byte DAV_GLOBAL
The memory has global visibility.

See Also:
Constant Field Values

DAV_EXTERN

public static final byte DAV_EXTERN
The memory is in another module.

See Also:
Constant Field Values

visibilities

public static final java.lang.String[] visibilities
map from visibility to displayable name.

Constructor Detail

SpaceAllocation

public SpaceAllocation(java.lang.String name,
                       int area,
                       int type,
                       boolean readOnly,
                       long size,
                       java.lang.Object value)
Create an object to represent static allocation of memory.

Parameters:
name - is the name of the allocated memory
area - is the area (section) in which the memory is allocated
type - specifies what the memory holds
readOnly - is true if the area is read-only
size - specifies the size of the memory in addressable units
value - specifies the object used to generate the initialization for the memory area

SpaceAllocation

public SpaceAllocation(java.lang.String name,
                       int area,
                       int type,
                       boolean readOnly,
                       long size,
                       int reps,
                       java.lang.Object value)
Create an object to represent static allocation of memory.

Parameters:
name - is the name of the allocated memory
area - is the area (section) in which the memory is allocated
type - specifies what the memory holds
readOnly - is true if the area is read-only
size - specifies the size of the memory or data item in addressable units
reps - specifies the number of times the value is repeated
value - specifies the object used to generate the initialization for the memory area

SpaceAllocation

public SpaceAllocation(java.lang.String name,
                       int area,
                       int type,
                       boolean readOnly,
                       long size,
                       int reps,
                       int alignment,
                       java.lang.Object value)
Create an object to represent static allocation of memory.

Parameters:
name - is the name of the allocated memory
area - is the area (section) in which the memory is allocated
type - specifies what the memory holds
readOnly - is true if the area is read-only
size - specifies the size of the memory or data item in addressable units
reps - specifies the number of times the value is repeated
alignment - specifies the memory boundary to align the data on
value - specifies the object used to generate the initialization for the memory area
Method Detail

setDisplacement

public void setDisplacement(Displacement disp)
Associate the displacement with this space allocation.


getDisplacement

public Displacement getDisplacement()
Return the displacement associated with this space allocation or null


matches

public boolean matches(int area,
                       int type,
                       long size,
                       boolean readOnly)
Return true if this space allocation has the specified attributes.

Parameters:
area - specifies the section in which the loader should place the area
type - specifies the type of data
size - is the number of addressable units required
readOnly - is true if the area is read-only

readOnly

public boolean readOnly()
Return true if the memory is read-only.


containsData

public boolean containsData()
Return true if the memory is initialized.


containsAddress

public boolean containsAddress()
Return true if the memory is initialized with address data.


setVisibility

public void setVisibility(byte visibility)
Set the visibility of the memory area.


getVisibility

public int getVisibility()
Return the visibility of the memory.


isWeak

public boolean isWeak()
Return true if the area is weakly linked.


setWeak

public void setWeak(boolean weak)
Specify if the symbol is weakly linked..


getValue

public java.lang.Object getValue()
Return the initilizer.


setValue

public void setValue(java.lang.Object value)
Set the initilizer


getName

public java.lang.String getName()
Return the name of the memory area.


getArea

public int getArea()
Return the index of the area in which this memory is allocated.


getSize

public long getSize()
Return the size of the memory in bytes.


getReps

public int getReps()
Return the number of times the value is repeated.


setAlignment

protected void setAlignment(int alignment)
Set the alignment boundary required.


getAlignment

public int getAlignment()
Return the alignment boundary required.


getType

public int getType()
Return the type of data this memory contains.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object