[pypy-svn] r25375 - in pypy/dist/pypy/translator/llvm/pyllvm: . test
ericvrp at codespeak.net
ericvrp at codespeak.net
Wed Apr 5 13:58:08 CEST 2006
Author: ericvrp
Date: Wed Apr 5 13:57:58 2006
New Revision: 25375
Added:
pypy/dist/pypy/translator/llvm/pyllvm/
pypy/dist/pypy/translator/llvm/pyllvm/__init__.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pyllvm/autopath.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pyllvm/cc.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pyllvm/create_llvmcapi.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pyllvm/helper.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pyllvm/llvmcapi.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pyllvm/pyllvm.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pyllvm/test/
pypy/dist/pypy/translator/llvm/pyllvm/test/__init__.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pyllvm/test/addnumbers.c
pypy/dist/pypy/translator/llvm/pyllvm/test/addnumbers.s
pypy/dist/pypy/translator/llvm/pyllvm/test/hello.c
pypy/dist/pypy/translator/llvm/pyllvm/test/hello.s
pypy/dist/pypy/translator/llvm/pyllvm/test/ll_snippet.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pyllvm/test/test_ee.py (contents, props changed)
Log:
Add the new ctypes based pyllvm again.
Using svn --force is not adviseable as I find out the hard way.
Added: pypy/dist/pypy/translator/llvm/pyllvm/__init__.py
==============================================================================
Added: pypy/dist/pypy/translator/llvm/pyllvm/autopath.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pyllvm/autopath.py Wed Apr 5 13:57:58 2006
@@ -0,0 +1,120 @@
+"""
+self cloning, automatic path configuration
+
+copy this into any subdirectory of pypy from which scripts need
+to be run, typically all of the test subdirs.
+The idea is that any such script simply issues
+
+ import autopath
+
+and this will make sure that the parent directory containing "pypy"
+is in sys.path.
+
+If you modify the master "autopath.py" version (in pypy/tool/autopath.py)
+you can directly run it which will copy itself on all autopath.py files
+it finds under the pypy root directory.
+
+This module always provides these attributes:
+
+ pypydir pypy root directory path
+ this_dir directory where this autopath.py resides
+
+"""
+
+
+def __dirinfo(part):
+ """ return (partdir, this_dir) and insert parent of partdir
+ into sys.path. If the parent directories don't have the part
+ an EnvironmentError is raised."""
+
+ import sys, os
+ try:
+ head = this_dir = os.path.realpath(os.path.dirname(__file__))
+ except NameError:
+ head = this_dir = os.path.realpath(os.path.dirname(sys.argv[0]))
+
+ while head:
+ partdir = head
+ head, tail = os.path.split(head)
+ if tail == part:
+ break
+ else:
+ raise EnvironmentError, "'%s' missing in '%r'" % (partdir, this_dir)
+
+ checkpaths = sys.path[:]
+ pypy_root = os.path.join(head, '')
+
+ while checkpaths:
+ orig = checkpaths.pop()
+ fullorig = os.path.join(os.path.realpath(orig), '')
+ if fullorig.startswith(pypy_root):
+ if os.path.exists(os.path.join(fullorig, '__init__.py')):
+ sys.path.remove(orig)
+ try:
+ sys.path.remove(head)
+ except ValueError:
+ pass
+ sys.path.insert(0, head)
+
+ munged = {}
+ for name, mod in sys.modules.items():
+ fn = getattr(mod, '__file__', None)
+ if '.' in name or not isinstance(fn, str):
+ continue
+ newname = os.path.splitext(os.path.basename(fn))[0]
+ if not newname.startswith(part + '.'):
+ continue
+ path = os.path.join(os.path.dirname(os.path.realpath(fn)), '')
+ if path.startswith(pypy_root) and newname != part:
+ modpaths = os.path.normpath(path[len(pypy_root):]).split(os.sep)
+ if newname != '__init__':
+ modpaths.append(newname)
+ modpath = '.'.join(modpaths)
+ if modpath not in sys.modules:
+ munged[modpath] = mod
+
+ for name, mod in munged.iteritems():
+ if name not in sys.modules:
+ sys.modules[name] = mod
+ if '.' in name:
+ prename = name[:name.rfind('.')]
+ postname = name[len(prename)+1:]
+ if prename not in sys.modules:
+ __import__(prename)
+ if not hasattr(sys.modules[prename], postname):
+ setattr(sys.modules[prename], postname, mod)
+
+ return partdir, this_dir
+
+def __clone():
+ """ clone master version of autopath.py into all subdirs """
+ from os.path import join, walk
+ if not this_dir.endswith(join('pypy','tool')):
+ raise EnvironmentError("can only clone master version "
+ "'%s'" % join(pypydir, 'tool',_myname))
+
+
+ def sync_walker(arg, dirname, fnames):
+ if _myname in fnames:
+ fn = join(dirname, _myname)
+ f = open(fn, 'rwb+')
+ try:
+ if f.read() == arg:
+ print "checkok", fn
+ else:
+ print "syncing", fn
+ f = open(fn, 'w')
+ f.write(arg)
+ finally:
+ f.close()
+ s = open(join(pypydir, 'tool', _myname), 'rb').read()
+ walk(pypydir, sync_walker, s)
+
+_myname = 'autopath.py'
+
+# set guaranteed attributes
+
+pypydir, this_dir = __dirinfo('pypy')
+
+if __name__ == '__main__':
+ __clone()
Added: pypy/dist/pypy/translator/llvm/pyllvm/cc.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pyllvm/cc.py Wed Apr 5 13:57:58 2006
@@ -0,0 +1,21 @@
+'''
+Added this because ctypes on my computer was missing cdecl.
+'''
+from ctypes import *
+
+class cdecl(object):
+ def __init__(self, restype, libname, argtypes):
+ d = __file__[:__file__.find("pyllvm")] + "llvmcapi/"
+ #XXX does this load once or every time?
+ try:
+ self.library = cdll.load(d + libname + ".so")
+ except:
+ raise Exception("llvmcapi not found: run 'python setup.py build_ext -i' in " + d)
+ self.restype = restype
+ self.argtypes = argtypes
+
+ def __call__(self, func):
+ func._api_ = getattr(self.library, func.__name__)
+ func._api_.restype = self.restype
+ func._api_.argtypes = self.argtypes
+ return func
Added: pypy/dist/pypy/translator/llvm/pyllvm/create_llvmcapi.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pyllvm/create_llvmcapi.py Wed Apr 5 13:57:58 2006
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+import os
+
+WRAPDIR = "/Users/eric/projects/ctypes/ctypes/wrap" #XXX get rid of this hardcoded path
+
+if os.path.exists(WRAPDIR + "/h2xml.py"):
+ print "h2xml.py"
+ os.system("python " + WRAPDIR + "/h2xml.py ../llvmcapi/include/llvmcapi.h -q -I. -I/opt/local/include -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -o llvmcapi.xml")
+ print "xml2py.py"
+ os.system("python " + WRAPDIR + "/xml2py.py llvmcapi.xml -l ../llvmcapi/llvmcapi.so -o llvmcapi.tmp1")
+ print "massage output"
+ os.system("sed -e s/from\ ctypes\ import/from\ cc\ import/ llvmcapi.tmp1 > llvmcapi.tmp2")
+ os.system("sed -e s/assert\ alignment.*// llvmcapi.tmp2 > llvmcapi.py")
+ print "cleanup some files"
+ os.system("rm -f llvmcapi.tmp* llvmcapi.xml")
+ print "created llvmcapi.py"
+else:
+ print "skipping llvmcapi.py creation"
Added: pypy/dist/pypy/translator/llvm/pyllvm/helper.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pyllvm/helper.py Wed Apr 5 13:57:58 2006
@@ -0,0 +1,83 @@
+'''
+Added this because ctypes on my computer was missing cdecl.
+'''
+from llvmcapi import *
+
+class Method(object):
+ def __init__(self, instance, method):
+ self.instance = instance
+ self.method = method
+
+ def __call__(self, *args):
+ a = [self.instance]
+ for arg in args:
+ if isinstance(arg, Wrapper): #pass on value to actual C (not Python) object
+ a.append(arg.instance)
+ else:
+ a.append(arg)
+ return apply(self.method, a)
+
+class Wrapper(object):
+ def __getattr__(self, name):
+ global_funcname = self.__class__.__name__ + "_" + name
+ return Method(self.instance, globals()[global_funcname])
+
+
+def to_llvm_value(pythonvalue, type_):
+ value = GenericValue_()
+ value.LongVal = 0
+ id_ = type_.getTypeID()
+ if id_ == PointerTyID and type_.getContainedType(0).getTypeID() == SByteTyID:
+ value.PointerVal = pointer(pythonvalue)
+ elif id_ == VoidTyID:
+ pass
+ elif id_ == BoolTyID:
+ value.BoolVal = pythonvalue
+ elif id_ == UByteTyID:
+ value.UByteVal = pythonvalue
+ elif id_ == SByteTyID:
+ value.SByteVal = pythonvalue
+ elif id_ == UShortTyID:
+ value.UShortVal = pythonvalue
+ elif id_ == ShortTyID:
+ value.ShortVal = pythonvalue
+ elif id_ == UIntTyID:
+ value.UIntVal = pythonvalue
+ elif id_ == IntTyID:
+ value.IntVal = pythonvalue
+ elif id_ == ULongTyID:
+ value.ULongVal = pythonvalue
+ elif id_ == LongTyID:
+ value.ULongVal = pythonvalue
+ else:
+ raise Exception("don't know how to convert pythontype '%s' to llvm" % type_.getDescription())
+ return value
+
+
+def to_python_value(llvmvalue, type_):
+ value = GenericValue_()
+ value.LongVal = llvmvalue # XXX convert llvmvalue from long long
+ id_ = type_.getTypeID()
+ if id_ == PointerTyID and type_.getContainedType(0).getTypeID() == SByteTyID:
+ return STRING(value.PointerVal).value
+ elif id_ == VoidTyID:
+ return None
+ elif id_ == BoolTyID:
+ return value.BoolVal
+ elif id_ == UByteTyID:
+ return value.UByteVal
+ elif id_ == SByteTyID:
+ return value.SByteVal
+ elif id_ == UShortTyID:
+ return value.UShortVal
+ elif id_ == ShortTyID:
+ return value.ShortVal
+ elif id_ == UIntTyID:
+ return value.UIntVal
+ elif id_ == IntTyID:
+ return value.IntVal
+ elif id_ == ULongTyID:
+ return value.ULongVal
+ elif id_ == LongTyID:
+ return value.ULongVal
+ raise Exception("don't know how to convert llvmtype '%s' to python" % type_.getDescription())
Added: pypy/dist/pypy/translator/llvm/pyllvm/llvmcapi.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pyllvm/llvmcapi.py Wed Apr 5 13:57:58 2006
@@ -0,0 +1,225 @@
+# generated by 'xml2py'
+# flags 'llvmcapi.xml -l ../llvmcapi/llvmcapi.so -o llvmcapi.tmp1'
+from cc import *
+STRING = c_char_p
+
+
+UShortTyID = 4
+FirstDerivedTyID = 13
+FunctionTyID = 13
+ShortTyID = 5
+LabelTyID = 12
+UIntTyID = 6
+ArrayTyID = 15
+IntTyID = 7
+PointerTyID = 16
+ULongTyID = 8
+LongTyID = 9
+BoolTyID = 1
+StructTyID = 14
+PackedTyID = 18
+FloatTyID = 10
+NumTypeIDs = 19
+UByteTyID = 2
+VoidTyID = 0
+SByteTyID = 3
+OpaqueTyID = 17
+LastPrimitiveTyID = 12
+DoubleTyID = 11
+
+def ExecutionEngine__create__(MP, ForceInterpreter):
+ # ../llvmcapi/include/ExecutionEngine/ExecutionEngine.h 12
+ return ExecutionEngine__create__._api_(MP, ForceInterpreter)
+ExecutionEngine__create__ = cdecl(c_void_p, 'llvmcapi', [c_void_p, c_int]) (ExecutionEngine__create__)
+
+
+def ExecutionEngine_getModule(EE):
+ # ../llvmcapi/include/ExecutionEngine/ExecutionEngine.h 13
+ return ExecutionEngine_getModule._api_(EE)
+ExecutionEngine_getModule = cdecl(c_void_p, 'llvmcapi', [c_void_p]) (ExecutionEngine_getModule)
+
+
+def ExecutionEngine_freeMachineCodeForFunction(EE, F):
+ # ../llvmcapi/include/ExecutionEngine/ExecutionEngine.h 14
+ return ExecutionEngine_freeMachineCodeForFunction._api_(EE, F)
+ExecutionEngine_freeMachineCodeForFunction = cdecl(None, 'llvmcapi', [c_void_p, c_void_p]) (ExecutionEngine_freeMachineCodeForFunction)
+
+
+def ExecutionEngine_runFunction(EE, F, A):
+ # ../llvmcapi/include/ExecutionEngine/ExecutionEngine.h 17
+ return ExecutionEngine_runFunction._api_(EE, F, A)
+ExecutionEngine_runFunction = cdecl(c_longlong, 'llvmcapi', [c_void_p, c_void_p, c_void_p]) (ExecutionEngine_runFunction)
+
+# ../llvmcapi/include/ExecutionEngine/GenericValue.h 20
+class GenericValue_(Union):
+ pass
+# ../llvmcapi/include/ExecutionEngine/GenericValue.h 32
+class N13GenericValue_3DOLLAR_0E(Structure):
+ pass
+N13GenericValue_3DOLLAR_0E._fields_ = [
+ # ../llvmcapi/include/ExecutionEngine/GenericValue.h 32
+ ('first', c_uint),
+ ('second', c_uint),
+]
+assert sizeof(N13GenericValue_3DOLLAR_0E) == 8, sizeof(N13GenericValue_3DOLLAR_0E)
+
+GenericValue_._fields_ = [
+ # ../llvmcapi/include/ExecutionEngine/GenericValue.h 20
+ ('BoolVal', c_byte),
+ ('UByteVal', c_ubyte),
+ ('SByteVal', c_byte),
+ ('UShortVal', c_ushort),
+ ('ShortVal', c_short),
+ ('UIntVal', c_uint),
+ ('IntVal', c_int),
+ ('ULongVal', c_ulonglong),
+ ('LongVal', c_longlong),
+ ('DoubleVal', c_double),
+ ('FloatVal', c_float),
+ ('UIntPairVal', N13GenericValue_3DOLLAR_0E),
+ ('PointerVal', c_void_p),
+ ('Untyped', c_ubyte * 8),
+]
+assert sizeof(GenericValue_) == 8, sizeof(GenericValue_)
+
+
+def GenericValue__init__():
+ # ../llvmcapi/include/ExecutionEngine/GenericValue.h 37
+ return GenericValue__init__._api_()
+GenericValue__init__ = cdecl(c_void_p, 'llvmcapi', []) (GenericValue__init__)
+
+
+def FunctionType_getNumParams(FT):
+ # ../llvmcapi/include/VMCore/DerivedTypes.h 8
+ return FunctionType_getNumParams._api_(FT)
+FunctionType_getNumParams = cdecl(c_int, 'llvmcapi', [c_void_p]) (FunctionType_getNumParams)
+
+
+def FunctionType_getParamType(FT, i):
+ # ../llvmcapi/include/VMCore/DerivedTypes.h 9
+ return FunctionType_getParamType._api_(FT, i)
+FunctionType_getParamType = cdecl(c_void_p, 'llvmcapi', [c_void_p, c_int]) (FunctionType_getParamType)
+
+
+def FunctionType_getReturnType(FT):
+ # ../llvmcapi/include/VMCore/DerivedTypes.h 10
+ return FunctionType_getReturnType._api_(FT)
+FunctionType_getReturnType = cdecl(c_void_p, 'llvmcapi', [c_void_p]) (FunctionType_getReturnType)
+
+
+def Function_eraseFromParent(F):
+ # ../llvmcapi/include/VMCore/Function.h 8
+ return Function_eraseFromParent._api_(F)
+Function_eraseFromParent = cdecl(None, 'llvmcapi', [c_void_p]) (Function_eraseFromParent)
+
+
+def Function_getFunctionType(F):
+ # ../llvmcapi/include/VMCore/Function.h 9
+ return Function_getFunctionType._api_(F)
+Function_getFunctionType = cdecl(c_void_p, 'llvmcapi', [c_void_p]) (Function_getFunctionType)
+
+
+def Module__init__(ModuleID):
+ # ../llvmcapi/include/VMCore/Module.h 8
+ return Module__init__._api_(ModuleID)
+Module__init__ = cdecl(c_void_p, 'llvmcapi', [STRING]) (Module__init__)
+
+
+def Module_getModuleIdentifier(M):
+ # ../llvmcapi/include/VMCore/Module.h 9
+ return Module_getModuleIdentifier._api_(M)
+Module_getModuleIdentifier = cdecl(STRING, 'llvmcapi', [c_void_p]) (Module_getModuleIdentifier)
+
+
+def Module_setModuleIdentifier(M, ID):
+ # ../llvmcapi/include/VMCore/Module.h 10
+ return Module_setModuleIdentifier._api_(M, ID)
+Module_setModuleIdentifier = cdecl(None, 'llvmcapi', [c_void_p, STRING]) (Module_setModuleIdentifier)
+
+
+def Module_getTargetTriple(M):
+ # ../llvmcapi/include/VMCore/Module.h 11
+ return Module_getTargetTriple._api_(M)
+Module_getTargetTriple = cdecl(STRING, 'llvmcapi', [c_void_p]) (Module_getTargetTriple)
+
+
+def Module_setTargetTriple(M, T):
+ # ../llvmcapi/include/VMCore/Module.h 12
+ return Module_setTargetTriple._api_(M, T)
+Module_setTargetTriple = cdecl(None, 'llvmcapi', [c_void_p, STRING]) (Module_setTargetTriple)
+
+
+def Module_getModuleInlineAsm(M):
+ # ../llvmcapi/include/VMCore/Module.h 13
+ return Module_getModuleInlineAsm._api_(M)
+Module_getModuleInlineAsm = cdecl(STRING, 'llvmcapi', [c_void_p]) (Module_getModuleInlineAsm)
+
+
+def Module_setModuleInlineAsm(M, Asm):
+ # ../llvmcapi/include/VMCore/Module.h 14
+ return Module_setModuleInlineAsm._api_(M, Asm)
+Module_setModuleInlineAsm = cdecl(None, 'llvmcapi', [c_void_p, STRING]) (Module_setModuleInlineAsm)
+
+
+def Module_getNamedFunction(M, fnname):
+ # ../llvmcapi/include/VMCore/Module.h 15
+ return Module_getNamedFunction._api_(M, fnname)
+Module_getNamedFunction = cdecl(c_void_p, 'llvmcapi', [c_void_p, STRING]) (Module_getNamedFunction)
+
+
+def Module_ParseAssemblyString(M, AsmString):
+ # ../llvmcapi/include/VMCore/Module.h 18
+ return Module_ParseAssemblyString._api_(M, AsmString)
+Module_ParseAssemblyString = cdecl(None, 'llvmcapi', [c_void_p, STRING]) (Module_ParseAssemblyString)
+
+
+def Module_verifyModule(M):
+ # ../llvmcapi/include/VMCore/Module.h 19
+ return Module_verifyModule._api_(M)
+Module_verifyModule = cdecl(c_int, 'llvmcapi', [c_void_p]) (Module_verifyModule)
+
+
+def Module_n_functions(M):
+ # ../llvmcapi/include/VMCore/Module.h 22
+ return Module_n_functions._api_(M)
+Module_n_functions = cdecl(c_int, 'llvmcapi', [c_void_p]) (Module_n_functions)
+
+
+def Module_function_exists(M, fnname):
+ # ../llvmcapi/include/VMCore/Module.h 23
+ return Module_function_exists._api_(M, fnname)
+Module_function_exists = cdecl(c_int, 'llvmcapi', [c_void_p, STRING]) (Module_function_exists)
+
+
+def ExistingModuleProvider__init__(M):
+ # ../llvmcapi/include/VMCore/ModuleProvider.h 8
+ return ExistingModuleProvider__init__._api_(M)
+ExistingModuleProvider__init__ = cdecl(c_void_p, 'llvmcapi', [c_void_p]) (ExistingModuleProvider__init__)
+
+
+# values for enumeration 'TypeID'
+TypeID = c_int # enum
+
+def Type_getTypeID(T):
+ # ../llvmcapi/include/VMCore/Type.h 32
+ return Type_getTypeID._api_(T)
+Type_getTypeID = cdecl(TypeID, 'llvmcapi', [c_void_p]) (Type_getTypeID)
+
+
+def Type_getContainedType(T, n):
+ # ../llvmcapi/include/VMCore/Type.h 33
+ return Type_getContainedType._api_(T, n)
+Type_getContainedType = cdecl(c_void_p, 'llvmcapi', [c_void_p, c_int]) (Type_getContainedType)
+
+
+def Type_getDescription(T):
+ # ../llvmcapi/include/VMCore/Type.h 34
+ return Type_getDescription._api_(T)
+Type_getDescription = cdecl(STRING, 'llvmcapi', [c_void_p]) (Type_getDescription)
+
+
+def toggle_print_machineinstrs():
+ # ../llvmcapi/include/llvmcapi.h 16
+ return toggle_print_machineinstrs._api_()
+toggle_print_machineinstrs = cdecl(None, 'llvmcapi', []) (toggle_print_machineinstrs)
+
Added: pypy/dist/pypy/translator/llvm/pyllvm/pyllvm.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pyllvm/pyllvm.py Wed Apr 5 13:57:58 2006
@@ -0,0 +1,101 @@
+from helper import *
+
+
+class Module(Wrapper):
+ def __init__(self, ModuleID='mymodule'):
+ self.instance = Module__init__(ModuleID)
+
+ def getNamedFunction(self, fnname):
+ f = object.__new__(Function)
+ f.instance = Module_getNamedFunction(self.instance, fnname)
+ return f
+
+
+class ExistingModuleProvider(Wrapper):
+ def __init__(self, M=None):
+ if not M:
+ M = Module()
+ self.instance = ExistingModuleProvider__init__(M.instance)
+
+global ee_hack
+
+class ExecutionEngine(Wrapper):
+ def __init__(self, MP=None, ForceInterpreter=False):
+ if not MP:
+ MP = ExistingModuleProvider();
+ self.instance = ExecutionEngine__create__(MP.instance, ForceInterpreter)
+ global ee_hack
+ ee_hack = self.instance #XXX how to get to the executionengine from a function?
+
+ # XXX cast to actual Python Module (can't we automate this?)
+ def getModule(self):
+ m = object.__new__(Module)
+ m.instance = ExecutionEngine_getModule(self.instance)
+ return m
+
+ # helpers
+ def parse(self, llcode, fnname=None):
+ mod = self.getModule()
+ mod.ParseAssemblyString(llcode)
+ mod.verifyModule()
+
+ def delete(self, fnname):
+ mod = self.getModule()
+ f = mod.getNamedFunction(fnname) # XXX handle fnname not found?
+ self.freeMachineCodeForFunction(f) # still no-op on march 27th 2006
+ f.eraseFromParent()
+
+
+class Function(Wrapper):
+ def __init__(self):
+ self.instance = Function__init__() #XXX this get annoying quickly
+
+ def __call__(self, *args):
+ #print 'calling %s(%s)' % ('Function', ','.join([str(arg) for arg in args]))
+ ft = self.getFunctionType()
+ argcount = ft.getNumParams()
+ #print 'argcount = ',argcounT
+ if argcount != len(args):
+ raise Exception("incorrect number of parameters")
+ ParamType = c_longlong * argcount
+ llvmvalues = ParamType()
+ for i, arg in enumerate(args):
+ llvmvalues[i] = to_llvm_value(arg, ft.getParamType(i)).LongVal
+ pLlvmValues = cast(llvmvalues, c_void_p) #would like to cast to c_longlong_p
+ llvmreturnvalue = ExecutionEngine_runFunction(ee_hack, self.instance, pLlvmValues)
+ return to_python_value(llvmreturnvalue, ft.getReturnType())
+
+ def getFunctionType(self):
+ ft = object.__new__(FunctionType)
+ ft.instance = Function_getFunctionType(self.instance)
+ return ft
+
+
+class GenericValue(Wrapper):
+ def __init(self):
+ self.instance = GenericValue__init__()
+
+
+class Type(Wrapper):
+ def __init(self):
+ self.instance = Type__init__()
+
+ def getContainedType(self, n):
+ t = object.__new__(Type)
+ t.instance = Type_getContainedType(self.instance, n)
+ return t
+
+
+class FunctionType(Wrapper):
+ def __init(self):
+ self.instance = FunctionType__init__()
+
+ def getReturnType(self):
+ t = object.__new__(Type)
+ t.instance = FunctionType_getReturnType(self.instance)
+ return t
+
+ def getParamType(self, i):
+ t = object.__new__(Type)
+ t.instance = FunctionType_getParamType(self.instance, i)
+ return t
Added: pypy/dist/pypy/translator/llvm/pyllvm/test/__init__.py
==============================================================================
Added: pypy/dist/pypy/translator/llvm/pyllvm/test/addnumbers.c
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pyllvm/test/addnumbers.c Wed Apr 5 13:57:58 2006
@@ -0,0 +1,4 @@
+int add(int n, int y) {
+ return n + y;
+}
+
Added: pypy/dist/pypy/translator/llvm/pyllvm/test/addnumbers.s
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pyllvm/test/addnumbers.s Wed Apr 5 13:57:58 2006
@@ -0,0 +1,441 @@
+; GNU C version 3.4-llvm 20051104 (LLVM 1.6) (i686-pc-linux-gnu)
+; compiled by GNU C version 3.4.0.
+; GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
+; options passed: -iprefix -mtune=pentiumpro -auxbase
+; options enabled: -feliminate-unused-debug-types -fpeephole
+; -ffunction-cse -fkeep-static-consts -fpcc-struct-return -fgcse-lm
+; -fgcse-sm -fsched-interblock -fsched-spec -fbranch-count-reg -fcommon
+; -fgnu-linker -fargument-alias -fzero-initialized-in-bss -fident
+; -fmath-errno -ftrapping-math -m80387 -mhard-float -mno-soft-float
+; -mieee-fp -mfp-ret-in-387 -maccumulate-outgoing-args -mno-red-zone
+; -mtls-direct-seg-refs -mtune=pentiumpro -march=i386
+
+target triple = "i686-pc-linux-gnu"
+target pointersize = 32
+target endian = little
+deplibs = ["c", "crtend"]
+
+"complex double" = type { double, double }
+"complex float" = type { float, float }
+"complex long double" = type { double, double }
+
+implementation
+declare double %acos(double) ;; __builtin_acos
+declare float %acosf(float) ;; __builtin_acosf
+declare double %acosh(double) ;; __builtin_acosh
+declare float %acoshf(float) ;; __builtin_acoshf
+declare double %acoshl(double) ;; __builtin_acoshl
+declare double %acosl(double) ;; __builtin_acosl
+declare double %asin(double) ;; __builtin_asin
+declare float %asinf(float) ;; __builtin_asinf
+declare double %asinh(double) ;; __builtin_asinh
+declare float %asinhf(float) ;; __builtin_asinhf
+declare double %asinhl(double) ;; __builtin_asinhl
+declare double %asinl(double) ;; __builtin_asinl
+declare double %atan(double) ;; __builtin_atan
+declare double %atan2(double,double) ;; __builtin_atan2
+declare float %atan2f(float,float) ;; __builtin_atan2f
+declare double %atan2l(double,double) ;; __builtin_atan2l
+declare float %atanf(float) ;; __builtin_atanf
+declare double %atanh(double) ;; __builtin_atanh
+declare float %atanhf(float) ;; __builtin_atanhf
+declare double %atanhl(double) ;; __builtin_atanhl
+declare double %atanl(double) ;; __builtin_atanl
+declare double %cbrt(double) ;; __builtin_cbrt
+declare float %cbrtf(float) ;; __builtin_cbrtf
+declare double %cbrtl(double) ;; __builtin_cbrtl
+declare double %ceil(double) ;; __builtin_ceil
+declare float %ceilf(float) ;; __builtin_ceilf
+declare double %ceill(double) ;; __builtin_ceill
+declare double %copysign(double,double) ;; __builtin_copysign
+declare float %copysignf(float,float) ;; __builtin_copysignf
+declare double %copysignl(double,double) ;; __builtin_copysignl
+declare double %cos(double) ;; __builtin_cos
+declare float %cosf(float) ;; __builtin_cosf
+declare double %cosh(double) ;; __builtin_cosh
+declare float %coshf(float) ;; __builtin_coshf
+declare double %coshl(double) ;; __builtin_coshl
+declare double %cosl(double) ;; __builtin_cosl
+declare double %drem(double,double) ;; __builtin_drem
+declare float %dremf(float,float) ;; __builtin_dremf
+declare double %dreml(double,double) ;; __builtin_dreml
+declare double %erf(double) ;; __builtin_erf
+declare double %erfc(double) ;; __builtin_erfc
+declare float %erfcf(float) ;; __builtin_erfcf
+declare double %erfcl(double) ;; __builtin_erfcl
+declare float %erff(float) ;; __builtin_erff
+declare double %erfl(double) ;; __builtin_erfl
+declare double %exp(double) ;; __builtin_exp
+declare double %exp10(double) ;; __builtin_exp10
+declare float %exp10f(float) ;; __builtin_exp10f
+declare double %exp10l(double) ;; __builtin_exp10l
+declare double %exp2(double) ;; __builtin_exp2
+declare float %exp2f(float) ;; __builtin_exp2f
+declare double %exp2l(double) ;; __builtin_exp2l
+declare float %expf(float) ;; __builtin_expf
+declare double %expl(double) ;; __builtin_expl
+declare double %expm1(double) ;; __builtin_expm1
+declare float %expm1f(float) ;; __builtin_expm1f
+declare double %expm1l(double) ;; __builtin_expm1l
+declare double %fabs(double) ;; __builtin_fabs
+declare float %fabsf(float) ;; __builtin_fabsf
+declare double %fabsl(double) ;; __builtin_fabsl
+declare double %fdim(double,double) ;; __builtin_fdim
+declare float %fdimf(float,float) ;; __builtin_fdimf
+declare double %fdiml(double,double) ;; __builtin_fdiml
+declare double %floor(double) ;; __builtin_floor
+declare float %floorf(float) ;; __builtin_floorf
+declare double %floorl(double) ;; __builtin_floorl
+declare double %fma(double,double,double) ;; __builtin_fma
+declare float %fmaf(float,float,float) ;; __builtin_fmaf
+declare double %fmal(double,double,double) ;; __builtin_fmal
+declare double %fmax(double,double) ;; __builtin_fmax
+declare float %fmaxf(float,float) ;; __builtin_fmaxf
+declare double %fmaxl(double,double) ;; __builtin_fmaxl
+declare double %fmin(double,double) ;; __builtin_fmin
+declare float %fminf(float,float) ;; __builtin_fminf
+declare double %fminl(double,double) ;; __builtin_fminl
+declare double %fmod(double,double) ;; __builtin_fmod
+declare float %fmodf(float,float) ;; __builtin_fmodf
+declare double %fmodl(double,double) ;; __builtin_fmodl
+declare double %frexp(double,int*) ;; __builtin_frexp
+declare float %frexpf(float,int*) ;; __builtin_frexpf
+declare double %frexpl(double,int*) ;; __builtin_frexpl
+declare double %gamma(double) ;; __builtin_gamma
+declare float %gammaf(float) ;; __builtin_gammaf
+declare double %gammal(double) ;; __builtin_gammal
+declare double %__builtin_huge_val()
+declare float %__builtin_huge_valf()
+declare double %__builtin_huge_vall()
+declare double %hypot(double,double) ;; __builtin_hypot
+declare float %hypotf(float,float) ;; __builtin_hypotf
+declare double %hypotl(double,double) ;; __builtin_hypotl
+declare int %ilogb(double) ;; __builtin_ilogb
+declare int %ilogbf(float) ;; __builtin_ilogbf
+declare int %ilogbl(double) ;; __builtin_ilogbl
+declare double %__builtin_inf()
+declare float %__builtin_inff()
+declare double %__builtin_infl()
+declare double %j0(double) ;; __builtin_j0
+declare float %j0f(float) ;; __builtin_j0f
+declare double %j0l(double) ;; __builtin_j0l
+declare double %j1(double) ;; __builtin_j1
+declare float %j1f(float) ;; __builtin_j1f
+declare double %j1l(double) ;; __builtin_j1l
+declare double %jn(int,double) ;; __builtin_jn
+declare float %jnf(int,float) ;; __builtin_jnf
+declare double %jnl(int,double) ;; __builtin_jnl
+declare double %ldexp(double,int) ;; __builtin_ldexp
+declare float %ldexpf(float,int) ;; __builtin_ldexpf
+declare double %ldexpl(double,int) ;; __builtin_ldexpl
+declare double %lgamma(double) ;; __builtin_lgamma
+declare float %lgammaf(float) ;; __builtin_lgammaf
+declare double %lgammal(double) ;; __builtin_lgammal
+declare long %llrint(double) ;; __builtin_llrint
+declare long %llrintf(float) ;; __builtin_llrintf
+declare long %llrintl(double) ;; __builtin_llrintl
+declare long %llround(double) ;; __builtin_llround
+declare long %llroundf(float) ;; __builtin_llroundf
+declare long %llroundl(double) ;; __builtin_llroundl
+declare double %log(double) ;; __builtin_log
+declare double %log10(double) ;; __builtin_log10
+declare float %log10f(float) ;; __builtin_log10f
+declare double %log10l(double) ;; __builtin_log10l
+declare double %log1p(double) ;; __builtin_log1p
+declare float %log1pf(float) ;; __builtin_log1pf
+declare double %log1pl(double) ;; __builtin_log1pl
+declare double %log2(double) ;; __builtin_log2
+declare float %log2f(float) ;; __builtin_log2f
+declare double %log2l(double) ;; __builtin_log2l
+declare double %logb(double) ;; __builtin_logb
+declare float %logbf(float) ;; __builtin_logbf
+declare double %logbl(double) ;; __builtin_logbl
+declare float %logf(float) ;; __builtin_logf
+declare double %logl(double) ;; __builtin_logl
+declare int %lrint(double) ;; __builtin_lrint
+declare int %lrintf(float) ;; __builtin_lrintf
+declare int %lrintl(double) ;; __builtin_lrintl
+declare int %lround(double) ;; __builtin_lround
+declare int %lroundf(float) ;; __builtin_lroundf
+declare int %lroundl(double) ;; __builtin_lroundl
+declare double %modf(double,double*) ;; __builtin_modf
+declare float %modff(float,float*) ;; __builtin_modff
+declare double %modfl(double,double*) ;; __builtin_modfl
+declare double %nan(sbyte*) ;; __builtin_nan
+declare float %nanf(sbyte*) ;; __builtin_nanf
+declare double %nanl(sbyte*) ;; __builtin_nanl
+declare double %nans(sbyte*) ;; __builtin_nans
+declare float %nansf(sbyte*) ;; __builtin_nansf
+declare double %nansl(sbyte*) ;; __builtin_nansl
+declare double %nearbyint(double) ;; __builtin_nearbyint
+declare float %nearbyintf(float) ;; __builtin_nearbyintf
+declare double %nearbyintl(double) ;; __builtin_nearbyintl
+declare double %nextafter(double,double) ;; __builtin_nextafter
+declare float %nextafterf(float,float) ;; __builtin_nextafterf
+declare double %nextafterl(double,double) ;; __builtin_nextafterl
+declare double %nexttoward(double,double) ;; __builtin_nexttoward
+declare float %nexttowardf(float,double) ;; __builtin_nexttowardf
+declare double %nexttowardl(double,double) ;; __builtin_nexttowardl
+declare double %pow(double,double) ;; __builtin_pow
+declare double %pow10(double) ;; __builtin_pow10
+declare float %pow10f(float) ;; __builtin_pow10f
+declare double %pow10l(double) ;; __builtin_pow10l
+declare float %powf(float,float) ;; __builtin_powf
+declare double %powl(double,double) ;; __builtin_powl
+declare double %remainder(double,double) ;; __builtin_remainder
+declare float %remainderf(float,float) ;; __builtin_remainderf
+declare double %remainderl(double,double) ;; __builtin_remainderl
+declare double %remquo(double,double,int*) ;; __builtin_remquo
+declare float %remquof(float,float,int*) ;; __builtin_remquof
+declare double %remquol(double,double,int*) ;; __builtin_remquol
+declare double %rint(double) ;; __builtin_rint
+declare float %rintf(float) ;; __builtin_rintf
+declare double %rintl(double) ;; __builtin_rintl
+declare double %round(double) ;; __builtin_round
+declare float %roundf(float) ;; __builtin_roundf
+declare double %roundl(double) ;; __builtin_roundl
+declare double %scalb(double,double) ;; __builtin_scalb
+declare float %scalbf(float,float) ;; __builtin_scalbf
+declare double %scalbl(double,double) ;; __builtin_scalbl
+declare double %scalbln(double,int) ;; __builtin_scalbln
+declare float %scalblnf(float,int) ;; __builtin_scalblnf
+declare double %scalblnl(double,int) ;; __builtin_scalblnl
+declare double %scalbn(double,int) ;; __builtin_scalbn
+declare float %scalbnf(float,int) ;; __builtin_scalbnf
+declare double %scalbnl(double,int) ;; __builtin_scalbnl
+declare double %significand(double) ;; __builtin_significand
+declare float %significandf(float) ;; __builtin_significandf
+declare double %significandl(double) ;; __builtin_significandl
+declare double %sin(double) ;; __builtin_sin
+declare void %sincos(double,double*,double*) ;; __builtin_sincos
+declare void %sincosf(float,float*,float*) ;; __builtin_sincosf
+declare void %sincosl(double,double*,double*) ;; __builtin_sincosl
+declare float %sinf(float) ;; __builtin_sinf
+declare double %sinh(double) ;; __builtin_sinh
+declare float %sinhf(float) ;; __builtin_sinhf
+declare double %sinhl(double) ;; __builtin_sinhl
+declare double %sinl(double) ;; __builtin_sinl
+declare double %sqrt(double) ;; __builtin_sqrt
+declare float %sqrtf(float) ;; __builtin_sqrtf
+declare double %sqrtl(double) ;; __builtin_sqrtl
+declare double %tan(double) ;; __builtin_tan
+declare float %tanf(float) ;; __builtin_tanf
+declare double %tanh(double) ;; __builtin_tanh
+declare float %tanhf(float) ;; __builtin_tanhf
+declare double %tanhl(double) ;; __builtin_tanhl
+declare double %tanl(double) ;; __builtin_tanl
+declare double %tgamma(double) ;; __builtin_tgamma
+declare float %tgammaf(float) ;; __builtin_tgammaf
+declare double %tgammal(double) ;; __builtin_tgammal
+declare double %trunc(double) ;; __builtin_trunc
+declare float %truncf(float) ;; __builtin_truncf
+declare double %truncl(double) ;; __builtin_truncl
+declare double %y0(double) ;; __builtin_y0
+declare float %y0f(float) ;; __builtin_y0f
+declare double %y0l(double) ;; __builtin_y0l
+declare double %y1(double) ;; __builtin_y1
+declare float %y1f(float) ;; __builtin_y1f
+declare double %y1l(double) ;; __builtin_y1l
+declare double %yn(int,double) ;; __builtin_yn
+declare float %ynf(int,float) ;; __builtin_ynf
+declare double %ynl(int,double) ;; __builtin_ynl
+declare double %cabs(double,double) ;; __builtin_cabs
+declare float %cabsf(float,float) ;; __builtin_cabsf
+declare double %cabsl(double,double) ;; __builtin_cabsl
+declare void %cacos("complex double"*,double,double) ;; __builtin_cacos
+declare void %cacosf("complex float"*,float,float) ;; __builtin_cacosf
+declare void %cacosh("complex double"*,double,double) ;; __builtin_cacosh
+declare void %cacoshf("complex float"*,float,float) ;; __builtin_cacoshf
+declare void %cacoshl("complex long double"*,double,double) ;; __builtin_cacoshl
+declare void %cacosl("complex long double"*,double,double) ;; __builtin_cacosl
+declare double %carg(double,double) ;; __builtin_carg
+declare float %cargf(float,float) ;; __builtin_cargf
+declare double %cargl(double,double) ;; __builtin_cargl
+declare void %casin("complex double"*,double,double) ;; __builtin_casin
+declare void %casinf("complex float"*,float,float) ;; __builtin_casinf
+declare void %casinh("complex double"*,double,double) ;; __builtin_casinh
+declare void %casinhf("complex float"*,float,float) ;; __builtin_casinhf
+declare void %casinhl("complex long double"*,double,double) ;; __builtin_casinhl
+declare void %casinl("complex long double"*,double,double) ;; __builtin_casinl
+declare void %catan("complex double"*,double,double) ;; __builtin_catan
+declare void %catanf("complex float"*,float,float) ;; __builtin_catanf
+declare void %catanh("complex double"*,double,double) ;; __builtin_catanh
+declare void %catanhf("complex float"*,float,float) ;; __builtin_catanhf
+declare void %catanhl("complex long double"*,double,double) ;; __builtin_catanhl
+declare void %catanl("complex long double"*,double,double) ;; __builtin_catanl
+declare void %ccos("complex double"*,double,double) ;; __builtin_ccos
+declare void %ccosf("complex float"*,float,float) ;; __builtin_ccosf
+declare void %ccosh("complex double"*,double,double) ;; __builtin_ccosh
+declare void %ccoshf("complex float"*,float,float) ;; __builtin_ccoshf
+declare void %ccoshl("complex long double"*,double,double) ;; __builtin_ccoshl
+declare void %ccosl("complex long double"*,double,double) ;; __builtin_ccosl
+declare void %cexp("complex double"*,double,double) ;; __builtin_cexp
+declare void %cexpf("complex float"*,float,float) ;; __builtin_cexpf
+declare void %cexpl("complex long double"*,double,double) ;; __builtin_cexpl
+declare double %cimag(double,double) ;; __builtin_cimag
+declare float %cimagf(float,float) ;; __builtin_cimagf
+declare double %cimagl(double,double) ;; __builtin_cimagl
+declare void %conj("complex double"*,double,double) ;; __builtin_conj
+declare void %conjf("complex float"*,float,float) ;; __builtin_conjf
+declare void %conjl("complex long double"*,double,double) ;; __builtin_conjl
+declare void %cpow("complex double"*,double,double,double,double) ;; __builtin_cpow
+declare void %cpowf("complex float"*,float,float,float,float) ;; __builtin_cpowf
+declare void %cpowl("complex long double"*,double,double,double,double) ;; __builtin_cpowl
+declare void %cproj("complex double"*,double,double) ;; __builtin_cproj
+declare void %cprojf("complex float"*,float,float) ;; __builtin_cprojf
+declare void %cprojl("complex long double"*,double,double) ;; __builtin_cprojl
+declare double %creal(double,double) ;; __builtin_creal
+declare float %crealf(float,float) ;; __builtin_crealf
+declare double %creall(double,double) ;; __builtin_creall
+declare void %csin("complex double"*,double,double) ;; __builtin_csin
+declare void %csinf("complex float"*,float,float) ;; __builtin_csinf
+declare void %csinh("complex double"*,double,double) ;; __builtin_csinh
+declare void %csinhf("complex float"*,float,float) ;; __builtin_csinhf
+declare void %csinhl("complex long double"*,double,double) ;; __builtin_csinhl
+declare void %csinl("complex long double"*,double,double) ;; __builtin_csinl
+declare void %csqrt("complex double"*,double,double) ;; __builtin_csqrt
+declare void %csqrtf("complex float"*,float,float) ;; __builtin_csqrtf
+declare void %csqrtl("complex long double"*,double,double) ;; __builtin_csqrtl
+declare void %ctan("complex double"*,double,double) ;; __builtin_ctan
+declare void %ctanf("complex float"*,float,float) ;; __builtin_ctanf
+declare void %ctanh("complex double"*,double,double) ;; __builtin_ctanh
+declare void %ctanhf("complex float"*,float,float) ;; __builtin_ctanhf
+declare void %ctanhl("complex long double"*,double,double) ;; __builtin_ctanhl
+declare void %ctanl("complex long double"*,double,double) ;; __builtin_ctanl
+declare int %bcmp(sbyte*,sbyte*,uint) ;; __builtin_bcmp
+declare void %bcopy(sbyte*,sbyte*,uint) ;; __builtin_bcopy
+declare void %bzero(sbyte*,uint) ;; __builtin_bzero
+declare int %ffs(int) ;; __builtin_ffs
+declare int %ffsl(int) ;; __builtin_ffsl
+declare int %ffsll(long) ;; __builtin_ffsll
+declare sbyte* %index(sbyte*,int) ;; __builtin_index
+declare int %memcmp(sbyte*,sbyte*,uint) ;; __builtin_memcmp
+declare sbyte* %memcpy(sbyte*,sbyte*,uint) ;; __builtin_memcpy
+declare sbyte* %memmove(sbyte*,sbyte*,uint) ;; __builtin_memmove
+declare sbyte* %mempcpy(sbyte*,sbyte*,uint) ;; __builtin_mempcpy
+declare sbyte* %memset(sbyte*,int,uint) ;; __builtin_memset
+declare sbyte* %rindex(sbyte*,int) ;; __builtin_rindex
+declare sbyte* %stpcpy(sbyte*,sbyte*) ;; __builtin_stpcpy
+declare sbyte* %strcat(sbyte*,sbyte*) ;; __builtin_strcat
+declare sbyte* %strchr(sbyte*,int) ;; __builtin_strchr
+declare int %strcmp(sbyte*,sbyte*) ;; __builtin_strcmp
+declare sbyte* %strcpy(sbyte*,sbyte*) ;; __builtin_strcpy
+declare uint %strcspn(sbyte*,sbyte*) ;; __builtin_strcspn
+declare sbyte* %strdup(sbyte*) ;; __builtin_strdup
+declare uint %strlen(sbyte*) ;; __builtin_strlen
+declare sbyte* %strncat(sbyte*,sbyte*,uint) ;; __builtin_strncat
+declare int %strncmp(sbyte*,sbyte*,uint) ;; __builtin_strncmp
+declare sbyte* %strncpy(sbyte*,sbyte*,uint) ;; __builtin_strncpy
+declare sbyte* %strpbrk(sbyte*,sbyte*) ;; __builtin_strpbrk
+declare sbyte* %strrchr(sbyte*,int) ;; __builtin_strrchr
+declare uint %strspn(sbyte*,sbyte*) ;; __builtin_strspn
+declare sbyte* %strstr(sbyte*,sbyte*) ;; __builtin_strstr
+declare int %fprintf(sbyte*,sbyte*, ...) ;; __builtin_fprintf
+declare int %fprintf_unlocked(sbyte*,sbyte*, ...) ;; __builtin_fprintf_unlocked
+declare int %fputc(int,sbyte*) ;; __builtin_fputc
+declare int %fputc_unlocked(int,sbyte*) ;; __builtin_fputc_unlocked
+declare int %fputs(sbyte*,sbyte*) ;; __builtin_fputs
+declare int %fputs_unlocked(sbyte*,sbyte*) ;; __builtin_fputs_unlocked
+declare int %fscanf(sbyte*,sbyte*, ...) ;; __builtin_fscanf
+declare uint %fwrite(sbyte*,uint,uint,sbyte*) ;; __builtin_fwrite
+declare uint %fwrite_unlocked(sbyte*,uint,uint,sbyte*) ;; __builtin_fwrite_unlocked
+declare int %printf(sbyte*, ...) ;; __builtin_printf
+declare int %printf_unlocked(sbyte*, ...) ;; __builtin_printf_unlocked
+declare int %putchar(int) ;; __builtin_putchar
+declare int %putchar_unlocked(int) ;; __builtin_putchar_unlocked
+declare int %puts(sbyte*) ;; __builtin_puts
+declare int %puts_unlocked(sbyte*) ;; __builtin_puts_unlocked
+declare int %scanf(sbyte*, ...) ;; __builtin_scanf
+declare int %snprintf(sbyte*,uint,sbyte*, ...) ;; __builtin_snprintf
+declare int %sprintf(sbyte*,sbyte*, ...) ;; __builtin_sprintf
+declare int %sscanf(sbyte*,sbyte*, ...) ;; __builtin_sscanf
+declare int %vfprintf(sbyte*,sbyte*,sbyte*) ;; __builtin_vfprintf
+declare int %vfscanf(sbyte*,sbyte*,sbyte*) ;; __builtin_vfscanf
+declare int %vprintf(sbyte*,sbyte*) ;; __builtin_vprintf
+declare int %vscanf(sbyte*,sbyte*) ;; __builtin_vscanf
+declare int %vsnprintf(sbyte*,uint,sbyte*,sbyte*) ;; __builtin_vsnprintf
+declare int %vsprintf(sbyte*,sbyte*,sbyte*) ;; __builtin_vsprintf
+declare int %vsscanf(sbyte*,sbyte*,sbyte*) ;; __builtin_vsscanf
+declare void %abort() ;; __builtin_abort
+declare int %abs(int) ;; __builtin_abs
+declare sbyte* %__builtin_aggregate_incoming_address(...)
+declare sbyte* %alloca(uint) ;; __builtin_alloca
+declare sbyte* %__builtin_apply(void (...)*,sbyte*,uint)
+declare sbyte* %__builtin_apply_args(...)
+declare int %__builtin_args_info(int)
+declare sbyte* %calloc(uint,uint) ;; __builtin_calloc
+declare int %__builtin_classify_type(...)
+declare int %__builtin_clz(int)
+declare int %__builtin_clzl(int)
+declare int %__builtin_clzll(long)
+declare int %__builtin_constant_p(...)
+declare int %__builtin_ctz(int)
+declare int %__builtin_ctzl(int)
+declare int %__builtin_ctzll(long)
+declare sbyte* %dcgettext(sbyte*,sbyte*,int) ;; __builtin_dcgettext
+declare sbyte* %dgettext(sbyte*,sbyte*) ;; __builtin_dgettext
+declare sbyte* %__builtin_dwarf_cfa()
+declare uint %__builtin_dwarf_sp_column()
+declare void %__builtin_eh_return(int,sbyte*)
+declare int %__builtin_eh_return_data_regno(int)
+declare void %exit(int) ;; __builtin_exit
+declare int %__builtin_expect(int,int)
+declare sbyte* %__builtin_extract_return_addr(sbyte*)
+declare sbyte* %__builtin_frame_address(uint)
+declare sbyte* %__builtin_frob_return_addr(sbyte*)
+declare sbyte* %gettext(sbyte*) ;; __builtin_gettext
+declare long %imaxabs(long) ;; __builtin_imaxabs
+declare void %__builtin_init_dwarf_reg_size_table(sbyte*)
+declare int %__builtin_isgreater(...)
+declare int %__builtin_isgreaterequal(...)
+declare int %__builtin_isless(...)
+declare int %__builtin_islessequal(...)
+declare int %__builtin_islessgreater(...)
+declare int %__builtin_isunordered(...)
+declare int %labs(int) ;; __builtin_labs
+declare long %llabs(long) ;; __builtin_llabs
+declare void %__builtin_longjmp(sbyte*,int)
+declare sbyte* %malloc(uint) ;; __builtin_malloc
+declare sbyte* %__builtin_next_arg(...)
+declare int %__builtin_parity(int)
+declare int %__builtin_parityl(int)
+declare int %__builtin_parityll(long)
+declare int %__builtin_popcount(int)
+declare int %__builtin_popcountl(int)
+declare int %__builtin_popcountll(long)
+declare void %__builtin_prefetch(sbyte*, ...)
+declare void %__builtin_return(sbyte*)
+declare sbyte* %__builtin_return_address(uint)
+declare sbyte* %__builtin_saveregs(...)
+declare int %__builtin_setjmp(sbyte*)
+declare void %__builtin_stdarg_start(sbyte**, ...)
+declare int %strfmon(sbyte*,uint,sbyte*, ...) ;; __builtin_strfmon
+declare uint %strftime(sbyte*,uint,sbyte*,sbyte*) ;; __builtin_strftime
+declare void %__builtin_trap()
+declare void %__builtin_unwind_init()
+declare void %__builtin_va_copy(sbyte**,sbyte*)
+declare void %__builtin_va_end(sbyte**)
+declare void %__builtin_va_start(sbyte**, ...)
+declare void %_exit(int) ;; __builtin__exit
+declare void %_Exit(int) ;; __builtin__Exit
+
+int %add(int %n, int %y) {
+entry:
+ %n_addr = alloca int ; ty=int*
+ %y_addr = alloca int ; ty=int*
+ %result = alloca int ; ty=int*
+ store int %n, int* %n_addr
+ store int %y, int* %y_addr
+ %tmp.0 = load int* %n_addr ; ty=int
+ %tmp.1 = load int* %y_addr ; ty=int
+ %tmp.2 = add int %tmp.0, %tmp.1 ; ty=int
+ store int %tmp.2, int* %result
+ br label %return
+after_ret:
+ br label %return
+return:
+ %tmp.3 = load int* %result ; ty=int
+ ret int %tmp.3
+}
+
+;; Created by "GCC: (GNU) 3.4-llvm 20051104 (LLVM 1.6)"
Added: pypy/dist/pypy/translator/llvm/pyllvm/test/hello.c
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pyllvm/test/hello.c Wed Apr 5 13:57:58 2006
@@ -0,0 +1,9 @@
+char *gethellostr() {
+ return "hello world\n";
+}
+
+int hello() {
+ printf(gethellostr());
+ return 0;
+}
+
Added: pypy/dist/pypy/translator/llvm/pyllvm/test/hello.s
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pyllvm/test/hello.s Wed Apr 5 13:57:58 2006
@@ -0,0 +1,451 @@
+; GNU C version 3.4-llvm 20051104 (LLVM 1.6) (i686-pc-linux-gnu)
+; compiled by GNU C version 3.4.0.
+; GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
+; options passed: -iprefix -mtune=pentiumpro -auxbase
+; options enabled: -feliminate-unused-debug-types -fpeephole
+; -ffunction-cse -fkeep-static-consts -fpcc-struct-return -fgcse-lm
+; -fgcse-sm -fsched-interblock -fsched-spec -fbranch-count-reg -fcommon
+; -fgnu-linker -fargument-alias -fzero-initialized-in-bss -fident
+; -fmath-errno -ftrapping-math -m80387 -mhard-float -mno-soft-float
+; -mieee-fp -mfp-ret-in-387 -maccumulate-outgoing-args -mno-red-zone
+; -mtls-direct-seg-refs -mtune=pentiumpro -march=i386
+
+target triple = "i686-pc-linux-gnu"
+target pointersize = 32
+target endian = little
+deplibs = ["c", "crtend"]
+
+"complex double" = type { double, double }
+"complex float" = type { float, float }
+"complex long double" = type { double, double }
+%.str_1 = internal constant [13 x sbyte] c"hello world\0A\00"
+
+
+implementation
+declare double %acos(double) ;; __builtin_acos
+declare float %acosf(float) ;; __builtin_acosf
+declare double %acosh(double) ;; __builtin_acosh
+declare float %acoshf(float) ;; __builtin_acoshf
+declare double %acoshl(double) ;; __builtin_acoshl
+declare double %acosl(double) ;; __builtin_acosl
+declare double %asin(double) ;; __builtin_asin
+declare float %asinf(float) ;; __builtin_asinf
+declare double %asinh(double) ;; __builtin_asinh
+declare float %asinhf(float) ;; __builtin_asinhf
+declare double %asinhl(double) ;; __builtin_asinhl
+declare double %asinl(double) ;; __builtin_asinl
+declare double %atan(double) ;; __builtin_atan
+declare double %atan2(double,double) ;; __builtin_atan2
+declare float %atan2f(float,float) ;; __builtin_atan2f
+declare double %atan2l(double,double) ;; __builtin_atan2l
+declare float %atanf(float) ;; __builtin_atanf
+declare double %atanh(double) ;; __builtin_atanh
+declare float %atanhf(float) ;; __builtin_atanhf
+declare double %atanhl(double) ;; __builtin_atanhl
+declare double %atanl(double) ;; __builtin_atanl
+declare double %cbrt(double) ;; __builtin_cbrt
+declare float %cbrtf(float) ;; __builtin_cbrtf
+declare double %cbrtl(double) ;; __builtin_cbrtl
+declare double %ceil(double) ;; __builtin_ceil
+declare float %ceilf(float) ;; __builtin_ceilf
+declare double %ceill(double) ;; __builtin_ceill
+declare double %copysign(double,double) ;; __builtin_copysign
+declare float %copysignf(float,float) ;; __builtin_copysignf
+declare double %copysignl(double,double) ;; __builtin_copysignl
+declare double %cos(double) ;; __builtin_cos
+declare float %cosf(float) ;; __builtin_cosf
+declare double %cosh(double) ;; __builtin_cosh
+declare float %coshf(float) ;; __builtin_coshf
+declare double %coshl(double) ;; __builtin_coshl
+declare double %cosl(double) ;; __builtin_cosl
+declare double %drem(double,double) ;; __builtin_drem
+declare float %dremf(float,float) ;; __builtin_dremf
+declare double %dreml(double,double) ;; __builtin_dreml
+declare double %erf(double) ;; __builtin_erf
+declare double %erfc(double) ;; __builtin_erfc
+declare float %erfcf(float) ;; __builtin_erfcf
+declare double %erfcl(double) ;; __builtin_erfcl
+declare float %erff(float) ;; __builtin_erff
+declare double %erfl(double) ;; __builtin_erfl
+declare double %exp(double) ;; __builtin_exp
+declare double %exp10(double) ;; __builtin_exp10
+declare float %exp10f(float) ;; __builtin_exp10f
+declare double %exp10l(double) ;; __builtin_exp10l
+declare double %exp2(double) ;; __builtin_exp2
+declare float %exp2f(float) ;; __builtin_exp2f
+declare double %exp2l(double) ;; __builtin_exp2l
+declare float %expf(float) ;; __builtin_expf
+declare double %expl(double) ;; __builtin_expl
+declare double %expm1(double) ;; __builtin_expm1
+declare float %expm1f(float) ;; __builtin_expm1f
+declare double %expm1l(double) ;; __builtin_expm1l
+declare double %fabs(double) ;; __builtin_fabs
+declare float %fabsf(float) ;; __builtin_fabsf
+declare double %fabsl(double) ;; __builtin_fabsl
+declare double %fdim(double,double) ;; __builtin_fdim
+declare float %fdimf(float,float) ;; __builtin_fdimf
+declare double %fdiml(double,double) ;; __builtin_fdiml
+declare double %floor(double) ;; __builtin_floor
+declare float %floorf(float) ;; __builtin_floorf
+declare double %floorl(double) ;; __builtin_floorl
+declare double %fma(double,double,double) ;; __builtin_fma
+declare float %fmaf(float,float,float) ;; __builtin_fmaf
+declare double %fmal(double,double,double) ;; __builtin_fmal
+declare double %fmax(double,double) ;; __builtin_fmax
+declare float %fmaxf(float,float) ;; __builtin_fmaxf
+declare double %fmaxl(double,double) ;; __builtin_fmaxl
+declare double %fmin(double,double) ;; __builtin_fmin
+declare float %fminf(float,float) ;; __builtin_fminf
+declare double %fminl(double,double) ;; __builtin_fminl
+declare double %fmod(double,double) ;; __builtin_fmod
+declare float %fmodf(float,float) ;; __builtin_fmodf
+declare double %fmodl(double,double) ;; __builtin_fmodl
+declare double %frexp(double,int*) ;; __builtin_frexp
+declare float %frexpf(float,int*) ;; __builtin_frexpf
+declare double %frexpl(double,int*) ;; __builtin_frexpl
+declare double %gamma(double) ;; __builtin_gamma
+declare float %gammaf(float) ;; __builtin_gammaf
+declare double %gammal(double) ;; __builtin_gammal
+declare double %__builtin_huge_val()
+declare float %__builtin_huge_valf()
+declare double %__builtin_huge_vall()
+declare double %hypot(double,double) ;; __builtin_hypot
+declare float %hypotf(float,float) ;; __builtin_hypotf
+declare double %hypotl(double,double) ;; __builtin_hypotl
+declare int %ilogb(double) ;; __builtin_ilogb
+declare int %ilogbf(float) ;; __builtin_ilogbf
+declare int %ilogbl(double) ;; __builtin_ilogbl
+declare double %__builtin_inf()
+declare float %__builtin_inff()
+declare double %__builtin_infl()
+declare double %j0(double) ;; __builtin_j0
+declare float %j0f(float) ;; __builtin_j0f
+declare double %j0l(double) ;; __builtin_j0l
+declare double %j1(double) ;; __builtin_j1
+declare float %j1f(float) ;; __builtin_j1f
+declare double %j1l(double) ;; __builtin_j1l
+declare double %jn(int,double) ;; __builtin_jn
+declare float %jnf(int,float) ;; __builtin_jnf
+declare double %jnl(int,double) ;; __builtin_jnl
+declare double %ldexp(double,int) ;; __builtin_ldexp
+declare float %ldexpf(float,int) ;; __builtin_ldexpf
+declare double %ldexpl(double,int) ;; __builtin_ldexpl
+declare double %lgamma(double) ;; __builtin_lgamma
+declare float %lgammaf(float) ;; __builtin_lgammaf
+declare double %lgammal(double) ;; __builtin_lgammal
+declare long %llrint(double) ;; __builtin_llrint
+declare long %llrintf(float) ;; __builtin_llrintf
+declare long %llrintl(double) ;; __builtin_llrintl
+declare long %llround(double) ;; __builtin_llround
+declare long %llroundf(float) ;; __builtin_llroundf
+declare long %llroundl(double) ;; __builtin_llroundl
+declare double %log(double) ;; __builtin_log
+declare double %log10(double) ;; __builtin_log10
+declare float %log10f(float) ;; __builtin_log10f
+declare double %log10l(double) ;; __builtin_log10l
+declare double %log1p(double) ;; __builtin_log1p
+declare float %log1pf(float) ;; __builtin_log1pf
+declare double %log1pl(double) ;; __builtin_log1pl
+declare double %log2(double) ;; __builtin_log2
+declare float %log2f(float) ;; __builtin_log2f
+declare double %log2l(double) ;; __builtin_log2l
+declare double %logb(double) ;; __builtin_logb
+declare float %logbf(float) ;; __builtin_logbf
+declare double %logbl(double) ;; __builtin_logbl
+declare float %logf(float) ;; __builtin_logf
+declare double %logl(double) ;; __builtin_logl
+declare int %lrint(double) ;; __builtin_lrint
+declare int %lrintf(float) ;; __builtin_lrintf
+declare int %lrintl(double) ;; __builtin_lrintl
+declare int %lround(double) ;; __builtin_lround
+declare int %lroundf(float) ;; __builtin_lroundf
+declare int %lroundl(double) ;; __builtin_lroundl
+declare double %modf(double,double*) ;; __builtin_modf
+declare float %modff(float,float*) ;; __builtin_modff
+declare double %modfl(double,double*) ;; __builtin_modfl
+declare double %nan(sbyte*) ;; __builtin_nan
+declare float %nanf(sbyte*) ;; __builtin_nanf
+declare double %nanl(sbyte*) ;; __builtin_nanl
+declare double %nans(sbyte*) ;; __builtin_nans
+declare float %nansf(sbyte*) ;; __builtin_nansf
+declare double %nansl(sbyte*) ;; __builtin_nansl
+declare double %nearbyint(double) ;; __builtin_nearbyint
+declare float %nearbyintf(float) ;; __builtin_nearbyintf
+declare double %nearbyintl(double) ;; __builtin_nearbyintl
+declare double %nextafter(double,double) ;; __builtin_nextafter
+declare float %nextafterf(float,float) ;; __builtin_nextafterf
+declare double %nextafterl(double,double) ;; __builtin_nextafterl
+declare double %nexttoward(double,double) ;; __builtin_nexttoward
+declare float %nexttowardf(float,double) ;; __builtin_nexttowardf
+declare double %nexttowardl(double,double) ;; __builtin_nexttowardl
+declare double %pow(double,double) ;; __builtin_pow
+declare double %pow10(double) ;; __builtin_pow10
+declare float %pow10f(float) ;; __builtin_pow10f
+declare double %pow10l(double) ;; __builtin_pow10l
+declare float %powf(float,float) ;; __builtin_powf
+declare double %powl(double,double) ;; __builtin_powl
+declare double %remainder(double,double) ;; __builtin_remainder
+declare float %remainderf(float,float) ;; __builtin_remainderf
+declare double %remainderl(double,double) ;; __builtin_remainderl
+declare double %remquo(double,double,int*) ;; __builtin_remquo
+declare float %remquof(float,float,int*) ;; __builtin_remquof
+declare double %remquol(double,double,int*) ;; __builtin_remquol
+declare double %rint(double) ;; __builtin_rint
+declare float %rintf(float) ;; __builtin_rintf
+declare double %rintl(double) ;; __builtin_rintl
+declare double %round(double) ;; __builtin_round
+declare float %roundf(float) ;; __builtin_roundf
+declare double %roundl(double) ;; __builtin_roundl
+declare double %scalb(double,double) ;; __builtin_scalb
+declare float %scalbf(float,float) ;; __builtin_scalbf
+declare double %scalbl(double,double) ;; __builtin_scalbl
+declare double %scalbln(double,int) ;; __builtin_scalbln
+declare float %scalblnf(float,int) ;; __builtin_scalblnf
+declare double %scalblnl(double,int) ;; __builtin_scalblnl
+declare double %scalbn(double,int) ;; __builtin_scalbn
+declare float %scalbnf(float,int) ;; __builtin_scalbnf
+declare double %scalbnl(double,int) ;; __builtin_scalbnl
+declare double %significand(double) ;; __builtin_significand
+declare float %significandf(float) ;; __builtin_significandf
+declare double %significandl(double) ;; __builtin_significandl
+declare double %sin(double) ;; __builtin_sin
+declare void %sincos(double,double*,double*) ;; __builtin_sincos
+declare void %sincosf(float,float*,float*) ;; __builtin_sincosf
+declare void %sincosl(double,double*,double*) ;; __builtin_sincosl
+declare float %sinf(float) ;; __builtin_sinf
+declare double %sinh(double) ;; __builtin_sinh
+declare float %sinhf(float) ;; __builtin_sinhf
+declare double %sinhl(double) ;; __builtin_sinhl
+declare double %sinl(double) ;; __builtin_sinl
+declare double %sqrt(double) ;; __builtin_sqrt
+declare float %sqrtf(float) ;; __builtin_sqrtf
+declare double %sqrtl(double) ;; __builtin_sqrtl
+declare double %tan(double) ;; __builtin_tan
+declare float %tanf(float) ;; __builtin_tanf
+declare double %tanh(double) ;; __builtin_tanh
+declare float %tanhf(float) ;; __builtin_tanhf
+declare double %tanhl(double) ;; __builtin_tanhl
+declare double %tanl(double) ;; __builtin_tanl
+declare double %tgamma(double) ;; __builtin_tgamma
+declare float %tgammaf(float) ;; __builtin_tgammaf
+declare double %tgammal(double) ;; __builtin_tgammal
+declare double %trunc(double) ;; __builtin_trunc
+declare float %truncf(float) ;; __builtin_truncf
+declare double %truncl(double) ;; __builtin_truncl
+declare double %y0(double) ;; __builtin_y0
+declare float %y0f(float) ;; __builtin_y0f
+declare double %y0l(double) ;; __builtin_y0l
+declare double %y1(double) ;; __builtin_y1
+declare float %y1f(float) ;; __builtin_y1f
+declare double %y1l(double) ;; __builtin_y1l
+declare double %yn(int,double) ;; __builtin_yn
+declare float %ynf(int,float) ;; __builtin_ynf
+declare double %ynl(int,double) ;; __builtin_ynl
+declare double %cabs(double,double) ;; __builtin_cabs
+declare float %cabsf(float,float) ;; __builtin_cabsf
+declare double %cabsl(double,double) ;; __builtin_cabsl
+declare void %cacos("complex double"*,double,double) ;; __builtin_cacos
+declare void %cacosf("complex float"*,float,float) ;; __builtin_cacosf
+declare void %cacosh("complex double"*,double,double) ;; __builtin_cacosh
+declare void %cacoshf("complex float"*,float,float) ;; __builtin_cacoshf
+declare void %cacoshl("complex long double"*,double,double) ;; __builtin_cacoshl
+declare void %cacosl("complex long double"*,double,double) ;; __builtin_cacosl
+declare double %carg(double,double) ;; __builtin_carg
+declare float %cargf(float,float) ;; __builtin_cargf
+declare double %cargl(double,double) ;; __builtin_cargl
+declare void %casin("complex double"*,double,double) ;; __builtin_casin
+declare void %casinf("complex float"*,float,float) ;; __builtin_casinf
+declare void %casinh("complex double"*,double,double) ;; __builtin_casinh
+declare void %casinhf("complex float"*,float,float) ;; __builtin_casinhf
+declare void %casinhl("complex long double"*,double,double) ;; __builtin_casinhl
+declare void %casinl("complex long double"*,double,double) ;; __builtin_casinl
+declare void %catan("complex double"*,double,double) ;; __builtin_catan
+declare void %catanf("complex float"*,float,float) ;; __builtin_catanf
+declare void %catanh("complex double"*,double,double) ;; __builtin_catanh
+declare void %catanhf("complex float"*,float,float) ;; __builtin_catanhf
+declare void %catanhl("complex long double"*,double,double) ;; __builtin_catanhl
+declare void %catanl("complex long double"*,double,double) ;; __builtin_catanl
+declare void %ccos("complex double"*,double,double) ;; __builtin_ccos
+declare void %ccosf("complex float"*,float,float) ;; __builtin_ccosf
+declare void %ccosh("complex double"*,double,double) ;; __builtin_ccosh
+declare void %ccoshf("complex float"*,float,float) ;; __builtin_ccoshf
+declare void %ccoshl("complex long double"*,double,double) ;; __builtin_ccoshl
+declare void %ccosl("complex long double"*,double,double) ;; __builtin_ccosl
+declare void %cexp("complex double"*,double,double) ;; __builtin_cexp
+declare void %cexpf("complex float"*,float,float) ;; __builtin_cexpf
+declare void %cexpl("complex long double"*,double,double) ;; __builtin_cexpl
+declare double %cimag(double,double) ;; __builtin_cimag
+declare float %cimagf(float,float) ;; __builtin_cimagf
+declare double %cimagl(double,double) ;; __builtin_cimagl
+declare void %conj("complex double"*,double,double) ;; __builtin_conj
+declare void %conjf("complex float"*,float,float) ;; __builtin_conjf
+declare void %conjl("complex long double"*,double,double) ;; __builtin_conjl
+declare void %cpow("complex double"*,double,double,double,double) ;; __builtin_cpow
+declare void %cpowf("complex float"*,float,float,float,float) ;; __builtin_cpowf
+declare void %cpowl("complex long double"*,double,double,double,double) ;; __builtin_cpowl
+declare void %cproj("complex double"*,double,double) ;; __builtin_cproj
+declare void %cprojf("complex float"*,float,float) ;; __builtin_cprojf
+declare void %cprojl("complex long double"*,double,double) ;; __builtin_cprojl
+declare double %creal(double,double) ;; __builtin_creal
+declare float %crealf(float,float) ;; __builtin_crealf
+declare double %creall(double,double) ;; __builtin_creall
+declare void %csin("complex double"*,double,double) ;; __builtin_csin
+declare void %csinf("complex float"*,float,float) ;; __builtin_csinf
+declare void %csinh("complex double"*,double,double) ;; __builtin_csinh
+declare void %csinhf("complex float"*,float,float) ;; __builtin_csinhf
+declare void %csinhl("complex long double"*,double,double) ;; __builtin_csinhl
+declare void %csinl("complex long double"*,double,double) ;; __builtin_csinl
+declare void %csqrt("complex double"*,double,double) ;; __builtin_csqrt
+declare void %csqrtf("complex float"*,float,float) ;; __builtin_csqrtf
+declare void %csqrtl("complex long double"*,double,double) ;; __builtin_csqrtl
+declare void %ctan("complex double"*,double,double) ;; __builtin_ctan
+declare void %ctanf("complex float"*,float,float) ;; __builtin_ctanf
+declare void %ctanh("complex double"*,double,double) ;; __builtin_ctanh
+declare void %ctanhf("complex float"*,float,float) ;; __builtin_ctanhf
+declare void %ctanhl("complex long double"*,double,double) ;; __builtin_ctanhl
+declare void %ctanl("complex long double"*,double,double) ;; __builtin_ctanl
+declare int %bcmp(sbyte*,sbyte*,uint) ;; __builtin_bcmp
+declare void %bcopy(sbyte*,sbyte*,uint) ;; __builtin_bcopy
+declare void %bzero(sbyte*,uint) ;; __builtin_bzero
+declare int %ffs(int) ;; __builtin_ffs
+declare int %ffsl(int) ;; __builtin_ffsl
+declare int %ffsll(long) ;; __builtin_ffsll
+declare sbyte* %index(sbyte*,int) ;; __builtin_index
+declare int %memcmp(sbyte*,sbyte*,uint) ;; __builtin_memcmp
+declare sbyte* %memcpy(sbyte*,sbyte*,uint) ;; __builtin_memcpy
+declare sbyte* %memmove(sbyte*,sbyte*,uint) ;; __builtin_memmove
+declare sbyte* %mempcpy(sbyte*,sbyte*,uint) ;; __builtin_mempcpy
+declare sbyte* %memset(sbyte*,int,uint) ;; __builtin_memset
+declare sbyte* %rindex(sbyte*,int) ;; __builtin_rindex
+declare sbyte* %stpcpy(sbyte*,sbyte*) ;; __builtin_stpcpy
+declare sbyte* %strcat(sbyte*,sbyte*) ;; __builtin_strcat
+declare sbyte* %strchr(sbyte*,int) ;; __builtin_strchr
+declare int %strcmp(sbyte*,sbyte*) ;; __builtin_strcmp
+declare sbyte* %strcpy(sbyte*,sbyte*) ;; __builtin_strcpy
+declare uint %strcspn(sbyte*,sbyte*) ;; __builtin_strcspn
+declare sbyte* %strdup(sbyte*) ;; __builtin_strdup
+declare uint %strlen(sbyte*) ;; __builtin_strlen
+declare sbyte* %strncat(sbyte*,sbyte*,uint) ;; __builtin_strncat
+declare int %strncmp(sbyte*,sbyte*,uint) ;; __builtin_strncmp
+declare sbyte* %strncpy(sbyte*,sbyte*,uint) ;; __builtin_strncpy
+declare sbyte* %strpbrk(sbyte*,sbyte*) ;; __builtin_strpbrk
+declare sbyte* %strrchr(sbyte*,int) ;; __builtin_strrchr
+declare uint %strspn(sbyte*,sbyte*) ;; __builtin_strspn
+declare sbyte* %strstr(sbyte*,sbyte*) ;; __builtin_strstr
+declare int %fprintf(sbyte*,sbyte*, ...) ;; __builtin_fprintf
+declare int %fprintf_unlocked(sbyte*,sbyte*, ...) ;; __builtin_fprintf_unlocked
+declare int %fputc(int,sbyte*) ;; __builtin_fputc
+declare int %fputc_unlocked(int,sbyte*) ;; __builtin_fputc_unlocked
+declare int %fputs(sbyte*,sbyte*) ;; __builtin_fputs
+declare int %fputs_unlocked(sbyte*,sbyte*) ;; __builtin_fputs_unlocked
+declare int %fscanf(sbyte*,sbyte*, ...) ;; __builtin_fscanf
+declare uint %fwrite(sbyte*,uint,uint,sbyte*) ;; __builtin_fwrite
+declare uint %fwrite_unlocked(sbyte*,uint,uint,sbyte*) ;; __builtin_fwrite_unlocked
+declare int %printf(sbyte*, ...) ;; __builtin_printf
+declare int %printf_unlocked(sbyte*, ...) ;; __builtin_printf_unlocked
+declare int %putchar(int) ;; __builtin_putchar
+declare int %putchar_unlocked(int) ;; __builtin_putchar_unlocked
+declare int %puts(sbyte*) ;; __builtin_puts
+declare int %puts_unlocked(sbyte*) ;; __builtin_puts_unlocked
+declare int %scanf(sbyte*, ...) ;; __builtin_scanf
+declare int %snprintf(sbyte*,uint,sbyte*, ...) ;; __builtin_snprintf
+declare int %sprintf(sbyte*,sbyte*, ...) ;; __builtin_sprintf
+declare int %sscanf(sbyte*,sbyte*, ...) ;; __builtin_sscanf
+declare int %vfprintf(sbyte*,sbyte*,sbyte*) ;; __builtin_vfprintf
+declare int %vfscanf(sbyte*,sbyte*,sbyte*) ;; __builtin_vfscanf
+declare int %vprintf(sbyte*,sbyte*) ;; __builtin_vprintf
+declare int %vscanf(sbyte*,sbyte*) ;; __builtin_vscanf
+declare int %vsnprintf(sbyte*,uint,sbyte*,sbyte*) ;; __builtin_vsnprintf
+declare int %vsprintf(sbyte*,sbyte*,sbyte*) ;; __builtin_vsprintf
+declare int %vsscanf(sbyte*,sbyte*,sbyte*) ;; __builtin_vsscanf
+declare void %abort() ;; __builtin_abort
+declare int %abs(int) ;; __builtin_abs
+declare sbyte* %__builtin_aggregate_incoming_address(...)
+declare sbyte* %alloca(uint) ;; __builtin_alloca
+declare sbyte* %__builtin_apply(void (...)*,sbyte*,uint)
+declare sbyte* %__builtin_apply_args(...)
+declare int %__builtin_args_info(int)
+declare sbyte* %calloc(uint,uint) ;; __builtin_calloc
+declare int %__builtin_classify_type(...)
+declare int %__builtin_clz(int)
+declare int %__builtin_clzl(int)
+declare int %__builtin_clzll(long)
+declare int %__builtin_constant_p(...)
+declare int %__builtin_ctz(int)
+declare int %__builtin_ctzl(int)
+declare int %__builtin_ctzll(long)
+declare sbyte* %dcgettext(sbyte*,sbyte*,int) ;; __builtin_dcgettext
+declare sbyte* %dgettext(sbyte*,sbyte*) ;; __builtin_dgettext
+declare sbyte* %__builtin_dwarf_cfa()
+declare uint %__builtin_dwarf_sp_column()
+declare void %__builtin_eh_return(int,sbyte*)
+declare int %__builtin_eh_return_data_regno(int)
+declare void %exit(int) ;; __builtin_exit
+declare int %__builtin_expect(int,int)
+declare sbyte* %__builtin_extract_return_addr(sbyte*)
+declare sbyte* %__builtin_frame_address(uint)
+declare sbyte* %__builtin_frob_return_addr(sbyte*)
+declare sbyte* %gettext(sbyte*) ;; __builtin_gettext
+declare long %imaxabs(long) ;; __builtin_imaxabs
+declare void %__builtin_init_dwarf_reg_size_table(sbyte*)
+declare int %__builtin_isgreater(...)
+declare int %__builtin_isgreaterequal(...)
+declare int %__builtin_isless(...)
+declare int %__builtin_islessequal(...)
+declare int %__builtin_islessgreater(...)
+declare int %__builtin_isunordered(...)
+declare int %labs(int) ;; __builtin_labs
+declare long %llabs(long) ;; __builtin_llabs
+declare void %__builtin_longjmp(sbyte*,int)
+declare sbyte* %malloc(uint) ;; __builtin_malloc
+declare sbyte* %__builtin_next_arg(...)
+declare int %__builtin_parity(int)
+declare int %__builtin_parityl(int)
+declare int %__builtin_parityll(long)
+declare int %__builtin_popcount(int)
+declare int %__builtin_popcountl(int)
+declare int %__builtin_popcountll(long)
+declare void %__builtin_prefetch(sbyte*, ...)
+declare void %__builtin_return(sbyte*)
+declare sbyte* %__builtin_return_address(uint)
+declare sbyte* %__builtin_saveregs(...)
+declare int %__builtin_setjmp(sbyte*)
+declare void %__builtin_stdarg_start(sbyte**, ...)
+declare int %strfmon(sbyte*,uint,sbyte*, ...) ;; __builtin_strfmon
+declare uint %strftime(sbyte*,uint,sbyte*,sbyte*) ;; __builtin_strftime
+declare void %__builtin_trap()
+declare void %__builtin_unwind_init()
+declare void %__builtin_va_copy(sbyte**,sbyte*)
+declare void %__builtin_va_end(sbyte**)
+declare void %__builtin_va_start(sbyte**, ...)
+declare void %_exit(int) ;; __builtin__exit
+declare void %_Exit(int) ;; __builtin__Exit
+
+sbyte* %gethellostr() {
+entry:
+ %result = alloca sbyte* ; ty=sbyte**
+ store sbyte* getelementptr ([13 x sbyte]* %.str_1, int 0, int 0), sbyte** %result
+ br label %return
+after_ret:
+ br label %return
+return:
+ %tmp.1 = load sbyte** %result ; ty=sbyte*
+ ret sbyte* %tmp.1
+}
+
+
+int %hello() {
+entry:
+ %result = alloca int ; ty=int*
+ %tmp.2 = call sbyte* (...)* cast (sbyte* ()* %gethellostr to sbyte* (...)*)() ; ty=sbyte*
+ %tmp.0 = call int (sbyte*, ...)* %printf(sbyte* %tmp.2) ; ty=int
+ store int 0, int* %result
+ br label %return
+after_ret:
+ br label %return
+return:
+ %tmp.3 = load int* %result ; ty=int
+ ret int %tmp.3
+}
+
+;; Created by "GCC: (GNU) 3.4-llvm 20051104 (LLVM 1.6)"
Added: pypy/dist/pypy/translator/llvm/pyllvm/test/ll_snippet.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pyllvm/test/ll_snippet.py Wed Apr 5 13:57:58 2006
@@ -0,0 +1,32 @@
+calc = """int %calc(int %n) {
+ %tmp.0 = call int %add1(int %n)
+ ret int %tmp.0
+}
+declare int %add1(int)"""
+
+add1 = """int %add1(int %n) {
+ %tmp.0 = add int %n, 1
+ ret int %tmp.0
+}"""
+
+add1_version2 = """int %add1(int %n) {
+ %tmp.0 = add int %n, 100 ;used for testing function replacement
+ ret int %tmp.0
+}"""
+
+global_int_a_is_100 = """%a = global int 100"""
+
+add1_to_global_int_a = """
+int %add1_to_global_int_a() {
+ %tmp.0 = load int* %a
+ %tmp.1 = add int %tmp.0, 1
+ store int %tmp.1, int* %a
+ ret int %tmp.1
+}"""
+
+sub10_from_global_int_a = """int %sub10_from_global_int_a() {
+ %tmp.0 = load int* %a
+ %tmp.1 = sub int %tmp.0, 10
+ store int %tmp.1, int* %a
+ ret int %tmp.1
+}"""
Added: pypy/dist/pypy/translator/llvm/pyllvm/test/test_ee.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pyllvm/test/test_ee.py Wed Apr 5 13:57:58 2006
@@ -0,0 +1,146 @@
+import py
+from pypy.translator.llvm.buildllvm import llvm_is_on_path
+if not llvm_is_on_path():
+ py.test.skip("llvm not found")
+
+from pypy.translator.llvm.pyllvm import pyllvm
+from pypy.translator.llvm.pyllvm.test import ll_snippet
+
+
+def test_execution_engine():
+ ee = pyllvm.ExecutionEngine()
+ ee = pyllvm.ExecutionEngine()
+ ee = pyllvm.ExecutionEngine()
+ del ee #XXX not actualy deleted at the moment!!!
+ ee2 = pyllvm.ExecutionEngine()
+ ee2 = pyllvm.ExecutionEngine()
+ ee2 = pyllvm.ExecutionEngine()
+
+codepath = py.path.local(__file__).dirpath()
+
+def test_load():
+ ee = pyllvm.ExecutionEngine()
+ ee.parse(codepath.join("hello.s").read())
+ ee.parse(codepath.join("addnumbers.s").read())
+
+def test_functions():
+ ee = pyllvm.ExecutionEngine()
+ ee.parse(codepath.join("hello.s").read())
+ mod = ee.getModule()
+ assert mod.n_functions() == 2
+ #TODO
+ #for function in functions:
+ # returnId, name, args = function
+ # assert len(function) == 3
+ # assert returnId > 0
+ # assert name in ('gethellostr', 'hello')
+ # assert len(args) == 0
+ py.test.raises(Exception, mod.n_functions, 1)
+ py.test.raises(Exception, mod.n_functions, "string")
+
+def test_call_parse_once():
+ ee = pyllvm.ExecutionEngine()
+ ee.parse(codepath.join("hello.s").read())
+ f = ee.getModule().getNamedFunction
+ hello = f("hello")
+ gethellostr = f("gethellostr")
+ assert hello() == 0
+ assert gethellostr() == "hello world\n"
+
+def test_call_parse_twice():
+ py.test.skip("WIP")
+ ee = pyllvm.ExecutionEngine()
+ ee.parse(codepath.join("hello.s").read())
+ f = ee.getModule().getNamedFunction
+ f1 = f("gethellostr")
+ assert f1() == "hello world\n"
+ ee.parse(codepath.join("addnumbers.s").read())
+ f2 = f("add")
+ assert f2(10, 32) == 42
+ assert f1() == "hello world\n"
+ py.test.raises(Exception, ee.parse)
+ py.test.raises(Exception, ee.parse, 1)
+ py.test.raises(Exception, ee.parse, "abc")
+
+def test_call_between_parsed_code():
+ """we parse add1 last on purpose to see if the JIT resolves
+ the function at execution time. Not sure if we really need this
+ particular feature. It appears that 'calc' requires a forward
+ declaration to add1 otherwise a segfault will occur!"""
+ ee = pyllvm.ExecutionEngine()
+ ee.parse(ll_snippet.calc)
+ ee.parse(ll_snippet.add1)
+ f = ee.getModule().getNamedFunction
+ assert f("add1")(41) == 42
+ assert f("calc")(122) == 123
+
+def test_replace_function():
+ py.test.skip("WIP")
+ """similar to test_call_between_parsed_code with additional complexity
+ because we rebind the add1 function to another version after it the
+ first version already has been used."""
+ ee = pyllvm.ExecutionEngine()
+ ee.parse(ll_snippet.calc)
+ ee.parse(ll_snippet.add1)
+ f = ee.getModule().getNamedFunction
+ assert f("add1")(41) == 42
+ assert f("calc")(122) == 123 #XXX need recompileAndRelinkFunction somewhere
+ ee.parse(ll_snippet.add1_version2, "add1")
+ assert f("add1")(42) == 142
+ assert f("calc")(142) == 242
+
+def test_share_data_between_parsed_code():
+ ee = pyllvm.ExecutionEngine()
+ ee.parse(ll_snippet.global_int_a_is_100)
+ ee.parse(ll_snippet.add1_to_global_int_a)
+ ee.parse(ll_snippet.sub10_from_global_int_a)
+ f = ee.getModule().getNamedFunction
+ assert f("add1_to_global_int_a")() == 101
+ assert f("sub10_from_global_int_a")() == 91
+ assert f("add1_to_global_int_a")() == 92
+ assert f("sub10_from_global_int_a")() == 82
+
+def test_native_code(): #examine JIT generate native (assembly) code
+ py.test.skip("WIP")
+ pyllvm.toggle_print_machineinstrs()
+ ee = pyllvm.ExecutionEngine()
+ ee.parse(ll_snippet.calc)
+ ee.parse(ll_snippet.add1)
+ f = ee.getModule().getNamedFunction
+ assert f("calc")(41) == 42
+ pyllvm.toggle_print_machineinstrs()
+
+def test_delete_function(): #this will only work if nothing uses Fn of course!
+ py.test.skip("WIP")
+ ee = pyllvm.ExecutionEngine()
+ mod = ee.getModule()
+ ee.parse(ll_snippet.calc)
+ ee.parse(ll_snippet.add1)
+ assert mod.n_functions() == 2
+
+ ee.delete("calc")
+ assert mod.n_functions() == 1
+ f = ee.getModule().getNamedFunction
+ assert f("add1")(41) == 42
+
+ ee.delete("add1")
+ assert mod.n_functions() == 0
+
+ ee.parse(ll_snippet.calc)
+ ee.parse(ll_snippet.add1)
+ assert f("calc")(100) == 101
+
+def TODOtest_multiple_executionengines():
+ pass
+
+def TODOtest_returntypes():
+ pass
+
+def TODOtest_paramtypes():
+ pass
+
+def TODOtest_add_to_function():
+ pass
+
+def TODOtest_optimize_functions(): #add/del/list llvm transformation passes
+ pass
More information about the Pypy-commit
mailing list