[llvm-commits] [hlvm] r38341 - in /hlvm/trunk: hlvm/AST/AST.cpp hlvm/AST/AST.h hlvm/AST/ContainerType.cpp hlvm/AST/ContainerType.h hlvm/AST/Node.cpp hlvm/AST/Node.h hlvm/AST/Operator.cpp hlvm/AST/Operator.h hlvm/AST/Type.h hlvm/CodeGen/LLVMGenerator.cpp hlvm/Pass/Validate.cpp hlvm/Reader/XMLReader.cpp hlvm/Writer/XMLWriter.cpp tools/hlvm-gentestcase/Generate.cpp

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


Author: reid
Date: Sat Jul  7 19:02:29 2007
New Revision: 38341

URL: http://llvm.org/viewvc/llvm-project?rev=38341&view=rev
Log:
Remove some confusion about NamedType vs NamedValue having to do with Arguments,
Values and Parameters. These are all now distinguishable things. Also,
implemented the validation for ReferenceOp and some more test case generation
code.

Modified:
    hlvm/trunk/hlvm/AST/AST.cpp
    hlvm/trunk/hlvm/AST/AST.h
    hlvm/trunk/hlvm/AST/ContainerType.cpp
    hlvm/trunk/hlvm/AST/ContainerType.h
    hlvm/trunk/hlvm/AST/Node.cpp
    hlvm/trunk/hlvm/AST/Node.h
    hlvm/trunk/hlvm/AST/Operator.cpp
    hlvm/trunk/hlvm/AST/Operator.h
    hlvm/trunk/hlvm/AST/Type.h
    hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp
    hlvm/trunk/hlvm/Pass/Validate.cpp
    hlvm/trunk/hlvm/Reader/XMLReader.cpp
    hlvm/trunk/hlvm/Writer/XMLWriter.cpp
    hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp

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

==============================================================================
--- hlvm/trunk/hlvm/AST/AST.cpp (original)
+++ hlvm/trunk/hlvm/AST/AST.cpp Sat Jul  7 19:02:29 2007
@@ -204,16 +204,12 @@
     ast->ProgramTypeSingleton->setName("ProgramType");
     Type* intType = ast->getPrimitiveType(SInt32TypeID);
     ast->ProgramTypeSingleton->setResultType(intType);
-    ArgumentType* argc = new ArgumentType();
-    argc->setName("argc");
-    argc->setElementType(intType);
-    ast->ProgramTypeSingleton->addArgument(argc);
+    Parameter* argc = new_Parameter("argc",intType);
+    ast->ProgramTypeSingleton->addParameter(argc);
     const PointerType* argv_type = getPointerTo(getPointerTo(
       ast->getPrimitiveType(StringTypeID)));
-    ArgumentType* argv = new ArgumentType();
-    argv->setName("argv");
-    argv->setElementType(argv);
-    ast->ProgramTypeSingleton->addArgument(argv);
+    Parameter* argv = new_Parameter("argv",argv_type);
+    ast->ProgramTypeSingleton->addParameter(argv);
   }
   return ast->ProgramTypeSingleton;
 }
@@ -469,14 +465,17 @@
   return result;
 }
 
-AliasType* 
-AST::new_AliasType(const std::string& id, Type* referrant, const Locator* loc)
+NamedType* 
+AST::new_NamedType(
+  const std::string& name, 
+  const Type* type,
+  const Locator* loc
+)
 {
-  AliasType* result = new AliasType();
+  NamedType* result = new NamedType();
   result->setLocator(loc);
-  result->setName(id);
-  result->setElementType(referrant);
-  static_cast<ASTImpl*>(this)->addType(result);
+  result->setName(name);
+  result->setType(type);
   return result;
 }
 
@@ -695,12 +694,13 @@
   ConstantStructure* result = new ConstantStructure();
   result->setLocator(loc);
   result->setName(name);
+  hlvmAssert(ST->size() == vals.size());
   StructureType::const_iterator STI = ST->begin();
   for (std::vector<ConstantValue*>::const_iterator I = vals.begin(),
        E = vals.end(); I != E; ++I ) 
   {
     hlvmAssert(STI != ST->end());
-    hlvmAssert((*I)->getType() == (*STI)->getElementType());
+    hlvmAssert((*I)->getType() == (*STI)->getType());
     result->addConstant(*I);
     ++STI;
   }
@@ -712,19 +712,20 @@
 AST::new_Variable(const std::string& id, const Type* Ty, const Locator* loc)
 {
   Variable* result = new Variable();
-  result->setLocator(loc);
-  result->setType(Ty);
   result->setName(id);
+  result->setType(Ty);
+  result->setLocator(loc);
   return result;
 }
 
 Argument*
