[llvm-commits] [hlvm] r38301 - in /hlvm/trunk/hlvm/AST: Block.h Node.h
Reid Spencer
reid at x10sys.com
Sat Jul 7 17:02:06 PDT 2007
Author: reid
Date: Sat Jul 7 19:02:06 2007
New Revision: 38301
URL: http://llvm.org/viewvc/llvm-project?rev=38301&view=rev
Log:
Add a new ResultOp to allow specification of a block's result. Also add ranges
for Terminator instructions to Node.h
Modified:
hlvm/trunk/hlvm/AST/Block.h
hlvm/trunk/hlvm/AST/Node.h
Modified: hlvm/trunk/hlvm/AST/Block.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Block.h?rev=38301&r1=38300&r2=38301&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Block.h (original)
+++ hlvm/trunk/hlvm/AST/Block.h Sat Jul 7 19:02:06 2007
@@ -41,9 +41,10 @@
/// This class represents an block of operators in the HLVM Abstract Syntax
/// Tree. A block is simply a sequential list of Operator nodes that are
/// executed in sequence. Block itself is an operator. Its result value is
-/// the value of the last operator executed. As such, blocks can be nested
-/// within blocks. Blocks are used as the operands of the control flow
-/// operators as well.
+/// is provided by a ResultOp operator. This approach allows processing to
+/// continue after a result for the block has been determined. Blocks can be
+/// nested within other blocks and used as the operands of other operators.
+/// @see ResultOp
/// @brief AST Block Node
class Block : public MultiOperator
{
@@ -84,5 +85,35 @@
friend class AST;
};
+/// This class provides an Abstract Syntax Tree node that indicates the result
+/// of a Block operator. The result operator may be utilized anywhere in the
+/// block. The last such result executed provides the value for the block.
+/// @see Block
+/// @brief AST Result Operator Node
+class ResultOp : public UnaryOperator
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ ResultOp() : UnaryOperator(ResultOpID) {}
+ virtual ~ResultOp();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ Operator* getResult() { return UnaryOperator::op1; }
+ static inline bool classof(const ResultOp*) { return true; }
+ static inline bool classof(const Node* N) { return N->is(ResultOpID); }
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ void setResult(Operator* op) { op->setParent(this); }
+ /// @}
+ friend class AST;
+};
+
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/Node.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Node.h?rev=38301&r1=38300&r2=38301&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Node.h (original)
+++ hlvm/trunk/hlvm/AST/Node.h Sat Jul 7 19:02:06 2007
@@ -167,8 +167,9 @@
// Control Flow Unary Operators
NullOpID, ///< The "do nothing" NullOp (no-op) Operator
FirstUnaryOperatorID = NullOpID,
- ReturnOpID, ///< The Return A Value Operator
- ThrowOpID, ///< The Throw an Exception Operator
+ ReturnOpID, ///< Return a value to the function's caller
+ ResultOpID, ///< Specify the result of a block
+ ThrowOpID, ///< Throw an exception out of the function
// Integer Arithmetic Unary Operators
NotOpID, ///< Not Unary Boolean Operator
@@ -378,6 +379,10 @@
inline bool isOperator() const {
return id >= FirstOperatorID && id <= LastOperatorID; }
+ inline bool isTerminator() const {
+ return (id >= BreakOpID && id <= ContinueOpID) ||
+ (id >= ReturnOpID && id <= ThrowOpID); }
+
inline bool isNilaryOperator() const {
return id >= FirstNilaryOperatorID && id <= LastNilaryOperatorID; }
More information about the llvm-commits
mailing list