aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS.md1
-rw-r--r--lib/languages.js3
-rw-r--r--static/modes/asm-mode.js5
-rw-r--r--static/modes/ptx-mode.js53
-rw-r--r--static/panes/compiler.js3
5 files changed, 62 insertions, 3 deletions
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 5a593955e..49137afca 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -70,3 +70,4 @@ From oldest to newest contributor, we would like to thank:
- [Daniel Black](https://github.com/grooverdan)
- [Gennadiy Civil](https://github.com/gennadiycivil)
- [Paul Scharnofske](https://github.com/asynts)
+- [Sebastian Staffa](https://github.com/Staff-d)
diff --git a/lib/languages.js b/lib/languages.js
index 72f208f5c..d4d0193d4 100644
--- a/lib/languages.js
+++ b/lib/languages.js
@@ -142,7 +142,8 @@ const languages = {
name: 'CUDA',
monaco: 'cuda',
extensions: ['.cu'],
- alias: ['nvcc']
+ alias: ['nvcc'],
+ monacoDisassembly: 'ptx'
},
zig: {
name: 'Zig',
diff --git a/static/modes/asm-mode.js b/static/modes/asm-mode.js
index c56e60a27..8fcb354e5 100644
--- a/static/modes/asm-mode.js
+++ b/static/modes/asm-mode.js
@@ -119,5 +119,8 @@ function definition() {
};
}
+var def = definition();
monaco.languages.register({id: 'asm'});
-monaco.languages.setMonarchTokensProvider('asm', definition());
+monaco.languages.setMonarchTokensProvider('asm', def);
+
+module.exports = def;
diff --git a/static/modes/ptx-mode.js b/static/modes/ptx-mode.js
new file mode 100644
index 000000000..18624275b
--- /dev/null
+++ b/static/modes/ptx-mode.js
@@ -0,0 +1,53 @@
+// Copyright (c) 2019, Compiler Explorer Authors
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+'use strict';
+var $ = require('jquery');
+var asm = require('./asm-mode');
+
+function definition() {
+ var ptx = $.extend(true, {}, asm); // deep copy
+
+ // Redefine registers for ptx:
+ // Usually ptx registers are in the form "%[pr][0-9]+", but a bunch of magic registers does not follow
+ // this scheme (see https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#special-registers ).
+ // Thus the register-regex captures everything that starts with a '%'.
+ ptx.registers = /%[a-z0-9_\\.]+/;
+
+
+ // Redefine whitespaces, as asm interprets strings with a leading '@' as comments.
+ ptx.tokenizer.whitespace = [
+ [/[ \t\r\n]+/, 'white'],
+ [/\/\*/, 'comment', '@comment'],
+ [/\/\/.*$/, 'comment'],
+ [/[#;\\].*$/, 'comment']
+ ];
+
+ // Add predicated instructions to the list of root tokens. Search for an opcode next, which is also a root token.
+ ptx.tokenizer.root.push([/@%p[0-9]+/, {token: 'operator', next: '@root'}]);
+
+ return ptx;
+}
+
+monaco.languages.register({id: 'ptx'});
+monaco.languages.setMonarchTokensProvider('ptx', definition());
diff --git a/static/panes/compiler.js b/static/panes/compiler.js
index bb8e095c9..0a944248a 100644
--- a/static/panes/compiler.js
+++ b/static/panes/compiler.js
@@ -40,6 +40,7 @@ var local = require('../local');
var Sentry = require('@sentry/browser');
var Libraries = require('../libs-widget');
require('../modes/asm-mode');
+require('../modes/ptx-mode');
require('selectize');
@@ -104,7 +105,7 @@ function Compiler(hub, container, state) {
this.outputEditor = monaco.editor.create(this.monacoPlaceholder[0], {
scrollBeyondLastLine: false,
readOnly: true,
- language: 'asm',
+ language: languages[this.currentLangId].monacoDisassembly || 'asm',
fontFamily: this.settings.editorsFFont,
glyphMargin: !options.embedded,
fixedOverflowWidgets: true,