llvm.org GIT mirror llvm / 03dcd3c
MIR Serialization: Serialize the 'killed' register machine operand flag. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241734 91177308-0d34-0410-b5e6-96231b3b80d8 Alex Lorenz 5 years ago
5 changed file(s) with 55 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
7070 .Case("implicit", MIToken::kw_implicit)
7171 .Case("implicit-def", MIToken::kw_implicit_define)
7272 .Case("dead", MIToken::kw_dead)
73 .Case("killed", MIToken::kw_killed)
7374 .Default(MIToken::Identifier);
7475 }
7576
3939 kw_implicit,
4040 kw_implicit_define,
4141 kw_dead,
42 kw_killed,
4243
4344 // Identifier tokens
4445 Identifier,
7475 }
7576
7677 bool isRegisterFlag() const {
77 return Kind == kw_implicit || Kind == kw_implicit_define || Kind == kw_dead;
78 return Kind == kw_implicit || Kind == kw_implicit_define ||
79 Kind == kw_dead || Kind == kw_killed;
7880 }
7981
8082 bool is(TokenKind K) const { return Kind == K; }
307307 case MIToken::kw_dead:
308308 Flags |= RegState::Dead;
309309 break;
310 case MIToken::kw_killed:
311 Flags |= RegState::Kill;
312 break;
310313 // TODO: report an error when we specify the same flag more than once.
311314 // TODO: parse the other register flags.
312315 default:
329332 return true;
330333 lex();
331334 // TODO: Parse subregister.
332 Dest = MachineOperand::CreateReg(Reg, Flags & RegState::Define,
333 Flags & RegState::Implicit, /*IsKill=*/false,
334 Flags & RegState::Dead);
335 Dest = MachineOperand::CreateReg(
336 Reg, Flags & RegState::Define, Flags & RegState::Implicit,
337 Flags & RegState::Kill, Flags & RegState::Dead);
335338 return false;
336339 }
337340
416419 case MIToken::kw_implicit:
417420 case MIToken::kw_implicit_define:
418421 case MIToken::kw_dead:
422 case MIToken::kw_killed:
419423 case MIToken::underscore:
420424 case MIToken::NamedRegister:
421425 return parseRegisterOperand(Dest);
217217 OS << (Op.isDef() ? "implicit-def " : "implicit ");
218218 if (Op.isDead())
219219 OS << "dead ";
220 if (Op.isKill())
221 OS << "killed ";
220222 printReg(Op.getReg(), OS, TRI);
221223 // TODO: Print sub register.
222224 break;
0 # RUN: llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s | FileCheck %s
1 # This test ensures that the MIR parser parses the 'killed' register flags
2 # correctly.
3
4 --- |
5
6 define i32 @foo(i32 %a) {
7 entry:
8 %0 = icmp sle i32 %a, 10
9 br i1 %0, label %less, label %exit
10
11 less:
12 ret i32 0
13
14 exit:
15 ret i32 %a
16 }
17
18 ...
19 ---
20 name: foo
21 body:
22 - id: 0
23 name: entry
24 instructions:
25 - 'CMP32ri8 %edi, 10, implicit-def %eflags'
26 - 'JG_1 %bb.2.exit, implicit %eflags'
27 - id: 1
28 name: less
29 instructions:
30 # CHECK: - '%eax = MOV32r0
31 # CHECK-NEXT: - 'RETQ killed %eax
32 - '%eax = MOV32r0 implicit-def %eflags'
33 - 'RETQ killed %eax'
34 - id: 2
35 name: exit
36 instructions:
37 # CHECK: - '%eax = COPY killed %edi
38 # CHECK-NEXT: - 'RETQ killed %eax
39 - '%eax = COPY killed %edi'
40 - 'RETQ killed %eax'
41 ...