diff options
author | Lauro Ramos Venancio <lauro.venancio@gmail.com> | 2007-01-12 20:35:49 +0000 |
---|---|---|
committer | Lauro Ramos Venancio <lauro.venancio@gmail.com> | 2007-01-12 20:35:49 +0000 |
commit | a38bbf7dd3b824aab6c290aec9e03e5cfdd028f5 (patch) | |
tree | 68230fad1be0de4a3927d02e1c8726f25ec2c01f /lib/Target/ARM/ARMRegisterInfo.cpp | |
parent | 609ca3e65307a955ee0eaea80ce0091e3c7967b7 (diff) |
Build constants using instructions mov/orr or mvn/eor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33141 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/ARMRegisterInfo.cpp')
-rw-r--r-- | lib/Target/ARM/ARMRegisterInfo.cpp | 75 |
1 files changed, 6 insertions, 69 deletions
diff --git a/lib/Target/ARM/ARMRegisterInfo.cpp b/lib/Target/ARM/ARMRegisterInfo.cpp index 404ebee0f4..4890e3094f 100644 --- a/lib/Target/ARM/ARMRegisterInfo.cpp +++ b/lib/Target/ARM/ARMRegisterInfo.cpp @@ -14,6 +14,7 @@ #include "ARM.h" #include "ARMRegisterInfo.h" +#include "ARMCommon.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFrameInfo.h" @@ -35,82 +36,18 @@ static bool hasFP(const MachineFunction &MF) { return NoFramePointerElim || MFI->hasVarSizedObjects(); } -static inline unsigned rotateL(unsigned x, unsigned n){ - return ((x << n) | (x >> (32 - n))); -} - -static inline unsigned rotateR(unsigned x, unsigned n){ - return ((x >> n) | (x << (32 - n))); -} - -// finds the end position of largest sequence of zeros in binary representation -// of 'immediate'. -static int findLargestZeroSequence(unsigned immediate){ - int max_zero_pos; - int max_zero_length = 0; - int zero_pos; - int zero_length; - int pos = 0; - int end_pos; - - while ((immediate & 0x3) == 0) { - immediate = rotateR(immediate, 2); - pos+=2; - } - end_pos = pos+32; - - while (pos<end_pos){ - while ((immediate & 0x3) != 0) { - immediate = rotateR(immediate, 2); - pos+=2; - } - zero_pos = pos; - while ((immediate & 0x3) == 0) { - immediate = rotateR(immediate, 2); - pos+=2; - } - zero_length = pos - zero_pos; - if (zero_length > max_zero_length){ - max_zero_length = zero_length; - max_zero_pos = zero_pos % 32; - } - - } - - return (max_zero_pos + max_zero_length) % 32; -} - static void splitInstructionWithImmediate(MachineBasicBlock &BB, MachineBasicBlock::iterator I, const TargetInstrDescriptor &TID, unsigned DestReg, unsigned OrigReg, unsigned immediate){ - - if (immediate == 0){ - BuildMI(BB, I, TID, DestReg).addReg(OrigReg).addImm(0) - .addImm(0).addImm(ARMShift::LSL); - return; - } - - int start_pos = findLargestZeroSequence(immediate); - unsigned immediate_tmp = rotateR(immediate, start_pos); - - int pos = 0; - while (pos < 32){ - while(((immediate_tmp&0x3) == 0)&&(pos<32)){ - immediate_tmp = rotateR(immediate_tmp,2); - pos+=2; - } - if (pos < 32){ - BuildMI(BB, I, TID, DestReg).addReg(OrigReg) - .addImm(rotateL(immediate_tmp&0xFF, (start_pos + pos) % 32 )) - .addImm(0).addImm(ARMShift::LSL); - immediate_tmp = rotateR(immediate_tmp,8); - pos+=8; - } + std::vector<unsigned> immediatePieces = splitImmediate(immediate); + std::vector<unsigned>::iterator it; + for (it=immediatePieces.begin(); it != immediatePieces.end(); ++it){ + BuildMI(BB, I, TID, DestReg).addReg(OrigReg) + .addImm(*it).addImm(0).addImm(ARMShift::LSL); } - } ARMRegisterInfo::ARMRegisterInfo(const TargetInstrInfo &tii) |