diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-29 09:56:09 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-29 09:56:09 -0800 |
commit | c647ea4b19618e17e1610da3290ccfd512ef0b77 (patch) | |
tree | be4c170788571e30182a120a82590a1c478edab7 /lib/Target/CppBackend/CPPBackend.cpp | |
parent | 2245f6af32f51b136d952d8bfcc46166f667f752 (diff) |
support runtime-sized allocas
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index f8eb80c5eb..44af1e85f9 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -1668,14 +1668,14 @@ std::string CppWriter::generateInstruction(const Instruction *I) { Type *T = AI->getAllocatedType(); assert(!isa<ArrayType>(T)); const Value *AS = AI->getArraySize(); - unsigned Size = T->getScalarSizeInBits()/8; + unsigned BaseSize = T->getScalarSizeInBits()/8; + std::string Size; if (const ConstantInt *CI = dyn_cast<ConstantInt>(AS)) { - Size *= CI->getZExtValue(); + Size = Twine(memAlign(BaseSize * CI->getZExtValue())).str(); } else { - dumpIR(I); - assert(0); + Size = '(' + utostr(BaseSize) + '*' + getValueAsStr(AS) + ")|0"; } - text = getAssign(iName, Type::getInt32Ty(I->getContext())) + "STACKTOP; STACKTOP = STACKTOP + " + Twine(memAlign(Size)).str() + "|0;"; + text = getAssign(iName, Type::getInt32Ty(I->getContext())) + "STACKTOP; STACKTOP = STACKTOP + " + Size + "|0;"; break; } case Instruction::Load: { |