Skip to content

Instantly share code, notes, and snippets.

@aguinet
Created December 12, 2016 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aguinet/5e2af8c6cb2f6d3b5bcd9b6c285b197e to your computer and use it in GitHub Desktop.
Save aguinet/5e2af8c6cb2f6d3b5bcd9b6c285b197e to your computer and use it in GitHub Desktop.
llvmlite {load,store}_reg example
import llvmlite.ir as ll
module = ll.Module()
Int64 = ll.IntType(64)
fntype = ll.FunctionType(ll.VoidType(), [])
func = ll.Function(module, fntype, name='foo')
BB = func.append_basic_block()
builder = ll.IRBuilder()
builder.position_at_end(BB)
rdi = builder.load_reg(Int64, "rdi")
ret = builder.xor(rdi, ll.Constant(ll.IntType(64), 44))
builder.store_reg(ret, Int64, "rax")
builder.ret_void()
print(module)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment