Browse Source

Big fix up of asm filtering. Adds a bunch of tests too.

refactor
Matt Godbolt 11 years ago
parent
commit
da98a1e24f
  1. 7
      Makefile
  2. 49
      static/asm-mode.js
  3. 105
      static/asm.js
  4. 1
      static/index.html
  5. 976
      test/cases/arm-hellow.asm
  6. 95
      test/cases/arm-hellow.asm.directives
  7. 18
      test/cases/arm-hellow.asm.directives.labels
  8. 16
      test/cases/arm-hellow.asm.directives.labels.comments
  9. 19
      test/cases/arm-static.asm
  10. 11
      test/cases/arm-static.asm.directives
  11. 195
      test/cases/clang-hellow.asm
  12. 45
      test/cases/clang-hellow.asm.directives
  13. 16
      test/cases/clang-hellow.asm.directives.labels
  14. 15
      test/cases/clang-hellow.asm.directives.labels.comments
  15. 24
      test/cases/clang-static.asm
  16. 8
      test/cases/clang-static.asm.directives
  17. 940
      test/cases/gcc4.6-hellow.asm
  18. 92
      test/cases/gcc4.6-hellow.asm.directives
  19. 17
      test/cases/gcc4.6-hellow.asm.directives.labels
  20. 17
      test/cases/gcc4.6-hellow.asm.directives.labels.comments
  21. 25
      test/cases/gcc4.6-static.asm
  22. 10
      test/cases/gcc4.6-static.asm.directives
  23. 23
      test/cases/icc-static.asm
  24. 8
      test/cases/icc-static.asm.directives
  25. 322
      test/cases/icc.hellow.asm
  26. 128
      test/cases/icc.hellow.asm.directives
  27. 79
      test/cases/icc.hellow.asm.directives.labels
  28. 39
      test/cases/icc.hellow.asm.directives.labels.comments
  29. 73
      test/test.js

7
Makefile

@ -14,9 +14,14 @@ $(NODE_MODULES): package.json
node_modules: $(NODE_MODULES)
test:
(cd test; node test.js)
@echo Tests pass
clean:
rm -rf node_modules
.PHONY: clean run
.PHONY: clean run test run-amazon
run: node_modules
./node_modules/.bin/supervisor ./app.js

49
static/asm-mode.js

@ -0,0 +1,49 @@
CodeMirror.defineMode("asm", function() {
function tokenString(quote) {
return function(stream) {
var escaped = false, next, end = false;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {end = true; break;}
escaped = !escaped && next == "\\";
}
return "string";
};
}
return {
token: function(stream) {
if (stream.match(/^.+:$/)) {
return "variable-2";
}
if (stream.sol() && stream.match(/^\s*\.\w+/)) {
return "header";
}
if (stream.sol() && stream.match(/^\s\w+/)) {
return "keyword";
}
if (stream.eatSpace()) return null;
var ch = stream.next();
if (ch == '"' || ch == "'") {
return tokenString(ch)(stream);
}
if (/[\[\]{}\(\),;\:]/.test(ch)) return null;
if (/[\d$]/.test(ch) || (ch == '-' && stream.peek().match(/[0-9]/))) {
stream.eatWhile(/[\w\.]/);
return "number";
}
if (ch == '%') {
stream.eatWhile(/\w+/);
return "variable-3";
}
if (ch == '#') {
stream.eatWhile(/.*/);
return "comment";
}
stream.eatWhile(/[\w\$_]/);
return "word";
}
};
});
CodeMirror.defineMIME("text/x-asm", "asm");

105
static/asm.js

