[pypy-svn] r15927 - in pypy/dist/pypy/translator/llvm2: . module
ericvrp at codespeak.net
ericvrp at codespeak.net
Wed Aug 10 18:12:10 CEST 2005
Author: ericvrp
Date: Wed Aug 10 18:12:08 2005
New Revision: 15927
Modified:
pypy/dist/pypy/translator/llvm2/codewriter.py
pypy/dist/pypy/translator/llvm2/database.py
pypy/dist/pypy/translator/llvm2/funcnode.py
pypy/dist/pypy/translator/llvm2/genllvm.py
pypy/dist/pypy/translator/llvm2/module/extfunction.py
pypy/dist/pypy/translator/llvm2/module/ll_math.py
pypy/dist/pypy/translator/llvm2/module/ll_os.py
pypy/dist/pypy/translator/llvm2/module/ll_time.py
pypy/dist/pypy/translator/llvm2/module/support.py
Log:
made most functions and data internal linkage
Modified: pypy/dist/pypy/translator/llvm2/codewriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/codewriter.py (original)
+++ pypy/dist/pypy/translator/llvm2/codewriter.py Wed Aug 10 18:12:08 2005
@@ -36,7 +36,7 @@
self.append(" %s:" % name)
def globalinstance(self, name, typeandata):
- self.append("%s = global %s" % (name, typeandata))
+ self.append("%s = internal global %s" % (name, typeandata))
def structdef(self, name, typereprs):
self.append("%s = type { %s }" %(name, ", ".join(typereprs)))
@@ -70,9 +70,13 @@
self.indent("switch %s %s, label %%%s [%s ]"
% (intty, cond, defaultdest, labels))
- def openfunc(self, decl):
+ def openfunc(self, decl, is_entrynode=False):
self.newline()
- self.append("fastcc %s {" % (decl,))
+ if is_entrynode:
+ linkage_type = ''
+ else:
+ linkage_type = 'internal '
+ self.append("%sfastcc %s {" % (linkage_type, decl,))
def closefunc(self):
self.append("}")
Modified: pypy/dist/pypy/translator/llvm2/database.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/database.py (original)
+++ pypy/dist/pypy/translator/llvm2/database.py Wed Aug 10 18:12:08 2005
@@ -257,8 +257,9 @@
# Always add type (it is safe)
self.prepare_repr_arg_type(type_)
- def setup_all(self):
+ def setup_all(self, entrynode):
# Constants setup need to be done after the rest
+ self.entrynode = entrynode
while self._pendingsetup:
node = self._pendingsetup.pop()
log.settingup(node)
Modified: pypy/dist/pypy/translator/llvm2/funcnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/funcnode.py (original)
+++ pypy/dist/pypy/translator/llvm2/funcnode.py Wed Aug 10 18:12:08 2005
@@ -68,7 +68,7 @@
def writeimpl(self, codewriter):
graph = self.graph
log.writeimpl(graph.name)
- codewriter.openfunc(self.getdecl())
+ codewriter.openfunc(self.getdecl(), self is self.db.entrynode)
nextblock = graph.startblock
args = graph.startblock.inputargs
l = [x for x in flatten(graph) if isinstance(x, Block)]
Modified: pypy/dist/pypy/translator/llvm2/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm2/genllvm.py Wed Aug 10 18:12:08 2005
@@ -59,7 +59,7 @@
if self.debug: print 'gen_llvm_source db.setup_all) ' + time.ctime()
#7 minutes
- self.db.setup_all()
+ self.db.setup_all(self.db.obj2node[c])
if self.debug: print 'gen_llvm_source typ_decl.writedatatypedecl) ' + time.ctime()
if self.debug: print 'gen_llvm_source n_nodes) %d' % len(self.db.getnodes())
#3 seconds
Modified: pypy/dist/pypy/translator/llvm2/module/extfunction.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/extfunction.py (original)
+++ pypy/dist/pypy/translator/llvm2/module/extfunction.py Wed Aug 10 18:12:08 2005
@@ -13,23 +13,23 @@
gc_boehm = """declare ccc sbyte* %GC_malloc(uint)
declare ccc sbyte* %GC_malloc_atomic(uint)
-fastcc sbyte* %gc_malloc(uint %n) {
+internal fastcc sbyte* %gc_malloc(uint %n) {
%ptr = call ccc sbyte* %GC_malloc(uint %n)
ret sbyte* %ptr
}
-fastcc sbyte* %gc_malloc_atomic(uint %n) {
+internal fastcc sbyte* %gc_malloc_atomic(uint %n) {
%ptr = call ccc sbyte* %GC_malloc_atomic(uint %n)
ret sbyte* %ptr
}
"""
-gc_disabled = """fastcc sbyte* %gc_malloc(uint %n) {
+gc_disabled = """internal fastcc sbyte* %gc_malloc(uint %n) {
%ptr = malloc sbyte, uint %n
ret sbyte* %ptr
}
-fastcc sbyte* %gc_malloc_atomic(uint %n) {
+internal fastcc sbyte* %gc_malloc_atomic(uint %n) {
%ptr = malloc sbyte, uint %n
ret sbyte* %ptr
}
Modified: pypy/dist/pypy/translator/llvm2/module/ll_math.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/ll_math.py (original)
+++ pypy/dist/pypy/translator/llvm2/module/ll_math.py Wed Aug 10 18:12:08 2005
@@ -30,7 +30,7 @@
]
simple_function_template = """
-fastcc double %%ll_math_%(function)s(%(params)s) {
+internal fastcc double %%ll_math_%(function)s(%(params)s) {
%%t = call ccc double %%%(function)s(%(params)s)
ret double %%t
}
Modified: pypy/dist/pypy/translator/llvm2/module/ll_os.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/ll_os.py (original)
+++ pypy/dist/pypy/translator/llvm2/module/ll_os.py Wed Aug 10 18:12:08 2005
@@ -13,7 +13,7 @@
extfunctions = {}
extfunctions["%ll_os_dup"] = ((), """
-fastcc int %ll_os_dup(int %fd) {
+internal fastcc int %ll_os_dup(int %fd) {
%ret = call ccc int %dup(int %fd)
ret int %ret
}
@@ -21,7 +21,7 @@
""")
extfunctions["%ll_os_close"] = ((), """
-fastcc void %ll_os_close(int %fd) {
+internal fastcc void %ll_os_close(int %fd) {
call ccc void %close(int %fd)
ret void
}
@@ -29,7 +29,7 @@
""")
extfunctions["%ll_os_open"] = (("%cast",), """
-fastcc int %ll_os_open(%structtype.rpy_string* %structstring, int %flag, int %mode) {
+internal fastcc int %ll_os_open(%structtype.rpy_string* %structstring, int %flag, int %mode) {
%dest = call fastcc sbyte* %cast(%structtype.rpy_string* %structstring)
%fd = call ccc int %open(sbyte* %dest, int %flag, int %mode)
ret int %fd
@@ -38,7 +38,7 @@
""")
extfunctions["%ll_os_write"] = (("%cast",), """
-fastcc int %ll_os_write(int %fd, %structtype.rpy_string* %structstring) {
+internal fastcc int %ll_os_write(int %fd, %structtype.rpy_string* %structstring) {
%reallengthptr = getelementptr %structtype.rpy_string* %structstring, int 0, uint 1, uint 0
%reallength = load int* %reallengthptr
%dest = call fastcc sbyte* %cast(%structtype.rpy_string* %structstring)
@@ -49,7 +49,7 @@
""")
extfunctions["%ll_read_into"] = ((), """
-fastcc int %ll_read_into(int %fd, %structtype.rpy_string* %structstring) {
+internal fastcc int %ll_read_into(int %fd, %structtype.rpy_string* %structstring) {
%reallengthptr = getelementptr %structtype.rpy_string* %structstring, int 0, uint 1, uint 0
%reallength = load int* %reallengthptr
@@ -63,7 +63,7 @@
""")
extfunctions["%ll_os_isatty"] = ((), """
-fastcc bool %ll_os_isatty(int %fd) {
+internal fastcc bool %ll_os_isatty(int %fd) {
%ret = call ccc int %isatty(int %fd)
%ret.bool = cast int %ret to bool
ret bool %ret.bool
@@ -72,7 +72,7 @@
""")
extfunctions["%ll_os_fstat"] = ((), """
-%structtype.tuple10* %ll_os_fstat(int %fd) {
+internal fastcc %structtype.tuple10* %ll_os_fstat(int %fd) {
%st = alloca int, uint 32
%error = call ccc int %fstat(int %fd, int* %st)
;TODO XXX if error: raise exception
Modified: pypy/dist/pypy/translator/llvm2/module/ll_time.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/ll_time.py (original)
+++ pypy/dist/pypy/translator/llvm2/module/ll_time.py Wed Aug 10 18:12:08 2005
@@ -19,7 +19,7 @@
extfunctions["%ll_time_time"] = ((), """
-fastcc double %ll_time_time() {
+internal fastcc double %ll_time_time() {
%t = alloca %struct.timeval ; <%struct.timeval*> [#uses=3]
%secs = alloca int ; <int*> [#uses=2]
%tmp.0 = call int %gettimeofday( %struct.timeval* %t, %struct.timeval* null ) ; <int> [#uses=1]
@@ -47,7 +47,7 @@
""")
extfunctions["%ll_time_clock"] = ((), """
-fastcc double %ll_time_clock() {
+internal fastcc double %ll_time_clock() {
entry:
%tmp.0 = call int %clock( ) ; <int> [#uses=1]
%tmp.1 = cast int %tmp.0 to double ; <double> [#uses=1]
@@ -57,7 +57,7 @@
""")
extfunctions["%ll_time_sleep"] = ((), """
-fastcc void %ll_time_sleep(double %secs) {
+internal fastcc void %ll_time_sleep(double %secs) {
entry:
%t = alloca %struct.timeval ; <%struct.timeval*> [#uses=3]
%tmp.0 = call double %fmod( double %secs, double 1.000000e+00 ) ; <double> [#uses=1]
Modified: pypy/dist/pypy/translator/llvm2/module/support.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/support.py (original)
+++ pypy/dist/pypy/translator/llvm2/module/support.py Wed Aug 10 18:12:08 2005
@@ -7,7 +7,7 @@
extfunctions = {}
extfunctions["%cast"] = ((), """
-fastcc sbyte* %cast(%structtype.rpy_string* %structstring) {
+internal fastcc sbyte* %cast(%structtype.rpy_string* %structstring) {
%reallengthptr = getelementptr %structtype.rpy_string* %structstring, int 0, uint 1, uint 0
%reallength = load int* %reallengthptr
%length = add int %reallength, 1
@@ -31,7 +31,7 @@
#abs functions
extfunctions["%int_abs"] = ((), """
-fastcc int %int_abs(int %x) {
+internal fastcc int %int_abs(int %x) {
block0:
%cond1 = setge int %x, 0
br bool %cond1, label %return_block, label %block1
@@ -46,7 +46,7 @@
""")
extfunctions["%float_abs"] = ((), """
-fastcc double %float_abs(double %x) {
+internal fastcc double %float_abs(double %x) {
block0:
%cond1 = setge double %x, 0.0
br bool %cond1, label %return_block, label %block1
@@ -64,7 +64,7 @@
#prepare exceptions
for exc in "ZeroDivisionError OverflowError ValueError".split(): #_ZER _OVF _VAL
extfunctions["%%__prepare_%(exc)s" % locals()] = ((), """
-fastcc void %%__prepare_%(exc)s() {
+internal fastcc void %%__prepare_%(exc)s() {
%%exception_value = call fastcc %%structtype.object* %%instantiate_%(exc)s()
%%tmp = getelementptr %%structtype.object* %%exception_value, int 0, uint 0
%%exception_type = load %%structtype.object_vtable** %%tmp
@@ -80,7 +80,7 @@
func, inst = func_inst.split(':')
for type_ in "int uint".split():
extfunctions["%%%(type_)s_%(func)s" % locals()] = (("%__prepare_ZeroDivisionError",), """
-fastcc %(type_)s %%%(type_)s_%(func)s(%(type_)s %%x, %(type_)s %%y) {
+internal fastcc %(type_)s %%%(type_)s_%(func)s(%(type_)s %%x, %(type_)s %%y) {
;zerodiv test
%%cond = seteq %(type_)s %%y, 0
@@ -108,7 +108,7 @@
#unary with OverflowError only
extfunctions["%int_neg_ovf"] = (("%__prepare_OverflowError",), """
-fastcc int %%int_neg_ovf(int %%x) {
+internal fastcc int %%int_neg_ovf(int %%x) {
block1:
%%x2 = sub int 0, %%x
%(int_ovf_test)s
@@ -118,7 +118,7 @@
""" % locals())
extfunctions["%int_abs_ovf"] = (("%__prepare_OverflowError",), """
-fastcc int %%int_abs_ovf(int %%x) {
+internal fastcc int %%int_abs_ovf(int %%x) {
block0:
%%cond1 = setge int %%x, 0
br bool %%cond1, label %%return_block, label %%block1
More information about the Pypy-commit
mailing list