当前位置: 首页>>代码示例>>C++>>正文


C++ SmallVector::data方法代码示例

本文整理汇总了C++中SmallVector::data方法的典型用法代码示例。如果您正苦于以下问题:C++ SmallVector::data方法的具体用法?C++ SmallVector::data怎么用?C++ SmallVector::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SmallVector的用法示例。


在下文中一共展示了SmallVector::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: computeOperandsBitWidth

SDNode *VDAGToDAGISel::SelectMemAccess(SDNode *N) {
  MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1);
  MemOp[0] = cast<MemSDNode>(N)->getMemOperand();

  unsigned Opcode = VTM::VOpMemTrans;
  SmallVector<SDValue, 8> Ops;
  Ops.push_back(N->getOperand(1)); // Address
  Ops.push_back(N->getOperand(2)); // Data to store
  Ops.push_back(N->getOperand(3)); // write enable
  Ops.push_back(N->getOperand(4)); // byte enable
  if (unsigned AS = MemOp[0]->getPointerInfo().getAddrSpace()) {
    // Block RAM number.
    Ops.push_back(CurDAG->getTargetConstant(AS, MVT::i32));
    Opcode = VTM::VOpBRAMTrans;
  }
  Ops.push_back(SDValue()); //The dummy bit width operand
  Ops.push_back(CurDAG->getTargetConstant(0, MVT::i64)); //and trace number*
  Ops.push_back(N->getOperand(0));


  computeOperandsBitWidth(N, Ops.data(), Ops.size() -1 /*Skip the chain*/);
  SDNode *Ret = CurDAG->SelectNodeTo(N, Opcode, N->getVTList(),
                                     Ops.data(), Ops.size());

  cast<MachineSDNode>(Ret)->setMemRefs(MemOp, MemOp + 1);
  return Ret;
}
开发者ID:b14ckkn19ht,项目名称:Shang,代码行数:27,代码来源:VISelDAGToDAG.cpp

示例2: generateFilename

void DebugIR::generateFilename(OwningPtr<int> &fd) {
  SmallVector<char, 16> PathVec;
  fd.reset(new int);
  sys::fs::createTemporaryFile("debug-ir", "ll", *fd, PathVec);
  StringRef Path(PathVec.data(), PathVec.size());
  Filename = sys::path::filename(Path);
  sys::path::remove_filename(PathVec);
  Directory = StringRef(PathVec.data(), PathVec.size());

  GeneratedPath = true;
}
开发者ID:rui314,项目名称:llvm,代码行数:11,代码来源:DebugIR.cpp

示例3: init

bool TempFile::init(const std::string &Ext) {
    SmallVector<char, 64> Vector;
    DEBUG(dbgs() << " - create-temp-file\n");
    if (auto EC = sys::fs::createTemporaryFile("uselistorder", Ext, Vector)) {
        errs() << "verify-uselistorder: error: " << EC.message() << "\n";
        return true;
    }
    assert(!Vector.empty());

    Filename.assign(Vector.data(), Vector.data() + Vector.size());
    Remover.setFile(Filename, !SaveTemps);
    if (SaveTemps)
        outs() << " - filename = " << Filename << "\n";
    return false;
}
开发者ID:shepmaster,项目名称:llvm,代码行数:15,代码来源:verify-uselistorder.cpp

示例4: printMetadata

