Reed Kotler
2013-Mar-14 07:35 UTC
[LLVMdev] initial putback for implementing mips16/nomips16 attributes - please review
I added one method which clears the list of register classes. Then there is a change to mips16 code which simulates switching from mips32 to mips16 mode in the same module. It seems to work fine in that I can run this version of llvm for mips16 and it works identical to the one without this code. Beyond the "make check" I have run test-suite against this version. We could just putback the change to include/llvm/Target/TargetLowering.h but by adding the change to lib/Target/Mips/Mips16ISelLowering.cpp which is a nop for the mips16 compiler, we are able to test that this feature works and that doing things this way allows one to change register sets on a per function basis. The idea here is to add two of the mips32 register sets (including float point which should have a big effect on things) and then computeRegisterProperties() and then revert things to mips16 only registers and call computeRegisterProperties() again. I have several more patches I will need to complete this mips16/nomips16 feature but it's easier to do this in pieces. In the end I will remove this testing code from lib/Target/Mips/Mips16ISelLowering.cpp and create a real test case for this. For now this test code shows how this feature can work for other ports like Arm than have a similar need. -------------- next part -------------- diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index e3e5737..e45b792 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -958,6 +958,14 @@ protected: RegClassForVT[VT.SimpleTy] = RC; } + /// clearRegisterClasses - remove all register classes + void clearRegisterClasses() { + for (unsigned i = 0 ; i<array_lengthof(RegClassForVT); i++) + RegClassForVT[i] = 0; + while (!AvailableRegClasses.empty()) + AvailableRegClasses.pop_back(); + } + /// 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> diff --git a/lib/Target/Mips/Mips16ISelLowering.cpp b/lib/Target/Mips/Mips16ISelLowering.cpp index 6de62cf..23eb537 100644 --- a/lib/Target/Mips/Mips16ISelLowering.cpp +++ b/lib/Target/Mips/Mips16ISelLowering.cpp @@ -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);
Apparently Analagous Threads
- [LLVMdev] void TargetLoweringBase::computeRegisterProperties
- Registers for i128 data type not registered in X86
- [LLVMdev] proposed change to class BasicTTI and dual mode mips16/32 working
- [LLVMdev] Lowering operations to 8-bit!
- [LLVMdev] Lowering operations to 8-bit!