diff options
author | Artem Belevich <artemb@gmail.com> | 2021-06-21 18:47:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-21 20:47:46 -0500 |
commit | b939d1fe5b44a3e3ea95c8bc92f6c9cf13490f2a (patch) | |
tree | 7d079dba112a0f0863a06ac3f61d3b4a4dcf57ac /lib/compilers/clang.js | |
parent | 51f7730e0e663e9d65788ab3e336d08516f2ccb6 (diff) | |
download | compiler-explorer-b939d1fe5b44a3e3ea95c8bc92f6c9cf13490f2a.tar.gz compiler-explorer-b939d1fe5b44a3e3ea95c8bc92f6c9cf13490f2a.zip |
Added support for SASS disassembly for clang as a CUDA compiler. (#2728)
* Added support for SASS disassembly for clang as a CUDA compiler.
Clang `--cuda-device-only -c` produces the same kind of CUBIN output as `nvcc
-cubin` and can use nvdisasm to disassemble it.
* Enable SASS disassembly for clang as a CUDA compiler.
Diffstat (limited to 'lib/compilers/clang.js')
-rw-r--r-- | lib/compilers/clang.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/compilers/clang.js b/lib/compilers/clang.js index 6c2bacb60..fa197d026 100644 --- a/lib/compilers/clang.js +++ b/lib/compilers/clang.js @@ -24,6 +24,7 @@ import path from 'path'; +import { SassAsmParser } from '../asm-parser-sass'; import { BaseCompiler } from '../base-compiler'; export class ClangCompiler extends BaseCompiler { @@ -39,3 +40,31 @@ export class ClangCompiler extends BaseCompiler { return super.runCompiler(compiler, options, inputFilename, execOptions); } } + +export class ClangCudaCompiler extends ClangCompiler { + static get key() { return 'clang-cuda'; } + constructor(info, env) { + super(info, env); + + this.asm = new SassAsmParser(); + } + + optionsForFilter(filters, outputFilename) { + return ['-o', this.filename(outputFilename), '-g1', filters.binary ? '-c' : '-S']; + } + + async objdump(outputFilename, result, maxSize) { + // For nvdisasm. + const args = [outputFilename, '-c', '-g', '-hex']; + const execOptions = {maxOutput: maxSize, customCwd: path.dirname(outputFilename)}; + + const objResult = await this.exec(this.compiler.objdumper, args, execOptions); + result.asm = objResult.stdout; + if (objResult.code !== 0) { + result.asm = `<No output: nvdisasm returned ${objResult.code}>`; + } else { + result.objdumpTime = objResult.execTime; + } + return result; + } +} |