void printMetadata(wxTextOutputStream & out, const llvm::Value* nodeVal,
    uint32_t maxDepth) {
  if (const MDString* ms = dyn_cast<MDString>(nodeVal)) {
    out << _("\"") << toWxStr(ms->getString()) << _("\"");
  } else if (const MDNode* m = dyn_cast<MDNode>(nodeVal)) {
    if (maxDepth > 0) {
      out << _("{");
      for (unsigned i = 0; i < m->getNumOperands(); ++i) {
        if (i != 0) {
          out << _(", ");
        }
        if (maxDepth == 1 && i > 3) {
          out << _("...");
          break;
        }

        printMetadata(out, m->getOperand(i), maxDepth - 1);
      }
      out << _("}");
    } else {
      out << _("{...}");
    }
  } else if (const GlobalVariable* gv = dyn_cast<GlobalVariable>(nodeVal)) {
    out << toWxStr(gv->getName());
  } else if (const Function* fn = dyn_cast<Function>(nodeVal)) {
    out << toWxStr(fn->getName());
  } else if (const ConstantInt* ci = dyn_cast<ConstantInt>(nodeVal)) {
    SmallVector<char, 16> intVal;
    ci->getValue().toString(intVal, 10, true);
    out << toWxStr(StringRef(intVal.data(), intVal.size()));
  } else {
    out << _("???");
  }
}
开发者ID:panglong,项目名称:LLBrowse-mirror,代码行数:34,代码来源:Formatting.cpp

示例5: distribute

void RenameIndependentSubregs::distribute(const IntEqClasses &Classes,
    const SmallVectorImpl<SubRangeInfo> &SubRangeInfos,
    const SmallVectorImpl<LiveInterval*> &Intervals) const {
  unsigned NumClasses = Classes.getNumClasses();
  SmallVector<unsigned, 8> VNIMapping;
  SmallVector<LiveInterval::SubRange*, 8> SubRanges;
  BumpPtrAllocator &Allocator = LIS->getVNInfoAllocator();
  for (const SubRangeInfo &SRInfo : SubRangeInfos) {
    LiveInterval::SubRange &SR = *SRInfo.SR;
    unsigned NumValNos = SR.valnos.size();
    VNIMapping.clear();
    VNIMapping.reserve(NumValNos);
    SubRanges.clear();
    SubRanges.resize(NumClasses-1, nullptr);
    for (unsigned I = 0; I < NumValNos; ++I) {
      const VNInfo &VNI = *SR.valnos[I];
      unsigned LocalID = SRInfo.ConEQ.getEqClass(&VNI);
      unsigned ID = Classes[LocalID + SRInfo.Index];
      VNIMapping.push_back(ID);
      if (ID > 0 && SubRanges[ID-1] == nullptr)
        SubRanges[ID-1] = Intervals[ID]->createSubRange(Allocator, SR.LaneMask);
    }
    DistributeRange(SR, SubRanges.data(), VNIMapping);
  }
}
开发者ID:anupam128,项目名称:llvm,代码行数:25,代码来源:RenameIndependentSubregs.cpp

示例6: performSingleCommand

int Compilation::performSingleCommand(const Job *Cmd) {
  assert(Cmd->getInputs().empty() &&
         "This can only be used to run a single command with no inputs");

  switch (Cmd->getCondition()) {
  case Job::Condition::CheckDependencies:
    return 0;
  case Job::Condition::RunWithoutCascading:
  case Job::Condition::Always:
  case Job::Condition::NewlyAdded:
    break;
  }

  if (!writeFilelistIfNecessary(Cmd, Diags))
    return 1;

  if (Level == OutputLevel::Verbose)
    Cmd->printCommandLine(llvm::errs());

  SmallVector<const char *, 128> Argv;
  Argv.push_back(Cmd->getExecutable());
  Argv.append(Cmd->getArguments().begin(), Cmd->getArguments().end());
  Argv.push_back(0);

  const char *ExecPath = Cmd->getExecutable();
  const char **argv = Argv.data();

  for (auto &envPair : Cmd->getExtraEnvironment())
    setenv(envPair.first, envPair.second, /*replacing=*/true);

  return ExecuteInPlace(ExecPath, argv);
}
开发者ID:0x4d4746h,项目名称:swift,代码行数:32,代码来源:Compilation.cpp

示例7: removeAttr

AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
#ifndef NDEBUG
  // FIXME it is not obvious how this should work for alignment.
  // For now, say we can't pass in alignment, which no current use does.
  assert(!(Attrs & Attribute::Alignment) && "Attempt to exclude alignment!");
