Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix function attributes and attribute groups on LLVM #986

Merged
merged 4 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/rouge/lexers/llvm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class LLVM < RegexLexer
rule %r/#{identifier}\s*:/, Name::Label

rule %r/@(#{identifier}|\d+)/, Name::Variable::Global
rule %r/#\d+/, Name::Variable::Global
rule %r/(%|!)#{identifier}/, Name::Variable
rule %r/(%|!)\d+/, Name::Variable

Expand All @@ -42,7 +43,7 @@ class LLVM < RegexLexer
end

builtin_keywords = %w(
begin end true false declare define global constant personality private
begin end true false declare define global constant alignstack private
landingpad linker_private internal available_externally linkonce_odr
linkonce weak weak_odr appending dllimport dllexport common default
hidden protected extern_weak external thread_local zeroinitializer
Expand All @@ -54,7 +55,13 @@ class LLVM < RegexLexer
nest readnone readonly inlinehint noinline alwaysinline optsize ssp
sspreq noredzone noimplicitfloat naked type opaque eq ne slt sgt sle
sge ult ugt ule uge oeq one olt ogt ole oge ord uno unnamed_addr ueq
une uwtable x
une uwtable x personality allocsize builtin cold convergent
inaccessiblememonly inaccessiblemem_or_argmemonly jumptable minsize
no-jump-tables nobuiltin noduplicate nonlazybind noredzone norecurse
optforfuzzing optnone writeonly argmemonly returns_twice safestack
sanitize_address sanitize_memory sanitize_thread sanitize_hwaddress
speculative_load_hardening speculatable sspstrong strictfp nocf_check
shadowcallstack attributes
)

builtin_instructions = %w(
Expand Down
11 changes: 11 additions & 0 deletions spec/visual/samples/llvm
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,14 @@ second_end:
; control-equivalent to %end, so this is
; well-defined (ignoring earlier undefined
; behavior in this example).

; copied from https://llvm.org/docs/LangRef.html#attribute-groups

; Target-independent attributes:
attributes #0 = { alwaysinline alignstack=4 }

; Target-dependent attributes:
attributes #1 = { "no-sse" }

; Function @f has attributes: alwaysinline, alignstack=4, and "no-sse".
define void @f() #0 #1 { ... }