From c8f2cb53bed418f41be937c18275fb989681d528 Mon Sep 17 00:00:00 2001 From: Yashwant Singh <114088807+yashssh@users.noreply.github.com> Date: Fri, 24 Feb 2023 10:58:15 +0530 Subject: [PATCH] Language support for LLVM Machine IR (#4763) Resolves #4762 --------- Co-authored-by: Yashwant --- etc/config/llvm_mir.amazon.properties | 65 +++++++++++++++++++++++++ etc/config/llvm_mir.defaults.properties | 14 ++++++ examples/llvm_mir/default.mir | 13 +++++ lib/languages.ts | 11 +++++ types/languages.interfaces.ts | 1 + 5 files changed, 104 insertions(+) create mode 100644 etc/config/llvm_mir.amazon.properties create mode 100644 etc/config/llvm_mir.defaults.properties create mode 100644 examples/llvm_mir/default.mir diff --git a/etc/config/llvm_mir.amazon.properties b/etc/config/llvm_mir.amazon.properties new file mode 100644 index 000000000..988f61a84 --- /dev/null +++ b/etc/config/llvm_mir.amazon.properties @@ -0,0 +1,65 @@ +compilers=&mirllc +defaultCompiler=mirllctrunk + +demangler=/opt/compiler-explorer/gcc-11.1.0/bin/c++filt +objdumper=/opt/compiler-explorer/gcc-11.1.0/bin/objdump + +licenseName=LLVM Apache 2 +licenseLink=https://github.com/llvm/llvm-project/blob/main/LICENSE.TXT +licensePreamble=The LLVM Project is under the Apache License v2.0 with LLVM Exceptions + +group.mirllc.compilers=mirllc32:mirllc33:mirllc391:mirllc400:mirllc401:mirllc500:mirllc600:mirllc700:mirllc800:mirllc900:mirllc1000:mirllc1001:mirllc1100:mirllc1101:mirllc1200:mirllc1201:mirllc1300:mirllc1400:mirllc1500:mirllctrunk:mirllc-assertions-trunk +group.mirllc.compilerType=llc +group.mirllc.supportsExecute=false +group.mirllc.intelAsm=-masm=intel +group.mirllc.groupName=LLVM Static Compiler +group.mirllc.versionRe=LLVM version .* +group.mirllc.isSemVer=true +group.mirllc.baseName=llc + +compiler.mirllc32.exe=/opt/compiler-explorer/clang-3.2/bin/llc +compiler.mirllc32.semver=3.2 +compiler.mirllc33.exe=/opt/compiler-explorer/clang-3.3/bin/llc +compiler.mirllc33.semver=3.3 +compiler.mirllc391.exe=/opt/compiler-explorer/clang-3.9.1/bin/llc +compiler.mirllc391.semver=3.9.1 +compiler.mirllc400.exe=/opt/compiler-explorer/clang-4.0.0/bin/llc +compiler.mirllc400.semver=4.0.0 +compiler.mirllc401.exe=/opt/compiler-explorer/clang-4.0.1/bin/llc +compiler.mirllc401.semver=4.0.1 +compiler.mirllc500.exe=/opt/compiler-explorer/clang-5.0.0/bin/llc +compiler.mirllc500.semver=5.0.0 +compiler.mirllc600.exe=/opt/compiler-explorer/clang-6.0.0/bin/llc +compiler.mirllc600.semver=6.0.0 +compiler.mirllc700.exe=/opt/compiler-explorer/clang-7.0.0/bin/llc +compiler.mirllc700.semver=7.0.0 +compiler.mirllc800.exe=/opt/compiler-explorer/clang-8.0.0/bin/llc +compiler.mirllc800.semver=8.0.0 +compiler.mirllc900.exe=/opt/compiler-explorer/clang-9.0.0/bin/llc +compiler.mirllc900.semver=9.0.0 +compiler.mirllc1000.exe=/opt/compiler-explorer/clang-10.0.0/bin/llc +compiler.mirllc1000.semver=10.0.0 +compiler.mirllc1001.exe=/opt/compiler-explorer/clang-10.0.1/bin/llc +compiler.mirllc1001.semver=10.0.1 +compiler.mirllc1100.exe=/opt/compiler-explorer/clang-11.0.0/bin/llc +compiler.mirllc1100.semver=11.0.0 +compiler.mirllc1101.exe=/opt/compiler-explorer/clang-11.0.1/bin/llc +compiler.mirllc1101.semver=11.0.1 +compiler.mirllc1200.exe=/opt/compiler-explorer/clang-12.0.0/bin/llc +compiler.mirllc1200.semver=12.0.0 +compiler.mirllc1201.exe=/opt/compiler-explorer/clang-12.0.1/bin/llc +compiler.mirllc1201.semver=12.0.1 +compiler.mirllc1300.exe=/opt/compiler-explorer/clang-13.0.0/bin/llc +compiler.mirllc1300.semver=13.0.0 +compiler.mirllc1400.exe=/opt/compiler-explorer/clang-14.0.0/bin/llc +compiler.mirllc1400.semver=14.0.0 +compiler.mirllc1500.exe=/opt/compiler-explorer/clang-15.0.0/bin/llc +compiler.mirllc1500.semver=15.0.0 +compiler.mirllctrunk.exe=/opt/compiler-explorer/clang-trunk/bin/llc +compiler.mirllctrunk.demangler=/opt/compiler-explorer/gcc-snapshot/bin/c++filt +compiler.mirllctrunk.objdumper=/opt/compiler-explorer/gcc-snapshot/bin/objdump +compiler.mirllctrunk.semver=(trunk) +compiler.mirllc-assertions-trunk.exe=/opt/compiler-explorer/clang-assertions-trunk/bin/llc +compiler.mirllc-assertions-trunk.demangler=/opt/compiler-explorer/gcc-snapshot/bin/c++filt +compiler.mirllc-assertions-trunk.objdumper=/opt/compiler-explorer/gcc-snapshot/bin/objdump +compiler.mirllc-assertions-trunk.semver=(assertions trunk) diff --git a/etc/config/llvm_mir.defaults.properties b/etc/config/llvm_mir.defaults.properties new file mode 100644 index 000000000..e7db96bd6 --- /dev/null +++ b/etc/config/llvm_mir.defaults.properties @@ -0,0 +1,14 @@ +binaryHideFuncRe=^(__.*|_(init|start|fini)|(de)?register_tm_clones|call_gmon_start|frame_dummy|(_GLOBAL__sub_I_|\.plt).*|.*@plt(-0x[0-9a-f]+)?)$ +objdumper=objdump +demangler=c++filt + +compilers=mirllc +defaultCompiler=mirllc + +compiler.mirllc.compilerType=llc +compiler.mirllc.supportsExecute=false +compiler.mirllc.intelAsm=-masm=intel +compiler.mirllc.groupName=LLVM Static Compiler +compiler.mirllc.versionRe=LLVM version .* +compiler.mirllc.exe=/usr/bin/llc +compiler.mirllc.name=llc diff --git a/examples/llvm_mir/default.mir b/examples/llvm_mir/default.mir new file mode 100644 index 000000000..24e92f56d --- /dev/null +++ b/examples/llvm_mir/default.mir @@ -0,0 +1,13 @@ +--- +name: square +tracksRegLiveness: true +body: | + bb.0: + liveins: $edi + + %0:gr32 = COPY $edi + %1:gr32 = nsw IMUL32rr %0, %0, implicit-def dead $eflags + $eax = COPY %1 + RET 0, $eax + +... diff --git a/lib/languages.ts b/lib/languages.ts index b65949316..87816351a 100644 --- a/lib/languages.ts +++ b/lib/languages.ts @@ -418,6 +418,17 @@ const definitions: Record = { previewFilter: null, monacoDisassembly: null, }, + llvm_mir: { + name: 'LLVM MIR', + monaco: 'llvm-ir', + extensions: ['.mir'], + alias: [], + logoUrl: 'llvm.png', + logoUrlDark: null, + formatter: null, + previewFilter: null, + monacoDisassembly: null, + }, modula2: { name: 'modula2', monaco: 'modula2', diff --git a/types/languages.interfaces.ts b/types/languages.interfaces.ts index 8c67c0e45..8900fc4b6 100644 --- a/types/languages.interfaces.ts +++ b/types/languages.interfaces.ts @@ -56,6 +56,7 @@ export type LanguageKey = | 'julia' | 'kotlin' | 'llvm' + | 'llvm_mir' | 'mlir' | 'modula2' | 'nim'