#endif
  if (AttrList == 0) return AttrListPtr();
  
  Attributes OldAttrs = getAttributes(Idx);
  Attributes NewAttrs = OldAttrs & ~Attrs;
  if (NewAttrs == OldAttrs)
    return *this;

  SmallVector<AttributeWithIndex, 8> NewAttrList;
  const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
  unsigned i = 0, e = OldAttrList.size();
  
  // Copy attributes for arguments before this one.
  for (; i != e && OldAttrList[i].Index < Idx; ++i)
    NewAttrList.push_back(OldAttrList[i]);
  
  // If there are attributes already at this index, merge them in.
  assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
  Attrs = OldAttrList[i].Attrs & ~Attrs;
  ++i;
  if (Attrs)  // If any attributes left for this parameter, add them.
    NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
  
  // Copy attributes for arguments after this one.
  NewAttrList.insert(NewAttrList.end(), 
                     OldAttrList.begin()+i, OldAttrList.end());
  
  return get(NewAttrList.data(), NewAttrList.size());
}
开发者ID:pombredanne,项目名称:llvm-mirror,代码行数:34,代码来源:Attributes.cpp

示例8: main

int main(int argc_, const char *argv_[]) {
  // Print a stack trace if we signal out.
  sys::PrintStackTraceOnErrorSignal();
  PrettyStackTraceProgram X(argc_, argv_);

  SmallVector<const char *, 256> argv;
  SpecificBumpPtrAllocator<char> ArgAllocator;
  std::error_code EC = sys::Process::GetArgumentVector(
      argv, makeArrayRef(argv_, argc_), ArgAllocator);
  if (EC) {
    errs() << "error: couldn't get arguments: " << EC.message() << '\n';
    return 1;
  }

  llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.

  cl::ParseCommandLineOptions(argv.size(), argv.data(), "LLVM PDB Dumper\n");
  if (opts::Lines)
    opts::Compilands = true;

  if (opts::All) {
    opts::Compilands = true;
    opts::Symbols = true;
    opts::Globals = true;
    opts::Types = true;
    opts::Externals = true;
    opts::Lines = true;
  }

  // When adding filters for excluded compilands and types, we need to remember
  // that these are regexes.  So special characters such as * and \ need to be
  // escaped in the regex.  In the case of a literal \, this means it needs to
  // be escaped again in the C++.  So matching a single \ in the input requires
  // 4 \es in the C++.
  if (opts::ExcludeCompilerGenerated) {
    opts::ExcludeTypes.push_back("__vc_attributes");
    opts::ExcludeCompilands.push_back("\\* Linker \\*");
  }
  if (opts::ExcludeSystemLibraries) {
    opts::ExcludeCompilands.push_back(
        "f:\\\\binaries\\\\Intermediate\\\\vctools\\\\crt_bld");
    opts::ExcludeCompilands.push_back("f:\\\\dd\\\\vctools\\\\crt");
    opts::ExcludeCompilands.push_back("d:\\\\th.obj.x86fre\\\\minkernel");
  }

#if defined(HAVE_DIA_SDK)
  CoInitializeEx(nullptr, COINIT_MULTITHREADED);
#endif

  std::for_each(opts::InputFilenames.begin(), opts::InputFilenames.end(),
                dumpInput);

#if defined(HAVE_DIA_SDK)
  CoUninitialize();
#endif

  return 0;
}
开发者ID:wgbwgb,项目名称:llvm,代码行数:58,代码来源:llvm-pdbdump.cpp

示例9: BCOS