-AST::new_Argument(const std::string& id, const Type* ty , const Locator* loc)
+AST::new_Argument(
+  const std::string& name, const Type* Ty, const Locator* loc)
 {
   Argument* result = new Argument();
+  result->setName(name);
+  result->setType(Ty);
   result->setLocator(loc);
-  result->setName(id);
-  result->setType(ty);
   return result;
 }
 
@@ -739,9 +740,9 @@
   for (SignatureType::const_iterator I = ty->begin(), E = ty->end(); 
        I != E; ++I ) 
   {
-    const Type* Ty = (*I)->getElementType();
+    const Type* Ty = (*I)->getType();
     assert(Ty && "Arguments can't be void type");
-    Argument* arg = new_Argument((*I)->getName(),Ty,loc);
+    Argument* arg = new_Argument((*I)->getName(),0,loc);
     result->addArgument(arg);
   }
   return result;
@@ -761,11 +762,9 @@
   for (SignatureType::const_iterator I = ty->begin(), E = ty->end(); 
        I != E; ++I ) 
   {
-    const Type* Ty = (*I)->getElementType();
+    const Type* Ty = (*I)->getType();
     assert(Ty && "Arguments can't be void type");
-    Argument* arg = new Argument();
-    arg->setType(Ty);
-    arg->setName((*I)->getName());
+    Argument* arg = new_Argument((*I)->getName(),Ty,loc);
     result->addArgument(arg);
   }
   return result;

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

==============================================================================
--- hlvm/trunk/hlvm/AST/AST.h (original)
+++ hlvm/trunk/hlvm/AST/AST.h Sat Jul  7 19:02:29 2007
@@ -47,8 +47,8 @@
 class Bundle;   
 class Documentation;
 class Block;
-class Function; 
 class Argument;
+class Function; 
 class Program; 
 class Import;
 class Locator; 
@@ -173,19 +173,18 @@
       const std::string& id,  ///< The name of the import
       const Locator* loc = 0 ///< 
     );
+    /// Create a new
+    Argument* new_Argument(
+      const std::string& name, /// The argument name
+      const Type* Ty,          /// The type of the argument
+      const Locator* loc = 0   /// The source locator
+    ); 
     /// Create a new Function node. 
     Function* new_Function(
       const std::string& id, ///< The name of the function
       const SignatureType* type,   ///< The type of the function
       const Locator* loc = 0 ///< The source locator
     );
-    /// Create a new Argument node. Arguments are used as the formal argument
-    /// value to a function.
-    Argument* new_Argument(
-      const std::string& id, ///< The name of the function argument
-      const Type* ty,        ///< The type of the function argument 
-      const Locator* loc = 0 ///< The source locator
-    );
     /// Create a new Program node. Programs are like functions except that their
     /// signature is fixed and they represent the entry point to a complete
     /// program. Unlike other languages, you can have multiple Program nodes
@@ -299,15 +298,28 @@
       uint64_t size,          ///< The number of elements in the vector
       const Locator* loc = 0  ///< The source locator
     );
-    /// Create a new AliasType node. An AliasType node is simply a way of giving
-    /// a new name to another type. Since type naming equates to type
-    /// equivalence in HLVM, this node allows two different types to be
-    /// equivalent without having the same name.
-    AliasType* new_AliasType(
-      const std::string& id,  ///< The name of the alias
-      Type* referrant,        ///< The type for which this type is an alias
-      const Locator* loc = 0  ///< The source locator
-    );
+    /// Create a new NamedType node. A NamedType is used as the field of a
+    /// structure or the parameter of a signature. It associates a type with
+    /// a name.
+    NamedType* new_NamedType(
+      const std::string& name, /// The field/parameter name
+      const Type* type,        /// The type of the field/parameter
+      const Locator* loc = 0   /// The source locator
+    );
+    inline Parameter* new_Parameter(
+      const std::string& name, /// The parameter name
+      const Type* type,        /// The type of the parameter
+      const Locator* loc = 0   /// The source locator
+    ) {
+      return new_NamedType(name,type,loc);
+    }
+    inline Field* new_Field(
+      const std::string& name, /// The field name
+      const Type* type,        /// The type of the field
+      const Locator* loc = 0   /// The source locator
+    ) {
+      return new_NamedType(name,type,loc);
+    }
     /// Create a new StructureType node. A StructureType is a type that is an
     /// ordered sequential arrangement of memory locations of various but 
     /// definite types.

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

==============================================================================
--- hlvm/trunk/hlvm/AST/ContainerType.cpp (original)
+++ hlvm/trunk/hlvm/AST/ContainerType.cpp Sat Jul  7 19:02:29 2007
@@ -46,49 +46,12 @@
   return 0;
 }
 
