Chromium Code Reviews| Index: src/PNaClTranslator.cpp |
| diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp |
| index 5bfa33bd7f2dc0f495e00b2ca22d8f8306a27def..6ecd546bdc3c5c60c69761b84b63c312e5575f9d 100644 |
| --- a/src/PNaClTranslator.cpp |
| +++ b/src/PNaClTranslator.cpp |
| @@ -845,6 +845,8 @@ private: |
| // True if the last processed instruction was a terminating |
| // instruction. |
| bool InstIsTerminating; |
| + // Upper limit of alignment power allowed by LLVM |
| + static const uint64_t AlignPowerLimit = 29; |
| virtual bool ParseBlock(unsigned BlockID) LLVM_OVERRIDE; |
| @@ -1515,6 +1517,34 @@ void FunctionParser::ProcessRecord() { |
| InstIsTerminating = true; |
| break; |
| } |
| + case naclbitc::FUNC_CODE_INST_ALLOCA: { |
| + // ALLOCA: [Size, align] |
| + if (!isValidRecordSize(2, "function block alloca")) |
| + return; |
| + 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 AlignPower = Values[1]; |
| + unsigned Alignment = 1; |
| + if (AlignPower <= AlignPowerLimit) { |
| + Alignment = (1 << static_cast<unsigned>(AlignPower)) >> 1; |
|
jvoung (off chromium)
2014/09/08 23:31:23
Isn't AlignPower already "unsigned" (cast was orig
Jim Stichnoth
2014/09/08 23:54:40
static_cast<> is unnecessary.
Karl
2014/09/10 17:29:59
Actually, I meant to make AlignPower uint64_t. Oth
Karl
2014/09/10 17:29:59
See other comment for line.
|
| + } else { |
| + std::string Buffer; |
| + raw_string_ostream StrBuf(Buffer); |
| + StrBuf << "Alloca on alignment greater than 2**" << AlignPowerLimit |
| + << ". Found: 2**" << AlignPower; |
| + Error(StrBuf.str()); |
| + // TODO(kschimpf) Remove error recovery once implementation complete. |
| + } |
| + Ice::Variable *Dest = NextInstVar(Context->getIcePointerType()); |
| + Inst = Ice::InstAlloca::create(Func, ByteCount, Alignment, Dest); |
| + break; |
| + } |
| default: |
| // Generate error message! |
| BlockParserBaseClass::ProcessRecord(); |