Skip to content

Commit c212f00

Browse files
committed
Merge branch 'llvm'
2 parents ce095c3 + f5e9920 commit c212f00

File tree

5 files changed

+281
-1
lines changed

5 files changed

+281
-1
lines changed

AUTHORS.en.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,5 @@ Contributors:
231231
- Alexander Lichter <manniL@gmx.net>
232232
- Nicolas Le Gall <contact@nlegall.fr>
233233
- Kenton Hamaluik <kentonh@gmail.com>
234-
- Marvin Saignat <contact@zgmrvn.com>
234+
- Marvin Saignat <contact@zgmrvn.com>
235+
- Michael Rodler <contact@f0rki.at>

AUTHORS.ru.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,4 @@ URL: https://highlightjs.org/
232232
- Николя Ле Галль <contact@nlegall.fr>
233233
- Кентон Хамалуик <kentonh@gmail.com>
234234
- Марвин Сайнат <contact@zgmrvn.com>
235+
- Михаель Родлер <contact@f0rki.at>

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
## Version 9.9.0
22

3+
New languages
4+
5+
- *LLVM* by [Michael Rodler][]
6+
37
Improvements:
48

59
- TypeScript updated with annotations and param lists inside constructors, by
610
[Raphael Parree][]
711

812
[Raphael Parree]: https://github.com/rparree
13+
[Michael Rodler]: https://github.com/f0rki
914

1015

1116
## Version 9.8.0 "New York"

src/languages/llvm.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
Language: LLVM IR
3+
Author: Michael Rodler <contact@f0rki.at>
4+
Description: language used as intermediate representation in the LLVM compiler framework
5+
Category: assembler
6+
*/
7+
8+
function(hljs) {
9+
var identifier = '([-a-zA-Z$._][\\w\\-$.]*)';
10+
return {
11+
//lexemes: '[.%]?' + hljs.IDENT_RE,
12+
keywords:
13+
'begin end true false declare define global ' +
14+
'constant private linker_private internal ' +
15+
'available_externally linkonce linkonce_odr weak ' +
16+
'weak_odr appending dllimport dllexport common ' +
17+
'default hidden protected extern_weak external ' +
18+
'thread_local zeroinitializer undef null to tail ' +
19+
'target triple datalayout volatile nuw nsw nnan ' +
20+
'ninf nsz arcp fast exact inbounds align ' +
21+
'addrspace section alias module asm sideeffect ' +
22+
'gc dbg linker_private_weak attributes blockaddress ' +
23+
'initialexec localdynamic localexec prefix unnamed_addr ' +
24+
'ccc fastcc coldcc x86_stdcallcc x86_fastcallcc ' +
25+
'arm_apcscc arm_aapcscc arm_aapcs_vfpcc ptx_device ' +
26+
'ptx_kernel intel_ocl_bicc msp430_intrcc spir_func ' +
27+
'spir_kernel x86_64_sysvcc x86_64_win64cc x86_thiscallcc ' +
28+
'cc c signext zeroext inreg sret nounwind ' +
29+
'noreturn noalias nocapture byval nest readnone ' +
30+
'readonly inlinehint noinline alwaysinline optsize ssp ' +
31+
'sspreq noredzone noimplicitfloat naked builtin cold ' +
32+
'nobuiltin noduplicate nonlazybind optnone returns_twice ' +
33+
'sanitize_address sanitize_memory sanitize_thread sspstrong ' +
34+
'uwtable returned type opaque eq ne slt sgt ' +
35+
'sle sge ult ugt ule uge oeq one olt ogt ' +
36+
'ole oge ord uno ueq une x acq_rel acquire ' +
37+
'alignstack atomic catch cleanup filter inteldialect ' +
38+
'max min monotonic nand personality release seq_cst ' +
39+
'singlethread umax umin unordered xchg add fadd ' +
40+
'sub fsub mul fmul udiv sdiv fdiv urem srem ' +
41+
'frem shl lshr ashr and or xor icmp fcmp ' +
42+
'phi call trunc zext sext fptrunc fpext uitofp ' +
43+
'sitofp fptoui fptosi inttoptr ptrtoint bitcast ' +
44+
'addrspacecast select va_arg ret br switch invoke ' +
45+
'unwind unreachable indirectbr landingpad resume ' +
46+
'malloc alloca free load store getelementptr ' +
47+
'extractelement insertelement shufflevector getresult ' +
48+
'extractvalue insertvalue atomicrmw cmpxchg fence ' +
49+
'argmemonly double',
50+
contains: [
51+
{
52+
className: 'keyword',
53+
begin: 'i\\d+'
54+
},
55+
hljs.COMMENT(
56+
';', '\\n', {relevance: 0}
57+
),
58+
// Double quote string
59+
hljs.QUOTE_STRING_MODE,
60+
{
61+
className: 'string',
62+
variants: [
63+
// Double-quoted string
64+
{ begin: '"', end: '[^\\\\]"' },
65+
],
66+
relevance: 0
67+
},
68+
{
69+
className: 'title',
70+
variants: [
71+
{ begin: '@' + identifier },
72+
{ begin: '@\\d+' },
73+
{ begin: '!' + identifier },
74+
{ begin: '!\\d+' + identifier }
75+
]
76+
},
77+
{
78+
className: 'symbol',
79+
variants: [
80+
{ begin: '%' + identifier },
81+
{ begin: '%\\d+' },
82+
{ begin: '#\\d+' },
83+
]
84+
},
85+
{
86+
className: 'number',
87+
variants: [
88+
{ begin: '0[xX][a-fA-F0-9]+' },
89+
{ begin: '-?\\d+(?:[.]\\d+)?(?:[eE][-+]?\\d+(?:[.]\\d+)?)?' }
90+
],
91+
relevance: 0
92+
},
93+
]
94+
};
95+
}

