diff options
| author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2003-06-23 02:13:57 +0000 |
|---|---|---|
| committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2003-06-23 02:13:57 +0000 |
| commit | 50b1d41ad4fc5292f20801e6b07c2a2a61bcf85e (patch) | |
| tree | f618b9d32a454ac3f160213af2e529ac669e46b9 /llvm/lib/Target/Sparc | |
| parent | 0c78f3fb146334110dee713fef5b88b88ee2d6a8 (diff) | |
| download | bcm5719-llvm-50b1d41ad4fc5292f20801e6b07c2a2a61bcf85e.tar.gz bcm5719-llvm-50b1d41ad4fc5292f20801e6b07c2a2a61bcf85e.zip | |
Add the padding needed for variable-size alloca's, which should work now.
llvm-svn: 6859
Diffstat (limited to 'llvm/lib/Target/Sparc')
| -rw-r--r-- | llvm/lib/Target/Sparc/SparcInstrSelection.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/llvm/lib/Target/Sparc/SparcInstrSelection.cpp b/llvm/lib/Target/Sparc/SparcInstrSelection.cpp index e5ea7e82b2d..6576ef96cec 100644 --- a/llvm/lib/Target/Sparc/SparcInstrSelection.cpp +++ b/llvm/lib/Target/Sparc/SparcInstrSelection.cpp @@ -1051,19 +1051,27 @@ CreateCodeForVariableSizeAlloca(const TargetMachine& target, Value* tsizeVal = ConstantSInt::get(Type::IntTy, tsize); // Create temporary values to hold the result of MUL, SLL, SRL - // THIS CASE IS INCOMPLETE AND WILL BE FIXED SHORTLY. + // To pad `size' to next smallest multiple of 16: + // size = (size + 15) & (-16 = 0xfffffffffffffff0) + // TmpInstruction* tmpProd = new TmpInstruction(mcfi,numElementsVal, tsizeVal); - TmpInstruction* tmpSLL = new TmpInstruction(mcfi,numElementsVal, tmpProd); - TmpInstruction* tmpSRL = new TmpInstruction(mcfi,numElementsVal, tmpSLL); + TmpInstruction* tmpAdd15= new TmpInstruction(mcfi,numElementsVal, tmpProd); + TmpInstruction* tmpAndf0= new TmpInstruction(mcfi,numElementsVal, tmpAdd15); // Instruction 1: mul numElements, typeSize -> tmpProd // This will optimize the MUL as far as possible. - CreateMulInstruction(target, F, numElementsVal, tsizeVal, tmpProd,getMvec, + CreateMulInstruction(target, F, numElementsVal, tsizeVal, tmpProd, getMvec, mcfi, INVALID_MACHINE_OPCODE); - assert(0 && "Need to insert padding instructions here!"); + // Instruction 2: andn tmpProd, 0x0f -> tmpAndn + getMvec.push_back(BuildMI(V9::ADDi, 3).addReg(tmpProd).addSImm(15) + .addReg(tmpAdd15, MOTy::Def)); + + // Instruction 3: add tmpAndn, 0x10 -> tmpAdd16 + getMvec.push_back(BuildMI(V9::ANDi, 3).addReg(tmpAdd15).addSImm(-16) + .addReg(tmpAndf0, MOTy::Def)); - totalSizeVal = tmpProd; + totalSizeVal = tmpAndf0; } // Get the constant offset from SP for dynamically allocated storage |