-void 
-UniformContainerType::insertChild(Node* n)
-{
-  hlvmAssert(isa<Type>(n) && "Can't insert those here");
-  if (type)
-    const_cast<Type*>(type)->setParent(0);
-  type = cast<Type>(n);
-}
-
-void 
-UniformContainerType::removeChild(Node* n)
-{
-  hlvmAssert(isa<Type>(n) && "Can't remove those here");
-  hlvmAssert(n->getParent() == this && "Node isn't my kid!");
-  hlvmAssert(type == n && "Node isn't mine");
-  type = 0;
-}
-
-PointerType::~PointerType()
-{
-}
+PointerType::~PointerType() { }
+ArrayType::~ArrayType() { }
+VectorType::~VectorType() { }
+NamedType::~NamedType() {}
 
-ArrayType::~ArrayType()
-{
-}
-
-VectorType::~VectorType()
-{
-}
-
-AliasType::~AliasType()
-{
-}
-
-const char*
-AliasType::getPrimitiveName() const
-{
-  return type->getPrimitiveName();
-}
-
-DisparateContainerType::~DisparateContainerType()
-{
-}
+DisparateContainerType::~DisparateContainerType() { }
 
 const char* 
 DisparateContainerType::getPrimitiveName() const
@@ -97,36 +60,8 @@
   return 0;
 }
 
-void 
-DisparateContainerType::insertChild(Node* n)
-{
-  hlvmAssert(isa<AliasType>(n) && "Can't insert those here");
-#ifdef HLVM_ASSERT
-  for (const_iterator I = begin(), E = end(); I != E; ++I)
-    hlvmAssert((*I) != n);
-#endif
-  contents.push_back(cast<AliasType>(n));
-}
-
-void 
-DisparateContainerType::removeChild(Node* n)
-{
-  hlvmAssert(isa<Type>(n) && "Can't remove those here");
-  // This is sucky slow, but we probably won't be removing nodes that much.
-  for (iterator I = begin(), E = end(); I != E; ++I ) {
-    if (*I == n) { contents.erase(I); break; }
-  }
-  hlvmAssert(!"That node isn't my child");
-}
-
 StructureType::~StructureType() { }
 
-void
-StructureType::setFields(const std::vector<FieldType*>& flds)
-{
-  contents.insert(contents.end(), flds.begin(),flds.end());
-}
-
 SignatureType::~SignatureType() { }
 
 }

Modified: hlvm/trunk/hlvm/AST/ContainerType.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/ContainerType.h?rev=38341&r1=38340&r2=38341&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/ContainerType.h (original)
+++ hlvm/trunk/hlvm/AST/ContainerType.h Sat Jul  7 19:02:29 2007
@@ -38,22 +38,22 @@
 /// This class provides an Abstract Syntax Tree node that represents a uniform
 /// container type.  Uniform container types are those types that reference 
 /// another type. They may have multiple elements but all elements are of the
-/// same type, hence they are uniform.  This is true of types such as AliasType
-/// (a simple renaming of another type), PointerType, ArrayType, and VectorTYpe.
+/// same type, hence they are uniform.  This is true of types such as 
+/// PointerType, ArrayType, and VectorTYpe.
 /// @brief AST Abstract Uniform Container Type Node
 class UniformContainerType : public Type
 {
   /// @name Constructors
   /// @{
   protected:
-    UniformContainerType(NodeIDs id) : Type(id), type(0) {}
+    UniformContainerType(NodeIDs id) : Type(id), elemType(0) {}
     virtual ~UniformContainerType();
 
   /// @}
   /// @name Accessors
   /// @{
   public:
-    const Type* getElementType() const { return type; }
+    const Type* getElementType() const { return elemType; }
     virtual const char* getPrimitiveName() const; // asserting override
     /// Methods to support type inquiry via isa, cast, dyn_cast
     static inline bool classof(const UniformContainerType*) { return true; }
@@ -65,17 +65,13 @@
   /// @name Mutators
   /// @{
   public:
-    void setElementType(const Type* t) { type = t; }
-
-  protected:
-    virtual void insertChild(Node* n);
-    virtual void removeChild(Node* n);
+    void setElementType(const Type* t) { elemType = t; }
 
   /// @}
   /// @name Data
   /// @{
   protected:
-    const Type* type; ///< The contained types
+    const Type* elemType; ///< The contained types
   /// @}
 };
 
@@ -195,37 +191,49 @@
   friend class AST;
 };
 