test/detect/llvm/default.txt

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
; ModuleID = 'test.c'
2+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3+
target triple = "x86_64-unknown-linux-gnu"
4+
5+
%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i64, i32, [20 x i8] }
6+
%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 }
7+
%struct.what = type { i8, i16 }
8+
9+
@.str = private unnamed_addr constant [6 x i8] c"foo()\00", align 1
10+
@e_long = common global i64 0, align 8
11+
@g_double = common global double 0.000000e+00, align 8
12+
@.str.1 = private unnamed_addr constant [7 x i8] c"oooooh\00", align 1
13+
@func_ptr = common global i32 (...)* null, align 8
14+
@.str.2 = private unnamed_addr constant [8 x i8] c"success\00", align 1
15+
@.str.3 = private unnamed_addr constant [9 x i8] c"FizzBuzz\00", align 1
16+
@.str.4 = private unnamed_addr constant [5 x i8] c"Fizz\00", align 1
17+
@.str.5 = private unnamed_addr constant [5 x i8] c"Buzz\00", align 1
18+
@.str.6 = private unnamed_addr constant [4 x i8] c"%zd\00", align 1
19+
@.str.7 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
20+
@.str.8 = private unnamed_addr constant [12 x i8] c"%d, %c, %d\0A\00", align 1
21+
@.str.9 = private unnamed_addr constant [11 x i8] c"need args!\00", align 1
22+
@stderr = external global %struct._IO_FILE*, align 8
23+
24+
; Function Attrs: nounwind uwtable
25+
define i32 @foo() #0 {
26+
%1 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0))
27+
ret i32 0
28+
}
29+
30+
declare i32 @puts(i8*) #1
31+
32+
; Function Attrs: nounwind uwtable
33+
define i32 @main(i32 %argc, i8** %argv) #0 {
34+
%1 = alloca i32, align 4
35+
%2 = alloca i32, align 4
36+
%3 = alloca i8**, align 8
37+
%b_char = alloca i8, align 1
38+
%d_int = alloca i32, align 4
39+
%cp_char_ptr = alloca i8*, align 8
40+
%X = alloca %struct.what, align 2
41+
%i = alloca i64, align 8
42+
store i32 0, i32* %1, align 4
43+
store i32 %argc, i32* %2, align 4
44+
store i8** %argv, i8*** %3, align 8
45+
%4 = load i8**, i8*** %3, align 8
46+
%5 = load i32, i32* %2, align 4
47+
%6 = icmp eq i32 %5, 1
48+
br i1 %6, label %7, label %11
49+
50+
; <label>:7 ; preds = %0
51+
%8 = getelementptr inbounds %struct.what, %struct.what* %X, i32 0, i32 0
52+
store i8 1, i8* %8, align 2
53+
store i8 49, i8* %b_char, align 1
54+
%9 = getelementptr inbounds %struct.what, %struct.what* %X, i32 0, i32 1
55+
store i16 128, i16* %9, align 2
56+
store i32 65536, i32* %d_int, align 4
57+
store i64 2147483648, i64* @e_long, align 8
58+
store double 1.000000e+01, double* @g_double, align 8
59+
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8** %cp_char_ptr, align 8
60+
store i32 (...)* bitcast (i32 ()* @foo to i32 (...)*), i32 (...)** @func_ptr, align 8
61+
%10 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0))
62+
store i32 10, i32* %1, align 4
63+
br label %66
64+
65+
; <label>:11 ; preds = %0
66+
%12 = load i32, i32* %2, align 4
67+
%13 = icmp eq i32 %12, 2
68+
br i1 %13, label %14, label %63
69+
70+
; <label>:14 ; preds = %11
71+
store i64 0, i64* %i, align 8
72+
br label %15
73+
74+
; <label>:15 ; preds = %43, %14
75+
%16 = load i64, i64* %i, align 8
76+
%17 = icmp ult i64 %16, 100
77+
br i1 %17, label %18, label %46
78+
79+
; <label>:18 ; preds = %15
80+
%19 = load i64, i64* %i, align 8
81+
%20 = urem i64 %19, 15
82+
%21 = icmp ne i64 %20, 0
83+
br i1 %21, label %24, label %22
84+
85+
; <label>:22 ; preds = %18
86+
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0))
87+
br label %41
88+
89+
; <label>:24 ; preds = %18
90+
%25 = load i64, i64* %i, align 8
91+
%26 = urem i64 %25, 3
92+
%27 = icmp ne i64 %26, 0
93+
br i1 %27, label %30, label %28
94+
95+
; <label>:28 ; preds = %24
96+
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0))
97+
br label %40
98+
99+
; <label>:30 ; preds = %24
100+
%31 = load i64, i64* %i, align 8
101+
%32 = urem i64 %31, 5
102+
%33 = icmp ne i64 %32, 0
103+
br i1 %33, label %36, label %34
104+
105+
; <label>:34 ; preds = %30
106+
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0))
107+
br label %39
108+
109+
; <label>:36 ; preds = %30
110+
%37 = load i64, i64* %i, align 8
111+
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i64 %37)
112+
br label %39
113+
114+
; <label>:39 ; preds = %36, %34
115+
br label %40
116+
117+
; <label>:40 ; preds = %39, %28
118+
br label %41
119+
120+
; <label>:41 ; preds = %40, %22
121+
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0))
122+
br label %43
123+
124+
; <label>:43 ; preds = %41
125+
%44 = load i64, i64* %i, align 8
126+
%45 = add i64 %44, 1
127+
store i64 %45, i64* %i, align 8
128+
br label %15
129+
130+
; <label>:46 ; preds = %15
131+
%47 = getelementptr inbounds %struct.what, %struct.what* %X, i32 0, i32 0
132+
store i8 1, i8* %47, align 2
133+
store i8 49, i8* %b_char, align 1
134+
%48 = getelementptr inbounds %struct.what, %struct.what* %X, i32 0, i32 1
135+
store i16 128, i16* %48, align 2
136+
store i32 65536, i32* %d_int, align 4
137+
store i64 2147483648, i64* @e_long, align 8
138+
store double 1.000000e+01, double* @g_double, align 8
139+
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8** %cp_char_ptr, align 8
140+
store i32 (...)* bitcast (i32 ()* @foo to i32 (...)*), i32 (...)** @func_ptr, align 8
141+
%49 = getelementptr inbounds %struct.what, %struct.what* %X, i32 0, i32 0
142+
%50 = load i8, i8* %49, align 2
143+
%51 = trunc i8 %50 to i1
144+
%52 = zext i1 %51 to i32
145+
%53 = load i8, i8* %b_char, align 1
146+
%54 = sext i8 %53 to i32
147+
%55 = getelementptr inbounds %struct.what, %struct.what* %X, i32 0, i32 1
148+
%56 = load i16, i16* %55, align 2
149+
%57 = sext i16 %56 to i32
150+
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i32 0, i32 0), i32 %52, i32 %54, i32 %57)
151+
%59 = getelementptr inbounds %struct.what, %struct.what* %X, i32 0, i32 0
152+
%60 = load i8, i8* %59, align 2
153+
%61 = trunc i8 %60 to i1
154+
%62 = zext i1 %61 to i32
155+
store i32 %62, i32* %1, align 4
156+
br label %66
157+
158+
; <label>:63 ; preds = %11
159+
%64 = load %struct._IO_FILE*, %struct._IO_FILE** @stderr, align 8
160+
%65 = call i32 @fputs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i32 0, i32 0), %struct._IO_FILE* %64)
161+
store i32 -1, i32* %1, align 4
162+
br label %66
163+
164+
; <label>:66 ; preds = %63, %46, %7
165+
%67 = load i32, i32* %1, align 4
166+
ret i32 %67
167+
}
168+
169+
declare i32 @printf(i8*, ...) #1
170+
171+
declare i32 @fputs(i8*, %struct._IO_FILE*) #1
172+
173+
attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
174+
attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
175+
176+
!llvm.ident = !{!0}
177+
178+
!0 = !{!"clang version 3.8.0 (tags/RELEASE_380/final)"}

0 commit comments

Comments
 (0)