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


C++ targetregistry::iterator类代码示例

本文整理汇总了C++中targetregistry::iterator的典型用法代码示例。如果您正苦于以下问题:C++ iterator类的具体用法?C++ iterator怎么用?C++ iterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: TheTriple

/// selectTarget - Pick a target either via -march or by guessing the native
/// arch.  Add any CPU features specified via -mcpu or -mattr.
TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple,
        StringRef MArch,
        StringRef MCPU,
        const SmallVectorImpl<std::string>& MAttrs) {
    Triple TheTriple(TargetTriple);
    if (TheTriple.getTriple().empty())
        TheTriple.setTriple(sys::getDefaultTargetTriple());

    // Adjust the triple to match what the user requested.
    const Target *TheTarget = 0;
    if (!MArch.empty()) {
        for (TargetRegistry::iterator it = TargetRegistry::begin(),
                ie = TargetRegistry::end(); it != ie; ++it) {
            if (MArch == it->getName()) {
                TheTarget = &*it;
                break;
            }
        }

        if (!TheTarget) {
            if (ErrorStr)
                *ErrorStr = "No available targets are compatible with this -march, "
                            "see -version for the available targets.\n";
            return 0;
        }

        // Adjust the triple to match (if known), otherwise stick with the
        // requested/host triple.
        Triple::ArchType Type = Triple::getArchTypeForLLVMName(MArch);
        if (Type != Triple::UnknownArch)
            TheTriple.setArch(Type);
    } else {
        std::string Error;
        TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Error);
        if (TheTarget == 0) {
            if (ErrorStr)
                *ErrorStr = Error;
            return 0;
        }
    }

    // Package up features to be passed to target/subtarget
    std::string FeaturesStr;
    if (!MAttrs.empty()) {
        SubtargetFeatures Features;
        for (unsigned i = 0; i != MAttrs.size(); ++i)
            Features.AddFeature(MAttrs[i]);
        FeaturesStr = Features.getString();
    }

    // Allocate a target...
    TargetMachine *Target = TheTarget->createTargetMachine(TheTriple.getTriple(),
                            MCPU, FeaturesStr,
                            Options,
                            RelocModel, CMModel,
                            OptLevel);
    assert(Target && "Could not allocate target machine!");
    return Target;
}
开发者ID:romix,项目名称:llvm,代码行数:61,代码来源:TargetSelect.cpp

示例2: LLVMGetTargetFromName

LLVMTargetRef LLVMGetTargetFromName(const char *Name) {
  StringRef NameRef = Name;
  for (TargetRegistry::iterator IT = TargetRegistry::begin(),
                                IE = TargetRegistry::end(); IT != IE; ++IT) {
    if (IT->getName() == NameRef)
      return wrap(&*IT);
  }

  return nullptr;
}
开发者ID:Fairly,项目名称:opencor,代码行数:10,代码来源:TargetMachineC.cpp

示例3: printRegisteredTargetsForVersion

void TargetRegistry::printRegisteredTargetsForVersion() {
  std::vector<std::pair<StringRef, const Target*> > Targets;
  size_t Width = 0;
  for (TargetRegistry::iterator I = TargetRegistry::begin(),
       E = TargetRegistry::end();
       I != E; ++I) {
    Targets.push_back(std::make_pair(I->getName(), &*I));
    Width = std::max(Width, Targets.back().first.size());
  }
  array_pod_sort(Targets.begin(), Targets.end(), TargetArraySortFn);

  raw_ostream &OS = outs();
  OS << "  Registered Targets:\n";
  for (unsigned i = 0, e = Targets.size(); i != e; ++i) {
    OS << "    " << Targets[i].first;
    OS.indent(Width - Targets[i].first.size()) << " - "
      << Targets[i].second->getShortDescription() << '\n';
  }
  if (Targets.empty())
    OS << "    (none)\n";
}
开发者ID:Fairly,项目名称:opencor,代码行数:21,代码来源:TargetRegistry.cpp

示例4:

const Target *TargetRegistry::lookupTarget(const std::string &ArchName,
                                           Triple &TheTriple,
                                           std::string &Error) {
  // Allocate target machine.  First, check whether the user has explicitly
  // specified an architecture to compile for. If so we have to look it up by
  // name, because it might be a backend that has no mapping to a target triple.
  const Target *TheTarget = nullptr;
  if (!ArchName.empty()) {
    for (TargetRegistry::iterator it = TargetRegistry::begin(),
           ie = TargetRegistry::end(); it != ie; ++it) {
      if (ArchName == it->getName()) {
        TheTarget = &*it;
        break;
      }
    }

    if (!TheTarget) {
      Error = "error: invalid target '" + ArchName + "'.\n";
      return nullptr;
    }

    // Adjust the triple to match (if known), otherwise stick with the
    // given triple.
    Triple::ArchType Type = Triple::getArchTypeForLLVMName(ArchName);
    if (Type != Triple::UnknownArch)
      TheTriple.setArch(Type);
  } else {
    // Get the target specific parser.
    std::string TempError;
    TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), TempError);
    if (!TheTarget) {
      Error = ": error: unable to get target for '"
            + TheTriple.getTriple()
            + "', see --version and --triple.\n";
      return nullptr;
    }
  }

  return TheTarget;
}
开发者ID:Fairly,项目名称:opencor,代码行数:40,代码来源:TargetRegistry.cpp

示例5: LLVMCreateTargetMachine

LLVMTargetMachineRef LLVMCreateTargetMachine(const char* cpu, const char* triple, const char** feats, size_t nfeats)
{
    // based on LDC code

    // find target from the given triple and cpu
    const Target* target = NULL;
    for (TargetRegistry::iterator it = TargetRegistry::begin(),
             ie = TargetRegistry::end(); it != ie; ++it)
    {
#if 0
        printf("cpu: %s target: %s\n", cpu, it->getName());
#endif
        if (strcmp(cpu, it->getName()) == 0)
        {
            target = &*it;
            break;
        }
    }
    assert(target != NULL);

    // add any features the user might have provided
    Twine twine;

    SubtargetFeatures features;
    //features.setCPU(cpu);

    for (size_t i = 0; i < nfeats; ++i)
    {
        features.AddFeature(feats[i]);
        twine = twine.concat(features.getString());
    }

    // create machine
    TargetMachine* targetMachine = target->createTargetMachine(triple, twine.str());
    if (!targetMachine)
        return NULL;

    return wrap(targetMachine);
}
开发者ID:CS-svnmirror,项目名称:dsource-bindings,代码行数:39,代码来源:Target.cpp

示例6: TheTriple

/// selectTarget - Pick a target either via -march or by guessing the native
/// arch.  Add any CPU features specified via -mcpu or -mattr.
TargetMachine *MCJIT::selectTarget(Module *Mod,
                                 StringRef MArch,
                                 StringRef MCPU,
                                 const SmallVectorImpl<std::string>& MAttrs,
                                 std::string *ErrorStr) {
  Triple TheTriple(Mod->getTargetTriple());
  if (TheTriple.getTriple().empty())
    TheTriple.setTriple(sys::getHostTriple());

  // Adjust the triple to match what the user requested.
  const Target *TheTarget = 0;
  if (!MArch.empty()) {
    for (TargetRegistry::iterator it = TargetRegistry::begin(),
           ie = TargetRegistry::end(); it != ie; ++it) {
      if (MArch == it->getName()) {
        TheTarget = &*it;
        break;
      }
    }

    if (!TheTarget) {
      *ErrorStr = "No available targets are compatible with this -march, "
        "see -version for the available targets.\n";
      return 0;
    }

    // Adjust the triple to match (if known), otherwise stick with the
    // module/host triple.
    Triple::ArchType Type = Triple::getArchTypeForLLVMName(MArch);
    if (Type != Triple::UnknownArch)
      TheTriple.setArch(Type);
  } else {
    std::string Error;
    TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Error);
    if (TheTarget == 0) {
      if (ErrorStr)
        *ErrorStr = Error;
      return 0;
    }
  }

  if (!TheTarget->hasJIT()) {
    errs() << "WARNING: This target JIT is not designed for the host you are"
           << " running.  If bad things happen, please choose a different "
           << "-march switch.\n";
  }

  // Package up features to be passed to target/subtarget
  std::string FeaturesStr;
  if (!MCPU.empty() || !MAttrs.empty()) {
    SubtargetFeatures Features;
    Features.setCPU(MCPU);
    for (unsigned i = 0; i != MAttrs.size(); ++i)
      Features.AddFeature(MAttrs[i]);
    FeaturesStr = Features.getString();
  }

  // Allocate a target...
  TargetMachine *Target =
    TheTarget->createTargetMachine(TheTriple.getTriple(), FeaturesStr);
  assert(Target && "Could not allocate target machine!");
  return Target;
}
开发者ID:5432935,项目名称:crossbridge,代码行数:65,代码来源:TargetSelect.cpp