-/// This class provides an Abstract Syntax Tree node that is simply a renaming
-/// of another type.  It adopts the characteristics of the referrent type. This
-/// construct is necessary in HLVM because type equivalence is done by name, 
-/// not by semantics.  To dissociate two types of equivalent semantics, say
-/// an integer type, one uses an AliasType to provide a new type name with the
-/// same semantics. AliasType is a UniformContainerType because it refers to
-/// another type of uniform type. AliasTypes are also used in the definition of
-/// a Function's formal arguments and a Structure's fields. In these situations
-/// the name provided by the AliasType forms the name of the argument or 
-/// structure field.
-/// @see Function
-/// @see Structure
-/// @brief AST Alias Type Node
-class AliasType : public UniformContainerType
+/// This typedef is used to associate a name with a type. Although types have 
+/// names, this provides another name such as used in the fields of a structure
+/// or the formal parameters of a function.
+/// @see Type
+/// @see StructureType
+/// @see SignatureType
+/// @see DisparateContainerType
+/// @brief A Named Type
+class NamedType : public Documentable
 {
   /// @name Constructors
   /// @{
   protected:
-    AliasType() : UniformContainerType(AliasTypeID) {}
-    virtual ~AliasType();
+    NamedType() : Documentable(NamedTypeID), name(), type(0) {}
+    virtual ~NamedType();
 
   /// @}
   /// @name Accessors
   /// @{
   public:
-    virtual const char* getPrimitiveName() const;
+    /// Get the maximum size the array can grow to.
+    const std::string& getName()  const { return name; }
+    const Type* getType() const { return type; }
+
     /// Methods to support type inquiry via is, cast, dyn_cast
-    static inline bool classof(const AliasType*) { return true; }
-    static inline bool classof(const Node* T) { return T->is(AliasTypeID); }
+    static inline bool classof(const NamedType*) { return true; }
+    static inline bool classof(const Node* T) { return T->is(NamedTypeID); }
 
   /// @}
+  /// @name Mutators
+  /// @{
+  public:
+    /// Set the size of the vector.
+    void setName(const std::string& N) { name = N; }
+    void setType(const Type* Ty) { type = Ty; }
+
+  /// @}
+  /// @name Data
+  /// @{
+  protected:
+    std::string name;
+    const Type* type;
+  /// @}
   friend class AST;
 };
 
@@ -240,7 +248,7 @@
   /// @name Types
   /// @{
   public:
-    typedef std::vector<AliasType*> ContentsList;
+    typedef std::vector<NamedType*> ContentsList;
     typedef ContentsList::iterator iterator;
     typedef ContentsList::const_iterator const_iterator;
 
@@ -265,8 +273,9 @@
   /// @name Mutators
   /// @{
   protected:
-    virtual void insertChild(Node* n);
-    virtual void removeChild(Node* n);
+    void setTypes(const std::vector<NamedType*>& Types) { contents = Types; }
+    void addType(NamedType* NT )
+      { contents.push_back(NT); }
 
   /// @}
   /// @name Iterators
@@ -278,22 +287,21 @@
     const_iterator   end  () const { return contents.end(); }
     size_t           size () const { return contents.size(); }
     bool             empty() const { return contents.empty(); }
-    AliasType*       front()       { return contents.front(); }
-    const AliasType* front() const { return contents.front(); }
-    AliasType*       back()        { return contents.back(); }
-    const AliasType* back()  const { return contents.back(); }
+    NamedType*       front()       { return contents.front(); }
+    const NamedType* front() const { return contents.front(); }
+    NamedType*       back()        { return contents.back(); }
+    const NamedType* back()  const { return contents.back(); }
 
   /// @}
   /// @name Data
   /// @{
-  protected:
+  private:
     ContentsList contents; ///< The contained types
   /// @}
 };
 
-/// This typedef just uses a more common name when accessing the fields of a
-/// structure.
-typedef AliasType FieldType;
+/// A convenience typedef so we can call NamedTypes as "Fields"
+typedef NamedType Field;
 
 /// This class provides an Abstract Syntax Tree node that represents an 
 /// sequence type. A sequence type is a type that lays out its elements in 
@@ -321,9 +329,9 @@
   /// @}
   /// @name Mutators
   /// @{
-  protected:
-    void setFields(const std::vector<FieldType*>& fields);
-    void addField(FieldType* field) { contents.push_back(field); }
+  public:
+    void setFields(const std::vector<Field*>& fields) { setTypes(fields); }
+    void addField(Field* Fld ) { addType(Fld); }
 
   /// @}
   /// @name Data
@@ -362,9 +370,8 @@
   friend class AST;
 };
 
-/// This typedef just provides a more common name for accessing the types of
-/// the arguments of a signature.
-typedef AliasType ArgumentType;
+/// A convenience typedef so we can call NamedTypes as Parameters
+typedef NamedType Parameter;
 
 /// This class provides an Abstract Syntax Tree node that represents the call
 /// signature of an HLVM function. A SignatureType encapsulates the
@@ -398,7 +405,8 @@
   public:
     void setResultType(const Type* ty) { result = ty; }
     void setIsVarArgs(bool is) { flags = is ? 1 : 0; }
