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


C++ TargetInfo类代码示例

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


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

示例1: getClobberConflictLocation

// Checks if there is a conflict between the input and output lists with the
// clobbers list. If there's a conflict, returns the location of the
// conflicted clobber, else returns nullptr
static SourceLocation
getClobberConflictLocation(MultiExprArg Exprs, StringLiteral **Constraints,
                           StringLiteral **Clobbers, int NumClobbers,
                           const TargetInfo &Target, ASTContext &Cont) {
  llvm::StringSet<> InOutVars;
  // Collect all the input and output registers from the extended asm
  // statement in order to check for conflicts with the clobber list
  for (unsigned int i = 0; i < Exprs.size(); ++i) {
    StringRef Constraint = Constraints[i]->getString();
    StringRef InOutReg = Target.getConstraintRegister(
        Constraint, extractRegisterName(Exprs[i], Target));
    if (InOutReg != "")
      InOutVars.insert(InOutReg);
  }
  // Check for each item in the clobber list if it conflicts with the input
  // or output
  for (int i = 0; i < NumClobbers; ++i) {
    StringRef Clobber = Clobbers[i]->getString();
    // We only check registers, therefore we don't check cc and memory
    // clobbers
    if (Clobber == "cc" || Clobber == "memory")
      continue;
    Clobber = Target.getNormalizedGCCRegisterName(Clobber, true);
    // Go over the output's registers we collected
    if (InOutVars.count(Clobber))
      return Clobbers[i]->getLocStart();
  }
  return SourceLocation();
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例2: DefineFmt

static void DefineFmt(const Twine &Prefix, TargetInfo::IntType Ty,
                      const TargetInfo &TI, MacroBuilder &Builder) {
  bool IsSigned = TI.isTypeSigned(Ty);
  StringRef FmtModifier = TI.getTypeFormatModifier(Ty);
  for (const char *Fmt = IsSigned ? "di" : "ouxX"; *Fmt; ++Fmt) {
    Builder.defineMacro(Prefix + "_FMT" + Twine(*Fmt) + "__",
                        Twine("\"") + FmtModifier + Twine(*Fmt) + "\"");
  }
}
开发者ID:OpenKimono,项目名称:clang,代码行数:9,代码来源:InitPreprocessor.cpp

示例3: DumpSTG

void DumpSTG(
    const TargetInfo& ti,
    SymbolManager *symbol,
    target_ptr_t sp,
    uint32_t starting_depth)
{
    // TODO: See GHC's 'Printer.c' on how we could print more information about what's on
    //       the stack

    // Traverse and print the passed STG stack
    for (unsigned int depth=starting_depth; depth<128; depth++) 
    {
        // Top closure
        const target_ptr_t info = ti.ReadMemoryPtr(sp);
        const uint32_t sym_id = symbol->AddressToSymbolID(info);

        Indent(depth);

        // Let our wrapper collect the required information
        uint32_t closure_type, closure_size;
        target_ptr_t fun_ref;
        if (GetClosureTypeAndSize(ti.m_task_port, sp, &closure_type, &closure_size, &fun_ref) != 0)
        {
            std::printf("0x%x (Can't read stack frame)\n", sp);
            break;
        }

        // Referenced closure
        char ref_buf[256] = { 0 };
        if (fun_ref != 0)
        {
            std::snprintf(
                ref_buf,
                sizeof(ref_buf),
                ", <%s>",
                symbol->SymbolIDToName(symbol->AddressToSymbolID(ti.ReadMemoryPtr(fun_ref))));
        }

        std::printf("0x%x <%s> (%s, %ib%s)\n",
            sp,
            symbol->SymbolIDToName(sym_id),
            ClosureTypeToString(closure_type),
            closure_size,
            ref_buf);

        if (closure_type == wrapper_STOP_FRAME)
            break;

        // TODO: Handle underflow frames
        if (closure_type == wrapper_UNDERFLOW_FRAME)
            break;

        sp += closure_size;
    }
}
开发者ID:blitzcode,项目名称:ghc-stack,代码行数:55,代码来源:ghd.cpp

示例4: hasFeature

/// \brief Determine whether a translation unit built using the current
/// language options has the given feature.
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
                       const TargetInfo &Target) {
  return llvm::StringSwitch<bool>(Feature)
           .Case("altivec", LangOpts.AltiVec)
           .Case("blocks", LangOpts.Blocks)
           .Case("cplusplus", LangOpts.CPlusPlus)
           .Case("cplusplus11", LangOpts.CPlusPlus11)
           .Case("objc", LangOpts.ObjC1)
           .Case("objc_arc", LangOpts.ObjCAutoRefCount)
           .Case("opencl", LangOpts.OpenCL)
           .Case("tls", Target.isTLSSupported())
           .Default(Target.hasFeature(Feature));
}
开发者ID:MarkTseng,项目名称:clang,代码行数:15,代码来源:Module.cpp