示例7: main

// main - Entry point for the llc compiler.
//
int main(int argc, char **argv) {
  sys::PrintStackTraceOnErrorSignal();
  PrettyStackTraceProgram X(argc, argv);

  // Enable debug stream buffering.
  EnableDebugBuffering = true;

  LLVMContext &Context = getGlobalContext();
  llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.

  // Initialize targets first, so that --version shows registered targets.
  InitializeAllTargets();
  InitializeAllAsmPrinters();

  cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");
  
  // Load the module to be compiled...
  SMDiagnostic Err;
  std::auto_ptr<Module> M;

  M.reset(ParseIRFile(InputFilename, Err, Context));
  if (M.get() == 0) {
    Err.Print(argv[0], errs());
    return 1;
  }
  Module &mod = *M.get();

  // If we are supposed to override the target triple, do so now.
  if (!TargetTriple.empty())
    mod.setTargetTriple(TargetTriple);

  Triple TheTriple(mod.getTargetTriple());
  if (TheTriple.getTriple().empty())
    TheTriple.setTriple(sys::getHostTriple());

  // Allocate target machine.  First, check whether the user has explicitly
  // specified an architecture to compile for. If so we have to look it up by
  // name, because it might be a backend that has no mapping to a target triple.
  const Target *TheTarget = 0;
  if (!MArch.empty()) {
    for (TargetRegistry::iterator it = TargetRegistry::begin(),
           ie = TargetRegistry::end(); it != ie; ++it) {
      if (MArch == it->getName()) {
        TheTarget = &*it;
        break;
      }
    }

    if (!TheTarget) {
      errs() << argv[0] << ": error: invalid target '" << MArch << "'.\n";
      return 1;
    }

    // Adjust the triple to match (if known), otherwise stick with the
    // module/host triple.
    Triple::ArchType Type = Triple::getArchTypeForLLVMName(MArch);
    if (Type != Triple::UnknownArch)
      TheTriple.setArch(Type);
  } else {
    std::string Err;
    TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Err);
    if (TheTarget == 0) {
      errs() << argv[0] << ": error auto-selecting target for module '"
             << Err << "'.  Please use the -march option to explicitly "
             << "pick a target.\n";
      return 1;
    }
  }

  // Package up features to be passed to target/subtarget
  std::string FeaturesStr;
  if (MCPU.size() || MAttrs.size()) {
    SubtargetFeatures Features;
    Features.setCPU(MCPU);
    for (unsigned i = 0; i != MAttrs.size(); ++i)
      Features.AddFeature(MAttrs[i]);
    FeaturesStr = Features.getString();
  }

  std::auto_ptr<TargetMachine> 
    target(TheTarget->createTargetMachine(TheTriple.getTriple(), FeaturesStr));
  assert(target.get() && "Could not allocate target machine!");
  TargetMachine &Target = *target.get();

  // Figure out where we are going to send the output...
  formatted_raw_ostream *Out = GetOutputStream(TheTarget->getName(), argv[0]);
  if (Out == 0) return 1;

  CodeGenOpt::Level OLvl = CodeGenOpt::Default;
  switch (OptLevel) {
  default:
    errs() << argv[0] << ": invalid optimization level.\n";
    return 1;
  case ' ': break;
  case '0': OLvl = CodeGenOpt::None; break;
  case '1': OLvl = CodeGenOpt::Less; break;
  case '2': OLvl = CodeGenOpt::Default; break;
  case '3': OLvl = CodeGenOpt::Aggressive; break;
//.........这里部分代码省略.........
开发者ID:Gcrosby5269,项目名称:clamav-bytecode-compiler,代码行数:101,代码来源:llc.cpp

示例8: main

// main - Entry point for the llc compiler.
//
int main(int argc, char **argv) {
  sys::PrintStackTraceOnErrorSignal();
  PrettyStackTraceProgram X(argc, argv);

  // Enable debug stream buffering.
  EnableDebugBuffering = true;

  LLVMContext &Context = getGlobalContext();
  llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.

  // Initialize targets first, so that --version shows registered targets.
  InitializeAllTargets();
  InitializeAllTargetMCs();
  InitializeAllAsmPrinters();
  InitializeAllAsmParsers();

  // Register the target printer for --version.
  cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);

  cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");

  // Load the module to be compiled...
  SMDiagnostic Err;
  std::auto_ptr<Module> M;

  M.reset(ParseIRFile(InputFilename, Err, Context));
  if (M.get() == 0) {
    Err.print(argv[0], errs());
    return 1;
  }
  Module &mod = *M.get();

  // If we are supposed to override the target triple, do so now.
  if (!TargetTriple.empty())
    mod.setTargetTriple(Triple::normalize(TargetTriple));

  Triple TheTriple(mod.getTargetTriple());
  if (TheTriple.getTriple().empty())
    TheTriple.setTriple(sys::getDefaultTargetTriple());

  // Allocate target machine.  First, check whether the user has explicitly
  // specified an architecture to compile for. If so we have to look it up by
  // name, because it might be a backend that has no mapping to a target triple.
  const Target *TheTarget = 0;
  if (!MArch.empty()) {
    for (TargetRegistry::iterator it = TargetRegistry::begin(),
           ie = TargetRegistry::end(); it != ie; ++it) {
      if (MArch == it->getName()) {
        TheTarget = &*it;
        break;
      }
    }

    if (!TheTarget) {
      errs() << argv[0] << ": error: invalid target '" << MArch << "'.\n";
      return 1;
    }

    // Adjust the triple to match (if known), otherwise stick with the
    // module/host triple.
    Triple::ArchType Type = Triple::getArchTypeForLLVMName(MArch);
    if (Type != Triple::UnknownArch)
      TheTriple.setArch(Type);
  } else {
    std::string Err;
    TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Err);
    if (TheTarget == 0) {
      errs() << argv[0] << ": error auto-selecting target for module '"
             << Err << "'.  Please use the -march option to explicitly "
             << "pick a target.\n";
      return 1;
    }
  }

  // Package up features to be passed to target/subtarget
  std::string FeaturesStr;
  if (MAttrs.size()) {
    SubtargetFeatures Features;
    for (unsigned i = 0; i != MAttrs.size(); ++i)
      Features.AddFeature(MAttrs[i]);
    FeaturesStr = Features.getString();
  }

  CodeGenOpt::Level OLvl = CodeGenOpt::Default;
  switch (OptLevel) {
  default:
    errs() << argv[0] << ": invalid optimization level.\n";
    return 1;
  case ' ': break;
  case '0': OLvl = CodeGenOpt::None; break;
  case '1': OLvl = CodeGenOpt::Less; break;
  case '2': OLvl = CodeGenOpt::Default; break;
  case '3': OLvl = CodeGenOpt::Aggressive; break;
  }

  TargetOptions Options;
  Options.LessPreciseFPMADOption = EnableFPMAD;
  Options.PrintMachineCode = PrintCode;