std::unique_ptr<Module>
llvm::splitCodeGen(std::unique_ptr<Module> M,
                   ArrayRef<llvm::raw_pwrite_stream *> OSs, StringRef CPU,
                   StringRef Features, const TargetOptions &Options,
                   Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL,
                   TargetMachine::CodeGenFileType FileType,
                   bool PreserveLocals) {
  StringRef TripleStr = M->getTargetTriple();
  std::string ErrMsg;
  const Target *TheTarget = TargetRegistry::lookupTarget(TripleStr, ErrMsg);
  if (!TheTarget)
    report_fatal_error(Twine("Target not found: ") + ErrMsg);

  if (OSs.size() == 1) {
    codegen(M.get(), *OSs[0], TheTarget, CPU, Features, Options, RM, CM,
            OL, FileType);
    return M;
  }

  std::vector<thread> Threads;
  SplitModule(std::move(M), OSs.size(), [&](std::unique_ptr<Module> MPart) {
    // We want to clone the module in a new context to multi-thread the codegen.
    // We do it by serializing partition modules to bitcode (while still on the
    // main thread, in order to avoid data races) and spinning up new threads
    // which deserialize the partitions into separate contexts.
    // FIXME: Provide a more direct way to do this in LLVM.
    SmallVector<char, 0> BC;
    raw_svector_ostream BCOS(BC);
    WriteBitcodeToFile(MPart.get(), BCOS);

    llvm::raw_pwrite_stream *ThreadOS = OSs[Threads.size()];
    Threads.emplace_back(
        [TheTarget, CPU, Features, Options, RM, CM, OL, FileType,
         ThreadOS](const SmallVector<char, 0> &BC) {
          LLVMContext Ctx;
          ErrorOr<std::unique_ptr<Module>> MOrErr =
              parseBitcodeFile(MemoryBufferRef(StringRef(BC.data(), BC.size()),
                                               "<split-module>"),
                               Ctx);
          if (!MOrErr)
            report_fatal_error("Failed to read bitcode");
          std::unique_ptr<Module> MPartInCtx = std::move(MOrErr.get());

          codegen(MPartInCtx.get(), *ThreadOS, TheTarget, CPU, Features,
                  Options, RM, CM, OL, FileType);
        },
        // Pass BC using std::move to ensure that it get moved rather than
        // copied into the thread's context.
        std::move(BC));
  }, PreserveLocals);

  for (thread &T : Threads)
    T.join();

  return {};
}
开发者ID:Aspirisha,项目名称:llvm,代码行数:56,代码来源:ParallelCG.cpp

示例10: writeSectionData

void ELFObjectWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
                                       const MCAsmLayout &Layout) {
  MCSectionELF &Section = static_cast<MCSectionELF &>(Sec);
  StringRef SectionName = Section.getSectionName();

  auto &MC = Asm.getContext();
  const auto &MAI = MC.getAsmInfo();

  // Compressing debug_frame requires handling alignment fragments which is
  // more work (possibly generalizing MCAssembler.cpp:writeFragment to allow
  // for writing to arbitrary buffers) for little benefit.
  bool CompressionEnabled =
      MAI->compressDebugSections() != DebugCompressionType::None;
  if (!CompressionEnabled || !SectionName.startswith(".debug_") ||
      SectionName == ".debug_frame") {
    Asm.writeSectionData(&Section, Layout);
    return;
  }

  assert((MAI->compressDebugSections() == DebugCompressionType::Z ||
          MAI->compressDebugSections() == DebugCompressionType::GNU) &&
         "expected zlib or zlib-gnu style compression");

  SmallVector<char, 128> UncompressedData;
  raw_svector_ostream VecOS(UncompressedData);
  raw_pwrite_stream &OldStream = getStream();
  setStream(VecOS);
  Asm.writeSectionData(&Section, Layout);
  setStream(OldStream);

  SmallVector<char, 128> CompressedContents;
  if (Error E = zlib::compress(
          StringRef(UncompressedData.data(), UncompressedData.size()),
          CompressedContents)) {
    consumeError(std::move(E));
    getStream() << UncompressedData;
    return;
  }

  bool ZlibStyle = MAI->compressDebugSections() == DebugCompressionType::Z;
  if (!maybeWriteCompression(UncompressedData.size(), CompressedContents,
                             ZlibStyle, Sec.getAlignment())) {
    getStream() << UncompressedData;
    return;
  }

  if (ZlibStyle)
    // Set the compressed flag. That is zlib style.
    Section.setFlags(Section.getFlags() | ELF::SHF_COMPRESSED);
  else
    // Add "z" prefix to section name. This is zlib-gnu style.
    MC.renameELFSection(&Section, (".z" + SectionName.drop_front(1)).str());
  getStream() << CompressedContents;
}
开发者ID:MatthiasJReisinger,项目名称:llvm,代码行数:54,代码来源:ELFObjectWriter.cpp

示例11: getOrInitSelector

Selector NSAPI::getOrInitSelector(ArrayRef<StringRef> Ids,
                                  Selector &Sel) const {
  if (Sel.isNull()) {
    SmallVector<IdentifierInfo *, 4> Idents;
    for (ArrayRef<StringRef>::const_iterator
           I = Ids.begin(), E = Ids.end(); I != E; ++I)
      Idents.push_back(&Ctx.Idents.get(*I));
    Sel = Ctx.Selectors.getSelector(Idents.size(), Idents.data());
  }
  return Sel;
}
开发者ID:C0deZLee,项目名称:llvm-dsa,代码行数:11,代码来源:NSAPI.cpp

示例12: Execute

int Command::Execute(const StringRef **Redirects, std::string *ErrMsg,
                     bool *ExecutionFailed) const {
  SmallVector<const char*, 128> Argv;
  Argv.push_back(Executable);
  for (size_t i = 0, e = Arguments.size(); i != e; ++i)
    Argv.push_back(Arguments[i]);
  Argv.push_back(nullptr);

  return llvm::sys::ExecuteAndWait(Executable, Argv.data(), /*env*/ nullptr,
                                   Redirects, /*secondsToWait*/ 0,
                                   /*memoryLimit*/ 0, ErrMsg, ExecutionFailed);
}
开发者ID:MarkTseng,项目名称:clang,代码行数:12,代码来源:Job.cpp

示例13: Execute

int Command::Execute(const StringRef **Redirects, std::string *ErrMsg,
                     bool *ExecutionFailed) const {
  SmallVector<const char*, 128> Argv;

  if (ResponseFile == nullptr) {
    Argv.push_back(Executable);
    Argv.append(Arguments.begin(), Arguments.end());
    Argv.push_back(nullptr);

    return llvm::sys::ExecuteAndWait(Executable, Argv.data(), /*env*/ nullptr,
                                     Redirects, /*secondsToWait*/ 0,
                                     /*memoryLimit*/ 0, ErrMsg,
                                     ExecutionFailed);
  }

  // We need to put arguments in a response file (command is too large)
  // Open stream to store the response file contents
  std::string RespContents;
  llvm::raw_string_ostream SS(RespContents);

  // Write file contents and build the Argv vector
  writeResponseFile(SS);
  buildArgvForResponseFile(Argv);
  Argv.push_back(nullptr);
  SS.flush();

  // Save the response file in the appropriate encoding
  if (std::error_code EC = writeFileWithEncoding(
          ResponseFile, RespContents, Creator.getResponseFileEncoding())) {
    if (ErrMsg)
      *ErrMsg = EC.message();
    if (ExecutionFailed)
      *ExecutionFailed = true;
    return -1;
  }

  return llvm::sys::ExecuteAndWait(Executable, Argv.data(), /*env*/ nullptr,
                                   Redirects, /*secondsToWait*/ 0,
                                   /*memoryLimit*/ 0, ErrMsg, ExecutionFailed);
}
开发者ID:apurtell,项目名称:llvm-clang,代码行数:40,代码来源:Job.cpp

示例14: EmitResultCode

