[llvm-commits] [hlvm] r38290 - in /hlvm/trunk: hlvm/AST/ hlvm/CodeGen/ hlvm/Pass/ hlvm/Reader/ hlvm/Writer/ test/return0/ test/xml2xml/ tools/hlvm-compiler/ tools/hlvm-config/

Reid Spencer reid at x10sys.com
Sat Jul 7 17:01:59 PDT 2007


Author: reid
Date: Sat Jul  7 19:01:59 2007
New Revision: 38290

URL: http://llvm.org/viewvc/llvm-project?rev=38290&view=rev
Log:
A rather large change set having to do with improvements to the AST class
hierarchy for handling constants better. Also, various cleanups like the
SymbolTable becoming parameterized by node type, changes in the XML syntax,
consolidation or all references to one ReferenceOp, addition of the CallOp (not
working yet).  This fails on some tests, but it is just unfinished work.

Added:
    hlvm/trunk/hlvm/AST/Linkables.cpp
      - copied, changed from r38279, hlvm/trunk/hlvm/AST/LinkageItems.cpp
    hlvm/trunk/hlvm/AST/Linkables.h
      - copied, changed from r38279, hlvm/trunk/hlvm/AST/LinkageItems.h
Removed:
    hlvm/trunk/hlvm/AST/LinkageItems.cpp
    hlvm/trunk/hlvm/AST/LinkageItems.h
Modified:
    hlvm/trunk/hlvm/AST/AST.cpp
    hlvm/trunk/hlvm/AST/AST.h
    hlvm/trunk/hlvm/AST/Bundle.cpp
    hlvm/trunk/hlvm/AST/Bundle.h
    hlvm/trunk/hlvm/AST/Constants.cpp
    hlvm/trunk/hlvm/AST/Constants.h
    hlvm/trunk/hlvm/AST/ControlFlow.cpp
    hlvm/trunk/hlvm/AST/ControlFlow.h
    hlvm/trunk/hlvm/AST/MemoryOps.cpp
    hlvm/trunk/hlvm/AST/MemoryOps.h
    hlvm/trunk/hlvm/AST/Node.h
    hlvm/trunk/hlvm/AST/Operator.cpp
    hlvm/trunk/hlvm/AST/SymbolTable.cpp
    hlvm/trunk/hlvm/AST/SymbolTable.h
    hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp
    hlvm/trunk/hlvm/Pass/Pass.cpp
    hlvm/trunk/hlvm/Pass/Validate.cpp
    hlvm/trunk/hlvm/Reader/HLVM.rng
    hlvm/trunk/hlvm/Reader/XMLReader.cpp
    hlvm/trunk/hlvm/Writer/XMLWriter.cpp
    hlvm/trunk/test/return0/arithmetic.hlx
    hlvm/trunk/test/return0/bitwise.hlx
    hlvm/trunk/test/return0/boolean.hlx
    hlvm/trunk/test/return0/helloworld.hlx
    hlvm/trunk/test/return0/return0.hlx
    hlvm/trunk/test/xml2xml/arithmetic.hlx
    hlvm/trunk/test/xml2xml/helloworld.hlx
    hlvm/trunk/test/xml2xml/loop.hlx
    hlvm/trunk/test/xml2xml/return.hlx
    hlvm/trunk/test/xml2xml/select.hlx
    hlvm/trunk/test/xml2xml/switch.hlx
    hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp
    hlvm/trunk/tools/hlvm-config/hlvm-config.cpp

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

==============================================================================
--- hlvm/trunk/hlvm/AST/AST.cpp (original)
+++ hlvm/trunk/hlvm/AST/AST.cpp Sat Jul  7 19:01:59 2007
@@ -32,7 +32,7 @@
 #include <hlvm/AST/Bundle.h>
 #include <hlvm/AST/Documentation.h>
 #include <hlvm/AST/ContainerType.h>
-#include <hlvm/AST/LinkageItems.h>
+#include <hlvm/AST/Linkables.h>
 #include <hlvm/AST/Constants.h>
 #include <hlvm/AST/Block.h>
 #include <hlvm/AST/ControlFlow.h>
@@ -55,7 +55,7 @@
 {
   public:
     ASTImpl()
-      : types(), vars(), funcs(), unresolvedTypes(), 
+      : types(), unresolvedTypes(), 
         AnyTypeSingleton(0), StringTypeSingleton(0),
         VoidSingleton(0), BooleanSingleton(), CharacterSingleton(0), 
         OctetSingleton(0), UInt8Singleton(0), UInt16Singleton(0), 
@@ -77,10 +77,8 @@
 
   private:
     // Pool pool;
-    SymbolTable    types;
-    SymbolTable    vars;
-    SymbolTable    funcs;
-    SymbolTable    unresolvedTypes;
+    SymbolTable<Type>    types;
+    SymbolTable<Type>    unresolvedTypes;
     AnyType*       AnyTypeSingleton;
     StringType*    StringTypeSingleton;
     VoidType*      VoidSingleton;
@@ -625,7 +623,10 @@
 
 AutoVarOp*
 AST::new_AutoVarOp(
-    const std::string& name, const Type* Ty, Constant* op1,const Locator* loc)
+    const std::string& name, 
+    const Type* Ty, 
+    ConstantValue* op1,
+    const Locator* loc)
 {
   hlvmAssert(Ty != 0 && "AutoVarOp must have a Type!");
   AutoVarOp* result = new AutoVarOp();
@@ -640,24 +641,17 @@
 AST::new_ReferenceOp(const Value* V, const Locator*loc)
 {
   hlvmAssert(V != 0 && "ReferenceOp must have a Value to reference");
-  hlvmAssert(llvm::isa<Variable>(V) || llvm::isa<AutoVarOp>(V));
-  const Type* elemType = V->getType();
-  PointerType* PT = getPointerTo(elemType);
+  hlvmAssert(llvm::isa<Constant>(V) || llvm::isa<AutoVarOp>(V));
   ReferenceOp* result = new ReferenceOp();
+  const Type* refType = V->getType();
+  if (llvm::isa<ConstantValue>(V)) {
+    result->setType(refType);
+  } else {
+    PointerType* PT = getPointerTo(refType);
+    result->setType(PT);
+  }
   result->setLocator(loc);
   result->setReferent(V);
-  result->setType(PT);
-  return result;
-}
-
-ConstantReferenceOp* 
-AST::new_ConstantReferenceOp(const Constant* C, const Locator* loc)
-{
-  hlvmAssert(C != 0 && "ConstantReferenceOp must have a Constant to reference");
-  ConstantReferenceOp* result = new ConstantReferenceOp();
-  result->setLocator(loc);
-  result->setReferent(C);
-  result->setType(C->getType());
   return result;
 }
 
@@ -995,10 +989,10 @@
 template Block* 
 AST::new_MultiOp<Block>(const std::vector<Operator*>& ops, const Locator*loc);
 
-template NoOperator* 
-AST::new_NilaryOp<NoOperator>(const Type* Ty, const Locator*loc);
-template NoOperator* 
-AST::new_NilaryOp<NoOperator>(const Locator*loc);
+template NullOp* 
+AST::new_NilaryOp<NullOp>(const Type* Ty, const Locator*loc);
+template NullOp* 
+AST::new_NilaryOp<NullOp>(const Locator*loc);
 
 template SelectOp*
 AST::new_TernaryOp<SelectOp>(
@@ -1049,6 +1043,11 @@
 template ReturnOp* 
 AST::new_UnaryOp<ReturnOp>(Operator*op1,const Locator*loc);
 
+template CallOp* 
+AST::new_MultiOp<CallOp>(const Type*Ty, const std::vector<Operator*>& ops, const Locator*loc);
+template CallOp* 
+AST::new_MultiOp<CallOp>(const std::vector<Operator*>& ops, const Locator* loc);
+
 // Memory Operators
 template StoreOp*  
 AST::new_BinaryOp<StoreOp>(const Type*, Operator*op1,Operator*op2,const Locator*loc);

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

==============================================================================
--- hlvm/trunk/hlvm/AST/AST.h (original)
+++ hlvm/trunk/hlvm/AST/AST.h Sat Jul  7 19:01:59 2007
@@ -475,7 +475,7 @@
     AutoVarOp* new_AutoVarOp(
       const std::string& name, ///< Name of the autovar in its scope
       const Type* Ty,          ///< Type of the autovar
-      Constant* op1,           ///< Initializer for the autovar
+      ConstantValue* op1,      ///< Initializer for the autovar
       const Locator* loc       ///< The source locator
     );
 
@@ -485,12 +485,6 @@
       const Locator*loc = 0 ///< The source locator
     );
 
-    /// Create a new ReferenceOp.
-    ConstantReferenceOp* new_ConstantReferenceOp(
-      const Constant* C,     ///< The constant being referenced
-      const Locator* loc = 0 ///< The source locator
-    );
-
     /// Provide a template function for creating standard nilary operators
     template<class OpClass>
     OpClass* new_NilaryOp(

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Bundle.cpp (original)
+++ hlvm/trunk/hlvm/AST/Bundle.cpp Sat Jul  7 19:01:59 2007
@@ -29,8 +29,9 @@
 
 #include <hlvm/AST/Bundle.h>
 #include <hlvm/AST/Type.h>
-#include <hlvm/AST/LinkageItems.h>
+#include <hlvm/AST/Linkables.h>
 #include <hlvm/Base/Assert.h>
+#include <llvm/Support/Casting.h>
 
 using namespace llvm; 
 
@@ -42,14 +43,12 @@
 Bundle::insertChild(Node* kid)
 {
   hlvmAssert(kid && "Null child!");
-  if (kid->isType())
-    types.insert(cast<Type>(kid)->getName(), kid);
-  else if (kid->is(VariableID))
-    vars.insert(cast<Variable>(kid)->getName(), kid);
-  else if (kid->isFunction())
-    funcs.insert(cast<Function>(kid)->getName(), kid);
-  else if (kid->isConstant()) // must be last, everything above isa<Constant>
-    consts.insert(cast<Constant>(kid)->getName(), kid);
+  if (isa<Type>(kid))
+    types.insert(cast<Type>(kid)->getName(), cast<Type>(kid));
+  else if (isa<ConstantValue>(kid))
+    cvals.insert(cast<ConstantValue>(kid)->getName(), cast<ConstantValue>(kid));
+  else if (isa<Linkable>(kid))
+    linkables.insert(cast<Linkable>(kid)->getName(), cast<Linkable>(kid));
   else
     hlvmAssert("Don't know how to insert that in a Bundle");
 }
@@ -59,15 +58,13 @@
 {
   hlvmAssert(isa<Constant>(kid) && "Can't remove that here");
   // This is sucky slow, but we probably won't be removing nodes that much.
-  if (kid->isType()) {
+  if (isa<Type>(kid))
     types.erase(cast<Type>(kid)->getName());
-  } else if (kid->is(VariableID)) {
-    vars.erase(cast<Variable>(kid)->getName());
-  } else if (kid->isFunction()) {
-    funcs.erase(cast<Function>(kid)->getName());
-  } else if (kid->isConstant()) {
-    consts.erase(cast<Constant>(kid)->getName());
-  } else 
+  else if (isa<ConstantValue>(kid))
+    cvals.erase(cast<ConstantValue>(kid)->getName());
+  else if (isa<Linkable>(kid))
+    linkables.erase(cast<Linkable>(kid)->getName());
+  else 
     hlvmAssert(!"That node isn't my child");
 }
 
@@ -79,27 +76,19 @@
   return 0;
 }
 
-Constant*  
-Bundle::find_const(const std::string& name) const
+ConstantValue*  
+Bundle::find_cval(const std::string& name) const
 {
-  if (Node* result = consts.lookup(name))
-    return llvm::cast<Constant>(result);
+  if (Node* result = cvals.lookup(name))
+    return llvm::cast<ConstantValue>(result);
   return 0;
 }
 
-Variable*  
-Bundle::find_var(const std::string& name) const
+Linkable*  
+Bundle::find_linkable(const std::string& name) const
 {
-  if (Node* result = vars.lookup(name))
-    return llvm::cast<Variable>(result);
-  return 0;
-}
-
-Function*  
-Bundle::find_func(const std::string& name) const
-{
-  if (Node* result = funcs.lookup(name))
-    return llvm::cast<Function>(result);
+  if (Node* result = linkables.lookup(name))
+    return llvm::cast<Linkable>(result);
   return 0;
 }
 

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Bundle.h (original)
+++ hlvm/trunk/hlvm/AST/Bundle.h Sat Jul  7 19:01:59 2007
@@ -38,8 +38,7 @@
 { 
 
 class Type;
-class Variable;
-class Function;
+class Linkable;
 
 /// This class is simply a collection of definitions. Things that can be 
 /// defined in a bundle include types, global variables, functions, classes,
@@ -55,27 +54,23 @@
   /// @name Types
   /// @{
   public:
-    typedef SymbolTable TypeList;
+    typedef SymbolTable<Type> TypeList;
     typedef TypeList::iterator type_iterator;
     typedef TypeList::const_iterator type_const_iterator;
 
-    typedef SymbolTable FuncList;
-    typedef FuncList::iterator func_iterator;
-    typedef FuncList::const_iterator func_const_iterator;
-
-    typedef SymbolTable VarList;
-    typedef VarList::iterator var_iterator;
-    typedef VarList::const_iterator var_const_iterator;
-
-    typedef SymbolTable ConstList;
-    typedef ConstList::iterator constant_iterator;
-    typedef ConstList::const_iterator constant_const_iterator;
+    typedef SymbolTable<ConstantValue> CValList;
+    typedef CValList::iterator cval_iterator;
+    typedef CValList::const_iterator cval_const_iterator;
+
+    typedef SymbolTable<Linkable> LinkableList;
+    typedef LinkableList::iterator linkable_iterator;
+    typedef LinkableList::const_iterator linkable_const_iterator;
 
   /// @}
   /// @name Constructors
   /// @{
   protected:
-    Bundle() : Documentable(BundleID), name(), types(), vars(), funcs() {}
+    Bundle() : Documentable(BundleID), name(), types(), linkables() {}
     virtual ~Bundle();
 
   /// @}
@@ -98,10 +93,9 @@
   /// @name Finders
   /// @{
   public:
-    Type*     find_type(const std::string& n) const;
-    Constant* find_const(const std::string& n) const;
-    Variable* find_var(const std::string& n) const;
-    Function* find_func(const std::string& n) const;
+    Type*              find_type(const std::string& n) const;
+    ConstantValue*     find_cval(const std::string& n) const;
+    Linkable*          find_linkable(const std::string& n) const;
 
   /// @}
   /// @name Iterators
@@ -115,39 +109,30 @@
     size_t                  type_size () const { return types.size(); }
     bool                    type_empty() const { return types.empty(); }
 
-    /// Constant iteration
-    constant_iterator       const_begin()       { return consts.begin(); }
-    constant_const_iterator const_begin() const { return consts.begin(); }
-    constant_iterator       const_end  ()       { return consts.end(); }
-    constant_const_iterator const_end  () const { return consts.end(); }
-    size_t                  const_size () const { return consts.size(); }
-    bool                    const_empty() const { return consts.empty(); }
-
-    /// Variable iteration
-    var_iterator            var_begin()       { return vars.begin(); }
-    var_const_iterator      var_begin() const { return vars.begin(); }
-    var_iterator            var_end  ()       { return vars.end(); }
-    var_const_iterator      var_end  () const { return vars.end(); }
-    size_t                  var_size () const { return vars.size(); }
-    bool                    var_empty() const { return vars.empty(); }
-
-    /// Function iteration
-    func_iterator           func_begin()       { return funcs.begin(); }
-    func_const_iterator     func_begin() const { return funcs.begin(); }
-    func_iterator           func_end  ()       { return funcs.end(); }
-    func_const_iterator     func_end  () const { return funcs.end(); }
-    size_t                  func_size () const { return funcs.size(); }
-    bool                    func_empty() const { return funcs.empty(); }
+    /// Type iteration
+    cval_iterator           cval_begin()       { return cvals.begin(); }
+    cval_const_iterator     cval_begin() const { return cvals.begin(); }
+    cval_iterator           cval_end  ()       { return cvals.end(); }
+    cval_const_iterator     cval_end  () const { return cvals.end(); }
+    size_t                  cval_size () const { return cvals.size(); }
+    bool                    cval_empty() const { return cvals.empty(); }
+
+    /// Value iteration
+    linkable_iterator       linkable_begin()       { return linkables.begin(); }
+    linkable_const_iterator linkable_begin() const { return linkables.begin(); }
+    linkable_iterator       linkable_end  ()       { return linkables.end(); }
+    linkable_const_iterator linkable_end  () const { return linkables.end(); }
+    size_t                  linkable_size () const { return linkables.size(); }
+    bool                    linkable_empty() const { return linkables.empty(); }
 
   /// @}
   /// @name Data
   /// @{
   protected:
-    std::string name;   ///< The name for this bundle
-    TypeList    types;  ///< The list of types
-    ConstList   consts; ///< The list of constants
-    VarList     vars;   ///< The list of variables
-    FuncList    funcs;  ///< The list of functions
+    std::string  name;      ///< The name for this bundle
+    TypeList     types;     ///< The list of types
+    CValList     cvals;     ///< The list of constant values
+    LinkableList linkables; ///< The list of linkables
 
   /// @}
   friend class AST;

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Constants.cpp (original)
+++ hlvm/trunk/hlvm/AST/Constants.cpp Sat Jul  7 19:01:59 2007
@@ -33,6 +33,7 @@
 namespace hlvm {
 
 Constant::~Constant() { }
+ConstantValue::~ConstantValue() { }
 ConstantBoolean::~ConstantBoolean() { }
 ConstantInteger::~ConstantInteger() { }
 ConstantReal::~ConstantReal() { }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Constants.h (original)
+++ hlvm/trunk/hlvm/AST/Constants.h Sat Jul  7 19:01:59 2007
@@ -53,15 +53,15 @@
   /// @name Constructors
   /// @{
   protected:
-    Constant(NodeIDs id) : Value(id), name()  {}
+    Constant(NodeIDs id) : Value(id), name() {}
     virtual ~Constant();
 
   /// @}
   /// @name Accessors
   /// @{
   public:
-    // Get the type of the value
-    inline const std::string& getName() const { return name; }
+    /// Get the name of the Constant
+    const std::string& getName() const { return name; }
     static inline bool classof(const Constant*) { return true; }
     static inline bool classof(const Node* N) { return N->isConstant(); }
 
@@ -69,13 +69,38 @@
   /// @name Mutators
   /// @{
   public:
+    /// Set the name of the Constant
     void setName(const std::string& n) { name = n; }
 
   /// @}
   /// @name Data
   /// @{
   protected:
-    std::string name; ///< The name of this Value.
+    std::string name; ///< The name of this value.
+
+  /// @}
+  friend class AST;
+};
+
+/// This is an abstract base class in the Abstract Syntax Tree that represents
+/// a constant value used in the program.
+/// @brief AST Constant Value Node
+class ConstantValue: public Constant
+{
+  /// @name Constructors
+  /// @{
+  protected:
+    ConstantValue(NodeIDs id) : Constant(id) {}
+    virtual ~ConstantValue();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    static inline bool classof(const ConstantValue*) { return true; }
+    static inline bool classof(const Node* N) 
+      { return N->isConstantValue(); }
+
   /// @}
   friend class AST;
 };
@@ -83,12 +108,12 @@
 /// This class provides an Abstract Syntax Tree node that yields a 
 /// constant boolean value. 
 /// @brief AST Constant Boolean Node
-class ConstantBoolean: public Constant
+class ConstantBoolean: public ConstantValue
 {
   /// @name Constructors
   /// @{
   protected:
-    ConstantBoolean(bool val) : Constant(ConstantBooleanID) {
+    ConstantBoolean(bool val) : ConstantValue(ConstantBooleanID) {
       flags = val; }
     virtual ~ConstantBoolean();
 
@@ -110,12 +135,12 @@
 /// constants of any of the signed or unsigned integer types of any bitsize.
 /// @see IntegerType
 /// @brief AST Constant Integer Node
-class ConstantInteger: public Constant
+class ConstantInteger: public ConstantValue
 {
   /// @name Constructors
   /// @{
   protected:
-    ConstantInteger(uint16_t base) : Constant(ConstantIntegerID) {}
+    ConstantInteger(uint16_t base) : ConstantValue(ConstantIntegerID) {}
     virtual ~ConstantInteger();
 
   /// @}
@@ -149,12 +174,12 @@
 /// number value of any mantissa or exponent size. 
 /// @see RealType
 /// @brief AST Constant Real Node
-class ConstantReal : public Constant
+class ConstantReal : public ConstantValue
 {
   /// @name Constructors
   /// @{
   protected:
-    ConstantReal() : Constant(ConstantRealID)  {}
+    ConstantReal() : ConstantValue(ConstantRealID)  {}
     virtual ~ConstantReal();
 
   /// @}
@@ -185,12 +210,12 @@
 /// string value. The constant value is encoded in UTF-8 with a null terminator.
 /// @see StringType
 /// @brief AST Constant String Node
-class ConstantString : public Constant
+class ConstantString : public ConstantValue
 {
   /// @name Constructors
   /// @{
   protected:
-    ConstantString() : Constant(ConstantStringID)  {}
+    ConstantString() : ConstantValue(ConstantStringID)  {}
     virtual ~ConstantString();
 
   /// @}
@@ -222,12 +247,12 @@
 /// such as arrays, vectors, structures and continuations. It simply contains 
 /// a list of other elements which themselves must be constants.
 /// @brief AST Constant Array Node.
-class ConstantAggregate : public Constant
+class ConstantAggregate : public ConstantValue
 {
   /// @name Types
   /// @{
   public:
-    typedef std::vector<Constant*> ElementsList;
+    typedef std::vector<ConstantValue*> ElementsList;
     typedef ElementsList::iterator iterator;
     typedef ElementsList::const_iterator const_iterator;
 
@@ -235,7 +260,7 @@
   /// @name Constructors
   /// @{
   protected:
-    ConstantAggregate() : Constant(ConstantAggregateID), elems()  {}
+    ConstantAggregate() : ConstantValue(ConstantAggregateID), elems()  {}
     virtual ~ConstantAggregate();
 
   /// @}
@@ -257,16 +282,16 @@
   /// @name Iterators
   /// @{
   public:
-    iterator         begin()       { return elems.begin(); }
-    const_iterator   begin() const { return elems.begin(); }
-    iterator         end  ()       { return elems.end(); }
-    const_iterator   end  () const { return elems.end(); }
-    size_t           size () const { return elems.size(); }
-    bool             empty() const { return elems.empty(); }
-    Constant*        front()       { return elems.front(); }
-    const Constant*  front() const { return elems.front(); }
-    Constant*        back()        { return elems.back(); }
-    const Constant*  back()  const { return elems.back(); }
+    iterator             begin()       { return elems.begin(); }
+    const_iterator       begin() const { return elems.begin(); }
+    iterator             end  ()       { return elems.end(); }
+    const_iterator       end  () const { return elems.end(); }
+    size_t               size () const { return elems.size(); }
+    bool                 empty() const { return elems.empty(); }
+    ConstantValue*       front()       { return elems.front(); }
+    const ConstantValue* front() const { return elems.front(); }
+    ConstantValue*       back()        { return elems.back(); }
+    const ConstantValue* back()  const { return elems.back(); }
 
   /// @}
   /// @name Data
@@ -282,12 +307,12 @@
 /// expression. The expression uses a limited set of operator identifiers that
 /// can yield constants such as arithmetic or comparison operators. 
 /// @brief AST Constant Expression Node.
-class ConstantExpression : public Constant
+class ConstantExpression : public ConstantValue
 {
   /// @name Constructors
   /// @{
   protected:
-    ConstantExpression(NodeIDs exprOp) : Constant(ConstantExpressionID)
+    ConstantExpression(NodeIDs exprOp) : ConstantValue(ConstantExpressionID)
       { flags = exprOp; }
     virtual ~ConstantExpression();
   public:

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

==============================================================================
--- hlvm/trunk/hlvm/AST/ControlFlow.cpp (original)
+++ hlvm/trunk/hlvm/AST/ControlFlow.cpp Sat Jul  7 19:01:59 2007
@@ -28,15 +28,32 @@
 //===----------------------------------------------------------------------===//
 
 #include <hlvm/AST/ControlFlow.h>
+#include <hlvm/AST/MemoryOps.h>
+#include <hlvm/AST/Linkables.h>
+#include <hlvm/Base/Assert.h>
+#include <llvm/Support/Casting.h>
+
+using namespace llvm;
 
 namespace hlvm {
 
-NoOperator::~NoOperator() {}
+NullOp::~NullOp() {}
 SelectOp::~SelectOp() {}
 SwitchOp::~SwitchOp() {}
 LoopOp::~LoopOp() {}
 ReturnOp::~ReturnOp() { }
 BreakOp::~BreakOp() {}
 ContinueOp::~ContinueOp() {}
+CallOp::~CallOp() {}
+
+Function* 
+CallOp::getCalledFunction() const
+{
+  hlvmAssert(isa<ReferenceOp>(getOperand(0)));
+  ReferenceOp* refop = cast<ReferenceOp>(getOperand(0));
+  const Value* referent = refop->getReferent();
+  hlvmAssert(isa<Function>(referent));
+  return const_cast<Function*>(cast<Function>(referent));
+}
 
 }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/ControlFlow.h (original)
+++ hlvm/trunk/hlvm/AST/ControlFlow.h Sat Jul  7 19:01:59 2007
@@ -38,20 +38,20 @@
 /// This class provides an Abstract Syntax Tree node for the "noop" operator
 /// that does nothing.
 /// @brief AST NoOp Operator
-class NoOperator : public NilaryOperator
+class NullOp : public NilaryOperator
 {
   /// @name Constructors
   /// @{
   protected:
-    NoOperator() : NilaryOperator(NoOperatorID) {}
-    virtual ~NoOperator();
+    NullOp() : NilaryOperator(NullOpID) {}
+    virtual ~NullOp();
 
   /// @}
   /// @name Accessors
   /// @{
   public:
-    static inline bool classof(const NoOperator*) { return true; }
-    static inline bool classof(const Node* N) { return N->is(NoOperatorID); }
+    static inline bool classof(const NullOp*) { return true; }
+    static inline bool classof(const Node* N) { return N->is(NullOpID); }
 
   /// @}
   friend class AST;
@@ -234,6 +234,34 @@
   friend class AST;
 };
 
+/// This class provides an Abstract Syntax Tree node that represents a function
+/// call operator. A CallOp invokes a function, possibly passing it arguments,
+/// and obtains the result of that function. The value of the CallOp becomes the
+/// result of the called function. 
+/// @brief AST Call Operator Node
+class CallOp : public MultiOperator
+{
+  /// @name Constructors
+  /// @{
+  public:
+    static CallOp* create();
+
+  protected:
+    CallOp() : MultiOperator(CallOpID)  {}
+    virtual ~CallOp();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    Function* getCalledFunction() const;
+    static inline bool classof(const CallOp*) { return true; }
+    static inline bool classof(const Node* N) { return N->is(CallOpID); }
+
+  /// @}
+  friend class AST;
+};
+
 } // end hlvm namespace
 
 #endif

Copied: hlvm/trunk/hlvm/AST/Linkables.cpp (from r38279, hlvm/trunk/hlvm/AST/LinkageItems.cpp)
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Linkables.cpp?p2=hlvm/trunk/hlvm/AST/Linkables.cpp&p1=hlvm/trunk/hlvm/AST/LinkageItems.cpp&r1=38279&r2=38290&rev=38290&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItems.cpp (original)
+++ hlvm/trunk/hlvm/AST/Linkables.cpp Sat Jul  7 19:01:59 2007
@@ -1,4 +1,4 @@
-//===-- AST Linkage Items Implementation ------------------------*- C++ -*-===//
+//===-- AST Linkables Implementation ----------------------------*- C++ -*-===//
 //
 //                      High Level Virtual Machine (HLVM)
 //
@@ -20,14 +20,14 @@
 // MA 02110-1301 USA
 //
 //===----------------------------------------------------------------------===//
-/// @file hlvm/AST/LinkageItems.cpp
+/// @file hlvm/AST/Linkables.cpp
 /// @author Reid Spencer <rspencer at reidspencer.com> (original author)
 /// @date 2006/05/04
 /// @since 0.1.0
-/// @brief Implements the subclasses of LinkageItem
+/// @brief Implements the subclasses of Linkable
 //===----------------------------------------------------------------------===//
 
-#include <hlvm/AST/LinkageItems.h>
+#include <hlvm/AST/Linkables.h>
 #include <hlvm/AST/Block.h>
 #include <hlvm/Base/Assert.h>
 #include <llvm/Support/Casting.h>
@@ -36,7 +36,7 @@
 
 namespace hlvm {
 
-LinkageItem::~LinkageItem() { }
+Linkable::~Linkable() { }
 Variable::~Variable() { }
 Function::~Function() { }
 Program::~Program() { }

Copied: hlvm/trunk/hlvm/AST/Linkables.h (from r38279, hlvm/trunk/hlvm/AST/LinkageItems.h)
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Linkables.h?p2=hlvm/trunk/hlvm/AST/Linkables.h&p1=hlvm/trunk/hlvm/AST/LinkageItems.h&r1=38279&r2=38290&rev=38290&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItems.h (original)
+++ hlvm/trunk/hlvm/AST/Linkables.h Sat Jul  7 19:01:59 2007
@@ -1,4 +1,4 @@
-//===-- AST Linkage Items Interface -----------------------------*- C++ -*-===//
+//===-- AST Linkables Interface ---------------------------------*- C++ -*-===//
 //
 //                      High Level Virtual Machine (HLVM)
 //
@@ -20,15 +20,15 @@
 // MA 02110-1301 USA
 //
 //===----------------------------------------------------------------------===//
-/// @file hlvm/AST/LinkageItems.h
+/// @file hlvm/AST/Linkables.h
 /// @author Reid Spencer <rspencer at reidspencer.com> (original author)
 /// @date 2006/06/10
 /// @since 0.1.0
-/// @brief Declares the interface to all subclasses of LinkageItem
+/// @brief Declares the interface to all subclasses of Linkable
 //===----------------------------------------------------------------------===//
 
-#ifndef HLVM_AST_LINKAGEITEMS_H
-#define HLVM_AST_LINKAGEITEMS_H
+#ifndef HLVM_AST_LINKABLE_H
+#define HLVM_AST_LINKABLE_H
 
 #include <hlvm/AST/Constants.h>
 #include <hlvm/AST/ContainerType.h>
@@ -41,7 +41,7 @@
 class Constant;
 
 /// This enumeration is used to specify the kinds of linkage that are
-/// permitted for a LinkageItem.
+/// permitted for a Linkable.
 /// @brief Enumeration of ways to link bundles
 enum LinkageKinds {
   ExternalLinkage   = 1, ///< Externally visible item
@@ -52,25 +52,25 @@
 };
 
 /// This class provides an Abstract Syntax Tree node that represents an item
-/// which can be linked with other Bundles. LinkageItem is an abstract base 
-/// class and cannot be instantiated. All LinkageItem's are Constant values
+/// which can be linked with other Bundles. Linkabe is an abstract base 
+/// class and cannot be instantiated. All Linkables are Constant values
 /// because they represents a runtime value that is a constant address. The
-/// value pointed to by the LinkageItem may be mutable or immutable depending
-/// on its type and options.  As the name suggests, LinkageItems participate
+/// value pointed to by the Linkable may be mutable or immutable depending
+/// on its type and options.  As the name suggests, Linkables participate
 /// in linkage. A Bundle referring to a name in another Bundle will only link
-/// with a LinkageItem and nothing else. There are several ways in which 
-/// LinkageItems can be linked together, specified by the LinkageKinds value.
+/// with a Linkable and nothing else. There are several ways in which 
+/// Linkables can be linked together, specified by the LinkageKinds value.
 /// @see LinkageKinds
 /// @see Bundle
 /// @see Constant
 /// @brief AST Bundle Node
-class LinkageItem : public Constant
+class Linkable : public Constant
 {
   /// @name Constructors
   /// @{
   protected:
-    LinkageItem( NodeIDs id ) : Constant(id) { setLinkageKind(InternalLinkage);}
-    virtual ~LinkageItem();
+    Linkable( NodeIDs id ) : Constant(id) { setLinkageKind(InternalLinkage);}
+    virtual ~Linkable();
 
   /// @}
   /// @name Accessors
@@ -78,8 +78,8 @@
   public:
     inline LinkageKinds getLinkageKind() const { 
       return LinkageKinds(flags & 0x0007); }
-    static inline bool classof(const LinkageItem*) { return true; }
-    static inline bool classof(const Node* N) { return N->isLinkageItem(); }
+    static inline bool classof(const Linkable*) { return true; }
+    static inline bool classof(const Node* N) { return N->isLinkable(); }
 
   /// @}
   /// @name Mutators
@@ -99,15 +99,15 @@
 /// location, with an address, of a specific type. Global variables may have
 /// a constant value in which case HLVM will ensure that the value of the
 /// global variable is immutable. Variables can be of any type except VoidType.
-/// @see LinkageItem
+/// @see Linkable
 /// @see Bundle
 /// @brief AST Variable Node
-class Variable : public LinkageItem
+class Variable : public Linkable
 {
   /// @name Constructors
   /// @{
   protected:
-    Variable() : LinkageItem(VariableID), init(0) {}
+    Variable() : Linkable(VariableID), init(0) {}
     virtual ~Variable();
 
   /// @}
@@ -115,7 +115,7 @@
   /// @{
   public:
     bool isConstant() const { return flags & 0x0008; }
-    Constant* getInitializer() const { return init; }
+    ConstantValue* getInitializer() const { return init; }
     bool hasInitializer() const { return init != 0; }
     bool isZeroInitialized() const { return init == 0; }
     static inline bool classof(const Variable*) { return true; }
@@ -126,13 +126,13 @@
   /// @{
   public:
     void setIsConstant(bool v) { flags |= 0x0008; }
-    void setInitializer(Constant* C) { init = C; }
+    void setInitializer(ConstantValue* C) { init = C; }
 
   /// @}
   /// @name Data
   /// @{
   protected:
-    Constant* init;
+    ConstantValue* init;
   /// @}
   friend class AST;
 };
@@ -152,12 +152,12 @@
 /// @see Bundle
 /// @see SignatureType
 /// @brief AST Function Node
-class Function : public LinkageItem
+class Function : public Linkable
 {
   /// @name Constructors
   /// @{
   protected:
-    Function(NodeIDs id = FunctionID) : LinkageItem(id), block(0) {}
+    Function(NodeIDs id = FunctionID) : Linkable(id), block(0) {}
     virtual ~Function();
 
   /// @}
@@ -220,7 +220,7 @@
   /// @name Data
   /// @{
   private:
-    LinkageItem::setLinkageKind;
+    Linkable::setLinkageKind;
   /// @}
   friend class AST;
 };

Removed: hlvm/trunk/hlvm/AST/LinkageItems.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/LinkageItems.cpp?rev=38289&view=auto

==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItems.cpp (original)
+++ hlvm/trunk/hlvm/AST/LinkageItems.cpp (removed)
@@ -1,72 +0,0 @@
-//===-- AST Linkage Items Implementation ------------------------*- C++ -*-===//
-//
-//                      High Level Virtual Machine (HLVM)
-//
-// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
-//
-// This software is free software; you can redistribute it and/or modify it 
-// under the terms of the GNU Lesser General Public License as published by 
-// the Free Software Foundation; either version 2.1 of the License, or (at 
-// your option) any later version.
-//
-// This software 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 Lesser General Public License for 
-// more details.
-//
-// You should have received a copy of the GNU Lesser General Public License 
-// along with this library in the file named LICENSE.txt; if not, write to the 
-// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
-// MA 02110-1301 USA
-//
-//===----------------------------------------------------------------------===//
-/// @file hlvm/AST/LinkageItems.cpp
-/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
-/// @date 2006/05/04
-/// @since 0.1.0
-/// @brief Implements the subclasses of LinkageItem
-//===----------------------------------------------------------------------===//
-
-#include <hlvm/AST/LinkageItems.h>
-#include <hlvm/AST/Block.h>
-#include <hlvm/Base/Assert.h>
-#include <llvm/Support/Casting.h>
-
-using namespace llvm;
-
-namespace hlvm {
-
-LinkageItem::~LinkageItem() { }
-Variable::~Variable() { }
-Function::~Function() { }
-Program::~Program() { }
-
-const SignatureType* 
-Function::getSignature() const
-{ 
-  return cast<SignatureType>(type); 
-}
-
-void 
-Function::insertChild(Node* kid)
-{
-  if (isa<Block>(kid)) {
-    if (block)
-      block->setParent(0);
-    block = cast<Block>(kid);
-  } else {
-    hlvmAssert(!"Can't insert one of those here");
-  }
-}
-
-void 
-Function::removeChild(Node* kid)
-{
-  if (isa<Block>(kid) && kid == block) {
-    block = 0;
-  } else {
-    hlvmAssert(!"Can't remove one of those here");
-  }
-}
-
-}

Removed: hlvm/trunk/hlvm/AST/LinkageItems.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/LinkageItems.h?rev=38289&view=auto

==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItems.h (original)
+++ hlvm/trunk/hlvm/AST/LinkageItems.h (removed)
@@ -1,229 +0,0 @@
-//===-- AST Linkage Items Interface -----------------------------*- C++ -*-===//
-//
-//                      High Level Virtual Machine (HLVM)
-//
-// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
-//
-// This software is free software; you can redistribute it and/or modify it 
-// under the terms of the GNU Lesser General Public License as published by 
-// the Free Software Foundation; either version 2.1 of the License, or (at 
-// your option) any later version.
-//
-// This software 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 Lesser General Public License for 
-// more details.
-//
-// You should have received a copy of the GNU Lesser General Public License 
-// along with this library in the file named LICENSE.txt; if not, write to the 
-// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
-// MA 02110-1301 USA
-//
-//===----------------------------------------------------------------------===//
-/// @file hlvm/AST/LinkageItems.h
-/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
-/// @date 2006/06/10
-/// @since 0.1.0
-/// @brief Declares the interface to all subclasses of LinkageItem
-//===----------------------------------------------------------------------===//
-
-#ifndef HLVM_AST_LINKAGEITEMS_H
-#define HLVM_AST_LINKAGEITEMS_H
-
-#include <hlvm/AST/Constants.h>
-#include <hlvm/AST/ContainerType.h>
-#include <hlvm/AST/Block.h>
-
-namespace hlvm 
-{
-
-class Type; // Forward declare
-class Constant;
-
-/// This enumeration is used to specify the kinds of linkage that are
-/// permitted for a LinkageItem.
-/// @brief Enumeration of ways to link bundles
-enum LinkageKinds {
-  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
-/// which can be linked with other Bundles. LinkageItem is an abstract base 
-/// class and cannot be instantiated. All LinkageItem's are Constant values
-/// because they represents a runtime value that is a constant address. The
-/// value pointed to by the LinkageItem may be mutable or immutable depending
-/// on its type and options.  As the name suggests, LinkageItems participate
-/// in linkage. A Bundle referring to a name in another Bundle will only link
-/// with a LinkageItem and nothing else. There are several ways in which 
-/// LinkageItems can be linked together, specified by the LinkageKinds value.
-/// @see LinkageKinds
-/// @see Bundle
-/// @see Constant
-/// @brief AST Bundle Node
-class LinkageItem : public Constant
-{
-  /// @name Constructors
-  /// @{
-  protected:
-    LinkageItem( NodeIDs id ) : Constant(id) { setLinkageKind(InternalLinkage);}
-    virtual ~LinkageItem();
-
-  /// @}
-  /// @name Accessors
-  /// @{
-  public:
-    inline LinkageKinds getLinkageKind() const { 
-      return LinkageKinds(flags & 0x0007); }
-    static inline bool classof(const LinkageItem*) { return true; }
-    static inline bool classof(const Node* N) { return N->isLinkageItem(); }
-
-  /// @}
-  /// @name Mutators
-  /// @{
-    void setLinkageKind(LinkageKinds k) { 
-      flags &= 0xFFF8; flags |= uint16_t(k); 
-    }
-
-  /// @}
-  friend class AST;
-};
-
-/// This class provides an Abstract Syntax Tree node that represents a 
-/// global Variable.  A Variable can only be declared as a component of a 
-/// Bundle. It is visible throughout the Bundle that declares it and may 
-/// be a candidate for linkage with other Bundles. A Variable is a storage 
-/// location, with an address, of a specific type. Global variables may have
-/// a constant value in which case HLVM will ensure that the value of the
-/// global variable is immutable. Variables can be of any type except VoidType.
-/// @see LinkageItem
-/// @see Bundle
-/// @brief AST Variable Node
-class Variable : public LinkageItem
-{
-  /// @name Constructors
-  /// @{
-  protected:
-    Variable() : LinkageItem(VariableID), init(0) {}
-    virtual ~Variable();
-
-  /// @}
-  /// @name Accessors
-  /// @{
-  public:
-    bool isConstant() const { return flags & 0x0008; }
-    Constant* getInitializer() const { return init; }
-    bool hasInitializer() const { return init != 0; }
-    bool isZeroInitialized() const { return init == 0; }
-    static inline bool classof(const Variable*) { return true; }
-    static inline bool classof(const Node* N) { return N->is(VariableID); }
-
-  /// @}
-  /// @name Mutators
-  /// @{
-  public:
-    void setIsConstant(bool v) { flags |= 0x0008; }
-    void setInitializer(Constant* C) { init = C; }
-
-  /// @}
-  /// @name Data
-  /// @{
-  protected:
-    Constant* init;
-  /// @}
-  friend class AST;
-};
-
-/// This class provides an Abstract Syntax Tree node that represents a Function.
-/// A Function is a callable block of code that accepts parameters and 
-/// 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, optionally, a 
-/// Block of code to execute. The name of a function is used for linking 
-/// purposes. The formal arguments and return type are encapsulated in the
-/// Function's associated SignatureType. If a Block is associated with the
-/// Function then the function is defined and the Block defines the computation
-/// the Function provides. If a Block is not associated with the Function, then
-/// the function is undefined and serves as a reference to a function in another
-/// Bundle.
-/// @see Block
-/// @see Bundle
-/// @see SignatureType
-/// @brief AST Function Node
-class Function : public LinkageItem
-{
-  /// @name Constructors
-  /// @{
-  protected:
-    Function(NodeIDs id = FunctionID) : LinkageItem(id), block(0) {}
-    virtual ~Function();
-
-  /// @}
-  /// @name Accessors
-  /// @{
-  public:
-    Block* getBlock() const { return block; }
-    const SignatureType* getSignature() const;
-    static inline bool classof(const Function*) { return true; }
-    static inline bool classof(const Node* N) { return N->isFunction(); }
-
-  /// @}
-  /// @name Mutators
-  /// @{
-  public:
-    virtual void insertChild(Node* kid);
-    virtual void removeChild(Node* kid);
-    void setSignature(SignatureType* sig) { type = sig; }
-    void setBlock(Block* blk) { blk->setParent(this); }
-
-  /// @}
-  /// @name Data
-  /// @{
-  protected:
-    Block * block;                   ///< The code block to be executed
-  /// @}
-  friend class AST;
-};
-
-class Block; // Forward declare
-class SignatureType;  // Forward declare
-
-/// This class provides an Abstract Syntax Tree node that represents a Program 
-/// in HLVM. A Program is an entry point for running HLVM programs. It is 
-/// simply a Function with a specific signature. It represents the first
-/// function to be executed by the runtime after option processing.  To be
-/// executable, a Bundle must have at least one Program node in it. 
-/// The Program node exists to simply ensure that the signature of the function
-/// is correct and to serve as a way to identify Program's quickly.
-/// @see Function
-/// @see Bundle
-/// @see SignatureType
-/// @brief AST Program Node
-class Program : public Function
-{
-  /// @name Constructors
-  /// @{
-  protected:
-    Program() : Function(ProgramID) {}
-    virtual ~Program();
-
-  /// @}
-  /// @name Accessors
-  /// @{
-  public:
-    static inline bool classof(const Program*) { return true; }
-    static inline bool classof(const Node* N) { return N->is(ProgramID); }
-
-  /// @}
-  /// @name Data
-  /// @{
-  private:
-    LinkageItem::setLinkageKind;
-  /// @}
-  friend class AST;
-};
-
-} // end hlvm namespace
-#endif

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

==============================================================================
--- hlvm/trunk/hlvm/AST/MemoryOps.cpp (original)
+++ hlvm/trunk/hlvm/AST/MemoryOps.cpp Sat Jul  7 19:01:59 2007
@@ -35,7 +35,6 @@
 StoreOp::~StoreOp() {}
 AutoVarOp::~AutoVarOp() {}
 ReferenceOp::~ReferenceOp() {}
-ConstantReferenceOp::~ConstantReferenceOp() {}
 IndexOp::~IndexOp() {}
 
 }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/MemoryOps.h (original)
+++ hlvm/trunk/hlvm/AST/MemoryOps.h Sat Jul  7 19:01:59 2007
@@ -31,12 +31,14 @@
 #define HLVM_AST_MEMORYOPS_H
 
 #include <hlvm/AST/Operator.h>
-#include <hlvm/AST/Constants.h>
 
 namespace hlvm
 {
 
 class Variable;
+class Constant;
+class ConstantValue;
+class Function;
 
 /// This class provides an Abstract Syntax Tree node that represents an operator
 /// for allocating memory from the heap. The type of this operator indicates the
@@ -165,7 +167,7 @@
 /// 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
+/// Automatic variables are not Linkables 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
@@ -185,7 +187,7 @@
   public:
     const std::string& getName() const { return name; }
     bool hasInitializer() const { return initializer != 0; }
-    Constant* getInitializer() const { return initializer; }
+    ConstantValue* getInitializer() const { return initializer; }
     bool isZeroInitialized() const { return initializer == 0; }
     static inline bool classof(const AutoVarOp*) { return true; }
     static inline bool classof(const Node* N) { return N->is(AutoVarOpID); }
@@ -195,26 +197,26 @@
   /// @{
   public:
     void setName(const std::string& n) { name = n; }
-    void setInitializer(Constant* C) { initializer = C; }
+    void setInitializer(ConstantValue* C) { initializer = C; }
 
   /// @}
   /// @name Data
   /// @{
   protected:
     std::string name;
-    Constant* initializer;
+    ConstantValue* initializer;
   /// @}
   friend class AST;
 };
 
 /// 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
+/// for obtaining a value. The operator has no operands but has a property 
+/// that is the Value to be referenced. The Value must be an AutoVarOp or one
+/// of the Linkable (Variable, Constant, Function).  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
+/// @see Variable AutoVarOp Operator Value Linkable LoadOp StoreOp
 /// @brief AST Reference Operator
 class ReferenceOp : public NilaryOperator
 {
@@ -230,7 +232,9 @@
   public:
     const Value* getReferent() const { return referent; }
     static inline bool classof(const ReferenceOp*) { return true; }
-    static inline bool classof(const Node* N) { return N->is(ReferenceOpID); }
+    static inline bool classof(const Node* N) { 
+      return N->is(ReferenceOpID); 
+    }
 
   /// @}
   /// @name Mutators
@@ -248,47 +252,6 @@
 };
 
 /// This class provides an Abstract Syntax Tree node that represents an operator
-/// for obtaining the value of a named constant.  The operator has no operands
-/// but has a property that is the Constant to be referenced. It is presumed 
-/// This operator bridges between non-operator Constants and Operators. The 
-/// result of this operator is the value of the constnat. Typically this 
-/// operator is used as the operand of some other operator to introduce the
-/// value of a constant.
-/// @see Reference Constant Operator Value
-/// @brief AST ConstantReference Operator
-class ConstantReferenceOp : public NilaryOperator
-{
-  /// @name Constructors
-  /// @{
-  protected:
-    ConstantReferenceOp() : NilaryOperator(ConstantReferenceOpID) {}
-    virtual ~ConstantReferenceOp();
-
-  /// @}
-  /// @name Accessors
-  /// @{
-  public:
-    const Constant* getReferent() const { return referent; }
-    static inline bool classof(const ConstantReferenceOp*) { return true; }
-    static inline bool classof(const Node* N) { 
-      return N->is(ConstantReferenceOpID); }
-
-  /// @}
-  /// @name Mutators
-  /// @{
-  public:
-    void setReferent(const Constant* ref) { referent = ref; }
-
-  /// @}
-  /// @name Data
-  /// @{
-  protected:
-    const Constant* referent;
-  /// @}
-  friend class AST;
-};
-
-/// 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

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Node.h (original)
+++ hlvm/trunk/hlvm/AST/Node.h Sat Jul  7 19:01:59 2007
@@ -134,19 +134,20 @@
   ConstantBooleanID,       ///< A constant boolean value
 FirstValueID = ConstantBooleanID,
 FirstConstantID = ConstantBooleanID,
+FirstConstantValueID = ConstantBooleanID,
   ConstantIntegerID,       ///< A constant integer value
   ConstantRealID,          ///< A constant real value
   ConstantStringID,        ///< A constant string value
   ConstantAggregateID,     ///< A constant aggregate for arrays, structures, etc
   ConstantExpressionID,    ///< A constant expression
-  SizeOfID,                ///< Size of a type
+LastConstantValueID = ConstantExpressionID,
 
   // Linkage Items
   VariableID,              ///< The Variable Node (a storage location)
-FirstLinkageItemID = VariableID,
+FirstLinkableID = VariableID,
   FunctionID,              ///< The Function Node (a callable function)
   ProgramID,               ///< The Program Node (a program starting point)
-LastLinkageItemID = ProgramID,
+LastLinkableID = ProgramID,
 LastConstantID = ProgramID,
 
   // Operator
@@ -160,13 +161,12 @@
   PInfOpID,                ///< Constant Positive Infinity Real Value
   NInfOpID,                ///< Constant Negative Infinity Real Value
   NaNOpID,                 ///< Constant Not-A-Number Real Value
-  ReferenceOpID,           ///< Obtain pointer to local/global variable
-  ConstantReferenceOpID,   ///< Obtain pointer to local/global variable
-LastNilaryOperatorID = ConstantReferenceOpID,
+  ReferenceOpID,           ///< Obtain value of Variable/Function/Constant
+LastNilaryOperatorID = ReferenceOpID,
 
   // Control Flow Unary Operators
-  NoOperatorID,            ///< The "do nothing" NoOp Operators
-FirstUnaryOperatorID = NoOperatorID,
+  NullOpID,                ///< The "do nothing" NullOp (no-op) Operator
+FirstUnaryOperatorID = NullOpID,
   ReturnOpID,              ///< The Return A Value Operator
   ThrowOpID,               ///< The Throw an Exception Operator
 
@@ -178,6 +178,7 @@
   PostIncrOpID,            ///< Post-Increment Unary Integer Operator
   PreDecrOpID,             ///< Pre-Decrement Unary Integer Operator
   PostDecrOpID,            ///< Post-Decrement Unary Integer Operator
+  SizeOfID,                ///< Size of a constant
 
   // Real Arithmetic Unary Operators
   IsPInfOpID,              ///< Real Number Positive Infinity Test Operator
@@ -365,9 +366,13 @@
     inline bool isConstant() const {
       return id >= FirstConstantID && id <= LastConstantID; }
 
-    /// Determine if the node is a LinkageItem
-    inline bool isLinkageItem() const {
-      return id >= FirstLinkageItemID && id <= LastLinkageItemID; }
+    /// Determine if the node is one of the Constant values.
+    inline bool isConstantValue() const {
+      return id >= FirstConstantValueID && id <= LastConstantValueID; }
+
+    /// Determine if the node is a Linkable
+    inline bool isLinkable() const {
+      return id >= FirstLinkableID && id <= LastLinkableID; }
 
     /// Determine if the node is any of the Operators
     inline bool isOperator() const { 
@@ -518,12 +523,11 @@
 };
 
 /// 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.
+/// that have a value at runtime. Every Value has a Type. All Operators, and
+/// Linkables are Values.
 /// @see Type
-/// @see LinkageItem
+/// @see Linkable
 /// @see Operator
-/// @see Constant
 /// @brief AST Value Node
 class Value : public Documentable
 {
@@ -559,5 +563,6 @@
   friend class AST;
 };
 
-} // hlvm
+
+} // 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=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.cpp (original)
+++ hlvm/trunk/hlvm/AST/Operator.cpp Sat Jul  7 19:01:59 2007
@@ -28,7 +28,7 @@
 //===----------------------------------------------------------------------===//
 
 #include <hlvm/AST/Operator.h>
-#include <hlvm/AST/LinkageItems.h>
+#include <hlvm/AST/Linkables.h>
 #include <hlvm/Base/Assert.h>
 #include <llvm/Support/Casting.h>
 

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

==============================================================================
--- hlvm/trunk/hlvm/AST/SymbolTable.cpp (original)
+++ hlvm/trunk/hlvm/AST/SymbolTable.cpp Sat Jul  7 19:01:59 2007
@@ -28,15 +28,18 @@
 //===----------------------------------------------------------------------===//
 
 #include "hlvm/AST/SymbolTable.h"
+#include "hlvm/AST/Type.h"
+#include "hlvm/AST/Linkables.h"
 #include "hlvm/Base/Assert.h"
 #include "llvm/ADT/StringExtras.h"
 #include <iostream>
 #include <algorithm>
 
-using namespace hlvm;
+namespace hlvm {
 
+template<class ElemType>
 std::string 
-SymbolTable::getUniqueName(const std::string &base_name) const {
+SymbolTable<ElemType>::getUniqueName(const std::string &base_name) const {
   std::string try_name = base_name;
   const_iterator end = map_.end();
 
@@ -49,15 +52,17 @@
 }
 
 // lookup a node by name - returns null on failure
-Node* SymbolTable::lookup(const std::string& name) const {
+template<class ElemType>
+ElemType* SymbolTable<ElemType>::lookup(const std::string& name) const {
   const_iterator TI = map_.find(name);
   if (TI != map_.end())
-    return const_cast<Node*>(TI->second);
+    return const_cast<ElemType*>(TI->second);
   return 0;
 }
 
 // Erase a specific type from the symbol table
-bool SymbolTable::erase(Node *N) {
+template<class ElemType>
+bool SymbolTable<ElemType>::erase(ElemType *N) {
   for (iterator TI = map_.begin(), TE = map_.end(); TI != TE; ++TI) {
     if (TI->second == N) {
       this->erase(TI);
@@ -68,15 +73,17 @@
 }
 
 // remove - Remove a node from the symbol table...
-Node* SymbolTable::erase(iterator Entry) {
+template<class ElemType>
+ElemType* SymbolTable<ElemType>::erase(iterator Entry) {
   hlvmAssert(Entry != map_.end() && "Invalid entry to remove!");
-  const Node* Result = Entry->second;
+  const ElemType* Result = Entry->second;
   map_.erase(Entry);
-  return const_cast<Node*>(Result);
+  return const_cast<ElemType*>(Result);
 }
 
 // insert - Insert a node into the symbol table with the specified name...
-void SymbolTable::insert(const std::string& Name, const Node* N) {
+template<class ElemType>
+void SymbolTable<ElemType>::insert(const std::string& Name, const ElemType* N) {
   hlvmAssert(N && "Can't insert null node into symbol table!");
 
   // Check to see if there is a naming conflict.  If so, rename this type!
@@ -93,7 +100,8 @@
 /// doing "remove(V), V->Name = Name, insert(V)", but is faster, and will not
 /// temporarily remove the symbol table plane if V is the last value in the
 /// symtab with that name (which could invalidate iterators to that plane).
-bool SymbolTable::rename(Node *N, const std::string &name) {
+template<class ElemType>
+bool SymbolTable<ElemType>::rename(ElemType *N, const std::string &name) {
   for (iterator NI = map_.begin(), NE = map_.end(); NI != NE; ++NI) {
     if (NI->second == N) {
       // Remove the old entry.
@@ -105,3 +113,10 @@
   }
   return false;
 }
+
+// instantiate for Types and Linkabes
+template class SymbolTable<Type>;
+template class SymbolTable<ConstantValue>;
+template class SymbolTable<Linkable>;
+
+}

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

==============================================================================
--- hlvm/trunk/hlvm/AST/SymbolTable.h (original)
+++ hlvm/trunk/hlvm/AST/SymbolTable.h Sat Jul  7 19:01:59 2007
@@ -30,7 +30,6 @@
 #ifndef HLVM_AST_SYMBOLTABLE_H
 #define HLVM_AST_SYMBOLTABLE_H
 
-#include <hlvm/AST/Node.h>
 #include <map>
 
 namespace hlvm 
@@ -38,19 +37,20 @@
 
 /// This class provides a symbol table of name/node pairs with operations to
 /// support constructing, searching and iterating over the symbol table.
+template<class ElemType>
 class SymbolTable
 {
 /// @name Types
 /// @{
 public:
   /// @brief A mapping of names to nodes.
-  typedef std::map<const std::string, const Node*> NodeMap;
+  typedef typename std::map<const std::string, const ElemType*> NodeMap;
 
   /// @brief An iterator over the NodeMap.
-  typedef NodeMap::iterator iterator;
+  typedef typename NodeMap::iterator iterator;
 
   /// @brief A const_iterator over the NodeMap.
-  typedef NodeMap::const_iterator const_iterator;
+  typedef typename NodeMap::const_iterator const_iterator;
 
 /// @}
 /// @name Constructors
@@ -71,10 +71,10 @@
 
   /// This method finds the node with the given \p name in the node map
   /// and returns it.
-  /// @returns null if the name is not found, otherwise the Node
+  /// @returns null if the name is not found, otherwise the ElemType
   /// associated with the \p name.
   /// @brief Lookup a node by name.
-  Node* lookup(const std::string& name) const;
+  ElemType* lookup(const std::string& name) const;
 
   /// @returns true iff the symbol table is empty.
   /// @brief Determine if the symbol table is empty
@@ -108,24 +108,24 @@
   /// be a many-to-one mapping between names and nodes. This method allows a 
   /// node with an existing entry in the symbol table to get a new name.
   /// @brief Insert a node under a new name.
-  void insert(const std::string &Name, const Node *N);
+  void insert(const std::string &Name, const ElemType *N);
 
   /// Remove a node at the specified position in the symbol table.
-  /// @returns the removed Node.
-  /// @returns the Node that was erased from the symbol table.
-  Node* erase(iterator TI);
+  /// @returns the removed ElemType.
+  /// @returns the ElemType that was erased from the symbol table.
+  ElemType* erase(iterator TI);
 
   /// Remove a node using a specific key
   bool erase(const std::string& name) { return map_.erase(name) > 0; }
 
-  /// Remove a specific Node from the symbol table. This isn't fast, linear
+  /// Remove a specific ElemType from the symbol table. This isn't fast, linear
   /// search, O(n), algorithm.
   /// @returns true if the erase was successful (TI was found)
-  bool erase(Node* TI);
+  bool erase(ElemType* TI);
 
   /// Rename a node. This ain't fast, we have to linearly search for it first.
   /// @returns true if the rename was successful (node was found)
-  bool rename(Node* T, const std::string& new_name);
+  bool rename(ElemType* T, const std::string& new_name);
 
 /// @}
 /// @name Internal Data

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

==============================================================================
--- hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp (original)
+++ hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp Sat Jul  7 19:01:59 2007
@@ -32,7 +32,7 @@
 #include <hlvm/AST/Bundle.h>
 #include <hlvm/AST/Documentation.h>
 #include <hlvm/AST/ContainerType.h>
-#include <hlvm/AST/LinkageItems.h>
+#include <hlvm/AST/Linkables.h>
 #include <hlvm/AST/ControlFlow.h>
 #include <hlvm/AST/MemoryOps.h>
 #include <hlvm/AST/InputOutput.h>
@@ -77,7 +77,8 @@
   typedef std::vector<llvm::Value*> OperandList;
   typedef std::map<hlvm::Variable*,llvm::Value*> VariableDictionary;
   typedef std::map<hlvm::AutoVarOp*,llvm::Value*> AutoVarDictionary;
-  typedef std::map<hlvm::Constant*,llvm::Constant*> ConstantDictionary;
+  typedef std::map<hlvm::ConstantValue*,llvm::Constant*> ConstantDictionary;
+  typedef std::map<hlvm::Function*,llvm::Function*> FunctionDictionary;
   ModuleList modules;        ///< The list of modules we construct
   llvm::Module*     lmod;    ///< The current module we're generation 
   llvm::Function*   lfunc;   ///< The current LLVM function we're generating 
@@ -88,6 +89,7 @@
   AutoVarDictionary lvars;
   llvm::TypeSymbolTable ltypes; ///< The cached LLVM types we've generated
   ConstantDictionary consts; ///< The cached LLVM constants we've generated
+  FunctionDictionary funcs;  ///< The cached LLVM constants we've generated
     ///< The current LLVM instructions we're generating
   const AST* ast;            ///< The current Tree we're traversing
   const Bundle* bundle;      ///< The current Bundle we're traversing
@@ -131,10 +133,10 @@
 
   /// Conversion functions
   const llvm::Type* getType(const hlvm::Type* ty);
-  llvm::Constant* getConstant(const hlvm::Constant* C);
+  llvm::Constant* getConstant(const hlvm::ConstantValue* C);
   llvm::Value* getVariable(const hlvm::Variable* V);
   inline llvm::GlobalValue::LinkageTypes getLinkageTypes(LinkageKinds lk);
-  inline std::string getLinkageName(LinkageItem* li);
+  inline std::string getLinkageName(Linkable* li);
   inline llvm::Value* getBoolean(llvm::Value* op);
   inline llvm::Value* getInteger(llvm::Value* op);
   inline llvm::Value* toBoolean(llvm::Value* op);
@@ -531,12 +533,14 @@
 }
 
 llvm::Constant*
-LLVMGeneratorPass::getConstant(const hlvm::Constant* C)
+LLVMGeneratorPass::getConstant(const hlvm::ConstantValue* C)
 {
   hlvmAssert(C!=0);
+  hlvmAssert(C->isConstantValue());
 
   // First, lets see if its cached already
-  ConstantDictionary::iterator I = consts.find(const_cast<hlvm::Constant*>(C));
+  ConstantDictionary::iterator I = 
+    consts.find(const_cast<hlvm::ConstantValue*>(C));
   if (I != consts.end())
     return I->second;
 
@@ -584,7 +588,7 @@
       break;
   }
   if (result)
-    consts[const_cast<hlvm::Constant*>(C)] = result;
+    consts[const_cast<hlvm::ConstantValue*>(C)] = result;
   else
     hlvmDeadCode("Didn't find constant");
   return result;
@@ -636,7 +640,7 @@
 }
 
 std::string
-LLVMGeneratorPass::getLinkageName(LinkageItem* lk)
+LLVMGeneratorPass::getLinkageName(Linkable* lk)
 {
   // if (lk->isProgram())
     // return std::string("_hlvm_entry_") + lk->getName();
@@ -1046,7 +1050,7 @@
 }
 
 template<> void
-LLVMGeneratorPass::gen<NoOperator>(NoOperator* op)
+LLVMGeneratorPass::gen<NullOp>(NullOp* op)
 {
 }
 
@@ -1281,16 +1285,30 @@
 {
   hlvm::Value* referent = const_cast<hlvm::Value*>(r->getReferent());
   llvm::Value* v = 0;
-  if (llvm::isa<Variable>(referent)) {
+  if (llvm::isa<AutoVarOp>(referent)) 
+  {
+    AutoVarDictionary::const_iterator I = 
+      lvars.find(llvm::cast<AutoVarOp>(referent));
+    hlvmAssert(I != lvars.end());
+    v = I->second;
+  }
+  else if (llvm::isa<ConstantValue>(referent))
+  {
+    const hlvm::ConstantValue* cval = llvm::cast<ConstantValue>(referent);
+    llvm::Constant* C = getConstant(cval);
+    hlvmAssert(C && "Can't generate constant?");
+    v = C;
+  }
+  else if (llvm::isa<Variable>(referent)) 
+  {
     VariableDictionary::iterator I = gvars.find(llvm::cast<Variable>(referent));
     hlvmAssert(I != gvars.end());
     v = I->second;
   } 
-  else if (llvm::isa<AutoVarOp>(referent)) 
+  else if (llvm::isa<Function>(referent)) 
   {
-    AutoVarDictionary::const_iterator I = 
-      lvars.find(llvm::cast<AutoVarOp>(referent));
-    hlvmAssert(I != lvars.end());
+    FunctionDictionary::iterator I = funcs.find(llvm::cast<Function>(referent));
+    hlvmAssert(I != funcs.end());
     v = I->second;
   }
   else
@@ -1299,14 +1317,6 @@
 }
 
 template<> void
-LLVMGeneratorPass::gen<ConstantReferenceOp>(ConstantReferenceOp* r)
-{
-  hlvm::Constant* referent = const_cast<hlvm::Constant*>(r->getReferent());
-  llvm::Constant* C = getConstant(referent);
-  hlvmAssert(C && "Can't generate constant?");
-  lops.push_back(C);
-}
-template<> void
 LLVMGeneratorPass::gen<IndexOp>(IndexOp* r)
 {
   hlvmAssert(lops.size() >= 2 && "Too few operands for IndexOp");
@@ -1394,6 +1404,7 @@
     getLinkageTypes(f->getLinkageKind()), 
     getLinkageName(f), lmod);
   lvars.clear();
+  funcs[f] = lfunc;
 }
 
 template<> void
@@ -1418,6 +1429,7 @@
   modules.push_back(lmod);
   lvars.clear();
   gvars.clear();
+  funcs.clear();
 }
 
 void 
@@ -1548,7 +1560,7 @@
     case BOrOpID:                 gen(llvm::cast<BOrOp>(n)); break;
     case BXorOpID:                gen(llvm::cast<BXorOp>(n)); break;
     case BNorOpID:                gen(llvm::cast<BNorOp>(n)); break;
-    case NoOperatorID:            gen(llvm::cast<NoOperator>(n)); break;
+    case NullOpID:                gen(llvm::cast<NullOp>(n)); break;
     case NotOpID:                 gen(llvm::cast<NotOp>(n)); break;
     case AndOpID:                 gen(llvm::cast<AndOp>(n)); break;
     case OrOpID:                  gen(llvm::cast<OrOp>(n)); break;
@@ -1569,8 +1581,6 @@
     case LoadOpID:                gen(llvm::cast<LoadOp>(n)); break;
     case StoreOpID:               gen(llvm::cast<StoreOp>(n)); break;
     case ReferenceOpID:           gen(llvm::cast<ReferenceOp>(n)); break;
-    case ConstantReferenceOpID:   gen(llvm::cast<ConstantReferenceOp>(n)); 
-                                  break;
     case AutoVarOpID:             gen(llvm::cast<AutoVarOp>(n)); break;
     case OpenOpID:                gen(llvm::cast<OpenOp>(n)); break;
     case CloseOpID:               gen(llvm::cast<CloseOp>(n)); break;

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

==============================================================================
--- hlvm/trunk/hlvm/Pass/Pass.cpp (original)
+++ hlvm/trunk/hlvm/Pass/Pass.cpp Sat Jul  7 19:01:59 2007
@@ -31,7 +31,7 @@
 #include <hlvm/AST/AST.h>
 #include <hlvm/AST/Bundle.h>
 #include <hlvm/AST/ContainerType.h>
-#include <hlvm/AST/LinkageItems.h>
+#include <hlvm/AST/Linkables.h>
 #include <hlvm/Base/Assert.h>
 
 using namespace hlvm;
@@ -55,6 +55,7 @@
   inline void runOn(Bundle* b);
   inline void runOn(Value* b);
   inline void runOn(Constant* b);
+  inline void runOn(Linkable* b);
 
 private:
   std::vector<Pass*> pre;
@@ -147,14 +148,8 @@
 {
   runPreOrder(b);
   for (Block::iterator I = b->begin(), E = b->end(); I != E; ++I) {
-    if (!*I)
-      break;
-    if (isa<Block>(*I))
-      runOn(cast<Block>(*I)); // recurse!
-    else if (isa<Variable>(*I))
-      runOn(cast<Variable>(*I));
-    else if (isa<Operator>(*I))
-      runOn(cast<Operator>(*I)); 
+    if (isa<Operator>(*I))
+      runOn(cast<Operator>(*I)); // recurse, possibly!
     else
       hlvmDeadCode("Block has invalid content");
   }
@@ -165,27 +160,23 @@
 PassManagerImpl::runOn(Bundle* b)
 {
   runPreOrder(b);
-  for (Bundle::type_iterator TI =b->type_begin(), TE = b->type_end(); 
+  for (Bundle::type_iterator TI = b->type_begin(), TE = b->type_end(); 
        TI != TE; ++TI) {
-    runPreOrder(const_cast<Node*>(TI->second));
-    runPostOrder(const_cast<Node*>(TI->second));
+    runPreOrder(const_cast<Type*>(TI->second));
+    runPostOrder(const_cast<Type*>(TI->second));
   }
-  for (Bundle::constant_iterator CI = b->const_begin(), CE = b->const_end();
-      CI != CE; ++CI)
-  {
-    runPreOrder(const_cast<Node*>(CI->second));
-    runPostOrder(const_cast<Node*>(CI->second));
+  for (Bundle::cval_iterator CI = b->cval_begin(), CE = b->cval_end(); 
+       CI != CE; ++CI) {
+    runPreOrder(const_cast<ConstantValue*>(CI->second));
+    runPostOrder(const_cast<ConstantValue*>(CI->second));
   }
-  for (Bundle::var_iterator VI = b->var_begin(), VE = b->var_end(); 
-       VI != VE; ++VI) {
-    runPreOrder(const_cast<Node*>(VI->second));
-    runPostOrder(const_cast<Node*>(VI->second));
-  }
-  for (Bundle::func_iterator FI = b->func_begin(), FE = b->func_end(); 
-       FI != FE; ++FI) {
-    runPreOrder(const_cast<Node*>(FI->second));
-    runOn(llvm::cast<Function>(FI->second)->getBlock());
-    runPostOrder(const_cast<Node*>(FI->second));
+  for (Bundle::linkable_iterator LI = b->linkable_begin(), 
+       LE = b->linkable_end(); LI != LE; ++LI)
+  {
+    runPreOrder(const_cast<Linkable*>(LI->second));
+    if (isa<Function>(LI->second))
+      runOn(llvm::cast<Function>(LI->second)->getBlock());
+    runPostOrder(const_cast<Linkable*>(LI->second));
   }
   runPostOrder(b);
 }

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

==============================================================================
--- hlvm/trunk/hlvm/Pass/Validate.cpp (original)
+++ hlvm/trunk/hlvm/Pass/Validate.cpp Sat Jul  7 19:01:59 2007
@@ -37,7 +37,7 @@
 #include <hlvm/AST/Arithmetic.h>
 #include <hlvm/AST/RealMath.h>
 #include <hlvm/AST/BooleanOps.h>
-#include <hlvm/AST/LinkageItems.h>
+#include <hlvm/AST/Linkables.h>
 #include <hlvm/AST/Constants.h>
 #include <llvm/Support/Casting.h>
 #include <llvm/Support/MathExtras.h>
@@ -66,7 +66,7 @@
     inline bool checkTerminator(Operator* op);
     inline bool checkUniformContainer(UniformContainerType* T, NodeIDs id);
     inline bool checkDisparateContainer(DisparateContainerType* T, NodeIDs id);
-    inline bool checkLinkageItem(LinkageItem* LI, NodeIDs id);
+    inline bool checkLinkable(Linkable* LI, NodeIDs id);
 
     template <class NodeClass>
     inline void validate(NodeClass* C);
@@ -232,17 +232,17 @@
 }
 
 bool 
-ValidateImpl::checkLinkageItem(LinkageItem* LI, NodeIDs id)
+ValidateImpl::checkLinkable(Linkable* LI, NodeIDs id)
 {
   bool result = checkConstant(LI,id);
   if (result) {
     if (LI->getLinkageKind() < ExternalLinkage || 
         LI->getLinkageKind() > InternalLinkage) {
-      error(LI,"Invalid LinkageKind for LinkageItem");
+      error(LI,"Invalid LinkageKind for Linkable");
       result = false;
     }
     if (LI->getName().length() == 0)  {
-      error(LI,"Zero length name for LinkageItem");
+      error(LI,"Zero length name for Linkable");
       result = false;
     }
   }
@@ -463,7 +463,7 @@
 template<> inline void
 ValidateImpl::validate(Variable* n)
 {
-  if (checkLinkageItem(n, VariableID)) 
+  if (checkLinkable(n, VariableID)) 
     if (n->hasInitializer())
       if (n->getType() != n->getInitializer()->getType())
         error(n,"Variable and its initializer do not agree in type");
@@ -472,7 +472,7 @@
 template<> inline void
 ValidateImpl::validate(Function* F)
 {
-  if (checkLinkageItem(F, FunctionID)) {
+  if (checkLinkable(F, FunctionID)) {
     if (F->getSignature() == 0)
       error(F,"Function without signature");
     else if (F->getSignature()->getID() != SignatureTypeID)
@@ -485,7 +485,7 @@
 template<> inline void
 ValidateImpl::validate(Program* P)
 {
-  if (checkLinkageItem(P, ProgramID)) {
+  if (checkLinkable(P, ProgramID)) {
     if (P->getSignature() == 0)
       error(P,"Program without signature");
     else if (P->getSignature()->getID() != SignatureTypeID)
@@ -510,9 +510,9 @@
 }
 
 template<> inline void
-ValidateImpl::validate(NoOperator* n)
+ValidateImpl::validate(NullOp* n)
 {
-  checkOperator(n,NoOperatorID,0);
+  checkOperator(n,NullOpID,0);
 }
 
 template<> inline void
@@ -554,7 +554,7 @@
     const Type* Ty3 = Op3->getType();
     if (!isa<BooleanType>(Ty1))
       error(n,"SelectOp expects first operand to be type boolean");
-    else if ( Ty1 != Ty2 )
+    else if ( Ty2 != Ty3 )
       error(n,"Second and third operands for SelectOp must agree in type");
     else if (isa<Block>(Op2) != isa<Block>(Op3))
       error(n,"SelectOp requires operands 2 and 3 to both be blocks or "
@@ -587,6 +587,12 @@
 }
 
 template<> inline void
+ValidateImpl::validate(CallOp* n)
+{
+  checkOperator(n,CallOpID,0,false);
+}
+
+template<> inline void
 ValidateImpl::validate(AllocateOp* n)
 {
   if (checkOperator(n,AllocateOpID,2)) {
@@ -673,13 +679,6 @@
 }
 
 template<> inline void
-ValidateImpl::validate(ConstantReferenceOp* op)
-{
-  checkOperator(op,ConstantReferenceOpID,0,true);
-  /// FIXME: check referent out
-}
-
-template<> inline void
 ValidateImpl::validate(NegateOp* n)
 {
   if (checkOperator(n,NegateOpID,1)) {
@@ -1236,13 +1235,13 @@
     case BundleID:               validate(cast<Bundle>(n)); break;
     case BlockID:                validate(cast<Block>(n)); break;
     case ImportID:               validate(cast<Import>(n)); break;
-    case CallOpID:               /*validate(cast<CallOp>(n));*/ break;
+    case CallOpID:               validate(cast<CallOp>(n)); break;
     case InvokeOpID:             /*validate(cast<InvokeOp>(n));*/ break;
     case DispatchOpID:           /*validate(cast<DispatchOp>(n));*/ break;
     case CreateContOpID:         /*validate(cast<CreateContOp>(n));*/ break;
     case CallWithContOpID:       /*validate(cast<CallWithContOp>(n));*/ break;
     case ThrowOpID:              /*validate(cast<ThrowOp>(n));*/ break;
-    case NoOperatorID:           validate(cast<NoOperator>(n)); break;
+    case NullOpID:               validate(cast<NullOp>(n)); break;
     case ReturnOpID:             validate(cast<ReturnOp>(n)); break;
     case ContinueOpID:           validate(cast<ContinueOp>(n)); break;
     case BreakOpID:              validate(cast<BreakOp>(n)); break;
@@ -1255,8 +1254,6 @@
     case DeallocateOpID:         validate(cast<DeallocateOp>(n)); break;
     case ReallocateOpID:         /*validate(cast<ReallocateOp>(n));*/ break;
     case ReferenceOpID:          validate(cast<ReferenceOp>(n)); break;
-    case ConstantReferenceOpID:  validate(cast<ConstantReferenceOp>(n)); 
-                                                                     break;
     case AutoVarOpID:            validate(cast<AutoVarOp>(n)); break;
     case NegateOpID:             validate(cast<NegateOp>(n)); break;
     case ComplementOpID:         validate(cast<ComplementOp>(n)); break;

Modified: hlvm/trunk/hlvm/Reader/HLVM.rng
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/HLVM.rng?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Reader/HLVM.rng (original)
+++ hlvm/trunk/hlvm/Reader/HLVM.rng Sat Jul  7 19:01:59 2007
@@ -659,7 +659,6 @@
   <define name="Operators.pat">
     <choice>
       <ref name="block.elem"/>
-      <ref name="cref.elem"/>
       <ref name="noop.elem"/>
       <ref name="BooleanOperators.pat"/>
       <ref name="UnaryArithmeticOperators.pat"/>
@@ -707,13 +706,6 @@
     </element>
   </define>
 
-  <define name="cref.elem">
-    <element name="cref">
-      <ref name="Named_Element.pat"/>
-      <empty/>
-    </element>
-  </define>
-
   <define name="noop.elem">
     <element name="noop">
       <empty/>
@@ -753,6 +745,7 @@
       <ref name="index.elem"/>
       <ref name="length.elem"/>
       <ref name="autovar.elem"/>
+      <ref name="ref.elem"/>
     </choice>
   </define>
 
@@ -1115,10 +1108,9 @@
 
   <define name="call.elem">
     <element name="call">
-      <ref name="Named_Element.pat"/>
-      <zeroOrMore>
+      <oneOrMore>
         <ref name="Operators.pat"/>
-      </zeroOrMore>
+      </oneOrMore>
     </element>
   </define>
 

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

==============================================================================
--- hlvm/trunk/hlvm/Reader/XMLReader.cpp (original)
+++ hlvm/trunk/hlvm/Reader/XMLReader.cpp Sat Jul  7 19:01:59 2007
@@ -35,7 +35,7 @@
 #include <hlvm/AST/Bundle.h>
 #include <hlvm/AST/ContainerType.h>
 #include <hlvm/AST/Documentation.h>
-#include <hlvm/AST/LinkageItems.h>
+#include <hlvm/AST/Linkables.h>
 #include <hlvm/AST/Constants.h>
 #include <hlvm/AST/ControlFlow.h>
 #include <hlvm/AST/MemoryOps.h>
@@ -393,7 +393,7 @@
     const std::string& name,
     const Type* Ty)
 {
-  if (!name.empty() && bundle->find_const(name) != 0) {
+  if (!name.empty() && bundle->find_linkable(name) != 0) {
     error(getLocator(cur),std::string("Constant '") + name 
           + "' already exists.");
     return 0;
@@ -687,7 +687,7 @@
   if (lnkg)
     var->setLinkageKind(recognize_LinkageKinds(lnkg));
   if (init) {
-    Constant* initializer = bundle->find_const(init);
+    ConstantValue* initializer = bundle->find_cval(init);
     if (initializer)
       var->setInitializer(initializer);
     else 
@@ -706,9 +706,9 @@
   getNameType(cur, name, type);
   const Type* Ty = getType(type);
   const char* init = getAttribute(cur,"init",false);
-  Constant *initializer = 0;
+  ConstantValue *initializer = 0;
   if (init) {
-    initializer = bundle->find_const(init);
+    initializer = bundle->find_cval(init);
     if (!initializer)
       error(loc,std::string("Constant '") + init + 
             "' not found in initializer.");
@@ -736,29 +736,20 @@
     blk = blk->getParentBlock();
   }
 
-  // Didn't find an autovar, try a global variable
-  if (!referent) {
-    referent = bundle->find_var(id);
-    if (!referent) {
-      error(loc,std::string("Variable '") + id + "' not found");
-    }
-  }
+  // Didn't find an autovar? Try a constant value.
+  if (!referent)
+    referent= bundle->find_cval(id);
+    
+  // Didn't find an constant? Try a linkable
+  if (!referent)
+    referent = bundle->find_linkable(id);
 
-  return ast->AST::new_ReferenceOp(referent, loc);
-}
 
-template<> ConstantReferenceOp*
-XMLReaderImpl::parse<ConstantReferenceOp>(xmlNodePtr& cur)
-{
-  std::string id = getAttribute(cur,"id");
-  Locator* loc = getLocator(cur);
-  Constant* referent = bundle->find_const(id);
-  if (!referent) {
-    error(loc,std::string("Constant '") + id + 
-          "' not found. Substituting false.");
-    referent = ast->new_ConstantBoolean(false, getLocator(cur)); 
-  }
-  return ast->AST::new_ConstantReferenceOp(referent, loc);
+  // Didn't find a linkable? Try an error message for size
+  if (!referent)
+      error(loc,std::string("Referent '") + id + "' not found");
+
+  return ast->AST::new_ReferenceOp(referent, loc);
 }
 
 template<class OpClass>
@@ -903,8 +894,7 @@
   func = program;
   xmlNodePtr child = cur->children;
   if (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
-    Block* b = parse<Block>(child);
-    program->setBlock(b);
+    parse<Block>(child);
   } else {
     hlvmDeadCode("Program Without Block!");
   }
@@ -1059,7 +1049,7 @@
       case TKN_bor:          op = parseBinaryOp<BOrOp>(cur); break;
       case TKN_bxor:         op = parseBinaryOp<BXorOp>(cur); break;
       case TKN_bnor:         op = parseBinaryOp<BNorOp>(cur); break;
-      case TKN_noop:         op = parseNilaryOp<NoOperator>(cur); break;
+      case TKN_noop:         op = parseNilaryOp<NullOp>(cur); break;
       case TKN_not:          op = parseUnaryOp<NotOp>(cur); break;
       case TKN_and:          op = parseBinaryOp<AndOp>(cur); break;
       case TKN_or:           op = parseBinaryOp<OrOp>(cur); break;
@@ -1077,13 +1067,13 @@
       case TKN_break:        op = parseNilaryOp<BreakOp>(cur); break;
       case TKN_continue:     op = parseNilaryOp<ContinueOp>(cur); break;
       case TKN_ret:          op = parseUnaryOp<ReturnOp>(cur); break;
+      case TKN_call:         op = parseMultiOp<CallOp>(cur); break;
       case TKN_store:        op = parseBinaryOp<StoreOp>(cur); break;
       case TKN_load:         op = parseUnaryOp<LoadOp>(cur); break;
       case TKN_open:         op = parseUnaryOp<OpenOp>(cur); break;
       case TKN_write:        op = parseBinaryOp<WriteOp>(cur); break;
       case TKN_close:        op = parseUnaryOp<CloseOp>(cur); break;
       case TKN_ref:          op = parse<ReferenceOp>(cur); break;
-      case TKN_cref:         op = parse<ConstantReferenceOp>(cur); break;
       case TKN_autovar:      op = parse<AutoVarOp>(cur); break;
       case TKN_block:        op = parse<Block>(cur); break;
       default:

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

==============================================================================
--- hlvm/trunk/hlvm/Writer/XMLWriter.cpp (original)
+++ hlvm/trunk/hlvm/Writer/XMLWriter.cpp Sat Jul  7 19:01:59 2007
@@ -32,7 +32,7 @@
 #include <hlvm/AST/Bundle.h>
 #include <hlvm/AST/Documentation.h>
 #include <hlvm/AST/ContainerType.h>
-#include <hlvm/AST/LinkageItems.h>
+#include <hlvm/AST/Linkables.h>
 #include <hlvm/AST/Constants.h>
 #include <hlvm/AST/Block.h>
 #include <hlvm/AST/ControlFlow.h>
@@ -273,7 +273,7 @@
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<RealType>(RealType* t)
+XMLWriterImpl::WriterPass::put(RealType* t)
 {
   startElement("atom");
   writeAttribute("id",t->getName());
@@ -292,7 +292,7 @@
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<OctetType>(OctetType* t)
+XMLWriterImpl::WriterPass::put(OctetType* t)
 {
   startElement("atom");
   writeAttribute("id",t->getName());
@@ -303,7 +303,7 @@
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<VoidType>(VoidType* t)
+XMLWriterImpl::WriterPass::put(VoidType* t)
 {
   startElement("atom");
   writeAttribute("id",t->getName());
@@ -314,7 +314,7 @@
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<OpaqueType>(OpaqueType* op)
+XMLWriterImpl::WriterPass::put(OpaqueType* op)
 {
   startElement("opaque");
   writeAttribute("id",op->getName());
@@ -322,7 +322,7 @@
 }
 
 template<> void 
-XMLWriterImpl::WriterPass::put<PointerType>(PointerType* t)
+XMLWriterImpl::WriterPass::put(PointerType* t)
 {
   startElement("pointer");
   writeAttribute("id", t->getName());
@@ -331,7 +331,7 @@
 }
 
 template<> void 
-XMLWriterImpl::WriterPass::put<ArrayType>(ArrayType* t)
+XMLWriterImpl::WriterPass::put(ArrayType* t)
 {
   startElement("array");
   writeAttribute("id", t->getName());
@@ -341,7 +341,7 @@
 }
 
 template<> void 
-XMLWriterImpl::WriterPass::put<VectorType>(VectorType* t)
+XMLWriterImpl::WriterPass::put(VectorType* t)
 {
   startElement("vector");
   writeAttribute("id", t->getName());
@@ -351,7 +351,7 @@
 }
 
 template<> void 
-XMLWriterImpl::WriterPass::put<StructureType>(StructureType* t)
+XMLWriterImpl::WriterPass::put(StructureType* t)
 {
   startElement("structure");
   writeAttribute("id",t->getName());
@@ -367,7 +367,7 @@
 }
 
 template<> void 
-XMLWriterImpl::WriterPass::put<SignatureType>(SignatureType* t)
+XMLWriterImpl::WriterPass::put(SignatureType* t)
 {
   startElement("signature");
   writeAttribute("id",t->getName());
@@ -385,7 +385,7 @@
 }
 
 template<> void 
-XMLWriterImpl::WriterPass::put<ConstantBoolean>(ConstantBoolean* i)
+XMLWriterImpl::WriterPass::put(ConstantBoolean* i)
 {
   startElement("constant");
   writeAttribute("id",i->getName());
@@ -398,7 +398,7 @@
 }
 
 template<> void 
-XMLWriterImpl::WriterPass::put<ConstantInteger>(ConstantInteger* i)
+XMLWriterImpl::WriterPass::put(ConstantInteger* i)
 {
   startElement("constant");
   writeAttribute("id",i->getName());
@@ -414,7 +414,7 @@
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<ConstantReal>(ConstantReal* r)
+XMLWriterImpl::WriterPass::put(ConstantReal* r)
 {
   startElement("constant");
   writeAttribute("id",r->getName());
@@ -425,7 +425,7 @@
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<ConstantString>(ConstantString* t)
+XMLWriterImpl::WriterPass::put(ConstantString* t)
 {
   startElement("constant");
   writeAttribute("id",t->getName());
@@ -436,7 +436,7 @@
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<Variable>(Variable* v)
+XMLWriterImpl::WriterPass::put(Variable* v)
 {
   startElement("variable");
   writeAttribute("id",v->getName());
@@ -449,7 +449,7 @@
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<Function>(Function* f)
+XMLWriterImpl::WriterPass::put(Function* f)
 {
   startElement("function");
   writeAttribute("id",f->getName());
@@ -459,7 +459,7 @@
 }
 
 template<> void 
-XMLWriterImpl::WriterPass::put<Program>(Program* p)
+XMLWriterImpl::WriterPass::put(Program* p)
 {
   startElement("program");
   writeAttribute("id",p->getName());
@@ -467,7 +467,7 @@
 }
 
 template<> void 
-XMLWriterImpl::WriterPass::put<Block>(Block* b)
+XMLWriterImpl::WriterPass::put(Block* b)
 {
   startElement("block");
   if (!b->getLabel().empty())
@@ -476,7 +476,7 @@
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<AutoVarOp>(AutoVarOp* av)
+XMLWriterImpl::WriterPass::put(AutoVarOp* av)
 {
   startElement("autovar");
   writeAttribute("id",av->getName());
@@ -489,182 +489,182 @@
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<NegateOp>(NegateOp* op)
+XMLWriterImpl::WriterPass::put(NegateOp* op)
 {
   startElement("neg");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<ComplementOp>(ComplementOp* op)
+XMLWriterImpl::WriterPass::put(ComplementOp* op)
 {
   startElement("cmpl");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<PreIncrOp>(PreIncrOp* op)
+XMLWriterImpl::WriterPass::put(PreIncrOp* op)
 {
   startElement("preinc");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<PreDecrOp>(PreDecrOp* op)
+XMLWriterImpl::WriterPass::put(PreDecrOp* op)
 {
   startElement("predec");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<PostIncrOp>(PostIncrOp* op)
+XMLWriterImpl::WriterPass::put(PostIncrOp* op)
 {
   startElement("postinc");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<PostDecrOp>(PostDecrOp* op)
+XMLWriterImpl::WriterPass::put(PostDecrOp* op)
 {
   startElement("postdec");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<AddOp>(AddOp* op)
+XMLWriterImpl::WriterPass::put(AddOp* op)
 {
   startElement("add");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<SubtractOp>(SubtractOp* op)
+XMLWriterImpl::WriterPass::put(SubtractOp* op)
 {
   startElement("sub");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<MultiplyOp>(MultiplyOp* op)
+XMLWriterImpl::WriterPass::put(MultiplyOp* op)
 {
   startElement("mul");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<DivideOp>(DivideOp* op)
+XMLWriterImpl::WriterPass::put(DivideOp* op)
 {
   startElement("div");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<ModuloOp>(ModuloOp* op)
+XMLWriterImpl::WriterPass::put(ModuloOp* op)
 {
   startElement("mod");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<BAndOp>(BAndOp* op)
+XMLWriterImpl::WriterPass::put(BAndOp* op)
 {
   startElement("band");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<BOrOp>(BOrOp* op)
+XMLWriterImpl::WriterPass::put(BOrOp* op)
 {
   startElement("bor");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<BXorOp>(BXorOp* op)
+XMLWriterImpl::WriterPass::put(BXorOp* op)
 {
   startElement("bxor");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<BNorOp>(BNorOp* op)
+XMLWriterImpl::WriterPass::put(BNorOp* op)
 {
   startElement("bnor");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<NotOp>(NotOp* op)
+XMLWriterImpl::WriterPass::put(NotOp* op)
 {
   startElement("not");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<AndOp>(AndOp* op)
+XMLWriterImpl::WriterPass::put(AndOp* op)
 {
   startElement("and");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<OrOp>(OrOp* op)
+XMLWriterImpl::WriterPass::put(OrOp* op)
 {
   startElement("or");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<XorOp>(XorOp* op)
+XMLWriterImpl::WriterPass::put(XorOp* op)
 {
   startElement("xor");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<NorOp>(NorOp* op)
+XMLWriterImpl::WriterPass::put(NorOp* op)
 {
   startElement("nor");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<EqualityOp>(EqualityOp* op)
+XMLWriterImpl::WriterPass::put(EqualityOp* op)
 {
   startElement("eq");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<InequalityOp>(InequalityOp* op)
+XMLWriterImpl::WriterPass::put(InequalityOp* op)
 {
   startElement("ne");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<LessThanOp>(LessThanOp* op)
+XMLWriterImpl::WriterPass::put(LessThanOp* op)
 {
   startElement("lt");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<GreaterThanOp>(GreaterThanOp* op)
+XMLWriterImpl::WriterPass::put(GreaterThanOp* op)
 {
   startElement("gt");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<LessEqualOp>(LessEqualOp* op)
+XMLWriterImpl::WriterPass::put(LessEqualOp* op)
 {
   startElement("le");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<GreaterEqualOp>(GreaterEqualOp* op)
+XMLWriterImpl::WriterPass::put(GreaterEqualOp* op)
 {
   startElement("ge");
   putDoc(op);
@@ -672,54 +672,61 @@
 
 
 template<> void
-XMLWriterImpl::WriterPass::put<NoOperator>(NoOperator* op)
+XMLWriterImpl::WriterPass::put(NullOp* op)
 {
   startElement("noop");
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<SelectOp>(SelectOp* op)
+XMLWriterImpl::WriterPass::put(SelectOp* op)
 {
   startElement("select");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<SwitchOp>(SwitchOp* op) 
+XMLWriterImpl::WriterPass::put(SwitchOp* op) 
 {
   startElement("switch");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<LoopOp>(LoopOp* op) 
+XMLWriterImpl::WriterPass::put(LoopOp* op) 
 {
   startElement("loop");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<BreakOp>(BreakOp* op)
+XMLWriterImpl::WriterPass::put(BreakOp* op)
 {
   startElement("break");
   putDoc(op);
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<ContinueOp>(ContinueOp* op)
+XMLWriterImpl::WriterPass::put(ContinueOp* op)
 {
   startElement("continue");
   putDoc(op);
 }
 
 template<> void 
-XMLWriterImpl::WriterPass::put<ReturnOp>(ReturnOp* r)
+XMLWriterImpl::WriterPass::put(ReturnOp* r)
 {
   startElement("ret");
   putDoc(r);
 }
 
 template<> void 
+XMLWriterImpl::WriterPass::put(CallOp* r)
+{
+  startElement("call");
+  putDoc(r);
+}
+
+template<> void 
 XMLWriterImpl::WriterPass::put(StoreOp* r)
 {
   startElement("store");
@@ -733,21 +740,18 @@
   putDoc(r);
 }
 
-template<> void
-XMLWriterImpl::WriterPass::put(ConstantReferenceOp* cr)
-{
-  startElement("cref");
-  writeAttribute("id",cr->getReferent()->getName());
-}
-
 template<> void 
 XMLWriterImpl::WriterPass::put(ReferenceOp* r)
 {
   startElement("ref");
   const Value* ref = r->getReferent();
-  const std::string& name = 
-     (isa<Variable>(ref) ? cast<Variable>(ref)->getName() :
-      (isa<AutoVarOp>(ref) ? cast<AutoVarOp>(ref)->getName() : "oops" ));
+  std::string name;
+  if (isa<AutoVarOp>(ref))
+    name = cast<AutoVarOp>(ref)->getName();
+  else if (isa<Constant>(ref))
+    name = cast<Constant>(ref)->getName();
+  else
+    name = "oops";
   writeAttribute("id",name);
   putDoc(r);
 }
@@ -774,7 +778,7 @@
 }
 
 template<> void 
-XMLWriterImpl::WriterPass::put<Bundle>(Bundle* b)
+XMLWriterImpl::WriterPass::put(Bundle* b)
 {
   startElement("bundle");
   writeAttribute("id",b->getName());
@@ -840,16 +844,16 @@
       case GreaterThanOpID:      put(cast<GreaterThanOp>(n)); break;
       case LessEqualOpID:        put(cast<LessEqualOp>(n)); break;
       case GreaterEqualOpID:     put(cast<GreaterEqualOp>(n)); break;
-      case NoOperatorID:         put(cast<NoOperator>(n)); break;
+      case NullOpID:             put(cast<NullOp>(n)); break;
       case SelectOpID:           put(cast<SelectOp>(n)); break;
       case SwitchOpID:           put(cast<SwitchOp>(n)); break;
       case LoopOpID:             put(cast<LoopOp>(n)); break;
       case BreakOpID:            put(cast<BreakOp>(n)); break;
       case ContinueOpID:         put(cast<ContinueOp>(n)); break;
       case ReturnOpID:           put(cast<ReturnOp>(n)); break;
+      case CallOpID:             put(cast<CallOp>(n)); break;
       case StoreOpID:            put(cast<StoreOp>(n)); break;
       case LoadOpID:             put(cast<LoadOp>(n)); break;
-      case ConstantReferenceOpID:put(cast<ConstantReferenceOp>(n)); break;
       case ReferenceOpID:        put(cast<ReferenceOp>(n)); break;
       case OpenOpID:             put(cast<OpenOp>(n)); break;
       case CloseOpID:            put(cast<CloseOp>(n)); break;

Modified: hlvm/trunk/test/return0/arithmetic.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/return0/arithmetic.hlx?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/test/return0/arithmetic.hlx (original)
+++ hlvm/trunk/test/return0/arithmetic.hlx Sat Jul  7 19:01:59 2007
@@ -13,14 +13,14 @@
             <add>
               <mul>
                 <div>
-                  <cref id="42"/>
-                  <cref id="7"/>
+                  <ref id="42"/>
+                  <ref id="7"/>
                 </div>
-                <cref id="1"/>
+                <ref id="1"/>
               </mul>
-              <cref id="2"/>
+              <ref id="2"/>
             </add>
-            <cref id="8"/>
+            <ref id="8"/>
           </sub>
         </ret>
       </block>

Modified: hlvm/trunk/test/return0/bitwise.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/return0/bitwise.hlx?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/test/return0/bitwise.hlx (original)
+++ hlvm/trunk/test/return0/bitwise.hlx Sat Jul  7 19:01:59 2007
@@ -12,14 +12,14 @@
             <bnor>
               <bor>
                 <bxor>
-                  <cref id="0f0f0f0f"/>
-                  <cref id="08080808"/>
+                  <ref id="0f0f0f0f"/>
+                  <ref id="08080808"/>
                 </bxor>
-                <cref id="04040404"/>
+                <ref id="04040404"/>
               </bor>
-              <cref id="0f0f0f0f"/>
+              <ref id="0f0f0f0f"/>
             </bnor>
-            <cref id="00000000"/>
+            <ref id="00000000"/>
           </band>
         </ret>
       </block>

Modified: hlvm/trunk/test/return0/boolean.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/return0/boolean.hlx?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/test/return0/boolean.hlx (original)
+++ hlvm/trunk/test/return0/boolean.hlx Sat Jul  7 19:01:59 2007
@@ -3,24 +3,37 @@
   <bundle id="boolean">
     <constant id="true" type="bool"><true/></constant>
     <constant id="false" type="bool"><false/></constant>
+    <constant id="one" type="s32"><dec>1</dec></constant>
+    <constant id="zero" type="s32"><dec>0</dec></constant>
+    <signature id="compute_type" result="bool"/>
     <program id="boolean">
       <block>
+        <select>
+          <call><ref id="compute"/></call>
+          <ref id="one"/>
+          <ref id="zero"/>
+        </select>
+      </block>
+    </program>
+
+    <function id="compute" type="compute_type">
+      <block>
         <ret>
           <and>
             <nor>
               <or>
                 <xor>
-                  <cref id="true"/>
-                  <cref id="false"/>
+                  <ref id="true"/>
+                  <ref id="false"/>
                 </xor>
-                <cref id="false"/>
+                <ref id="false"/>
               </or>
-              <cref id="true"/>
+              <ref id="true"/>
             </nor>
-            <cref id="false"/>
+            <ref id="false"/>
           </and>
         </ret>
       </block>
-    </program>
+    </function>
   </bundle>
 </hlvm>

Modified: hlvm/trunk/test/return0/helloworld.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/return0/helloworld.hlx?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/test/return0/helloworld.hlx (original)
+++ hlvm/trunk/test/return0/helloworld.hlx Sat Jul  7 19:01:59 2007
@@ -13,20 +13,20 @@
     </constant>
     <program id="helloworld">
       <block>
-        <autovar id="stdout" type="stream"></autovar>
+        <autovar id="out" type="stream"></autovar>
         <store>
-          <ref id="stdout"/>
-          <open><cref id="stdout"/></open>
+          <ref id="out"/>
+          <open><ref id="stdout"/></open>
         </store>
         <write>
-          <load><ref id="stdout"/></load>
-          <cref id="hw"/>
+          <load><ref id="out"/></load>
+          <ref id="hw"/>
         </write>
         <close>
-          <load><ref id="stdout"/></load>
+          <load><ref id="out"/></load>
         </close>
         <ret>
-          <cref id="zero"/>
+          <ref id="zero"/>
         </ret>
       </block>
     </program>

Modified: hlvm/trunk/test/return0/return0.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/return0/return0.hlx?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/test/return0/return0.hlx (original)
+++ hlvm/trunk/test/return0/return0.hlx Sat Jul  7 19:01:59 2007
@@ -5,7 +5,7 @@
     <program id="return0">
       <block>
         <ret>
-          <cref id="zero"/>
+          <ref id="zero"/>
         </ret>
       </block>
     </program>

Modified: hlvm/trunk/test/xml2xml/arithmetic.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/arithmetic.hlx?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/arithmetic.hlx (original)
+++ hlvm/trunk/test/xml2xml/arithmetic.hlx Sat Jul  7 19:01:59 2007
@@ -34,13 +34,13 @@
           <load>
             <ref id="v1"/>
           </load>
-          <cref id="one"/>
+          <ref id="one"/>
         </add>
         <sub>
           <load>
             <ref id="v1"/>
           </load>
-          <cref id="one"/>
+          <ref id="one"/>
         </sub>
         <mul>
           <load>

Modified: hlvm/trunk/test/xml2xml/helloworld.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/helloworld.hlx?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/helloworld.hlx (original)
+++ hlvm/trunk/test/xml2xml/helloworld.hlx Sat Jul  7 19:01:59 2007
@@ -12,26 +12,26 @@
     </constant>
     <program id="helloworld">
       <block>
-        <autovar id="stdout" type="stream"/>
+        <autovar id="out" type="stream"/>
         <store>
-          <ref id="stdout"/>
+          <ref id="out"/>
           <open>
-            <cref id="stdout"/>
+            <ref id="stdout"/>
           </open>
         </store>
         <write>
           <load>
-            <ref id="stdout"/>
+            <ref id="out"/>
           </load>
-          <cref id="hw"/>
+          <ref id="hw"/>
         </write>
         <close>
           <load>
-            <ref id="stdout"/>
+            <ref id="out"/>
           </load>
         </close>
         <ret>
-          <cref id="0"/>
+          <ref id="0"/>
         </ret>
       </block>
     </program>

Modified: hlvm/trunk/test/xml2xml/loop.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/loop.hlx?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/loop.hlx (original)
+++ hlvm/trunk/test/xml2xml/loop.hlx Sat Jul  7 19:01:59 2007
@@ -12,10 +12,10 @@
         <ret>
           <loop>
             <ne>
-              <cref id="1"/>
-              <cref id="0"/>
+              <ref id="1"/>
+              <ref id="0"/>
             </ne>
-            <cref id="0"/>
+            <ref id="0"/>
             <noop/>
           </loop>
         </ret>

Modified: hlvm/trunk/test/xml2xml/return.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/return.hlx?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/return.hlx (original)
+++ hlvm/trunk/test/xml2xml/return.hlx Sat Jul  7 19:01:59 2007
@@ -7,7 +7,7 @@
     <program id="return">
       <block>
         <ret>
-          <cref id="42"/>
+          <ref id="42"/>
         </ret>
       </block>
     </program>

Modified: hlvm/trunk/test/xml2xml/select.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/select.hlx?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/select.hlx (original)
+++ hlvm/trunk/test/xml2xml/select.hlx Sat Jul  7 19:01:59 2007
@@ -15,11 +15,11 @@
         <ret>
           <select>
             <ne>
-              <cref id="0"/>
-              <cref id="21"/>
+              <ref id="0"/>
+              <ref id="21"/>
             </ne>
-            <cref id="42"/>
-            <cref id="21"/>
+            <ref id="42"/>
+            <ref id="21"/>
           </select>
         </ret>
       </block>

Modified: hlvm/trunk/test/xml2xml/switch.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/switch.hlx?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/switch.hlx (original)
+++ hlvm/trunk/test/xml2xml/switch.hlx Sat Jul  7 19:01:59 2007
@@ -29,20 +29,20 @@
       <block>
         <ret>
           <switch>
-            <cref id="42"/>
-            <cref id="42"/>
-            <cref id="1"/>
-            <cref id="1"/>
-            <cref id="2"/>
-            <cref id="2"/>
-            <cref id="3"/>
-            <cref id="3"/>
-            <cref id="4"/>
-            <cref id="4"/>
-            <cref id="5"/>
-            <cref id="5"/>
-            <cref id="42"/>
-            <cref id="21"/>
+            <ref id="42"/>
+            <ref id="42"/>
+            <ref id="1"/>
+            <ref id="1"/>
+            <ref id="2"/>
+            <ref id="2"/>
+            <ref id="3"/>
+            <ref id="3"/>
+            <ref id="4"/>
+            <ref id="4"/>
+            <ref id="5"/>
+            <ref id="5"/>
+            <ref id="42"/>
+            <ref id="21"/>
           </switch>
         </ret>
       </block>

Modified: hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp (original)
+++ hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp Sat Jul  7 19:01:59 2007
@@ -52,7 +52,9 @@
 
 enum GenerationOptions {
   GenLLVMBytecode,
-  GenLLVMAssembly
+  GenLLVMAssembly,
+  GenNativeExecutable,
+  GenLoadableModule
 };
 
 static cl::opt<GenerationOptions> WhatToGenerate(
@@ -60,8 +62,10 @@
   cl::desc("Choose what kind of output to generate"),
   cl::init(GenLLVMBytecode),
   cl::values(
-    clEnumValN(GenLLVMBytecode, "llvmbc", "Generate LLVM Bytecode"),
-    clEnumValN(GenLLVMAssembly, "llvmasm", "Generate LLVM Assembly"),
+    clEnumValN(GenLLVMBytecode,     "llvmbc",  "Generate LLVM Bytecode"),
+    clEnumValN(GenLLVMAssembly,     "llvmasm", "Generate LLVM Assembly"),
+    clEnumValN(GenNativeExecutable, "native",  "Generate Native Executable"),
+    clEnumValN(GenLoadableModule,   "module",  "Generate Loadable Module"),
     clEnumValEnd
   )
 );

Modified: hlvm/trunk/tools/hlvm-config/hlvm-config.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-config/hlvm-config.cpp?rev=38290&r1=38289&r2=38290&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm-config/hlvm-config.cpp (original)
+++ hlvm/trunk/tools/hlvm-config/hlvm-config.cpp Sat Jul  7 19:01:59 2007
@@ -92,7 +92,6 @@
   "ConstantString",
   "ConstantAggregate",
   "ConstantExpression",
-  "SizeOf",
   "Variable",
   "Function",
   "Program",
@@ -103,8 +102,7 @@
   "NInfOp",
   "NaNOp",
   "ReferenceOp",
-  "ConstantReferenceOp",
-  "NoOperator",
+  "NullOp",
   "ReturnOp",
   "ThrowOp",
   "NotOp",
@@ -114,6 +112,7 @@
   "PostIncrOp",
   "PreDecrOp",
   "PostDecrOp",
+  "SizeOf",
   "IsPInfOp",
   "IsNInfOp",
   "IsNanOp",
@@ -228,9 +227,12 @@
     std::cout << "Constants: " 
               << FirstConstantID << " -> "
               << LastConstantID << "\n";
-    std::cout << "LinkageItems: " 
-              << FirstLinkageItemID << " -> "
-              << LastLinkageItemID << "\n";
+    std::cout << "ConstantValues: " 
+              << FirstConstantValueID << " -> "
+              << LastConstantValueID << "\n";
+    std::cout << "Linkables: " 
+              << FirstLinkableID << " -> "
+              << LastLinkableID << "\n";
     std::cout << "Operators: " 
               << FirstOperatorID << " -> "
               << LastOperatorID << "\n";
@@ -250,7 +252,7 @@
               << FirstMultiOperatorID << " -> "
               << LastMultiOperatorID << "\n";
     if (sizeof(NodeIDStrs)/sizeof(NodeIDStrs[0]) != NumNodeIDs)
-      std::cout << "\n**##!! NodeIDStrs Out Of Date !!##**\n";
+      std::cout << "\n**##!! NodeIDStrs Out Of Date !!##**\n\n";
 
   }
   return 0;





More information about the llvm-commits mailing list