Forráskód Böngészése

[MIR] Allow frame-setup and frame-destroy on the same instruction

Nothing prevents us from having both frame-setup and frame-destroy on
the same instruction.

When merging:
* frame-setup OPCODE1
* frame-destroy OPCODE2
into
* frame-setup frame-destroy OPCODE3

we want to be able to print and parse both flags.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327442 91177308-0d34-0410-b5e6-96231b3b80d8
Francis Visoiu Mistrih 7 éve
szülő
commit
12d5807d03

+ 7 - 5
lib/CodeGen/MIRParser/MIParser.cpp

@@ -923,11 +923,13 @@ bool MIParser::verifyImplicitOperands(ArrayRef<ParsedMachineOperand> Operands,
 }
 
 bool MIParser::parseInstruction(unsigned &OpCode, unsigned &Flags) {
-  if (Token.is(MIToken::kw_frame_setup)) {
-    Flags |= MachineInstr::FrameSetup;
-    lex();
-  } else if (Token.is(MIToken::kw_frame_destroy)) {
-    Flags |= MachineInstr::FrameDestroy;
+  // Allow both:
+  // * frame-setup frame-destroy OPCODE
+  // * frame-destroy frame-setup OPCODE
+  while (Token.is(MIToken::kw_frame_setup) ||
+         Token.is(MIToken::kw_frame_destroy)) {
+    Flags |= Token.is(MIToken::kw_frame_setup) ? MachineInstr::FrameSetup
+                                               : MachineInstr::FrameDestroy;
     lex();
   }
   if (Token.isNot(MIToken::Identifier))

+ 1 - 1
lib/CodeGen/MIRPrinter.cpp

@@ -672,7 +672,7 @@ void MIPrinter::print(const MachineInstr &MI) {
     OS << " = ";
   if (MI.getFlag(MachineInstr::FrameSetup))
     OS << "frame-setup ";
-  else if (MI.getFlag(MachineInstr::FrameDestroy))
+  if (MI.getFlag(MachineInstr::FrameDestroy))
     OS << "frame-destroy ";
 
   OS << TII->getName(MI.getOpcode());

+ 1 - 1
lib/CodeGen/MachineInstr.cpp

@@ -1292,7 +1292,7 @@ void MachineInstr::print(raw_ostream &OS, ModuleSlotTracker &MST,
 
   if (getFlag(MachineInstr::FrameSetup))
     OS << "frame-setup ";
-  else if (getFlag(MachineInstr::FrameDestroy))
+  if (getFlag(MachineInstr::FrameDestroy))
     OS << "frame-destroy ";
 
   // Print the opcode name.

+ 4 - 0
test/CodeGen/MIR/X86/frame-setup-instruction-flag.mir

@@ -32,5 +32,9 @@ body: |
     CALL64pcrel32 @compute, csr_64, implicit $rsp, implicit $edi, implicit-def $rsp, implicit-def $eax
     ; CHECK: $rdx = frame-destroy POP64r
     $rdx = frame-destroy POP64r implicit-def $rsp, implicit $rsp
+    ; CHECK: $rdx = frame-setup frame-destroy POP64r
+    $rdx = frame-setup frame-destroy POP64r implicit-def $rsp, implicit $rsp
+    ; CHECK: $rdx = frame-setup frame-destroy POP64r
+    $rdx = frame-destroy frame-setup POP64r implicit-def $rsp, implicit $rsp
     RETQ $eax
 ...