Anton Skvorts
2011-Feb-12 05:07 UTC
[LLVMdev] conversion from 'const llvm::Value*' to 'llvm::Constant*'
Hi Apolagize if this newbie question has some obvious answer. When running something like ... ExprAST *Init = GlobalNames[i].second; const Value *InitVal; InitVal = Init->Codegen(); GlobalVariable * globvar = new GlobalVariable(*TheModule, InitVal->getType(), false, llvm::GlobalValue::ExternalLinkage, InitVal, Twine(GlobalName)); ... I'm getting the following error error: invalid conversion from `const llvm::Value*' to `llvm::Constant*' How may I make this conversion? Any help would be much appreciated! Anton -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110212/cd5fbea8/attachment.html>
Duncan Sands
2011-Feb-12 12:47 UTC
[LLVMdev] conversion from 'const llvm::Value*' to 'llvm::Constant*'
Hi Anton,> I'm getting the following error > > error: invalid conversion from `const llvm::Value*' to `llvm::Constant*' > > How may I make this conversion? Any help would be much appreciated!cast<Constant>(whatever) Ciao, Duncan.
Anton Skvorts
2011-Feb-13 00:03 UTC
[LLVMdev] conversion from 'const llvm::Value*' to 'llvm::Constant*'
Hi Duncan Many many thanks, it works now! But there are still some details I must be missing. I'm getting an assertion when I try the following assignment in my script: global c = cos(1); Assertion failed: isa<X>(Val) && "cast<Ty>() argument of incompatible type!", file c:/llvm-source-2.7/include/llvm/Support/Casting.h, line 200 However, running for example cos(1); global a = 0.5403023058681398; # cos(1) = 0.5403023058681398 global b = 1 + 1; works fine @a = global double 0x3FE14A280FB5068C ; <double*> [#uses=0] @b = global double 2.000000e+000 ; <double*> [#uses=0] define double @0() { entry: ret double 0x3FE14A280FB5068C } The relevant code is ... Value *InitVal; InitVal = Init->Codegen(); GlobalVariable * globval = *new* *GlobalVariable*(*TheModule, InitVal->getType(), *false*, llvm::GlobalValue::*ExternalLinkage*, cast<Constant>(InitVal), Twine(GlobalName) ); Any help, as always, would be really much appreciated! Anton Skvorts 2011/2/12 Duncan Sands <baldrick at free.fr>> Hi Anton, > > > I'm getting the following error > > > > error: invalid conversion from `const llvm::Value*' to > `llvm::Constant*' > > > > How may I make this conversion? Any help would be much appreciated! > > > cast<Constant>(whatever) > > Ciao, Duncan. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110213/785d31fe/attachment.html>
Seemingly Similar Threads
- [LLVMdev] conversion from 'const llvm::Value*' to 'llvm::Constant*'
- [LLVMdev] conversion from 'const llvm::Value*' to 'llvm::Constant*'
- [LLVMdev] conversion from 'const llvm::Value*' to 'llvm::Constant*'
- [LLVMdev] conversion from 'const llvm::Value*' to 'llvm::Constant*'
- [LLVMdev] conversion from 'const llvm::Value*' to 'llvm::Constant*'