本文整理汇总了C++中TargetInfo类的典型用法代码示例。如果您正苦于以下问题:C++ TargetInfo类的具体用法?C++ TargetInfo怎么用?C++ TargetInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TargetInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: DefineLeastWidthIntType
static void DefineLeastWidthIntType(unsigned TypeWidth, bool IsSigned,
const TargetInfo &TI,
MacroBuilder &Builder) {
TargetInfo::IntType Ty = TI.getLeastIntTypeByWidth(TypeWidth, IsSigned);
if (Ty == TargetInfo::NoInt)
return;
const char *Prefix = IsSigned ? "__INT_LEAST" : "__UINT_LEAST";
DefineType(Prefix + Twine(TypeWidth) + "_TYPE__", Ty, Builder);
DefineTypeSize(Prefix + Twine(TypeWidth) + "_MAX__", Ty, TI, Builder);
}
开发者ID:PDi-Communication-Systems-Inc,项目名称:lollipop_external_clang,代码行数:11,代码来源:InitPreprocessor.cpp
示例17: DefineFastIntType
static void DefineFastIntType(unsigned TypeWidth, bool IsSigned,
const TargetInfo &TI, MacroBuilder &Builder) {
// stdint.h currently defines the fast int types as equivalent to the least
// types.
TargetInfo::IntType Ty = TI.getLeastIntTypeByWidth(TypeWidth, IsSigned);
if (Ty == TargetInfo::NoInt)
return;
const char *Prefix = IsSigned ? "__INT_FAST" : "__UINT_FAST";
DefineType(Prefix + Twine(TypeWidth) + "_TYPE__", Ty, Builder);
DefineTypeSize(Prefix + Twine(TypeWidth) + "_MAX__", Ty, TI, Builder);
}
开发者ID:PDi-Communication-Systems-Inc,项目名称:lollipop_external_clang,代码行数:12,代码来源:InitPreprocessor.cpp
示例18: DefineExactWidthIntType
static void DefineExactWidthIntType(TargetInfo::IntType Ty,
const TargetInfo &TI, std::vector<char> &Buf) {
char MacroBuf[60];
int TypeWidth = TI.getTypeWidth(Ty);
sprintf(MacroBuf, "__INT%d_TYPE__", TypeWidth);
DefineType(MacroBuf, Ty, Buf);
const char *ConstSuffix = TargetInfo::getTypeConstantSuffix(Ty);
if (strlen(ConstSuffix) > 0) {
sprintf(MacroBuf, "__INT%d_C_SUFFIX__=%s", TypeWidth, ConstSuffix);
DefineBuiltinMacro(Buf, MacroBuf);
}
}
开发者ID:aaasz,项目名称:SHP,代码行数:14,代码来源:InitPreprocessor.cpp
示例19: SimplifyConstraint
static std::string
SimplifyConstraint(const char *Constraint, TargetInfo &Target,
llvm::SmallVectorImpl<TargetInfo::ConstraintInfo> *OutCons=0) {
std::string Result;
while (*Constraint) {
switch (*Constraint) {
default:
Result += Target.convertConstraint(*Constraint);
break;
// Ignore these
case '*':
case '?':
case '!':
break;
case 'g':
Result += "imr";
break;
case '[': {
assert(OutCons &&
"Must pass output names to constraints with a symbolic name");
unsigned Index;
bool result = Target.resolveSymbolicName(Constraint,
&(*OutCons)[0],
OutCons->size(), Index);
assert(result && "Could not resolve symbolic name"); result=result;
Result += llvm::utostr(Index);
break;
}
}
Constraint++;
}
return Result;
}
开发者ID:Killfrra,项目名称:llvm-kernel,代码行数:36,代码来源:CGStmt.cpp
示例20: InitializeStandardPredefinedMacros
static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
const LangOptions &LangOpts,
const FrontendOptions &FEOpts,
MacroBuilder &Builder) {
if (!LangOpts.MSVCCompat && !LangOpts.TraditionalCPP)
Builder.defineMacro("__STDC__");
if (LangOpts.Freestanding)
Builder.defineMacro("__STDC_HOSTED__", "0");
else
Builder.defineMacro("__STDC_HOSTED__");
if (!LangOpts.CPlusPlus) {
if (LangOpts.C11)
Builder.defineMacro("__STDC_VERSION__", "201112L");
else if (LangOpts.C99)
Builder.defineMacro("__STDC_VERSION__", "199901L");
else if (!LangOpts.GNUMode && LangOpts.Digraphs)
Builder.defineMacro("__STDC_VERSION__", "199409L");
} else {
// FIXME: Use correct value for C++17.
if (LangOpts.CPlusPlus1z)
Builder.defineMacro("__cplusplus", "201406L");
// C++1y [cpp.predefined]p1:
// The name __cplusplus is defined to the value 201402L when compiling a
// C++ translation unit.
else if (LangOpts.CPlusPlus14)
Builder.defineMacro("__cplusplus", "201402L");
// C++11 [cpp.predefined]p1:
// The name __cplusplus is defined to the value 201103L when compiling a
// C++ translation unit.
else if (LangOpts.CPlusPlus11)
Builder.defineMacro("__cplusplus", "201103L");
// C++03 [cpp.predefined]p1:
// The name __cplusplus is defined to the value 199711L when compiling a
// C++ translation unit.
else
Builder.defineMacro("__cplusplus", "199711L");
// C++1z [cpp.predefined]p1:
// An integer literal of type std::size_t whose value is the alignment
// guaranteed by a call to operator new(std::size_t)
//
// We provide this in all language modes, since it seems generally useful.
Builder.defineMacro("__STDCPP_DEFAULT_NEW_ALIGNMENT__",
Twine(TI.getNewAlign() / TI.getCharWidth()) +
TI.getTypeConstantSuffix(TI.getSizeType()));
}
// In C11 these are environment macros. In C++11 they are only defined
// as part of <cuchar>. To prevent breakage when mixing C and C++
// code, define these macros unconditionally. We can define them
// unconditionally, as Clang always uses UTF-16 and UTF-32 for 16-bit
// and 32-bit character literals.
Builder.defineMacro("__STDC_UTF_16__", "1");
Builder.defineMacro("__STDC_UTF_32__", "1");
if (LangOpts.ObjC1)
Builder.defineMacro("__OBJC__");
// OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
if (LangOpts.OpenCL) {
// OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
// language standard with which the program is compiled. __OPENCL_VERSION__
// is for the OpenCL version supported by the OpenCL device, which is not
// necessarily the language standard with which the program is compiled.
// A shared OpenCL header file requires a macro to indicate the language
// standard. As a workaround, __OPENCL_C_VERSION__ is defined for
// OpenCL v1.0 and v1.1.
switch (LangOpts.OpenCLVersion) {
case 100:
Builder.defineMacro("__OPENCL_C_VERSION__", "100");
break;
case 110:
Builder.defineMacro("__OPENCL_C_VERSION__", "110");
break;
case 120:
Builder.defineMacro("__OPENCL_C_VERSION__", "120");
break;
case 200:
Builder.defineMacro("__OPENCL_C_VERSION__", "200");
break;
default:
llvm_unreachable("Unsupported OpenCL version");
}
Builder.defineMacro("CL_VERSION_1_0", "100");
Builder.defineMacro("CL_VERSION_1_1", "110");
Builder.defineMacro("CL_VERSION_1_2", "120");
Builder.defineMacro("CL_VERSION_2_0", "200");
if (TI.isLittleEndian())
Builder.defineMacro("__ENDIAN_LITTLE__");
if (LangOpts.FastRelaxedMath)
Builder.defineMacro("__FAST_RELAXED_MATH__");
}
// Not "standard" per se, but available even with the -undef flag.
if (LangOpts.AsmPreprocessor)
Builder.defineMacro("__ASSEMBLER__");
if (LangOpts.CUDA)
Builder.defineMacro("__CUDA__");
//.........这里部分代码省略.........
开发者ID:wsmoses,项目名称:Cilk-Clang,代码行数:101,代码来源:InitPreprocessor.cpp
注:本文中的TargetInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论