This is an archive of the discontinued LLVM Phabricator instance.

[emacs] Handle vector types, arbitary integer types and function names
Needs ReviewPublic

Authored by luke on Aug 18 2023, 3:02 PM.

Details

Reviewers
goldstein.w.n
Summary

This adds a few more regexp patterns for llvm-mode-syntax-table. The primitive
type regexp was split out so it could be reused when handling vectors. Also
worth noting is that the vector regexp needs to come before the primitive
types, otherwise they will match first.

Diff Detail

Unit TestsFailed

Event Timeline

luke created this revision.Aug 18 2023, 3:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2023, 3:02 PM
luke requested review of this revision.Aug 18 2023, 3:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2023, 3:02 PM

Example of some syntax this is suppose to help?

I tried on:

define <2 x i1> @foo.v2i1(<2 x i1> %v) {
  ret <2 x i1> %v
}

define i64 @promote_vscale_i32_to_i64() {
; CHECK-LABEL: @promote_vscale_i32_to_i64(
; CHECK-NEXT:    [[VSCALE:%.*]] = call i64 @llvm.vscale.i64()
; CHECK-NEXT:    [[EXT:%.*]] = and i64 [[VSCALE]], 4294967295
; CHECK-NEXT:    ret i64 [[EXT]]
;
  %vscale = call i32 @llvm.vscale.i32()
  %ext = zext i32 %vscale to i64
  ret i64 %ext
}

declare i32 @llvm.vscale.i32()

attributes #0 = {
  vscale_range(1, 16)
}

And no change.

luke updated this revision to Diff 551777.Aug 19 2023, 11:20 AM

Fix splicing not in a quasiquote, use a defconst instead

luke added a comment.Aug 19 2023, 11:25 AM

Example of some syntax this is suppose to help?

My bad, I did some last minute refactoring and didn't realise that the script didn't actually evaluate successfully. Fixed now.

New bits of syntax that should be highlighted:

<vscale x 4 x i32>
<2 x float>
i25
@my_function

Also by dropping the symbols arg to regexp-opt, we now properly highlight types that appear inside a vector constant, e.g. previously the first i32 wasn't highlighted in <i32 0, i32 1, i32 2, i32 3>

Example of some syntax this is suppose to help?

My bad, I did some last minute refactoring and didn't realise that the script didn't actually evaluate successfully. Fixed now.

New bits of syntax that should be highlighted:

<vscale x 4 x i32>
<2 x float>
i25
@my_function

Also by dropping the symbols arg to regexp-opt, we now properly highlight types that appear inside a vector constant, e.g. previously the first i32 wasn't highlighted in <i32 0, i32 1, i32 2, i32 3>

Okay a few notes.
Object first: This fails for something like: < 2x i64>.

Subjective:
Personally not a fan of some of the new highlighting.

  1. Personal preference would be in something like <vscale x 2 x i64> each of the component (</>, x, vscale, 2, and i64) would have seperate font-locks.

I'm not sure this is actually doable though. Can you set font for a portion of a regex match?

llvm/utils/emacs/llvm-mode.el
41

This should be a seperate patch.

41

Actually scratch this comment. Fine to keep here.