-    void addArgument(ArgumentType* arg) { contents.push_back(arg); }
+    void setParameters(const std::vector<Parameter*>& param) { setTypes(param);}
+    void addParameter(Parameter* param) { addType(param); }
 
   /// @}
   /// @name Data

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Node.cpp (original)
+++ hlvm/trunk/hlvm/AST/Node.cpp Sat Jul  7 19:02:29 2007
@@ -29,6 +29,7 @@
 
 #include <hlvm/AST/Node.h>
 #include <hlvm/AST/AST.h>
+#include <hlvm/AST/ContainerType.h>
 #include <hlvm/Base/Assert.h>
 #include <llvm/Support/Casting.h>
 

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Node.h (original)
+++ hlvm/trunk/hlvm/AST/Node.h Sat Jul  7 19:02:29 2007
@@ -55,8 +55,8 @@
   TreeTopID,               ///< The AST node which is always root of the tree
 FirstNodeID = TreeTopID,
   DocumentationID,         ///< XHTML Documentation Node
-  DocumentableID,          ///< A node that can have a Documentation Node
-FirstDocumentableID = DocumentableID,
+  NamedTypeID,             ///< An association of a name with a type
+FirstDocumentableID = NamedTypeID,
   BundleID,                ///< The Bundle Node (a group of other declarations)
   ImportID,                ///< A bundle's Import declaration
 
@@ -97,10 +97,9 @@
 LastSimpleTypeID     = OpaqueTypeID,  
 
   // Uniform Container Types
-  AliasTypeID,             ///< A new name for an existing type
-FirstContainerTypeID = AliasTypeID,
-FirstUniformContainerTypeID = AliasTypeID,
   PointerTypeID,           ///< The Pointer Type (Pointer To object of Type)
+FirstContainerTypeID = PointerTypeID,
+FirstUniformContainerTypeID = PointerTypeID,
   ArrayTypeID,             ///< The Array Type (Linear array of some type)
   VectorTypeID,            ///< The Vector Type (Packed Fixed Size Vector)
 LastUniformContainerTypeID = VectorTypeID,
@@ -570,6 +569,7 @@
   public:
     // Get the type of the value
     virtual const Type* getType() const { return type; }
+    const Type* getConcreteType() const;
 
     static inline bool classof(const Value*) { return true; }
     static inline bool classof(const Node* N) { return N->isValue(); }
@@ -589,6 +589,5 @@
   friend class AST;
 };
 
-
 } // end hlvm namespace
 #endif

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.cpp (original)
+++ hlvm/trunk/hlvm/AST/Operator.cpp Sat Jul  7 19:02:29 2007
@@ -29,6 +29,7 @@
 
 #include <hlvm/AST/Operator.h>
 #include <hlvm/AST/Linkables.h>
+#include <hlvm/AST/Bundle.h>
 #include <hlvm/AST/ControlFlow.h>
 #include <hlvm/Base/Assert.h>
 #include <llvm/Support/Casting.h>
@@ -41,6 +42,16 @@
 {
 }
 
