Richard Catlin
2013-Mar-26 00:14 UTC
[LLVMdev] Fwd: Extending Kaleidoscope to support Strings
I hope this is the right place to ask this question. If not, please let me
know where I can ask for help.
We are using Kaleidoscope as the base framework to write a source to source
compiler. Our source language has Strings with supported operations such
as concatenation, upper case, and substrings.
I am following the patterns set forth in Kaleidoscope, and need to
represent my std::string as a Value *.
I have:
Value *StringExprAST::Codegen() {
StringRef r(Val); // Val is a std::string captured by the parser
return ConstantDataArray::getString(getGlobalContext(), r);
}
For a test string of "Hello World!", I am trying to create an Alloca *
and
store the InitVal, which I get from codegen of StringExprAST.
uint64_t v(13);
APInt d(8, v);
Value * ArraySize = ConstantInt::get(getGlobalContext(), d);
Alloca = CreateEntryBlockAllocaString(TheFunction, VarName, ArraySize);
Builder.CreateStore(InitVal, Alloca);
I get the following error:
tok_string: "Hello World!"
Assertion failed: (getOperand(0)->getType()
=cast<PointerType>(getOperand(1)->getType())->getElementType()
&& "Ptr must
be a pointer to Val type!"), function AssertOK, file
/Users/rcatlin1/lldb/llvm/lib/IR/Instructions.cpp, line 1089.
Thanks for any guidance.
Regards,
Richard Catlin
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20130325/39d3da8c/attachment.html>
Reasonably Related Threads
- [LLVMdev] How to cast Value* to ConstantDataArray*
- [LLVMdev] How to cast Value* to ConstantDataArray*
- [LLVMdev] How to cast Value* to ConstantDataArray*
- FAST_IPSEC doesn't seem to honor net.key.prefered_oldsa=0
- [LLVMdev] conversion from 'const llvm::Value*' to 'llvm::Constant*'
