Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. """
  2. This file demonstrates a trivial function "fpadd" returning the sum of
  3. two floating-point numbers.
  4. """
  5.  
  6. from llvmlite import ir
  7.  
  8. # Create some useful types
  9. double = ir.DoubleType()
  10. fnty = ir.FunctionType(double, (double, double))
  11.  
  12. # Create an empty module...
  13. module = ir.Module(name=__file__)
  14. # and declare a function named "fpadd" inside it
  15. func = ir.Function(module, fnty, name="fpadd")
  16.  
  17. # Now implement the function
  18. block = func.append_basic_block(name="entry")
  19. builder = ir.IRBuilder(block)
  20. a, b = func.args
  21. result = builder.fadd(a, b, name="res")
  22. builder.ret(result)
  23.  
  24. # Print the module IR
  25. print(module)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement