[llvm-commits] [hlvm] r38195 - in /hlvm/trunk/hlvm/AST: LinkageItem.h LinkageItems.h Locator.h MemoryOps.h Node.h Operator.h RuntimeType.h Type.cpp Type.h URI.h
Reid Spencer
reid at x10sys.com
Sat Jul 7 17:01:02 PDT 2007
Author: reid
Date: Sat Jul 7 19:01:01 2007
New Revision: 38195
URL: http://llvm.org/viewvc/llvm-project?rev=38195&view=rev
Log:
Finish AST documentation upgrade.
Modified:
hlvm/trunk/hlvm/AST/LinkageItem.h
hlvm/trunk/hlvm/AST/LinkageItems.h
hlvm/trunk/hlvm/AST/Locator.h
hlvm/trunk/hlvm/AST/MemoryOps.h
hlvm/trunk/hlvm/AST/Node.h
hlvm/trunk/hlvm/AST/Operator.h
hlvm/trunk/hlvm/AST/RuntimeType.h
hlvm/trunk/hlvm/AST/Type.cpp
hlvm/trunk/hlvm/AST/Type.h
hlvm/trunk/hlvm/AST/URI.h
Modified: hlvm/trunk/hlvm/AST/LinkageItem.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/LinkageItem.h?rev=38195&r1=38194&r2=38195&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItem.h (original)
+++ hlvm/trunk/hlvm/AST/LinkageItem.h Sat Jul 7 19:01:01 2007
@@ -39,11 +39,11 @@
/// permitted for a LinkageItem.
/// @brief Enumeration of ways to link bundles
enum LinkageKinds {
- ExternalLinkage, ///< Externally visible item
- LinkOnceLinkage, ///< Keep one copy of item when linking (inline)
- WeakLinkage, ///< Keep one copy of item when linking (weak)
- AppendingLinkage, ///< Append item to an array of similar items
- InternalLinkage ///< Rename collisions when linking (static funcs)
+ ExternalLinkage = 1, ///< Externally visible item
+ LinkOnceLinkage = 2, ///< Keep one copy of item when linking (inline)
+ WeakLinkage = 3, ///< Keep one copy of item when linking (weak)
+ AppendingLinkage = 4, ///< Append item to an array of similar items
+ InternalLinkage = 5 ///< Rename collisions when linking (static funcs)
};
/// This class provides an Abstract Syntax Tree node that represents an item
@@ -64,7 +64,9 @@
/// @name Constructors
/// @{
protected:
- LinkageItem( NodeIDs id ) : Constant(id), kind(InternalLinkage), name() {}
+ LinkageItem( NodeIDs id ) : Constant(id), name() {
+ setLinkageKind(InternalLinkage);
+ }
public:
virtual ~LinkageItem();
@@ -73,7 +75,7 @@
/// @{
public:
inline const std::string& getName() { return name; }
- inline LinkageKinds getLinkageKind() { return kind; }
+ inline LinkageKinds getLinkageKind() { return LinkageKinds(flags & 0x0007); }
static inline bool classof(const LinkageItem*) { return true; }
static inline bool classof(const Node* N) { return N->isLinkageItem(); }
@@ -81,13 +83,14 @@
/// @name Mutators
/// @{
void setName(const std::string& n) { name = n; }
- void setLinkageKind(LinkageKinds k) { kind = k; }
+ void setLinkageKind(LinkageKinds k) {
+ flags &= 0xFFF8; flags |= uint16_t(k);
+ }
/// @}
/// @name Data
/// @{
protected:
- LinkageKinds kind; ///< The type of linkage to perform for this item
std::string name;
/// @}
friend class AST;
Modified: hlvm/trunk/hlvm/AST/LinkageItems.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/LinkageItems.h?rev=38195&r1=38194&r2=38195&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItems.h (original)
+++ hlvm/trunk/hlvm/AST/LinkageItems.h Sat Jul 7 19:01:01 2007
@@ -63,7 +63,7 @@
/// @name Accessors
/// @{
public:
- bool isConstant() const { return isConst; }
+ bool isConstant() const { return flags & 0x0008; }
Constant* getInitializer() { return init; }
static inline bool classof(const Variable*) { return true; }
static inline bool classof(const Node* N) { return N->is(VariableID); }
@@ -72,7 +72,7 @@
/// @name Mutators
/// @{
public:
- void setIsConstant(bool v) { isConst = v; }
+ void setIsConstant(bool v) { flags |= 0x0008; }
void setInitializer(Constant* C) { init = C; }
/// @}
@@ -80,7 +80,6 @@
/// @{
protected:
Constant* init;
- bool isConst;
/// @}
friend class AST;
};
Modified: hlvm/trunk/hlvm/AST/Locator.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Locator.h?rev=38195&r1=38194&r2=38195&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Locator.h (original)
+++ hlvm/trunk/hlvm/AST/Locator.h Sat Jul 7 19:01:01 2007
@@ -36,10 +36,17 @@
namespace hlvm
{
-/// This class is used to hold a source code location as a filename, line
-/// number and column number. This is used for generating error messages and
-/// for debugging support.
-/// @brief Source location holder class.
+/// This abstract base class is the superclass of the various Locator classes
+/// that are used to associate a source code location with a node in the
+/// AST. Locators are not Abstract Syntax Tree nodes, but they are referenced
+/// as a value of any Node subclass. These classes are retained separately from
+/// the Node class so that multiple nodes can share an instance of a Locator.
+/// This can occur frequently when a single line of source code produces several
+/// AST operator nodes. By keeping the Locator as a separate object, the memory
+/// consumption of the AST is reduced. This abstrat base class provides a single
+/// virtual method, getReference, which should produce a string that identifies
+/// the source code location. This will be used in error messages, etc.
+/// @brief Source Code Location Abstract Base Class
class Locator
{
/// @name Constructors
@@ -57,6 +64,12 @@
unsigned short SubclassID;
};
+/// This Locator subclass provides a locator that specifies the location as
+/// simply being some resource (URI). While this usually isn't sufficient, it
+/// may be useful in some contexts and also serves as the base class of other
+/// Locator classes.
+/// @see Locator
+/// @brief Locator that contains just a URI
class URILocator : public Locator
{
/// @name Constructors
@@ -79,6 +92,10 @@
/// @}
};
+/// This Locator can be used to locate a specific line within some resource. It
+/// is a URILocator sublcass.
+/// @see Locator
+/// @brief Locator with URI (file) and line number.
class LineLocator : public URILocator
{
/// @name Constructors
@@ -103,6 +120,9 @@
/// @}
};
+/// This class provides a locator that specifies a specific column on a specific
+/// line of a given URI (file).
+/// @brief Locator with File, Line and Column
class LineColumnLocator : public LineLocator
{
/// @name Constructors
@@ -126,6 +146,12 @@
/// @}
};
+/// This class provides a Locator that identifies a range of text in a source
+/// location. The range is specified by a pair of Line/Column pairs. That is,
+/// the range specifies a starting line and column number and an ending line and
+/// column number.
+/// @see Locator
+/// @brief Locator for specifying a range of text in a source file.
class RangeLocator : public LineColumnLocator
{
/// @name Constructors
Modified: hlvm/trunk/hlvm/AST/MemoryOps.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/MemoryOps.h?rev=38195&r1=38194&r2=38195&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/MemoryOps.h (original)
+++ hlvm/trunk/hlvm/AST/MemoryOps.h Sat Jul 7 19:01:01 2007
@@ -1,4 +1,4 @@
-//===-- HLVM AST Memory Operations ------------------------------*- C++ -*-===//
+//===-- HLVM AST Memory Operations Interface --------------------*- C++ -*-===//
//
// High Level Virtual Machine (HLVM)
//
@@ -38,8 +38,12 @@
class Variable;
-/// This operator loads the value of a memory location.
-/// @brief HLVM Memory Load Operator
+/// This class provides an Abstract Syntax Tree node that represents an operator
+/// for loading a value from a memory location. This operator takes a single
+/// operand which must resolve to the address of a memory location, either
+/// global or local (stack). The result of the operator is the value of the
+/// memory object, whatever type it may be.
+/// @brief AST Memory Load Operator
class LoadOp : public UnaryOperator
{
/// @name Constructors
@@ -70,10 +74,11 @@
friend class AST;
};
-/// This operator stores a value into a memory location. The first operand
+/// This class provides an Abstract Syntax Tree node that represents an operator
+/// for storing a a value into a memory location. The first operand
/// resolves to the storage location into which the value is stored. The second
-/// operand provides the value to store.
-/// @brief HLVM Memory Store Operator
+/// operand provides the value to store. The operator returns a void value.
+/// @brief AST Memory Store Operator
class StoreOp : public BinaryOperator
{
/// @name Constructors
@@ -104,9 +109,18 @@
friend class AST;
};
-/// This operator represents a local (stack) variable whose lifespan is the
-/// lifespan of the enclosing block. Its value is the initialized value.
-/// @brief HLVM AST Automatic Variable Operator
+/// This class provides an Abstract Syntax Tree node that represents an operator
+/// for defining an automatic (local) variable on a function's stack. The scope
+/// of such a variable is the block that contains it from the point at which
+/// the declaration occurs, onward. Automatic variables are allocated
+/// automatically on a function's stack. When execution leaves the block in
+/// which the variable is defined, the variable is automatically deallocated.
+/// Automatic variables are not LinkageItems and do not participate in linkage
+/// at all. They don't exist until a Function is activated. Automatic variables
+/// are operators because they provide the value of their initializer. Automatic
+/// variables may be declared to be constant in which case they must have an
+/// initializer and their value is immutable.
+/// @brief AST Automatic Variable Operator
class AutoVarOp : public UnaryOperator
{
/// @name Constructors
@@ -142,9 +156,15 @@
friend class AST;
};
-/// This operator yields the value of a named variable, either an automatic
-/// variable (function scoped) or global variable (bundle scoped).
-/// @brief HLVM AST Variable Operator
+/// This class provides an Abstract Syntax Tree node that represents an operator
+/// for obtaining the address of a named variable. The operator has no operands
+/// but has a property that is the Value to be referenced. It is presumed that
+/// this value is either an AutoVarOp or one of the LinkageItems. This operator
+/// bridges between non-operator Values and Operators. The result of this
+/// operator is the address of the memory object. Typically this operator is
+/// used as the operand of a LoadOp or StoreOp.
+/// @see Variable AutoVarOp Operator Value LinkageItem LoadOp StoreOp
+/// @brief AST Reference Operator
class ReferenceOp : public NilaryOperator
{
/// @name Constructors
@@ -178,9 +198,19 @@
friend class AST;
};
-/// This operator indexes into an Array and yields the address of an element of
-/// the array.
-/// @brief HLVM AST Variable Operator
+/// This class provides an Abstract Syntax Tree node that represents an operator
+/// for indexing into a ContainerType. The Index operator can have many
+//operands but in all cases requires at least two. The first operand must
+//resolve to the address of a memory location, such as returned by the
+//ReferenceOp. The second and subsequent operands must all be of integer type.
+/// They specify which elements of the memory object should be indexed. This
+/// operator is the means by which the elements of memory objects of type
+/// PointerType, ArrayType, VectorType, StructureType, and ContinuationType can
+/// be accessed. The resulting value of the operator is the address of the
+/// corresponding memory location. In the case of StructureType and
+/// ContinuationType elements, the corresponding index indicates the field, in
+/// declaration order, that is accessed. Field numbering begins at zero.
+/// @brief AST Index Operator
class IndexOp : public MultiOperator
{
/// @name Constructors
Modified: hlvm/trunk/hlvm/AST/Node.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Node.h?rev=38195&r1=38194&r2=38195&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Node.h (original)
+++ hlvm/trunk/hlvm/AST/Node.h Sat Jul 7 19:01:01 2007
@@ -1,4 +1,4 @@
-//===-- Abstract Node Class -------------------------------------*- C++ -*-===//
+//===-- Abstract Node Class Interface ---------------------------*- C++ -*-===//
//
// High Level Virtual Machine (HLVM)
//
@@ -21,10 +21,10 @@
//
//===----------------------------------------------------------------------===//
/// @file hlvm/AST/Node.h
-/// @author Reid Spencer <reid at hlvm.org> (original author)
+/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
/// @date 2006/05/04
/// @since 0.1.0
-/// @brief Declares the class hlvm::AST::Node
+/// @brief Declares the class hlvm::AST::Node and basic subclasses
//===----------------------------------------------------------------------===//
#ifndef HLVM_AST_NODE_H
@@ -41,16 +41,13 @@
class Documentation;
class AST;
-/// This enumeration is used to identify the primitive types. Each of these
-/// types is a node with a NodeID but they are treated specially because of
-/// their frequency of use.
-enum PrimitiveTypes {
-};
-
-/// This enumeration is used to identify a specific node. Its organization is
-/// very specific and dependent on the class hierarchy. In order to use these
-/// values as ranges for class identification (classof methods), we need to
-/// group things by inheritance rather than by function.
+/// This enumeration is used to identify the various kinds of Abstract Syntax
+/// Tre nodes. Its organization is very specific and dependent on the class
+/// hierarchy. In order to use these values as ranges for class identification
+/// (classof methods), we need to group things by inheritance rather than by
+/// function. Items beginning with "First" or "Last" identify a useful range
+/// of node types and do not introduce any value of their own.
+/// @brief Identifiers of th AST Node Types.
enum NodeIDs
{
NoTypeID = 0, ///< Use this for an invalid type ID.
@@ -273,9 +270,12 @@
NumNodeIDs ///< The number of node identifiers in the enum
};
-/// This class is the base class of HLVM Abstract Syntax Tree (AST). All
-/// other AST nodes are subclasses of this class.
-/// @brief Abstract base class of all HLVM AST node classes
+/// This class is the abstract base class of all the Abstract Syntax Tree (AST)
+/// node types. All other AST nodes are subclasses of this class. This class
+/// must only provide functionality that is common to all AST Node subclasses.
+/// It provides for class identification, insertion of nodes, management of a
+/// set of flags,
+/// @brief Abstract Base Class of All HLVM AST Nodes
class Node
{
/// @name Constructors
@@ -418,6 +418,12 @@
friend class AST;
};
+/// This class is an abstract base class in the Abstract Syntax Tree for any
+/// node type that can be documented. That is, it provides a facility for
+/// attaching a Documentation node. This is the base class of most definitions
+/// in the AST.
+/// @see Documentation
+/// @brief AST Documentable Node
class Documentable : public Node
{
/// @name Constructors
@@ -452,6 +458,14 @@
friend class AST;
};
+/// This class is an abstract base class in the Abstract Syntax Tree for things
+/// that have a value at runtime. Every Value has a Type. All Operators,
+/// LinkageItems, and Constants are values.
+/// @see Type
+/// @see LinkageItem
+/// @see Operator
+/// @see Constant
+/// @brief AST Value Node
class Value : public Documentable
{
/// @name Constructors
Modified: hlvm/trunk/hlvm/AST/Operator.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Operator.h?rev=38195&r1=38194&r2=38195&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.h (original)
+++ hlvm/trunk/hlvm/AST/Operator.h Sat Jul 7 19:01:01 2007
@@ -37,9 +37,18 @@
class Type;
-/// This class is the abstract superclass for all Operators. It provides the
-/// methods and virtual signature that is common to all Operator nodes.
-/// @brief HLVM AST Abstract Operator Node
+/// This class is the abstract base class in the Abstract Syntax Tree for all
+/// operators. An Operator is an instruction to the virtual machine to take
+/// some action. Operators form the content of a Block. As this is the base
+/// class of all operators, the Operator class only provides the functionality
+/// that is common to all operators: getting the number of operands
+/// (numOperands), getting the Value of an operand (getOperand), and setting
+/// the Value of an operand (setOperand). Since Operand is a Value, this implies
+/// two things: (1) Operators can be the operand of other operators and (2) eery
+/// Operator has a type.
+/// @see Value
+/// @see Block
+/// @brief AST Abstract Operator Node
class Operator : public Value
{
/// @name Constructors
@@ -70,7 +79,9 @@
friend class AST;
};
-// An operator that takes no operands
+/// This class provides an Abstract Syntax Tree base class for all Operators
+/// that have no operands.
+/// @brief AST Operator With No Operands
class NilaryOperator : public Operator
{
/// @name Constructors
@@ -101,6 +112,9 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree base class for Operators that
+/// take a single operand.
+/// @brief AST Operator With One Operand
class UnaryOperator : public Operator
{
/// @name Constructors
@@ -138,6 +152,9 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree base class for all operators
+/// that have two operands. The operands may be of any Type.
+/// @brief AST Operator With Two Operands
class BinaryOperator : public Operator
{
/// @name Constructors
@@ -174,6 +191,9 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree base class for all operators
+/// that have three operands. The operands may be of any Type.
+/// @brief AST Operator With Three Operands
class TernaryOperator : public Operator
{
/// @name Constructors
@@ -210,6 +230,13 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree base class for all operators
+/// that have multiple operands. The operands may be of any Type. Although the
+/// interface to this class permits any number of operands, in practice the
+/// number of allowed operands for a given MultiOperator subclass is limited.
+/// The subclass's insertChild and removeChild method overrides will enforce
+/// the correct arity for that subclass.
+/// @brief AST Operator With Multiple Operands
class MultiOperator : public Operator
{
/// @name Types
@@ -269,5 +296,5 @@
friend class AST;
};
-} // hlvm
+} // end hlvm namespace
#endif
Modified: hlvm/trunk/hlvm/AST/RuntimeType.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/RuntimeType.h?rev=38195&r1=38194&r2=38195&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/RuntimeType.h (original)
+++ hlvm/trunk/hlvm/AST/RuntimeType.h Sat Jul 7 19:01:01 2007
@@ -35,9 +35,12 @@
namespace hlvm
{
-/// This class represents an opaque type that the runtime will use. The generic
-/// definition (in LLVM lingo) is a "pointer to opaque". The Runtime then is
-/// able to define what the types are without breaking compatibility across
+/// This class provides an Abstract Syntax Tree base class for the various types
+/// that are manipulated by the HLVM runtime. In general, a RuntimeType is
+/// simply a pointer (handle) to some internal data structure of the runtime.
+/// The subclasses of RuntimeType exist to differentiate between the different
+/// kinds of objects the runtime manipulates. The Runtime then is able to
+/// define what the actualy types are without breaking compatibility across
/// releases. Runtime types are disginguished by their names.
class RuntimeType : public Type
{
@@ -59,12 +62,17 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree node that represents a Text Type
+/// object. TextType objects are unicode strings of either variable or constant
+/// value. Internall, the encoding of a TextType string is UTF-8. However, the
+/// string can be converted to any of a number of Unicode encodings.
+/// @brief AST Unicode Text Type
class TextType : public RuntimeType
{
/// @name Constructors
/// @{
protected:
- TextType() : RuntimeType(TextTypeID,"hlvm_text") {}
+ TextType() : RuntimeType(TextTypeID,"text") {}
virtual ~TextType();
/// @}
@@ -79,6 +87,11 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree node that represents a stream
+/// type. A StreamType is used for input and output. The StreamType represents
+/// a handle that the HLVM runtime uses to identify the source of the program's
+/// input or the destination of a program's output.
+/// @brief AST Input Output Stream Type
class StreamType : public RuntimeType
{
/// @name Constructors
@@ -98,6 +111,10 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree node that represents a data
+/// buffer in the HLVM runtime. A buffer is logically the combination of an
+/// area of memory and an integer length for the size of that memory area.
+/// @brief AST Buffer Type
class BufferType : public RuntimeType
{
/// @name Constructors
Modified: hlvm/trunk/hlvm/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Type.cpp?rev=38195&r1=38194&r2=38195&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Type.cpp (original)
+++ hlvm/trunk/hlvm/AST/Type.cpp Sat Jul 7 19:01:01 2007
@@ -96,7 +96,7 @@
if (numBits > 128)
return 0;
- if (signedness) {
+ if (isSigned()) {
if (numBits > 64)
return "s128";
else if (numBits > 32)
Modified: hlvm/trunk/hlvm/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Type.h?rev=38195&r1=38194&r2=38195&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Type.h (original)
+++ hlvm/trunk/hlvm/AST/Type.h Sat Jul 7 19:01:01 2007
@@ -35,10 +35,11 @@
namespace hlvm
{
-class IntrinsicType;
-
-/// This class represents a Type in the HLVM Abstract Syntax Tree.
-/// A Type defines the format of storage.
+/// This class provides the Abstract Syntax Tree base class for all Types. A
+/// Type describes the memory layout of a Value. There are many subclasses of
+/// of Type, each with a particular way of describing memory layout. In HLVM,
+/// Type resolution is done by name. That is, two types with identical layout
+/// but different names are not equivalent.
/// @brief HLVM AST Type Node
class Type : public Documentable
{
@@ -86,6 +87,15 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree node for describing a type that
+/// can accept any type of Value. The AnyType can be used to represent
+/// dynamically typed variables and it, essentially, bypasses the HLVM type
+/// system but in a type-safe way. The AnyType instances will, internally,
+/// carry a type identifier with the value. If the value changes to a new type,
+/// then the type identifier changes with it. In this way, the correct type for
+/// whatever is assigned to an AnyType is maintained by the runtime so that it
+/// cannot be mis-used.
+/// @brief AST Dynamically Typed Type
class AnyType : public Type
{
/// @name Constructors
@@ -107,6 +117,10 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree node to represent the boolean
+/// type. Booleans have a simple true-or-false value and could be represented by
+/// a single bit.
+/// @brief AST Boolean Type
class BooleanType : public Type
{
/// @name Constructors
@@ -127,6 +141,10 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree node to represent the character
+/// type. A Character is a UTF-16 encoded value. It is sixteen bits long and
+/// interpreted with the UTF-16 codeset.
+/// @brief AST Character Type
class CharacterType : public Type
{
/// @name Constructors
@@ -147,6 +165,12 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree node that represents an octet
+/// type. Octets are simply 8 bits of data without interpretation. Octets are
+/// used as the element type of a buffer. Octets cannot be used in arithmetic
+/// computation. They simply hold 8 bits of data. Octets are commonly used in
+/// stream I/O to represent the raw data flowing on the stream.
+/// @brief AST Octet Type
class OctetType : public Type
{
/// @name Constructors
@@ -167,6 +191,10 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree node that represents the void
+/// type. The void type represents a Value that has no value. It is zero bits
+/// long. Consequently, its utility is limited.
+/// @brief AST Void Type
class VoidType : public Type
{
/// @name Constructors
@@ -187,39 +215,51 @@
friend class AST;
};
-/// This class represents all HLVM integer types. An integer type declares the
-/// the minimum number of bits that are required to store the integer type.
-/// HLVM will convert this specification to the most appropriate sized
-/// machine type for computation. If the number of bits is specified as zero
-/// it implies infinite precision integer arithmetic.
+/// This class provides an Abstract Syntax Tree node that represents an integer
+/// type in HLVM. An integer is simply a sequence of bits, of specific length,
+/// that is interpreted to be an integer value. An integer type declares the
+/// the minimum number of bits that are required to store the integer type. The
+/// runtime may, for pragmatic reason, choose to store the type in more bits
+/// than specified by the type. There are a number of "primitive" integer types
+/// of specific size, that line up with the natural word sizes of an underlying
+/// machines. Such types are preferred because they imply less translation and
+/// a more efficient computation. If the number of bits is specified as zero,
+/// it implies infinite precision integer arithmetic. Integer types may be
+/// declared as either signed or unsigned. The maximum number of bits for an
+/// integer type that may be specified is 32,767. Larger integer types should
+/// use infinite precision (number of bits = 0).
class IntegerType : public Type
{
- /// @name Types
- /// @{
- public:
/// @name Constructors
/// @{
protected:
- IntegerType(NodeIDs id, int bits = 32, bool sign = true)
- : Type(id), numBits(bits), signedness(sign) {}
+ IntegerType(
+ NodeIDs id, ///< The node type identifier, passed on to Node base class
+ int16_t bits = 32, ///< The number of bits in this integer type
+ bool sign = true ///< Indicates if this is a signed integer type, or not.
+ ) : Type(id), numBits(bits) {
+ setSigned(sign);
+ }
+
public:
virtual ~IntegerType();
IntegerType* clone(const std::string& newname);
-
/// @}
/// @name Accessors
/// @{
public:
+ /// Get the primitive name for this type. That is, if this type conforms to
+ /// one of the primitive integer types, then return that primitive's name.
virtual const char* getPrimitiveName() const;
- /// Return the number of bits
- uint64_t getBits() const { return numBits; }
+ /// @brief Return the number of bits in this integer type
+ int16_t getBits() const { return int16_t(numBits&0x7FFF); }
- /// Return the signedness of the type
- bool isSigned() const { return signedness ; }
+ /// @brief Return the signedness of this type
+ bool isSigned() const { return flags & 0x8000; }
- // Methods to support type inquiry via is, cast, dyn_cast
+ /// @brief Methods to support type inquiry via isa, cast, dyn_cast
static inline bool classof(const IntegerType*) { return true; }
static inline bool classof(const Node* T) { return T->isIntegralType(); }
@@ -227,26 +267,27 @@
/// @name Mutators
/// @{
public:
- /// Set the number of bits for this integer type
- void setBits(uint64_t bits) { numBits = bits; }
-
- /// Set the signedness of the type
- void setSigned(bool isSigned) { signedness = isSigned; }
+ /// An int
+ /// @brief Set the number of bits for this integer type
+ void setBits(int16_t bits) {
+ numBits &= 0x8000; numBits |= uint16_t(bits)&0x7FFF; }
- /// @}
- /// @name Data
- /// @{
- protected:
- uint32_t numBits; ///< Minimum number of bits
- bool signedness; ///< Whether the integer type is signed or not
+ /// @brief Set the signedness of the type
+ void setSigned(bool isSigned) {
+ if (isSigned) flags |= 0x8000; else flags &= 0x7FFF; }
/// @}
friend class AST;
};
-/// A RangeType is an IntegerType that allows the range of values to be
-/// constricted. The use of RangeType implies range checking whenever the
-/// value of a RangeType variable is assigned.
+/// This class specifies an Abstract Syntax Tree node that represents a range
+/// type. A RangeType is an integral type that constricts the set of allowed
+/// values for the integer to be within an inclusive range. The number of bits
+/// required to represent the range is selected by HLVM. The selected integer
+/// size will contain sufficient bits to represent the requested range. Range
+/// types are limited to values within the limits of a signed 64-bit integer.
+/// The use of RangeType implies range checking whenever the value of a
+/// RangeType variable is assigned.
class RangeType: public Type
{
/// @name Constructors
@@ -291,9 +332,17 @@
friend class AST;
};
-/// This class represents an enumeration of things. Although represented by
-/// an integer type, enumerations have no value. They only have a collation
-/// order.
+/// This class provides an Abstract Syntax Tree node that represents an
+/// enumeration of names. Enumerations consist of a set of enumerators. An
+/// enumerator is simply a name that uniquely identifies one of the possible
+/// values of the EnumerationType. Enumerators are not integers as in some
+/// other languages. HLVM will select a representation that is efficient based
+/// on the characteristics of the EnumerationType. The enumerators define, by
+/// their order of insertion into the enumeration, a collation order for the
+/// enumerators. This collation order can be used to test enumeration values
+/// for equivalence or inequivalence using the equality and inequality
+/// operators.
+/// @brief AST Enumeration Type
class EnumerationType : public Type
{
/// @name Types
@@ -351,12 +400,15 @@
friend class AST;
};
-/// This class represents all HLVM real number types. The precision and
-/// mantissa are specified as a number of decimal digits to be provided as a
-/// minimum. HLVM will use the machine's natural floating point
-/// representation for those real types that can fit within the requested
-/// precision and mantissa lengths. If not, infinite precision floating point
-/// arithmetic will be utilized.
+/// This class provides an Abstract Syntax Tree node that represents a real
+/// number. All floating point and real number arithmetic is done using values
+/// of this type. The precision and mantissa are specified as a number of
+/// binary digits to be provided as a minimum. HLVM will use the machine's
+/// natural floating point representation for those RealTypes that can fit
+/// within the precision and mantissa lengths supported by the machine.
+/// Otherwise, if a machine floating point type cannot meet the requirements of
+/// the RealType, infinite precision floating point arithmetic will be utilized.
+/// @brief AST Real Number Type
class RealType : public Type
{
/// @name Constructors
@@ -402,6 +454,16 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree node that represents an opaque
+/// type. Opaque types are those whose definition is not known. Opaque types are
+/// used to handle forward type references and recursion within container types.
+/// HLVM will automatically resolve OpaqueTypes whose definition is later
+/// discovered. It can also be used as the element type of a PointerType to
+/// effectively hide the implementation details of a given type. This helps
+/// libraries to retain control over the implementation details of a type that
+/// is to be treated as generic by the library's users.
+/// @see PointerType
+/// @brief AST Opaque Type
class OpaqueType : public Type
{
/// @name Constructors
Modified: hlvm/trunk/hlvm/AST/URI.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/URI.h?rev=38195&r1=38194&r2=38195&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/URI.h (original)
+++ hlvm/trunk/hlvm/AST/URI.h Sat Jul 7 19:01:01 2007
@@ -1,4 +1,4 @@
-//===-- Uniform Resource Identifier -----------------------------*- C++ -*-===//
+//===-- Uniform Resource Identifier Interface -------------------*- C++ -*-===//
//
// High Level Virtual Machine (HLVM)
//
@@ -40,20 +40,19 @@
class Pool;
/// A class to represent Uniform Resource Identifiers (URIs). This class can
-/// also support URLs and URNs. The implementation is based on the APR-UTIL
-/// apr_uri set of functions and associated data types.
-/// @see RFC 2396 states that hostnames take the form described in
-/// @see RFC 1034 (Section 3) Hostname Syntax
-/// @see RFC 1123 (Section 2.1). Hostnames
-/// @see RFC 1609 Universal Resource Identifiers in WWW - Berners-Lee.
-/// @see RFC 1738 Uniform Resource Locators - Berners-Lee.
-/// @see RFC 1808 Relative Uniform Resource Locators - Fielding
-/// @see RFC 2059 Uniform Resource Locators for z39.50 - Denenberg
-/// @see RFC 2111 Content-ID and Message-ID Uniform Resource Locators-Levinson
-/// @see RFC 2396 Uniform Resource Identifiers (URI) - Berners-Lee
-/// @see RFC 3305 URI/URL/URN Clarifications and Recommendations - Mealling
-/// @see RFC 3406 URN Namespace Definition Mechanisms - Daigle
-/// @see RFC 3508 URL Schem Registration - Levin
+/// also support URLs and URNs. HLVM uses URIs to uniquely identify bundles and
+/// as the operand of OpenOp operators to specify the resource to be opened.
+/// HLVM defines its own namespace, "hlvm", in which certain classes of
+/// resources can be specified.
+/// @see RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax
+/// @see RFC 1034 HEMS Variable Definitions (Section 3, Hostname Syntax)
+/// @see RFC 1123 Requirements for Internet Hosts (Section 2.1, Hostnames)
+/// @see RFC 1738 Uniform Resource Locators (URL)
+/// @see RFC 1808 Relative Uniform Resource Locators
+/// @see RFC 2111 Content-ID and Message-ID Uniform Resource Locators
+/// @see RFC 3305 URI/URL/URN Clarifications and Recommendations
+/// @see RFC 3406 URN Namespace Definition Mechanisms
+/// @see RFC 3508 H.323 URL Scheme Registration
/// @brief HLVM Uniform Resource Identifier Class
class URI
{
More information about the llvm-commits
mailing list