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

Side by Side Diff: src/PNaClTranslator.cpp

Issue 904783002: Subzero: Convert a few getName() methods to return a const string ref. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « src/IceOperand.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
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 // This file implements the PNaCl bitcode file to Ice, to machine code 10 // This file implements the PNaCl bitcode file to Ice, to machine code
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 bool IsUndefined = false; 287 bool IsUndefined = false;
288 if (ID < FcnIDSize) { 288 if (ID < FcnIDSize) {
289 Decl = FunctionDeclarationList[ID]; 289 Decl = FunctionDeclarationList[ID];
290 const auto Func = llvm::cast<Ice::FunctionDeclaration>(Decl); 290 const auto Func = llvm::cast<Ice::FunctionDeclaration>(Decl);
291 IsUndefined = Func->isProto(); 291 IsUndefined = Func->isProto();
292 } else if ((ID - FcnIDSize) < VariableDeclarations.size()) { 292 } else if ((ID - FcnIDSize) < VariableDeclarations.size()) {
293 Decl = VariableDeclarations[ID - FcnIDSize]; 293 Decl = VariableDeclarations[ID - FcnIDSize];
294 const auto Var = llvm::cast<Ice::VariableDeclaration>(Decl); 294 const auto Var = llvm::cast<Ice::VariableDeclaration>(Decl);
295 IsUndefined = !Var->hasInitializer(); 295 IsUndefined = !Var->hasInitializer();
296 } 296 }
297 std::string Name; 297 Ice::IceString Name;
298 bool SuppressMangling; 298 bool SuppressMangling;
299 if (Decl) { 299 if (Decl) {
300 Name = Decl->getName(); 300 Name = Decl->getName();
301 SuppressMangling = Decl->getSuppressMangling(); 301 SuppressMangling = Decl->getSuppressMangling();
302 } else { 302 } else {
303 std::string Buffer; 303 std::string Buffer;
304 raw_string_ostream StrBuf(Buffer); 304 raw_string_ostream StrBuf(Buffer);
305 StrBuf << "Reference to global not defined: " << ID; 305 StrBuf << "Reference to global not defined: " << ID;
306 BlockError(StrBuf.str()); 306 BlockError(StrBuf.str());
307 // TODO(kschimpf) Remove error recovery once implementation complete. 307 // TODO(kschimpf) Remove error recovery once implementation complete.
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 if (C == nullptr) 1501 if (C == nullptr)
1502 return VectorIndexNotConstant; 1502 return VectorIndexNotConstant;
1503 if (static_cast<size_t>(C->getValue()) >= typeNumElements(VecType)) 1503 if (static_cast<size_t>(C->getValue()) >= typeNumElements(VecType))
1504 return VectorIndexNotInRange; 1504 return VectorIndexNotInRange;
1505 if (Index->getType() != Ice::IceType_i32) 1505 if (Index->getType() != Ice::IceType_i32)
1506 return VectorIndexNotI32; 1506 return VectorIndexNotI32;
1507 return VectorIndexValid; 1507 return VectorIndexValid;
1508 } 1508 }
1509 1509
1510 // Returns true if the Str begins with Prefix. 1510 // Returns true if the Str begins with Prefix.
1511 bool isStringPrefix(Ice::IceString &Str, Ice::IceString &Prefix) { 1511 bool isStringPrefix(const Ice::IceString &Str, const Ice::IceString &Prefix) {
1512 const size_t PrefixSize = Prefix.size(); 1512 const size_t PrefixSize = Prefix.size();
1513 if (Str.size() < PrefixSize) 1513 if (Str.size() < PrefixSize)
1514 return false; 1514 return false;
1515 for (size_t i = 0; i < PrefixSize; ++i) { 1515 for (size_t i = 0; i < PrefixSize; ++i) {
1516 if (Str[i] != Prefix[i]) 1516 if (Str[i] != Prefix[i])
1517 return false; 1517 return false;
1518 } 1518 }
1519 return true; 1519 return true;
1520 } 1520 }
1521 1521
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
2439 Ice::Operand *Callee = getOperand(CalleeIndex); 2439 Ice::Operand *Callee = getOperand(CalleeIndex);
2440 Ice::Type ReturnType = Ice::IceType_void; 2440 Ice::Type ReturnType = Ice::IceType_void;
2441 const Ice::Intrinsics::FullIntrinsicInfo *IntrinsicInfo = nullptr; 2441 const Ice::Intrinsics::FullIntrinsicInfo *IntrinsicInfo = nullptr;
2442 if (Record.GetCode() == naclbitc::FUNC_CODE_INST_CALL) { 2442 if (Record.GetCode() == naclbitc::FUNC_CODE_INST_CALL) {
2443 Ice::FunctionDeclaration *Fcn = Context->getFunctionByID(CalleeIndex); 2443 Ice::FunctionDeclaration *Fcn = Context->getFunctionByID(CalleeIndex);
2444 const Ice::FuncSigType &Signature = Fcn->getSignature(); 2444 const Ice::FuncSigType &Signature = Fcn->getSignature();
2445 ReturnType = Signature.getReturnType(); 2445 ReturnType = Signature.getReturnType();
2446 2446
2447 // Check if this direct call is to an Intrinsic (starts with "llvm.") 2447 // Check if this direct call is to an Intrinsic (starts with "llvm.")
2448 static Ice::IceString LLVMPrefix("llvm."); 2448 static Ice::IceString LLVMPrefix("llvm.");
2449 Ice::IceString Name = Fcn->getName(); 2449 const Ice::IceString &Name = Fcn->getName();
2450 if (isStringPrefix(Name, LLVMPrefix)) { 2450 if (isStringPrefix(Name, LLVMPrefix)) {
2451 Ice::IceString Suffix = Name.substr(LLVMPrefix.size()); 2451 Ice::IceString Suffix = Name.substr(LLVMPrefix.size());
2452 IntrinsicInfo = 2452 IntrinsicInfo =
2453 getTranslator().getContext()->getIntrinsicsInfo().find(Suffix); 2453 getTranslator().getContext()->getIntrinsicsInfo().find(Suffix);
2454 if (!IntrinsicInfo) { 2454 if (!IntrinsicInfo) {
2455 std::string Buffer; 2455 std::string Buffer;
2456 raw_string_ostream StrBuf(Buffer); 2456 raw_string_ostream StrBuf(Buffer);
2457 StrBuf << "Invalid PNaCl intrinsic call to " << Name; 2457 StrBuf << "Invalid PNaCl intrinsic call to " << Name;
2458 Error(StrBuf.str()); 2458 Error(StrBuf.str());
2459 appendErrorInstruction(ReturnType); 2459 appendErrorInstruction(ReturnType);
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
3021 3021
3022 if (TopLevelBlocks != 1) { 3022 if (TopLevelBlocks != 1) {
3023 errs() << IRFilename 3023 errs() << IRFilename
3024 << ": Contains more than one module. Found: " << TopLevelBlocks 3024 << ": Contains more than one module. Found: " << TopLevelBlocks
3025 << "\n"; 3025 << "\n";
3026 ErrorStatus.assign(EC_Bitcode); 3026 ErrorStatus.assign(EC_Bitcode);
3027 } 3027 }
3028 } 3028 }
3029 3029
3030 } // end of namespace Ice 3030 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceOperand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698