src/plugins/thirdParty/LLVM/tools/clang/lib/Basic/Targets.cpp
/// CreateTargetInfo - Return the target info object for the specified target
/// triple.
Return the target info object for the specified target
triple.
Return the target info object for the specified target triple .
TargetInfo *
TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
                             const std::shared_ptr<TargetOptions> &Opts) {
  llvm::Triple Triple(Opts->Triple);
  std::unique_ptr<TargetInfo> Target(AllocateTarget(Triple));
  if (!Target) {
    Diags.Report(diag::err_target_unknown_triple) << Triple.str();
    return nullptr;
  }
  Target->TargetOpts = Opts;
  if (!Opts->CPU.empty() && !Target->setCPU(Opts->CPU)) {
    Diags.Report(diag::err_target_unknown_cpu) << Opts->CPU;
    return nullptr;
  }
  if (!Opts->ABI.empty() && !Target->setABI(Opts->ABI)) {
    Diags.Report(diag::err_target_unknown_abi) << Opts->ABI;
    return nullptr;
  }
  if (!Opts->FPMath.empty() && !Target->setFPMath(Opts->FPMath)) {
    Diags.Report(diag::err_target_unknown_fpmath) << Opts->FPMath;
    return nullptr;
  }
  llvm::StringMap<bool> Features;
  Target->getDefaultFeatures(Features);
  for (unsigned I = 0, N = Opts->FeaturesAsWritten.size();
       I < N; ++I) {
    const char *Name = Opts->FeaturesAsWritten[I].c_str();
    bool Enabled = Name[0] == '+';
    Target->setFeatureEnabled(Features, Name + 1, Enabled);
  }
   FIXME: If we are completely confident that we have the right set, we only
   need to pass the minuses.
  Opts->Features.clear();
  for (llvm::StringMap<bool>::const_iterator it = Features.begin(),
         ie = Features.end(); it != ie; ++it)
    Opts->Features.push_back((it->second ? "+" : "-") + it->first().str());
  if (!Target->handleTargetFeatures(Opts->Features, Diags))
    return nullptr;
  return Target.release();
}
TargetInfo * TargetInfo :: CreateTargetInfo ( DiagnosticsEngine & Diags , const std :: shared_ptr < TargetOptions > & Opts ) { llvm :: Triple Triple ( Opts -> Triple ) ; std :: unique_ptr < TargetInfo > Target ( AllocateTarget ( Triple ) ) ; if ( ! Target ) { Diags . Report ( diag :: err_target_unknown_triple ) << Triple . str ( ) ; return nullptr ; } Target -> TargetOpts = Opts ; if ( ! Opts -> CPU . empty ( ) && ! Target -> setCPU ( Opts -> CPU ) ) { Diags . Report ( diag :: err_target_unknown_cpu ) << Opts -> CPU ; return nullptr ; } if ( ! Opts -> ABI . empty ( ) && ! Target -> setABI ( Opts -> ABI ) ) { Diags . Report ( diag :: err_target_unknown_abi ) << Opts -> ABI ; return nullptr ; } if ( ! Opts -> FPMath . empty ( ) && ! Target -> setFPMath ( Opts -> FPMath ) ) { Diags . Report ( diag :: err_target_unknown_fpmath ) << Opts -> FPMath ; return nullptr ; } llvm :: StringMap < bool > Features ; Target -> getDefaultFeatures ( Features ) ; for ( unsigned I = 0 , N = Opts -> FeaturesAsWritten . size ( ) ; I < N ; ++ I ) { const char * Name = Opts -> FeaturesAsWritten [ I ] . c_str ( ) ; bool Enabled = Name [ 0 ] == ' ' ; Target -> setFeatureEnabled ( Features , Name + 1 , Enabled ) ; } Opts -> Features . clear ( ) ; for ( llvm :: StringMap < bool > :: const_iterator it = Features . begin ( ) , ie = Features . end ( ) ; it != ie ; ++ it ) Opts -> Features . push_back ( ( it -> second ? " " : " " ) + it -> first ( ) . str ( ) ) ; if ( ! Target -> handleTargetFeatures ( Opts -> Features , Diags ) ) return nullptr ; return Target . release ( ) ; }
CreateTargetInfo - Return the target info object for the specified target
triple.
CreateTargetInfo - Return the target info object for the specified target triple .
// Construct the target // Set the target CPU if specified. // Set the target ABI if specified. // Set the fp math unit. // Compute the default target features, we need the target to handle this // because features may have dependencies on one another. // Apply the user specified deltas. // Apply the feature via the target. // Add the features to the compile options. // // FIXME: If we are completely confident that we have the right set, we only // need to pass the minuses.