mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-02 07:09:48 -06:00
A majority of the actions/backends expect to find certain classes and definitions in the source code. There's no canonical reference for this so it's a combination of incomplete docs and the actual uses in llvm-project. (most of the time I expect people will come from llvm-project to experiment, rather than the other way around) I've added an example that uses the Searchable Tables backend. <!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE IT Thanks for taking the time to improve CE. We really appreciate it. Before opening the PR, please make sure that the tests & linter pass their checks, by running `make check`. In the best case scenario, you are also adding tests to back up your changes, but don't sweat it if you don't. We can discuss them at a later date. Feel free to append your name to the CONTRIBUTORS.md file Thanks again, we really appreciate this! -->
51 lines
2.0 KiB
TypeScript
51 lines
2.0 KiB
TypeScript
import {BaseCompiler} from '../base-compiler.js';
|
|
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
|
|
import {TableGenParser} from './argument-parsers.js';
|
|
import {CompilerOverrideType} from '../../types/compilation/compiler-overrides.interfaces.js';
|
|
|
|
export class TableGenCompiler extends BaseCompiler {
|
|
static get key() {
|
|
return 'tablegen';
|
|
}
|
|
|
|
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string) {
|
|
const options: string[] = ['-o', outputFilename];
|
|
if (this.compiler.includePath) {
|
|
options.push(`-I${this.compiler.includePath}`);
|
|
}
|
|
return options;
|
|
}
|
|
|
|
override isCfgCompiler() {
|
|
return false;
|
|
}
|
|
|
|
override getArgumentParser() {
|
|
return TableGenParser;
|
|
}
|
|
|
|
override async populatePossibleOverrides() {
|
|
const possibleActions = await TableGenParser.getPossibleActions(this);
|
|
if (possibleActions.length > 0) {
|
|
this.compiler.possibleOverrides?.push({
|
|
name: CompilerOverrideType.action,
|
|
display_title: 'Action',
|
|
description:
|
|
'The action to perform, which is the backend you wish to ' +
|
|
'run. By default, the records are just printed as text. ' +
|
|
'Many backends expect to find certain classes and defnitions ' +
|
|
'in your source code. You may find details of those in the ' +
|
|
'<a href="https://llvm.org/docs/TableGen/BackEnds.html" target="_blank">documentation</a>, ' +
|
|
'but if not, refer to use of the backend in the ' +
|
|
'<a href="https://github.com/llvm/llvm-project" target="_blank">LLVM Project</a> ' +
|
|
'by searching for the command line name e.g. "gen-attrs".',
|
|
flags: ['<value>'],
|
|
values: possibleActions,
|
|
default: '--print-records',
|
|
});
|
|
}
|
|
|
|
await super.populatePossibleOverrides();
|
|
}
|
|
}
|