summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Sanders <daniel_l_sanders@apple.com>2020-01-24 08:56:46 -0800
committerMatthäus G. Chajdas <Anteru@users.noreply.github.com>2020-01-24 17:56:46 +0100
commit59396bb83c3a1ba6331fa65771ce3d881e9f7c0c (patch)
tree739fc2dc3d42a2b939d08a458ffea2314bc751ea /tests
parentc786e452f08840d4cc5ac8b3fcb001a218b7a56b (diff)
downloadpygments-git-59396bb83c3a1ba6331fa65771ce3d881e9f7c0c.tar.gz
Add lexer for LLVM's MIR format (#1361)
MIR is a human readable serialization format that's used to represent LLVM's machine specific intermediate representation. It allows LLVM's developers to see the state of the compilation process at various points, as well as test individual pieces of the compiler. Our documentation for the format can be found at https://llvm.org/docs/MIRLangRef.html. Adding a lexer for this format will allow the LLVM documentation to contain syntax highlighted examples of LLVM-MIR. Two lexers are included in this change. 'llvm-mir' lexes the overall document format and delegates to 'llvm' and 'llvm-mir-body' as appropriate. 'llvm-mir-body' lexes the contents of the 'body:' attribute and can be used directly to syntax highlight code examples without including the document boilerplate. Since the 'llvm-mir' lexer delegates to the 'llvm' lexer at times, this change also adds the 'immarg' and 'willreturn' keywords to the 'llvm' lexer as these were missing.
Diffstat (limited to 'tests')
-rw-r--r--tests/examplefiles/llvm-mir.mir32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/examplefiles/llvm-mir.mir b/tests/examplefiles/llvm-mir.mir
new file mode 100644
index 00000000..561296c2
--- /dev/null
+++ b/tests/examplefiles/llvm-mir.mir
@@ -0,0 +1,32 @@
+# YAML line comment
+
+--- |
+ ; LLVM-IR line comment
+ define void @myfunction() { ret void }
+...
+
+---
+name: myfunction
+legalized: true
+registers:
+ - { id: 0, class: gpr }
+body: |
+ bb.0.named (address-taken):
+ liveins: $r0, $r1
+ successors: %bb.1.alsonamed
+
+ ; MIR line comment
+ %0:gpr(s64) = COPY $r0
+ %1(s32) = COPY $r1
+ bb.1.alsonamed:
+ successors: %bb.2
+
+ %2(s32) = EXTRACT_SUBREG %1(s32), %subreg.sub0
+ %3(s32) = G_ADD %0:gpr(s32), %2(s32) killed
+ %4(s32) = G_CONSTANT i32 1
+ %5(s32) = G_FCONSTANT float 1.0
+ %6(p0) = G_LOAD %6(p0) :: (load 4 from %ir.myvar + 4)
+
+ bb.2:
+ $r0 = COPY %3
+...