[pypy-svn] r25221 - in pypy/dist/pypy/translator/llvm: llvmcapi llvmcapi/include llvmcapi/include/ExecutionEngine llvmcapi/include/VMCore llvmcapi/lib llvmcapi/lib/ExecutionEngine llvmcapi/lib/VMCore pythonllvm pythonllvm/doc pythonllvm/test
ericvrp at codespeak.net
ericvrp at codespeak.net
Sun Apr 2 13:08:33 CEST 2006
Author: ericvrp
Date: Sun Apr 2 13:08:28 2006
New Revision: 25221
Added:
pypy/dist/pypy/translator/llvm/llvmcapi/
pypy/dist/pypy/translator/llvm/llvmcapi/README.txt (contents, props changed)
pypy/dist/pypy/translator/llvm/llvmcapi/include/
pypy/dist/pypy/translator/llvm/llvmcapi/include/ExecutionEngine/
pypy/dist/pypy/translator/llvm/llvmcapi/include/ExecutionEngine/ExecutionEngine.h
pypy/dist/pypy/translator/llvm/llvmcapi/include/VMCore/
pypy/dist/pypy/translator/llvm/llvmcapi/include/VMCore/Function.h
pypy/dist/pypy/translator/llvm/llvmcapi/include/VMCore/Module.h
pypy/dist/pypy/translator/llvm/llvmcapi/include/VMCore/ModuleProvider.h
pypy/dist/pypy/translator/llvm/llvmcapi/include/llvmcapi.h
pypy/dist/pypy/translator/llvm/llvmcapi/lib/
pypy/dist/pypy/translator/llvm/llvmcapi/lib/ExecutionEngine/
pypy/dist/pypy/translator/llvm/llvmcapi/lib/ExecutionEngine/ExecutionEngine.cpp (contents, props changed)
pypy/dist/pypy/translator/llvm/llvmcapi/lib/VMCore/
pypy/dist/pypy/translator/llvm/llvmcapi/lib/VMCore/Function.cpp (contents, props changed)
pypy/dist/pypy/translator/llvm/llvmcapi/lib/VMCore/Module.cpp (contents, props changed)
pypy/dist/pypy/translator/llvm/llvmcapi/lib/VMCore/ModuleProvider.cpp (contents, props changed)
pypy/dist/pypy/translator/llvm/llvmcapi/lib/llvmcapi.cpp
pypy/dist/pypy/translator/llvm/llvmcapi/setup.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pythonllvm/
pypy/dist/pypy/translator/llvm/pythonllvm/__init__.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pythonllvm/autopath.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pythonllvm/cc.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pythonllvm/create_llvmcapi.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pythonllvm/doc/
pypy/dist/pypy/translator/llvm/pythonllvm/doc/pyllvm.cpp.org
pypy/dist/pypy/translator/llvm/pythonllvm/helper.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pythonllvm/llvmcapi.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pythonllvm/pyllvm.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pythonllvm/test/
pypy/dist/pypy/translator/llvm/pythonllvm/test/.gdb_history
pypy/dist/pypy/translator/llvm/pythonllvm/test/__init__.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pythonllvm/test/addnumbers.c
pypy/dist/pypy/translator/llvm/pythonllvm/test/addnumbers.s
pypy/dist/pypy/translator/llvm/pythonllvm/test/hello.c
pypy/dist/pypy/translator/llvm/pythonllvm/test/hello.s
pypy/dist/pypy/translator/llvm/pythonllvm/test/ll_snippet.py (contents, props changed)
pypy/dist/pypy/translator/llvm/pythonllvm/test/test_ee.py (contents, props changed)
Log:
WIP llvm c api library and ctypes wrapper for that.
Checkin because I'm moving machines
Added: pypy/dist/pypy/translator/llvm/llvmcapi/README.txt
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/llvmcapi/README.txt Sun Apr 2 13:08:28 2006
@@ -0,0 +1,4 @@
+Create llvm c api library by running "python setup.py build_ext -i" here
+
+note: This library building should maybe not be done with distutils at all!
+ It should probably be done with the regular: ./configure;make;make install
Added: pypy/dist/pypy/translator/llvm/llvmcapi/include/ExecutionEngine/ExecutionEngine.h
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/llvmcapi/include/ExecutionEngine/ExecutionEngine.h Sun Apr 2 13:08:28 2006
@@ -0,0 +1,21 @@
+#ifndef __EXECUIONENGINE_H__
+#define __EXECUIONENGINE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+void* ExecutionEngine__init__M(void* M);
+void* ExecutionEngine__init__MP(void* MP);
+*/
+void* ExecutionEngine__create__(void* MP, int ForceInterpreter);
+void* ExecutionEngine_getModule(void* EE);
+int ExecutionEngine_n_functions(void* EE);
+int ExecutionEngine_function_exists(void* EE, const char* funcname);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
Added: pypy/dist/pypy/translator/llvm/llvmcapi/include/VMCore/Function.h
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/llvmcapi/include/VMCore/Function.h Sun Apr 2 13:08:28 2006
@@ -0,0 +1,14 @@
+#ifndef __FUNCTION_H__
+#define __FUNCTION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
Added: pypy/dist/pypy/translator/llvm/llvmcapi/include/VMCore/Module.h
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/llvmcapi/include/VMCore/Module.h Sun Apr 2 13:08:28 2006
@@ -0,0 +1,26 @@
+#ifndef __MODULE_H__
+#define __MODULE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void* Module__init__(const char* ModuleID);
+const char* Module_getModuleIdentifier(void* M);
+void Module_setModuleIdentifier(void* M, const char* ID);
+const char* Module_getTargetTriple(void* M);
+void Module_setTargetTriple(void* M, const char* T);
+//const char* Module_getEndianness(void* M);
+//void Module_setEndianness(void* M, Endianness E);
+//const char* Module_getPointerSize(void* M);
+//void Module_setPointerSize(void* M, PointerSize PS);
+const char* Module_getModuleInlineAsm(void* M);
+void Module_setModuleInlineAsm(void* M, const char* Asm);
+void Module_ParseAssemblyString(void* M, const char* AsmString);
+int Module_verifyModule(void* M);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
Added: pypy/dist/pypy/translator/llvm/llvmcapi/include/VMCore/ModuleProvider.h
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/llvmcapi/include/VMCore/ModuleProvider.h Sun Apr 2 13:08:28 2006
@@ -0,0 +1,14 @@
+#ifndef __MODULEPROVIDER_H__
+#define __MODULEPROVIDER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void* ExistingModuleProvider__init__(void* M);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
Added: pypy/dist/pypy/translator/llvm/llvmcapi/include/llvmcapi.h
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/llvmcapi/include/llvmcapi.h Sun Apr 2 13:08:28 2006
@@ -0,0 +1,19 @@
+#ifndef __LLVMCAPI_H__
+#define __LLVMCAPI_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "VMCore/Module.h"
+#include "VMCore/ModuleProvider.h"
+#include "VMCore/Function.h"
+#include "ExecutionEngine/ExecutionEngine.h"
+
+void toggle_print_machineinstrs();
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
Added: pypy/dist/pypy/translator/llvm/llvmcapi/lib/ExecutionEngine/ExecutionEngine.cpp
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/llvmcapi/lib/ExecutionEngine/ExecutionEngine.cpp Sun Apr 2 13:08:28 2006
@@ -0,0 +1,46 @@
+#include "llvm/ExecutionEngine/ExecutionEngine.h"
+
+using namespace llvm;
+
+/*
+void* ExecutionEngine__init__M(void* M) {
+ return new ExecutionEngine((Module*)M);
+}
+
+void* ExecutionEngine__init__MP(void* MP) {
+ return new ExecutionEngine((ModuleProvider*)MP);
+}
+*/
+
+void* ExecutionEngine__create__(void* MP, int ForceInterpreter) {
+ return ExecutionEngine::create((ModuleProvider*)MP, (bool)ForceInterpreter);
+}
+
+void* ExecutionEngine_getModule(void* EE) {
+ return &((ExecutionEngine*)EE)->getModule();
+}
+
+int ExecutionEngine_n_functions(void* EE) { //move to Module?
+ Module* mod = &((ExecutionEngine*)EE)->getModule();
+ int funccount = 0;
+ Module::FunctionListType &fns = mod->getFunctionList();
+ for (Module::FunctionListType::const_iterator ii = fns.begin(); ii != fns.end(); ++ii) {
+ if (!(ii->isIntrinsic() || ii->isExternal())) {
+ funccount += 1;
+ }
+ }
+ return funccount;
+}
+
+int Module_function_exists(void* EE, const char* funcname) { //move to Module?
+ Module* mod = &((ExecutionEngine*)EE)->getModule();
+ Module::FunctionListType &fns = mod->getFunctionList();
+ for (Module::FunctionListType::const_iterator ii = fns.begin(); ii != fns.end(); ++ii) {
+ if (!(ii->isIntrinsic() || ii->isExternal())) {
+ if (ii->getName() == funcname) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
Added: pypy/dist/pypy/translator/llvm/llvmcapi/lib/VMCore/Function.cpp
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/llvmcapi/lib/VMCore/Function.cpp Sun Apr 2 13:08:28 2006
@@ -0,0 +1,7 @@
+#include "llvm/Function.h"
+
+using namespace llvm;
+
+//void* Function__init__(void* M) {
+// return new Function((Module*)M);
+//}
Added: pypy/dist/pypy/translator/llvm/llvmcapi/lib/VMCore/Module.cpp
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/llvmcapi/lib/VMCore/Module.cpp Sun Apr 2 13:08:28 2006
@@ -0,0 +1,58 @@
+#include "llvm/Module.h"
+#include "llvm/Analysis/Verifier.h"
+
+using namespace llvm;
+
+void* Module__init__(const char* ModuleID) {
+ return new Module(ModuleID);
+}
+
+const char* Module_getModuleIdentifier(void* M) {
+ return ((Module*)M)->getModuleIdentifier().c_str();
+}
+
+void Module_setModuleIdentifier(void* M, const char* ID) {
+ return ((Module*)M)->setModuleIdentifier(ID);
+}
+
+const char* Module_getTargetTriple(void* M) {
+ return ((Module*)M)->getTargetTriple().c_str();
+}
+
+void Module_setTargetTriple(void* M, const char* T) {
+ return ((Module*)M)->setTargetTriple(T);
+}
+
+/*
+const char* Module_getEndianness(void* M) {
+ return ((Module*)M)->getEndianness().c_str();
+}
+
+void Module_setEndianness(void* M, Endianness E) {
+ return ((Module*)M)->setEndianness(E);
+}
+
+const char* Module_getPointerSize(void* M) {
+ return ((Module*)M)->getPointerSize().c_str();
+}
+
+void Module_setPointerSize(void* M, PointerSize PS) {
+ return ((Module*)M)->setPointerSize(PS);
+}
+*/
+
+const char* Module_getModuleInlineAsm(void* M) {
+ return ((Module*)M)->getModuleInlineAsm().c_str();
+}
+
+void Module_setModuleInlineAsm(void* M, const char* Asm) {
+ ((Module*)M)->setModuleInlineAsm(Asm);
+}
+
+void Module_ParseAssemblyString(void* M, const char* AsmString) { //from Assembly/Parser.h
+ ParseAssemblyString(AsmString, (Module*)M);
+}
+
+int Module_verifyModule(void* M) { //from Analysis/Verifier.h
+ return verifyModule(*(Module*)M, ThrowExceptionAction);
+}
Added: pypy/dist/pypy/translator/llvm/llvmcapi/lib/VMCore/ModuleProvider.cpp
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/llvmcapi/lib/VMCore/ModuleProvider.cpp Sun Apr 2 13:08:28 2006
@@ -0,0 +1,7 @@
+#include "llvm/ModuleProvider.h"
+
+using namespace llvm;
+
+void* ExistingModuleProvider__init__(void* M) {
+ return new ExistingModuleProvider((Module*)M);
+}
Added: pypy/dist/pypy/translator/llvm/llvmcapi/lib/llvmcapi.cpp
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/llvmcapi/lib/llvmcapi.cpp Sun Apr 2 13:08:28 2006
@@ -0,0 +1,30 @@
+// llvm includes
+#include "llvm/Type.h"
+#include "llvm/Module.h"
+#include "llvm/ModuleProvider.h"
+#include "llvm/Assembly/Parser.h"
+#include "llvm/Bytecode/Reader.h"
+#include "llvm/ExecutionEngine/GenericValue.h"
+#include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/Analysis/Verifier.h"
+#include "llvm/DerivedTypes.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Target/TargetOptions.h"
+
+// llvm c api includes
+#include "llvmcapi.h"
+
+
+using namespace llvm;
+
+
+// llvm c acpi code
+#include "VMCore/Module.cpp"
+#include "VMCore/ModuleProvider.cpp"
+#include "VMCore/Function.cpp"
+#include "ExecutionEngine/ExecutionEngine.cpp"
+
+
+void toggle_print_machineinstrs() {
+ PrintMachineCode = !PrintMachineCode;
+}
Added: pypy/dist/pypy/translator/llvm/llvmcapi/setup.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/llvmcapi/setup.py Sun Apr 2 13:08:28 2006
@@ -0,0 +1,19 @@
+from distutils.core import setup
+from distutils.extension import Extension
+from os import popen
+
+cxxflags = popen('llvm-config --cxxflags').readline().split()
+ldflags = popen('llvm-config --ldflags').readline().split()
+libs = popen('llvm-config --libs all').readline().split()
+
+opts = dict(name='llvmcapi',
+ sources=['lib/llvmcapi.cpp'],
+ libraries=[],
+ include_dirs =["include"] + [f[2:] for f in cxxflags if f.startswith('-I')],
+ library_dirs =[f[2:] for f in ldflags if f.startswith('-L')],
+ define_macros=[(f[2:], None) for f in cxxflags if f.startswith('-D')],
+ extra_objects=libs)
+
+ext_modules = Extension(**opts)
+
+setup(name=opts['name'], ext_modules=[ext_modules])
Added: pypy/dist/pypy/translator/llvm/pythonllvm/__init__.py
==============================================================================
Added: pypy/dist/pypy/translator/llvm/pythonllvm/autopath.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/autopath.py Sun Apr 2 13:08:28 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/pythonllvm/cc.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/cc.py Sun Apr 2 13:08:28 2006
@@ -0,0 +1,17 @@
+'''
+Added this because ctypes on my computer was missing cdecl.
+'''
+from ctypes import *
+
+class cdecl(object):
+ def __init__(self, restype, libname, argtypes):
+ #XXX does this load once or every time?
+ self.library = cdll.load("../llvmcapi/" + libname + ".so")
+ 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/pythonllvm/create_llvmcapi.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/create_llvmcapi.py Sun Apr 2 13:08:28 2006
@@ -0,0 +1,14 @@
+#!/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 "creating llvmcapi.py"
+ os.system("python " + WRAPDIR + "/h2xml.py ../llvmcapi/include/llvmcapi.h -q -I . -o llvmcapi.xml")
+ os.system("python " + WRAPDIR + "/xml2py.py llvmcapi.xml -l ../llvmcapi/llvmcapi.so -o llvmcapi.tmp")
+ os.system("sed -e s/from\ ctypes\ import/from\ cc\ import/ llvmcapi.tmp > llvmcapi.py")
+ os.system("rm -f llvmcapi.tmp llvmcapi.xml")
+ print "done"
+else:
+ print "skipping llvmcapi.py creation"
Added: pypy/dist/pypy/translator/llvm/pythonllvm/doc/pyllvm.cpp.org
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/doc/pyllvm.cpp.org Sun Apr 2 13:08:28 2006
@@ -0,0 +1,473 @@
+
+// python includes
+#include <Python.h>
+#include <structmember.h>
+
+// llvm includes
+#include "llvm/Type.h"
+#include "llvm/Module.h"
+#include "llvm/ModuleProvider.h"
+#include "llvm/Assembly/Parser.h"
+#include "llvm/Bytecode/Reader.h"
+#include "llvm/ExecutionEngine/GenericValue.h"
+#include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/Analysis/Verifier.h"
+#include "llvm/DerivedTypes.h"
+
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Target/TargetOptions.h"
+
+
+// c++ includes
+#include <string>
+#include <iostream>
+
+using namespace llvm;
+
+typedef struct {
+ PyObject_HEAD
+ ExecutionEngine *exec;
+
+} PyExecutionEngine;
+
+
+/*
+XXX we should probably support parsing one function at a time too.
+This would enable use to use self->exec->recompileAndRelinkFunction(Function* F)
+to support rebinding to a new (more blocks?) function. (or self modifying code)
+*/
+static PyObject *ee_parse(PyExecutionEngine *self, PyObject *args) {
+
+ // check number of parameters
+ if (PyTuple_Size(args) < 1 or PyTuple_Size(args) > 2) {
+ PyErr_SetString(PyExc_TypeError, "expected one or two parameters");
+ return NULL;
+ }
+
+ // get first parameter (llcode)
+ PyObject *pyllcode = PyTuple_GetItem(args, 0);
+ if (!PyString_Check(pyllcode)) {
+ PyErr_SetString(PyExc_TypeError, "first arg expected as string with llcode");
+ return NULL;
+ }
+ const char* llcode = PyString_AsString(pyllcode);
+
+ // get optional second parameter (fnname)
+ const char* fnname = NULL;
+ if (PyTuple_Size(args) > 1) {
+ PyObject *pyfnname = PyTuple_GetItem(args, 1);
+ if (!PyString_Check(pyllcode)) {
+ PyErr_SetString(PyExc_TypeError, "second arg expected as string with functionname");
+ return NULL;
+ }
+ fnname = PyString_AsString(pyfnname);
+ }
+
+ // parse and verify llcode
+ try {
+ Module *M = &self->exec->getModule();
+
+ if (fnname) {
+ Function *F = M->getNamedFunction(fnname);
+ if (F == NULL) {
+ PyErr_SetString(PyExc_Exception, "Failed to resolve function to be replaced");
+ return NULL;
+ }
+ F->setName(""); // now it won't conflicht
+ ParseAssemblyString(llcode, M);
+ Function *Fnew = M->getNamedFunction(fnname);
+ F->replaceAllUsesWith(Fnew); // Everything using the old one uses the new one
+ self->exec->freeMachineCodeForFunction(F); // still no-op on march 27th 2006
+ F->eraseFromParent(); // also, take it out of the JIT (LLVM IR) if it was in it
+
+ /*
+ XXX this is a really dump implementation!!! Should really be somehthing like...
+ codegend_uses = list of function that have codegen'd calls to F
+ for func in codegend_uses:
+ self->exec->recompileAndRelinkFunction(func);
+ // what about (codegen-ed) pointers to F?
+ */
+ Module::FunctionListType &fns = M->getFunctionList();
+ for (Module::FunctionListType::iterator ii = fns.begin();
+ ii != fns.end();
+ ++ii) {
+ if (!(ii->isIntrinsic() || ii->isExternal())) {
+ self->exec->recompileAndRelinkFunction(ii);
+ }
+ }
+ } else {
+ ParseAssemblyString(llcode, M);
+ }
+
+ verifyModule(*M, ThrowExceptionAction); // XXX make this optional for performance?
+ Py_INCREF(Py_None);
+ return Py_None;
+
+ } catch (const ParseException &ref) {
+ PyErr_SetString(PyExc_Exception, ref.getMessage().c_str());
+
+ } catch (...) {
+ PyErr_SetString(PyExc_Exception, "Unexpected unknown exception occurred");
+ }
+
+ return NULL;
+}
+
+static int from_python_to_args(std::vector<GenericValue> &llvmargs,
+ PyObject *value,
+ const Type *type) {
+ // XXX Flesh out
+ GenericValue res;
+ if (type->getTypeID() == Type::IntTyID) {
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "expected an integer type");
+ return -1;
+ }
+ res.IntVal = PyInt_AsLong(value);
+ llvmargs.push_back(res);
+ return 0;
+ }
+
+ std::string err = "unsupported type: " + type->getDescription();
+ PyErr_SetString(PyExc_TypeError, err.c_str());
+ return -1;
+}
+
+static PyObject *to_python_value(const GenericValue &value,
+ const Type *type) {
+
+ // special case for strings - it is your own fault if not NULL terminated
+ if (type->getTypeID() == Type::PointerTyID &&
+ type->getContainedType(0)->getTypeID() == Type::SByteTyID) {
+ return PyString_FromString((const char *) value.PointerVal);
+ }
+
+ PyObject *res;
+
+ switch (type->getTypeID()) {
+
+ case Type::VoidTyID:
+ Py_INCREF(Py_None);
+ res = Py_None;
+ break;
+
+ case Type::BoolTyID:
+ res = PyBool_FromLong((long) value.BoolVal);
+ break;
+
+ case Type::UByteTyID:
+ res = PyInt_FromLong((long) value.UByteVal);
+ break;
+
+ case Type::SByteTyID:
+ res = PyInt_FromLong((long) value.SByteVal);
+ break;
+
+ case Type::UShortTyID:
+ res = PyInt_FromLong((long) value.UShortVal);
+ break;
+
+ case Type::ShortTyID:
+ res = PyInt_FromLong((long) value.ShortVal);
+ break;
+
+ case Type::UIntTyID:
+ res = PyLong_FromUnsignedLong(value.UIntVal);
+ break;
+
+ case Type::IntTyID:
+ res = PyInt_FromLong(value.IntVal);
+ break;
+
+ case Type::ULongTyID:
+ res = PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value.ULongVal);
+ break;
+
+ case Type::LongTyID:
+ res = PyLong_FromLongLong((PY_LONG_LONG) value.ULongVal);
+ break;
+
+ // XXX the rest
+ default:
+ std::string err = "unsupported type: " + type->getDescription();
+ PyErr_SetString(PyExc_TypeError, err.c_str());
+ res = NULL;
+ }
+
+ return res;
+}
+
+static PyObject *ee_call(PyExecutionEngine *self, PyObject *args) {
+
+ if (PyTuple_Size(args) == 0) {
+ PyErr_SetString(PyExc_TypeError, "missing functionname");
+ return NULL;
+ }
+
+ PyObject *pyfnname = PyTuple_GetItem(args, 0);
+ if (!PyString_Check(pyfnname)) {
+ PyErr_SetString(PyExc_TypeError, "first arg expected as string");
+ return NULL;
+ }
+ char *fnname = PyString_AsString(pyfnname);
+
+ try {
+ Function *fn = self->exec->getModule().getNamedFunction(fnname);
+ if (fn == NULL) {
+ PyErr_SetString(PyExc_Exception, "Failed to resolve function to call");
+ return NULL;
+ }
+
+ unsigned argcount = fn->getFunctionType()->getNumParams();
+ if ((unsigned) PyTuple_Size(args) != argcount + 1) {
+ PyErr_SetString(PyExc_TypeError, "args not much count");
+ return NULL;
+ }
+
+ std::vector<GenericValue> llvmargs;
+ for (unsigned ii=0; ii<argcount; ii++) {
+ if (from_python_to_args(llvmargs,
+ PyTuple_GetItem(args, ii+1),
+ fn->getFunctionType()->getParamType(ii)) == -1) {
+ return NULL;
+ }
+ }
+
+ GenericValue ret = self->exec->runFunction(fn, llvmargs);
+ return to_python_value(ret, fn->getFunctionType()->getReturnType());
+
+ } catch (...) {
+ PyErr_SetString(PyExc_Exception, "Unexpected unknown exception occurred");
+ return NULL;
+ }
+}
+
+static PyObject *ee_delete(PyExecutionEngine *self, PyObject *args) {
+
+ if (PyTuple_Size(args) != 1) {
+ PyErr_SetString(PyExc_TypeError, "missing functionname");
+ return NULL;
+ }
+
+ PyObject *pyfnname = PyTuple_GetItem(args, 0);
+ if (!PyString_Check(pyfnname)) {
+ PyErr_SetString(PyExc_TypeError, "functionname expected as string");
+ return NULL;
+ }
+ char *fnname = PyString_AsString(pyfnname);
+
+ try {
+ Function *fn = self->exec->getModule().getNamedFunction(fnname);
+ if (fn == NULL) {
+ PyErr_SetString(PyExc_Exception, "Failed to resolve function to delete");
+ return NULL;
+ }
+
+ // XXX fn should not be refered to from anywhere! Check for this?
+ self->exec->freeMachineCodeForFunction(fn); // still no-op on march 27th 2006
+ fn->eraseFromParent();
+ } catch (...) {
+ PyErr_SetString(PyExc_Exception, "Unexpected unknown exception occurred");
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *ee_functions(PyExecutionEngine *self) {
+ int funccount = 0;
+ Module::FunctionListType &fns = self->exec->getModule().getFunctionList();
+ // spin thrru and get function count
+ for (Module::FunctionListType::const_iterator ii = fns.begin(); ii != fns.end(); ++ii) {
+ if (!(ii->isIntrinsic() || ii->isExternal())) {
+ funccount += 1;
+ }
+ }
+
+ PyObject *functions = PyTuple_New(funccount);
+
+ int count = 0;
+ for (Module::FunctionListType::const_iterator ii = fns.begin();
+ ii != fns.end();
+ ++ii, funccount++) {
+ if (!(ii->isIntrinsic() || ii->isExternal())) {
+
+ unsigned argcount = ii->getFunctionType()->getNumParams();
+
+ PyObject *entry = PyTuple_New(3);
+
+ PyObject *returnId = PyInt_FromLong(ii->getFunctionType()->getReturnType()->getTypeID());
+ PyObject *name = PyString_FromString(ii->getName().c_str());
+ PyObject *args = PyTuple_New(argcount);
+
+ for (unsigned jj=0; jj<argcount; jj++) {
+ long argtype = ii->getFunctionType()->getParamType(jj)->getTypeID();
+ PyTuple_SetItem(args, (long) jj, PyInt_FromLong(argtype));
+ }
+
+ PyTuple_SetItem(entry, 0, returnId);
+ PyTuple_SetItem(entry, 1, name);
+ PyTuple_SetItem(entry, 2, args);
+
+ PyTuple_SetItem(functions, count, entry);
+ count += 1;
+ }
+ }
+
+ return functions;
+}
+
+static PyMethodDef ee_methodlist[] = {
+ {"parse" , (PyCFunction) ee_parse , METH_VARARGS, NULL},
+ {"call" , (PyCFunction) ee_call , METH_VARARGS, NULL},
+ {"delete" , (PyCFunction) ee_delete , METH_VARARGS, NULL},
+ {"functions", (PyCFunction) ee_functions, METH_NOARGS , NULL},
+
+ {NULL, NULL}
+};
+
+void ee_dealloc(PyExecutionEngine *self);
+PyObject *ee_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
+
+// PyTypeObject - pythons type structure
+PyTypeObject ExecutionEngine_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0,
+ "ExecutionEngine",
+ sizeof(PyExecutionEngine),
+ 0,
+ (destructor)ee_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ ee_methodlist, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
+
+PyObject *pyllvm_execution_engine;
+
+static PyObject *ee_factory() {
+
+ if (pyllvm_execution_engine != NULL) {
+ PyErr_SetString(PyExc_Exception, "This should not happen");
+ return NULL;
+ }
+
+ ExecutionEngine *exec;
+
+ try {
+ Module *mod = new Module((const char *) "my module");
+ ModuleProvider *mp = new ExistingModuleProvider(mod);
+ exec = ExecutionEngine::create(mp, false);
+ assert(exec && "Couldn't create an ExecutionEngine, not even an interpreter?");
+ } catch (...) {
+ PyErr_SetString(PyExc_Exception, "Unexpected unknown exception occurred");
+ return NULL;
+ }
+
+ PyTypeObject *type = &ExecutionEngine_Type;
+
+ PyExecutionEngine *self = (PyExecutionEngine *) type->tp_alloc(type, 0);
+ self->exec = exec;
+
+ return (PyObject *) self;
+}
+
+void ee_dealloc(PyExecutionEngine *self) {
+ self->ob_type->tp_free((PyObject*) self);
+}
+
+static PyObject *pyllvm_get_ee(PyObject *self, PyObject *args) {
+ if (pyllvm_execution_engine != NULL) {
+ Py_INCREF(pyllvm_execution_engine);
+ return pyllvm_execution_engine;
+ }
+
+ pyllvm_execution_engine = ee_factory();
+ return pyllvm_execution_engine;
+}
+
+static PyObject *pyllvm_delete_ee(PyObject *self, PyObject *args) {
+ PyExecutionEngine *ee = (PyExecutionEngine *) pyllvm_execution_engine;
+ if (ee != NULL) {
+
+ // bye
+ if (ee->exec != NULL) {
+ delete ee->exec;
+ }
+
+ Py_DECREF(pyllvm_execution_engine);
+ pyllvm_execution_engine = NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *pyllvm_toggle_print_machineinstrs(PyObject *self, PyObject *args) {
+ PrintMachineCode = !PrintMachineCode;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+PyMethodDef pyllvm_functions[] = {
+ {"get_ee" , pyllvm_get_ee , METH_NOARGS, NULL},
+ {"delete_ee" , pyllvm_delete_ee , METH_NOARGS, NULL},
+ {"toggle_print_machineinstrs", pyllvm_toggle_print_machineinstrs, METH_NOARGS, NULL},
+ {NULL, NULL}
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void initpyllvm(void) {
+ PyObject *module = Py_InitModule("pyllvm", pyllvm_functions);
+
+ if(PyType_Ready(&ExecutionEngine_Type) < 0) {
+ return;
+ }
+
+ Py_INCREF(&ExecutionEngine_Type);
+ PyModule_AddObject(module, "ExecutionEngine",
+ (PyObject*) &ExecutionEngine_Type);
+
+ if (0) { // pass in `lli` type parameters
+ static char * Args[] = { "", "-print-machineinstrs", 0 };
+ int n_args = 2;
+ cl::ParseCommandLineOptions(n_args, Args);
+ }
+}
+
+}
Added: pypy/dist/pypy/translator/llvm/pythonllvm/helper.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/helper.py Sun Apr 2 13:08:28 2006
@@ -0,0 +1,24 @@
+'''
+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)
+ a += args
+ 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])
Added: pypy/dist/pypy/translator/llvm/pythonllvm/llvmcapi.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/llvmcapi.py Sun Apr 2 13:08:28 2006
@@ -0,0 +1,90 @@
+# generated by 'xml2py'
+# flags 'llvmcapi.xml -l ../llvmcapi/llvmcapi.so -o llvmcapi.tmp'
+from cc import *
+STRING = c_char_p
+
+
+
+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_n_functions(EE):
+ # ../llvmcapi/include/ExecutionEngine/ExecutionEngine.h 14
+ return ExecutionEngine_n_functions._api_(EE)
+ExecutionEngine_n_functions = cdecl(c_int, 'llvmcapi', [c_void_p]) (ExecutionEngine_n_functions)
+
+
+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 17
+ 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 18
+ return Module_setModuleInlineAsm._api_(M, Asm)
+Module_setModuleInlineAsm = cdecl(None, 'llvmcapi', [c_void_p, STRING]) (Module_setModuleInlineAsm)
+
+
+def Module_ParseAssemblyString(M, AsmString):
+ # ../llvmcapi/include/VMCore/Module.h 19
+ 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 20
+ return Module_verifyModule._api_(M)
+Module_verifyModule = cdecl(c_int, 'llvmcapi', [c_void_p]) (Module_verifyModule)
+
+
+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__)
+
+
+def toggle_print_machineinstrs():
+ # ../llvmcapi/include/llvmcapi.h 13
+ return toggle_print_machineinstrs._api_()
+toggle_print_machineinstrs = cdecl(None, 'llvmcapi', []) (toggle_print_machineinstrs)
+
Added: pypy/dist/pypy/translator/llvm/pythonllvm/pyllvm.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/pyllvm.py Sun Apr 2 13:08:28 2006
@@ -0,0 +1,29 @@
+from helper import *
+
+class Module(Wrapper):
+ def __init__(self, ModuleID='mymodule'):
+ self.instance = Module__init__(ModuleID)
+
+class ModuleProvider(Wrapper):
+ pass
+
+class ExistingModuleProvider(ModuleProvider):
+ def __init__(self, M=None):
+ if not M:
+ M = Module()
+ self.instance = ExistingModuleProvider__init__(M.instance)
+
+class ExecutionEngine(Wrapper):
+ def __init__(self, MP=None, ForceInterpreter=False):
+ if not MP:
+ MP = ExistingModuleProvider();
+ self.instance = ExecutionEngine__create__(MP.instance, ForceInterpreter)
+
+ def getModule(self):
+ m = object.__new__(Module)
+ m.instance = ExecutionEngine_getModule(self.instance)
+ return m
+
+ def parse(self, llcode):
+ self.getModule().ParseAssemblyString(llcode)
+ self.getModule().verifyModule()
Added: pypy/dist/pypy/translator/llvm/pythonllvm/test/.gdb_history
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/test/.gdb_history Sun Apr 2 13:08:28 2006
@@ -0,0 +1 @@
+run
Added: pypy/dist/pypy/translator/llvm/pythonllvm/test/__init__.py
==============================================================================
Added: pypy/dist/pypy/translator/llvm/pythonllvm/test/addnumbers.c
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/test/addnumbers.c Sun Apr 2 13:08:28 2006
@@ -0,0 +1,4 @@
+int add(int n, int y) {
+ return n + y;
+}
+
Added: pypy/dist/pypy/translator/llvm/pythonllvm/test/addnumbers.s
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/test/addnumbers.s Sun Apr 2 13:08:28 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/pythonllvm/test/hello.c
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/test/hello.c Sun Apr 2 13:08:28 2006
@@ -0,0 +1,9 @@
+char *gethellostr() {
+ return "hello world\n";
+}
+
+int hello() {
+ printf(gethellostr());
+ return 0;
+}
+
Added: pypy/dist/pypy/translator/llvm/pythonllvm/test/hello.s
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/test/hello.s Sun Apr 2 13:08:28 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/pythonllvm/test/ll_snippet.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/test/ll_snippet.py Sun Apr 2 13:08:28 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/pythonllvm/test/test_ee.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/pythonllvm/test/test_ee.py Sun Apr 2 13:08:28 2006
@@ -0,0 +1,126 @@
+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.pythonllvm import pyllvm
+from pypy.translator.llvm.pythonllvm.test import ll_snippet
+
+py.test.skip("WIP")
+
+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())
+ assert ee.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, ee.n_functions, 1)
+ py.test.raises(Exception, ee.n_functions, "string")
+
+def test_call_parse_once():
+ ee = pyllvm.ExecutionEngine()
+ ee.parse(codepath.join("hello.s").read())
+ assert ee.call("hello") == 0
+ assert ee.call("gethellostr") == "hello world\n"
+ py.test.raises(Exception, ee.call)
+ py.test.raises(Exception, ee.call, 1)
+ py.test.raises(Exception, ee.call, "gethellostrx")
+ py.test.raises(Exception, ee.call, "gethellostrx", 1)
+ py.test.raises(Exception, ee.call, "gethellostr", 1)
+
+def test_call_parse_twice():
+ ee = pyllvm.ExecutionEngine()
+ ee.parse(codepath.join("hello.s").read())
+ assert ee.call("gethellostr") == "hello world\n"
+ ee.parse(codepath.join("addnumbers.s").read())
+ assert ee.call("add", 10, 32) == 42
+ assert ee.call("gethellostr") == "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)
+ assert ee.call("add1", 41) == 42
+ assert ee.call("calc", 122) == 123
+
+def test_replace_function():
+ """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)
+ assert ee.call("add1", 41) == 42
+ assert ee.call("calc", 122) == 123 #XXX need recompileAndRelinkFunction somewhere
+ ee.parse(ll_snippet.add1_version2, "add1")
+ assert ee.call("add1", 42) == 142
+ assert ee.call("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)
+ assert ee.call("add1_to_global_int_a") == 101
+ assert ee.call("sub10_from_global_int_a") == 91
+ assert ee.call("add1_to_global_int_a") == 92
+ assert ee.call("sub10_from_global_int_a") == 82
+
+def test_native_code(): #examine JIT generate native (assembly) code
+ pyllvm.toggle_print_machineinstrs()
+ ee = pyllvm.ExecutionEngine()
+ ee.parse(ll_snippet.calc)
+ ee.parse(ll_snippet.add1)
+ assert ee.call("calc", 41) == 42
+ pyllvm.toggle_print_machineinstrs()
+
+def test_delete_function(): #this will only work if nothing uses Fn of course!
+ ee = pyllvm.ExecutionEngine()
+ ee.parse(ll_snippet.calc)
+ ee.parse(ll_snippet.add1)
+ assert ee.n_functions() == 2
+
+ ee.delete("calc")
+ assert ee.n_functions() == 1
+ assert ee.call("add1", 41) == 42
+
+ ee.delete("add1")
+ assert ee.n_functions() == 0
+
+ ee.parse(ll_snippet.calc)
+ ee.parse(ll_snippet.add1)
+ assert ee.call("calc", 100) == 101
+
+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