Skip to content

Commit

Permalink
compiler: remove bitcode/JS implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Jul 13, 2020
1 parent 9901bfd commit 4b6ddc8
Show file tree
Hide file tree
Showing 75 changed files with 42 additions and 3,585 deletions.
80 changes: 8 additions & 72 deletions src/compiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import * as frontend from 'llparse-frontend';

import source = frontend.source;

import * as bitcodeImpl from '../implementation/bitcode';
import * as cImpl from '../implementation/c';
import * as jsImpl from '../implementation/js';
import { HeaderBuilder } from './header-builder';

const debug = debugAPI('llparse:compiler');
Expand All @@ -32,54 +30,25 @@ export interface ICompilerOptions {
*/
readonly headerGuard?: string;

/** Generate bitcode (`true` by default) */
readonly generateBitcode?: boolean;

/** Generate C (`true` by default) */
readonly generateC?: boolean;

/** Generate JS (`true` by default) */
readonly generateJS?: boolean;

/** Optional frontend configuration */
readonly frontend?: frontend.IFrontendLazyOptions;

/** Optional C-backend configuration */
readonly c?: cImpl.ICPublicOptions;

/** Optional JS-backend configuration */
readonly js?: jsImpl.IJSPublicOptions;
}

export interface ICompilerResult {
/**
* Binary LLVM bitcode, if `generateBitcode` option was `true`
*/
readonly bitcode?: Buffer;

/**
* Textual C code, if `generateC` option was `true`
*/
readonly c?: string;

/**
* Textual JS code, if `generateJS` option was `true`
* Textual C code
*/
readonly js?: string;
readonly c: string;

/**
* Textual C header file
*/
readonly header: string;
}

interface IWritableCompilerResult {
bitcode?: Buffer;
c?: string;
js?: string;
header: string;
}

export class Compiler {
constructor(public readonly prefix: string,
public readonly options: ICompilerOptions) {
Expand All @@ -90,26 +59,9 @@ export class Compiler {
debug('Combining implementations');
const container = new frontend.Container();

let bitcode: bitcodeImpl.BitcodeCompiler | undefined;
if (this.options.generateBitcode !== false) {
bitcode = new bitcodeImpl.BitcodeCompiler(container, {
debug: this.options.debug,
});
}

let c: cImpl.CCompiler | undefined;
if (this.options.generateC !== false) {
c = new cImpl.CCompiler(container, Object.assign({
debug: this.options.debug,
}, this.options.c));
}

let js: jsImpl.JSCompiler | undefined;
if (this.options.generateJS !== false) {
js = new jsImpl.JSCompiler(container, Object.assign({
debug: this.options.debug,
}, this.options.js!));
}
const c = new cImpl.CCompiler(container, Object.assign({
debug: this.options.debug,
}, this.options.c));

debug('Running frontend pass');
const f = new frontend.Frontend(this.prefix,
Expand All @@ -127,26 +79,10 @@ export class Compiler {
spans: info.spans,
});

const result: IWritableCompilerResult = {
bitcode: undefined,
debug('Building C');
return {
header,
c: c.compile(info),
};

debug('Building bitcode');
if (bitcode) {
result.bitcode = bitcode.compile(info);
}

debug('Building C');
if (c) {
result.c = c.compile(info);
}

debug('Building JS');
if (js) {
result.js = js.compile(info);
}

return result;
}
}
50 changes: 0 additions & 50 deletions src/implementation/bitcode/code/base.ts

This file was deleted.

26 changes: 0 additions & 26 deletions src/implementation/bitcode/code/external.ts

This file was deleted.

32 changes: 0 additions & 32 deletions src/implementation/bitcode/code/field.ts

This file was deleted.

25 changes: 0 additions & 25 deletions src/implementation/bitcode/code/index.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/implementation/bitcode/code/is-equal.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/implementation/bitcode/code/load.ts

This file was deleted.

100 changes: 0 additions & 100 deletions src/implementation/bitcode/code/mul-add.ts

This file was deleted.

Loading

0 comments on commit 4b6ddc8

Please sign in to comment.