Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
ELVM – Similar to LLVM but Dedicated to Esoteric Languages (github.com/shinh)
2 points by peter_d_sherman on Jan 9, 2021 | hide | past | favorite | 3 comments


Some backends might have some of the operations that ELVM doesn't have. One idea is to have ELVM with macros (which can have parameters); unsupported operations can be implemented using macros. Macros can be expanded independently of the backend, so this does not require changing the backend code. By examing the 8cc code, I guess that it might be possible to do it like that. Also ensure it can work correctly with different word sizes (and some backends might have option to control word sizes).


Interesting! Will keep that in mind!


>"ELVM is similar to LLVM but dedicated to Esoteric Languages. This project consists of two components - frontend and backend. Currently, the only frontend we have is a modified version of 8cc. The modified 8cc translates C code to an internal representation format called ELVM IR (EIR). Unlike LLVM bitcode, EIR is designed to be extremely simple, so there's more chance we can write a translator from EIR to an esoteric language.

Currently, there are 48 backends:

Awk (by @dubek)

Bash

Befunge

Brainfuck

C

C++14 constexpr (compile-time) (by @kw-udon)

C++ Template Metaprogramming (compile-time) (by @kw-udon) (WIP)

C# (by @masaedw)

C-INTERCAL

CMake (by @ooxi)

CommonLisp (by @youz)

Crystal (compile-time) (by @MakeNowJust)

Emacs Lisp

F# (by @masaedw)

Forth (by @dubek)

Fortran (by @samcoppini)

Go (by @shogo82148)

HeLL (by @esoteric-programmer)

J (by @dubek)

Java

JavaScript

Kinx (by @Kray-G)

LLVM IR (by @retrage)

LOLCODE (by @gamerk)

Lua (by @retrage)

Octave (by @inaniwa3)

Perl5 (by @mackee)

PHP (by @zonuexe)

Piet

Python

Ruby

Scheme syntax-rules (by @zeptometer)

Scratch3.0 (by @algon-320)

SQLite3 (by @youz)

Swift (by @kwakasa)

Tcl (by @dubek)

TeX (by @hak7a3)

TensorFlow (WIP)

Turing machine (by @ND-CSE-30151)

Unlambda (by @irori)

Vim script (by @rhysd)

WebAssembly (by @dubek)

WebAssembly System Interface (by @sanemat)

Whirl by (@samcoppini)

W-Machine by (@jcande)

Whitespace

arm-linux (by @irori)

i386-linux

sed

The above list contains languages which are known to be difficult to program in, but with ELVM, you can create programs in such languages. You can easily create Brainfuck programs by writing C code for example. One of interesting testcases ELVM has is a tiny Lisp interpreter. The all above language backends are passing the test, which means you can run Lisp on the above languages.

Moreover, 8cc and ELVM themselves are written in C. So we can run a C compiler written in the above languages to compile the ELVM's compiler toolchain itself, though such compilation takes long time in some esoteric languages."

[...]

>"ELVM internals

ELVM IR

Harvard architecture, not Neumann (allowing self-modifying code is hard)

6 registers: A, B, C, D, SP, and BP

Ops: mov, add, sub, load, store, setcc, jcc, putc, getc, and exit

Psuedo ops: .text, .data, .long, and .string mul/div/mod are implemented by _builtin*

No bit operations

No floating point arithmetic

sizeof(char) == sizeof(int) == sizeof(void*) == 1

The word-size is backend dependent, but most backend uses 24bit words

A single programming counter may contain multiple operations"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: