Created
December 12, 2016 10:21
-
-
Save aguinet/5e2af8c6cb2f6d3b5bcd9b6c285b197e to your computer and use it in GitHub Desktop.
llvmlite {load,store}_reg example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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