示例5: extractRegisterName

// Extracting the register name from the Expression value,
// if there is no register name to extract, returns ""
static StringRef extractRegisterName(const Expr *Expression,
                                     const TargetInfo &Target) {
  Expression = Expression->IgnoreImpCasts();
  if (const DeclRefExpr *AsmDeclRef = dyn_cast<DeclRefExpr>(Expression)) {
    // Handle cases where the expression is a variable
    const VarDecl *Variable = dyn_cast<VarDecl>(AsmDeclRef->getDecl());
    if (Variable && Variable->getStorageClass() == SC_Register) {
      if (AsmLabelAttr *Attr = Variable->getAttr<AsmLabelAttr>())
        if (Target.isValidGCCRegisterName(Attr->getLabel()))
          return Target.getNormalizedGCCRegisterName(Attr->getLabel(), true);
    }
  }
  return "";
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例6: DefineExactWidthIntTypeSize

static void DefineExactWidthIntTypeSize(TargetInfo::IntType Ty,
                                        const TargetInfo &TI,
                                        MacroBuilder &Builder) {
  int TypeWidth = TI.getTypeWidth(Ty);
  bool IsSigned = TI.isTypeSigned(Ty);

  // Use the target specified int64 type, when appropriate, so that [u]int64_t
  // ends up being defined in terms of the correct type.
  if (TypeWidth == 64)
    Ty = IsSigned ? TI.getInt64Type() : TI.getUInt64Type();

  const char *Prefix = IsSigned ? "__INT" : "__UINT";
  DefineTypeSize(Prefix + Twine(TypeWidth) + "_MAX__", Ty, TI, Builder);
}
开发者ID:OpenKimono,项目名称:clang,代码行数:14,代码来源:InitPreprocessor.cpp

示例7: assert

void Builtin::Context::InitializeTarget(const TargetInfo &Target,
                                        const TargetInfo *AuxTarget) {
  assert(TSRecords.empty() && "Already initialized target?");
  TSRecords = Target.getTargetBuiltins();
  if (AuxTarget)
    AuxTSRecords = AuxTarget->getTargetBuiltins();
}
开发者ID:2asoft,项目名称:freebsd,代码行数:7,代码来源:Builtins.cpp

示例8: DefineExactWidthIntType

static void DefineExactWidthIntType(TargetInfo::IntType Ty, 
                               const TargetInfo &TI, MacroBuilder &Builder) {
  int TypeWidth = TI.getTypeWidth(Ty);

  // Use the target specified int64 type, when appropriate, so that [u]int64_t
  // ends up being defined in terms of the correct type.
  if (TypeWidth == 64)
    Ty = TI.getInt64Type();

  DefineType("__INT" + Twine(TypeWidth) + "_TYPE__", Ty, Builder);

  StringRef ConstSuffix(TargetInfo::getTypeConstantSuffix(Ty));
  if (!ConstSuffix.empty())
    Builder.defineMacro("__INT" + Twine(TypeWidth) + "_C_SUFFIX__",
                        ConstSuffix);
}
开发者ID:clawplach,项目名称:duetto-clang,代码行数:16,代码来源:InitPreprocessor.cpp

示例9: strncmp

bool CallingConvention_x86_64_systemv::matches(TargetInfo &target, Executable &executable) const
{
	const char arch[] = "x86";
	const char exe[] = "ELF 64";
	return strncmp(target.targetName().c_str(), arch, sizeof arch - 1) == 0
		&& strncmp(executable.getExecutableType().c_str(), exe, sizeof exe - 1) == 0;
}
开发者ID:EgoIncarnate,项目名称:fcd,代码行数:7,代码来源:x86_64_systemv.cpp

示例10: TextDiagnosticPrinter

void c2ffi::init_ci(config &c, clang::CompilerInstance &ci) {
    using clang::DiagnosticOptions;
    using clang::TextDiagnosticPrinter;
    using clang::TargetOptions;
    using clang::TargetInfo;

    DiagnosticOptions *dopt = new DiagnosticOptions;
    TextDiagnosticPrinter *tpd =
        new TextDiagnosticPrinter(llvm::errs(), dopt, false);
    ci.createDiagnostics(tpd);

    std::shared_ptr<TargetOptions> pto =
        std::shared_ptr<TargetOptions>(new TargetOptions());
    if(c.arch == "")
        pto->Triple = llvm::sys::getDefaultTargetTriple();
    else
        pto->Triple = c.arch;

    TargetInfo *pti = TargetInfo::CreateTargetInfo(ci.getDiagnostics(), pto);

    clang::LangOptions &lo = ci.getLangOpts();
    switch(pti->getTriple().getEnvironment()) {
        case llvm::Triple::EnvironmentType::GNU:
            lo.GNUMode = 1;
            break;
        case llvm::Triple::EnvironmentType::MSVC:
            lo.MSVCCompat = 1;
            lo.MicrosoftExt = 1;
            break;
        default:
            std::cerr << "c2ffi warning: Unhandled environment: '"
                      << pti->getTriple().getEnvironmentName().str()
                      << "' for triple '" << c.arch
                      << "'" << std::endl;
    }
    ci.getInvocation().setLangDefaults(lo, c.kind, c.std);

    ci.setTarget(pti);
    ci.createFileManager();
    ci.createSourceManager(ci.getFileManager());
    ci.createPreprocessor(clang::TU_Complete);
    ci.getPreprocessorOpts().UsePredefines = false;
    ci.getPreprocessorOutputOpts().ShowCPP = c.preprocess_only;
    ci.getPreprocessor().setPreprocessedOutput(c.preprocess_only);
}
开发者ID:rmattes,项目名称:c2ffi,代码行数:45,代码来源:init.cpp

示例11: DumpCCS

void DumpCCS(const TargetInfo& ti, target_ptr_t ccs, uint32_t starting_depth)
{
    // Traverse and print the passed Cost Center Stack
    for (unsigned int depth=starting_depth; depth<64; depth++) 
    {
        Indent(depth);

        // Get CC pointer from CCS
        const target_ptr_t cc = ti.ReadMemoryPtr(ccs + OFFSET_ConstCentreStack_cc);
        if (cc == 0)
        {
            std::printf("(Can't read CC pointer)\n");
            break;
        }

        // Retrieve symbol information from CC
        const target_ptr_t label_ptr  = ti.ReadMemoryPtr(cc + OFFSET_ConstCentre_label);
        const target_ptr_t module_ptr = ti.ReadMemoryPtr(cc + OFFSET_ConstCentre_module);
        const target_ptr_t srcloc_ptr = ti.ReadMemoryPtr(cc + OFFSET_ConstCentre_srcloc);
        char label[256], module[256], srcloc[256];
        if (ti.ReadMemoryString(label_ptr, label, sizeof(label)) == false)
            std::strcpy(label, "(can't read label)");
        if (ti.ReadMemoryString(module_ptr, module, sizeof(module)) == false)
            std::strcpy(module, "(can't read module)");
        if (ti.ReadMemoryString(srcloc_ptr, srcloc, sizeof(srcloc)) == false)
            std::strcpy(srcloc, "(can't read srcloc)");
        std::printf("CCS:0x%x <%s> from %s (%s)\n", ccs, label, module, srcloc);

        // Walk the CC stack
        ccs = ti.ReadMemoryPtr(ccs + OFFSET_ConstCentreStack_prevStack);
        if (ccs == 0)
            break;
    }
}
开发者ID:blitzcode,项目名称:ghc-stack,代码行数:34,代码来源:ghd.cpp

示例12: isSimpleMSAsm

// Determine if this is a simple MSAsm instruction.
static bool isSimpleMSAsm(std::vector<StringRef> &Pieces,
                          const TargetInfo &TI) {
  if (isMSAsmKeyword(Pieces[0]))
      return false;

  for (unsigned i = 1, e = Pieces.size(); i != e; ++i)
    if (!TI.isValidGCCRegisterName(Pieces[i]))
      return false;
  return true;
}
开发者ID:DevO2012,项目名称:clang-with-ms-abi-support,代码行数:11,代码来源:SemaStmtAsm.cpp

示例13: DefineExactWidthIntType

static void DefineExactWidthIntType(TargetInfo::IntType Ty,
                                    const TargetInfo &TI,
                                    MacroBuilder &Builder) {
  int TypeWidth = TI.getTypeWidth(Ty);
  bool IsSigned = TI.isTypeSigned(Ty);

  // Use the target specified int64 type, when appropriate, so that [u]int64_t
  // ends up being defined in terms of the correct type.
  if (TypeWidth == 64)
    Ty = IsSigned ? TI.getInt64Type() : TI.getIntTypeByWidth(64, false);

  const char *Prefix = IsSigned ? "__INT" : "__UINT";

  DefineType(Prefix + Twine(TypeWidth) + "_TYPE__", Ty, Builder);

  StringRef ConstSuffix(TargetInfo::getTypeConstantSuffix(Ty));
  if (!ConstSuffix.empty())
    Builder.defineMacro(Prefix + Twine(TypeWidth) + "_C_SUFFIX__", ConstSuffix);

}
开发者ID:PDi-Communication-Systems-Inc,项目名称:lollipop_external_clang,代码行数:20,代码来源:InitPreprocessor.cpp

示例14: SetClingTargetLangOpts

 void CIFactory::SetClingTargetLangOpts(LangOptions& Opts,
                                        const TargetInfo& Target) {
   if (Target.getTriple().getOS() == llvm::Triple::Win32) {
     Opts.MicrosoftExt = 1;
     Opts.MSCVersion = 1300;
     // Should fix http://llvm.org/bugs/show_bug.cgi?id=10528
     Opts.DelayedTemplateParsing = 1;
   } else {
     Opts.MicrosoftExt = 0;
   }
 }
开发者ID:cheatiiit,项目名称:root,代码行数:11,代码来源:CIFactory.cpp

示例15: hasFeature

/// \brief Determine whether a translation unit built using the current
/// language options has the given feature.
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
                       const TargetInfo &Target) {
  bool HasFeature = llvm::StringSwitch<bool>(Feature)
                        .Case("altivec", LangOpts.AltiVec)
                        .Case("blocks", LangOpts.Blocks)
                        .Case("cplusplus", LangOpts.CPlusPlus)
                        .Case("cplusplus11", LangOpts.CPlusPlus11)
                        .Case("objc", LangOpts.ObjC1)
                        .Case("objc_arc", LangOpts.ObjCAutoRefCount)
                        .Case("opencl", LangOpts.OpenCL)
                        .Case("tls", Target.isTLSSupported())
                        .Case("zvector", LangOpts.ZVector)
                        .Case("cplusplusamp", LangOpts.CPlusPlusAMP)
                        .Default(Target.hasFeature(Feature));
  if (!HasFeature)
    HasFeature = std::find(LangOpts.ModuleFeatures.begin(),
                           LangOpts.ModuleFeatures.end(),
                           Feature) != LangOpts.ModuleFeatures.end();
  return HasFeature;
}
开发者ID:scchan,项目名称:hcc-clang-upgrade,代码行数:22,代码来源:Module.cpp


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