mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 09:23:52 -05:00
Add minimal TI-C2000 compiler support (#4625)
This adds the ability to use TI's C2000 compiler with basic directive filtering and assembly code parsing.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,6 +15,7 @@
|
||||
/lib/storage/data
|
||||
|
||||
# IDE project files
|
||||
/.idea/shelf
|
||||
/nbproject
|
||||
*.vscode
|
||||
*.code-workspace
|
||||
|
||||
30
docs/TiC2000.md
Normal file
30
docs/TiC2000.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Running TI-C2000 compiler
|
||||
|
||||
This document is a very basic explanation of how to get the TI-C2000 compiler working with Compiler Explorer.
|
||||
|
||||
# Prerequisites
|
||||
|
||||
To run the TI-C2000 compiler you will need a valid installation of the C2000 compiler. https://www.ti.com/tool/C2000-CGT
|
||||
|
||||
## Setting up c++.local.properties
|
||||
|
||||
The next step is to create a `c++.local.properties` file under `etc/config` folder. It is going to be different for
|
||||
everyone, as you can choose what compiler options you pass to the compiler. Below is the template that I used for the
|
||||
22.6.0.LTS version of the compiler. Modify it as necessary for your needs.
|
||||
|
||||
```
|
||||
compilers=&c2000
|
||||
# TI-C2000 Compilers
|
||||
group.c2000.compilers=c2k2260LTS
|
||||
group.c2000.versionFlag=-version
|
||||
group.c2000.supportsBinary=false
|
||||
group.c2000.intelAsm=
|
||||
group.c2000.compilerType=tic2000
|
||||
group.c2000.demangler=C:\ti\ccs1210\ccs\tools\compiler\ti-cgt-c2000_22.6.0.LTS\bin\dem2000.exe
|
||||
group.c2000.demanglerType=tic2000
|
||||
group.c2000.includeFlag=-I
|
||||
|
||||
compiler.c2k2260LTS.exe=C:\ti\ccs1210\ccs\tools\compiler\ti-cgt-c2000_22.6.0.LTS\bin\cl2000.exe
|
||||
compiler.c2k2260LTS.options=-I"C:\ti\ccs1210\ccs\tools\compiler\ti-cgt-c2000_22.6.0.LTS\include"
|
||||
compiler.c2k2260LTS.name=C2000 22.6.0.LTS
|
||||
```
|
||||
@@ -99,6 +99,7 @@ export {SolidityCompiler} from './solidity.js';
|
||||
export {SPIRVCompiler} from './spirv.js';
|
||||
export {SwiftCompiler} from './swift.js';
|
||||
export {TenDRACompiler} from './tendra.js';
|
||||
export {TIC2000} from './tic2000.js';
|
||||
export {TinyCCompiler} from './tinyc.js';
|
||||
export {ToitCompiler} from './toit.js';
|
||||
export {TurboCCompiler} from './turboc.js';
|
||||
|
||||
72
lib/compilers/tic2000.ts
Normal file
72
lib/compilers/tic2000.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
// Copyright (c) 2023, 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.
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import _ from 'underscore';
|
||||
|
||||
import {BaseCompiler} from '../base-compiler.js';
|
||||
import {TiC2000AsmParser} from '../parsers/asm-parser-tic2000.js';
|
||||
|
||||
export class TIC2000 extends BaseCompiler {
|
||||
static get key() {
|
||||
return 'tic2000';
|
||||
}
|
||||
|
||||
constructor(info, env) {
|
||||
super(info, env);
|
||||
this.outputFilebase = this.compileFilename.split('.')[0];
|
||||
this.asm = new TiC2000AsmParser(this.compilerProps);
|
||||
}
|
||||
|
||||
override optionsForFilter(filters, outputFilename) {
|
||||
const options = ['-g', '-c', '-n', '--output_file=' + outputFilename];
|
||||
|
||||
filters.preProcessLines = _.bind(this.preProcessLines, this);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
override getOutputFilename(dirPath, outputFilebase) {
|
||||
return path.join(dirPath, `${outputFilebase}.asm`);
|
||||
}
|
||||
|
||||
preProcessLines(asmLines) {
|
||||
let i = 0;
|
||||
|
||||
while (i < asmLines.length) {
|
||||
// Regex for determining the file line and column of the following source lines
|
||||
const match = asmLines[i].match(/^\s*\.dwpsn\s+file\s+(".*"),line\s+(\d+),column\s+(\d+)/);
|
||||
i++;
|
||||
if (match) {
|
||||
// Add two lines stating the file and location to allow parsing the source location by the standard
|
||||
// parser
|
||||
asmLines.splice(i, 0, ' .file 1 ' + match[1], ' .loc 1 ' + match[2] + ' ' + match[3]);
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return asmLines;
|
||||
}
|
||||
}
|
||||
@@ -26,5 +26,6 @@ export {CppDemangler} from './cpp.js';
|
||||
export {DefaultDemangler} from './default.js';
|
||||
export {PascalDemangler} from './pascal.js';
|
||||
export {Win32Demangler} from './win32.js';
|
||||
export {TiC2000Demangler} from './tic2000.js';
|
||||
export {NVHPCDemangler} from './nvhpc.js';
|
||||
export {LLVMWin32Demangler} from './win32-llvm.js';
|
||||
|
||||
36
lib/demangler/tic2000.ts
Normal file
36
lib/demangler/tic2000.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2023, 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.
|
||||
|
||||
import {CppDemangler} from './cpp.js';
|
||||
|
||||
export class TiC2000Demangler extends CppDemangler {
|
||||
static override get key() {
|
||||
return 'tic2000';
|
||||
}
|
||||
|
||||
constructor(demanglerExe, compiler) {
|
||||
super(demanglerExe, compiler);
|
||||
this.demanglerArguments = ['-q'];
|
||||
}
|
||||
}
|
||||
34
lib/parsers/asm-parser-tic2000.ts
Normal file
34
lib/parsers/asm-parser-tic2000.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2023, 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.
|
||||
|
||||
import {AsmParser} from './asm-parser.js';
|
||||
|
||||
export class TiC2000AsmParser extends AsmParser {
|
||||
constructor(compilerProps) {
|
||||
super(compilerProps);
|
||||
|
||||
// ignore things that start with a $ or start with .
|
||||
this.directive = /^(\$+|\s*\.).*$/;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user