From 3779864fcf9c2b1df53b4841c6d87e92b5bbce4a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 18 Sep 2001 04:01:05 +0000 Subject: Add support for global constants, and for initializers for constants llvm-svn: 598 --- llvm/lib/VMCore/Function.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'llvm/lib/VMCore/Function.cpp') diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp index 75a27781a90..47a85395a3f 100644 --- a/llvm/lib/VMCore/Function.cpp +++ b/llvm/lib/VMCore/Function.cpp @@ -82,12 +82,18 @@ void Method::dropAllReferences() { // GlobalVariable Implementation //===----------------------------------------------------------------------===// -GlobalVariable::GlobalVariable(const Type *Ty, const string &Name = "") - : Value(Ty, Value::GlobalVal, Name), Parent(0) { +GlobalVariable::GlobalVariable(const Type *Ty, bool isConstant, + ConstPoolVal *Initializer = 0, + const string &Name = "") + : User(Ty, Value::GlobalVal, Name), Parent(0), Constant(isConstant) { assert(Ty->isPointerType() && // No unsized array pointers - (!Ty->dyncastPointerType()->isArrayType() || - Ty->dyncastPointerType()->dyncastArrayType()->isSized()) && + (!Ty->castPointerType()->isArrayType() || + Ty->castPointerType()->castArrayType()->isSized()) && "Global Variables must be pointers to a sized type!"); + if (Initializer) Operands.push_back(Use((Value*)Initializer, this)); + + assert(!isConstant || hasInitializer() && + "Globals Constants must have an initializer!"); } // Specialize setName to take care of symbol table majik -- cgit v1.2.3