LLVM assembly: assign integer constant to register

Viewed 6376

I'm writing a compiler that uses LLVM as a backend, and my compiler generates the following LLVM assembly code

@0 = private constant [25 x i8] c"Hello World to %dntegers\00"

declare void @printf (i8*, i32)

define void @main () {
  %1 = getelementptr [25 x i8]* @0, i32 0, i32 0
  %2 = 1
  tail call void @printf(i8* %1, i32 %2)
  ret void
}

But I get the following error:

c.ll:8:8: error: expected instruction opcode
  %2 = 1
       ^

The documentation shows examples like that though.

Do you know how to get this to work? Currently, I'm using instead:

  %2 = add i32 0, 1 ; FIXME
1 Answers
Related