Add support for the Spice programming language.
Spice (`spicelang`) is a simple, AOT compiled, LLVM-based systems
language with focus on practicality and performance.
**Key features of Spice**
- simplicity - see what you get aproach with batteries included
- performance: As Spice uses LLVM as its primary backbone, it competes
with the performance of other LLVM-based compilers
- enhanced safety: Spice implements an enhanced safety mechanism, which
includes builtin heap type with auto-free and more
- cross-compile support: Currently x86_64, AArch64 and wasm32 are
supported cross-compilation targets, but more to come
- Pretty good C and C++ interop
**Links**
- Source code: https://github.com/spicelang/spice
- Website: https://spicelang.com
- Playground (own CE instance): https://play.spicelang.com
- Infra PR: https://github.com/compiler-explorer/infra/pull/1229
**Things this PR addresses**
- General support for Spice
- Three code examples
- Spice mode (Syntax highlighting)
- Opt pipeline support
- LLVM mca and osaca support
This restores the sorting behavior for the compiler picker to about two
years ago before the ts conversion. I'm not sure what the effect of
`.localeCompare() === 0` on .sort is, since that's only giving equality
information. The `@types` for underscorejs says `_._Chain.sort`'s
compare function should return a boolean but I can't actually find the
definition of any `sort` function in underscorejs nor are there docs
about what its compare function should return, but I think it's really
calling `Array.prototype.sort` which expects a negative/0/positive.
Replace the deprecated `monaco.editor.ICodeEditor.deltaDecorations` with `monaco.editor.IEditorDecorationsCollection`
Seems that today the official way of colouring monaco editors is having
them `createDecorationsCollection`, keep the resulting
decorations-collection and call `set` on it with new decorations
whenever needed.
There are many possible design choices on where to put it, I opted to
put `editorDecorations` in `MonacoPane`, and have
`MonacoPane.createEditor` initialize it only in panes where decorations
are actually used.
Also some signatures changed which had a broad (but non-interesting)
impact.
<!-- 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!
-->
Pane contents are populated by `<pane>.onCompileResult`, triggered by
`eventHub.emit('compileResult'..)` in `compiler.ts`.
The contents' colors are updated by `<pane>.onColours`, triggered mainly
by `eventHub.emit('colours'...)` invoked indirectly by
`editor.onCompileResult`. (colors are an editor property).
The order of invocations is governed by the order of registration and is
hard to control, and so a mechanism was devised to cache `onColours`
arguments and invoke it only after `onCompileResult`:
`mediateDependentCalls`:
https://github.com/compiler-explorer/compiler-explorer/blob/ab937c5d151807eeff8d0735ca999ae36ff10392/static/event-hub.ts#L93-L116
It is coded as a generic mechanism but used only for this
color->compileResult dependency in ir-view and ast-view.
I imagine this worked for a while, but somewhere along the line
triggering of events got messier - there are now multiple compilation
runs that generate different contents, and the `mediateDependentCalls`
logic breaks for some triggering orders, eg: dependent -> dependency ->
dependency. (note how
https://github.com/compiler-explorer/compiler-explorer/blob/ab937c5d151807eeff8d0735ca999ae36ff10392/static/event-hub.ts#L104
prevents `dependent` from being called after the last `dependency`
call).
This PR fixes `mediateDependentCalls` to make it call `dependent` with
its _latest_ arguments after _every_ `dependency` call.
This brings color back to IR and to AST. Until a few days ago I wasn't
aware they were already colored in the past, and I suspects others
weren't aware either:
https://github.com/compiler-explorer/compiler-explorer/issues/5475#issuecomment-1714699031
Mindless replacements of the form
`_.filter(options, option =>...` --> `options.filter(option =>...`.
One not *entirely* mindless replacement at the bottom of
compiler-dropin-tool.ts :
```
- return _.filter(pathFilteredFlags) as string[];
+ return pathFilteredFlags.filter(Boolean) as string[];
```
6 files can now stop importing underscore.
This adds a Racket optimisation pipeline view by reusing the existing
LLVM-focused optimisation pipeline UI. A Racket-specific pass parser
translates its output into passes for the UI to present.
This new Racket optimisation pipeline view is currently only enabled for
Racket nightly, as it depends on [recent
changes](https://github.com/racket/racket/pull/4842) to Racket's
compiler output to function.
This also extends the opt pipeline view to allow customising the
function selector label as well as the options and filters for each
compiler where needed.

---------
Co-authored-by: Matt Godbolt <matt@godbolt.org>
This works and seems reasonable - some intersections might be
unavoidable and we wouldn't want to throw the entire graph away if it
happens.
...But I don't really know what I'm doing, as so far I failed to track
internal `GraphLayoutCore` logic.
@jeremy-rifkin would appreciate if you could take a look.
This prepares for future work that will reuse the opt pipeline view
outside of the LLVM ecosystem by renaming related components to remove
the LLVM prefix.
The pass dumper keep its LLVM prefix, as it is assumed this part is
likely to be customised for each compiler ecosystem.
The historical component name has been preserved in the component list
as an alias to keep old links working.
<!-- 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!
-->
LLVM TableGen is used to generate complex output files in the llvm
project. A generic description of classes and definitions produces
"records" that can then be walked by a TableGen backend to produce
things like C++ code, configuration files, etc.
The biggest examples are LLVM's assembler and disassembler where all the
targets' instructions are defined in TableGen.
https://llvm.org/docs/TableGen/ProgRef.html
An example:
```
class Register<int _size, string _alias=""> {
int size = _size;
string alias = _alias;
}
def X0: Register<8> {}
def X29: Register<8, "frame pointer"> {}
```
```
------------- Classes -----------------
class Register<int Register:_size = ?, string Register:_alias = ""> {
int size = Register:_size;
string alias = Register:_alias;
}
------------- Defs -----------------
def X0 { // Register
int size = 8;
string alias = "";
}
def X29 { // Register
int size = 8;
string alias = "frame pointer";
}
```
It's often a pain point for people new to LLVM so having a quick way to
experiment would be a great benefit for the community (we have a Jupyter
kernel which is good but not as simple as Compiler Explorer).
The compiler for TableGen is `llvm-tblgen`. This comes with most release
builds of LLVM in /bin along with clang and the others. Its default is
to output a text dump of the records defined so that's what I've used
here. This is not executable code so I've disabled the features related
to that.
A user could pass options to `llvm-tblgen` to produce text in a format
other than this, C++ code or JSON for example. However this text dump is
the main use case.
I've re-used an existing clang install, since that includes
`llvm-tblgen` in `bin/`. I just added the 17.01 version for this first
change.
Syntax highlighting is a mix of the Fortran and Ada configuration,
following the language spec I linked above. Though I am very new to that
so it is likely incomplete.
#5552 boils down to a state where `CompilationResult` has `stderr` but
no `stdout` - which seems reasonable given the input (the compilation
wasn't even run). This causes these lines to break:
```ts
addOutputLines(result: CompilationResult) {
const stdout = result.stdout;
const stderr = result.stderr;
for (const obj of stdout.concat(stderr)) { // <-----stdout is undefined
```
This is an attempt to make only `stdout` (not `stderr`) optional, and
account for it being undefined in this context. Feedback is welcome.