void MatcherGen::EmitResultCode() {
  // Patterns that match nodes with (potentially multiple) chain inputs have to
  // merge them together into a token factor.  This informs the generated code
  // what all the chained nodes are.
  if (!MatchedChainNodes.empty())
    AddMatcher(new EmitMergeInputChainsMatcher
               (MatchedChainNodes.data(), MatchedChainNodes.size()));

  // Codegen the root of the result pattern, capturing the resulting values.
  SmallVector<unsigned, 8> Ops;
  EmitResultOperand(Pattern.getDstPattern(), Ops);

  // At this point, we have however many values the result pattern produces.
  // However, the input pattern might not need all of these.  If there are
  // excess values at the end (such as implicit defs of condition codes etc)
  // just lop them off.  This doesn't need to worry about glue or chains, just
  // explicit results.
  //
  unsigned NumSrcResults = Pattern.getSrcPattern()->getNumTypes();

  // If the pattern also has (implicit) results, count them as well.
  if (!Pattern.getDstRegs().empty()) {
    // If the root came from an implicit def in the instruction handling stuff,
    // don't re-add it.
    Record *HandledReg = 0;
    const TreePatternNode *DstPat = Pattern.getDstPattern();
    if (!DstPat->isLeaf() &&DstPat->getOperator()->isSubClassOf("Instruction")){
      const CodeGenTarget &CGT = CGP.getTargetInfo();
      CodeGenInstruction &II = CGT.getInstruction(DstPat->getOperator());

      if (II.HasOneImplicitDefWithKnownVT(CGT) != MVT::Other)
        HandledReg = II.ImplicitDefs[0];
    }

    for (unsigned i = 0; i != Pattern.getDstRegs().size(); ++i) {
      Record *Reg = Pattern.getDstRegs()[i];
      if (!Reg->isSubClassOf("Register") || Reg == HandledReg) continue;
      ++NumSrcResults;
    }
  }

  assert(Ops.size() >= NumSrcResults && "Didn't provide enough results");
  Ops.resize(NumSrcResults);

  // If the matched pattern covers nodes which define a glue result, emit a node
  // that tells the matcher about them so that it can update their results.
  if (!MatchedGlueResultNodes.empty())
    AddMatcher(new MarkGlueResultsMatcher(MatchedGlueResultNodes.data(),
                                          MatchedGlueResultNodes.size()));

  AddMatcher(new CompleteMatchMatcher(Ops.data(), Ops.size(), Pattern));
}
开发者ID:pombredanne,项目名称:llvm-mirror,代码行数:52,代码来源:DAGISelMatcherGen.cpp

示例15: GetBuiltinType

Type ASTContext::GetBuiltinType(unsigned Id, GetBuiltinTypeError &Error,
                                unsigned *IntegerConstantArgs) const {
  const char *TypeStr = BuiltinInfo.GetTypeString(Id);
  SmallVector<Type, 8> ArgTypes;
  bool RequiresICE = false;
  Error = GE_None;
  Type ResType = DecodeTypeFromStr(TypeStr, *this, Error, RequiresICE,
                                   true);
  if (Error != GE_None)
    return Type();

  assert(!RequiresICE && "Result of intrinsic cannot be required to be an ICE");

  while (TypeStr[0] && TypeStr[0] != '.') {
    Type Ty = DecodeTypeFromStr(TypeStr, *this, Error, RequiresICE, true);
    if (Error != GE_None)
      return Type();

    // If this argument is required to be an IntegerConstantExpression and the
    // caller cares, fill in the bitmask we return.
    if (RequiresICE && IntegerConstantArgs)
      *IntegerConstantArgs |= 1 << ArgTypes.size();

    // Do array -> pointer decay.  The builtin should use the decayed type.
//		if (Ty->isArrayType())
//			Ty = getArrayDecayedType(Ty);
    ArgTypes.push_back(Ty);
  }

  assert((TypeStr[0] != '.' || TypeStr[1] == 0)
         && "'.' should only occur at end of builtin type list!");

  FunctionType::ExtInfo EI;
  if (BuiltinInfo.isNoReturn(Id))
    EI = EI.withNoReturn(true);

  bool Variadic = (TypeStr[0] == '.');

  // We really shouldn't be making a no-proto type here, especially in C++.
  if (ArgTypes.empty() && Variadic) {
    return getFunctionNoProtoType(ResType, EI);
  }

  FunctionProtoType::ExtProtoInfo EPI;
  EPI.ExtInfo = EI;
  EPI.Variadic = Variadic;

  return getFunctionType(ResType, ArgTypes.data(), ArgTypes.size(), EPI);
}
开发者ID:YabinHu,项目名称:mlang,代码行数:49,代码来源:ASTContext.cpp


注:本文中的SmallVector::data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。