[llvm-commits] [hlvm] r38349 - in /hlvm/trunk/hlvm/AST: AST.cpp Node.cpp Node.h Operator.cpp Operator.h

Reid Spencer reid at x10sys.com
Sat Jul 7 17:02:34 PDT 2007


Author: reid
Date: Sat Jul  7 19:02:34 2007
New Revision: 38349

URL: http://llvm.org/viewvc/llvm-project?rev=38349&view=rev
Log:
Make the getContainingBundle method available on all nodes, not just Operators.
Make sure getPointerTo sets the parent for each type it creates.

Modified:
    hlvm/trunk/hlvm/AST/AST.cpp
    hlvm/trunk/hlvm/AST/Node.cpp
    hlvm/trunk/hlvm/AST/Node.h
    hlvm/trunk/hlvm/AST/Operator.cpp
    hlvm/trunk/hlvm/AST/Operator.h

Modified: hlvm/trunk/hlvm/AST/AST.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/AST.cpp?rev=38349&r1=38348&r2=38349&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/AST.cpp (original)
+++ hlvm/trunk/hlvm/AST/AST.cpp Sat Jul  7 19:02:34 2007
@@ -228,6 +228,7 @@
   PointerType* PT = new PointerType();
   PT->setElementType(Ty);
   PT->setName(ptr_name);
+  PT->setParent(Ty->getContainingBundle());
   ast->types.insert(ptr_name,Ty);
   return PT;
 }

Modified: hlvm/trunk/hlvm/AST/Node.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Node.cpp?rev=38349&r1=38348&r2=38349&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Node.cpp (original)
+++ hlvm/trunk/hlvm/AST/Node.cpp Sat Jul  7 19:02:34 2007
@@ -29,6 +29,7 @@
 
 #include <hlvm/AST/Node.h>
 #include <hlvm/AST/AST.h>
+#include <hlvm/AST/Bundle.h>
 #include <hlvm/AST/ContainerType.h>
 #include <hlvm/Base/Assert.h>
 #include <llvm/Support/Casting.h>
@@ -50,6 +51,16 @@
   return llvm::cast<AST>(last);
 }
 
+Bundle*
+Node::getContainingBundle() const
+{
+  Node* p = getParent();
+  while (p && !p->is(BundleID)) p = p->getParent();
+  if (!p)
+    return 0;
+  return llvm::cast<Bundle>(p);
+}
+
 void 
 Node::insertChild(Node* child)
 {

Modified: hlvm/trunk/hlvm/AST/Node.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Node.h?rev=38349&r1=38348&r2=38349&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Node.h (original)
+++ hlvm/trunk/hlvm/AST/Node.h Sat Jul  7 19:02:34 2007
@@ -39,6 +39,7 @@
 
 class Type;
 class AST;
+class Bundle;
 
 /// This enumeration is used to identify the various kinds of Abstract Syntax
 /// Tre nodes. Its organization is very specific and dependent on the class 
@@ -310,8 +311,12 @@
   /// @name Accessors
   /// @{
   public:
+    /// Get the AST root node that this Node is part of.
     inline AST* getRoot(); 
 
+    /// Return the bundle that contains this Node.
+    Bundle* getContainingBundle() const;
+
     /// Get the type of node
     inline NodeIDs getID() const { return NodeIDs(id); }
 

Modified: hlvm/trunk/hlvm/AST/Operator.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Operator.cpp?rev=38349&r1=38348&r2=38349&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.cpp (original)
+++ hlvm/trunk/hlvm/AST/Operator.cpp Sat Jul  7 19:02:34 2007
@@ -42,18 +42,8 @@
 {
 }
 
-Bundle*
-Operator::getContainingBundle()
-{
-  Node* p = getParent();
-  while (p && !p->is(BundleID)) p = p->getParent();
-  if (!p)
-    return 0;
-  return cast<Bundle>(p);
-}
-
 Function* 
-Operator::getContainingFunction()
+Operator::getContainingFunction() const
 {
   Node* p = getParent();
   while (p && !p->isFunction()) p = p->getParent();
@@ -63,7 +53,7 @@
 }
 
 Block*
-Operator::getContainingBlock()
+Operator::getContainingBlock() const
 {
   Node* p = getParent();
   while (p && !isa<Block>(p)) p = p->getParent();
@@ -73,7 +63,7 @@
 }
 
 Operator*
-Operator::getContainingLoop()
+Operator::getContainingLoop() const
 {
   Node* p = getParent();
   while (p && !p->isLoop()) p = p->getParent();

Modified: hlvm/trunk/hlvm/AST/Operator.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Operator.h?rev=38349&r1=38348&r2=38349&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.h (original)
+++ hlvm/trunk/hlvm/AST/Operator.h Sat Jul  7 19:02:34 2007
@@ -71,19 +71,15 @@
     virtual Operator* getOperand(unsigned opnum) const = 0;
 
     /// Return the function containing this operator
-    Function* getContainingFunction();
+    Function* getContainingFunction() const;
 
     /// Return the block containing this operator
-    Block* getContainingBlock();
+    Block* getContainingBlock() const;
 
     /// Return the loop operator containing this operator. This can return
     /// any of the loop constructs (Loop, While, Unless, etc.) so its result
     /// type is Operator*.
-    Operator* getContainingLoop();
-
-    /// Return the bundle that contains the function that contains the block
-    /// that contains this operator.
-    Bundle* getContainingBundle();
+    Operator* getContainingLoop() const;
 
     /// Determine if this is a classof some other type.
     static inline bool classof(const Operator*) { return true; }





More information about the llvm-commits mailing list