Chromium Code Reviews| Index: src/PNaClTranslator.cpp |
| diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp |
| index f315294b21dd4a53f5096017aaefa5ce3a765716..79759016fee089844f6b3178b165a3c0cea84f0e 100644 |
| --- a/src/PNaClTranslator.cpp |
| +++ b/src/PNaClTranslator.cpp |
| @@ -1510,6 +1510,22 @@ void FunctionParser::ProcessRecord() { |
| InstIsTerminating = true; |
| break; |
| } |
| + case naclbitc::FUNC_CODE_INST_ALLOCA: { |
| + // ALLOCA: [Size, align] |
| + if (!isValidRecordSize(2, "function block alloca")) return; |
|
jvoung (off chromium)
2014/09/05 16:55:04
return on separate line
Karl
2014/09/08 21:16:23
Done.
|
| + Ice::Operand *ByteCount = getRelativeOperand(Values[0]); |
| + if (ByteCount->getType() != Ice::IceType_i32) { |
| + std::string Buffer; |
| + raw_string_ostream StrBuf(Buffer); |
| + StrBuf << "Alloca on non-i32 value. Found: " << ByteCount; |
| + Error(StrBuf.str()); |
| + return; |
| + } |
| + unsigned Align = static_cast<unsigned>(Values[1]); |
|
jvoung (off chromium)
2014/09/05 16:55:04
Should probably check that Align <= 29 or so? I th
Karl
2014/09/08 21:16:23
Good point.
|
| + Ice::Variable *Dest = NextInstVar(Context->getIcePointerType()); |
| + Inst = Ice::InstAlloca::create(Func, ByteCount, (1 << Align) >> 1, Dest); |
|
Jim Stichnoth
2014/09/05 23:03:39
Any reason why it isn't (1<<(Align-1)) as opposed
Karl
2014/09/08 21:16:23
In LLVM and PNaCl, 0 is allowed, and hence the spe
|
| + break; |
| + } |
| default: |
| // Generate error message! |
| BlockParserBaseClass::ProcessRecord(); |