├── .gitignore ├── LICENSE ├── README.md ├── bindings ├── core.v └── flags.v ├── v.mod └── vllvm.v /.gitignore: -------------------------------------------------------------------------------- 1 | # http://www.gnu.org/software/automake 2 | 3 | Makefile.in 4 | /ar-lib 5 | /mdate-sh 6 | /py-compile 7 | /test-driver 8 | /ylwrap 9 | 10 | # http://www.gnu.org/software/autoconf 11 | 12 | autom4te.cache 13 | /autoscan.log 14 | /autoscan-*.log 15 | /aclocal.m4 16 | /compile 17 | /config.guess 18 | /config.h.in 19 | /config.log 20 | /config.status 21 | /config.sub 22 | /configure 23 | /configure.scan 24 | /depcomp 25 | /install-sh 26 | /missing 27 | /stamp-h1 28 | 29 | # https://www.gnu.org/software/libtool/ 30 | 31 | /ltmain.sh 32 | 33 | # http://www.gnu.org/software/texinfo 34 | 35 | /texinfo.tex 36 | 37 | # http://www.gnu.org/software/m4/ 38 | 39 | m4/libtool.m4 40 | m4/ltoptions.m4 41 | m4/ltsugar.m4 42 | m4/ltversion.m4 43 | m4/lt~obsolete.m4 44 | 45 | # Generated Makefile 46 | # (meta build system like autotools, 47 | # can automatically generate from config.status script 48 | # (which is called by configure script)) 49 | Makefile 50 | 51 | # Prerequisites 52 | *.d 53 | 54 | # Compiled Object files 55 | *.slo 56 | *.lo 57 | *.o 58 | *.obj 59 | *.pdb 60 | 61 | # Precompiled Headers 62 | *.gch 63 | *.pch 64 | 65 | # Compiled Dynamic libraries 66 | *.so 67 | *.dylib 68 | *.dll 69 | 70 | # Fortran module files 71 | #*.mod 72 | #*.smod 73 | 74 | # Compiled Static libraries 75 | *.lai 76 | *.la 77 | *.a 78 | *.lib 79 | 80 | # Executables 81 | *.exe 82 | *.out 83 | *.app 84 | *.ilk 85 | 86 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 87 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 88 | 89 | .idea 90 | *.iml 91 | *.ipr 92 | *.log 93 | *.dmp 94 | *.so 95 | 96 | # CMake 97 | cmake-build-*/ 98 | 99 | # Mongo Explorer plugin 100 | .idea/**/mongoSettings.xml 101 | 102 | # File-based project format 103 | *.iws 104 | 105 | # IntelliJ 106 | out/ 107 | 108 | # mpeltonen/sbt-idea plugin 109 | .idea_modules/ 110 | 111 | # JIRA plugin 112 | atlassian-ide-plugin.xml 113 | 114 | # Cursive Clojure plugin 115 | .idea/replstate.xml 116 | 117 | # Crashlytics plugin (for Android Studio and IntelliJ) 118 | com_crashlytics_export_strings.xml 119 | crashlytics.properties 120 | crashlytics-build.properties 121 | fabric.properties 122 | 123 | # Editor-based Rest Client 124 | .idea/httpRequests 125 | 126 | # Android studio 3.1+ serialized cache file 127 | .idea/caches/build_file_checksums.ser 128 | 129 | *.Po 130 | /build 131 | 132 | # vlang shit 133 | *.tmp.c 134 | *.vh 135 | */fns.txt 136 | fns.txt 137 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Alexander Medvednikov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # v-llvm 2 | Experimental LLVM backend for V developed by the community. 3 | 4 | The goal is to generate LLVM IR from the V AST. 5 | 6 | Requires LLVM 10. -------------------------------------------------------------------------------- /bindings/core.v: -------------------------------------------------------------------------------- 1 | module bindings 2 | 3 | // Core 4 | fn C.LLVMShutdown() 5 | fn C.LLVMCreateMessage(charptr) charptr 6 | fn C.LLVMDisposeMessage(charptr) 7 | 8 | pub fn llvm_shutdown() { 9 | C.LLVMShutdown() 10 | } 11 | 12 | pub fn llvm_create_message(message string) string { 13 | return tos2(C.LLVMCreateMessage(message.str)) 14 | } 15 | 16 | pub fn llvm_dispose_message(message string) { 17 | C.LLVMDisposeMessage(message.str) 18 | } -------------------------------------------------------------------------------- /bindings/flags.v: -------------------------------------------------------------------------------- 1 | module bindings 2 | 3 | // todo: pkg-config? 4 | #flag `llvm-config-10 --cflags` `llvm-config-10 --ldflags` `llvm-config-10 --libs` 5 | 6 | #include -------------------------------------------------------------------------------- /v.mod: -------------------------------------------------------------------------------- 1 | Module { 2 | name: 'vllvm' 3 | version: '0.1.0' 4 | deps: [] 5 | } -------------------------------------------------------------------------------- /vllvm.v: -------------------------------------------------------------------------------- 1 | module vllvm 2 | 3 | import bindings 4 | 5 | pub const ( 6 | version = '0.1.0' 7 | ) --------------------------------------------------------------------------------