+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()
 {

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.h (original)
+++ hlvm/trunk/hlvm/AST/Operator.h Sat Jul  7 19:02:29 2007
@@ -36,6 +36,7 @@
 {
 
 class Type; 
+class Bundle;
 class Function;
 class Block;
 class LoopOp;
@@ -80,6 +81,10 @@
     /// type is Operator*.
     Operator* getContainingLoop();
 
+    /// Return the bundle that contains the function that contains the block
+    /// that contains this operator.
+    Bundle* getContainingBundle();
+
     /// Determine if this is a classof some other type.
     static inline bool classof(const Operator*) { return true; }
     static inline bool classof(const Node* N) { return N->isOperator(); }

Modified: hlvm/trunk/hlvm/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Type.h?rev=38341&r1=38340&r2=38341&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Type.h (original)
+++ hlvm/trunk/hlvm/AST/Type.h Sat Jul  7 19:02:29 2007
@@ -87,6 +87,7 @@
   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 

Modified: hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp?rev=38341&r1=38340&r2=38341&view=diff

==============================================================================
--- hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp (original)
+++ hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp Sat Jul  7 19:02:29 2007
@@ -511,9 +511,6 @@
     case BufferTypeID: 
       result = get_hlvm_buffer();
       break;
-    case AliasTypeID:
-      result = getType(llvm::cast<AliasType>(ty)->getElementType());
-      break;
     case PointerTypeID: 
     {
       const hlvm::Type* hElemType = 
@@ -547,7 +544,7 @@
       std::vector<const llvm::Type*> Fields;
       for (StructureType::const_iterator I = ST->begin(), E = ST->end(); 
            I != E; ++I)
-        Fields.push_back(getType((*I)->getElementType()));
+        Fields.push_back(getType((*I)->getType()));
       result = llvm::StructType::get(Fields);
       break;
     }
@@ -557,7 +554,7 @@
       const SignatureType* st = llvm::cast<SignatureType>(ty);
       for (SignatureType::const_iterator I = st->begin(), E = st->end(); 
            I != E; ++I)
-        params.push_back(getType(*I));
+        params.push_back(getType((*I)->getType()));
       result = llvm::FunctionType::get(
         getType(st->getResultType()),params,st->isVarArgs());
       break;
@@ -1686,7 +1683,6 @@
   hlvm::Function* hFunc = co->getCalledFunction();
   const SignatureType* sigTy = hFunc->getSignature();
   // Set up the loop
-  std::vector<llvm::Value*> args;
   CallOp::iterator I = co->begin();
   CallOp::iterator E = co->end();
 
@@ -1695,7 +1691,8 @@
   hlvmAssert(funcToCall && "No function to call?");
   hlvmAssert(llvm::isa<llvm::Function>(funcToCall));
 
-  // Get the function call operands
+  // Get the function call arguments
+  std::vector<llvm::Value*> args;
   for ( ; I != E; ++I ) {
     llvm::Value* arg = popOperand(*I);
     hlvmAssert(arg && "No argument for CallOp?");
@@ -1973,12 +1970,6 @@
     // post-order because we want their operands to be constructed first.
     switch (n->getID()) 
     {
-      case AliasTypeID:
-      {
-        AliasType* t = llvm::cast<AliasType>(n);
-        lmod->addTypeName(t->getName(), getType(t->getElementType()));
-        break;
-      }
       case AnyTypeID:
       case StringTypeID:
       case BooleanTypeID:

Modified: hlvm/trunk/hlvm/Pass/Validate.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Pass/Validate.cpp?rev=38341&r1=38340&r2=38341&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Pass/Validate.cpp (original)
+++ hlvm/trunk/hlvm/Pass/Validate.cpp Sat Jul  7 19:02:29 2007
@@ -222,10 +222,19 @@
   else if (n->size() == 0 && !llvm::isa<SignatureType>(n)) {
     error(n,"DisparateContainerType without elements");
     result = false;
-  } else
+  } else {
     for (DisparateContainerType::iterator I = n->begin(), E = n->end(); 
-         I != E; ++I)
-      result &= checkUniformContainer(*I, AliasTypeID);
+         I != E; ++I) {
+      if (!(*I)->getType()) {
+        error(n,std::string("Null type not permited in DisparateContainerType")
+            + " for '" + (*I)->getName() + "'");
+        result = false;
+      } else if ((*I)->getName().empty()) {
+        error((*I)->getType(),"Type has no field name");
+        result = false;
+      }
+    }
+  }
   return result;
 }
 
@@ -408,12 +417,6 @@
 }
 
 template<> inline void
-ValidateImpl::validate(AliasType* n)
-{
-  checkUniformContainer(n, AliasTypeID);
-}
-
-template<> inline void
 ValidateImpl::validate(PointerType* n)
 {
   checkUniformContainer(n, PointerTypeID);
@@ -807,7 +810,7 @@
       unsigned opNum = 1;
       for (SignatureType::const_iterator I = sig->begin(), E = sig->end(); 
            I != E; ++I)
-        if ((*I)->getElementType() != op->getOperand(opNum++)->getType())
+        if ((*I)->getType() != op->getOperand(opNum++)->getType())
           error(op,std::string("Argument #") + utostr(opNum-1) +
               " has wrong type for function");
     }
@@ -892,8 +895,42 @@
 template<> inline void
 ValidateImpl::validate(ReferenceOp* op)
 {
-  checkOperator(op,ReferenceOpID,0,true);
-  /// FIXME: check referent out
+  if (checkOperator(op,ReferenceOpID,0,true)) {
+    const Value* referent = op->getReferent();
+    Block* blk = op->getContainingBlock();
+    if (!blk)
+      error(op,"ReferenceOp not in a block?");
+    else if (const AutoVarOp* ref = dyn_cast<AutoVarOp>(referent)) {
+      while (blk != 0) {
+        if (AutoVarOp* av = blk->getAutoVar(ref->getName())) 
+          if (av == ref)
+            break;
+        blk = blk->getContainingBlock();
+      }
+      if (blk == 0)
+        error(op,"Referent does not match name in scope");
+    } else if (const Argument* ref = dyn_cast<Argument>(referent)) {
+      Function* F = op->getContainingFunction();
+      if (!F)
+        error(op,"ReferenceOp not in a function?");
+      else if (F->getArgument(ref->getName()) != ref)
+        error(op,"Referent does not match function argument");
+    } else if (const ConstantValue* cval = dyn_cast<ConstantValue>(referent)) {
+      Bundle* B = op->getContainingBundle();
+      if (!B)
+        error(op,"ReferenceOp not in a bundle?");
+      else if (B->find_cval(cval->getName()) != cval)
+        error(op,"Referent does not match constant value");
+    } else if (const Linkable* var = dyn_cast<Linkable>(referent)) {
+      Bundle* B = op->getContainingBundle();
+      if (!B)
+        error(op,"ReferenceOp not in a bundle?");
+      else if (B->find_cval(cval->getName()) != cval)
+        error(op,"Referent does not match linkable by name");
+    } else {
+      error(op,"Referent of unknown kind");
+    }
+  }
 }
 
 template<> inline void
@@ -1434,7 +1471,6 @@
     case TextTypeID:             validate(cast<TextType>(n)); break;
     case StreamTypeID:           validate(cast<StreamType>(n)); break;
     case BufferTypeID:           validate(cast<BufferType>(n)); break;
-    case AliasTypeID:            validate(cast<AliasType>(n)); break;
     case PointerTypeID:          validate(cast<PointerType>(n)); break;
     case ArrayTypeID:            validate(cast<ArrayType>(n)); break;
     case VectorTypeID:           validate(cast<VectorType>(n)); break;

Modified: hlvm/trunk/hlvm/Reader/XMLReader.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/XMLReader.cpp?rev=38341&r1=38340&r2=38341&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Reader/XMLReader.cpp (original)
+++ hlvm/trunk/hlvm/Reader/XMLReader.cpp Sat Jul  7 19:02:29 2007
@@ -529,18 +529,6 @@
   return child;
 }
 
-template<> AliasType*
-XMLReaderImpl::parse<AliasType>(xmlNodePtr& cur)
-{
-  hlvmAssert(getToken(cur->name)==TKN_alias);
-  std::string id = getAttribute(cur,"id");
-  std::string renames = getAttribute(cur,"renames");
-  AliasType* alias = 
-    ast->new_AliasType(id,getType(renames),getLocator(cur));
-  checkDoc(cur,alias);
-  return alias;
-}
-
 template<> EnumerationType*
 XMLReaderImpl::parse<EnumerationType>(xmlNodePtr& cur)
 {
@@ -613,9 +601,10 @@
                "Structure only has fields");
     std::string name = getAttribute(child,"id");
     std::string type = getAttribute(child,"type");
-    AliasType* alias = ast->new_AliasType(name,getType(type),loc);
-    alias->setParent(struc);
-    checkDoc(child,alias);
+    Locator* fldLoc = getLocator(child);
+    Field* fld = ast->new_Field(name,getType(type),fldLoc);
+    struc->addField(fld);
+    checkDoc(child,fld);
     child = child->next;
   }
   return struc;
@@ -638,9 +627,10 @@
     hlvmAssert(getToken(child->name) == TKN_arg && "Signature only has args");
     std::string name = getAttribute(child,"id");
     std::string type = getAttribute(child,"type");
-    AliasType* alias = ast->new_AliasType(name,getType(type),loc);
-    alias->setParent(sig);
-    checkDoc(child,alias);
+    Locator* paramLoc = getLocator(child);
+    Parameter* param = ast->new_Parameter(name,getType(type),paramLoc);
+    sig->addParameter(param);
+    checkDoc(child,param);
     child = child->next;
   }
   return sig;
@@ -955,7 +945,6 @@
       }
       case TKN_import      : { n = parse<Import>(child); break; }
       case TKN_bundle      : { n = parse<Bundle>(child); break; }
-      case TKN_alias       : { n = parse<AliasType>(child); break; }
       case TKN_atom        : { n = parseAtom(child); break; }
       case TKN_enumeration : { n = parse<EnumerationType>(child); break; }
       case TKN_pointer     : { n = parse<PointerType>(child); break; }

Modified: hlvm/trunk/hlvm/Writer/XMLWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/XMLWriter.cpp?rev=38341&r1=38340&r2=38341&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Writer/XMLWriter.cpp (original)
+++ hlvm/trunk/hlvm/Writer/XMLWriter.cpp Sat Jul  7 19:02:29 2007
@@ -175,15 +175,6 @@
 }
 
 template<> void 
-XMLWriterImpl::WriterPass::put(AliasType* t)
-{
-  startElement("alias");
-  writeAttribute("id",t->getName());
-  writeAttribute("renames",t->getElementType());
-  putDoc(t);
-}
-
-template<> void 
 XMLWriterImpl::WriterPass::put(AnyType* t)
 {
   startElement("atom");
@@ -347,10 +338,10 @@
   putDoc(t);
   for (StructureType::iterator I = t->begin(), E = t->end(); I != E; ++I) {
     startElement("field");
-    AliasType* alias = cast<AliasType>(*I);
-    writeAttribute("id",alias->getName());
-    writeAttribute("type",alias->getElementType());
-    putDoc(alias);
+    Field* field = cast<Field>(*I);
+    writeAttribute("id",field->getName());
+    writeAttribute("type",field->getType());
+    putDoc(field);
     endElement();
   }
 }
