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

Unified Diff: src/PNaClTranslator.cpp

Issue 531123002: Add select instruction to Subzero bitcode reader. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. 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/select.ll » ('j') | no next file with comments »
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 12727e1ce6a9085fd2474b0107ad2a63c4159a0d..4d46d4d070f198a4b11a313f54625416419e06ee 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -1198,6 +1198,44 @@ void FunctionParser::ProcessRecord() {
Inst = Ice::InstCast::create(Func, CastKind, Dest, Src);
break;
}
+ case naclbitc::FUNC_CODE_INST_VSELECT: {
+ // VSELECT: [opval, opval, pred]
+ Ice::Operand *ThenVal = getOperand(convertRelativeToAbsIndex(Values[0]));
+ Ice::Type ThenType = ThenVal->getType();
+ Ice::Operand *ElseVal = getOperand(convertRelativeToAbsIndex(Values[1]));
+ Ice::Type ElseType = ElseVal->getType();
+ if (ThenType != ElseType) {
+ std::string Buffer;
+ raw_string_ostream StrBuf(Buffer);
+ StrBuf << "Select operands not same type. Found " << ThenType << " and "
+ << ElseType;
+ Error(StrBuf.str());
+ return;
+ }
+ Ice::Operand *CondVal = getOperand(convertRelativeToAbsIndex(Values[2]));
+ Ice::Type CondType = CondVal->getType();
+ if (isVectorType(CondType)) {
+ if (!isVectorType(ThenType) ||
+ typeElementType(CondType) != Ice::IceType_i1 ||
+ typeNumElements(ThenType) != typeNumElements(CondType)) {
+ std::string Buffer;
+ raw_string_ostream StrBuf(Buffer);
+ StrBuf << "Select condition " << CondType
+ << " not allowed for values of type " << ThenType;
+ Error(StrBuf.str());
+ return;
+ }
+ } else if (CondVal->getType() != Ice::IceType_i1) {
+ std::string Buffer;
+ raw_string_ostream StrBuf(Buffer);
+ StrBuf << "Select condition not type i1. Found: " << CondVal->getType();
+ Error(StrBuf.str());
+ return;
+ }
+ Ice::Variable *DestVal = NextInstVar(ThenType);
+ Inst = Ice::InstSelect::create(Func, DestVal, CondVal, ThenVal, ElseVal);
+ break;
+ }
case naclbitc::FUNC_CODE_INST_EXTRACTELT: {
// EXTRACTELT: [opval, opval]
Ice::Operand *Vec = getRelativeOperand(Values[0]);
« no previous file with comments | « no previous file | tests_lit/reader_tests/select.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698