Deal with call return values.
authorBrian Gaeke <gaeke@uiuc.edu>
Tue, 6 Apr 2004 22:09:23 +0000 (22:09 +0000)
committerBrian Gaeke <gaeke@uiuc.edu>
Tue, 6 Apr 2004 22:09:23 +0000 (22:09 +0000)
Don't put NOPs in delay slots at all. We'll have a fix-up pass later.

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

lib/Target/Sparc/InstSelectSimple.cpp
lib/Target/Sparc/SparcV8ISelSimple.cpp
lib/Target/SparcV8/InstSelectSimple.cpp
lib/Target/SparcV8/SparcV8ISelSimple.cpp

index 05a1920946d1a857e06fed87d2514c3198ce8a52..8ae5a0c27cff462ae9df9ce719b1b496291e21a6 100644 (file)
@@ -229,8 +229,22 @@ bool V8ISel::runOnFunction(Function &Fn) {
 
 void V8ISel::visitCallInst(CallInst &I) {
   assert (I.getNumOperands () == 1 && "Can't handle call args yet");
+  unsigned DestReg = getReg (I);
   BuildMI (BB, V8::CALL, 1).addPCDisp (I.getOperand (0));
-  BuildMI (BB, V8::NOP, 0); // NOP in delay slot
+  if (I.getType ()->getPrimitiveID () == Type::VoidTyID)
+    return;
+  // Deal w/ return value
+  switch (getClass (I.getType ())) {
+    case cByte:
+    case cShort:
+    case cInt:
+      // Schlep it over into the destination register
+      BuildMI (BB, V8::ORrr, 2, DestReg).addReg(V8::G0).addReg(V8::O0);
+      break;
+    default:
+      visitInstruction (I);
+      return;
+  }
 }
 
 void V8ISel::visitReturnInst(ReturnInst &I) {
index 05a1920946d1a857e06fed87d2514c3198ce8a52..8ae5a0c27cff462ae9df9ce719b1b496291e21a6 100644 (file)
@@ -229,8 +229,22 @@ bool V8ISel::runOnFunction(Function &Fn) {
 
 void V8ISel::visitCallInst(CallInst &I) {
   assert (I.getNumOperands () == 1 && "Can't handle call args yet");
+  unsigned DestReg = getReg (I);
   BuildMI (BB, V8::CALL, 1).addPCDisp (I.getOperand (0));
-  BuildMI (BB, V8::NOP, 0); // NOP in delay slot
+  if (I.getType ()->getPrimitiveID () == Type::VoidTyID)
+    return;
+  // Deal w/ return value
+  switch (getClass (I.getType ())) {
+    case cByte:
+    case cShort:
+    case cInt:
+      // Schlep it over into the destination register
+      BuildMI (BB, V8::ORrr, 2, DestReg).addReg(V8::G0).addReg(V8::O0);
+      break;
+    default:
+      visitInstruction (I);
+      return;
+  }
 }
 
 void V8ISel::visitReturnInst(ReturnInst &I) {
index 05a1920946d1a857e06fed87d2514c3198ce8a52..8ae5a0c27cff462ae9df9ce719b1b496291e21a6 100644 (file)
@@ -229,8 +229,22 @@ bool V8ISel::runOnFunction(Function &Fn) {
 
 void V8ISel::visitCallInst(CallInst &I) {
   assert (I.getNumOperands () == 1 && "Can't handle call args yet");
+  unsigned DestReg = getReg (I);
   BuildMI (BB, V8::CALL, 1).addPCDisp (I.getOperand (0));
-  BuildMI (BB, V8::NOP, 0); // NOP in delay slot
+  if (I.getType ()->getPrimitiveID () == Type::VoidTyID)
+    return;
+  // Deal w/ return value
+  switch (getClass (I.getType ())) {
+    case cByte:
+    case cShort:
+    case cInt:
+      // Schlep it over into the destination register
+      BuildMI (BB, V8::ORrr, 2, DestReg).addReg(V8::G0).addReg(V8::O0);
+      break;
+    default:
+      visitInstruction (I);
+      return;
+  }
 }
 
 void V8ISel::visitReturnInst(ReturnInst &I) {
index 05a1920946d1a857e06fed87d2514c3198ce8a52..8ae5a0c27cff462ae9df9ce719b1b496291e21a6 100644 (file)
@@ -229,8 +229,22 @@ bool V8ISel::runOnFunction(Function &Fn) {
 
 void V8ISel::visitCallInst(CallInst &I) {
   assert (I.getNumOperands () == 1 && "Can't handle call args yet");
+  unsigned DestReg = getReg (I);
   BuildMI (BB, V8::CALL, 1).addPCDisp (I.getOperand (0));
-  BuildMI (BB, V8::NOP, 0); // NOP in delay slot
+  if (I.getType ()->getPrimitiveID () == Type::VoidTyID)
+    return;
+  // Deal w/ return value
+  switch (getClass (I.getType ())) {
+    case cByte:
+    case cShort:
+    case cInt:
+      // Schlep it over into the destination register
+      BuildMI (BB, V8::ORrr, 2, DestReg).addReg(V8::G0).addReg(V8::O0);
+      break;
+    default:
+      visitInstruction (I);
+      return;
+  }
 }
 
 void V8ISel::visitReturnInst(ReturnInst &I) {