File: examples.rst

package info (click to toggle)
llvmlite 0.46.0-0.1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,140 kB
  • sloc: python: 13,605; cpp: 3,192; makefile: 185; sh: 168
file content (30 lines) | stat: -rw-r--r-- 720 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
====================================
Example---defining a simple function
====================================

.. _ir-fpadd:

This example defines a function that adds 2 double-precision, 
floating-point numbers.

.. literalinclude:: ../examples/ir_fpadd.py

The generated LLVM 
:ref:`intermediate representation <intermediate representation>` 
is printed at the end:

.. code-block:: llvm

   ; ModuleID = "examples/ir_fpadd.py"
   target triple = "unknown-unknown-unknown"
   target datalayout = ""

   define double @"fpadd"(double %".1", double %".2")
   {
   entry:
     %"res" = fadd double %".1", %".2"
     ret double %"res"
   }

To learn how to compile and execute this function, see 
:doc:`../binding/index`.