[pypy-svn] r13237 - pypy/dist/pypy/translator/llvm
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Jun 9 19:39:41 CEST 2005
Author: cfbolz
Date: Thu Jun 9 19:39:40 2005
New Revision: 13237
Removed:
pypy/dist/pypy/translator/llvm/int_list.ll
pypy/dist/pypy/translator/llvm/intlist.c
pypy/dist/pypy/translator/llvm/list.c
pypy/dist/pypy/translator/llvm/list_template.ll
pypy/dist/pypy/translator/llvm/make_runtime.py
Modified:
pypy/dist/pypy/translator/llvm/genllvm.py
Log:
removing more files obsoleted by the rtyper. disabling respective modules
in genllvm (soon they will probably go, too).
Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py Thu Jun 9 19:39:40 2005
@@ -72,8 +72,7 @@
self.global_counts = {}
self.local_counts = {}
self.repr_classes = []
- for mod in [representation, funcrepr, typerepr, seqrepr, classrepr,
- pbcrepr, pointerrepr]:
+ for mod in [representation, funcrepr, typerepr, pointerrepr]:
self.repr_classes += [getattr(mod, s)
for s in dir(mod) if "Repr" in s]
#if debug:
@@ -188,7 +187,7 @@
for l_repr in traverse_dependencies(self.l_entrypoint, seen_reprs):
l_repr.collect_init_code(init_block, self.l_entrypoint)
if include == True:
- include_files = ["operations.ll", "class.ll"]
+ include_files = ["class.ll"]
else:
include_files = []
for i, fn in enumerate(include_files):
Deleted: /pypy/dist/pypy/translator/llvm/int_list.ll
==============================================================================
--- /pypy/dist/pypy/translator/llvm/int_list.ll Thu Jun 9 19:39:40 2005
+++ (empty file)
@@ -1,39 +0,0 @@
-
-
-internal %std.list.int* %std.range(int %length) {
-entry:
- %tmp.1 = setlt int %length, 1
- %tmp.3 = malloc %std.list.int
- %tmp.6 = getelementptr %std.list.int* %tmp.3, int 0, uint 0
- br bool %tmp.1, label %then, label %endif
-
-then:
- store uint 0, uint* %tmp.6
- %tmp.8 = getelementptr %std.list.int* %tmp.3, int 0, uint 1
- store int* null, int** %tmp.8
- ret %std.list.int* %tmp.3
-
-endif:
- %tmp.15 = cast int %length to uint
- store uint %tmp.15, uint* %tmp.6
- %tmp.17 = getelementptr %std.list.int* %tmp.3, int 0, uint 1
- %tmp.18 = malloc int, uint %tmp.15
- store int* %tmp.18, int** %tmp.17
- %tmp.255 = setgt int %length, 0
- br bool %tmp.255, label %no_exit, label %UnifiedReturnBlock
-
-no_exit:
- %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %endif ]
- %i.0.0 = cast uint %indvar to int
- %tmp.29 = load int** %tmp.17
- %tmp.31 = getelementptr int* %tmp.29, uint %indvar
- store int %i.0.0, int* %tmp.31
- %tmp.34 = add int %i.0.0, 1
- %tmp.25 = setlt int %tmp.34, %length
- %indvar.next = add uint %indvar, 1
- br bool %tmp.25, label %no_exit, label %UnifiedReturnBlock
-
-UnifiedReturnBlock:
- %UnifiedRetVal = phi %std.list.int* [ %tmp.3, %endif ], [ %tmp.3, %no_exit ]
- ret %std.list.int* %UnifiedRetVal
-}
Deleted: /pypy/dist/pypy/translator/llvm/intlist.c
==============================================================================
--- /pypy/dist/pypy/translator/llvm/intlist.c Thu Jun 9 19:39:40 2005
+++ (empty file)
@@ -1,27 +0,0 @@
-/* implementation of range. This file is transformed to int_list.ll by
-make_runtime.py */
-#include <stdio.h>
-
-struct list_int {
- unsigned int length;
- int* data;
-};
-
-struct list_int* range(int length) {
- int i = 0;
- if (length <= 0) {
- struct list_int* nlist = malloc(sizeof(struct list_int));
- nlist->length = 0;
- nlist->data = NULL;
- return nlist;
- }
- struct list_int* nlist = malloc(sizeof(struct list_int));
- nlist->length = length;
- nlist->data = malloc(sizeof(int) * length);
- while (i < length) {
- nlist->data[i] = i;
- i += 1;
- }
- return nlist;
-}
-
Deleted: /pypy/dist/pypy/translator/llvm/list.c
==============================================================================
--- /pypy/dist/pypy/translator/llvm/list.c Thu Jun 9 19:39:40 2005
+++ (empty file)
@@ -1,188 +0,0 @@
-/* implementation of list methods. This file is transformed to list_template.ll
- by make_runtime.py */
-#include <stdio.h>
-
-signed char unwind();
-
-struct item {
- char* dummy;
-};
-
-struct class {
- char dummy;
-};
-
-
-struct class* LAST_EXCEPTION_TYPE = 0;
-struct class INDEX_ERROR = {0};
-
-
-
-struct list {
- unsigned int length;
- struct item** data;
-};
-
-void copy(struct item** from, struct item** to, unsigned int length) {
- unsigned int i = 0;
- while(i < length) {
- to[i] = from[i];
- i += 1;
- }
-}
-
-int len(struct list* l) {
- return (int) l->length;
-}
-
-int valid_index(int i, struct list* l) {
- if (i < 0)
- return 0;
- if (i >= len(l))
- return 0;
- return 1;
-}
-
-struct list* newlist() {
- struct list* nlist = malloc(sizeof(struct list));
- nlist->length = 0;
- nlist->data = NULL;
- return nlist;
-}
-
-struct list* alloc_and_set(int length, struct item* init) {
- unsigned int i = 0;
- struct list* nlist = malloc(sizeof(struct list));
- nlist->length = (unsigned int)length;
- nlist->data = malloc(sizeof(struct item*) * length);
- while (i < length) {
- nlist->data[i] = init;
- i += 1;
- }
- return nlist;
-}
-
-struct item* getitem(struct list* l, int index) {
- if (index < 0)
- index = l->length + index;
- return l->data[index];
-}
-
-struct item* getitem_EXCEPTION(struct list* l, int index) {
- if (index < 0)
- index = l->length + index;
- if (valid_index(index, l) == 0) {
- LAST_EXCEPTION_TYPE = &INDEX_ERROR;
- return unwind();
- }
- return l->data[index];
-}
-
-void setitem(struct list* l, int index, struct item* value) {
- if (index < 0)
- index = l->length + index;
- l->data[index] = value;
-}
-
-void setitem_EXCEPTION(struct list* l, int index, struct item* value) {
- if (index < 0)
- index = l->length + index;
- if (valid_index(index, l) == 0) {
- LAST_EXCEPTION_TYPE = &INDEX_ERROR;
- unwind();
- return;
- }
- l->data[index] = value;
-}
-
-struct list* add(struct list* a, struct list* b) {
- struct list* nlist = malloc(sizeof(struct list));
- unsigned int newlength = a->length + b->length;
- nlist->length = newlength;
- nlist->data = malloc(sizeof(struct item*) * newlength);
- copy(a->data, nlist->data, a->length);
- copy(b->data, nlist->data + a->length, newlength - a->length);
- return nlist;
-}
-
-struct list* mul(struct list* a, int times) {
- struct list* nlist = malloc(sizeof(struct list));
- unsigned int newlength = a->length * times;
- int i = 0;
- nlist->length = newlength;
- nlist->data = malloc(sizeof(struct item*) * newlength);
- while (i < times) {
- copy(a->data, nlist->data + i * a->length, a->length);
- i += 1;
- }
- return nlist;
-}
-
-struct list* inplace_add(struct list* a, struct list* b) {
- struct item** newdata = malloc(sizeof(struct item*) * (a->length + b->length));
- copy(a->data, newdata, a->length);
- copy(b->data, newdata + a->length, b->length);
- a->length += b->length;
- free(a->data);
- a->data = newdata;
- return a;
-}
-
-void append(struct list* a, struct item* value) {
- struct item** newdata = malloc(sizeof(struct item*) * (a->length + 1));
- newdata[a->length] = value;
- copy(a->data, newdata, a->length);
- a->length += 1;
- free(a->data);
- a->data = newdata;
-}
-
-struct item* pop(struct list* a, int index) {
- if (index < 0)
- index = a->length + index;
- struct item* ret = a->data[index];
- struct item** newdata = malloc(sizeof(struct item*) * (a->length - 1));
- copy(a->data, newdata, index);
- copy(a->data + index + 1, newdata + index, a->length - 1 - index);
- a->length -= 1;
- free(a->data);
- a->data = newdata;
- return ret;
-}
-
-struct item* pop_EXCEPTION(struct list* a, int index) {
- if (index < 0)
- index = a->length + index;
- if (valid_index(index, a) == 0) {
- LAST_EXCEPTION_TYPE = &INDEX_ERROR;
- return unwind();
- }
- struct item* ret = a->data[index];
- struct item** newdata = malloc(sizeof(struct item*) * (a->length - 1));
- copy(a->data, newdata, index);
- copy(a->data + index + 1, newdata + index, a->length - 1 - index);
- a->length -= 1;
- free(a->data);
- a->data = newdata;
- return ret;
-}
-
-
-struct item* pop_ALTERNATIVE1(struct list* a) {
- return pop(a, a->length - 1);
-}
-
-
-void reverse(struct list* a) {
- unsigned int lo = 0;
- unsigned int hi = a->length - 1;
- struct item* temp;
- while (lo < hi) {
- temp = a->data[lo];
- a->data[lo] = a->data[hi];
- a->data[hi] = temp;
- lo += 1;
- hi -= 1;
- }
-}
-
Deleted: /pypy/dist/pypy/translator/llvm/list_template.ll
==============================================================================
--- /pypy/dist/pypy/translator/llvm/list_template.ll Thu Jun 9 19:39:40 2005
+++ (empty file)
@@ -1,546 +0,0 @@
-
-
-internal void %std.copy(%(item)s* %from, %(item)s* %to, uint %length) {
-entry:
- %tmp.25 = seteq uint %length, 0
- br bool %tmp.25, label %return, label %no_exit
-
-no_exit:
- %i.0.0 = phi uint [ %tmp.14, %no_exit ], [ 0, %entry ]
- %tmp.7 = getelementptr %(item)s* %to, uint %i.0.0
- %tmp.11 = getelementptr %(item)s* %from, uint %i.0.0
- %tmp.12 = load %(item)s* %tmp.11
- store %(item)s %tmp.12, %(item)s* %tmp.7
- %tmp.14 = add uint %i.0.0, 1
- %tmp.2 = setlt uint %tmp.14, %length
- br bool %tmp.2, label %no_exit, label %return
-
-return:
- ret void
-}
-
-internal int %std.len(%(name)s* %l) {
-entry:
- %tmp.1 = getelementptr %(name)s* %l, int 0, uint 0
- %tmp.2 = load uint* %tmp.1
- %tmp.3 = cast uint %tmp.2 to int
- ret int %tmp.3
-}
-
-internal int %std.valid_index(int %i, %(name)s* %l) {
-entry:
- %tmp.1 = setlt int %i, 0
- br bool %tmp.1, label %UnifiedReturnBlock, label %endif.0
-
-endif.0:
- %tmp.1.i = getelementptr %(name)s* %l, int 0, uint 0
- %tmp.2.i = load uint* %tmp.1.i
- %tmp.3.i = cast uint %tmp.2.i to int
- %not.tmp.6 = setgt int %tmp.3.i, %i
- %retval = cast bool %not.tmp.6 to int
- ret int %retval
-
-UnifiedReturnBlock:
- ret int 0
-}
-
-internal %(name)s* %std.newlist() {
-entry:
- %tmp.0 = malloc %(name)s
- %tmp.3 = getelementptr %(name)s* %tmp.0, int 0, uint 0
- store uint 0, uint* %tmp.3
- %tmp.5 = getelementptr %(name)s* %tmp.0, int 0, uint 1
- store %(item)s* null, %(item)s** %tmp.5
- ret %(name)s* %tmp.0
-}
-
-internal %(name)s* %std.alloc_and_set(int %length, %(item)s %init) {
-entry:
- %tmp.0 = malloc %(name)s
- %tmp.3 = getelementptr %(name)s* %tmp.0, int 0, uint 0
- %tmp.5 = cast int %length to uint
- store uint %tmp.5, uint* %tmp.3
- %tmp.7 = getelementptr %(name)s* %tmp.0, int 0, uint 1
- %tmp.8 = malloc %(item)s, uint %tmp.5
- store %(item)s* %tmp.8, %(item)s** %tmp.7
- %tmp.165 = seteq int %length, 0
- br bool %tmp.165, label %loopexit, label %no_exit
-
-no_exit:
- %i.0.0 = phi uint [ %tmp.26, %no_exit ], [ 0, %entry ]
- %tmp.20 = load %(item)s** %tmp.7
- %tmp.23 = getelementptr %(item)s* %tmp.20, uint %i.0.0
- store %(item)s %init, %(item)s* %tmp.23
- %tmp.26 = add uint %i.0.0, 1
- %tmp.16 = setgt uint %tmp.5, %tmp.26
- br bool %tmp.16, label %no_exit, label %loopexit
-
-loopexit:
- ret %(name)s* %tmp.0
-}
-
-internal %(item)s %std.getitem(%(name)s* %l, int %index.1) {
-entry:
- %tmp.1 = setlt int %index.1, 0
- %tmp.11 = getelementptr %(name)s* %l, int 0, uint 1
- br bool %tmp.1, label %then, label %endif
-
-then:
- %tmp.4 = getelementptr %(name)s* %l, int 0, uint 0
- %tmp.5 = load uint* %tmp.4
- %tmp.5 = cast uint %tmp.5 to int
- %tmp.9 = add int %tmp.5, %index.1
- %tmp.121 = load %(item)s** %tmp.11
- %tmp.142 = getelementptr %(item)s* %tmp.121, int %tmp.9
- %tmp.153 = load %(item)s* %tmp.142
- ret %(item)s %tmp.153
-
-endif:
- %tmp.12 = load %(item)s** %tmp.11
- %tmp.14 = getelementptr %(item)s* %tmp.12, int %index.1
- %tmp.15 = load %(item)s* %tmp.14
- ret %(item)s %tmp.15
-}
-
-internal %(item)s %std.getitem.exc(%(name)s* %l, int %index.1) {
-entry:
- %tmp.1 = setlt int %index.1, 0
- br bool %tmp.1, label %then.0, label %endif.0.i
-
-then.0:
- %tmp.4 = getelementptr %(name)s* %l, int 0, uint 0
- %tmp.5 = load uint* %tmp.4
- %tmp.5 = cast uint %tmp.5 to int
- %tmp.9 = add int %tmp.5, %index.1
- %tmp.1.i5 = setlt int %tmp.9, 0
- br bool %tmp.1.i5, label %then.1, label %endif.0.i
-
-endif.0.i:
- %index_addr.0.0 = phi int [ %tmp.9, %then.0 ], [ %index.1, %entry ]
- %tmp.1.i.i = getelementptr %(name)s* %l, int 0, uint 0
- %tmp.2.i.i = load uint* %tmp.1.i.i
- %tmp.3.i.i = cast uint %tmp.2.i.i to int
- %tmp.6.i = setgt int %tmp.3.i.i, %index_addr.0.0
- br bool %tmp.6.i, label %endif.1, label %then.1
-
-then.1:
- store %std.class* %glb.class.IndexError.object, %std.class** %std.last_exception.type
- unwind
-endif.1:
- %tmp.19 = getelementptr %(name)s* %l, int 0, uint 1
- %tmp.20 = load %(item)s** %tmp.19
- %tmp.22 = getelementptr %(item)s* %tmp.20, int %index_addr.0.0
- %tmp.23 = load %(item)s* %tmp.22
- ret %(item)s %tmp.23
-}
-
-
-internal void %std.setitem(%(name)s* %l, int %index.1, %(item)s %value) {
-entry:
- %tmp.1 = setlt int %index.1, 0
- %tmp.11 = getelementptr %(name)s* %l, int 0, uint 1
- br bool %tmp.1, label %then, label %endif
-
-then:
- %tmp.4 = getelementptr %(name)s* %l, int 0, uint 0
- %tmp.5 = load uint* %tmp.4
- %tmp.5 = cast uint %tmp.5 to int
- %tmp.9 = add int %tmp.5, %index.1
- %tmp.121 = load %(item)s** %tmp.11
- %tmp.142 = getelementptr %(item)s* %tmp.121, int %tmp.9
- store %(item)s %value, %(item)s* %tmp.142
- ret void
-
-endif:
- %tmp.12 = load %(item)s** %tmp.11
- %tmp.14 = getelementptr %(item)s* %tmp.12, int %index.1
- store %(item)s %value, %(item)s* %tmp.14
- ret void
-}
-
-internal void %std.setitem.exc(%(name)s* %l, int %index.1, %(item)s %value) {
-entry:
- %tmp.1 = setlt int %index.1, 0
- br bool %tmp.1, label %then.0, label %endif.0.i
-
-then.0:
- %tmp.4 = getelementptr %(name)s* %l, int 0, uint 0
- %tmp.5 = load uint* %tmp.4
- %tmp.5 = cast uint %tmp.5 to int
- %tmp.9 = add int %tmp.5, %index.1
- %tmp.1.i5 = setlt int %tmp.9, 0
- br bool %tmp.1.i5, label %then.1, label %endif.0.i
-
-endif.0.i:
- %index_addr.0.0 = phi int [ %tmp.9, %then.0 ], [ %index.1, %entry ]
- %tmp.1.i.i = getelementptr %(name)s* %l, int 0, uint 0
- %tmp.2.i.i = load uint* %tmp.1.i.i
- %tmp.3.i.i = cast uint %tmp.2.i.i to int
- %tmp.6.i = setgt int %tmp.3.i.i, %index_addr.0.0
- br bool %tmp.6.i, label %endif.1, label %then.1
-
-then.1:
- store %std.class* %glb.class.IndexError.object, %std.class** %std.last_exception.type
- unwind
-endif.1:
- %tmp.17 = getelementptr %(name)s* %l, int 0, uint 1
- %tmp.18 = load %(item)s** %tmp.17
- %tmp.20 = getelementptr %(item)s* %tmp.18, int %index_addr.0.0
- store %(item)s %value, %(item)s* %tmp.20
- ret void
-}
-
-internal %(name)s* %std.add(%(name)s* %a, %(name)s* %b) {
-entry:
- %tmp.0 = malloc %(name)s
- %tmp.3 = getelementptr %(name)s* %a, int 0, uint 0
- %tmp.4 = load uint* %tmp.3
- %tmp.6 = getelementptr %(name)s* %b, int 0, uint 0
- %tmp.7 = load uint* %tmp.6
- %tmp.8 = add uint %tmp.7, %tmp.4
- %tmp.10 = getelementptr %(name)s* %tmp.0, int 0, uint 0
- store uint %tmp.8, uint* %tmp.10
- %tmp.13 = getelementptr %(name)s* %tmp.0, int 0, uint 1
- %tmp.14 = malloc %(item)s, uint %tmp.8
- store %(item)s* %tmp.14, %(item)s** %tmp.13
- %tmp.19 = getelementptr %(name)s* %a, int 0, uint 1
- %tmp.20 = load %(item)s** %tmp.19
- %tmp.2.i14 = seteq uint %tmp.4, 0
- br bool %tmp.2.i14, label %copy.entry, label %no_exit.i
-
-no_exit.i:
- %i.0.i.0 = phi uint [ %tmp.14.i, %no_exit.i ], [ 0, %entry ]
- %tmp.7.i = getelementptr %(item)s* %tmp.14, uint %i.0.i.0
- %tmp.11.i = getelementptr %(item)s* %tmp.20, uint %i.0.i.0
- %tmp.12.i = load %(item)s* %tmp.11.i
- store %(item)s %tmp.12.i, %(item)s* %tmp.7.i
- %tmp.14.i = add uint %i.0.i.0, 1
- %tmp.2.i = setlt uint %tmp.14.i, %tmp.4
- br bool %tmp.2.i, label %no_exit.i, label %copy.entry
-
-copy.entry:
- %tmp.28 = getelementptr %(name)s* %b, int 0, uint 1
- %tmp.29 = load %(item)s** %tmp.28
- %tmp.42 = sub uint %tmp.8, %tmp.4
- %tmp.2.i319 = seteq uint %tmp.8, %tmp.4
- br bool %tmp.2.i319, label %copy.entry9, label %no_exit.i4
-
-no_exit.i4:
- %i.0.i2.0 = phi uint [ %tmp.14.i8, %no_exit.i4 ], [ 0, %copy.entry ]
- %tmp.37.sum = add uint %i.0.i2.0, %tmp.4
- %tmp.7.i5 = getelementptr %(item)s* %tmp.14, uint %tmp.37.sum
- %tmp.11.i6 = getelementptr %(item)s* %tmp.29, uint %i.0.i2.0
- %tmp.12.i7 = load %(item)s* %tmp.11.i6
- store %(item)s %tmp.12.i7, %(item)s* %tmp.7.i5
- %tmp.14.i8 = add uint %i.0.i2.0, 1
- %tmp.2.i3 = setlt uint %tmp.14.i8, %tmp.42
- br bool %tmp.2.i3, label %no_exit.i4, label %copy.entry9
-
-copy.entry9:
- ret %(name)s* %tmp.0
-}
-
-internal %(name)s* %std.mul(%(name)s* %a, int %times) {
-entry:
- %tmp.0 = malloc %(name)s
- %tmp.3 = getelementptr %(name)s* %a, int 0, uint 0
- %tmp.4 = load uint* %tmp.3
- %tmp.6 = cast int %times to uint
- %tmp.7 = mul uint %tmp.4, %tmp.6
- %tmp.9 = getelementptr %(name)s* %tmp.0, int 0, uint 0
- store uint %tmp.7, uint* %tmp.9
- %tmp.12 = getelementptr %(name)s* %tmp.0, int 0, uint 1
- %tmp.13 = malloc %(item)s, uint %tmp.7
- store %(item)s* %tmp.13, %(item)s** %tmp.12
- %tmp.194 = setgt int %times, 0
- br bool %tmp.194, label %no_exit.preheader, label %loopexit
-
-no_exit.preheader:
- %tmp.22 = getelementptr %(name)s* %a, int 0, uint 1
- br label %no_exit
-
-no_exit:
- %indvar = phi uint [ 0, %no_exit.preheader ], [ %indvar.next10, %copy.entry ]
- %i.0.0 = cast uint %indvar to int
- %tmp.23 = load %(item)s** %tmp.22
- %tmp.26 = load %(item)s** %tmp.12
- %tmp.29 = load uint* %tmp.3
- %tmp.32 = mul uint %indvar, %tmp.29
- %tmp.2.i9 = seteq uint %tmp.29, 0
- br bool %tmp.2.i9, label %copy.entry, label %no_exit.i
-
-no_exit.i:
- %i.0.i.2 = phi uint [ %tmp.14.i, %no_exit.i ], [ 0, %no_exit ]
- %tmp.34.sum = add uint %i.0.i.2, %tmp.32
- %tmp.7.i = getelementptr %(item)s* %tmp.26, uint %tmp.34.sum
- %tmp.11.i = getelementptr %(item)s* %tmp.23, uint %i.0.i.2
- %tmp.12.i = load %(item)s* %tmp.11.i
- store %(item)s %tmp.12.i, %(item)s* %tmp.7.i
- %tmp.14.i = add uint %i.0.i.2, 1
- %tmp.2.i = setlt uint %tmp.14.i, %tmp.29
- br bool %tmp.2.i, label %no_exit.i, label %copy.entry
-
-copy.entry:
- %tmp.39 = add int %i.0.0, 1
- %tmp.19 = setlt int %tmp.39, %times
- %indvar.next10 = add uint %indvar, 1
- br bool %tmp.19, label %no_exit, label %loopexit
-
-loopexit:
- ret %(name)s* %tmp.0
-}
-
-internal %(name)s* %std.inplace_add(%(name)s* %a, %(name)s* %b) {
-entry:
- %tmp.2 = getelementptr %(name)s* %a, int 0, uint 0
- %tmp.3 = load uint* %tmp.2
- %tmp.5 = getelementptr %(name)s* %b, int 0, uint 0
- %tmp.6 = load uint* %tmp.5
- %tmp.7 = add uint %tmp.6, %tmp.3
- %tmp.0 = malloc %(item)s, uint %tmp.7
- %tmp.11 = getelementptr %(name)s* %a, int 0, uint 1
- %tmp.12 = load %(item)s** %tmp.11
- %tmp.2.i14 = seteq uint %tmp.3, 0
- br bool %tmp.2.i14, label %copy.entry, label %no_exit.i
-
-no_exit.i:
- %i.0.i.0 = phi uint [ %tmp.14.i, %no_exit.i ], [ 0, %entry ]
- %tmp.7.i = getelementptr %(item)s* %tmp.0, uint %i.0.i.0
- %tmp.11.i = getelementptr %(item)s* %tmp.12, uint %i.0.i.0
- %tmp.12.i = load %(item)s* %tmp.11.i
- store %(item)s %tmp.12.i, %(item)s* %tmp.7.i
- %tmp.14.i = add uint %i.0.i.0, 1
- %tmp.2.i = setlt uint %tmp.14.i, %tmp.3
- br bool %tmp.2.i, label %no_exit.i, label %copy.entry
-
-copy.entry:
- %tmp.18 = getelementptr %(name)s* %b, int 0, uint 1
- %tmp.19 = load %(item)s** %tmp.18
- %tmp.2.i319 = seteq uint %tmp.6, 0
- br bool %tmp.2.i319, label %copy.entry9, label %no_exit.i4
-
-no_exit.i4:
- %i.0.i2.0 = phi uint [ %tmp.14.i8, %no_exit.i4 ], [ 0, %copy.entry ]
- %tmp.25.sum = add uint %i.0.i2.0, %tmp.3
- %tmp.7.i5 = getelementptr %(item)s* %tmp.0, uint %tmp.25.sum
- %tmp.11.i6 = getelementptr %(item)s* %tmp.19, uint %i.0.i2.0
- %tmp.12.i7 = load %(item)s* %tmp.11.i6
- store %(item)s %tmp.12.i7, %(item)s* %tmp.7.i5
- %tmp.14.i8 = add uint %i.0.i2.0, 1
- %tmp.2.i3 = setlt uint %tmp.14.i8, %tmp.6
- br bool %tmp.2.i3, label %no_exit.i4, label %copy.entry9
-
-copy.entry9:
- store uint %tmp.7, uint* %tmp.2
- free %(item)s* %tmp.12
- store %(item)s* %tmp.0, %(item)s** %tmp.11
- ret %(name)s* %a
-}
-
-internal void %std.append(%(name)s* %a, %(item)s %value) {
-entry:
- %tmp.2 = getelementptr %(name)s* %a, int 0, uint 0
- %tmp.3 = load uint* %tmp.2
- %tmp.3-off = add uint %tmp.3, 1
- %tmp.0 = malloc %(item)s, uint %tmp.3-off
- %tmp.12 = getelementptr %(item)s* %tmp.0, uint %tmp.3
- store %(item)s %value, %(item)s* %tmp.12
- %tmp.15 = getelementptr %(name)s* %a, int 0, uint 1
- %tmp.16 = load %(item)s** %tmp.15
- %tmp.2.i5 = seteq uint %tmp.3, 0
- br bool %tmp.2.i5, label %copy.entry, label %no_exit.i
-
-no_exit.i:
- %i.0.i.0 = phi uint [ %tmp.14.i, %no_exit.i ], [ 0, %entry ]
- %tmp.7.i = getelementptr %(item)s* %tmp.0, uint %i.0.i.0
- %tmp.11.i = getelementptr %(item)s* %tmp.16, uint %i.0.i.0
- %tmp.12.i = load %(item)s* %tmp.11.i
- store %(item)s %tmp.12.i, %(item)s* %tmp.7.i
- %tmp.14.i = add uint %i.0.i.0, 1
- %tmp.2.i = setlt uint %tmp.14.i, %tmp.3
- br bool %tmp.2.i, label %no_exit.i, label %copy.entry
-
-copy.entry:
- store uint %tmp.3-off, uint* %tmp.2
- free %(item)s* %tmp.16
- store %(item)s* %tmp.0, %(item)s** %tmp.15
- ret void
-}
-
-internal %(item)s %std.pop(%(name)s* %a, int %index.1) {
-entry:
- %tmp.1 = setlt int %index.1, 0
- br bool %tmp.1, label %then, label %endif
-
-then:
- %tmp.4 = getelementptr %(name)s* %a, int 0, uint 0
- %tmp.5 = load uint* %tmp.4
- %tmp.5 = cast uint %tmp.5 to int
- %tmp.9 = add int %tmp.5, %index.1
- br label %endif
-
-endif:
- %index_addr.0 = phi int [ %tmp.9, %then ], [ %index.1, %entry ]
- %tmp.11 = getelementptr %(name)s* %a, int 0, uint 1
- %tmp.12 = load %(item)s** %tmp.11
- %tmp.14 = getelementptr %(item)s* %tmp.12, int %index_addr.0
- %tmp.15 = load %(item)s* %tmp.14
- %tmp.18 = getelementptr %(name)s* %a, int 0, uint 0
- %tmp.19 = load uint* %tmp.18
- %tmp.19-off = add uint %tmp.19, 1073741823
- %tmp.16 = malloc %(item)s, uint %tmp.19-off
- %tmp.28 = cast int %index_addr.0 to uint
- %tmp.2.i14 = seteq int %index_addr.0, 0
- br bool %tmp.2.i14, label %copy.entry, label %no_exit.i
-
-no_exit.i:
- %i.0.i.0 = phi uint [ %tmp.14.i, %no_exit.i ], [ 0, %endif ]
- %tmp.7.i = getelementptr %(item)s* %tmp.16, uint %i.0.i.0
- %tmp.11.i = getelementptr %(item)s* %tmp.12, uint %i.0.i.0
- %tmp.12.i = load %(item)s* %tmp.11.i
- store %(item)s %tmp.12.i, %(item)s* %tmp.7.i
- %tmp.14.i = add uint %i.0.i.0, 1
- %tmp.2.i = setlt uint %tmp.14.i, %tmp.28
- br bool %tmp.2.i, label %no_exit.i, label %copy.entry
-
-copy.entry:
- %tmp.35.sum = add int %index_addr.0, 1
- %tmp.48 = add uint %tmp.19, 4294967295
- %tmp.49 = sub uint %tmp.48, %tmp.28
- %tmp.2.i319 = seteq uint %tmp.48, %tmp.28
- br bool %tmp.2.i319, label %copy.entry9, label %no_exit.i4
-
-no_exit.i4:
- %i.0.i2.0 = phi uint [ %tmp.14.i8, %no_exit.i4 ], [ 0, %copy.entry ]
- %i.0.i2.020 = cast uint %i.0.i2.0 to int
- %tmp.42.sum = add int %i.0.i2.020, %index_addr.0
- %tmp.7.i5 = getelementptr %(item)s* %tmp.16, int %tmp.42.sum
- %tmp.37.sum = add int %i.0.i2.020, %tmp.35.sum
- %tmp.11.i6 = getelementptr %(item)s* %tmp.12, int %tmp.37.sum
- %tmp.12.i7 = load %(item)s* %tmp.11.i6
- store %(item)s %tmp.12.i7, %(item)s* %tmp.7.i5
- %tmp.14.i8 = add uint %i.0.i2.0, 1
- %tmp.2.i3 = setlt uint %tmp.14.i8, %tmp.49
- br bool %tmp.2.i3, label %no_exit.i4, label %copy.entry9
-
-copy.entry9:
- store uint %tmp.48, uint* %tmp.18
- free %(item)s* %tmp.12
- store %(item)s* %tmp.16, %(item)s** %tmp.11
- ret %(item)s %tmp.15
-}
-
-internal %(item)s %std.pop.exc(%(name)s* %a, int %index.1) {
-entry:
- %tmp.1 = setlt int %index.1, 0
- br bool %tmp.1, label %then.0, label %endif.0.i
-
-then.0:
- %tmp.4 = getelementptr %(name)s* %a, int 0, uint 0
- %tmp.5 = load uint* %tmp.4
- %tmp.5 = cast uint %tmp.5 to int
- %tmp.9 = add int %tmp.5, %index.1
- %tmp.1.i20 = setlt int %tmp.9, 0
- br bool %tmp.1.i20, label %then.1, label %endif.0.i
-
-endif.0.i:
- %index_addr.0.0 = phi int [ %tmp.9, %then.0 ], [ %index.1, %entry ]
- %tmp.1.i.i = getelementptr %(name)s* %a, int 0, uint 0
- %tmp.2.i.i = load uint* %tmp.1.i.i
- %tmp.3.i.i = cast uint %tmp.2.i.i to int
- %tmp.6.i = setgt int %tmp.3.i.i, %index_addr.0.0
- br bool %tmp.6.i, label %endif.1, label %then.1
-
-then.1:
- store %std.class* %glb.class.IndexError.object, %std.class** %std.last_exception.type
- unwind
-endif.1:
- %tmp.19 = getelementptr %(name)s* %a, int 0, uint 1
- %tmp.20 = load %(item)s** %tmp.19
- %tmp.22 = getelementptr %(item)s* %tmp.20, int %index_addr.0.0
- %tmp.23 = load %(item)s* %tmp.22
- %tmp.27-off = add uint %tmp.2.i.i, 1073741823
- %tmp.24 = malloc %(item)s, uint %tmp.27-off
- %tmp.36 = cast int %index_addr.0.0 to uint
- %tmp.2.i526 = seteq int %index_addr.0.0, 0
- br bool %tmp.2.i526, label %copy.entry12, label %no_exit.i6
-
-no_exit.i6:
- %i.0.i4.0 = phi uint [ %tmp.14.i10, %no_exit.i6 ], [ 0, %endif.1 ]
- %tmp.7.i7 = getelementptr %(item)s* %tmp.24, uint %i.0.i4.0
- %tmp.11.i8 = getelementptr %(item)s* %tmp.20, uint %i.0.i4.0
- %tmp.12.i9 = load %(item)s* %tmp.11.i8
- store %(item)s %tmp.12.i9, %(item)s* %tmp.7.i7
- %tmp.14.i10 = add uint %i.0.i4.0, 1
- %tmp.2.i5 = setlt uint %tmp.14.i10, %tmp.36
- br bool %tmp.2.i5, label %no_exit.i6, label %copy.entry12
-
-copy.entry12:
- %tmp.43.sum = add int %index_addr.0.0, 1
- %tmp.56 = add uint %tmp.2.i.i, 4294967295
- %tmp.57 = sub uint %tmp.56, %tmp.36
- %tmp.2.i31 = seteq uint %tmp.56, %tmp.36
- br bool %tmp.2.i31, label %copy.entry, label %no_exit.i
-
-no_exit.i:
- %i.0.i.0 = phi uint [ %tmp.14.i, %no_exit.i ], [ 0, %copy.entry12 ]
- %i.0.i.032 = cast uint %i.0.i.0 to int
- %tmp.50.sum = add int %i.0.i.032, %index_addr.0.0
- %tmp.7.i = getelementptr %(item)s* %tmp.24, int %tmp.50.sum
- %tmp.45.sum = add int %i.0.i.032, %tmp.43.sum
- %tmp.11.i = getelementptr %(item)s* %tmp.20, int %tmp.45.sum
- %tmp.12.i = load %(item)s* %tmp.11.i
- store %(item)s %tmp.12.i, %(item)s* %tmp.7.i
- %tmp.14.i = add uint %i.0.i.0, 1
- %tmp.2.i = setlt uint %tmp.14.i, %tmp.57
- br bool %tmp.2.i, label %no_exit.i, label %copy.entry
-
-copy.entry:
- store uint %tmp.56, uint* %tmp.1.i.i
- free %(item)s* %tmp.20
- store %(item)s* %tmp.24, %(item)s** %tmp.19
- ret %(item)s %tmp.23
-}
-
-internal %(item)s %std.pop(%(name)s* %a) {
-entry:
- %tmp.3 = getelementptr %(name)s* %a, int 0, uint 0
- %tmp.4 = load uint* %tmp.3
- %tmp.4 = cast uint %tmp.4 to int
- %tmp.6 = add int %tmp.4, -1
- %tmp.0 = call %(item)s %std.pop( %(name)s* %a, int %tmp.6 )
- ret %(item)s %tmp.0
-}
-
-internal void %std.reverse(%(name)s* %a) {
-entry:
- %tmp.1 = getelementptr %(name)s* %a, int 0, uint 0
- %tmp.2 = load uint* %tmp.1
- %tmp.610 = seteq uint %tmp.2, 1
- br bool %tmp.610, label %return, label %no_exit.preheader
-
-no_exit.preheader:
- %tmp.9 = getelementptr %(name)s* %a, int 0, uint 1
- br label %no_exit
-
-no_exit:
- %lo.0.0 = phi uint [ 0, %no_exit.preheader ], [ %tmp.36, %no_exit ]
- %tmp. = add uint %tmp.2, 4294967295
- %hi.0.0 = sub uint %tmp., %lo.0.0
- %tmp.10 = load %(item)s** %tmp.9
- %tmp.13 = getelementptr %(item)s* %tmp.10, uint %lo.0.0
- %tmp.14 = load %(item)s* %tmp.13
- %tmp.26 = getelementptr %(item)s* %tmp.10, uint %hi.0.0
- %tmp.27 = load %(item)s* %tmp.26
- store %(item)s %tmp.27, %(item)s* %tmp.13
- %tmp.30 = load %(item)s** %tmp.9
- %tmp.33 = getelementptr %(item)s* %tmp.30, uint %hi.0.0
- store %(item)s %tmp.14, %(item)s* %tmp.33
- %tmp.36 = add uint %lo.0.0, 1
- %hi.0 = add uint %hi.0.0, 4294967295
- %tmp.6 = setlt uint %tmp.36, %hi.0
- br bool %tmp.6, label %no_exit, label %return
-
-return:
- ret void
-}
Deleted: /pypy/dist/pypy/translator/llvm/make_runtime.py
==============================================================================
--- /pypy/dist/pypy/translator/llvm/make_runtime.py Thu Jun 9 19:39:40 2005
+++ (empty file)
@@ -1,274 +0,0 @@
-"""
-This file produces the .ll files with the implementations of lists and the
-implementations of simple space operations (like add, mul, sub, div for float,
-bool, int).
-"""
-
-import autopath
-
-import os
-from pypy.tool.udir import udir
-from py.process import cmdexec
-from py import path
-
-def get_llvm_code(cfile):
- include_dir = autopath.this_dir
- print "include_dir", include_dir
- cfile = include_dir + "/" + cfile
- print cfile
- bytecode = udir.join("temp.bc")
- lastdir = path.local()
- ops = ["llvm-gcc -enable-correct-eh-support-O3 -c %s -o %s" % \
- (cfile, bytecode), "llvm-dis %s -f" % bytecode]
- for op in ops:
- print op
- cmdexec(op)
- f = udir.join("temp.ll").open("r")
- return f.read()
-
-def remove_comments(code):
- ret = []
- for line in code.split("\n"):
- line = line.split(";")
- ret.append(line[0].rstrip())
- return "\n".join(ret)
-
-def add_std(code):
- with_std = []
- functions = []
- for line in code.split("\n"):
- if "{" in line and "(" in line and ")" in line:
- s1 = line.split("(")
- s2 = s1[0].split("%")
- functions.append(s2[-1])
- s2[-1] = "std." + s2[-1]
- s2 = "%".join(s2)
- s1[0] = s2
- with_std.append("(".join(s1))
- else:
- with_std.append(line)
- ret = []
- for line in with_std:
- if "call" in line:
- for f in functions:
- if f in line:
- line = line.replace(f, "std." + f)
- ret.append(line)
- break
- else:
- ret.append(line)
- else:
- ret.append(line)
- return "\n".join(ret)
-
-def remove_alternatives(code):
- for i in range(1, 10):
- code = code.replace("_ALTERNATIVE%i" % i, "")
- return code
-
-def create_exceptions(code):
- code = code.replace("%LAST_EXCEPTION_TYPE", "%std.last_exception.type")
- code = code.replace("%INDEX_ERROR", "%glb.class.IndexError.object")
- return code
-
-def remove_exception(code):
- code = code.replace("_EXCEPTION", ".exc")
- return code
-
-def remove_header(code):
- code = code.split("implementation")
- return code[1]
-
-def internal_functions(code):
- ret = []
- for line in code.split("\n"):
- if "{" in line and "(" in line and ")" in line:
- ret.append("internal " + line)
- else:
- ret.append(line)
- return "\n".join(ret)
-
-def create_unwind(code):
- ret = []
- remove = False
- for line in code.split("\n"):
- if "call" in line and "%unwind(" in line:
- ret.append("\tunwind")
- remove = True
- elif "declare" in line and "unwind" in line:
- pass
- elif remove:
- if not line.startswith("\t") and ":" in line:
- remove = False
- ret.append(line)
- else:
- ret.append(line)
- return "\n".join(ret)
-
-def remove_structs(code):
- code = code.replace("struct.class", "std.class")
- return code
-
-def cleanup_code(code):
- code = remove_comments(code)
- code = add_std(code)
- code = remove_header(code)
- code = internal_functions(code)
- code = remove_alternatives(code)
- code = create_exceptions(code)
- code = remove_exception(code)
- code = remove_structs(code)
- code = create_unwind(code)
- return code
-
-def make_list_template():
- code = get_llvm_code("list.c")
- code = cleanup_code(code)
- code = code.replace("%struct.list", "%(name)s")
- code = code.replace("%struct.item*", "%(item)s")
- f = open(autopath.this_dir + "/list_template.ll", "w")
- print (autopath.this_dir + "/list_template.ll")
- f.write(code)
- f.close()
-
-def make_int_list():
- code = get_llvm_code("intlist.c")
- code = cleanup_code(code)
- code = code.replace("struct.list_int", "std.list.int")
- f = open(autopath.this_dir + "/int_list.ll", "w")
- print (autopath.this_dir + "/int_list.ll")
- f.write(code)
- f.close()
-
-MAP_ARITHM_OPS = [("add", ("add", None, None)),
- ("inplace_add", ("add", None, None)),
- ("sub", ("sub", None, None)),
- ("inplace_sub", ("sub", None, None)),
- ("mul", ("mul", None, None)),
- ("inplace_mul", ("mul", None, None)),
- ("div", ("div", None, None)),
- ("inplace_div", ("div", None, None)),
- ("floordiv", ("div", "int", None)),
- ("inplace_floordiv", ("div", "int", None)),
- ("truediv", ("div", "double", "double")),
- ("inplace_truediv", ("div", "double", "double")),
- ("mod", ("rem", None, None)),
- ("inplace_mod", ("rem", None, None))
- ]
-
-MAP_LOGICAL_OPS = [("and_", ("and", None, None)),
- ("inplace_and", ("and", None, None)),
- ("or_", ("or", None, None)),
- ("inplace_or", ("or", None, None)),
- ("xor", ("xor", None, None)),
- ("inplace_xor", ("xor", None, None))
- ]
-
-MAP_COMPAR_OPS = [("is_", "seteq"),
- ("eq", "seteq"),
- ("lt", "setlt"),
- ("le", "setle"),
- ("ge", "setge"),
- ("gt", "setgt")]
-
-types = ((0, "double"), (1, "uint"), (2, "int"), (3, "bool"))
-
-def make_binary_ops():
- code = ["implementation\n"]
- def normalize_type(t1, t, var):
- if t1 != t:
- code.append("\t%%%s = cast %s %%%s to %s\n" % (var, t1, var, t))
- for type1 in types:
- for type2 in types:
- #Arithmetic operators
- for op, (llvmop, calctype, rettype) in MAP_ARITHM_OPS:
- if calctype is None:
- calctype = min(type1, type2)[1]
- if rettype is None:
- rettype = min(type1, type2)[1]
- if calctype == "bool":
- calctype = rettype = "int"
- code.append("internal %s %%std.%s(%s %%a, %s %%b) {\n" %
- (rettype, op, type1[1], type2[1]))
- normalize_type(type1[1], calctype, "a")
- normalize_type(type2[1], calctype, "b")
- code.append("\t%%r = %s %s %%a, %%b\n" %
- (llvmop, calctype))
- normalize_type(calctype, rettype, "r")
- code.append("\tret %s %%r\n}\n\n" % rettype)
- calctype = min(type1, type2)[1]
- #Comparison operators
- for op, llvmop in MAP_COMPAR_OPS:
- code.append("internal bool %%std.%s(%s %%a, %s %%b) {\n" %
- (op, type1[1], type2[1]))
- normalize_type(type1[1], calctype, "a")
- normalize_type(type2[1], calctype, "b")
- code.append("\t%%r = %s %s %%a, %%b\n" %
- (llvmop, calctype))
- code.append("\tret bool %r\n}\n\n")
- code.append("internal bool %%std.neq(%s %%a, %s %%b) {\n" %
- (type1[1], type2[1]))
- normalize_type(type1[1], calctype, "a")
- normalize_type(type2[1], calctype, "b")
- code.append("\t%%r = %s %s %%a, %%b\n" %
- (llvmop, calctype))
- code.append("\t%r1 = xor bool %r, true\n\tret bool %r1\n}\n\n")
- #Logical operators
- for type1 in types[1:]:
- for type2 in types[1:]:
- for op, (llvmop, calctype, rettype) in MAP_LOGICAL_OPS:
- if calctype is None:
- calctype = min(type1, type2)[1]
- if rettype is None:
- rettype = min(type1, type2)[1]
- code.append("internal %s %%std.%s(%s %%a, %s %%b) {\n" %
- (rettype, op, type1[1], type2[1]))
- normalize_type(type1[1], calctype, "a")
- normalize_type(type2[1], calctype, "b")
- code.append("\t%%r = %s %s %%a, %%b\n" %
- (llvmop, calctype))
- normalize_type(calctype, rettype, "r")
- code.append("\tret %s %%r\n}\n\n" % rettype)
- #Shift
- for type1 in types[1:-1]:
- for type2 in types[1:-1]:
- for op, llvmop in (("lshift", "shl"), ("rshift", "shr")):
- code.append("internal %s %%std.%s(%s %%a, %s %%b) {\n" %
- (type1[1], op, type1[1], type2[1]))
- code.append("\t%%b = cast %s %%b to ubyte\n" % type2[1])
- code.append("\t%%r = %s %s %%a, ubyte %%b\n" %
- (llvmop, type1[1]))
- code.append("\tret %s %%r\n}\n\n" % type1[1])
- return code
-
-def make_unary_ops():
- code = []
- def normalize_type(t1, t, var):
- if t1 != t:
- code.append("\t%%%s = cast %s %%%s to %s\n" % (var, t1, var, t))
- for type1 in types:
- #"casts" int, bool
- for type2 in ("int", "bool"):
- code.append("internal %s %%std.%s(%s %%a) {\n" %
- (type2, type2, type1[1]))
- code.append("\t%%r = cast %s %%a to %s\n" % (type1[1], type2))
- code.append("\tret %s %%r\n}\n\n" % type2)
- #is_true
- code.append("internal bool %%std.is_true(%s %%a) {\n" % type1[1])
- code.append("\t%%r = cast %s %%a to bool\n" % type1[1])
- code.append("\tret bool %r\n}\n\n")
- return code
-
-
-def make_operations():
- code = make_binary_ops()
- code += make_unary_ops()
- f = open(autopath.this_dir + "/operations.ll", "w")
- f.write("".join(code))
- f.close()
-
-if __name__ == '__main__':
- make_operations()
- make_list_template()
- make_int_list()
-
More information about the Pypy-commit
mailing list