├── CREDITS.TXT ├── LICENSE.TXT ├── README.md ├── after ├── ftplugin │ └── llvm.vim └── syntax │ └── llvm.vim ├── ftdetect ├── llvm-lit.vim ├── llvm.vim ├── mir.vim ├── mlir.vim └── tablegen.vim ├── ftplugin ├── llvm.vim ├── mir.vim ├── mlir.vim └── tablegen.vim ├── indent ├── llvm.vim └── mlir.vim ├── scripts.vim └── syntax ├── llvm.vim ├── machine-ir.vim ├── mir.vim ├── mlir.vim └── tablegen.vim /CREDITS.TXT: -------------------------------------------------------------------------------- 1 | This file is a partial list of people who have contributed to the LLVM 2 | project. If you have contributed a patch or made some other contribution to 3 | LLVM, please submit a patch to this file to add yourself, and it will be 4 | done! 5 | 6 | The list is sorted by surname and formatted to allow easy grepping and 7 | beautification by scripts. The fields are: name (N), email (E), web-address 8 | (W), PGP key ID and fingerprint (P), description (D), snail-mail address 9 | (S), and (I) IRC handle. 10 | 11 | N: Vikram Adve 12 | E: vadve@cs.uiuc.edu 13 | W: http://www.cs.uiuc.edu/~vadve/ 14 | D: The Sparc64 backend, provider of much wisdom, and motivator for LLVM 15 | 16 | N: Owen Anderson 17 | E: resistor@mac.com 18 | D: LCSSA pass and related LoopUnswitch work 19 | D: GVNPRE pass, DataLayout refactoring, random improvements 20 | 21 | N: Henrik Bach 22 | D: MingW Win32 API portability layer 23 | 24 | N: Aaron Ballman 25 | E: aaron@aaronballman.com 26 | D: Clang frontend, frontend attributes, Windows support, general bug fixing 27 | I: AaronBallman 28 | 29 | N: Nate Begeman 30 | E: natebegeman@mac.com 31 | D: PowerPC backend developer 32 | D: Target-independent code generator and analysis improvements 33 | 34 | N: Daniel Berlin 35 | E: dberlin@dberlin.org 36 | D: ET-Forest implementation. 37 | D: Sparse bitmap 38 | 39 | N: Geoff Berry 40 | E: gberry@codeaurora.org 41 | E: gcb@acm.org 42 | D: AArch64 backend improvements 43 | D: Added EarlyCSE MemorySSA support 44 | D: CodeGen improvements 45 | 46 | N: David Blaikie 47 | E: dblaikie@gmail.com 48 | D: General bug fixing/fit & finish, mostly in Clang 49 | 50 | N: Neil Booth 51 | E: neil@daikokuya.co.uk 52 | D: APFloat implementation. 53 | 54 | N: Alex Bradbury 55 | E: asb@lowrisc.org 56 | D: RISC-V backend 57 | 58 | N: Misha Brukman 59 | E: brukman+llvm@uiuc.edu 60 | W: http://misha.brukman.net 61 | D: Portions of X86 and Sparc JIT compilers, PowerPC backend 62 | D: Incremental bitcode loader 63 | 64 | N: Cameron Buschardt 65 | E: buschard@uiuc.edu 66 | D: The `mem2reg' pass - promotes values stored in memory to registers 67 | 68 | N: Brendon Cahoon 69 | E: bcahoon@codeaurora.org 70 | D: Loop unrolling with run-time trip counts. 71 | 72 | N: Chandler Carruth 73 | E: chandlerc@gmail.com 74 | E: chandlerc@google.com 75 | D: Hashing algorithms and interfaces 76 | D: Inline cost analysis 77 | D: Machine block placement pass 78 | D: SROA 79 | 80 | N: Casey Carter 81 | E: ccarter@uiuc.edu 82 | D: Fixes to the Reassociation pass, various improvement patches 83 | 84 | N: Evan Cheng 85 | E: evan.cheng@apple.com 86 | D: ARM and X86 backends 87 | D: Instruction scheduler improvements 88 | D: Register allocator improvements 89 | D: Loop optimizer improvements 90 | D: Target-independent code generator improvements 91 | 92 | N: Dan Villiom Podlaski Christiansen 93 | E: danchr@gmail.com 94 | E: danchr@cs.au.dk 95 | W: http://villiom.dk 96 | D: LLVM Makefile improvements 97 | D: Clang diagnostic & driver tweaks 98 | S: Aarhus, Denmark 99 | 100 | N: Jeff Cohen 101 | E: jeffc@jolt-lang.org 102 | W: http://jolt-lang.org 103 | D: Native Win32 API portability layer 104 | 105 | N: John T. Criswell 106 | E: criswell@uiuc.edu 107 | D: Original Autoconf support, documentation improvements, bug fixes 108 | 109 | N: Anshuman Dasgupta 110 | E: adasgupt@codeaurora.org 111 | D: Deterministic finite automaton based infrastructure for VLIW packetization 112 | 113 | N: Stefanus Du Toit 114 | E: stefanus.du.toit@intel.com 115 | D: Bug fixes and minor improvements 116 | 117 | N: Rafael Avila de Espindola 118 | E: rafael@espindo.la 119 | D: MC and LLD work 120 | 121 | N: Dave Estes 122 | E: cestes@codeaurora.org 123 | D: AArch64 machine description for Cortex-A53 124 | 125 | N: Alkis Evlogimenos 126 | E: alkis@evlogimenos.com 127 | D: Linear scan register allocator, many codegen improvements, Java frontend 128 | 129 | N: Hal Finkel 130 | E: hfinkel@anl.gov 131 | D: Basic-block autovectorization, PowerPC backend improvements 132 | 133 | N: Eric Fiselier 134 | E: eric@efcs.ca 135 | D: LIT patches and documentation 136 | 137 | N: Ryan Flynn 138 | E: pizza@parseerror.com 139 | D: Miscellaneous bug fixes 140 | 141 | N: Brian Gaeke 142 | E: gaeke@uiuc.edu 143 | W: http://www.students.uiuc.edu/~gaeke/ 144 | D: Portions of X86 static and JIT compilers; initial SparcV8 backend 145 | D: Dynamic trace optimizer 146 | D: FreeBSD/X86 compatibility fixes, the llvm-nm tool 147 | 148 | N: Nicolas Geoffray 149 | E: nicolas.geoffray@lip6.fr 150 | W: http://www-src.lip6.fr/homepages/Nicolas.Geoffray/ 151 | D: PPC backend fixes for Linux 152 | 153 | N: Louis Gerbarg 154 | E: lgg@apple.com 155 | D: Portions of the PowerPC backend 156 | 157 | N: Saem Ghani 158 | E: saemghani@gmail.com 159 | D: Callgraph class cleanups 160 | 161 | N: Mikhail Glushenkov 162 | E: foldr@codedgers.com 163 | D: Author of llvmc2 164 | 165 | N: Dan Gohman 166 | E: sunfish@mozilla.com 167 | D: Miscellaneous bug fixes 168 | D: WebAssembly Backend 169 | 170 | N: Renato Golin 171 | E: rengolin@systemcall.eu 172 | E: renato.golin@linaro.org 173 | E: rengolin@gmail.com 174 | D: ARM/AArch64 back-end improvements 175 | D: Loop Vectorizer improvements 176 | D: Regression and Test Suite improvements 177 | D: Linux compatibility (GNU, musl, etc) 178 | D: Initial Linux kernel / Android support effort 179 | I: rengolin 180 | 181 | N: David Goodwin 182 | E: david@goodwinz.net 183 | D: Thumb-2 code generator 184 | 185 | N: David Greene 186 | E: greened@obbligato.org 187 | D: Miscellaneous bug fixes 188 | D: Register allocation refactoring 189 | 190 | N: Gabor Greif 191 | E: ggreif@gmail.com 192 | D: Improvements for space efficiency 193 | 194 | N: James Grosbach 195 | E: grosbach@apple.com 196 | I: grosbach 197 | D: SjLj exception handling support 198 | D: General fixes and improvements for the ARM back-end 199 | D: MCJIT 200 | D: ARM integrated assembler and assembly parser 201 | D: Led effort for the backend formerly known as ARM64 202 | 203 | N: Lang Hames 204 | E: lhames@gmail.com 205 | D: PBQP-based register allocator 206 | 207 | N: Gordon Henriksen 208 | E: gordonhenriksen@mac.com 209 | D: Pluggable GC support 210 | D: C interface 211 | D: Ocaml bindings 212 | 213 | N: Raul Fernandes Herbster 214 | E: raul@dsc.ufcg.edu.br 215 | D: JIT support for ARM 216 | 217 | N: Paolo Invernizzi 218 | E: arathorn@fastwebnet.it 219 | D: Visual C++ compatibility fixes 220 | 221 | N: Patrick Jenkins 222 | E: patjenk@wam.umd.edu 223 | D: Nightly Tester 224 | 225 | N: Tony(Yanjun) Jiang 226 | E: jtony@ca.ibm.com 227 | D: PowerPC Backend Developer 228 | D: Improvements to the PPC backend and miscellaneous bug fixes 229 | 230 | N: Dale Johannesen 231 | E: dalej@apple.com 232 | D: ARM constant islands improvements 233 | D: Tail merging improvements 234 | D: Rewrite X87 back end 235 | D: Use APFloat for floating point constants widely throughout compiler 236 | D: Implement X87 long double 237 | 238 | N: Brad Jones 239 | E: kungfoomaster@nondot.org 240 | D: Support for packed types 241 | 242 | N: Rod Kay 243 | E: rkay@auroraux.org 244 | D: Author of LLVM Ada bindings 245 | 246 | N: Erich Keane 247 | E: erich.keane@intel.com 248 | D: A variety of Clang contributions including function multiversioning, regcall/vectorcall. 249 | I: ErichKeane 250 | 251 | N: Eric Kidd 252 | W: http://randomhacks.net/ 253 | D: llvm-config script 254 | 255 | N: Anton Korobeynikov 256 | E: anton at korobeynikov dot info 257 | D: Mingw32 fixes, cross-compiling support, stdcall/fastcall calling conv. 258 | D: x86/linux PIC codegen, aliases, regparm/visibility attributes 259 | D: Switch lowering refactoring 260 | 261 | N: Sumant Kowshik 262 | E: kowshik@uiuc.edu 263 | D: Author of the original C backend 264 | 265 | N: Benjamin Kramer 266 | E: benny.kra@gmail.com 267 | D: Miscellaneous bug fixes 268 | 269 | N: Sundeep Kushwaha 270 | E: sundeepk@codeaurora.org 271 | D: Implemented DFA-based target independent VLIW packetizer 272 | 273 | N: Christopher Lamb 274 | E: christopher.lamb@gmail.com 275 | D: aligned load/store support, parts of noalias and restrict support 276 | D: vreg subreg infrastructure, X86 codegen improvements based on subregs 277 | D: address spaces 278 | 279 | N: Jim Laskey 280 | E: jlaskey@apple.com 281 | D: Improvements to the PPC backend, instruction scheduling 282 | D: Debug and Dwarf implementation 283 | D: Auto upgrade mangler 284 | D: llvm-gcc4 svn wrangler 285 | 286 | N: Chris Lattner 287 | E: sabre@nondot.org 288 | W: http://nondot.org/~sabre/ 289 | D: Primary architect of LLVM 290 | 291 | N: Tanya Lattner (Tanya Brethour) 292 | E: tonic@nondot.org 293 | W: http://nondot.org/~tonic/ 294 | D: The initial llvm-ar tool, converted regression testsuite to dejagnu 295 | D: Modulo scheduling in the SparcV9 backend 296 | D: Release manager (1.7+) 297 | 298 | N: Sylvestre Ledru 299 | E: sylvestre@debian.org 300 | W: http://sylvestre.ledru.info/ 301 | W: https://apt.llvm.org/ 302 | D: Debian and Ubuntu packaging 303 | D: Continuous integration with jenkins 304 | 305 | N: Andrew Lenharth 306 | E: alenhar2@cs.uiuc.edu 307 | W: http://www.lenharth.org/~andrewl/ 308 | D: Alpha backend 309 | D: Sampling based profiling 310 | 311 | N: Nick Lewycky 312 | E: nicholas@mxc.ca 313 | D: PredicateSimplifier pass 314 | 315 | N: Tony Linthicum, et. al. 316 | E: tlinth@codeaurora.org 317 | D: Backend for Qualcomm's Hexagon VLIW processor. 318 | 319 | N: Bruno Cardoso Lopes 320 | E: bruno.cardoso@gmail.com 321 | I: bruno 322 | W: http://brunocardoso.cc 323 | D: Mips backend 324 | D: Random ARM integrated assembler and assembly parser improvements 325 | D: General X86 AVX1 support 326 | 327 | N: Duraid Madina 328 | E: duraid@octopus.com.au 329 | W: http://kinoko.c.u-tokyo.ac.jp/~duraid/ 330 | D: IA64 backend, BigBlock register allocator 331 | 332 | N: John McCall 333 | E: rjmccall@apple.com 334 | D: Clang semantic analysis and IR generation 335 | 336 | N: Michael McCracken 337 | E: michael.mccracken@gmail.com 338 | D: Line number support for llvmgcc 339 | 340 | N: Vladimir Merzliakov 341 | E: wanderer@rsu.ru 342 | D: Test suite fixes for FreeBSD 343 | 344 | N: Scott Michel 345 | E: scottm@aero.org 346 | D: Added STI Cell SPU backend. 347 | 348 | N: Kai Nacke 349 | E: kai@redstar.de 350 | D: Support for implicit TLS model used with MS VC runtime 351 | D: Dumping of Win64 EH structures 352 | 353 | N: Takumi Nakamura 354 | I: chapuni 355 | E: geek4civic@gmail.com 356 | E: chapuni@hf.rim.or.jp 357 | D: Maintaining the Git monorepo 358 | W: https://github.com/llvm-project/ 359 | S: Ebina, Japan 360 | 361 | N: Edward O'Callaghan 362 | E: eocallaghan@auroraux.org 363 | W: http://www.auroraux.org 364 | D: Add Clang support with various other improvements to utils/NewNightlyTest.pl 365 | D: Fix and maintain Solaris & AuroraUX support for llvm, various build warnings 366 | D: and error clean ups. 367 | 368 | N: Morten Ofstad 369 | E: morten@hue.no 370 | D: Visual C++ compatibility fixes 371 | 372 | N: Jakob Stoklund Olesen 373 | E: stoklund@2pi.dk 374 | D: Machine code verifier 375 | D: Blackfin backend 376 | D: Fast register allocator 377 | D: Greedy register allocator 378 | 379 | N: Richard Osborne 380 | E: richard@xmos.com 381 | D: XCore backend 382 | 383 | N: Piotr Padlewski 384 | E: piotr.padlewski@gmail.com 385 | D: !invariant.group metadata and other intrinsics for devirtualization in clang 386 | 387 | N: Devang Patel 388 | E: dpatel@apple.com 389 | D: LTO tool, PassManager rewrite, Loop Pass Manager, Loop Rotate 390 | D: GCC PCH Integration (llvm-gcc), llvm-gcc improvements 391 | D: Optimizer improvements, Loop Index Split 392 | 393 | N: Ana Pazos 394 | E: apazos@codeaurora.org 395 | D: Fixes and improvements to the AArch64 backend 396 | 397 | N: Wesley Peck 398 | E: peckw@wesleypeck.com 399 | W: http://wesleypeck.com/ 400 | D: MicroBlaze backend 401 | 402 | N: Francois Pichet 403 | E: pichet2000@gmail.com 404 | D: MSVC support 405 | 406 | N: Adrian Prantl 407 | E: aprantl@apple.com 408 | D: Debug Information 409 | 410 | N: Vladimir Prus 411 | W: http://vladimir_prus.blogspot.com 412 | E: ghost@cs.msu.su 413 | D: Made inst_iterator behave like a proper iterator, LowerConstantExprs pass 414 | 415 | N: QIU Chaofan 416 | E: qiucofan@cn.ibm.com 417 | D: PowerPC Backend Developer 418 | 419 | N: Kalle Raiskila 420 | E: kalle.rasikila@nokia.com 421 | D: Some bugfixes to CellSPU 422 | 423 | N: Xerxes Ranby 424 | E: xerxes@zafena.se 425 | D: Cmake dependency chain and various bug fixes 426 | 427 | N: Alex Rosenberg 428 | E: alexr@leftfield.org 429 | I: arosenberg 430 | D: ARM calling conventions rewrite, hard float support 431 | 432 | N: Chad Rosier 433 | E: mcrosier@codeaurora.org 434 | I: mcrosier 435 | D: AArch64 fast instruction selection pass 436 | D: Fixes and improvements to the ARM fast-isel pass 437 | D: Fixes and improvements to the AArch64 backend 438 | 439 | N: Nadav Rotem 440 | E: nadav.rotem@me.com 441 | D: X86 code generation improvements, Loop Vectorizer, SLP Vectorizer 442 | 443 | N: Roman Samoilov 444 | E: roman@codedgers.com 445 | D: MSIL backend 446 | 447 | N: Duncan Sands 448 | E: baldrick@free.fr 449 | I: baldrick 450 | D: Ada support in llvm-gcc 451 | D: Dragonegg plugin 452 | D: Exception handling improvements 453 | D: Type legalizer rewrite 454 | 455 | N: Ruchira Sasanka 456 | E: sasanka@uiuc.edu 457 | D: Graph coloring register allocator for the Sparc64 backend 458 | 459 | N: Arnold Schwaighofer 460 | E: arnold.schwaighofer@gmail.com 461 | D: Tail call optimization for the x86 backend 462 | 463 | N: Shantonu Sen 464 | E: ssen@apple.com 465 | D: Miscellaneous bug fixes 466 | 467 | N: Anand Shukla 468 | E: ashukla@cs.uiuc.edu 469 | D: The `paths' pass 470 | 471 | N: Michael J. Spencer 472 | E: bigcheesegs@gmail.com 473 | D: Shepherding Windows COFF support into MC. 474 | D: Lots of Windows stuff. 475 | 476 | N: Reid Spencer 477 | E: rspencer@reidspencer.com 478 | W: http://reidspencer.com/ 479 | D: Lots of stuff, see: http://wiki.llvm.org/index.php/User:Reid 480 | 481 | N: Alp Toker 482 | E: alp@nuanti.com 483 | W: http://atoker.com/ 484 | D: C++ frontend next generation standards implementation 485 | 486 | N: Craig Topper 487 | E: craig.topper@gmail.com 488 | D: X86 codegen and disassembler improvements. AVX2 support. 489 | 490 | N: Edwin Torok 491 | E: edwintorok@gmail.com 492 | D: Miscellaneous bug fixes 493 | 494 | N: Adam Treat 495 | E: manyoso@yahoo.com 496 | D: C++ bugs filed, and C++ front-end bug fixes. 497 | 498 | N: Andrew Trick 499 | E: atrick@apple.com 500 | D: Instruction Scheduling, ... 501 | 502 | N: Lauro Ramos Venancio 503 | E: lauro.venancio@indt.org.br 504 | D: ARM backend improvements 505 | D: Thread Local Storage implementation 506 | 507 | N: Bill Wendling 508 | I: wendling 509 | E: isanbard@gmail.com 510 | D: Release manager, IR Linker, LTO. 511 | D: Bunches of stuff. 512 | 513 | N: Bob Wilson 514 | E: bob.wilson@acm.org 515 | D: Advanced SIMD (NEON) support in the ARM backend. 516 | 517 | N: QingShan Zhang 518 | E: qshanz@cn.ibm.com 519 | D: PowerPC Backend Developer 520 | 521 | N: Li Jia He 522 | E: hljhehlj@cn.ibm.com 523 | D: PowerPC Backend Developer 524 | 525 | N: Zixuan Wu 526 | E: wuzish@cn.ibm.com 527 | D: PowerPC Backend Developer 528 | 529 | N: Kang Zhang 530 | E: shkzhang@cn.ibm.com 531 | D: PowerPC Backend Developer 532 | 533 | N: Zheng Chen 534 | E: czhengsz@cn.ibm.com 535 | D: PowerPC Backend Developer 536 | 537 | N: Djordje Todorovic 538 | E: djordje.todorovic@rt-rk.com 539 | D: Debug Information 540 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | ============================================================================== 2 | The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: 3 | ============================================================================== 4 | 5 | Apache License 6 | Version 2.0, January 2004 7 | http://www.apache.org/licenses/ 8 | 9 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 10 | 11 | 1. Definitions. 12 | 13 | "License" shall mean the terms and conditions for use, reproduction, 14 | and distribution as defined by Sections 1 through 9 of this document. 15 | 16 | "Licensor" shall mean the copyright owner or entity authorized by 17 | the copyright owner that is granting the License. 18 | 19 | "Legal Entity" shall mean the union of the acting entity and all 20 | other entities that control, are controlled by, or are under common 21 | control with that entity. For the purposes of this definition, 22 | "control" means (i) the power, direct or indirect, to cause the 23 | direction or management of such entity, whether by contract or 24 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 25 | outstanding shares, or (iii) beneficial ownership of such entity. 26 | 27 | "You" (or "Your") shall mean an individual or Legal Entity 28 | exercising permissions granted by this License. 29 | 30 | "Source" form shall mean the preferred form for making modifications, 31 | including but not limited to software source code, documentation 32 | source, and configuration files. 33 | 34 | "Object" form shall mean any form resulting from mechanical 35 | transformation or translation of a Source form, including but 36 | not limited to compiled object code, generated documentation, 37 | and conversions to other media types. 38 | 39 | "Work" shall mean the work of authorship, whether in Source or 40 | Object form, made available under the License, as indicated by a 41 | copyright notice that is included in or attached to the work 42 | (an example is provided in the Appendix below). 43 | 44 | "Derivative Works" shall mean any work, whether in Source or Object 45 | form, that is based on (or derived from) the Work and for which the 46 | editorial revisions, annotations, elaborations, or other modifications 47 | represent, as a whole, an original work of authorship. For the purposes 48 | of this License, Derivative Works shall not include works that remain 49 | separable from, or merely link (or bind by name) to the interfaces of, 50 | the Work and Derivative Works thereof. 51 | 52 | "Contribution" shall mean any work of authorship, including 53 | the original version of the Work and any modifications or additions 54 | to that Work or Derivative Works thereof, that is intentionally 55 | submitted to Licensor for inclusion in the Work by the copyright owner 56 | or by an individual or Legal Entity authorized to submit on behalf of 57 | the copyright owner. For the purposes of this definition, "submitted" 58 | means any form of electronic, verbal, or written communication sent 59 | to the Licensor or its representatives, including but not limited to 60 | communication on electronic mailing lists, source code control systems, 61 | and issue tracking systems that are managed by, or on behalf of, the 62 | Licensor for the purpose of discussing and improving the Work, but 63 | excluding communication that is conspicuously marked or otherwise 64 | designated in writing by the copyright owner as "Not a Contribution." 65 | 66 | "Contributor" shall mean Licensor and any individual or Legal Entity 67 | on behalf of whom a Contribution has been received by Licensor and 68 | subsequently incorporated within the Work. 69 | 70 | 2. Grant of Copyright License. Subject to the terms and conditions of 71 | this License, each Contributor hereby grants to You a perpetual, 72 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 73 | copyright license to reproduce, prepare Derivative Works of, 74 | publicly display, publicly perform, sublicense, and distribute the 75 | Work and such Derivative Works in Source or Object form. 76 | 77 | 3. Grant of Patent License. Subject to the terms and conditions of 78 | this License, each Contributor hereby grants to You a perpetual, 79 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 80 | (except as stated in this section) patent license to make, have made, 81 | use, offer to sell, sell, import, and otherwise transfer the Work, 82 | where such license applies only to those patent claims licensable 83 | by such Contributor that are necessarily infringed by their 84 | Contribution(s) alone or by combination of their Contribution(s) 85 | with the Work to which such Contribution(s) was submitted. If You 86 | institute patent litigation against any entity (including a 87 | cross-claim or counterclaim in a lawsuit) alleging that the Work 88 | or a Contribution incorporated within the Work constitutes direct 89 | or contributory patent infringement, then any patent licenses 90 | granted to You under this License for that Work shall terminate 91 | as of the date such litigation is filed. 92 | 93 | 4. Redistribution. You may reproduce and distribute copies of the 94 | Work or Derivative Works thereof in any medium, with or without 95 | modifications, and in Source or Object form, provided that You 96 | meet the following conditions: 97 | 98 | (a) You must give any other recipients of the Work or 99 | Derivative Works a copy of this License; and 100 | 101 | (b) You must cause any modified files to carry prominent notices 102 | stating that You changed the files; and 103 | 104 | (c) You must retain, in the Source form of any Derivative Works 105 | that You distribute, all copyright, patent, trademark, and 106 | attribution notices from the Source form of the Work, 107 | excluding those notices that do not pertain to any part of 108 | the Derivative Works; and 109 | 110 | (d) If the Work includes a "NOTICE" text file as part of its 111 | distribution, then any Derivative Works that You distribute must 112 | include a readable copy of the attribution notices contained 113 | within such NOTICE file, excluding those notices that do not 114 | pertain to any part of the Derivative Works, in at least one 115 | of the following places: within a NOTICE text file distributed 116 | as part of the Derivative Works; within the Source form or 117 | documentation, if provided along with the Derivative Works; or, 118 | within a display generated by the Derivative Works, if and 119 | wherever such third-party notices normally appear. The contents 120 | of the NOTICE file are for informational purposes only and 121 | do not modify the License. You may add Your own attribution 122 | notices within Derivative Works that You distribute, alongside 123 | or as an addendum to the NOTICE text from the Work, provided 124 | that such additional attribution notices cannot be construed 125 | as modifying the License. 126 | 127 | You may add Your own copyright statement to Your modifications and 128 | may provide additional or different license terms and conditions 129 | for use, reproduction, or distribution of Your modifications, or 130 | for any such Derivative Works as a whole, provided Your use, 131 | reproduction, and distribution of the Work otherwise complies with 132 | the conditions stated in this License. 133 | 134 | 5. Submission of Contributions. Unless You explicitly state otherwise, 135 | any Contribution intentionally submitted for inclusion in the Work 136 | by You to the Licensor shall be under the terms and conditions of 137 | this License, without any additional terms or conditions. 138 | Notwithstanding the above, nothing herein shall supersede or modify 139 | the terms of any separate license agreement you may have executed 140 | with Licensor regarding such Contributions. 141 | 142 | 6. Trademarks. This License does not grant permission to use the trade 143 | names, trademarks, service marks, or product names of the Licensor, 144 | except as required for reasonable and customary use in describing the 145 | origin of the Work and reproducing the content of the NOTICE file. 146 | 147 | 7. Disclaimer of Warranty. Unless required by applicable law or 148 | agreed to in writing, Licensor provides the Work (and each 149 | Contributor provides its Contributions) on an "AS IS" BASIS, 150 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 151 | implied, including, without limitation, any warranties or conditions 152 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 153 | PARTICULAR PURPOSE. You are solely responsible for determining the 154 | appropriateness of using or redistributing the Work and assume any 155 | risks associated with Your exercise of permissions under this License. 156 | 157 | 8. Limitation of Liability. In no event and under no legal theory, 158 | whether in tort (including negligence), contract, or otherwise, 159 | unless required by applicable law (such as deliberate and grossly 160 | negligent acts) or agreed to in writing, shall any Contributor be 161 | liable to You for damages, including any direct, indirect, special, 162 | incidental, or consequential damages of any character arising as a 163 | result of this License or out of the use or inability to use the 164 | Work (including but not limited to damages for loss of goodwill, 165 | work stoppage, computer failure or malfunction, or any and all 166 | other commercial damages or losses), even if such Contributor 167 | has been advised of the possibility of such damages. 168 | 169 | 9. Accepting Warranty or Additional Liability. While redistributing 170 | the Work or Derivative Works thereof, You may choose to offer, 171 | and charge a fee for, acceptance of support, warranty, indemnity, 172 | or other liability obligations and/or rights consistent with this 173 | License. However, in accepting such obligations, You may act only 174 | on Your own behalf and on Your sole responsibility, not on behalf 175 | of any other Contributor, and only if You agree to indemnify, 176 | defend, and hold each Contributor harmless for any liability 177 | incurred by, or claims asserted against, such Contributor by reason 178 | of your accepting any such warranty or additional liability. 179 | 180 | END OF TERMS AND CONDITIONS 181 | 182 | APPENDIX: How to apply the Apache License to your work. 183 | 184 | To apply the Apache License to your work, attach the following 185 | boilerplate notice, with the fields enclosed by brackets "[]" 186 | replaced with your own identifying information. (Don't include 187 | the brackets!) The text should be enclosed in the appropriate 188 | comment syntax for the file format. We also recommend that a 189 | file or class name and description of purpose be included on the 190 | same "printed page" as the copyright notice for easier 191 | identification within third-party archives. 192 | 193 | Copyright [yyyy] [name of copyright owner] 194 | 195 | Licensed under the Apache License, Version 2.0 (the "License"); 196 | you may not use this file except in compliance with the License. 197 | You may obtain a copy of the License at 198 | 199 | http://www.apache.org/licenses/LICENSE-2.0 200 | 201 | Unless required by applicable law or agreed to in writing, software 202 | distributed under the License is distributed on an "AS IS" BASIS, 203 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 204 | See the License for the specific language governing permissions and 205 | limitations under the License. 206 | 207 | 208 | ---- LLVM Exceptions to the Apache 2.0 License ---- 209 | 210 | As an exception, if, as a result of your compiling your source code, portions 211 | of this Software are embedded into an Object form of such source code, you 212 | may redistribute such embedded portions in such Object form without complying 213 | with the conditions of Sections 4(a), 4(b) and 4(d) of the License. 214 | 215 | In addition, if you combine or link compiled forms of this Software with 216 | software that is licensed under the GPLv2 ("Combined Software") and if a 217 | court of competent jurisdiction determines that the patent provision (Section 218 | 3), the indemnity provision (Section 9) or other Section of the License 219 | conflicts with the conditions of the GPLv2, you may retroactively and 220 | prospectively choose to deem waived or otherwise exclude such Section(s) of 221 | the License, but only in their entirety and only with respect to the Combined 222 | Software. 223 | 224 | ============================================================================== 225 | Software from third parties included in the LLVM Project: 226 | ============================================================================== 227 | The LLVM Project contains third party software which is under different license 228 | terms. All such code will be identified clearly using at least one of two 229 | mechanisms: 230 | 1) It will be in a separate directory tree with its own `LICENSE.txt` or 231 | `LICENSE` file at the top containing the specific license and restrictions 232 | which apply to that software, or 233 | 2) It will contain specific license and restriction terms at the top of every 234 | file. 235 | 236 | ============================================================================== 237 | Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): 238 | ============================================================================== 239 | University of Illinois/NCSA 240 | Open Source License 241 | 242 | Copyright (c) 2003-2019 University of Illinois at Urbana-Champaign. 243 | All rights reserved. 244 | 245 | Developed by: 246 | 247 | LLVM Team 248 | 249 | University of Illinois at Urbana-Champaign 250 | 251 | http://llvm.org 252 | 253 | Permission is hereby granted, free of charge, to any person obtaining a copy of 254 | this software and associated documentation files (the "Software"), to deal with 255 | the Software without restriction, including without limitation the rights to 256 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 257 | of the Software, and to permit persons to whom the Software is furnished to do 258 | so, subject to the following conditions: 259 | 260 | * Redistributions of source code must retain the above copyright notice, 261 | this list of conditions and the following disclaimers. 262 | 263 | * Redistributions in binary form must reproduce the above copyright notice, 264 | this list of conditions and the following disclaimers in the 265 | documentation and/or other materials provided with the distribution. 266 | 267 | * Neither the names of the LLVM Team, University of Illinois at 268 | Urbana-Champaign, nor the names of its contributors may be used to 269 | endorse or promote products derived from this Software without specific 270 | prior written permission. 271 | 272 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 273 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 274 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 275 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 276 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 277 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 278 | SOFTWARE. 279 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Vim files for Low Level Virtual Machine (LLVM) 2 | ============================================== 3 | 4 | This repository and its subdirectories contain source code for Vim files for the Low Level Virtual 5 | Machine (LLVM), a toolkit for the construction of highly optimized compilers, optimizers, and runtime 6 | environments. LLVM is open source software. You may freely distribute it under the terms of the license 7 | agreement found in LICENSE.txt. 8 | 9 | This repository aims to make Vim plugin package managers deal with a Vim plugin bundled in the LLVM 10 | official repository and provides some extended features. 11 | 12 | If no license is specified in the header of a file (it means that it came from 13 | [LLVM official repository][llvm]), the file is distributed under [LLVM's LICENSE](LICENSE.TXT). 14 | 15 | ## Imported from upstream ([LLVM official repository][llvm]) 16 | 17 | Following files are imported from `llvm/utils/vim` and `mlir/utils/vim`. They are updated at LLVM 18 | version bump. 19 | 20 | - `ftdetect/*.vim` 21 | - `ftplugin/*.vim` 22 | - `indent/*.vim` 23 | - `syntax/*.vim` 24 | 25 | Imported from LLVM 19.1.0 (`a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4`) 26 | 27 | ## Extended features 28 | 29 | This repository provides some advanced features which are not supported in LLVM official repository. 30 | 31 | - `after/**/*.vim`: Extended filetype support 32 | - `scripts.vim`: Improved `llvm` filetype detection 33 | 34 | If you want to disable these features, write the following config in your `vimrc`: 35 | 36 | ```vim 37 | let g:llvm_extends_official = 0 38 | ``` 39 | 40 | ### Mappings 41 | 42 | Some useful mappings to jump a cursor are provided. 43 | 44 | - `K`: Jump to the definition of an identifier under the cursor. Or if an instruction (like `getelementptr`) 45 | is under the cursor, the explanation of the instruction will be opened in a browser. 46 | - `]]`, `][`: Move the cursor to the next basic block (Please see `:help ]]` for more details). 47 | - `b]`: Jump to a basic block which follows the current basic block. 48 | - `b[`: Jump to a basic block which the current basic block is following. 49 | 50 | More mappings might be supported in the future. 51 | 52 | When `g:llvm_ext_no_mapping` is set to `1`, these mappings won't be defined. Instead, please map `` 53 | mappings to your favorite key sequences. 54 | 55 | ```vim 56 | " e.g. Map 'go to definition' to gd 57 | autocmd FileType llvm nmap gd (llvm-goto-definition) 58 | ``` 59 | 60 | ### Commands 61 | 62 | Some useful commands are defined in `llvm` filetype buffers. 63 | 64 | #### `:LLI [file]` 65 | 66 | Runs the given `file` using `lli` command. If `file` is omitted, it runs current buffer instead. 67 | This command uses Neovim/Vim8 terminal feature. The LLVM IR code is run in job asynchronously and 68 | the result is output in a temporary terminal buffer. 69 | 70 | The default command to run is `lli`. You can change it by setting `g:llvm_ext_lli_executable`. 71 | 72 | ## Installation 73 | 74 | Three options. First one or second one are recommended. 75 | 76 | - Use your favorite plugin manager such as [vim-plug][], [dein.vim][], [minpac][] 77 | - Use `:packadd` (Please see `:help packadd` for more details) 78 | - Manually copy all directories and `scripts.vim` in this repository to your `~/.vim` (or `~/vimfiles` on Windows) 79 | 80 | [llvm]: https://github.com/llvm/llvm-project 81 | [vim-plug]: https://github.com/junegunn/vim-plug 82 | [dein.vim]: https://github.com/Shougo/dein.vim 83 | [minpac]: https://github.com/k-takata/minpac 84 | -------------------------------------------------------------------------------- /after/ftplugin/llvm.vim: -------------------------------------------------------------------------------- 1 | " Copyright (c) 2018 rhysd 2 | " 3 | " Permission is hereby granted, free of charge, to any person obtaining a copy 4 | " of this software and associated documentation files (the "Software"), to deal 5 | " in the Software without restriction, including without limitation the rights 6 | " to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | " copies of the Software, and to permit persons to whom the Software is 8 | " furnished to do so, subject to the following conditions: 9 | " 10 | " The above copyright notice and this permission notice shall be included in 11 | " all copies or substantial portions of the Software. 12 | " 13 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | " OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | " THE SOFTWARE. 20 | 21 | if get(g:, 'llvm_extends_official', 1) == 0 22 | finish 23 | endif 24 | 25 | let g:llvm_ext_no_mapping = get(g:, 'llvm_ext_no_mapping', 0) 26 | let g:llvm_ext_lli_executable = get(g:, 'llvm_ext_lli_executable', 'lli') 27 | 28 | let s:KIND_BLOCK_PREC = 0 29 | let s:KIND_BLOCK_FOLLOW = 1 30 | let s:KIND_FUNC_BEGIN = 2 31 | let s:KIND_FUNC_END = 3 32 | 33 | function! s:section_delim_at(lnum) abort 34 | let line = getline(a:lnum) 35 | let m = matchlist(line, '^\([^:]\+\):\%( \+; preds = \(%.\+\)\)\=$') 36 | if !empty(m) 37 | if m[2] ==# '' 38 | return [s:KIND_BLOCK_PREC, m[1]] 39 | else 40 | return [s:KIND_BLOCK_FOLLOW, m[1], split(m[2], ',\s*')] 41 | endif 42 | endif 43 | if line =~# '^}$' 44 | return [s:KIND_FUNC_END] 45 | endif 46 | if line =~# '^define\>' 47 | return [s:KIND_FUNC_BEGIN] 48 | endif 49 | return [] 50 | endfunction 51 | 52 | function! s:is_section_delim(line, func_delim) abort 53 | let sec = s:section_delim_at(a:line) 54 | if empty(sec) 55 | return 0 56 | endif 57 | let kind = sec[0] 58 | return kind == s:KIND_BLOCK_PREC || kind == s:KIND_BLOCK_FOLLOW || kind == a:func_delim 59 | endfunction 60 | 61 | function! s:next_section(stop_func_begin) abort 62 | let func_delim = a:stop_func_begin ? s:KIND_FUNC_BEGIN : s:KIND_FUNC_END 63 | let last = line('$') - 1 64 | let line = line('.') 65 | while line < last 66 | let line += 1 67 | if s:is_section_delim(line, func_delim) 68 | call cursor(line, col('.')) 69 | return 70 | endif 71 | endwhile 72 | endfunction 73 | 74 | function! s:prev_section(stop_func_begin) abort 75 | let func_delim = a:stop_func_begin ? s:KIND_FUNC_BEGIN : s:KIND_FUNC_END 76 | let line = line('.') 77 | while line > 1 78 | let line -= 1 79 | if s:is_section_delim(line, func_delim) 80 | call cursor(line, col('.')) 81 | return 82 | endif 83 | endwhile 84 | endfunction 85 | 86 | nnoremap (llvm-next-section-begin) :call next_section(1) 87 | nnoremap (llvm-prev-section-begin) :call prev_section(1) 88 | nnoremap (llvm-next-section-end) :call next_section(0) 89 | nnoremap (llvm-prev-section-end) :call prev_section(0) 90 | 91 | if !g:llvm_ext_no_mapping 92 | nmap ]] (llvm-next-section-begin) 93 | nmap [[ (llvm-prev-section-begin) 94 | nmap ][ (llvm-next-section-end) 95 | nmap [] (llvm-prev-section-end) 96 | endif 97 | 98 | function! s:function_range_at(linum) abort 99 | let line = a:linum 100 | while line >= 1 101 | let s = getline(line) 102 | if s =~# '^define\>' 103 | let start = line 104 | break 105 | elseif s =~# '^}$' 106 | return [] 107 | endif 108 | let line -= 1 109 | endwhile 110 | if line < 1 111 | return [] 112 | endif 113 | 114 | let line = a:linum 115 | let last = line('$') 116 | while line <= last 117 | let s = getline(line) 118 | if s =~# '^}$' 119 | let end = line 120 | break 121 | elseif s =~# '^define\>' 122 | return [] 123 | endif 124 | let line += 1 125 | endwhile 126 | if line > last 127 | return [] 128 | endif 129 | 130 | return [start, end] 131 | endfunction 132 | 133 | function! s:blocks_graph_at(linum) abort 134 | let func_range = s:function_range_at(a:linum) 135 | if empty(func_range) 136 | return {} 137 | endif 138 | let line = func_range[0] + 1 139 | let last = func_range[1] - 1 140 | let graph = {} 141 | while line <= last 142 | let block = s:section_delim_at(line) 143 | if empty(block) 144 | let line += 1 145 | continue 146 | endif 147 | let block_name = '%' . block[1] 148 | if block[0] == s:KIND_BLOCK_PREC 149 | let graph[block_name] = {'line': line, 'follows': [], 'preds': []} 150 | elseif block[0] == s:KIND_BLOCK_FOLLOW 151 | let graph[block_name] = {'line': line, 'follows': [], 'preds': block[2]} 152 | for follow in block[2] 153 | call add(graph[follow].follows, block_name) 154 | endfor 155 | else 156 | echoerr 'unreachable' 157 | endif 158 | let line += 1 159 | endwhile 160 | return graph 161 | endfunction 162 | 163 | function! s:find_pred_block(linum) abort 164 | let sec = s:section_delim_at(a:linum) 165 | if empty(sec) || sec[0] != s:KIND_BLOCK_PREC && sec[0] != s:KIND_BLOCK_FOLLOW 166 | throw 'No block is starting at line ' . a:linum 167 | endif 168 | if sec[0] != s:KIND_BLOCK_FOLLOW 169 | throw printf("Block '%s' has no pred block", sec[1]) 170 | endif 171 | let block_name = '%' . sec[1] 172 | let pred_block = sec[2][0] 173 | 174 | let graph = s:blocks_graph_at(a:linum) 175 | if empty(graph) 176 | throw 'No block is found in function at line ' . a:linum 177 | endif 178 | 179 | if !has_key(graph, pred_block) 180 | throw printf("Block '%s' (pred block of '%s') not found in function", pred_block, block_name) 181 | endif 182 | return graph[pred_block] 183 | endfunction 184 | 185 | function! s:move_to_pred_block() abort 186 | try 187 | let b = s:find_pred_block(line('.')) 188 | call cursor(b.line, col('.')) 189 | catch 190 | echohl ErrorMsg | echom v:exception | echohl None 191 | endtry 192 | endfunction 193 | 194 | function! s:find_following_block(linum) abort 195 | let sec = s:section_delim_at(a:linum) 196 | if empty(sec) || sec[0] != s:KIND_BLOCK_PREC && sec[0] != s:KIND_BLOCK_FOLLOW 197 | throw 'No block is starting at line ' . a:linum 198 | endif 199 | let block_name = '%' . sec[1] 200 | 201 | let graph = s:blocks_graph_at(a:linum) 202 | if empty(graph) 203 | throw 'No block is found in function at line ' . a:linum 204 | endif 205 | 206 | let follows = graph[block_name].follows 207 | if empty(follows) 208 | throw printf("Block '%s' has no following block", block_name) 209 | endif 210 | 211 | echom printf("Block '%s' has %d following blocks: %s", block_name, len(follows), join(follows, ', ')) 212 | 213 | if !has_key(graph, follows[0]) 214 | throw printf("Block '%s' is not defined in function at line %d", follows[0], a:linum) 215 | endif 216 | return graph[follows[0]] 217 | endfunction 218 | 219 | function! s:move_to_following_block() abort 220 | try 221 | let b = s:find_following_block(line('.')) 222 | call cursor(b.line, col('.')) 223 | catch 224 | echohl ErrorMsg | echom v:exception | echohl None 225 | endtry 226 | endfunction 227 | 228 | nnoremap (llvm-move-block-prev) :call move_to_pred_block() 229 | nnoremap (llvm-move-block-next) :call move_to_following_block() 230 | 231 | if !g:llvm_ext_no_mapping 232 | nmap [b (llvm-move-block-prev) 233 | nmap ]b (llvm-move-block-next) 234 | endif 235 | 236 | function! s:get_func_identifiers(line) abort 237 | let idx = stridx(a:line, '@') 238 | if idx == -1 239 | " Invalid signature 240 | return [] 241 | endif 242 | 243 | " e.g. define internal i32 @foo(...) { -> @foo(...) { 244 | let sig = a:line[idx:] 245 | 246 | let idx = stridx(sig, '(') 247 | if idx == -1 248 | " Invalid signature 249 | return [] 250 | endif 251 | 252 | " @foo(...) { -> @foo 253 | let idents = [sig[:idx-1]] 254 | 255 | " @foo(...) { -> ...) { 256 | let params = sig[idx+1:] 257 | 258 | let idx = strridx(sig, ')') 259 | if idx == -1 260 | return idents 261 | endif 262 | 263 | " ...) { -> ... 264 | let params = params[:idx-1] 265 | 266 | " Gather parameters in function signature 267 | while params !=# '' 268 | let m = matchlist(params, '^[^%]*\(%\%("[^"]\+"\|[[:alnum:]_.]\+\)\)\s*\(.*\)$') 269 | if empty(m) 270 | break 271 | endif 272 | let idents += [m[1]] 273 | let params = m[2] 274 | endwhile 275 | 276 | return idents 277 | endfunction 278 | 279 | function! s:get_identifiers(line) abort 280 | " Registers and type defs 281 | let m = matchlist(a:line, '^\s*\(%\S\+\)\s\+=') 282 | if !empty(m) 283 | return [m[1]] 284 | endif 285 | 286 | " Constants 287 | let m = matchlist(a:line, '^\(@\S\+\)\s\+=.\+\') 288 | if !empty(m) 289 | return [m[1]] 290 | endif 291 | 292 | " Labels for basic blocks 293 | let m = matchlist(a:line, '^\([^:]\+\):\%(\s\+; preds = .\+\)\=$') 294 | if !empty(m) 295 | return ['%' . m[1]] 296 | endif 297 | 298 | " Meta variables 299 | let m = matchlist(a:line, '^\(!\S\+\)\s\+=') 300 | if !empty(m) 301 | return [m[1]] 302 | endif 303 | 304 | " Attributes 305 | let m = matchlist(a:line, '^attributes\s\+\(#\d\+\)\s\+=') 306 | if !empty(m) 307 | return [m[1]] 308 | endif 309 | 310 | if a:line =~# '^\%(declare\|define\)\>' 311 | return s:get_func_identifiers(a:line) 312 | endif 313 | 314 | return [] 315 | endfunction 316 | 317 | function! s:extract_identifier(word) abort 318 | if strlen(a:word) <= 1 319 | return '' 320 | endif 321 | 322 | let prefix = a:word[0] 323 | if prefix ==# '@' || prefix ==# '%' || prefix ==# '!' 324 | if prefix ==# '!' && a:word[1] ==# '{' 325 | return '' 326 | endif 327 | 328 | if a:word[1] ==# '"' 329 | let idx = stridx(a:word, '"', 2) 330 | if idx == -1 331 | return '' 332 | endif 333 | " @"foo" or %"foo" 334 | return a:word[:idx] 335 | else 336 | " @foo or %foo 337 | return matchstr(a:word, '^[@%!][[:alnum:]_.]\+') 338 | endif 339 | endif 340 | 341 | if prefix ==# '#' 342 | return matchstr(a:word, '^#\d\+\>') 343 | endif 344 | 345 | return '' 346 | endfunction 347 | 348 | function! s:jump_to_identifier_at(linum, ident) abort 349 | let line = getline(a:linum) 350 | let column = stridx(line, a:ident) + 1 351 | if column == 0 352 | let column = col('.') 353 | endif 354 | call cursor(a:linum, column) 355 | endfunction 356 | 357 | function! s:browser_open_command() abort 358 | if exists('g:llvm_ext_browser_open_command') 359 | return g:llvm_ext_browser_open_command 360 | endif 361 | if exists('s:browser_opener') 362 | return s:browser_opener 363 | endif 364 | let s:browser_opener = '' 365 | if has('mac') 366 | let s:browser_opener = 'open' 367 | elseif has('win32') || has('win64') 368 | let s:browser_opener = 'cmd /q /c start ""' 369 | else 370 | for cmd in ['xdg-open', 'chromium', 'google-chrome', 'firefox'] 371 | if executable(cmd) 372 | let s:browser_opener = cmd 373 | break 374 | endif 375 | endfor 376 | endif 377 | return s:browser_opener 378 | endfunction 379 | 380 | function! s:open_browser(url) abort 381 | let cmd = s:browser_open_command() 382 | if cmd ==# '' 383 | throw "Failed to open a browser. I don't know how to open a browser: Please set g:llvm_ext_browser_open_command" 384 | endif 385 | let cmdline = cmd . ' ' . shellescape(a:url) 386 | let out = system(cmdline) 387 | if v:shell_error 388 | throw printf("Failed to open a browser with command '%s': %s", cmdline, out) 389 | endif 390 | endfunction 391 | 392 | function! s:goto_definition() abort 393 | " Open language reference manual under the cursor in browser 394 | let syn_name = synIDattr(synID(line('.'),col('.'),1),'name') 395 | if syn_name ==# 'llvmStatement' 396 | let word = expand('') 397 | if word !=# '' 398 | try 399 | " Open browser assuming a word under the cursor is an instruction 400 | call s:open_browser('https://llvm.org/docs/LangRef.html#' . word . '-instruction') 401 | catch /^Failed to open a browser/ 402 | echohl ErrorMsg | echom v:exception | echohl None 403 | endtry 404 | endif 405 | return 406 | endif 407 | 408 | " XXX: This does not support identifiers which contains spaces 409 | let word = expand('') 410 | if word ==# '' 411 | echom 'No identifier found under the cursor' 412 | return 413 | endif 414 | let ident = s:extract_identifier(word) 415 | if ident ==# '' 416 | echom 'No identifier found under the cursor' 417 | return 418 | endif 419 | 420 | " Definition tends to be near its usages. Look back at first. 421 | let line = line('.') 422 | while line > 0 423 | for found in s:get_identifiers(getline(line)) 424 | if ident ==# found 425 | call s:jump_to_identifier_at(line, ident) 426 | return 427 | endif 428 | endfor 429 | let line -= 1 430 | endwhile 431 | 432 | let line = line('.') + 1 433 | let last = line('$') 434 | while line <= last 435 | for found in s:get_identifiers(getline(line)) 436 | if ident ==# found 437 | call s:jump_to_identifier_at(line, ident) 438 | return 439 | endif 440 | endfor 441 | let line += 1 442 | endwhile 443 | 444 | echom "No definition for '" . ident . "' found" 445 | endfunction 446 | 447 | nnoremap (llvm-goto-definition) :call goto_definition() 448 | 449 | if !g:llvm_ext_no_mapping 450 | nmap K (llvm-goto-definition) 451 | endif 452 | 453 | function! s:run_lli(...) abort 454 | if !has('job') || !has('channel') || !has('terminal') 455 | echohl ErrorMsg 456 | echomsg ':LLI requires terminal feature. Please update your Vim to 8.0+' 457 | echohl None 458 | return 459 | endif 460 | 461 | if !executable(g:llvm_ext_lli_executable) 462 | echohl ErrorMsg 463 | echomsg g:llvm_ext_lli_executable . ' is not executable. Please set g:llvm_ext_lli_executable' 464 | echohl None 465 | return 466 | endif 467 | 468 | if a:0 > 0 469 | let bufnr = term_start([g:llvm_ext_lli_executable, a:1]) 470 | echo 'Run lli in termnal buffer(' . bufnr . ')' 471 | return 472 | endif 473 | 474 | let tmpfile = tempname() 475 | call writefile(getline(1, '$'), tmpfile) 476 | let Cleanup = {ch -> filereadable(tmpfile) ? delete(tmpfile) : 0} 477 | try 478 | let bufnr = term_start([g:llvm_ext_lli_executable, tmpfile], {'close_cb': Cleanup, 'exit_cb': Cleanup}) 479 | echo 'Run lli in termnal buffer(' . bufnr . ')' 480 | catch 481 | if filereadable(tmpfile) 482 | delete(tmpfile) 483 | endif 484 | endtry 485 | endfunction 486 | 487 | if !exists(':LLI') 488 | command! -buffer -nargs=? -bar -complete=file LLI call run_lli() 489 | endif 490 | -------------------------------------------------------------------------------- /after/syntax/llvm.vim: -------------------------------------------------------------------------------- 1 | " Copyright (c) 2018 rhysd 2 | " 3 | " Permission is hereby granted, free of charge, to any person obtaining a copy 4 | " of this software and associated documentation files (the "Software"), to deal 5 | " in the Software without restriction, including without limitation the rights 6 | " to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | " copies of the Software, and to permit persons to whom the Software is 8 | " furnished to do so, subject to the following conditions: 9 | " 10 | " The above copyright notice and this permission notice shall be included in 11 | " all copies or substantial portions of the Software. 12 | " 13 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | " OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | " THE SOFTWARE. 20 | 21 | syn keyword llvmKeyword attributes 22 | syn match llvmNoName /#\d\+\>/ 23 | -------------------------------------------------------------------------------- /ftdetect/llvm-lit.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile lit.*cfg set filetype=python 2 | -------------------------------------------------------------------------------- /ftdetect/llvm.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.ll set filetype=llvm 2 | -------------------------------------------------------------------------------- /ftdetect/mir.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.mir set filetype=mir 2 | -------------------------------------------------------------------------------- /ftdetect/mlir.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.mlir set filetype=mlir 2 | -------------------------------------------------------------------------------- /ftdetect/tablegen.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.td set filetype=tablegen 2 | -------------------------------------------------------------------------------- /ftplugin/llvm.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin file 2 | " Language: LLVM Assembly 3 | " Maintainer: The LLVM team, http://llvm.org/ 4 | 5 | if exists("b:did_ftplugin") 6 | finish 7 | endif 8 | let b:did_ftplugin = 1 9 | 10 | setlocal softtabstop=2 shiftwidth=2 11 | setlocal expandtab 12 | setlocal comments+=:; 13 | setlocal commentstring=;\ %s 14 | -------------------------------------------------------------------------------- /ftplugin/mir.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin file 2 | " Language: LLVM Machine IR 3 | " Maintainer: The LLVM team, http://llvm.org/ 4 | 5 | if exists("b:did_ftplugin") 6 | finish 7 | endif 8 | let b:did_ftplugin = 1 9 | 10 | setlocal softtabstop=2 shiftwidth=2 11 | setlocal expandtab 12 | setlocal comments+=:; 13 | 14 | -------------------------------------------------------------------------------- /ftplugin/mlir.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin file 2 | " Language: MLIR Assembly 3 | " Maintainer: The MLIR team 4 | 5 | if exists("b:did_ftplugin") 6 | finish 7 | endif 8 | let b:did_ftplugin = 1 9 | 10 | setlocal softtabstop=2 shiftwidth=2 11 | setlocal expandtab 12 | setlocal comments+=:// 13 | -------------------------------------------------------------------------------- /ftplugin/tablegen.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin file 2 | " Language: LLVM TableGen 3 | " Maintainer: The LLVM team, http://llvm.org/ 4 | 5 | if exists("b:did_ftplugin") 6 | finish 7 | endif 8 | let b:did_ftplugin = 1 9 | 10 | setlocal matchpairs+=<:> 11 | setlocal softtabstop=2 shiftwidth=2 12 | setlocal expandtab 13 | -------------------------------------------------------------------------------- /indent/llvm.vim: -------------------------------------------------------------------------------- 1 | " Vim indent file 2 | " Language: llvm 3 | " Maintainer: The LLVM team, http://llvm.org/ 4 | " What this indent plugin currently does: 5 | " - If no other rule matches copy indent from previous non-empty, 6 | " non-commented line 7 | " - On '}' align the same as the line containing the matching '{' 8 | " - If previous line ends with ':' increase indentation 9 | " - If the current line ends with ':' indent at the same level as the 10 | " enclosing '{'/'}' block 11 | " Stuff that would be nice to add: 12 | " - Continue comments on next line 13 | " - If there is an opening+unclosed parenthesis on previous line indent to that 14 | if exists("b:did_indent") 15 | finish 16 | endif 17 | let b:did_indent = 1 18 | 19 | setlocal shiftwidth=2 expandtab 20 | 21 | setlocal indentkeys=0{,0},<:>,!^F,o,O,e 22 | setlocal indentexpr=GetLLVMIndent() 23 | 24 | if exists("*GetLLVMIndent") 25 | finish 26 | endif 27 | 28 | function! FindOpenBrace(lnum) 29 | call cursor(a:lnum, 1) 30 | return searchpair('{', '', '}', 'bW') 31 | endfun 32 | 33 | function! GetLLVMIndent() 34 | " On '}' align the same as the line containing the matching '{' 35 | let thisline = getline(v:lnum) 36 | if thisline =~ '^\s*}' 37 | call cursor(v:lnum, 1) 38 | silent normal % 39 | let opening_lnum = line('.') 40 | if opening_lnum != v:lnum 41 | return indent(opening_lnum) 42 | endif 43 | endif 44 | 45 | " Indent labels the same as the current opening block 46 | if thisline =~ ':\s*$' 47 | let blockbegin = FindOpenBrace(v:lnum) 48 | if blockbegin > 0 49 | return indent(blockbegin) 50 | endif 51 | endif 52 | 53 | " Find a non-blank not-completely commented line above the current line. 54 | let prev_lnum = prevnonblank(v:lnum - 1) 55 | while prev_lnum > 0 && synIDattr(synID(prev_lnum, indent(prev_lnum)+1, 0), "name") =? "string\|comment" 56 | let prev_lnum = prevnonblank(prev_lnum-1) 57 | endwhile 58 | " Hit the start of the file, use zero indent. 59 | if prev_lnum == 0 60 | return 0 61 | endif 62 | 63 | let ind = indent(prev_lnum) 64 | let prevline = getline(prev_lnum) 65 | 66 | " Add a 'shiftwidth' after lines that start a block or labels 67 | if prevline =~ '{\s*$' || prevline =~ ':\s*$' 68 | let ind = ind + &shiftwidth 69 | endif 70 | 71 | return ind 72 | endfunction 73 | -------------------------------------------------------------------------------- /indent/mlir.vim: -------------------------------------------------------------------------------- 1 | " Vim indent file 2 | " Language: mlir 3 | " Maintainer: The MLIR team 4 | " Adapted from the LLVM vim indent file 5 | " What this indent plugin currently does: 6 | " - If no other rule matches copy indent from previous non-empty, 7 | " non-commented line. 8 | " - On '}' align the same as the line containing the matching '{'. 9 | " - If previous line starts with a block label, increase indentation. 10 | " - If the current line is a block label and ends with ':' indent at the same 11 | " level as the enclosing '{'/'}' block. 12 | " Stuff that would be nice to add: 13 | " - Continue comments on next line. 14 | " - If there is an opening+unclosed parenthesis on previous line indent to 15 | " that. 16 | if exists("b:did_indent") 17 | finish 18 | endif 19 | let b:did_indent = 1 20 | 21 | setlocal shiftwidth=2 expandtab 22 | 23 | setlocal indentkeys=0{,0},<:>,!^F,o,O,e 24 | setlocal indentexpr=GetMLIRIndent() 25 | 26 | if exists("*GetMLIRIndent") 27 | finish 28 | endif 29 | 30 | function! FindOpenBrace(lnum) 31 | call cursor(a:lnum, 1) 32 | return searchpair('{', '', '}', 'bW') 33 | endfun 34 | 35 | function! GetMLIRIndent() 36 | " On '}' align the same as the line containing the matching '{' 37 | let thisline = getline(v:lnum) 38 | if thisline =~ '^\s*}' 39 | call cursor(v:lnum, 1) 40 | silent normal % 41 | let opening_lnum = line('.') 42 | if opening_lnum != v:lnum 43 | return indent(opening_lnum) 44 | endif 45 | endif 46 | 47 | " Indent labels the same as the current opening block 48 | if thisline =~ '\^\h\+.*:\s*$' 49 | let blockbegin = FindOpenBrace(v:lnum) 50 | if blockbegin > 0 51 | return indent(blockbegin) 52 | endif 53 | endif 54 | 55 | " Find a non-blank not-completely commented line above the current line. 56 | let prev_lnum = prevnonblank(v:lnum - 1) 57 | while prev_lnum > 0 && synIDattr(synID(prev_lnum, 1 + indent(prev_lnum), 0), "name") == "mlirComment" 58 | let prev_lnum = prevnonblank(prev_lnum-1) 59 | endwhile 60 | " Hit the start of the file, use zero indent. 61 | if prev_lnum == 0 62 | return 0 63 | endif 64 | 65 | let ind = indent(prev_lnum) 66 | let prevline = getline(prev_lnum) 67 | 68 | " Add a 'shiftwidth' after lines that start a function, block/labels, or a 69 | " region. 70 | if prevline =~ '{\s*$' || prevline =~ '\^\h\+.*:\s*$' 71 | let ind = ind + &shiftwidth 72 | endif 73 | 74 | return ind 75 | endfunction 76 | -------------------------------------------------------------------------------- /scripts.vim: -------------------------------------------------------------------------------- 1 | " Copyright (c) 2014 rhysd 2 | " 3 | " Permission is hereby granted, free of charge, to any person obtaining a copy 4 | " of this software and associated documentation files (the "Software"), to deal 5 | " in the Software without restriction, including without limitation the rights 6 | " to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | " copies of the Software, and to permit persons to whom the Software is 8 | " furnished to do so, subject to the following conditions: 9 | " 10 | " The above copyright notice and this permission notice shall be included in 11 | " all copies or substantial portions of the Software. 12 | " 13 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | " OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | " THE SOFTWARE. 20 | " 21 | " 22 | " This script detects filetype 'llvm' from the content of file. 23 | " See :help new-filetype-scripts 24 | 25 | if get(g:, 'llvm_extends_official', 1) == 0 || did_filetype() 26 | finish 27 | endif 28 | 29 | if line('$') > 4 && 30 | \ getline(1) =~# '^; ModuleID = ' && 31 | \ getline(2) =~# '^source_filename = ' && 32 | \ getline(3) =~# '^target datalayout = ' && 33 | \ getline(4) =~# '^target triple = ' 34 | setfiletype llvm 35 | endif 36 | -------------------------------------------------------------------------------- /syntax/llvm.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: llvm 3 | " Maintainer: The LLVM team, http://llvm.org/ 4 | " Version: $Revision$ 5 | 6 | if version < 600 7 | syntax clear 8 | elseif exists("b:current_syntax") 9 | finish 10 | endif 11 | 12 | syn case match 13 | 14 | " Types. 15 | " Types also include struct, array, vector, etc. but these don't 16 | " benefit as much from having dedicated highlighting rules. 17 | syn keyword llvmType void half bfloat float double x86_fp80 fp128 ppc_fp128 18 | syn keyword llvmType label metadata x86_mmx x86_amx 19 | syn keyword llvmType type label opaque token ptr 20 | syn match llvmType /\/ 21 | 22 | " Instructions. 23 | " The true and false tokens can be used for comparison opcodes, but it's 24 | " much more common for these tokens to be used for boolean constants. 25 | syn keyword llvmStatement add addrspacecast alloca and arcp ashr atomicrmw 26 | syn keyword llvmStatement bitcast br catchpad catchswitch catchret call callbr 27 | syn keyword llvmStatement cleanuppad cleanupret cmpxchg eq exact extractelement 28 | syn keyword llvmStatement extractvalue fadd fast fcmp fdiv fence fmul fneg fpext 29 | syn keyword llvmStatement fptosi fptoui fptrunc free freeze frem fsub 30 | syn keyword llvmStatement getelementptr icmp inbounds indirectbr insertelement 31 | syn keyword llvmStatement insertvalue inttoptr invoke landingpad load lshr 32 | syn keyword llvmStatement malloc max min mul nand ne ninf nnan nsw nsz nuw oeq 33 | syn keyword llvmStatement oge ogt ole olt one or ord phi ptrtoint resume ret 34 | syn keyword llvmStatement sdiv select sext sge sgt shl shufflevector sitofp 35 | syn keyword llvmStatement sle slt srem store sub switch trunc udiv ueq uge ugt 36 | syn keyword llvmStatement uitofp ule ult umax umin une uno unreachable unwind 37 | syn keyword llvmStatement urem va_arg xchg xor zext 38 | 39 | " Debug records. 40 | syn match llvmStatement /\v#dbg_(assign|declare|label|value)/ 41 | 42 | " Keywords. 43 | syn keyword llvmKeyword 44 | \ acq_rel 45 | \ acquire 46 | \ addrspace 47 | \ alias 48 | \ align 49 | \ alignstack 50 | \ allocsize 51 | \ alwaysinline 52 | \ appending 53 | \ argmemonly 54 | \ arm_aapcs_vfpcc 55 | \ arm_aapcscc 56 | \ arm_apcscc 57 | \ asm 58 | \ atomic 59 | \ available_externally 60 | \ blockaddress 61 | \ builtin 62 | \ byref 63 | \ byval 64 | \ c 65 | \ caller 66 | \ catch 67 | \ cc 68 | \ ccc 69 | \ cleanup 70 | \ cold 71 | \ coldcc 72 | \ comdat 73 | \ common 74 | \ constant 75 | \ convergent 76 | \ datalayout 77 | \ declare 78 | \ default 79 | \ define 80 | \ deplibs 81 | \ dereferenceable 82 | \ dereferenceable_or_null 83 | \ distinct 84 | \ dllexport 85 | \ dllimport 86 | \ dso_local 87 | \ dso_preemptable 88 | \ except 89 | \ extern_weak 90 | \ external 91 | \ externally_initialized 92 | \ fastcc 93 | \ filter 94 | \ from 95 | \ gc 96 | \ global 97 | \ hhvm_ccc 98 | \ hhvmcc 99 | \ hidden 100 | \ hot 101 | \ immarg 102 | \ inaccessiblemem_or_argmemonly 103 | \ inaccessiblememonly 104 | \ inalloca 105 | \ initialexec 106 | \ inlinehint 107 | \ inreg 108 | \ intel_ocl_bicc 109 | \ inteldialect 110 | \ internal 111 | \ jumptable 112 | \ linkonce 113 | \ linkonce_odr 114 | \ local_unnamed_addr 115 | \ localdynamic 116 | \ localexec 117 | \ minsize 118 | \ module 119 | \ monotonic 120 | \ msp430_intrcc 121 | \ mustprogress 122 | \ musttail 123 | \ naked 124 | \ nest 125 | \ noalias 126 | \ nobuiltin 127 | \ nocallback 128 | \ nocapture 129 | \ nocf_check 130 | \ no_cfi 131 | \ noduplicate 132 | \ nofree 133 | \ noimplicitfloat 134 | \ noinline 135 | \ nomerge 136 | \ nonlazybind 137 | \ nonnull 138 | \ noprofile 139 | \ norecurse 140 | \ noredzone 141 | \ noreturn 142 | \ nosync 143 | \ noundef 144 | \ nounwind 145 | \ nosanitize_bounds 146 | \ nosanitize_coverage 147 | \ null_pointer_is_valid 148 | \ optdebug 149 | \ optforfuzzing 150 | \ optnone 151 | \ optsize 152 | \ personality 153 | \ preallocated 154 | \ private 155 | \ protected 156 | \ ptrauth 157 | \ ptx_device 158 | \ ptx_kernel 159 | \ readnone 160 | \ readonly 161 | \ release 162 | \ returned 163 | \ returns_twice 164 | \ safestack 165 | \ sanitize_address 166 | \ sanitize_hwaddress 167 | \ sanitize_memory 168 | \ sanitize_memtag 169 | \ sanitize_thread 170 | \ section 171 | \ seq_cst 172 | \ shadowcallstack 173 | \ sideeffect 174 | \ signext 175 | \ source_filename 176 | \ speculatable 177 | \ speculative_load_hardening 178 | \ spir_func 179 | \ spir_kernel 180 | \ splat 181 | \ sret 182 | \ ssp 183 | \ sspreq 184 | \ sspstrong 185 | \ strictfp 186 | \ swiftcc 187 | \ swifterror 188 | \ swifttailcc 189 | \ swiftself 190 | \ syncscope 191 | \ tail 192 | \ tailcc 193 | \ target 194 | \ thread_local 195 | \ to 196 | \ triple 197 | \ unnamed_addr 198 | \ unordered 199 | \ uselistorder 200 | \ uselistorder_bb 201 | \ uwtable 202 | \ volatile 203 | \ weak 204 | \ weak_odr 205 | \ willreturn 206 | \ win64cc 207 | \ within 208 | \ writeonly 209 | \ x86_64_sysvcc 210 | \ x86_fastcallcc 211 | \ x86_stdcallcc 212 | \ x86_thiscallcc 213 | \ zeroext 214 | 215 | " Obsolete keywords. 216 | syn keyword llvmError getresult begin end 217 | 218 | " Misc syntax. 219 | syn match llvmNoName /[%@!]\d\+\>/ 220 | syn match llvmNumber /-\?\<\d\+\>/ 221 | syn match llvmFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/ 222 | syn match llvmFloat /\<0x[KLMHR]\?\x\+\>/ 223 | syn keyword llvmBoolean true false 224 | syn keyword llvmConstant zeroinitializer undef null none poison vscale 225 | syn match llvmComment /;.*$/ 226 | syn region llvmString start=/"/ skip=/\\"/ end=/"/ 227 | syn match llvmLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/ 228 | syn match llvmIdentifier /[%@][-a-zA-Z$._][-a-zA-Z$._0-9]*/ 229 | 230 | " Named metadata and specialized metadata keywords. 231 | syn match llvmIdentifier /![-a-zA-Z$._][-a-zA-Z$._0-9]*\ze\s*$/ 232 | syn match llvmIdentifier /![-a-zA-Z$._][-a-zA-Z$._0-9]*\ze\s*[=!]/ 233 | syn match llvmType /!\zs\a\+\ze\s*(/ 234 | syn match llvmConstant /\/ 235 | syn match llvmConstant /\/ 236 | syn match llvmConstant /\/ 237 | syn match llvmConstant /\/ 238 | syn match llvmConstant /\/ 239 | syn match llvmConstant /\/ 240 | 241 | " Syntax-highlight lit test commands and bug numbers. 242 | syn match llvmSpecialComment /;\s*PR\d*\s*$/ 243 | syn match llvmSpecialComment /;\s*REQUIRES:.*$/ 244 | syn match llvmSpecialComment /;\s*RUN:.*$/ 245 | syn match llvmSpecialComment /;\s*ALLOW_RETRIES:.*$/ 246 | syn match llvmSpecialComment /;\s*CHECK:.*$/ 247 | syn match llvmSpecialComment /;\s*CHECK-EMPTY:\s*$/ 248 | syn match llvmSpecialComment /\v;\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL|COUNT-\d+):.*$/ 249 | syn match llvmSpecialComment /;\s*XFAIL:.*$/ 250 | 251 | if version >= 508 || !exists("did_c_syn_inits") 252 | if version < 508 253 | let did_c_syn_inits = 1 254 | command -nargs=+ HiLink hi link 255 | else 256 | command -nargs=+ HiLink hi def link 257 | endif 258 | 259 | HiLink llvmType Type 260 | HiLink llvmStatement Statement 261 | HiLink llvmNumber Number 262 | HiLink llvmComment Comment 263 | HiLink llvmString String 264 | HiLink llvmLabel Label 265 | HiLink llvmKeyword Keyword 266 | HiLink llvmBoolean Boolean 267 | HiLink llvmFloat Float 268 | HiLink llvmNoName Identifier 269 | HiLink llvmConstant Constant 270 | HiLink llvmSpecialComment SpecialComment 271 | HiLink llvmError Error 272 | HiLink llvmIdentifier Identifier 273 | 274 | delcommand HiLink 275 | endif 276 | 277 | let b:current_syntax = "llvm" 278 | -------------------------------------------------------------------------------- /syntax/machine-ir.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: mir 3 | " Maintainer: The LLVM team, http://llvm.org/ 4 | " Version: $Revision$ 5 | 6 | syn case match 7 | 8 | " FIXME: MIR doesn't actually match LLVM IR. Stop including it all as a 9 | " fallback once enough is implemented. 10 | " See the MIR LangRef: https://llvm.org/docs/MIRLangRef.html 11 | unlet b:current_syntax " Unlet so that the LLVM syntax will load 12 | runtime! syntax/llvm.vim 13 | unlet b:current_syntax 14 | 15 | syn match mirType /\<[sp]\d\+\>/ 16 | 17 | " Opcodes. Matching instead of listing them because individual targets can add 18 | " these. FIXME: Maybe use some more context to make this more accurate? 19 | syn match mirStatement /\<[A-Z][A-Za-z0-9_]*\>/ 20 | 21 | syn match mirPReg /$[-a-zA-Z$._][-a-zA-Z$._0-9]*/ 22 | 23 | if version >= 508 || !exists("did_c_syn_inits") 24 | if version < 508 25 | let did_c_syn_inits = 1 26 | command -nargs=+ HiLink hi link 27 | else 28 | command -nargs=+ HiLink hi def link 29 | endif 30 | 31 | HiLink mirType Type 32 | HiLink mirStatement Statement 33 | HiLink mirPReg Identifier 34 | 35 | delcommand HiLink 36 | endif 37 | 38 | let b:current_syntax = "mir" 39 | -------------------------------------------------------------------------------- /syntax/mir.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: mir 3 | " Maintainer: The LLVM team, http://llvm.org/ 4 | " Version: $Revision$ 5 | 6 | if version < 600 7 | syntax clear 8 | elseif exists("b:current_syntax") 9 | finish 10 | endif 11 | 12 | syn case match 13 | 14 | " MIR is embedded in a yaml container, so we load all of the yaml syntax. 15 | runtime! syntax/yaml.vim 16 | unlet b:current_syntax 17 | 18 | " The first document of a file is allowed to contain an LLVM IR module inside 19 | " a top-level yaml block string. 20 | syntax include @LLVM syntax/llvm.vim 21 | " FIXME: This should only be allowed for the first document of the file 22 | syntax region llvm start=/\(^---\s*|\)\@<=/ end=/\(^\.\.\.\)\@=/ contains=@LLVM 23 | 24 | " The `body:` field of a document contains the MIR dump of the function 25 | syntax include @MIR syntax/machine-ir.vim 26 | syntax region mir start=/\(^body:\s*|\)\@<=/ end=/\(^[^[:space:]]\)\@=/ contains=@MIR 27 | 28 | " Syntax-highlight lit test commands and bug numbers. 29 | syn match mirSpecialComment /#\s*PR\d*\s*$/ 30 | syn match mirSpecialComment /#\s*REQUIRES:.*$/ 31 | syn match mirSpecialComment /#\s*RUN:.*$/ 32 | syn match mirSpecialComment /#\s*ALLOW_RETRIES:.*$/ 33 | syn match mirSpecialComment /#\s*CHECK:.*$/ 34 | syn match mirSpecialComment "\v#\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$" 35 | syn match mirSpecialComment /#\s*XFAIL:.*$/ 36 | 37 | if version >= 508 || !exists("did_c_syn_inits") 38 | if version < 508 39 | let did_c_syn_inits = 1 40 | command -nargs=+ HiLink hi link 41 | else 42 | command -nargs=+ HiLink hi def link 43 | endif 44 | 45 | HiLink mirSpecialComment SpecialComment 46 | 47 | delcommand HiLink 48 | endif 49 | 50 | let b:current_syntax = "mir" 51 | -------------------------------------------------------------------------------- /syntax/mlir.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: mlir 3 | " Maintainer: The MLIR team, http://github.com/tensorflow/mlir/ 4 | " Version: $Revision$ 5 | " Some parts adapted from the LLVM vim syntax file. 6 | 7 | if version < 600 8 | syntax clear 9 | elseif exists("b:current_syntax") 10 | finish 11 | endif 12 | 13 | syn case match 14 | 15 | " Types. 16 | " 17 | syn keyword mlirType index f16 f32 f64 bf16 18 | " Signless integer types. 19 | syn match mlirType /\/ 20 | " Unsigned integer types. 21 | syn match mlirType /\/ 22 | " Signed integer types. 23 | syn match mlirType /\/ 24 | 25 | " Elemental types inside memref, tensor, or vector types. 26 | syn match mlirType /x\s*\zs\(bf16|f16\|f32\|f64\|i\d\+\|ui\d\+\|si\d\+\)/ 27 | 28 | " Shaped types. 29 | syn match mlirType /\/ 30 | syn match mlirType /\/ 31 | syn match mlirType /\/ 32 | 33 | " vector types inside memref or tensor. 34 | syn match mlirType /x\s*\zsvector/ 35 | 36 | " Operations. 37 | " TODO: this list is not exhaustive. 38 | syn keyword mlirOps alloc alloca addf addi and call call_indirect cmpf cmpi 39 | syn keyword mlirOps constant dealloc divf dma_start dma_wait dim exp 40 | syn keyword mlirOps getTensor index_cast load log memref_cast 41 | syn keyword mlirOps memref_shape_cast mulf muli negf powf prefetch rsqrt sitofp 42 | syn keyword mlirOps splat store select sqrt subf subi subview tanh 43 | syn keyword mlirOps view 44 | 45 | " Math ops. 46 | syn match mlirOps /\/ 47 | 48 | " Affine ops. 49 | syn match mlirOps /\/ 50 | syn match mlirOps /\/ 51 | syn match mlirOps /\/ 52 | syn match mlirOps /\/ 53 | syn match mlirOps /\/ 54 | syn match mlirOps /\/ 55 | syn match mlirOps /\/ 56 | syn match mlirOps /\/ 57 | syn match mlirOps /\/ 58 | syn match mlirOps /\/ 59 | syn match mlirOps /\/ 60 | syn match mlirOps /\/ 61 | syn match mlirOps /\/ 62 | 63 | " TODO: dialect name prefixed ops (llvm or std). 64 | 65 | " Keywords. 66 | syn keyword mlirKeyword 67 | \ affine_map 68 | \ affine_set 69 | \ dense 70 | \ else 71 | \ func 72 | \ module 73 | \ return 74 | \ step 75 | \ to 76 | 77 | " Misc syntax. 78 | 79 | syn match mlirNumber /-\?\<\d\+\>/ 80 | " Match numbers even in shaped types. 81 | syn match mlirNumber /-\?\<\d\+\ze\s*x/ 82 | syn match mlirNumber /x\s*\zs-\?\d\+\ze\s*x/ 83 | 84 | syn match mlirFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/ 85 | syn match mlirFloat /\<0x\x\+\>/ 86 | syn keyword mlirBoolean true false 87 | " Spell checking is enabled only in comments by default. 88 | syn match mlirComment /\/\/.*$/ contains=@Spell 89 | syn region mlirString start=/"/ skip=/\\"/ end=/"/ 90 | syn match mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/ 91 | " Prefixed identifiers usually used for ssa values and symbols. 92 | syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/ 93 | syn match mlirIdentifier /[%@]\d\+\>/ 94 | " Prefixed identifiers usually used for blocks. 95 | syn match mlirBlockIdentifier /\^[a-zA-Z$._-][a-zA-Z0-9$._-]*/ 96 | syn match mlirBlockIdentifier /\^\d\+\>/ 97 | " Prefixed identifiers usually used for types. 98 | syn match mlirTypeIdentifier /![a-zA-Z$._-][a-zA-Z0-9$._-]*/ 99 | syn match mlirTypeIdentifier /!\d\+\>/ 100 | " Prefixed identifiers usually used for attribute aliases and result numbers. 101 | syn match mlirAttrIdentifier /#[a-zA-Z$._-][a-zA-Z0-9$._-]*/ 102 | syn match mlirAttrIdentifier /#\d\+\>/ 103 | 104 | " Syntax-highlight lit test commands and bug numbers. 105 | syn match mlirSpecialComment /\/\/\s*RUN:.*$/ 106 | syn match mlirSpecialComment /\/\/\s*CHECK:.*$/ 107 | syn match mlirSpecialComment "\v\/\/\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$" 108 | syn match mlirSpecialComment /\/\/\s*expected-error.*$/ 109 | syn match mlirSpecialComment /\/\/\s*expected-remark.*$/ 110 | syn match mlirSpecialComment /;\s*XFAIL:.*$/ 111 | syn match mlirSpecialComment /\/\/\s*PR\d*\s*$/ 112 | syn match mlirSpecialComment /\/\/\s*REQUIRES:.*$/ 113 | 114 | if version >= 508 || !exists("did_c_syn_inits") 115 | if version < 508 116 | let did_c_syn_inits = 1 117 | command -nargs=+ HiLink hi link 118 | else 119 | command -nargs=+ HiLink hi def link 120 | endif 121 | 122 | HiLink mlirType Type 123 | HiLink mlirOps Statement 124 | HiLink mlirNumber Number 125 | HiLink mlirComment Comment 126 | HiLink mlirString String 127 | HiLink mlirLabel Label 128 | HiLink mlirKeyword Keyword 129 | HiLink mlirBoolean Boolean 130 | HiLink mlirFloat Float 131 | HiLink mlirConstant Constant 132 | HiLink mlirSpecialComment SpecialComment 133 | HiLink mlirIdentifier Identifier 134 | HiLink mlirBlockIdentifier Label 135 | HiLink mlirTypeIdentifier Type 136 | HiLink mlirAttrIdentifier PreProc 137 | 138 | delcommand HiLink 139 | endif 140 | 141 | let b:current_syntax = "mlir" 142 | -------------------------------------------------------------------------------- /syntax/tablegen.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: TableGen 3 | " Maintainer: The LLVM team, http://llvm.org/ 4 | " Version: $Revision$ 5 | 6 | if version < 600 7 | syntax clear 8 | elseif exists("b:current_syntax") 9 | finish 10 | endif 11 | 12 | " May be changed if you have a really slow machine 13 | syntax sync minlines=100 14 | 15 | syn case match 16 | 17 | syn keyword tgKeyword def let in code dag field include defm foreach defset defvar if then else assert dump 18 | syn keyword tgType class int string list bit bits multiclass 19 | 20 | syn match tgNumber /\<\d\+\>/ 21 | syn match tgNumber /\<\d\+\.\d*\>/ 22 | syn match tgNumber /\<0b[01]\+\>/ 23 | syn match tgNumber /\<0x[0-9a-fA-F]\+\>/ 24 | syn region tgString start=/"/ skip=/\\"/ end=/"/ oneline 25 | 26 | syn region tgCode start=/\[{/ end=/}\]/ 27 | 28 | syn keyword tgTodo contained TODO FIXME 29 | syn match tgComment /\/\/.*$/ contains=tgTodo 30 | " Handle correctly imbricated comment 31 | syn region tgComment2 matchgroup=tgComment2 start=+/\*+ end=+\*/+ contains=tgTodo,tgComment2 32 | 33 | if version >= 508 || !exists("did_c_syn_inits") 34 | if version < 508 35 | let did_c_syn_inits = 1 36 | command -nargs=+ HiLink hi link 37 | else 38 | command -nargs=+ HiLink hi def link 39 | endif 40 | 41 | HiLink tgKeyword Statement 42 | HiLink tgType Type 43 | HiLink tgNumber Number 44 | HiLink tgComment Comment 45 | HiLink tgComment2 Comment 46 | HiLink tgString String 47 | " May find a better Hilight group... 48 | HiLink tgCode Special 49 | HiLink tgTodo Todo 50 | 51 | delcommand HiLink 52 | endif 53 | 54 | let b:current_syntax = "tablegen" 55 | --------------------------------------------------------------------------------