[llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp X86InstrInfo.def

Chris Lattner lattner at cs.uiuc.edu
Fri Nov 29 06:03:01 PST 2002


Changes in directory llvm/lib/Target/X86:

InstSelectSimple.cpp updated: 1.38 -> 1.39
X86InstrInfo.def updated: 1.27 -> 1.28

---
Log message:

brg

InstSelectSimple.cpp: First draft of visitCallInst method, handling
 int/float args.
X86InstrInfo.def: Add entries for CALL with 32-bit pc relative arg, and
 PUSH with 32-bit reg arg.


---
Diffs of the changes:

Index: llvm/lib/Target/X86/InstSelectSimple.cpp
diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.38 llvm/lib/Target/X86/InstSelectSimple.cpp:1.39
--- llvm/lib/Target/X86/InstSelectSimple.cpp:1.38	Tue Nov 26 04:43:30 2002
+++ llvm/lib/Target/X86/InstSelectSimple.cpp	Fri Nov 29 06:01:58 2002
@@ -363,10 +363,30 @@
     }
 }
 
-/// visitCallInst - Have to push args and do a procedure call
-/// instruction, if the target address is known.
-void ISel::visitCallInst (CallInst &CI) {
-  visitInstruction (CI);
+/// visitCallInst - Push args on stack and do a procedure call instruction.
+void
+ISel::visitCallInst (CallInst & CI)
+{
+  // Push the arguments on the stack in reverse order, as specified by
+  // the ABI.
+  for (unsigned i = CI.getNumOperands (); i >= 1; --i)
+    {
+      Value *v = CI.getOperand (i);
+      unsigned argReg = getReg (v);
+      switch (getClass (v->getType ()))
+	{
+	case cInt:
+	case cFloat:
+	  BuildMI (BB, X86::PUSHr32, 1).addReg (argReg);
+	  break;
+	default:
+	  // FIXME
+	  visitInstruction (CI);
+	  break;
+	}
+    }
+  // Emit a CALL instruction with PC-relative displacement.
+  BuildMI (BB, X86::CALLpcrel32, 1).addPCDisp (CI.getCalledValue ());
 }
 
 /// visitSimpleBinary - Implement simple binary operators for integral types...


Index: llvm/lib/Target/X86/X86InstrInfo.def
diff -u llvm/lib/Target/X86/X86InstrInfo.def:1.27 llvm/lib/Target/X86/X86InstrInfo.def:1.28
--- llvm/lib/Target/X86/X86InstrInfo.def:1.27	Thu Nov 21 16:49:46 2002
+++ llvm/lib/Target/X86/X86InstrInfo.def	Fri Nov 29 06:01:58 2002
@@ -39,6 +39,7 @@
 I(JMP         , "jmp",   0xE9, M_BRANCH_FLAG, X86II::Void)                       // jmp foo
 I(JNE         , "jne",   0x85, M_BRANCH_FLAG, X86II::TB | X86II::Void)
 I(JE          , "je",    0x84, M_BRANCH_FLAG, X86II::TB | X86II::Void)
+I(CALLpcrel32 , "call",  0xE8, M_BRANCH_FLAG, X86II::Void)
 
 // Misc instructions
 I(LEAVE       , "leave", 0xC9,             0, X86II::RawFrm)                     // leave
@@ -57,6 +58,8 @@
 I(MOVrm16     , "movw",  0x89,             0, X86II::MRMDestMem | X86II::Void |  // [mem] = R16  89/r
                                               X86II::OpSize)
 I(MOVrm32     , "movl",  0x89,             0, X86II::MRMDestMem | X86II::Void)   // [mem] = R32  89/r
+
+I(PUSHr32     , "pushl", 0x50,             0, X86II::AddRegFrm | X86II::Void)
 
 // Arithmetic instructions
 I(ADDrr8      , "addb",  0x00,             0, X86II::MRMDestReg)                 // R8  += R8





More information about the llvm-commits mailing list