Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Unified Diff: src/PNaClTranslator.cpp

Issue 545623005: Add alloca instruction to Subzero bitcode reader. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests_lit/reader_tests/alloc.ll » ('j') | tests_lit/reader_tests/alloc.ll » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | tests_lit/reader_tests/alloc.ll » ('j') | tests_lit/reader_tests/alloc.ll » ('J')

Powered by Google App Engine
This is Rietveld 408576698