Added "LoadEffective" pattern to handle stack locations.
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Mon, 24 Sep 2007 20:15:11 +0000 (20:15 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Mon, 24 Sep 2007 20:15:11 +0000 (20:15 +0000)
Fixed some comments

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42271 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/MipsAsmPrinter.cpp
lib/Target/Mips/MipsISelDAGToDAG.cpp
lib/Target/Mips/MipsInstrInfo.td

index 11db54753c116cdcb36fa02d1702b94052bf184c..254cc563c9c43ba17200bcc76df20cc40c81f189 100644 (file)
@@ -141,7 +141,7 @@ emitMaskDirective(MachineFunction &MF)
   #endif
 
   unsigned int Bitmask = getSavedRegsBitmask(false, MF);
-  O << "\t.mask\t"; 
+  O << "\t.mask \t"; 
   printHex32(Bitmask);
   O << "," << Offset << "\n";
 }
@@ -366,9 +366,16 @@ printOperand(const MachineInstr *MI, int opNum)
 void MipsAsmPrinter::
 printMemOperand(const MachineInstr *MI, int opNum, const char *Modifier) 
 {
-  // lw/sw $reg, MemOperand
-  // will turn into :
-  // lw/sw $reg, imm($reg)
+  // when using stack locations for not load/store instructions
+  // print the same way as all normal 3 operand instructions.
+  if (Modifier && !strcmp(Modifier, "stackloc")) {
+    printOperand(MI, opNum+1);
+    O << ", ";
+    printOperand(MI, opNum);
+    return;
+  }
+
+  // Load/Store memory operands -- imm($reg)
   printOperand(MI, opNum);
   O << "(";
   printOperand(MI, opNum+1);
index 80477d56d521d510f312b7ea141123dea13d9869..85fa640bb096c50b10b1a3d0b62422109aa9b540 100644 (file)
@@ -196,8 +196,8 @@ Select(SDOperand N)
   }
 
   ///
-  // Instruction Selection not handled by custom or by the 
-  // auto-generated tablegen selection should be handled here
+  // Instruction Selection not handled by the auto-generated 
+  // tablegen selection should be handled here.
   /// 
   switch(Opcode) {
 
index b1f975482aaa93b9f35089b285c3ac8f2f110b4a..a7c406014063ad5009e7627c5a815c06108bfb51 100644 (file)
@@ -332,6 +332,12 @@ class CountLeading<bits<6> func, string instr_asm>:
       !strconcat(instr_asm, " $dst, $src"), 
       [], IIAlu>;
 
+class EffectiveAddress<string instr_asm> : 
+  FI<0x09, 
+     (outs CPURegs:$dst), 
+     (ins mem:$addr),
+     instr_asm,
+     [(set CPURegs:$dst, addr:$addr)], IIAlu>;
 
 //===----------------------------------------------------------------------===//
 // Pseudo instructions
@@ -468,6 +474,12 @@ let isReturn=1, isTerminator=1, hasDelaySlot=1,
                 "jr $target", [(MipsRet CPURegs:$target)], IIBranch>;
 }
 
+// FrameIndexes are legalized when they are operands from load/store 
+// instructions. The same not happens for stack address copies, so an
+// add op with mem ComplexPattern is used and the stack address copy
+// can be matched. It's similar to Sparc LEA_ADDRi
+def LEA_ADDiu : EffectiveAddress<"addiu $dst, ${addr:stackloc}">;
+
 //===----------------------------------------------------------------------===//
 //  Arbitrary patterns that map to one or more instructions
 //===----------------------------------------------------------------------===//