mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 10:33:59 -05:00
Adding ylc (#6982)
Hi dear godbolt team, > Before opening the PR, please make sure that the tests & linter pass their checks, > by running `make check`. With this pr i added support for the ylc compiler. Infra-PR: https://github.com/compiler-explorer/infra/pull/1441
This commit is contained in:
16
etc/config/ylc.amazon.properties
Normal file
16
etc/config/ylc.amazon.properties
Normal file
@@ -0,0 +1,16 @@
|
||||
compilers=&ylc_compilers
|
||||
defaultCompiler=ylc_newest
|
||||
objdumper=/opt/compiler-explorer/clang-18.1.0/bin/llvm-objdump
|
||||
objdumperType=llvm
|
||||
|
||||
group.ylc_compilers.compilers=ylc_newest
|
||||
group.ylc_compilers.compilerType=ylc
|
||||
group.ylc_compilers.options=
|
||||
group.ylc_compilers.supportsBinary=false
|
||||
group.ylc_compilers.supportsBinaryObject=false
|
||||
group.ylc_compilers.versionFlag=--version
|
||||
group.ylc_compilers.isSemVer=true
|
||||
group.ylc_compilers.baseName=ylc
|
||||
|
||||
compiler.ylc_newest.exe=/opt/compiler-explorer/ygen/bin/ylc
|
||||
compiler.ylc_newest.semver=0.0.0
|
||||
11
etc/config/ylc.defaults.properties
Normal file
11
etc/config/ylc.defaults.properties
Normal file
@@ -0,0 +1,11 @@
|
||||
compilers=ylc_newest
|
||||
displayName=ylc
|
||||
|
||||
compiler.ylc_newest.exe=/opt/compiler-explorer/ygen/bin/ylc
|
||||
compiler.ylc_newest.semver=0.0.0
|
||||
compiler.ylc_newest.supportsBinary=false
|
||||
compiler.ylc_newest.compilerType=ylc
|
||||
compiler.ylc_newest.objdumper=objdump
|
||||
compiler.ylc_newest.versionFlag=--version
|
||||
compiler.ylc_newest.options=-asm
|
||||
compiler.ylc_newest.displayName=ylc
|
||||
5
examples/ylc/default.yl
Normal file
5
examples/ylc/default.yl
Normal file
@@ -0,0 +1,5 @@
|
||||
define i32 @square(i32 %0) {
|
||||
entry:
|
||||
%1 = mul i32 %0, %0
|
||||
ret i32 %1
|
||||
}
|
||||
1
infra
Submodule
1
infra
Submodule
Submodule infra added at 3d4a55bdc2
@@ -91,6 +91,7 @@ export {JuliaCompiler} from './julia.js';
|
||||
export {KotlinCompiler} from './kotlin.js';
|
||||
export {LDCCompiler} from './ldc.js';
|
||||
export {LLCCompiler} from './llc.js';
|
||||
export {YLCCompiler} from './ylc.js';
|
||||
export {LLVMmcaTool} from './llvm-mca.js';
|
||||
export {LLVMMOSCompiler} from './llvm-mos.js';
|
||||
export {MadPascalCompiler} from './madpascal.js';
|
||||
|
||||
83
lib/compilers/ylc.ts
Normal file
83
lib/compilers/ylc.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import path from 'path';
|
||||
|
||||
import {CompileChildLibraries} from '../../types/compilation/compilation.interfaces.js';
|
||||
import {ConfiguredOverrides} from '../../types/compilation/compiler-overrides.interfaces.js';
|
||||
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
|
||||
import {unwrap} from '../assert.js';
|
||||
import {BaseCompiler} from '../base-compiler.js';
|
||||
import * as utils from '../utils.js';
|
||||
|
||||
import {BaseParser} from './argument-parsers.js';
|
||||
|
||||
export class YLCCompiler extends BaseCompiler {
|
||||
static get key() {
|
||||
return 'ylc';
|
||||
}
|
||||
|
||||
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string, userOptions: string[]) {
|
||||
return ['-o=' + this.filename(outputFilename)];
|
||||
}
|
||||
|
||||
override getArgumentParserClass() {
|
||||
return BaseParser;
|
||||
}
|
||||
|
||||
override prepareArguments(
|
||||
userOptions: string[],
|
||||
filters: ParseFiltersAndOutputOptions,
|
||||
backendOptions: Record<string, any>,
|
||||
inputFilename: string,
|
||||
outputFilename: string,
|
||||
libraries: CompileChildLibraries[],
|
||||
overrides: ConfiguredOverrides,
|
||||
) {
|
||||
let options = this.optionsForFilter(filters, outputFilename, userOptions);
|
||||
backendOptions = backendOptions || {};
|
||||
|
||||
options = options.concat(this.optionsForBackend(backendOptions, outputFilename));
|
||||
|
||||
if (this.compiler.options) {
|
||||
options = options.concat(utils.splitArguments(this.compiler.options));
|
||||
}
|
||||
|
||||
if (this.compiler.supportsOptOutput && backendOptions.produceOptInfo) {
|
||||
options = options.concat(unwrap(this.compiler.optArg));
|
||||
}
|
||||
if (this.compiler.supportsStackUsageOutput && backendOptions.produceStackUsageInfo) {
|
||||
options = options.concat(unwrap(this.compiler.stackUsageArg));
|
||||
}
|
||||
|
||||
const toolchainPath = this.getDefaultOrOverridenToolchainPath(backendOptions.overrides || []);
|
||||
|
||||
const dirPath = path.dirname(inputFilename);
|
||||
|
||||
const libIncludes = this.getIncludeArguments(libraries, dirPath);
|
||||
const libOptions = this.getLibraryOptions(libraries);
|
||||
let libLinks: string[] = [];
|
||||
let libPaths: string[] = [];
|
||||
let libPathsAsFlags: string[] = [];
|
||||
let staticLibLinks: string[] = [];
|
||||
|
||||
if (filters.binary) {
|
||||
libLinks = (this.getSharedLibraryLinks(libraries).filter(Boolean) as string[]) || [];
|
||||
libPathsAsFlags = this.getSharedLibraryPathsAsArguments(libraries, undefined, toolchainPath, dirPath);
|
||||
libPaths = this.getSharedLibraryPaths(libraries, dirPath);
|
||||
staticLibLinks = (this.getStaticLibraryLinks(libraries, libPaths).filter(Boolean) as string[]) || [];
|
||||
}
|
||||
|
||||
userOptions = this.filterUserOptions(userOptions) || [];
|
||||
[options, overrides] = this.fixIncompatibleOptions(options, userOptions, overrides);
|
||||
options = this.changeOptionsBasedOnOverrides(options, overrides);
|
||||
|
||||
return this.orderArguments(
|
||||
options,
|
||||
'-in=' + inputFilename,
|
||||
libIncludes,
|
||||
libOptions,
|
||||
libPathsAsFlags,
|
||||
libLinks,
|
||||
userOptions,
|
||||
staticLibLinks,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -851,6 +851,17 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
|
||||
previewFilter: /^\s*#include/,
|
||||
monacoDisassembly: null,
|
||||
},
|
||||
ylc: {
|
||||
name: 'Ygen',
|
||||
monaco: 'llvm-ir',
|
||||
extensions: ['.yl'],
|
||||
alias: [],
|
||||
logoUrl: null, // ygen does not yet have a logo ping me if it requires one (@Cr0a3)
|
||||
logoUrlDark: null,
|
||||
formatter: null,
|
||||
previewFilter: null,
|
||||
monacoDisassembly: null,
|
||||
},
|
||||
};
|
||||
|
||||
export const languages = Object.fromEntries(
|
||||
|
||||
@@ -93,7 +93,8 @@ export type LanguageKey =
|
||||
| 'vala'
|
||||
| 'vb'
|
||||
| 'wasm'
|
||||
| 'zig';
|
||||
| 'zig'
|
||||
| 'ylc';
|
||||
|
||||
export interface Language {
|
||||
/** Id of language. Added programmatically based on CELanguages key */
|
||||
|
||||
Reference in New Issue
Block a user