search for: exprast

Displaying 14 results from an estimated 14 matches for "exprast".

2010 Feb 17
2
[LLVMdev] Kaleidoscope toy4 failure seg fault on llvm::ExecutionEngine::getTargetData (this=0x0)
...s its ascii value. int ThisChar = LastChar; LastChar = getchar(); return ThisChar; } //===----------------------------------------------------------------------===// // Abstract Syntax Tree (aka Parse Tree) //===----------------------------------------------------------------------===// /// ExprAST - Base class for all expression nodes. class ExprAST { public: virtual ~ExprAST() {} virtual Value *Codegen() = 0; }; /// NumberExprAST - Expression class for numeric literals like "1.0". class NumberExprAST : public ExprAST { double Val; public: NumberExprAST(double val) : Val(v...
2010 Feb 17
0
[LLVMdev] Kaleidoscope toy4 failure seg fault on llvm::ExecutionEngine::getTargetData (this=0x0)
...LastChar = getchar(); > return ThisChar; > } > > > //===----------------------------------------------------------------------===// > // Abstract Syntax Tree (aka Parse Tree) > > //===----------------------------------------------------------------------===// > > /// ExprAST - Base class for all expression nodes. > class ExprAST { > public: > virtual ~ExprAST() {} > virtual Value *Codegen() = 0; > }; > > /// NumberExprAST - Expression class for numeric literals like "1.0". > class NumberExprAST : public ExprAST { > double Val; &g...
2010 Feb 17
1
[LLVMdev] Kaleidoscope toy4 failure seg fault on llvm::ExecutionEngine::getTargetData (this=0x0)
...ThisChar; >> } >> >> >> //===----------------------------------------------------------------------===// >> // Abstract Syntax Tree (aka Parse Tree) >> >> //===----------------------------------------------------------------------===// >> >> /// ExprAST - Base class for all expression nodes. >> class ExprAST { >> public: >>  virtual ~ExprAST() {} >>  virtual Value *Codegen() = 0; >> }; >> >> /// NumberExprAST - Expression class for numeric literals like "1.0". >> class NumberExprAST : publi...
2011 Feb 08
1
[LLVMdev] Question about linker error
Hello all, When extending the tutorial to support global variables I'm getting the following linker error: glob.o:glob.cpp:(.text+0x12241): undefined reference to `vtable for GlobalExprAST' collect2: ld returned 1 exit status GlobalExprAST class is: /// GlobalExprAST - Expression class for globals class GlobalExprAST : public ExprAST { std::string Name; ExprAST *Init; public: GlobalExprAST(const std::string &name, ExprAST *init) : Name(name), Init(init) {} virtua...
2007 Nov 05
0
[LLVMdev] 'Implementing a language with LLVM' tutorial
...le comments by skipping to the end of the line and then returning the next comment." Shouldn't this say "returning the next comment"? http://llvm.org/docs/tutorial/LangImpl2.html I was a bit confused at first because the AST node classes are called ASTs. Instead of saying "ExprAST node" all the time, who not just call the class ExprNode or ExprAstNode? http://llvm.org/docs/tutorial/LangImpl3.html case '<': L = Builder.CreateFCmpULT(L, R, "multmp"); Should this be something like "cmptmp"? Also, you mention zero-argument functions, b...
2009 Oct 01
3
[LLVMdev] PHI and Allocas
...to account for one value only, the result of: Value *ThenV = Then->Codegen(); (...) Value *ElseV = Else->Codegen(); (...) PN->addIncoming(ThenV, ThenBB); PN->addIncoming(ElseV, ElseBB); But both Then and Else are expressions, so the Value returned is in the form of a single variable. ExprAST *Then = ParseExpression(); (...) ExprAST *Else = ParseExpression(); In my toy language, I accept any number of statements inside a block. Ignoring nested if statements, should I keep track of *each* variable mutation inside the block, or is there some LLVM magic (as I'm getting used to)? A s...
2007 Nov 05
5
[LLVMdev] 'Implementing a language with LLVM' tutorial
On Mon, 5 Nov 2007, Aaron Gray wrote: >> Anyone have thoughts or feedback? :) > > Nice job. The only bit that is not immediately clear is the 'Proto' > variable, but is clear when looking through the code at the end of the page. Where in the tutorial? What would you suggest that I say? > Could do with a link to the LLVMBuilder class reference material. I added a link
2019 Nov 18
2
Crash using exceptions
...ns flag. Do I need to throw no exceptions whatsoever in my application to use LLVM JIT? As a minimal example, I modified the code in https://github.com/llvm-mirror/llvm/tree/master/examples/Kaleidoscope/BuildingAJIT/Chapter2. In toy.cpp, I update LogError to throw an exception: std::unique_ptr<ExprAST> LogError(const char *Str) { fprintf(stderr, "Error: %s\n", Str); throw std::runtime_error(""); } and I catch that exception in MainLoop: static void MainLoop() { while (true) { fprintf(stderr, "ready> "); try { switch (CurTok) { ......
2009 Oct 01
0
[LLVMdev] PHI and Allocas
...alue *ThenV = Then->Codegen(); > (...) > Value *ElseV = Else->Codegen(); > (...) > PN->addIncoming(ThenV, ThenBB); > PN->addIncoming(ElseV, ElseBB); > > But both Then and Else are expressions, so the Value returned is in > the form of a single variable. > > ExprAST *Then = ParseExpression(); > (...) > ExprAST *Else = ParseExpression(); > > In my toy language, I accept any number of statements inside a block. > > Ignoring nested if statements, should I keep track of *each* variable > mutation inside the block, or is there some LLVM magic (...
2011 Feb 12
2
[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 conver...
2011 Feb 13
0
[LLVMdev] conversion from 'const llvm::Value*' to 'llvm::Constant*'
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.
2008 Feb 22
1
[LLVMdev] tutorial typos
...tor&lt;std::string&gt; Args; public: PrototypeAST(const std::string &amp;name, const std::vector&lt;std::string&gt; &amp;args) : Name(name), Args(args) {} @@ -1132,7 +1132,7 @@ static FunctionAST *ParseDefinition() { static FunctionAST *ParseTopLevelExpr() { if (ExprAST *E = ParseExpression()) { // Make an anonymous proto. - PrototypeAST *Proto = new PrototypeAST("", std::vector&lt;()); + PrototypeAST *Proto = new PrototypeAST("", std::vector&lt;std::string&gt;()); return new FunctionAST(Proto, E); } return 0;
2011 Feb 13
2
[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
2011 Feb 13
3
[LLVMdev] conversion from 'const llvm::Value*' to 'llvm::Constant*'
...= 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 * gl...