.Case("implicit", MIToken::kw_implicit)
.Case("implicit-def", MIToken::kw_implicit_define)
.Case("dead", MIToken::kw_dead)
+ .Case("killed", MIToken::kw_killed)
.Default(MIToken::Identifier);
}
kw_implicit,
kw_implicit_define,
kw_dead,
+ kw_killed,
// Identifier tokens
Identifier,
}
bool isRegisterFlag() const {
- return Kind == kw_implicit || Kind == kw_implicit_define || Kind == kw_dead;
+ return Kind == kw_implicit || Kind == kw_implicit_define ||
+ Kind == kw_dead || Kind == kw_killed;
}
bool is(TokenKind K) const { return Kind == K; }
case MIToken::kw_dead:
Flags |= RegState::Dead;
break;
+ case MIToken::kw_killed:
+ Flags |= RegState::Kill;
+ break;
// TODO: report an error when we specify the same flag more than once.
// TODO: parse the other register flags.
default:
return true;
lex();
// TODO: Parse subregister.
- Dest = MachineOperand::CreateReg(Reg, Flags & RegState::Define,
- Flags & RegState::Implicit, /*IsKill=*/false,
- Flags & RegState::Dead);
+ Dest = MachineOperand::CreateReg(
+ Reg, Flags & RegState::Define, Flags & RegState::Implicit,
+ Flags & RegState::Kill, Flags & RegState::Dead);
return false;
}
case MIToken::kw_implicit:
case MIToken::kw_implicit_define:
case MIToken::kw_dead:
+ case MIToken::kw_killed:
case MIToken::underscore:
case MIToken::NamedRegister:
return parseRegisterOperand(Dest);
OS << (Op.isDef() ? "implicit-def " : "implicit ");
if (Op.isDead())
OS << "dead ";
+ if (Op.isKill())
+ OS << "killed ";
printReg(Op.getReg(), OS, TRI);
// TODO: Print sub register.
break;
--- /dev/null
+# RUN: llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s | FileCheck %s
+# This test ensures that the MIR parser parses the 'killed' register flags
+# correctly.
+
+--- |
+
+ define i32 @foo(i32 %a) {
+ entry:
+ %0 = icmp sle i32 %a, 10
+ br i1 %0, label %less, label %exit
+
+ less:
+ ret i32 0
+
+ exit:
+ ret i32 %a
+ }
+
+...
+---
+name: foo
+body:
+ - id: 0
+ name: entry
+ instructions:
+ - 'CMP32ri8 %edi, 10, implicit-def %eflags'
+ - 'JG_1 %bb.2.exit, implicit %eflags'
+ - id: 1
+ name: less
+ instructions:
+ # CHECK: - '%eax = MOV32r0
+ # CHECK-NEXT: - 'RETQ killed %eax
+ - '%eax = MOV32r0 implicit-def %eflags'
+ - 'RETQ killed %eax'
+ - id: 2
+ name: exit
+ instructions:
+ # CHECK: - '%eax = COPY killed %edi
+ # CHECK-NEXT: - 'RETQ killed %eax
+ - '%eax = COPY killed %edi'
+ - 'RETQ killed %eax'
+...