llc - 期望值令牌错误
llc - expected value token error
我在尝试 llc 我的 example.ll 文件时收到此消息:
llc: example.ll:12:29: error: expected value token
%1 = icmp slt i1 %cmptmp, i16 0
^
example.ll 文件:
; ModuleID = 'modulle'
define i16 @main() {
entry:
%x = alloca i16
store i16 2, i16* %x
br label %loop_condition
loop_condition: ; preds = %loop, %entry
%0 = load i16, i16* %x
%cmptmp = icmp sgt i16 %0, 1
%1 = icmp slt i1 %cmptmp, i16 0
br i1 %1, label %loop, label %while_continue
loop: ; preds = %loop_condition
br label %loop_condition
while_continue: ; preds = %loop_condition
ret i16 0
}
当我删除 i16 时一切正常,但我不知道为什么 LLVM 将其插入我的代码中。有人知道问题出在哪里吗?
---更新---
.ll 输出来自我的玩具编译器。这是 11 和 12:
行的代码
Value *cond = llvm::CmpInst::Create(llvm::Instruction::ICmp, llvm::CmpInst::ICMP_SLT, binRelOpCond, llvm::ConstantInt::get(llvm::getGlobalContext(), llvm::APInt(16, 0, true)), "", codeGenContext.getBlock());
其中 binRelOpCond 变量是:
CmpInst *compareRes = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_SGT, left, right, "cmptmp", codeGenContext.getBlock());
谢谢。
该 ll 文件格式错误。 icmp
的语法没有每个操作数的类型,只有一个类型:
<result> = icmp <cond> <ty> <op1>, <op2>
查看您在生成 ll 的注释中添加的代码,错误在于 llvm::APInt(16, 0, true)
- 您明确创建了一个 i16
类型的常量,但您只能与i1
类型的常量,因为那是 %cmptmp
的类型。不过,我不知道为什么没有断言捕捉到这一点。
我在尝试 llc 我的 example.ll 文件时收到此消息:
llc: example.ll:12:29: error: expected value token
%1 = icmp slt i1 %cmptmp, i16 0
^
example.ll 文件:
; ModuleID = 'modulle'
define i16 @main() {
entry:
%x = alloca i16
store i16 2, i16* %x
br label %loop_condition
loop_condition: ; preds = %loop, %entry
%0 = load i16, i16* %x
%cmptmp = icmp sgt i16 %0, 1
%1 = icmp slt i1 %cmptmp, i16 0
br i1 %1, label %loop, label %while_continue
loop: ; preds = %loop_condition
br label %loop_condition
while_continue: ; preds = %loop_condition
ret i16 0
}
当我删除 i16 时一切正常,但我不知道为什么 LLVM 将其插入我的代码中。有人知道问题出在哪里吗?
---更新---
.ll 输出来自我的玩具编译器。这是 11 和 12:
行的代码Value *cond = llvm::CmpInst::Create(llvm::Instruction::ICmp, llvm::CmpInst::ICMP_SLT, binRelOpCond, llvm::ConstantInt::get(llvm::getGlobalContext(), llvm::APInt(16, 0, true)), "", codeGenContext.getBlock());
其中 binRelOpCond 变量是:
CmpInst *compareRes = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_SGT, left, right, "cmptmp", codeGenContext.getBlock());
谢谢。
该 ll 文件格式错误。 icmp
的语法没有每个操作数的类型,只有一个类型:
<result> = icmp <cond> <ty> <op1>, <op2>
查看您在生成 ll 的注释中添加的代码,错误在于 llvm::APInt(16, 0, true)
- 您明确创建了一个 i16
类型的常量,但您只能与i1
类型的常量,因为那是 %cmptmp
的类型。不过,我不知道为什么没有断言捕捉到这一点。