LLVM arithmetic

xsq <- mul x x x5 <- mul 5 x r1 <- sub xsq x5 r <- add r1 6

r <- x^2 - 5*x + 6

add

Value a -> Value a -> CodeGenFunction r (Value a)

CodeGenFunction

r

ret

So we want to compute-5+6 using the Haskell LLVM bindings. It would look some something like this.Not very readable, it would be nicer to writeBut, e.g., theinstruction has the (simplified) type, whereis the monad for generating code for a function. (BTW, thetype variable is used to keep track of the return type of the function, used by theinstruction.)

We can't change the return type of add , but we can change the argument type.