[llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrSelection.cpp
Vikram Adve
vadve at cs.uiuc.edu
Sun Jun 22 21:15:01 PDT 2003
Changes in directory llvm/lib/Target/Sparc:
SparcInstrSelection.cpp updated: 1.102 -> 1.103
---
Log message:
Add the padding needed for variable-size alloca's, which should work now.
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp
diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.102 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.103
--- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.102 Fri Jun 6 04:52:23 2003
+++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp Sun Jun 22 21:13:57 2003
@@ -1051,19 +1051,27 @@
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));
- totalSizeVal = tmpProd;
+ // Instruction 3: add tmpAndn, 0x10 -> tmpAdd16
+ getMvec.push_back(BuildMI(V9::ANDi, 3).addReg(tmpAdd15).addSImm(-16)
+ .addReg(tmpAndf0, MOTy::Def));
+
+ totalSizeVal = tmpAndf0;
}
// Get the constant offset from SP for dynamically allocated storage
More information about the llvm-commits
mailing list