Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- This file demonstrates a trivial function "fpadd" returning the sum of
- two floating-point numbers.
- """
- from llvmlite import ir
- # Create some useful types
- double = ir.DoubleType()
- fnty = ir.FunctionType(double, (double, double))
- # Create an empty module...
- module = ir.Module(name=__file__)
- # and declare a function named "fpadd" inside it
- func = ir.Function(module, fnty, name="fpadd")
- # Now implement the function
- block = func.append_basic_block(name="entry")
- builder = ir.IRBuilder(block)
- a, b = func.args
- result = builder.fadd(a, b, name="res")
- builder.ret(result)
- # Print the module IR
- print(module)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement