[LLVMdev] Making Constants from GenericValues

Patrick Meredith pmeredit at uiuc.edu
Mon Mar 7 19:23:15 PST 2005


Nevermind, I got burned by cut and paste, this works perfectly.

----- Original Message ----- 
From: "Patrick Meredith" <pmeredit at uiuc.edu>
To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu>
Sent: Monday, March 07, 2005 9:17 PM
Subject: Re: [LLVMdev] Making Constants from GenericValues


> I'm trying to turn some GenericValues into Constants in the interpreter
> using code like this, in a switch statement:
>
>      case Type::IntTyID:
>          SI = ConstantSInt::get(FB->getType(), ArgVals[i].IntVal);
>          params.push_back(UI);
>          UI->dump(); //for testing
>      break;
>
> FB is a Function::ArgumentListType::iterator
> ArgVals is a std::vector<GenericValue>
> the switch is on FB->getType()->getTypeID()
> so basically what I am doing is iterating through the formal argument list
> and using that to know how to convert the GenericValues
> (on a side note I can't get it to create iterators for ArgVals, hence the
> often n time operator[])
>
> The dump() call causes a segfault and I can't figure out why.  I looked at
> the implementation of get and it is supposed to create the constant if it
> does not already exist in the module, so I'm at a complete loss.
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list