Question

I want to add the following line to my llvm code (as specified in the ptx backend documentation):

%1 = internal addrspace(3) global [4 x i32] [ i32 0, i32 1, i32 2, i32 3 ]

However, I get the following error:

expected instruction opcode
@g = internal addrspace(3) global [4 x i32] [ i32 0, i32 1, i32 2, i32 3 ]
^

What am I doing wrong?

Was it helpful?

Solution

The line you want to add and the line on which the error is reported are not the same - I'm guessing a copy-paste error?

In any case, the first line is illegal, because you're defining a global with a local name (starting with % instead of @). The second line is legal by itself but from the error message I'm guessing you tried to write it inside a function, which is not a legal location for a global. Just like globals in C, LLVM globals need to be defined directly in the module scope, outside any function definition.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top