Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将以下行添加到我的 llvm 代码中(在ptx 后端文档中指定):
%1 = internal addrspace(3) global [4 x i32] [ i32 0, i32 1, i32 2, i32 3 ]
但是,我收到以下错误:
expected instruction opcode @g = internal addrspace(3) global [4 x i32] [ i32 0, i32 1, i32 2, i32 3 ] ^
我究竟做错了什么?
您要添加的行和报告错误的行不一样 - 我猜是复制粘贴错误?
在任何情况下,第一行都是非法的,因为您正在定义一个具有本地名称的全局名称(以%代替开头@)。第二行本身是合法的,但从错误消息中我猜你试图将它写在一个函数中,这不是全局的合法位置。就像 C 中的全局变量一样,LLVM 全局变量需要直接在模块范围内定义,在任何函数定义之外。
%
@