//.........这里部分代码省略.........
开发者ID:mdekruijf,项目名称:llvm,代码行数:101,代码来源:llc.cpp

示例9: main


//.........这里部分代码省略.........
    }

    raw_ostream &OS = outs();
    for (int i = 1; i != argc; ++i) {
        StringRef Arg = argv[i];

        if (Arg.startswith("-")) {
            HasAnyOption = true;
            if (Arg == "--version") {
                OS << PACKAGE_VERSION << '\n';
            } else if (Arg == "--prefix") {
                OS << ActivePrefix << '\n';
            } else if (Arg == "--bindir") {
                OS << ActiveBinDir << '\n';
            } else if (Arg == "--includedir") {
                OS << ActiveIncludeDir << '\n';
            } else if (Arg == "--libdir") {
                OS << ActiveLibDir << '\n';
            } else if (Arg == "--cppflags") {
                OS << ActiveIncludeOption << ' ' << LLVM_CPPFLAGS << '\n';
            } else if (Arg == "--cflags") {
                OS << ActiveIncludeOption << ' ' << LLVM_CFLAGS << '\n';
            } else if (Arg == "--cxxflags") {
                OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << '\n';
            } else if (Arg == "--ldflags") {
                OS << "-L" << ActiveLibDir << ' ' << LLVM_LDFLAGS
                   << ' ' << LLVM_SYSTEM_LIBS << '\n';
            } else if (Arg == "--libs") {
                PrintLibs = true;
            } else if (Arg == "--libnames") {
                PrintLibNames = true;
            } else if (Arg == "--libfiles") {
                PrintLibFiles = true;
            } else if (Arg == "--components") {
                for (unsigned j = 0; j != array_lengthof(AvailableComponents); ++j) {
                    OS << ' ';
                    OS << AvailableComponents[j].Name;
                }
                OS << '\n';
            } else if (Arg == "--targets-built") {
                bool First = true;
                for (TargetRegistry::iterator I = TargetRegistry::begin(),
                        E = TargetRegistry::end(); I != E; First = false, ++I) {
                    if (!First)
                        OS << ' ';
                    OS << I->getName();
                }
                OS << '\n';
            } else if (Arg == "--host-target") {
                OS << LLVM_DEFAULT_TARGET_TRIPLE << '\n';
            } else if (Arg == "--build-mode") {
                OS << LLVM_BUILDMODE << '\n';
            } else if (Arg == "--obj-root") {
                OS << LLVM_OBJ_ROOT << '\n';
            } else if (Arg == "--src-root") {
                OS << LLVM_SRC_ROOT << '\n';
            } else {
                usage();
            }
        } else {
            Components.push_back(Arg);
        }
    }

    if (!HasAnyOption)
        usage();

    if (PrintLibs || PrintLibNames || PrintLibFiles) {
        // Construct the list of all the required libraries.
        std::vector<StringRef> RequiredLibs;
        ComputeLibsForComponents(Components, RequiredLibs);

        for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) {
            StringRef Lib = RequiredLibs[i];
            if (i)
                OS << ' ';

            if (PrintLibNames) {
                OS << Lib;
            } else if (PrintLibFiles) {
                OS << ActiveLibDir << '/' << Lib;
            } else if (PrintLibs) {
                // If this is a typical library name, include it using -l.
                if (Lib.startswith("lib") && Lib.endswith(".a")) {
                    OS << "-l" << Lib.slice(3, Lib.size()-2);
                    continue;
                }

                // Otherwise, print the full path.
                OS << ActiveLibDir << '/' << Lib;
            }
        }
        OS << '\n';
    } else if (!Components.empty()) {
        errs() << "llvm-config: error: components given, but unused\n\n";
        usage();
    }

    return 0;
}
开发者ID:Bootz,项目名称:multicore-opimization,代码行数:101,代码来源:llvm-config.cpp


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