aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-10-07 22:50:33 -0700
committeralon@honor <none@none>2010-10-07 22:50:33 -0700
commitd0eb15c81a09cf011c5f660413e593b0c09ff5fb (patch)
treea71c70048458637f3a595a7e39b5cfee130a3e4a
parent4de0755572570e6de83788998e8288724b45b2fa (diff)
begin work to adapt to llvm 2.8 | TESTS BROKEN
-rw-r--r--src/intertyper.js25
-rw-r--r--src/jsifier.js4
-rw-r--r--src/library.js1
-rw-r--r--src/preamble.js2
-rw-r--r--tests/runner.py4
-rw-r--r--tests/settings.py22
6 files changed, 39 insertions, 19 deletions
diff --git a/src/intertyper.js b/src/intertyper.js
index 3092a310..6333492d 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -3,6 +3,8 @@
function intertyper(data) {
// Substrate
+ LLVM_STYLE = data.indexOf('<label>') == -1 ? 'old' : 'new'; // new = clang on 2.8, old = llvm-gcc anywhere or clang on 2.7
+
substrate = new Substrate('Intertyper');
// Line splitter.
@@ -153,15 +155,16 @@ function intertyper(data) {
processItem: function(item) {
function triage() {
if (!item.intertype) {
- if (item.tokens[0].text in searchable(';', 'target'))
- return '/dev/null';
if (item.tokens.length >= 3 && item.indent === 0 && item.tokens[1].text == '=')
return 'Global';
if (item.tokens.length >= 4 && item.indent === 0 && item.tokens[0].text == 'define' &&
item.tokens.slice(-1)[0].text == '{')
return 'FuncHeader';
- if (item.tokens.length >= 1 && item.indent === 0 && item.tokens[0].text.substr(-1) == ':')
+ if ((item.tokens.length >= 1 && item.indent === 0 && item.tokens[0].text.substr(-1) == ':') || // XXX LLVM 2.7 format, or llvm-gcc in 2.8
+ (item.tokens.length >= 3 && item.indent === 0 && item.tokens[1].text == '<label>'))
return 'Label';
+ if (item.tokens[0].text in searchable(';', 'target'))
+ return '/dev/null';
if (item.indent === 2 && item.tokens && item.tokens.length >= 3 && findTokenText(item, '=') >= 0 &&
!item.intertype)
return 'Assign';
@@ -284,7 +287,7 @@ function intertyper(data) {
item.tokens = item.tokens.filter(function(token) {
return ['noalias', 'available_externally', 'weak', 'internal', 'signext', 'zeroext', 'nounwind', 'define', 'linkonce_odr', 'inlinehint', '{'].indexOf(token.text) == -1;
});
- return [{
+ var ret = [{
__result__: true,
intertype: 'function',
ident: item.tokens[1].text,
@@ -292,6 +295,16 @@ function intertyper(data) {
params: item.tokens[2],
lineNum: item.lineNum,
}];
+ if (LLVM_STYLE == 'new') {
+ // no explicit 'entry' label in clang on LLVM 2.8, so we add one
+ ret.push({
+ __result__: true,
+ intertype: 'label',
+ ident: '%entry',
+ lineNum: item.lineNum + 'b',
+ });
+ }
+ return ret;
},
});
// label
@@ -300,7 +313,9 @@ function intertyper(data) {
return [{
__result__: true,
intertype: 'label',
- ident: '%' + item.tokens[0].text.substr(0, item.tokens[0].text.length-1),
+ ident: LLVM_STYLE == 'old' ?
+ '%' + item.tokens[0].text.substr(0, item.tokens[0].text.length-1) :
+ '%' + item.tokens[2].text.substr(1),
lineNum: item.lineNum,
}];
},
diff --git a/src/jsifier.js b/src/jsifier.js
index 66beb0bf..12017e2a 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -440,7 +440,9 @@ function JSify(data) {
var LABEL_IDs = {};
var LABEL_ID_COUNTER = 0;
function getLabelId(label) {
- //print('needs id: ' + label + ' : ' + JSON.stringify(LABEL_IDs));
+ label = label.substr(1);
+ if (label === 'entry') return '-1';
+ if (label === parseInt(label)) return label; // clang
label = toNiceIdent(label);
if (label in LABEL_IDs) return LABEL_IDs[label];
return LABEL_IDs[label] = LABEL_ID_COUNTER ++;
diff --git a/src/library.js b/src/library.js
index 08d62309..7fa4b979 100644
--- a/src/library.js
+++ b/src/library.js
@@ -137,6 +137,7 @@ var Library = {
HEAP[ptr+i] = value;
}
},
+ llvm_memset_p0i8_i32: 'llvm_memset_i32',
llvm_eh_exception: function() {
return 'code-generated exception: ' + (new Error().stack);
diff --git a/src/preamble.js b/src/preamble.js
index a2efad57..5496170d 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -1,4 +1,3 @@
-
// === Auto-generated preamble library stuff ===
function __globalConstructor__() {
@@ -207,6 +206,7 @@ function _llvm_memcpy_i32(dest, src, num, idunno) {
// dest.slab = src.slab.slice(src.pos);
}
_llvm_memcpy_i64 = _llvm_memcpy_i32;
+_llvm_memcpy_p0i8_p0i8_i32 = _llvm_memcpy_i32;
// Tools
diff --git a/tests/runner.py b/tests/runner.py
index 2ce216f5..b134f739 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -57,12 +57,12 @@ class T(unittest.TestCase):
raise Exception("Compilation error");
# LLVM binary ==> LLVM assembly
- output = Popen([LLVM_DIS, filename + '.o', '-o=' + filename + '.o.llvm'], stdout=PIPE, stderr=STDOUT).communicate()[0]
+ output = Popen([LLVM_DIS, filename + '.o'] + LLVM_DIS_OPTS + ['-o=' + filename + '.o.ll'], stdout=PIPE, stderr=STDOUT).communicate()[0]
# Run Emscripten
emscripten_settings = ['{ "QUANTUM_SIZE": %d, "RELOOP": %d, "OPTIMIZE": %d }' % (QUANTUM_SIZE, RELOOP, OPTIMIZE)]
out = open(filename + '.o.js', 'w') if not OUTPUT_TO_SCREEN else None
- timeout_run(Popen([EMSCRIPTEN, filename + '.o.llvm', PARSER_ENGINE] + emscripten_settings, stdout=out, stderr=STDOUT), 240, 'Compiling')
+ timeout_run(Popen([EMSCRIPTEN, filename + '.o.ll', PARSER_ENGINE] + emscripten_settings, stdout=out, stderr=STDOUT), 240, 'Compiling')
output = open(filename + '.o.js').read()
if output_processor is not None:
output_processor(output)
diff --git a/tests/settings.py b/tests/settings.py
index d6b24d66..21c7cef0 100644
--- a/tests/settings.py
+++ b/tests/settings.py
@@ -1,14 +1,15 @@
TEMP_DIR='/dev/shm'
-CLANG=os.path.expanduser('~/Dev/llvm-2.7/cbuild/bin/clang++')
-#CLANG=os.path.expanduser('~/Dev/llvm-2.8/cbuild/Release/bin/clang++')
-LLVM_GCC=os.path.expanduser('~/Dev/llvm-gcc-2.7/cbuild/install/bin/llvm-g++')
+LLVM_ROOT=os.path.expanduser('~/Dev/llvm-2.8/cbuild/Release/bin') # Might not need 'Release'
+
+CLANG=os.path.expanduser(os.path.join(LLVM_ROOT, 'clang++'))
+LLVM_GCC=os.path.expanduser('~/Dev/llvm-gcc-4.2-2.8.source/cbuild/install/bin/llvm-g++')
COMPILERS = {
- 'clang': {
- 'path': CLANG,
- 'quantum_size': 4, # See settings.js
- },
+# 'clang': {
+# 'path': CLANG,
+# 'quantum_size': 4, # See settings.js
+# },
'llvm_gcc': {
'path': LLVM_GCC,
'quantum_size': 1,
@@ -18,15 +19,16 @@ COMPILERS = {
COMPILER_OPTS = ['-m32'] # Need to build as 32bit arch, for now -
# various errors on 64bit compilation
-LLVM_DIS=os.path.expanduser('~/Dev/llvm-2.7/cbuild/bin/llvm-dis')
+LLVM_DIS=os.path.expanduser(os.path.join(LLVM_ROOT, 'llvm-dis'))
+LLVM_DIS_OPTS=['-show-annotations']
SPIDERMONKEY_ENGINE=os.path.expanduser('~/Dev/mozilla-central/js/src/js')
V8_ENGINE=os.path.expanduser('~/Dev/v8/d8')
# XXX Warning: Compiling the 'sauer' test in SpiderMonkey can lead to an extreme amount of memory being
# used, see Mozilla bug 593659. Possibly also some other tests as well.
-#PARSER_ENGINE=SPIDERMONKEY_ENGINE
-PARSER_ENGINE=V8_ENGINE
+PARSER_ENGINE=SPIDERMONKEY_ENGINE
+#PARSER_ENGINE=V8_ENGINE
JS_ENGINE=SPIDERMONKEY_ENGINE
#JS_ENGINE=V8_ENGINE