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

Side by Side Diff: lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp

Issue 221693002: PNaCl: Add support for GCC/LLVM vector extensions (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Address dschuff's comments. Created 6 years, 8 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 unified diff | Download patch
OLDNEW
1 //===--- Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp - Bitcode Writer -------===// 1 //===--- Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp - Bitcode Writer -------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // Bitcode writer implementation. 10 // Bitcode writer implementation.
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 switch (T->getTypeID()) { 278 switch (T->getTypeID()) {
279 default: llvm_unreachable("Unknown type!"); 279 default: llvm_unreachable("Unknown type!");
280 case Type::VoidTyID: Code = naclbitc::TYPE_CODE_VOID; break; 280 case Type::VoidTyID: Code = naclbitc::TYPE_CODE_VOID; break;
281 case Type::FloatTyID: Code = naclbitc::TYPE_CODE_FLOAT; break; 281 case Type::FloatTyID: Code = naclbitc::TYPE_CODE_FLOAT; break;
282 case Type::DoubleTyID: Code = naclbitc::TYPE_CODE_DOUBLE; break; 282 case Type::DoubleTyID: Code = naclbitc::TYPE_CODE_DOUBLE; break;
283 case Type::IntegerTyID: 283 case Type::IntegerTyID:
284 // INTEGER: [width] 284 // INTEGER: [width]
285 Code = naclbitc::TYPE_CODE_INTEGER; 285 Code = naclbitc::TYPE_CODE_INTEGER;
286 TypeVals.push_back(cast<IntegerType>(T)->getBitWidth()); 286 TypeVals.push_back(cast<IntegerType>(T)->getBitWidth());
287 break; 287 break;
288 case Type::VectorTyID: {
289 VectorType *VT = cast<VectorType>(T);
290 // VECTOR [numelts, eltty]
291 Code = naclbitc::TYPE_CODE_VECTOR;
292 TypeVals.push_back(VT->getNumElements());
293 TypeVals.push_back(VE.getTypeID(VT->getElementType()));
294 break;
295 }
288 case Type::FunctionTyID: { 296 case Type::FunctionTyID: {
289 FunctionType *FT = cast<FunctionType>(T); 297 FunctionType *FT = cast<FunctionType>(T);
290 // FUNCTION: [isvararg, retty, paramty x N] 298 // FUNCTION: [isvararg, retty, paramty x N]
291 Code = naclbitc::TYPE_CODE_FUNCTION; 299 Code = naclbitc::TYPE_CODE_FUNCTION;
292 TypeVals.push_back(FT->isVarArg()); 300 TypeVals.push_back(FT->isVarArg());
293 TypeVals.push_back(VE.getTypeID(FT->getReturnType())); 301 TypeVals.push_back(VE.getTypeID(FT->getReturnType()));
294 for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) 302 for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i)
295 TypeVals.push_back(VE.getTypeID(FT->getParamType(i))); 303 TypeVals.push_back(VE.getTypeID(FT->getParamType(i)));
296 AbbrevToUse = TYPE_FUNCTION_ABBREV; 304 AbbrevToUse = TYPE_FUNCTION_ABBREV;
297 break; 305 break;
298 } 306 }
299 case Type::StructTyID: 307 case Type::StructTyID:
300 report_fatal_error("Struct types are not supported in PNaCl bitcode"); 308 report_fatal_error("Struct types are not supported in PNaCl bitcode");
301 case Type::ArrayTyID: 309 case Type::ArrayTyID:
302 report_fatal_error("Array types are not supported in PNaCl bitcode"); 310 report_fatal_error("Array types are not supported in PNaCl bitcode");
303 case Type::VectorTyID:
304 report_fatal_error("Vector types are not supported in PNaCl bitcode");
305 } 311 }
306 312
307 // Emit the finished record. 313 // Emit the finished record.
308 Stream.EmitRecord(Code, TypeVals, AbbrevToUse); 314 Stream.EmitRecord(Code, TypeVals, AbbrevToUse);
309 TypeVals.clear(); 315 TypeVals.clear();
310 } 316 }
311 317
312 Stream.ExitBlock(); 318 Stream.ExitBlock();
313 DEBUG(dbgs() << "<- WriteTypeTable\n"); 319 DEBUG(dbgs() << "<- WriteTypeTable\n");
314 } 320 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 } else { 644 } else {
639 ReportIllegalValue("instruction", I); 645 ReportIllegalValue("instruction", I);
640 } 646 }
641 break; 647 break;
642 case Instruction::Select: 648 case Instruction::Select:
643 Code = naclbitc::FUNC_CODE_INST_VSELECT; 649 Code = naclbitc::FUNC_CODE_INST_VSELECT;
644 pushValue(I.getOperand(1), InstID, Vals, VE, Stream); 650 pushValue(I.getOperand(1), InstID, Vals, VE, Stream);
645 pushValue(I.getOperand(2), InstID, Vals, VE, Stream); 651 pushValue(I.getOperand(2), InstID, Vals, VE, Stream);
646 pushValue(I.getOperand(0), InstID, Vals, VE, Stream); 652 pushValue(I.getOperand(0), InstID, Vals, VE, Stream);
647 break; 653 break;
654 case Instruction::ExtractElement:
655 Code = naclbitc::FUNC_CODE_INST_EXTRACTELT;
656 pushValue(I.getOperand(0), InstID, Vals, VE, Stream);
657 pushValue(I.getOperand(1), InstID, Vals, VE, Stream);
658 break;
659 case Instruction::InsertElement:
660 Code = naclbitc::FUNC_CODE_INST_INSERTELT;
661 pushValue(I.getOperand(0), InstID, Vals, VE, Stream);
662 pushValue(I.getOperand(1), InstID, Vals, VE, Stream);
663 pushValue(I.getOperand(2), InstID, Vals, VE, Stream);
664 break;
648 case Instruction::ICmp: 665 case Instruction::ICmp:
649 case Instruction::FCmp: 666 case Instruction::FCmp:
650 // compare returning Int1Ty or vector of Int1Ty 667 // compare returning Int1Ty or vector of Int1Ty
651 Code = naclbitc::FUNC_CODE_INST_CMP2; 668 Code = naclbitc::FUNC_CODE_INST_CMP2;
652 pushValue(I.getOperand(0), InstID, Vals, VE, Stream); 669 pushValue(I.getOperand(0), InstID, Vals, VE, Stream);
653 pushValue(I.getOperand(1), InstID, Vals, VE, Stream); 670 pushValue(I.getOperand(1), InstID, Vals, VE, Stream);
654 Vals.push_back(GetEncodedCmpPredicate(cast<CmpInst>(I))); 671 Vals.push_back(GetEncodedCmpPredicate(cast<CmpInst>(I)));
655 break; 672 break;
656 673
657 case Instruction::Ret: 674 case Instruction::Ret:
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 NaClWriteHeader(Header, Stream); 1243 NaClWriteHeader(Header, Stream);
1227 } 1244 }
1228 1245
1229 // Emit the module. 1246 // Emit the module.
1230 WriteModule(M, Stream); 1247 WriteModule(M, Stream);
1231 } 1248 }
1232 1249
1233 // Write the generated bitstream to "Out". 1250 // Write the generated bitstream to "Out".
1234 Out.write((char*)&Buffer.front(), Buffer.size()); 1251 Out.write((char*)&Buffer.front(), Buffer.size());
1235 } 1252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698