[llvm-commits] [hlvm] r37991 - in /hlvm/trunk/hlvm/AST: Block.cpp Block.h Node.h Operator.cpp Operator.h Program.h
Reid Spencer
reid at x10sys.com
Sat Jul 7 16:58:44 PDT 2007
Author: reid
Date: Sat Jul 7 18:58:44 2007
New Revision: 37991
URL: http://llvm.org/viewvc/llvm-project?rev=37991&view=rev
Log:
Remove usless members from Program and endow it with a static Signature for the
type of its function signature. Add Block and Operator nodes. Fill in the
NodeIDs enumeration with all the nodes that have come to mind.
Added:
hlvm/trunk/hlvm/AST/Block.cpp
hlvm/trunk/hlvm/AST/Block.h
hlvm/trunk/hlvm/AST/Operator.cpp
hlvm/trunk/hlvm/AST/Operator.h
Modified:
hlvm/trunk/hlvm/AST/Node.h
hlvm/trunk/hlvm/AST/Program.h
Added: hlvm/trunk/hlvm/AST/Block.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Block.cpp?rev=37991&view=auto
==============================================================================
--- hlvm/trunk/hlvm/AST/Block.cpp (added)
+++ hlvm/trunk/hlvm/AST/Block.cpp Sat Jul 7 18:58:44 2007
@@ -0,0 +1,29 @@
+//
+// Copyright (C) 2006 HLVM Group. All Rights Reserved.
+//
+// This program is open source software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License (GPL) as published by
+// the Free Software Foundation; either version 2 of the License, or (at your
+// option) any later version. You should have received a copy of the GPL in a
+// file named COPYING that was included with this program; if not, you can
+// obtain a copy of the license through the Internet at http://www.fsf.org/
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+////////////////////////////////////////////////////////////////////////////////
+/// @file hlvm/AST/Block.cpp
+/// @author Reid Spencer <reid at hlvm.org> (original author)
+/// @date 2006/05/04
+/// @since 0.1.0
+/// @brief Implements the functions of class hlvm::AST::Block.
+////////////////////////////////////////////////////////////////////////////////
+
+#include <hlvm/AST/Block.h>
+
+namespace hlvm {
+namespace AST {
+
+}}
Added: hlvm/trunk/hlvm/AST/Block.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Block.h?rev=37991&view=auto
==============================================================================
--- hlvm/trunk/hlvm/AST/Block.h (added)
+++ hlvm/trunk/hlvm/AST/Block.h Sat Jul 7 18:58:44 2007
@@ -0,0 +1,68 @@
+//
+// Copyright (C) 2006 HLVM Group. All Rights Reserved.
+//
+// This program is open source software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License (GPL) as published by
+// the Free Software Foundation; either version 2 of the License, or (at your
+// option) any later version. You should have received a copy of the GPL in a
+// file named COPYING that was included with this program; if not, you can
+// obtain a copy of the license through the Internet at http://www.fsf.org/
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+////////////////////////////////////////////////////////////////////////////////
+/// @file hlvm/AST/Block.h
+/// @author Reid Spencer <reid at hlvm.org> (original author)
+/// @date 2006/05/04
+/// @since 0.1.0
+/// @brief Declares the class hlvm::AST::Block
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef HLVM_AST_BLOCK_H
+#define HLVM_AST_BLOCK_H
+
+#include <hlvm/AST/Node.h>
+
+namespace hlvm
+{
+namespace AST
+{
+ class Operator; // Forward declare
+
+ /// This class represents an Variable in the HLVM Abstract Syntax Tree.
+ /// A Variable is a storage location of a specific type. It can either be
+ /// global or local, depending on its parent. Global variables are always
+ /// contained in a Bundle. Local variables are always contained in a
+ /// Function.
+ /// @brief HLVM AST Variable Node
+ class Block : public Node
+ {
+ /// @name Constructors
+ /// @{
+ public:
+ Block(
+ Node* parent, ///< The bundle or function that defines the ariable
+ const std::string& name ///< The name of the variable
+ ) : Node(BlockID,parent,name) {}
+ virtual ~Block();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ static inline bool classof(const Block*) { return true; }
+ static inline bool classof(const Node* N) { return N->isBlock(); }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ std::vector<Operator*> ops_; ///< The operators the Block contains
+ /// @}
+ };
+} // AST
+} // hlvm
+#endif
Modified: hlvm/trunk/hlvm/AST/Node.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Node.h?rev=37991&r1=37990&r2=37991&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Node.h (original)
+++ hlvm/trunk/hlvm/AST/Node.h Sat Jul 7 18:58:44 2007
@@ -44,26 +44,114 @@
IntegerTypeID, ///< The Integer Type
RangeTypeID, ///< The Range Type
RealTypeID, ///< The Real Number Type
+ StringTypeID, ///< The String Type
PointerTypeID, ///< The Pointer Type
ArrayTypeID, ///< The Array Type
VectorTypeID, ///< The Vector Type
StructureTypeID, ///< The Structure Type
SignatureTypeID, ///< The Function Signature Type
+ ClassID, ///< The Class Type
+
+ // Class Constructs (TBD)
+
+ // Variables
+ VariableID, ///< The Variable Node
// Containers
BundleID, ///< The Bundle Node
FunctionID, ///< The Function Node
ProgramID, ///< The Program Node
+ BlockID, ///< A Block Of Code Node
- // Declarations
- VariableID, ///< The Variable Node
+ // Control Flow And Invocation Operators
+ CallOpID, ///< The Call Operator
+ InvokeOpID, ///< The Invoke Operator
+ DispatchOpID, ///< The Object Method Dispatch Operator
+ CreateContOpID, ///< The Create Continutation Operator
+ CallWithContOpID, ///< The Call with Continuation Operator
+ ReturnOpID, ///< The Return A Value Operator
+ ThrowOpID, ///< The Throw And Exception Operator
+ JumpToOpID, ///< The Jump To Labelled Block Operator
+ BreakOpID, ///< The Break Out Of Block Operator
+ IfOpID, ///< The If-Then-Else Operator
+ LoopOpID, ///< The General Purpose Loop Operator
+ SelectOpID, ///< The Select An Alternate Operator
+
+ // Memory Operators
+ LoadOpID, ///< The Load Operator
+ StoreOpID, ///< The Store Operator
+ AllocateOpID, ///< The Allocate Memory Operator
+ FreeOpID, ///< The Free Memory Operator
+ ReallocateOpID, ///< The Reallocate Memory Operator
+ ReferenceOpID, ///< The Reference A Memory Object Operator (for GC)
+ DereferenceOpID, ///< The Dereference A Memory Object Operator (for GC)
+
+ // Arithmetic Operators
+ NegateOpID, ///< The Negation Unary Integer Operator
+ ComplementOpID, ///< The Bitwise Complement Unary Integer Operator
+ PreIncrOpID, ///< The Pre-Increment Unary Integer Operator
+ PostIncrOpID, ///< The Post-Increment Unary Integer Operator
+ PreDecrOpID, ///< The Pre-Decrement Unary Integer Operator
+ PostDecrOpID, ///< The Post-Decrement Unary Integer Operator
+ AddOpID, ///< The Addition Binary Integer Operator
+ SubtractOpID, ///< The Subtraction Binary Integer Operator
+ MultiplyOpID, ///< The Multiplcation Binary Integer Operator
+ DivideOpID, ///< The Division Binary Integer Operator
+ ModulusOpID, ///< The Modulus Binary Integer Operator
+ BAndOpID, ///< The Bitwise And Binary Integer Operator
+ BOrOpID, ///< The Bitwise Or Binary Integer Operator
+ BXOrOpID, ///< The Bitwise XOr Binary Integer Operator
+
+ // Boolean Operators
+ AndOpID, ///< The And Binary Boolean Operator
+ OrOpID, ///< The Or Binary Boolean Operator
+ NorOpID, ///< The Nor Binary Boolean Operator
+ XorOpID, ///< The Xor Binary Boolean Operator
+ NotOpID, ///< The Not Unary Boolean Operator
+ LTOpID, ///< The less-than Binary Boolean Operator
+ GTOpID, ///< The greater-than Binary Boolean Operator
+ LEOpID, ///< The less-than-or-equal Binary Boolean Operator
+ GEOpID, ///< The greather-than-or-equal Binary Boolean Operator
+ EQOpID, ///< The esual Binary Boolean Operator
+ NEOpID, ///< The not-equal Binary Comparison Operator
+
+ // Real Arithmetic Operators
+ IsPInfOpID, ///< Real Number Positive Infinity Test Operator
+ IsNInfOpID, ///< Real Number Negative Infinity Test Operator
+ IsNaNOpID, ///< Real Number Not-A-Number Test Operator
+ TruncOpID, ///< Real Number Truncation Operator
+ RoundOpID, ///< Real Number Rounding Operator
+ FloorOpID, ///< Real Number Floor Operator
+ CeilingOpID, ///< Real Number Ceiling Operator
+ PowerOpID, ///< Real Number Power Operator
+ LogEOpID, ///< Real Number Base e (Euler's Number) logarithm
+ Log2OpID, ///< Real Number Base 2 logarithm Operator
+ Log10OpID, ///< Real Number Base 10 logarithm Operator
+ SqRootOpID, ///< Real Number Square Root Operator
+ RootOpID, ///< Real Number Arbitrary Root Operator
+ FactorialOpID, ///< Real Number Factorial Operator
+ GCDOpID, ///< Real Number Greatest Common Divisor Operator
+ LCMOpID, ///< Real Number Least Common Multiplicator Operator
+
+ // Constant Value Operators
+ IntOpID, ///< Constant Integer Value
+ RealOpID, ///< Constant Real Value
+ PInfOpID, ///< Constant Positive Infinity Real Value
+ NInfOpID, ///< Constant Negative Infinity Real Value
+ NaNOpID, ///< Constant Not-A-Number Real Value
+ StringOpID, ///< Constant String Value
+ ArrayOpID, ///< Constant Array Value
+ VectorOpID, ///< Constant Vector Value
+ StructureOpID, ///< Constant Structure Value
- // Enumeration Limits
+ // Enumeration Ranges and Limits
NumNodeIDs, ///< The number of type identifiers in the enum
FirstPrimitiveTypeID = VoidTypeID,
- LastPrimitiveTypeID = RealTypeID,
+ LastPrimitiveTypeID = StringTypeID,
FirstContainerTypeID = PointerTypeID,
- LastContainerTypeID = SignatureTypeID
+ LastContainerTypeID = SignatureTypeID,
+ FirstOperatorID = CallOpID,
+ LastOperatorID = StructureOpID
};
class Type;
@@ -81,7 +169,7 @@
/// @{
public:
Node(NodeIDs id, Node* parent = 0, const std::string& name = "")
- : id_(id), parent_(parent), name_(name), kids_() {}
+ : id_(id), parent_(parent), kids_(), name_(name) {}
virtual ~Node();
#ifndef _NDEBUG
virtual void dump() const;
@@ -92,8 +180,12 @@
/// @{
public:
inline bool isType() const {
- return id_ <= FirstPrimitiveTypeID && id_ >= LastContainerTypeID;
+ return id_ >= FirstPrimitiveTypeID && id_ <= LastContainerTypeID;
}
+ inline bool isOperator() const {
+ return id_ >= FirstOperatorID && id_ <= LastOperatorID;
+ }
+ inline bool isBlock() const { return id_ == BlockID; }
inline bool isBundle() const { return id_ == BundleID; }
inline bool isFunction() const { return id_ == FunctionID; }
inline bool isProgram() const { return id_ == ProgramID; }
@@ -106,8 +198,8 @@
protected:
NodeIDs id_; ///< Identification of the node kind.
Node* parent_; ///< The node that owns this node.
- std::string name_; ///< The name of this node.
std::vector<Node> kids_; ///< The vector of children nodes.
+ std::string name_; ///< The name of this node.
/// @}
};
} // AST
Added: hlvm/trunk/hlvm/AST/Operator.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Operator.cpp?rev=37991&view=auto
==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.cpp (added)
+++ hlvm/trunk/hlvm/AST/Operator.cpp Sat Jul 7 18:58:44 2007
@@ -0,0 +1,29 @@
+//
+// Copyright (C) 2006 HLVM Group. All Rights Reserved.
+//
+// This program is open source software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License (GPL) as published by
+// the Free Software Foundation; either version 2 of the License, or (at your
+// option) any later version. You should have received a copy of the GPL in a
+// file named COPYING that was included with this program; if not, you can
+// obtain a copy of the license through the Internet at http://www.fsf.org/
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+////////////////////////////////////////////////////////////////////////////////
+/// @file hlvm/AST/Operator.cpp
+/// @author Reid Spencer <reid at hlvm.org> (original author)
+/// @date 2006/05/04
+/// @since 0.1.0
+/// @brief Implements the functions of class hlvm::AST::Operator.
+////////////////////////////////////////////////////////////////////////////////
+
+#include <hlvm/AST/Operator.h>
+
+namespace hlvm {
+namespace AST {
+
+}}
Added: hlvm/trunk/hlvm/AST/Operator.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Operator.h?rev=37991&view=auto
==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.h (added)
+++ hlvm/trunk/hlvm/AST/Operator.h Sat Jul 7 18:58:44 2007
@@ -0,0 +1,68 @@
+//
+// Copyright (C) 2006 HLVM Group. All Rights Reserved.
+//
+// This program is open source software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License (GPL) as published by
+// the Free Software Foundation; either version 2 of the License, or (at your
+// option) any later version. You should have received a copy of the GPL in a
+// file named COPYING that was included with this program; if not, you can
+// obtain a copy of the license through the Internet at http://www.fsf.org/
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+////////////////////////////////////////////////////////////////////////////////
+/// @file hlvm/AST/Variable.h
+/// @author Reid Spencer <reid at hlvm.org> (original author)
+/// @date 2006/05/04
+/// @since 0.1.0
+/// @brief Declares the class hlvm::AST::Variable
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef HLVM_AST_OPERATOR_H
+#define HLVM_AST_OPERATOR_H
+
+#include <hlvm/AST/Node.h>
+
+namespace hlvm {
+namespace AST {
+
+ class Type; // Forward declare
+
+ /// This class represents an Variable in the HLVM Abstract Syntax Tree.
+ /// A Variable is a storage location of a specific type. It can either be
+ /// global or local, depending on its parent. Global variables are always
+ /// contained in a Bundle. Local variables are always contained in a
+ /// Function.
+ /// @brief HLVM AST Variable Node
+ class Operator : public Node
+ {
+ /// @name Constructors
+ /// @{
+ public:
+ Operator(
+ NodeIDs opID, ///< The Operator ID for this operator kind
+ Node* parent, ///< The bundle or function that defines the ariable
+ const std::string& name ///< The name of the variable
+ ) : Node(opID,parent,name) {}
+ virtual ~Operator();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ static inline bool classof(const Operator*) { return true; }
+ static inline bool classof(const Node* N) { return N->isOperator(); }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ std::vector<Operator*> Operands; ///< The list of Operands
+ /// @}
+ };
+} // AST
+} // hlvm
+#endif
Modified: hlvm/trunk/hlvm/AST/Program.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Program.h?rev=37991&r1=37990&r2=37991&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Program.h (original)
+++ hlvm/trunk/hlvm/AST/Program.h Sat Jul 7 18:58:44 2007
@@ -14,11 +14,11 @@
// for more details.
//
////////////////////////////////////////////////////////////////////////////////
-/// @file hlvm/AST/Function.h
+/// @file hlvm/AST/Program.h
/// @author Reid Spencer <reid at hlvm.org> (original author)
/// @date 2006/05/04
/// @since 0.1.0
-/// @brief Declares the class hlvm::AST::Function
+/// @brief Declares the class hlvm::AST::Program
////////////////////////////////////////////////////////////////////////////////
#ifndef HLVM_AST_PROGRAM_H
@@ -31,15 +31,13 @@
class Block; // Forward declare
class SignatureType; // Forward declare
- class Bundle; // Forward declare
/// This class represents a Program in the HLVM Abstract Syntax Tree.
/// A Program is a function with a specific set of arguments. It represents
/// a starting point for any execution. To be executable, a Bundle must have
- /// at least one Program node in it.
- /// returns a result. This is the basic unit of code in HLVM. A Function
- /// has a name, a set of formal arguments, a return type, and a block of
- /// code to execute.
+ /// at least one Program node in it. The Program node is simply introduced
+ /// to ensure the signature of the function is correct and to serve as a way
+ /// to identify Program's quickly.
/// @brief HLVM AST Function Node
class Program : public Function
{
@@ -62,9 +60,6 @@
/// @}
/// @name Data
/// @{
- protected:
- Block * block_; ///< The code block to be executed
- SignatureType* signature_; ///< The function signature.
private:
static SignatureType* SignatureTy; ///< The signature for programs
static SignatureType* initSignature();
More information about the llvm-commits
mailing list