Add a new method which enables one to change register classes.
authorReed Kotler <rkotler@mips.com>
Thu, 14 Mar 2013 22:02:09 +0000 (22:02 +0000)
committerReed Kotler <rkotler@mips.com>
Thu, 14 Mar 2013 22:02:09 +0000 (22:02 +0000)
See the Mips16ISetLowering.cpp patch to see a use of this.
For now now the extra code in Mips16ISetLowering.cpp is a nop but is
used for test purposes. Mips32 registers are setup and then removed and
then the Mips16 registers are setup.

Normally you need to add register classes and then call
computeRegisterProperties.

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

include/llvm/Target/TargetLowering.h
lib/Target/Mips/Mips16ISelLowering.cpp

index e3e57373001e735e413ecf0ace45666a33646e75..5d74848b71c7acfabd788226156ded0601081627 100644 (file)
@@ -958,6 +958,13 @@ protected:
     RegClassForVT[VT.SimpleTy] = RC;
   }
 
+  /// clearRegisterClasses - remove all register classes
+  void clearRegisterClasses() {
+    for (unsigned i = 0 ; i<array_lengthof(RegClassForVT); i++)
+      RegClassForVT[i] = 0;
+    AvailableRegClasses.clear();
+  }
+
   /// findRepresentativeClass - Return the largest legal super-reg register class
   /// of the register class for the specified type and its associated "cost".
   virtual std::pair<const TargetRegisterClass*, uint8_t>
index 6de62cfab3b1b289f18516ec68c79c2bc0f4b477..23eb5375ac94bc921566e5a269b565d41c46c208 100644 (file)
@@ -39,6 +39,14 @@ namespace {
 
 Mips16TargetLowering::Mips16TargetLowering(MipsTargetMachine &TM)
   : MipsTargetLowering(TM) {
+  //
+  // set up as if mips32 and then revert so we can test the mechanism
+  // for switching
+  addRegisterClass(MVT::i32, &Mips::CPURegsRegClass);
+  addRegisterClass(MVT::f32, &Mips::FGR32RegClass);
+  computeRegisterProperties();
+  clearRegisterClasses();
+
   // Set up the register classes
   addRegisterClass(MVT::i32, &Mips::CPU16RegsRegClass);