lib/Target/Target.td
authorEvan Cheng <evan.cheng@apple.com>
Thu, 18 May 2006 20:42:07 +0000 (20:42 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 18 May 2006 20:42:07 +0000 (20:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28386 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetInstrInfo.h
lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
utils/TableGen/InstrInfoEmitter.cpp

index 625f5c217097ad17d98f30634a2be222d61a7369..9e49a975bc11d3a24f36ba61763bbd354e4ee285 100644 (file)
@@ -76,6 +76,11 @@ const unsigned M_TERMINATOR_FLAG       = 1 << 10;
 // block.
 const unsigned M_USES_CUSTOM_DAG_SCHED_INSERTION = 1 << 11;
 
+// Machine operand flags
+// M_LOOK_UP_PTR_REG_CLASS - Set if this operand is a pointer value and it
+// requires a callback to look up its register class.
+const unsigned M_LOOK_UP_PTR_REG_CLASS = 1 << 0;
+
 /// TargetOperandInfo - This holds information about one operand of a machine
 /// instruction, indicating the register class for register operands, etc.
 ///
@@ -84,7 +89,7 @@ public:
   /// RegClass - This specifies the register class of the operand if the
   /// operand is a register.  If not, this contains null.
   const TargetRegisterClass *RegClass;
-  
+  unsigned Flags;
   /// Currently no other information.
 };
 
@@ -137,6 +142,13 @@ public:
     return get(Opcode).Name;
   }
 
+  const TargetRegisterClass
+  *getInstrOperandRegClass(const TargetInstrDescriptor *II, unsigned Op) const {
+    const TargetOperandInfo &toi = II->OpInfo[Op];
+    return (toi.Flags & M_LOOK_UP_PTR_REG_CLASS)
+           ? getPointerRegClass() : toi.RegClass;
+  }
+
   int getNumOperands(MachineOpCode Opcode) const {
     return get(Opcode).numOperands;
   }
@@ -275,6 +287,13 @@ public:
     assert(0 && "Target didn't implement insertNoop!");
     abort();
   }
+
+  /// getPointerRegClass - Returns a TargetRegisterClass used for pointer
+  /// values.
+  virtual const TargetRegisterClass *getPointerRegClass() const {
+    assert(0 && "Target didn't implement getPointerRegClass!");
+    abort();
+  }
   
   /// hasDelaySlot - Returns true if the specified instruction has a delay slot
   /// which must be filled by the code generator.
index 523062053d881f259fe4f36ab4c367b5c0c42e98..cfe5e6b0767d91711e2bf0e261ecc5ffb3a1dcbd 100644 (file)
@@ -229,16 +229,17 @@ static unsigned CountOperands(SDNode *Node) {
 static unsigned CreateVirtualRegisters(MachineInstr *MI,
                                        unsigned NumResults,
                                        SSARegMap *RegMap,
+                                       const TargetInstrInfo *TII,
                                        const TargetInstrDescriptor &II) {
   // Create the result registers for this node and add the result regs to
   // the machine instruction.
-  const TargetOperandInfo *OpInfo = II.OpInfo;
-  unsigned ResultReg = RegMap->createVirtualRegister(OpInfo[0].RegClass);
+  unsigned ResultReg =
+    RegMap->createVirtualRegister(TII->getInstrOperandRegClass(&II, 0));
   MI->addRegOperand(ResultReg, MachineOperand::Def);
   for (unsigned i = 1; i != NumResults; ++i) {
-    assert(OpInfo[i].RegClass && "Isn't a register operand!");
-    MI->addRegOperand(RegMap->createVirtualRegister(OpInfo[i].RegClass),
-                      MachineOperand::Def);
+    const TargetRegisterClass *RC = TII->getInstrOperandRegClass(&II, i);
+    assert(RC && "Isn't a register operand!");
+    MI->addRegOperand(RegMap->createVirtualRegister(RC), MachineOperand::Def);
   }
   return ResultReg;
 }
@@ -275,9 +276,9 @@ void ScheduleDAG::AddOperand(MachineInstr *MI, SDOperand Op,
     // Verify that it is right.
     assert(MRegisterInfo::isVirtualRegister(VReg) && "Not a vreg?");
     if (II) {
-      assert(II->OpInfo[IIOpNum].RegClass &&
-             "Don't have operand info for this instruction!");
-      assert(RegMap->getRegClass(VReg) == II->OpInfo[IIOpNum].RegClass &&
+      const TargetRegisterClass *RC = TII->getInstrOperandRegClass(II, IIOpNum);
+      assert(RC && "Don't have operand info for this instruction!");
+      assert(RegMap->getRegClass(VReg) == RC &&
              "Register class of operand and regclass of use don't agree!");
     }
   } else if (ConstantSDNode *C =
@@ -332,9 +333,9 @@ void ScheduleDAG::AddOperand(MachineInstr *MI, SDOperand Op,
     // Verify that it is right.
     assert(MRegisterInfo::isVirtualRegister(VReg) && "Not a vreg?");
     if (II) {
-      assert(II->OpInfo[IIOpNum].RegClass &&
-             "Don't have operand info for this instruction!");
-      assert(RegMap->getRegClass(VReg) == II->OpInfo[IIOpNum].RegClass &&
+      const TargetRegisterClass *RC = TII->getInstrOperandRegClass(II, IIOpNum);
+      assert(RC && "Don't have operand info for this instruction!");
+      assert(RegMap->getRegClass(VReg) == RC &&
              "Register class of operand and regclass of use don't agree!");
     }
   }
@@ -387,7 +388,7 @@ void ScheduleDAG::EmitNode(SDNode *Node,
     
     // Otherwise, create new virtual registers.
     if (NumResults && VRBase == 0)
-      VRBase = CreateVirtualRegisters(MI, NumResults, RegMap, II);
+      VRBase = CreateVirtualRegisters(MI, NumResults, RegMap, TII, II);
     
     // Emit all of the actual operands of this instruction, adding them to the
     // instruction as appropriate.
index a713bc330d731c9bf8b3a4c43491533123a242a7..66d17cb86bb8cdbaf29eba682034ad291cfc7c51 100644 (file)
@@ -139,11 +139,13 @@ void InstrInfoEmitter::run(std::ostream &OS) {
       for (unsigned i = 0, e = OperandInfo.size(); i != e; ++i) {
         Record *RC = OperandInfo[i];
         // FIXME: We only care about register operands for now.
-        if (RC && RC->isSubClassOf("RegisterClass")) {
-          OS << "{ &" << getQualifiedName(RC) << "RegClass }, ";
-        } else {
-          OS << "{ 0 }, ";
-        }
+        if (RC && RC->isSubClassOf("RegisterClass"))
+          OS << "{ &" << getQualifiedName(RC) << "RegClass, 0 }, ";
+        else if (RC && RC->getName() == "ptr_rc")
+          // Ptr value whose register class is resolved via callback.
+          OS << "{ 0, 1 }, ";
+        else
+          OS << "{ 0, 0 }, ";
       }
       OS << "};\n";
     }