Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh(llvm) Improve grammar and align assembly like grammars (#2830)
- Variables are now highlighted as `variable` - `i8`, `i32`, etc now highlighted as `type` - Labels are now highlighted as `symbol` (matching our other grammars) - Better comment detection - Restore relevance to strings - prevent false positives on `;` line endings as "comments" - Add very minimal `operator` and `punctuation` support
- Loading branch information
1 parent
9ba5a5d
commit 7816b2f
Showing
4 changed files
with
108 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<span class="hljs-comment">;; foooo</span> | ||
<span class="hljs-keyword">define</span> <span class="hljs-type">i32</span> <span class="hljs-title">@mul_add</span>(<span class="hljs-type">i32</span> <span class="hljs-variable">%x</span><span class="hljs-punctuation">,</span> <span class="hljs-type">i32</span> <span class="hljs-variable">%y</span><span class="hljs-punctuation">,</span> <span class="hljs-type">i32</span> <span class="hljs-variable">%z</span>) { | ||
<span class="hljs-symbol"> entry:</span> | ||
<span class="hljs-variable">%tmp</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">mul</span> <span class="hljs-type">i32</span> <span class="hljs-variable">%x</span><span class="hljs-punctuation">,</span> <span class="hljs-variable">%y</span> | ||
<span class="hljs-variable">%tmp2</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">add</span> <span class="hljs-type">i32</span> <span class="hljs-variable">%tmp</span><span class="hljs-punctuation">,</span> <span class="hljs-variable">%z</span> | ||
<span class="hljs-variable">%tmp3</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">add</span> <span class="hljs-type">i32</span> <span class="hljs-variable">%tmp</span><span class="hljs-punctuation">,</span> <span class="hljs-number">0</span> | ||
<span class="hljs-keyword">ret</span> <span class="hljs-type">i32</span> <span class="hljs-variable">%tmp3</span> | ||
} | ||
|
||
<span class="hljs-comment">; Named metadata</span> | ||
<span class="hljs-title">!0</span> <span class="hljs-operator">=</span> !{<span class="hljs-type">i32</span> <span class="hljs-number">42</span><span class="hljs-punctuation">,</span> <span class="hljs-keyword">null</span><span class="hljs-punctuation">,</span> !<span class="hljs-string">"string"</span>} | ||
<span class="hljs-title">!foo</span> <span class="hljs-operator">=</span> !{<span class="hljs-title">!0</span>} | ||
|
||
<span class="hljs-comment">; Some unnamed metadata nodes, which are referenced by the named metadata.</span> | ||
<span class="hljs-title">!0</span> <span class="hljs-operator">=</span> !{!<span class="hljs-string">"zero"</span>} | ||
<span class="hljs-title">!1</span> <span class="hljs-operator">=</span> !{!<span class="hljs-string">"one"</span>} | ||
<span class="hljs-title">!2</span> <span class="hljs-operator">=</span> !{!<span class="hljs-string">"two"</span>} | ||
<span class="hljs-comment">; A named metadata.</span> | ||
<span class="hljs-title">!name</span> <span class="hljs-operator">=</span> !{<span class="hljs-title">!0</span><span class="hljs-punctuation">,</span> <span class="hljs-title">!1</span><span class="hljs-punctuation">,</span> <span class="hljs-title">!2</span>} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
;; foooo | ||
define i32 @mul_add(i32 %x, i32 %y, i32 %z) { | ||
entry: | ||
%tmp = mul i32 %x, %y | ||
%tmp2 = add i32 %tmp, %z | ||
%tmp3 = add i32 %tmp, 0 | ||
ret i32 %tmp3 | ||
} | ||
|
||
; Named metadata | ||
!0 = !{i32 42, null, !"string"} | ||
!foo = !{!0} | ||
|
||
; Some unnamed metadata nodes, which are referenced by the named metadata. | ||
!0 = !{!"zero"} | ||
!1 = !{!"one"} | ||
!2 = !{!"two"} | ||
; A named metadata. | ||
!name = !{!0, !1, !2} |