Пример #1
0
    def test_bitcode_roundtrip(self):
        # create a new context to avoid struct renaming
        context1 = llvm.create_context()
        bc = self.module(context=context1).as_bitcode()
        context2 = llvm.create_context()
        mod = llvm.parse_bitcode(bc, context2)
        self.assertEqual(mod.as_bitcode(), bc)

        mod.get_function("sum")
        mod.get_global_variable("glob")
Пример #2
0
import sys
import ctypes
from slr import SLRParser
from AST import asts, AST, flattenLists
from varClasses import NamedType, FunType
from semantic import errorCheck
from symTable import SymbolTable, NamedSymbolTable

from llvmlite import ir, binding
from ctypes import CFUNCTYPE, c_double, c_int

import llvmlite

b = binding.create_context()

i64 = ir.IntType(64)
fp = ir.DoubleType()
boolean = ir.IntType(1)
unit = 'll_unit'

module = ir.Module(name='Default')
fnty = ir.FunctionType(ir.VoidType(), ())
ext_func = ir.Function(module, fnty, name='test')
fnty = ir.FunctionType(i64, (i64,))
runtime_my_malloc = ir.Function(module, fnty, name='My_Malloc')
fnty = ir.FunctionType(i64, (i64,))
runtime_print_int = ir.Function(module, fnty, name = 'Print_int')
t_data = binding.create_target_data('e-m:o-i64:64-f80:128-n8:16:32:64-S128')

def gen_unit(t):
    return t(None)