diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-04-19 14:21:38 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-04-19 14:21:38 -0700 |
commit | 5128461279805416694953c78bfbc7ad4bcde7be (patch) | |
tree | 910560d60731b378bb3031f18c1e3a76dfd3e037 /tools/autodebugger.py | |
parent | 46e3b2a78717b112254be5f6e8cbd1fad6ab1703 (diff) |
autodebugger support for i16 and i64
Diffstat (limited to 'tools/autodebugger.py')
-rw-r--r-- | tools/autodebugger.py | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/tools/autodebugger.py b/tools/autodebugger.py index f11053e8..d69b8ac5 100644 --- a/tools/autodebugger.py +++ b/tools/autodebugger.py @@ -11,6 +11,17 @@ POSTAMBLE = ''' @.emscripten.autodebug.str = private constant [21 x i8] c"line: %d, value: %d\\0A\\00", align 1 ; [#uses=1] ; [#uses=1] +define void @emscripten_autodebug_i64(i32 %line, i64 %value) { +entry: + %0 = sitofp i64 %value to double ; [#uses=1] + %1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x i8]* @.emscripten.autodebug.str, i32 0, i32 0), i32 %line, double %0) ; [#uses=0] + br label %return + +return: ; preds = %entry + ret void +} + +; [#uses=1] define void @emscripten_autodebug_i32(i32 %line, i32 %value) { entry: %0 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x i8]* @.emscripten.autodebug.str, i32 0, i32 0), i32 %line, i32 %value) ; [#uses=0] @@ -21,6 +32,17 @@ return: ; preds = %entry } ; [#uses=1] +define void @emscripten_autodebug_i16(i32 %line, i16 %value) { +entry: + %0 = zext i16 %value to i32 ; [#uses=1] + %1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x i8]* @.emscripten.autodebug.str, i32 0, i32 0), i32 %line, i32 %0) ; [#uses=0] + br label %return + +return: ; preds = %entry + ret void +} + +; [#uses=1] define void @emscripten_autodebug_i8(i32 %line, i8 %value) { entry: %0 = zext i8 %value to i32 ; [#uses=1] @@ -57,12 +79,26 @@ POSTAMBLE_NEW = ''' @.emscripten.autodebug.str = private constant [21 x i8] c"line: %d, value: %d\\0A\\00", align 1 ; [#uses=1] ; [#uses=1] +define void @emscripten_autodebug_i64(i32 %line, i64 %value) { + %1 = sitofp i64 %value to double + %2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x i8]* @.emscripten.autodebug.str, i32 0, i32 0), i32 %line, double %1) ; [#uses=0] + ret void +} + +; [#uses=1] define void @emscripten_autodebug_i32(i32 %line, i32 %value) { %1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x i8]* @.emscripten.autodebug.str, i32 0, i32 0), i32 %line, i32 %value) ; [#uses=0] ret void } ; [#uses=1] +define void @emscripten_autodebug_i16(i32 %line, i16 %value) { + %1 = zext i16 %value to i32 ; [#uses=1] + %2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x i8]* @.emscripten.autodebug.str, i32 0, i32 0), i32 %line, i32 %1) ; [#uses=0] + ret void +} + +; [#uses=1] define void @emscripten_autodebug_i8(i32 %line, i8 %value) { %1 = zext i8 %value to i32 ; [#uses=1] %2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x i8]* @.emscripten.autodebug.str, i32 0, i32 0), i32 %line, i32 %1) ; [#uses=0] @@ -106,7 +142,7 @@ for i in range(len(lines)): # lines[i] += '\n m = re.match(' store (?P<type>i64|i32|i16|i8) %(?P<var>[\w.]+), .*', lines[i]) - if m and m.group('type') in ['i8', 'i32', 'float', 'double']: + if m and m.group('type') in ['i8', 'i16', 'i32', 'i64', 'float', 'double']: lines[i] += '\n call void @emscripten_autodebug_%s(i32 %d, %s %%%s)' % (m.group('type'), i+1+lines_added, m.group('type'), m.group('var')) lines_added += 1 |