[llvm-commits] CVS: llvm/utils/TableGen/CodeGenRegisters.h CodeGenTarget.cpp CodeGenTarget.h

Chris Lattner lattner at cs.uiuc.edu
Thu Sep 8 14:43:32 PDT 2005



Changes in directory llvm/utils/TableGen:

CodeGenRegisters.h updated: 1.7 -> 1.8
CodeGenTarget.cpp updated: 1.35 -> 1.36
CodeGenTarget.h updated: 1.17 -> 1.18
---
Log message:

Compute the value types that are natively supported by a target.


---
Diffs of the changes:  (+25 -2)

 CodeGenRegisters.h |    2 ++
 CodeGenTarget.cpp  |    6 ++++++
 CodeGenTarget.h    |   19 +++++++++++++++++--
 3 files changed, 25 insertions(+), 2 deletions(-)


Index: llvm/utils/TableGen/CodeGenRegisters.h
diff -u llvm/utils/TableGen/CodeGenRegisters.h:1.7 llvm/utils/TableGen/CodeGenRegisters.h:1.8
--- llvm/utils/TableGen/CodeGenRegisters.h:1.7	Fri Aug 19 14:12:51 2005
+++ llvm/utils/TableGen/CodeGenRegisters.h	Thu Sep  8 16:43:21 2005
@@ -17,6 +17,7 @@
 
 #include <string>
 #include <vector>
+#include "llvm/CodeGen/ValueTypes.h"
 
 namespace llvm {
   class Record;
@@ -36,6 +37,7 @@
     std::vector<Record*> Elements;
     unsigned SpillSize;
     unsigned SpillAlignment;
+    MVT::ValueType VT;
     std::string MethodProtos, MethodBodies;
 
     const std::string &getName() const;


Index: llvm/utils/TableGen/CodeGenTarget.cpp
diff -u llvm/utils/TableGen/CodeGenTarget.cpp:1.35 llvm/utils/TableGen/CodeGenTarget.cpp:1.36
--- llvm/utils/TableGen/CodeGenTarget.cpp:1.35	Fri Aug 26 15:55:40 2005
+++ llvm/utils/TableGen/CodeGenTarget.cpp	Thu Sep  8 16:43:21 2005
@@ -152,6 +152,7 @@
   Namespace = R->getValueAsString("Namespace");
   SpillSize = R->getValueAsInt("Size");
   SpillAlignment = R->getValueAsInt("Alignment");
+  VT = getValueType(R->getValueAsDef("RegType"));
 
   if (CodeInit *CI = dynamic_cast<CodeInit*>(R->getValueInit("MethodBodies")))
     MethodBodies = CI->getValue();
@@ -182,6 +183,11 @@
   return TheDef->getName();
 }
 
+void CodeGenTarget::ReadLegalValueTypes() const {
+  const std::vector<CodeGenRegisterClass> &RCs = getRegisterClasses();
+  for (unsigned i = 0, e = RCs.size(); i != e; ++i)
+    LegalValueTypes.push_back(RCs[i].VT);
+}
 
 
 void CodeGenTarget::ReadInstructions() const {


Index: llvm/utils/TableGen/CodeGenTarget.h
diff -u llvm/utils/TableGen/CodeGenTarget.h:1.17 llvm/utils/TableGen/CodeGenTarget.h:1.18
--- llvm/utils/TableGen/CodeGenTarget.h:1.17	Thu Apr 21 19:00:35 2005
+++ llvm/utils/TableGen/CodeGenTarget.h	Thu Sep  8 16:43:21 2005
@@ -47,9 +47,11 @@
   mutable std::map<std::string, CodeGenInstruction> Instructions;
   mutable std::vector<CodeGenRegister> Registers;
   mutable std::vector<CodeGenRegisterClass> RegisterClasses;
+  mutable std::vector<MVT::ValueType> LegalValueTypes;
   void ReadRegisters() const;
   void ReadRegisterClasses() const;
   void ReadInstructions() const;
+  void ReadLegalValueTypes() const;
 public:
   CodeGenTarget();
 
@@ -70,16 +72,29 @@
   ///
   Record *getAsmWriter() const;
 
-  const std::vector<CodeGenRegister> &getRegisters() {
+  const std::vector<CodeGenRegister> &getRegisters() const {
     if (Registers.empty()) ReadRegisters();
     return Registers;
   }
 
-  const std::vector<CodeGenRegisterClass> getRegisterClasses() {
+  const std::vector<CodeGenRegisterClass> &getRegisterClasses() const {
     if (RegisterClasses.empty()) ReadRegisterClasses();
     return RegisterClasses;
   }
 
+  const std::vector<MVT::ValueType> &getLegalValueTypes() const {
+    if (LegalValueTypes.empty()) ReadLegalValueTypes();
+    return LegalValueTypes;
+  }
+  
+  /// isLegalValueType - Return true if the specified value type is natively
+  /// supported by the target (i.e. there are registers that directly hold it).
+  bool isLegalValueType(MVT::ValueType VT) const {
+    const std::vector<MVT::ValueType> &LegalVTs = getLegalValueTypes();
+    for (unsigned i = 0, e = LegalVTs.size(); i != e; ++i)
+      if (LegalVTs[i] == VT) return true;
+    return false;    
+  }
 
   /// getInstructions - Return all of the instructions defined for this target.
   ///






More information about the llvm-commits mailing list