小编Phi*_*lip的帖子

在llvm中没有生成基本块终止符

我对llvm很新,只在这里做了在线教程:http://llvm.org/docs/tutorial/LangImpl1.html 现在我想做自己的小语言并遇到一些问题.我想解析一下:

(def i 1)
Run Code Online (Sandbox Code Playgroud)

它应该做两件事:

  1. 定义一个返回1的新函数
  2. 返回一个值,以便它可以用作表达式

该函数已正确创建,但我将其用作表达式时遇到问题.AST看起来像这样:

FunctionAST // the whole statement
  - Prototype // is an nameless statement
  - Body // contains the definition expression
    - DefExprAST
      - Body // contains the Function definition
        - FunctionAST
          - Prototype // named i
          - Body // the value 1
Run Code Online (Sandbox Code Playgroud)

该函数的代码创建代码如下所示:

Function *FunctionAST::Codegen() {
  NamedValues.clear();

  Function *TheFunction = Proto->Codegen();
  if ( TheFunction == 0 ) return 0;

  BasicBlock *BB = BasicBlock::Create( getGlobalContext(), "entry", TheFunction );
  Builder.SetInsertPoint( BB …
Run Code Online (Sandbox Code Playgroud)

llvm llvm-ir

6
推荐指数
1
解决办法
2743
查看次数

标签 统计

llvm ×1

llvm-ir ×1