@ -1,70 +1,19 @@
CodeMirror.defineMode("asm", function() {
function tokenString(quote) {
return function(stream) {
var escaped = false, next, end = false;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {end = true; break;}
escaped = !escaped && next == "\\";
}
return "string";
};
}
return {
token: function(stream) {
if (stream.match(/^.+:$/)) {
return "variable-2";
}
if (stream.sol() && stream.match(/^\s*\.\w+/)) {
return "header";
}
if (stream.sol() && stream.match(/^\s\w+/)) {
return "keyword";
}
if (stream.eatSpace()) return null;
var ch = stream.next();
if (ch == '"' || ch == "'") {
return tokenString(ch)(stream);
}
if (/[\[\]{}\(\),;\:]/.test(ch)) return null;
if (/[\d$]/.test(ch) || (ch == '-' && stream.peek().match(/[0-9]/))) {
stream.eatWhile(/[\w\.]/);
return "number";
}
if (ch == '%') {
stream.eatWhile(/\w+/);
return "variable-3";
}
if (ch == '#') {
stream.eatWhile(/.*/);
return "comment";
}
stream.eatWhile(/[\w\$_]/);
return "word";
}
};
});
CodeMirror.defineMIME("text/x-asm", "asm");
function processAsm(asm, filters) {
var result = [];
var asmLines = asm.split("\n");
var labelsUsed = {};
var labelFind = /\.[a-zA-Z0-9$_.]+/g;
var labelFind = /[.a-zA-Z0-9_][a-zA-Z0-9$_.]*/g;
var files = {};
var prevLabel = "";
var literalConstant = /^\.LC\d+/;
var lcString = /\.string/;
var dataDefn = /\.(string|asciz|ascii|[1248]?byte|short|word|long|quad|value)/;
var fileFind = /^\s*\.file\s+(\d+)\s+"([^"]+)"$/;
var hasOpcode = /^\s*([a-zA-Z0-9$_][a-zA-Z0-9$_.]*:\s*)?[a-zA-Z].*/;
$.each(asmLines, function(_, line) {
asmLines.forEach(function(line) {
if (line == "" || line[0] == ".") return;
var match = line.match(labelFind);
if (match && (!filters.directives || line.match(hasOpcode))) {
// Only count a label as used if it's used by an opcode, or else we're not filtering directives.
$.each(match, function(_, label) { labelsUsed[label] = true; });
match.forEach(function(label) { labelsUsed[label] = true; });
}
match = line.match(fileFind);
if (match) {
@ -73,14 +22,18 @@ function processAsm(asm, filters) {
});
var directive = /^\s*\..*$/;
var labelDefinition = /^(\.[a-zA-Z0-9$_.]+):/;
var labelDefinition = /^([a-zA-Z0-9$_.]+):/;
var commentOnly = /^\s*(#|@|\/\/).*/;
var sourceTag = /^\s*\.loc\s+(\d+)\s+(\d+).*/;
var stdInLooking = /.*<stdin>|-/;
var endBlock = /\.(cfi_endproc|data|text|section)/;
var source = null;
$.each(asmLines, function(_, line) {
asmLines.forEach(function(line) {
var match;
if (line.trim() == "") return;
if (line.trim() == "") {
result.push({text:"", source:null});
return;
}
if (match = line.match(sourceTag)) {
source = null;
var file = files[parseInt(match[1])];
@ -88,25 +41,32 @@ function processAsm(asm, filters) {
source = parseInt(match[2]);
}
}
if (line.match(endBlock)) {
source = null;
prevLabel = null;
}
if (filters.commentOnly && line.match(commentOnly)) return;
match = line.match(labelDefinition);
if (!match && line.match(lcString) && prevLabel) {
result.push({text: line, source: null});
prevLabel = "";
return;
}
if (match && labelsUsed[match[1]] == undefined) {
if (filters.labels) return;
}
if (match && line.match(literalConstant)) {
prevLabel = line;
if (match) {
// It's a label definition.
if (labelsUsed[match[1]] == undefined) {
// It's an unused label.
if (filters.labels) return;
} else {
// A used label.
prevLabel = match;
}
}
if (!match && filters.directives) {
// Check for directives only if it wasn't a label; the regexp would
// otherwise misinterpret labels as directives.
match = line.match(directive);
if (match) return;
if (line.match(dataDefn) && prevLabel) {
// We're defining data that's being used somewhere.
} else {
if (line.match(directive)) return;
}
}
var hasOpcodeMatch = line.match(hasOpcode);
@ -115,3 +75,8 @@ function processAsm(asm, filters) {
return result;
}
if (typeof module !== 'undefined' && module.exports) {
module.exports = {
processAsm: processAsm
};
}

1
static/index.html

@ -8,6 +8,7 @@
<script src="ext/codemirror/codemirror.js"></script>
<script src="ext/codemirror/clike.js"></script>
<script src="asm.js"></script>
<script src="asm-mode.js"></script>
<script src="ext/jquery/jquery-1.7.1.min.js"></script>
<script src="gcc.js"></script>
<script src="ext/bootstrap/js/bootstrap.js"></script>

976
test/cases/arm-hellow.asm

@ -0,0 +1,976 @@
.syntax unified
.arch armv7-a
.eabi_attribute 27, 3
.fpu vfpv3-d16
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 2
.eabi_attribute 30, 2
.eabi_attribute 34, 1
.eabi_attribute 18, 4
.thumb
.file ""
.text
.Ltext0:
.cfi_sections .debug_frame
.section .text.startup,"ax",%progbits
.align 2
.global main
.thumb
.thumb_func
.type main, %function
main:
.fnstart
.LFB31:
.file 1 "<stdin>"
.loc 1 2 0
.cfi_startproc
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
.LVL0:
push {r3, lr}
.save {r3, lr}
.LCFI0:
.cfi_def_cfa_offset 8
.cfi_offset 14, -4
.cfi_offset 3, -8
.LBB6:
.LBB7:
.file 2 "/usr/arm-linux-gnueabi/include/bits/stdio2.h"
.loc 2 105 0
movs r0, #1
movw r1, #:lower16:.LC0
movt r1, #:upper16:.LC0
bl __printf_chk
.LVL1:
.LBE7:
.LBE6:
.LBB8:
.LBB9:
movs r0, #1
movw r1, #:lower16:.LC1
movt r1, #:upper16:.LC1
bl __printf_chk
.LBE9:
.LBE8:
.loc 1 5 0
movs r0, #0
pop {r3, pc}
.cfi_endproc
.LFE31:
.fnend
.size main, .-main
.section .rodata.str1.4,"aMS",%progbits,1
.align 2
.LC0:
.ascii "Hello world\000"
.LC1:
.ascii "moo\012\000"
.text
.Letext0:
.file 3 "/usr/lib/gcc/arm-linux-gnueabi/4.6/include/stddef.h"
.file 4 "/usr/arm-linux-gnueabi/include/bits/types.h"
.file 5 "/usr/arm-linux-gnueabi/include/libio.h"
.file 6 "/usr/arm-linux-gnueabi/include/stdio.h"
.section .debug_info,"",%progbits
.Ldebug_info0:
.4byte 0x37d
.2byte 0x2
.4byte .Ldebug_abbrev0
.byte 0x4
.uleb128 0x1
.4byte .LASF50
.byte 0x4
.4byte .LASF51
.4byte 0
.4byte 0
.4byte .Ldebug_ranges0+0
.4byte .Ldebug_line0
.uleb128 0x2
.4byte .LASF8
.byte 0x3
.byte 0xd4
.4byte 0x30
.uleb128 0x3
.byte 0x4
.byte 0x7
.4byte .LASF0
.uleb128 0x3
.byte 0x1
.byte 0x8
.4byte .LASF1
.uleb128 0x3
.byte 0x2
.byte 0x7
.4byte .LASF2
.uleb128 0x3
.byte 0x4
.byte 0x7
.4byte .LASF3
.uleb128 0x3
.byte 0x1
.byte 0x6
.4byte .LASF4
.uleb128 0x3
.byte 0x2
.byte 0x5
.4byte .LASF5
.uleb128 0x4
.byte 0x4
.byte 0x5
.ascii "int\000"
.uleb128 0x3
.byte 0x8
.byte 0x5
.4byte .LASF6
.uleb128 0x3
.byte 0x8
.byte 0x7
.4byte .LASF7
.uleb128 0x2
.4byte .LASF9
.byte 0x4
.byte 0x38
.4byte 0x61
.uleb128 0x2
.4byte .LASF10
.byte 0x4
.byte 0x8d
.4byte 0x85
.uleb128 0x3
.byte 0x4
.byte 0x5
.4byte .LASF11
.uleb128 0x2
.4byte .LASF12
.byte 0x4
.byte 0x8e
.4byte 0x6f
.uleb128 0x5
.byte 0x4
.uleb128 0x6
.byte 0x4
.4byte 0x9f
.uleb128 0x3
.byte 0x1
.byte 0x8
.4byte .LASF13
.uleb128 0x7
.4byte .LASF43
.byte 0x98
.byte 0x5
.2byte 0x111
.4byte 0x267
.uleb128 0x8
.4byte .LASF14
.byte 0x5
.2byte 0x112
.4byte 0x5a
.byte 0x2
.byte 0x23
.uleb128 0
.uleb128 0x8
.4byte .LASF15
.byte 0x5
.2byte 0x117
.4byte 0x99
.byte 0x2
.byte 0x23
.uleb128 0x4
.uleb128 0x8
.4byte .LASF16
.byte 0x5
.2byte 0x118
.4byte 0x99
.byte 0x2
.byte 0x23
.uleb128 0x8
.uleb128 0x8
.4byte .LASF17
.byte 0x5
.2byte 0x119
.4byte 0x99
.byte 0x2
.byte 0x23
.uleb128 0xc
.uleb128 0x8
.4byte .LASF18
.byte 0x5
.2byte 0x11a
.4byte 0x99
.byte 0x2
.byte 0x23
.uleb128 0x10
.uleb128 0x8
.4byte .LASF19
.byte 0x5
.2byte 0x11b
.4byte 0x99
.byte 0x2
.byte 0x23
.uleb128 0x14
.uleb128 0x8
.4byte .LASF20
.byte 0x5
.2byte 0x11c
.4byte 0x99
.byte 0x2
.byte 0x23
.uleb128 0x18
.uleb128 0x8
.4byte .LASF21
.byte 0x5
.2byte 0x11d
.4byte 0x99
.byte 0x2
.byte 0x23
.uleb128 0x1c
.uleb128 0x8
.4byte .LASF22
.byte 0x5
.2byte 0x11e
.4byte 0x99
.byte 0x2
.byte 0x23
.uleb128 0x20
.uleb128 0x8
.4byte .LASF23
.byte 0x5
.2byte 0x120
.4byte 0x99
.byte 0x2
.byte 0x23
.uleb128 0x24
.uleb128 0x8
.4byte .LASF24
.byte 0x5
.2byte 0x121
.4byte 0x99
.byte 0x2
.byte 0x23
.uleb128 0x28
.uleb128 0x8
.4byte .LASF25
.byte 0x5
.2byte 0x122
.4byte 0x99
.byte 0x2
.byte 0x23
.uleb128 0x2c
.uleb128 0x8
.4byte .LASF26
.byte 0x5
.2byte 0x124
.4byte 0x2b1
.byte 0x2
.byte 0x23
.uleb128 0x30
.uleb128 0x8
.4byte .LASF27
.byte 0x5
.2byte 0x126
.4byte 0x2b7
.byte 0x2
.byte 0x23
.uleb128 0x34
.uleb128 0x8
.4byte .LASF28
.byte 0x5
.2byte 0x128
.4byte 0x5a
.byte 0x2
.byte 0x23
.uleb128 0x38
.uleb128 0x8
.4byte .LASF29
.byte 0x5
.2byte 0x12c
.4byte 0x5a
.byte 0x2
.byte 0x23
.uleb128 0x3c
.uleb128 0x8
.4byte .LASF30
.byte 0x5
.2byte 0x12e
.4byte 0x7a
.byte 0x2
.byte 0x23
.uleb128 0x40
.uleb128 0x8
.4byte .LASF31
.byte 0x5
.2byte 0x132
.4byte 0x3e
.byte 0x2
.byte 0x23
.uleb128 0x44
.uleb128 0x8
.4byte .LASF32
.byte 0x5
.2byte 0x133
.4byte 0x4c
.byte 0x2
.byte 0x23
.uleb128 0x46
.uleb128 0x8
.4byte .LASF33
.byte 0x5
.2byte 0x134
.4byte 0x2bd
.byte 0x2
.byte 0x23
.uleb128 0x47
.uleb128 0x8
.4byte .LASF34
.byte 0x5
.2byte 0x138
.4byte 0x2cd
.byte 0x2
.byte 0x23
.uleb128 0x48
.uleb128 0x8
.4byte .LASF35
.byte 0x5
.2byte 0x141
.4byte 0x8c
.byte 0x2
.byte 0x23
.uleb128 0x50
.uleb128 0x8
.4byte .LASF36
.byte 0x5
.2byte 0x14a
.4byte 0x97
.byte 0x2
.byte 0x23
.uleb128 0x58
.uleb128 0x8
.4byte .LASF37
.byte 0x5
.2byte 0x14b
.4byte 0x97
.byte 0x2
.byte 0x23
.uleb128 0x5c
.uleb128 0x8
.4byte .LASF38
.byte 0x5
.2byte 0x14c
.4byte 0x97
.byte 0x2
.byte 0x23
.uleb128 0x60
.uleb128 0x8
.4byte .LASF39
.byte 0x5
.2byte 0x14d
.4byte 0x97
.byte 0x2
.byte 0x23
.uleb128 0x64
.uleb128 0x8
.4byte .LASF40
.byte 0x5
.2byte 0x14e
.4byte 0x25
.byte 0x2
.byte 0x23
.uleb128 0x68
.uleb128 0x8
.4byte .LASF41
.byte 0x5
.2byte 0x150
.4byte 0x5a
.byte 0x2
.byte 0x23
.uleb128 0x6c
.uleb128 0x8
.4byte .LASF42
.byte 0x5
.2byte 0x152
.4byte 0x2d3
.byte 0x2
.byte 0x23
.uleb128 0x70
.byte 0
.uleb128 0x9
.4byte .LASF52
.byte 0x5
.byte 0xb6
.uleb128 0xa
.4byte .LASF44
.byte 0xc
.byte 0x5
.byte 0xbc
.4byte 0x2a5
.uleb128 0xb
.4byte .LASF45
.byte 0x5
.byte 0xbd
.4byte 0x2a5
.byte 0x2
.byte 0x23
.uleb128 0
.uleb128 0xb
.4byte .LASF46
.byte 0x5
.byte 0xbe
.4byte 0x2ab
.byte 0x2
.byte 0x23
.uleb128 0x4
.uleb128 0xb
.4byte .LASF47
.byte 0x5
.byte 0xc2
.4byte 0x5a
.byte 0x2
.byte 0x23
.uleb128 0x8
.byte 0
.uleb128 0x6
.byte 0x4
.4byte 0x26e
.uleb128 0x6
.byte 0x4
.4byte 0xa6
.uleb128 0x6
.byte 0x4
.4byte 0x26e
.uleb128 0x6
.byte 0x4
.4byte 0xa6
.uleb128 0xc
.4byte 0x9f
.4byte 0x2cd
.uleb128 0xd
.4byte 0x30
.byte 0
.byte 0
.uleb128 0x6
.byte 0x4
.4byte 0x267
.uleb128 0xc
.4byte 0x9f
.4byte 0x2e3
.uleb128 0xd
.4byte 0x30
.byte 0x27
.byte 0
.uleb128 0x6
.byte 0x4
.4byte 0x2e9
.uleb128 0xe
.4byte 0x9f
.uleb128 0xf
.byte 0x1
.4byte .LASF53
.byte 0x2
.byte 0x67
.4byte 0x5a
.byte 0x3
.byte 0x1
.4byte 0x30d
.uleb128 0x10
.4byte .LASF54
.byte 0x2
.byte 0x67
.4byte 0x2e3
.uleb128 0x11
.byte 0
.uleb128 0x12
.byte 0x1
.4byte .LASF55
.byte 0x1
.byte 0x2
.4byte 0x5a
.4byte .LFB31
.4byte .LFE31
.4byte .LLST0
.4byte 0x366
.uleb128 0x13
.4byte 0x2ee
.4byte .LBB6
.4byte .LBE6
.byte 0x1
.byte 0x3
.4byte 0x349
.uleb128 0x14
.4byte 0x300
.byte 0x6
.byte 0x3
.4byte .LC0
.byte 0x9f
.byte 0
.uleb128 0x15
.4byte 0x2ee
.4byte .LBB8
.4byte .LBE8
.byte 0x1
.byte 0x4
.uleb128 0x14
.4byte 0x300
.byte 0x6
.byte 0x3
.4byte .LC1
.byte 0x9f
.byte 0
.byte 0
.uleb128 0x16
.4byte .LASF48
.byte 0x6
.byte 0xa9
.4byte 0x2ab
.byte 0x1
.byte 0x1
.uleb128 0x16
.4byte .LASF49
.byte 0x6
.byte 0xaa
.4byte 0x2ab
.byte 0x1
.byte 0x1
.byte 0
.section .debug_abbrev,"",%progbits
.Ldebug_abbrev0:
.uleb128 0x1
.uleb128 0x11
.byte 0x1
.uleb128 0x25
.uleb128 0xe
.uleb128 0x13
.uleb128 0xb
.uleb128 0x1b
.uleb128 0xe
.uleb128 0x11
.uleb128 0x1
.uleb128 0x52
.uleb128 0x1
.uleb128 0x55
.uleb128 0x6
.uleb128 0x10
.uleb128 0x6
.byte 0
.byte 0
.uleb128 0x2
.uleb128 0x16
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x3
.uleb128 0x24
.byte 0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.uleb128 0x3
.uleb128 0xe
.byte 0
.byte 0
.uleb128 0x4
.uleb128 0x24
.byte 0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.uleb128 0x3
.uleb128 0x8
.byte 0
.byte 0
.uleb128 0x5
.uleb128 0xf
.byte 0
.uleb128 0xb
.uleb128 0xb
.byte 0
.byte 0
.uleb128 0x6
.uleb128 0xf
.byte 0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x7
.uleb128 0x13
.byte 0x1
.uleb128 0x3
.uleb128 0xe
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0x5
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x8
.uleb128 0xd
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0x5
.uleb128 0x49
.uleb128 0x13
.uleb128 0x38
.uleb128 0xa
.byte 0
.byte 0
.uleb128 0x9
.uleb128 0x16
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.byte 0
.byte 0
.uleb128 0xa
.uleb128 0x13
.byte 0x1
.uleb128 0x3
.uleb128 0xe
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0xb
.uleb128 0xd
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x38
.uleb128 0xa
.byte 0
.byte 0
.uleb128 0xc
.uleb128 0x1
.byte 0x1
.uleb128 0x49
.uleb128 0x13
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0xd
.uleb128 0x21
.byte 0
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2f
.uleb128 0xb
.byte 0
.byte 0
.uleb128 0xe
.uleb128 0x26
.byte 0
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0xf
.uleb128 0x2e
.byte 0x1
.uleb128 0x3f
.uleb128 0xc
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x20
.uleb128 0xb
.uleb128 0x34
.uleb128 0xc
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x10
.uleb128 0x5
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x11
.uleb128 0x18
.byte 0
.byte 0
.byte 0
.uleb128 0x12
.uleb128 0x2e
.byte 0x1
.uleb128 0x3f
.uleb128 0xc
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x1
.uleb128 0x40
.uleb128 0x6
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x13
.uleb128 0x1d
.byte 0x1
.uleb128 0x31
.uleb128 0x13
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x1
.uleb128 0x58
.uleb128 0xb
.uleb128 0x59
.uleb128 0xb
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x14
.uleb128 0x5
.byte 0
.uleb128 0x31
.uleb128 0x13
.uleb128 0x2
.uleb128 0xa
.byte 0
.byte 0
.uleb128 0x15
.uleb128 0x1d
.byte 0x1
.uleb128 0x31
.uleb128 0x13
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x1
.uleb128 0x58
.uleb128 0xb
.uleb128 0x59
.uleb128 0xb
.byte 0
.byte 0
.uleb128 0x16
.uleb128 0x34
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x3f
.uleb128 0xc
.uleb128 0x3c
.uleb128 0xc
.byte 0
.byte 0
.byte 0
.section .debug_loc,"",%progbits
.Ldebug_loc0:
.LLST0:
.4byte .LFB31
.4byte .LCFI0
.2byte 0x2
.byte 0x7d
.sleb128 0
.4byte .LCFI0
.4byte .LFE31
.2byte 0x2
.byte 0x7d
.sleb128 8
.4byte 0
.4byte 0
.section .debug_aranges,"",%progbits
.4byte 0x1c
.2byte 0x2
.4byte .Ldebug_info0
.byte 0x4
.byte 0
.2byte 0
.2byte 0
.4byte .LFB31
.4byte .LFE31-.LFB31
.4byte 0
.4byte 0
.section .debug_ranges,"",%progbits
.Ldebug_ranges0:
.4byte .LFB31
.4byte .LFE31
.4byte 0
.4byte 0
.section .debug_line,"",%progbits
.Ldebug_line0:
.section .debug_str,"MS",%progbits,1
.LASF22:
.ascii "_IO_buf_end\000"
.LASF9:
.ascii "__quad_t\000"
.LASF30:
.ascii "_old_offset\000"
.LASF25:
.ascii "_IO_save_end\000"
.LASF5:
.ascii "short int\000"
.LASF8:
.ascii "size_t\000"
.LASF50:
.ascii "GNU C++ 4.6.3\000"
.LASF35:
.ascii "_offset\000"
.LASF19:
.ascii "_IO_write_ptr\000"
.LASF14:
.ascii "_flags\000"
.LASF21:
.ascii "_IO_buf_base\000"
.LASF26:
.ascii "_markers\000"
.LASF16:
.ascii "_IO_read_end\000"
.LASF6:
.ascii "long long int\000"
.LASF34:
.ascii "_lock\000"
.LASF11:
.ascii "long int\000"
.LASF53:
.ascii "printf\000"
.LASF31:
.ascii "_cur_column\000"
.LASF47:
.ascii "_pos\000"
.LASF46:
.ascii "_sbuf\000"
.LASF43:
.ascii "_IO_FILE\000"
.LASF1:
.ascii "unsigned char\000"
.LASF4:
.ascii "signed char\000"
.LASF7:
.ascii "long long unsigned int\000"
.LASF0:
.ascii "unsigned int\000"
.LASF44:
.ascii "_IO_marker\000"
.LASF33:
.ascii "_shortbuf\000"
.LASF18:
.ascii "_IO_write_base\000"
.LASF42:
.ascii "_unused2\000"
.LASF15:
.ascii "_IO_read_ptr\000"
.LASF2:
.ascii "short unsigned int\000"
.LASF13:
.ascii "char\000"
.LASF55:
.ascii "main\000"
.LASF45:
.ascii "_next\000"
.LASF36:
.ascii "__pad1\000"
.LASF37:
.ascii "__pad2\000"
.LASF38:
.ascii "__pad3\000"
.LASF39:
.ascii "__pad4\000"
.LASF40:
.ascii "__pad5\000"
.LASF54:
.ascii "__fmt\000"
.LASF3:
.ascii "long unsigned int\000"
.LASF20:
.ascii "_IO_write_end\000"
.LASF12:
.ascii "__off64_t\000"
.LASF10:
.ascii "__off_t\000"
.LASF27:
.ascii "_chain\000"
.LASF24:
.ascii "_IO_backup_base\000"
.LASF48:
.ascii "stdin\000"
.LASF29:
.ascii "_flags2\000"
.LASF41:
.ascii "_mode\000"
.LASF17:
.ascii "_IO_read_base\000"
.LASF32:
.ascii "_vtable_offset\000"
.LASF51:
.ascii "/home/mgodbolt/dev/gcc-explorer\000"
.LASF23:
.ascii "_IO_save_base\000"
.LASF28:
.ascii "_fileno\000"
.LASF49:
.ascii "stdout\000"
.LASF52:
.ascii "_IO_lock_t\000"
.ident "GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3"
.section .note.GNU-stack,"",%progbits

95
test/cases/arm-hellow.asm.directives

@ -0,0 +1,95 @@
.Ltext0:
main:
.LFB31:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
.LVL0:
push {r3, lr}
.LCFI0:
.LBB6:
.LBB7:
movs r0, #1
movw r1, #:lower16:.LC0
movt r1, #:upper16:.LC0
bl __printf_chk
.LVL1:
.LBE7:
.LBE6:
.LBB8:
.LBB9:
movs r0, #1
movw r1, #:lower16:.LC1
movt r1, #:upper16:.LC1
bl __printf_chk
.LBE9:
.LBE8:
movs r0, #0
pop {r3, pc}
.LFE31:
.LC0:
.ascii "Hello world\000"
.LC1:
.ascii "moo\012\000"
.Letext0:
.Ldebug_info0:
.Ldebug_abbrev0:
.Ldebug_loc0:
.LLST0:
.Ldebug_ranges0:
.Ldebug_line0:
.LASF22:
.LASF9:
.LASF30:
.LASF25:
.LASF5:
.LASF8:
.LASF50:
.LASF35:
.LASF19:
.LASF14:
.LASF21:
.LASF26:
.LASF16:
.LASF6:
.LASF34:
.LASF11:
.LASF53:
.LASF31:
.LASF47:
.LASF46:
.LASF43:
.LASF1:
.LASF4:
.LASF7:
.LASF0:
.LASF44:
.LASF33:
.LASF18:
.LASF42:
.LASF15:
.LASF2:
.LASF13:
.LASF55:
.LASF45:
.LASF36:
.LASF37:
.LASF38:
.LASF39:
.LASF40:
.LASF54:
.LASF3:
.LASF20:
.LASF12:
.LASF10:
.LASF27:
.LASF24:
.LASF48:
.LASF29:
.LASF41:
.LASF17:
.LASF32:
.LASF51:
.LASF23:
.LASF28:
.LASF49:
.LASF52:

18
test/cases/arm-hellow.asm.directives.labels

@ -0,0 +1,18 @@
main:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
push {r3, lr}
movs r0, #1
movw r1, #:lower16:.LC0
movt r1, #:upper16:.LC0
bl __printf_chk
movs r0, #1
movw r1, #:lower16:.LC1
movt r1, #:upper16:.LC1
bl __printf_chk
movs r0, #0
pop {r3, pc}
.LC0:
.ascii "Hello world\000"
.LC1:
.ascii "moo\012\000"

16
test/cases/arm-hellow.asm.directives.labels.comments

@ -0,0 +1,16 @@
main:
push {r3, lr}
movs r0, #1
movw r1, #:lower16:.LC0
movt r1, #:upper16:.LC0
bl __printf_chk
movs r0, #1
movw r1, #:lower16:.LC1
movt r1, #:upper16:.LC1
bl __printf_chk
movs r0, #0
pop {r3, pc}
.LC0:
.ascii "Hello world\000"
.LC1:
.ascii "moo\012\000"

19
test/cases/arm-static.asm

@ -0,0 +1,19 @@
LongLong:
.word 123456
.word 0
.type Long, %object
.size Long, 4
Long:
.word 2345
.type Int, %object
.size Int, 4
Int:
.word 123
.type Short, %object
.size Short, 2
Short:
.short 4660
.type Char, %object
.size Char, 1
Char:
.byte -128

11
test/cases/arm-static.asm.directives

@ -0,0 +1,11 @@
LongLong:
.word 123456
.word 0
Long:
.word 2345
Int:
.word 123
Short:
.short 4660
Char:
.byte -128

195
test/cases/clang-hellow.asm

@ -0,0 +1,195 @@
.file "-"
.file 1 "/home/mgodbolt/dev/gcc-explorer/-"
.file 2 "/home/mgodbolt/dev/gcc-explorer/<stdin>"
.section .debug_info,"",@progbits
.Lsection_info:
.section .debug_abbrev,"",@progbits
.Lsection_abbrev:
.section .debug_aranges,"",@progbits
.section .debug_macinfo,"",@progbits
.section .debug_line,"",@progbits
.Lsection_line:
.section .debug_loc,"",@progbits
.section .debug_pubnames,"",@progbits
.section .debug_pubtypes,"",@progbits
.section .debug_str,"",@progbits
.Lsection_str:
.section .debug_ranges,"",@progbits
.Ldebug_range:
.section .debug_loc,"",@progbits
.Lsection_debug_loc:
.text
.Ltext_begin:
.data
.text
.globl main
.align 16, 0x90
.type main,@function
main: # @main
.Ltmp2:
.cfi_startproc
.Lfunc_begin0:
.loc 2 2 0 # <stdin>:2:0
# BB#0:
pushq %rbp
.Ltmp3:
.cfi_def_cfa_offset 16
.Ltmp4:
.cfi_offset %rbp, -16
movq %rsp, %rbp
.Ltmp5:
.cfi_def_cfa_register %rbp
.loc 2 3 1 prologue_end # <stdin>:3:1
.Ltmp6:
movl $.L.str, %edi
xorb %al, %al
callq printf
.loc 2 4 3 # <stdin>:4:3
movl $str, %edi
callq puts
xorl %eax, %eax
.loc 2 5 1 # <stdin>:5:1
popq %rbp
ret
.Ltmp7:
.Ltmp8:
.size main, .Ltmp8-main
.Lfunc_end0:
.Ltmp9:
.cfi_endproc
.Leh_func_end0:
.type .L.str,@object # @.str
.section .rodata.str1.1,"aMS",@progbits,1
.L.str:
.asciz "Hello world"
.size .L.str, 12
.type str,@object # @str
.section .rodata,"a",@progbits
str:
.asciz "moo"
.size str, 4
.text
.Ltext_end:
.data
.Ldata_end:
.text
.Lsection_end1:
.section .debug_info,"",@progbits
.Linfo_begin1:
.long 175 # Length of Compilation Unit Info
.short 2 # DWARF version number
.long .Labbrev_begin # Offset Into Abbrev. Section
.byte 8 # Address Size (in bytes)
.byte 1 # Abbrev [1] 0xb:0xa8 DW_TAG_compile_unit
.ascii "Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)" # DW_AT_producer
.byte 0
.short 4 # DW_AT_language
.byte 45 # DW_AT_name
.byte 0
.quad 0 # DW_AT_entry_pc
.long .Lsection_line # DW_AT_stmt_list
.ascii "/home/mgodbolt/dev/gcc-explorer" # DW_AT_comp_dir
.byte 0
.byte 1 # DW_AT_APPLE_optimized
.byte 2 # Abbrev [2] 0x8b:0x20 DW_TAG_subprogram
.ascii "main" # DW_AT_name
.byte 0
.byte 2 # DW_AT_decl_file
.byte 2 # DW_AT_decl_line
.byte 1 # DW_AT_prototyped
.long 171 # DW_AT_type
.byte 1 # DW_AT_external
.quad .Lfunc_begin0 # DW_AT_low_pc
.quad .Lfunc_end0 # DW_AT_high_pc
.byte 1 # DW_AT_frame_base
.byte 86
.byte 3 # Abbrev [3] 0xab:0x7 DW_TAG_base_type
.ascii "int" # DW_AT_name
.byte 0
.byte 5 # DW_AT_encoding
.byte 4 # DW_AT_byte_size
.byte 0 # End Of Children Mark
.Linfo_end1:
.section .debug_abbrev,"",@progbits
.Labbrev_begin:
.byte 1 # Abbreviation Code
.byte 17 # DW_TAG_compile_unit
.byte 1 # DW_CHILDREN_yes
.byte 37 # DW_AT_producer
.byte 8 # DW_FORM_string
.byte 19 # DW_AT_language
.byte 5 # DW_FORM_data2
.byte 3 # DW_AT_name
.byte 8 # DW_FORM_string
.byte 82 # DW_AT_entry_pc
.byte 1 # DW_FORM_addr
.byte 16 # DW_AT_stmt_list
.byte 6 # DW_FORM_data4
.byte 27 # DW_AT_comp_dir
.byte 8 # DW_FORM_string
.ascii "\341\177" # DW_AT_APPLE_optimized
.byte 12 # DW_FORM_flag
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 2 # Abbreviation Code
.byte 46 # DW_TAG_subprogram
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 8 # DW_FORM_string
.byte 58 # DW_AT_decl_file
.byte 11 # DW_FORM_data1
.byte 59 # DW_AT_decl_line
.byte 11 # DW_FORM_data1
.byte 39 # DW_AT_prototyped
.byte 12 # DW_FORM_flag
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 63 # DW_AT_external
.byte 12 # DW_FORM_flag
.byte 17 # DW_AT_low_pc
.byte 1 # DW_FORM_addr
.byte 18 # DW_AT_high_pc
.byte 1 # DW_FORM_addr
.byte 64 # DW_AT_frame_base