llvm.org GIT mirror llvm / 437b240
update_mir_test_checks: Accept IR as input as well as MIR We need to handle IR for tests that want to do lowering (or just -stop-after with IR as input). I've run this on one AArch64 test to demonstrate what it looks like. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321048 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Bogner 2 years ago
2 changed file(s) with 93 addition(s) and 47 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
1 ; RUN: llc -mtriple=aarch64-linux-gnu -O0 -global-isel -stop-after=irtranslator -o - %s | FileCheck %s
12
23 %type = type [4 x {i8, i32}]
34
45 define %type* @first_offset_const(%type* %addr) {
5 ; CHECK-LABEL: name: first_offset_const
6 ; CHECK: [[BASE:%[0-9]+]]:_(p0) = COPY %x0
7 ; CHECK: [[OFFSET:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
8 ; CHECK: [[RES:%[0-9]+]]:_(p0) = G_GEP [[BASE]], [[OFFSET]](s64)
9 ; CHECK: %x0 = COPY [[RES]](p0)
106
7 ; CHECK-LABEL: name: first_offset_const
8 ; CHECK: bb.1 (%ir-block.0):
9 ; CHECK: liveins: %x0
10 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY %x0
11 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
12 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[C]](s64)
13 ; CHECK: %x0 = COPY [[GEP]](p0)
14 ; CHECK: RET_ReallyLR implicit %x0
1115 %res = getelementptr %type, %type* %addr, i32 1
1216 ret %type* %res
1317 }
1418
1519 define %type* @first_offset_trivial(%type* %addr) {
16 ; CHECK-LABEL: name: first_offset_trivial
17 ; CHECK: [[BASE:%[0-9]+]]:_(p0) = COPY %x0
18 ; CHECK: [[TRIVIAL:%[0-9]+]]:_(p0) = COPY [[BASE]](p0)
19 ; CHECK: %x0 = COPY [[TRIVIAL]](p0)
2020
21 ; CHECK-LABEL: name: first_offset_trivial
22 ; CHECK: bb.1 (%ir-block.0):
23 ; CHECK: liveins: %x0
24 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY %x0
25 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY [[COPY]](p0)
26 ; CHECK: %x0 = COPY [[COPY1]](p0)
27 ; CHECK: RET_ReallyLR implicit %x0
2128 %res = getelementptr %type, %type* %addr, i32 0
2229 ret %type* %res
2330 }
2431
2532 define %type* @first_offset_variable(%type* %addr, i64 %idx) {
26 ; CHECK-LABEL: name: first_offset_variable
27 ; CHECK: [[BASE:%[0-9]+]]:_(p0) = COPY %x0
28 ; CHECK: [[IDX:%[0-9]+]]:_(s64) = COPY %x1
29 ; CHECK: [[SIZE:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
30 ; CHECK: [[OFFSET:%[0-9]+]]:_(s64) = G_MUL [[SIZE]], [[IDX]]
31 ; CHECK: [[STEP0:%[0-9]+]]:_(p0) = G_GEP [[BASE]], [[OFFSET]](s64)
32 ; CHECK: [[RES:%[0-9]+]]:_(p0) = COPY [[STEP0]](p0)
33 ; CHECK: %x0 = COPY [[RES]](p0)
3433
34 ; CHECK-LABEL: name: first_offset_variable
35 ; CHECK: bb.1 (%ir-block.0):
36 ; CHECK: liveins: %x0, %x1
37 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY %x0
38 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY %x1
39 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
40 ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C]], [[COPY1]]
41 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[MUL]](s64)
42 ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[GEP]](p0)
43 ; CHECK: %x0 = COPY [[COPY2]](p0)
44 ; CHECK: RET_ReallyLR implicit %x0
3545 %res = getelementptr %type, %type* %addr, i64 %idx
3646 ret %type* %res
3747 }
3848
3949 define %type* @first_offset_ext(%type* %addr, i32 %idx) {
40 ; CHECK-LABEL: name: first_offset_ext
41 ; CHECK: [[BASE:%[0-9]+]]:_(p0) = COPY %x0
42 ; CHECK: [[IDX32:%[0-9]+]]:_(s32) = COPY %w1
43 ; CHECK: [[SIZE:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
44 ; CHECK: [[IDX64:%[0-9]+]]:_(s64) = G_SEXT [[IDX32]](s32)
45 ; CHECK: [[OFFSET:%[0-9]+]]:_(s64) = G_MUL [[SIZE]], [[IDX64]]
46 ; CHECK: [[STEP0:%[0-9]+]]:_(p0) = G_GEP [[BASE]], [[OFFSET]](s64)
47 ; CHECK: [[RES:%[0-9]+]]:_(p0) = COPY [[STEP0]](p0)
48 ; CHECK: %x0 = COPY [[RES]](p0)
4950
51 ; CHECK-LABEL: name: first_offset_ext
52 ; CHECK: bb.1 (%ir-block.0):
53 ; CHECK: liveins: %w1, %x0
54 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY %x0
55 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY %w1
56 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
57 ; CHECK: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[COPY1]](s32)
58 ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C]], [[SEXT]]
59 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[MUL]](s64)
60 ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[GEP]](p0)
61 ; CHECK: %x0 = COPY [[COPY2]](p0)
62 ; CHECK: RET_ReallyLR implicit %x0
5063 %res = getelementptr %type, %type* %addr, i32 %idx
5164 ret %type* %res
5265 }
5366
5467 %type1 = type [4 x [4 x i32]]
5568 define i32* @const_then_var(%type1* %addr, i64 %idx) {
56 ; CHECK-LABEL: name: const_then_var
57 ; CHECK: [[BASE:%[0-9]+]]:_(p0) = COPY %x0
58 ; CHECK: [[IDX:%[0-9]+]]:_(s64) = COPY %x1
59 ; CHECK: [[OFFSET1:%[0-9]+]]:_(s64) = G_CONSTANT i64 272
60 ; CHECK: [[SIZE:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
61 ; CHECK: [[BASE1:%[0-9]+]]:_(p0) = G_GEP [[BASE]], [[OFFSET1]](s64)
62 ; CHECK: [[OFFSET2:%[0-9]+]]:_(s64) = G_MUL [[SIZE]], [[IDX]]
63 ; CHECK: [[BASE2:%[0-9]+]]:_(p0) = G_GEP [[BASE1]], [[OFFSET2]](s64)
64 ; CHECK: [[RES:%[0-9]+]]:_(p0) = COPY [[BASE2]](p0)
65 ; CHECK: %x0 = COPY [[RES]](p0)
6669
70 ; CHECK-LABEL: name: const_then_var
71 ; CHECK: bb.1 (%ir-block.0):
72 ; CHECK: liveins: %x0, %x1
73 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY %x0
74 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY %x1
75 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 272
76 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
77 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[C]](s64)
78 ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C1]], [[COPY1]]
79 ; CHECK: [[GEP1:%[0-9]+]]:_(p0) = G_GEP [[GEP]], [[MUL]](s64)
80 ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[GEP1]](p0)
81 ; CHECK: %x0 = COPY [[COPY2]](p0)
82 ; CHECK: RET_ReallyLR implicit %x0
6783 %res = getelementptr %type1, %type1* %addr, i32 4, i32 1, i64 %idx
6884 ret i32* %res
6985 }
7086
7187 define i32* @var_then_const(%type1* %addr, i64 %idx) {
72 ; CHECK-LABEL: name: var_then_const
73 ; CHECK: [[BASE:%[0-9]+]]:_(p0) = COPY %x0
74 ; CHECK: [[IDX:%[0-9]+]]:_(s64) = COPY %x1
75 ; CHECK: [[SIZE:%[0-9]+]]:_(s64) = G_CONSTANT i64 64
76 ; CHECK: [[OFFSET2:%[0-9]+]]:_(s64) = G_CONSTANT i64 40
77 ; CHECK: [[OFFSET1:%[0-9]+]]:_(s64) = G_MUL [[SIZE]], [[IDX]]
78 ; CHECK: [[BASE1:%[0-9]+]]:_(p0) = G_GEP [[BASE]], [[OFFSET1]](s64)
79 ; CHECK: [[BASE2:%[0-9]+]]:_(p0) = G_GEP [[BASE1]], [[OFFSET2]](s64)
80 ; CHECK: %x0 = COPY [[BASE2]](p0)
8188
89 ; CHECK-LABEL: name: var_then_const
90 ; CHECK: bb.1 (%ir-block.0):
91 ; CHECK: liveins: %x0, %x1
92 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY %x0
93 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY %x1
94 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 64
95 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 40
96 ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C]], [[COPY1]]
97 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[MUL]](s64)
98 ; CHECK: [[GEP1:%[0-9]+]]:_(p0) = G_GEP [[GEP]], [[C1]](s64)
99 ; CHECK: %x0 = COPY [[GEP1]](p0)
100 ; CHECK: RET_ReallyLR implicit %x0
82101 %res = getelementptr %type1, %type1* %addr, i64 %idx, i32 2, i32 2
83102 ret i32* %res
84103 }
4141 r'= (?P[A-Zt][A-Za-z0-9_]+)'.format(VREG_RE.pattern))
4242 MIR_PREFIX_DATA_RE = re.compile(r'^ *(;|bb.[0-9].*: *$|[a-z]+:( |$)|$)')
4343 VREG_CLASS_RE = re.compile(r'^ *- *{ id: ([0-9]+), class: ([a-z0-9_]+)', re.M)
44
45 IR_FUNC_NAME_RE = re.compile(
46 r'^\s*define\s+(?:internal\s+)?[^@]*@(?P\w+)\s*\(')
47 IR_PREFIX_DATA_RE = re.compile(r'^ *(;|$)')
4448
4549 MIR_FUNC_RE = re.compile(
4650 r'^---$'
339343 warn('Ignoring common prefixes: {}'.format(common_prefixes),
340344 test_file=test)
341345
342 autogenerated_note = ('# NOTE: Assertions have been autogenerated by '
343 'utils/{}'.format(os.path.basename(__file__)))
346 comment_char = '#' if test.endswith('.mir') else ';'
347 autogenerated_note = ('{} NOTE: Assertions have been autogenerated by '
348 'utils/{}'.format(comment_char,
349 os.path.basename(__file__)))
344350 output_lines = []
345351 output_lines.append(autogenerated_note)
346352
349355 continue
350356
351357 if state == 'toplevel':
358 m = IR_FUNC_NAME_RE.match(input_line)
359 if m:
360 state = 'ir function prefix'
361 func_name = m.group('func')
352362 if input_line.strip() == '---':
353363 state = 'document'
354364 output_lines.append(input_line)
391401 func_name = None
392402 if should_add_line_to_output(input_line, prefix_set):
393403 output_lines.append(input_line)
404 elif state == 'ir function prefix':
405 m = IR_PREFIX_DATA_RE.match(input_line)
406 if not m:
407 state = 'ir function body'
408 add_checks_for_function(test, output_lines, run_list,
409 func_dict, func_name, add_vreg_checks,
410 single_bb=False, verbose=verbose)
411
412 if should_add_line_to_output(input_line, prefix_set):
413 output_lines.append(input_line)
414 elif state == 'ir function body':
415 if input_line.strip() == '}':
416 state = 'toplevel'
417 func_name = None
418 if should_add_line_to_output(input_line, prefix_set):
419 output_lines.append(input_line)
420
394421
395422 log('Writing {} lines to {}...'.format(len(output_lines), test), verbose)
396423