[LLVMdev] conversion from 'const llvm::Value*' to 'llvm::Constant*'
Anton Skvorts
anton.skvorts at gmail.com
Sun Feb 13 08:35:41 PST 2011
Oh, I thought that after "codegening" cos(0) would get me double 1.0
(assigment is working for anything like: global a = 1/3 + 2 /3 for
example) What would be the best way to make assigments involving
functions, like global a = cos(0);
without getting the assertion arising from InitVal =
cast<Constant>(Init->Codegen()); ?
I made some changes and now my code basically works, except in
assigments like the one above. It is a little bit frustrating because
is the main thing preventing me finishing my little silly scripting
language for monte carlo simulations.
Value *GlobalExprAST::Codegen() {
for (unsigned i = 0, e = GlobalNames.size(); i != e; ++i) {
const std::string &GlobalName = GlobalNames[i].first;
ExprAST *Init = GlobalNames[i].second;
Constant *InitVal;
InitVal = cast<Constant>(Init->Codegen());
if (InitVal == 0) return 0;
GlobalVariable * globval = new GlobalVariable(*TheModule,
InitVal->getType(), false, llvm::GlobalValue::ExternalLinkage,
InitVal, Twine(GlobalName) );
}
}
Thank you very much for our help
Anton
2011/2/13 Duncan Sands <baldrick at free.fr>:
> Hi Anton,
>
>> 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!",
>
> I think this is telling you that cos(1) is not a constant.
>
> Ciao, Duncan.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list