@@ -366,10 +357,10 @@
   putDoc(t);
   for (SignatureType::iterator I = t->begin(), E = t->end(); I != E; ++I) {
     startElement("arg");
-    AliasType* alias = cast<AliasType>(*I);
-    writeAttribute("id",alias->getName());
-    writeAttribute("type",alias->getElementType());
-    putDoc(alias);
+    Parameter* param = cast<Parameter>(*I);
+    writeAttribute("id",param->getName());
+    writeAttribute("type",param->getType());
+    putDoc(param);
     endElement();
   }
 }
@@ -804,7 +795,6 @@
   if (mode & Pass::PreOrderTraversal) {
     switch (n->getID()) 
     {
-      case AliasTypeID:          put(cast<AliasType>(n)); break;
       case AnyTypeID:            put(cast<AnyType>(n)); break;
       case StringTypeID:         put(cast<StringType>(n)); break;
       case BooleanTypeID:        put(cast<BooleanType>(n)); break;

Modified: hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp?rev=38341&r1=38340&r2=38341&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp (original)
+++ hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp Sat Jul  7 19:02:29 2007
@@ -154,13 +154,6 @@
       result = ast->new_RealType(name,randRange(1,52),randRange(1,11),loc);
       break;
     }
-    case AliasTypeID:
-    {
-      Locator* loc = getLocator();
-      std::string name = "alias_" + utostr(line);
-      result = ast->new_AliasType(name,genType(),loc);
-      break;
-    }
     case PointerTypeID:
     {
       Locator* loc = getLocator();
@@ -191,9 +184,8 @@
       std::string name = "struct_" + utostr(line);
       StructureType* S = ast->new_StructureType(name,loc);
       for (unsigned i = 0; i < Complexity; ++i) {
-        FieldType* fld = 
-          ast->new_AliasType(name+"_"+utostr(i),genType(),getLocator());
-        fld->setParent(S);
+        Field* fld = ast->new_Field(name+"_"+utostr(i),genType(),getLocator());
+        S->addField(fld);
       }
       result = S;
       break;
@@ -385,12 +377,6 @@
         std::string("cf32_")+utostr(line),val_str,Ty,loc);
       break;
     }
-    case AliasTypeID:
-    {
-      C = cast<ConstantValue>(
-            genValue(llvm::cast<AliasType>(Ty)->getElementType(),true));
-      break;
-    }
     case PointerTypeID:
     {
       const PointerType* PT = llvm::cast<PointerType>(Ty);
@@ -430,15 +416,15 @@
       /* FALL THROUGH (not implemented) */
     case StructureTypeID:
     {
-      const StructureType* VT = llvm::cast<StructureType>(Ty);
+      const StructureType* ST = llvm::cast<StructureType>(Ty);
       std::vector<ConstantValue*> elems;
-      for (StructureType::const_iterator I = VT->begin(), E = VT->end(); 
+      for (StructureType::const_iterator I = ST->begin(), E = ST->end(); 
            I != E; ++I) {
-        Value* V = genValue((*I)->getElementType(),true);
+        Value* V = genValue((*I)->getType(),true);
         elems.push_back(cast<ConstantValue>(V));
       }
       C = ast->new_ConstantStructure(std::string("cstruct_") + utostr(line),
-          elems, VT, loc);
+          elems, ST, loc);
       break;
     }
     default:
@@ -455,9 +441,6 @@
     result = var;
   }
 
-  // Give the thing a place to live
-  result->setParent(bundle);
-
   // Memoize the result
   values[result->getType()].push_back(result);
   return result;
@@ -473,7 +456,7 @@
   for (SignatureType::const_iterator I = sig->begin(), E = sig->end(); 
        I != E; ++I)
   {
-    Value* V = genValue((*I)->getElementType());
+    Value* V = genValue((*I)->getType());
     hlvmAssert(isa<ConstantValue>(V) || isa<Linkable>(V)) ;
     Operator* O = ast->new_ReferenceOp(V,getLocator());
     args.push_back(O);
@@ -503,8 +486,8 @@
   for (unsigned i = 0; i < numArgs; ++i )
   {
     std::string name = "arg_" + utostr(i+1);
-    AliasType* alias = ast->new_AliasType(name,genType(),loc);
-    alias->setParent(sig);
+    Parameter* param = ast->new_Parameter(name,genType(),loc);
+    sig->addParameter(param);
   }
 
   // Create the function and set its linkage





More information about the llvm-commits mailing list