本文整理汇总了C++中TargetData类的典型用法代码示例。如果您正苦于以下问题:C++ TargetData类的具体用法?C++ TargetData怎么用?C++ TargetData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TargetData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Target
void
nest::TargetTable::add_target( const thread tid,
const thread target_rank,
const TargetData& target_data )
{
const index lid = target_data.get_source_lid();
vector_util::grow( targets_[ tid ][ lid ] );
if ( target_data.is_primary() )
{
const TargetDataFields& target_fields = target_data.target_data;
targets_[ tid ][ lid ].push_back( Target( target_fields.get_tid(),
target_rank,
target_fields.get_syn_id(),
target_fields.get_lcid() ) );
}
else
{
const SecondaryTargetDataFields& secondary_fields =
target_data.secondary_data;
const size_t send_buffer_pos = secondary_fields.get_send_buffer_pos();
const synindex syn_id = secondary_fields.get_syn_id();
assert( syn_id < secondary_send_buffer_pos_[ tid ][ lid ].size() );
secondary_send_buffer_pos_[ tid ][ lid ][ syn_id ].push_back(
send_buffer_pos );
}
}
示例2: QDialog
NewProjectDialog::NewProjectDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::NewProjectDialog)
{
ui->setupUi(this);
/* Getting the default directory from the application settings */
QSettings settings;
settings.beginGroup("NewProjectDialog");
ui->locationBox->setText(settings.value("defaultDir",
QDir::home().absolutePath())
.toString());
settings.endGroup();
/* Populating the target box */
TargetData targets;
for(int i = 0; i < targets.count(); i++)
{
ui->targetBox->insertItem(i, QIcon(), targets.name(i), targets.id(i));
}
targetChange(0);
/* Connecting the browse button and target box */
QObject::connect(ui->browseButton, SIGNAL(clicked()),
this, SLOT(browse()));
QObject::connect(ui->targetBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(targetChange(int)));
}
示例3: qPrintable
// Write ViewPaneBlock keywords
bool UChromaSession::writeViewPaneBlock(LineParser& parser, ViewPane* pane)
{
parser.writeLineF(" %s '%s'\n", UChromaSession::viewKeyword(UChromaSession::ViewPaneBlockKeyword), qPrintable(pane->name()));
parser.writeLineF(" %s %s\n", UChromaSession::viewPaneKeyword(UChromaSession::AutoPositionTitlesKeyword), stringBool(pane->axes().autoPositionTitles()));
for (int axis=0; axis < 3; ++axis) writeAxisBlock(parser, pane->axes(), axis);
parser.writeLineF(" %s %i\n", UChromaSession::viewPaneKeyword(UChromaSession::BoundingBoxKeyword), pane->boundingBox());
parser.writeLineF(" %s %f\n", UChromaSession::viewPaneKeyword(UChromaSession::BoundingBoxPlaneYKeyword), pane->boundingBoxPlaneY());
parser.writeLineF(" %s %s\n", UChromaSession::viewPaneKeyword(UChromaSession::FlatLabelsKeyword), stringBool(pane->flatLabels()));
parser.writeLineF(" %s %i %i %i %i\n", UChromaSession::viewPaneKeyword(UChromaSession::GeometryKeyword), pane->bottomEdge(), pane->leftEdge(), pane->width(), pane->height());
parser.writeLineF(" %s %f\n", UChromaSession::viewPaneKeyword(UChromaSession::LabelPointSizeKeyword), pane->labelPointSize());
parser.writeLineF(" %s %f\n", UChromaSession::viewPaneKeyword(UChromaSession::TitlePointSizeKeyword), pane->titlePointSize());
Matrix mat = pane->viewRotation();
Vec3<double> trans = pane->viewTranslation();
parser.writeLineF(" %s %f %f %f\n", UChromaSession::viewPaneKeyword(UChromaSession::RotationXKeyword), mat[0], mat[1], mat[2]);
parser.writeLineF(" %s %f %f %f\n", UChromaSession::viewPaneKeyword(UChromaSession::RotationYKeyword), mat[4], mat[5], mat[6]);
parser.writeLineF(" %s %f %f %f\n", UChromaSession::viewPaneKeyword(UChromaSession::RotationZKeyword), mat[8], mat[9], mat[10]);
parser.writeLineF(" %s %f %f %f\n", UChromaSession::viewPaneKeyword(UChromaSession::TranslationKeyword), trans.x, trans.y, trans.z);
parser.writeLineF(" %s %s\n", UChromaSession::viewPaneKeyword(UChromaSession::PerspectiveKeyword), stringBool(pane->hasPerspective()));
parser.writeLineF(" %s '%s'\n", UChromaSession::viewPaneKeyword(UChromaSession::RoleKeyword), ViewPane::paneRole(pane->role()));
for (TargetData* target = pane->collectionTargets(); target != NULL; target = target->next)
{
if (!Collection::objectValid(target->collection(), "collection in UChromaSession::writeViewPaneBlock")) continue;
parser.writeLineF(" %s '%s'\n", UChromaSession::viewPaneKeyword(UChromaSession::RoleTargetCollectionKeyword), qPrintable(target->collection()->locator()));
}
for (RefListItem<ViewPane,bool>* ri = pane->paneTargets(); ri != NULL; ri = ri->next) parser.writeLineF(" %s '%s'\n", UChromaSession::viewPaneKeyword(UChromaSession::RoleTargetPaneKeyword), qPrintable(ri->item->name()));
parser.writeLineF(" %s %s\n", UChromaSession::viewPaneKeyword(UChromaSession::UseBestFlatViewKeyword), stringBool(pane->axes().useBestFlatView()));
parser.writeLineF(" %s '%s'\n", UChromaSession::viewPaneKeyword(UChromaSession::ViewTypeKeyword), ViewPane::viewType(pane->viewType()));
parser.writeLineF(" %s\n", UChromaSession::viewPaneKeyword(UChromaSession::EndViewPaneKeyword));
return true;
}
示例4: GetOffsetFromIndex
static int64_t GetOffsetFromIndex(const GEPOperator *GEP, unsigned Idx,
bool &VariableIdxFound, const TargetData &TD) {
// Skip over the first indices.
gep_type_iterator GTI = gep_type_begin(GEP);
for (unsigned i = 1; i != Idx; ++i, ++GTI)
/*skip along*/;
// Compute the offset implied by the rest of the indices.
int64_t Offset = 0;
for (unsigned i = Idx, e = GEP->getNumOperands(); i != e; ++i, ++GTI) {
ConstantInt *OpC = dyn_cast<ConstantInt>(GEP->getOperand(i));
if (OpC == 0)
return VariableIdxFound = true;
if (OpC->isZero()) continue; // No offset.
// Handle struct indices, which add their field offset to the pointer.
if (StructType *STy = dyn_cast<StructType>(*GTI)) {
Offset += TD.getStructLayout(STy)->getElementOffset(OpC->getZExtValue());
continue;
}
// Otherwise, we have a sequential type like an array or vector. Multiply
// the index by the ElementSize.
uint64_t Size = TD.getTypeAllocSize(GTI.getIndexedType());
Offset += Size*OpC->getSExtValue();
}
return Offset;
}
示例5: getTypeSize
static unsigned getTypeSize(TargetData &TD, Type *type) {
if (type->isFunctionTy()) /* it is not sized, weird */
return TD.getPointerSize();
if (!type->isSized())
return 100; /* FIXME */
if (StructType *ST = dyn_cast<StructType>(type))
return TD.getStructLayout(ST)->getSizeInBytes();
return TD.getTypeAllocSize(type);
}
示例6: IsConstantOffsetFromGlobal
/// IsConstantOffsetFromGlobal - If this constant is actually a constant offset
/// from a global, return the global and the constant. Because of
/// constantexprs, this function is recursive.
static bool IsConstantOffsetFromGlobal(Constant *C, GlobalValue *&GV,
int64_t &Offset, const TargetData &TD) {
// Trivial case, constant is the global.
if ((GV = dyn_cast<GlobalValue>(C))) {
Offset = 0;
return true;
}
// Otherwise, if this isn't a constant expr, bail out.
ConstantExpr *CE = dyn_cast<ConstantExpr>(C);
if (!CE) return false;
// Look through ptr->int and ptr->ptr casts.
if (CE->getOpcode() == Instruction::PtrToInt ||
CE->getOpcode() == Instruction::BitCast)
return IsConstantOffsetFromGlobal(CE->getOperand(0), GV, Offset, TD);
// i32* getelementptr ([5 x i32]* @a, i32 0, i32 5)
if (CE->getOpcode() == Instruction::GetElementPtr) {
// Cannot compute this if the element type of the pointer is missing size
// info.
if (!cast<PointerType>(CE->getOperand(0)->getType())->getElementType()->isSized())
return false;
// If the base isn't a global+constant, we aren't either.
if (!IsConstantOffsetFromGlobal(CE->getOperand(0), GV, Offset, TD))
return false;
// Otherwise, add any offset that our operands provide.
gep_type_iterator GTI = gep_type_begin(CE);
for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i, ++GTI) {
ConstantInt *CI = dyn_cast<ConstantInt>(CE->getOperand(i));
if (!CI) return false; // Index isn't a simple constant?
if (CI->getZExtValue() == 0) continue; // Not adding anything.
if (const StructType *ST = dyn_cast<StructType>(*GTI)) {
// N = N + Offset
Offset += TD.getStructLayout(ST)->getElementOffset(CI->getZExtValue());
} else {
const SequentialType *SQT = cast<SequentialType>(*GTI);
Offset += TD.getTypeSize(SQT->getElementType())*CI->getSExtValue();
}
}
return true;
}
return false;
}
示例7: ComputeStructureFieldIndices
static void ComputeStructureFieldIndices(const Type *Ty, unsigned Offset,
std::vector<unsigned> &Idxs,
const TargetData &TD) {
if (Ty->isFirstClassType()) {
assert(Offset == 0 && "Illegal structure index!");
return;
}
if (const SequentialType *STy = dyn_cast<SequentialType>(Ty)) {
ComputeStructureFieldIndices(STy->getElementType(), Offset, Idxs, TD);
} else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
const StructLayout *SL = TD.getStructLayout(STy);
std::vector<uint64_t>::const_iterator SI =
std::upper_bound(SL->MemberOffsets.begin(), SL->MemberOffsets.end(),
Offset);
assert(SI != SL->MemberOffsets.begin() && "Offset not in structure type!");
--SI;
assert(*SI <= Offset && "upper_bound didn't work");
assert((SI == SL->MemberOffsets.begin() || *(SI-1) < Offset) &&
(SI+1 == SL->MemberOffsets.end() || *(SI+1) > Offset) &&
"Upper bound didn't work!");
Offset -= *SI; // Skip over the offset to this structure field.
unsigned Idx = SI - SL->MemberOffsets.begin();
assert(Idx < STy->getNumElements() && "Illegal structure index");
Idxs.push_back(Idx);
ComputeStructureFieldIndices(STy->getElementType(Idx), Offset, Idxs, TD);
} else {
assert(0 && "Unknown type to index into!");
}
}
示例8: isObjectSmallerThan
/// isObjectSmallerThan - Return true if we can prove that the object specified
/// by V is smaller than Size.
static bool isObjectSmallerThan(const Value *V, unsigned Size,
const TargetData &TD) {
const Type *AccessTy;
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
AccessTy = GV->getType()->getElementType();
} else if (const AllocaInst *AI = dyn_cast<AllocaInst>(V)) {
if (!AI->isArrayAllocation())
AccessTy = AI->getType()->getElementType();
else
return false;
} else if (const CallInst* CI = extractMallocCall(V)) {
if (!isArrayMalloc(V, &TD))
// The size is the argument to the malloc call.
if (const ConstantInt* C = dyn_cast<ConstantInt>(CI->getOperand(1)))
return (C->getZExtValue() < Size);
return false;
} else if (const Argument *A = dyn_cast<Argument>(V)) {
if (A->hasByValAttr())
AccessTy = cast<PointerType>(A->getType())->getElementType();
else
return false;
} else {
return false;
}
if (AccessTy->isSized())
return TD.getTypeAllocSize(AccessTy) < Size;
return false;
}
示例9: getPointeeAlignment
/// getPointeeAlignment - Compute the minimum alignment of the value pointed
/// to by the given pointer.
static unsigned getPointeeAlignment(Value *V, const TargetData &TD) {
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
if (CE->getOpcode() == Instruction::BitCast ||
(CE->getOpcode() == Instruction::GetElementPtr &&
cast<GEPOperator>(CE)->hasAllZeroIndices()))
return getPointeeAlignment(CE->getOperand(0), TD);
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
if (!GV->isDeclaration())
return TD.getPreferredAlignment(GV);
if (PointerType *PT = dyn_cast<PointerType>(V->getType()))
return TD.getABITypeAlignment(PT->getElementType());
return 0;
}
示例10: getEntryAlignment
/// getEntryAlignment - Return the alignment of each entry in the jump table.
unsigned MachineJumpTableInfo::getEntryAlignment(const TargetData &TD) const {
// The alignment of a jump table entry is the alignment of int32 unless the
// entry is just the address of a block, in which case it is the pointer
// alignment.
switch (getEntryKind()) {
case MachineJumpTableInfo::EK_BlockAddress:
return TD.getPointerABIAlignment();
case MachineJumpTableInfo::EK_GPRel32BlockAddress:
case MachineJumpTableInfo::EK_LabelDifference32:
case MachineJumpTableInfo::EK_Custom32:
return TD.getABIIntegerTypeAlignment(32);
case MachineJumpTableInfo::EK_Inline:
return 1;
}
assert(0 && "Unknown jump table encoding!");
return ~0;
}
示例11: Kleerer
Kleerer(ModulePass &modPass, Module &M, TargetData &TD,
callgraph::Callgraph &CG) : modPass(modPass),
M(M), TD(TD), CG(CG), C(M.getContext()), intPtrTy(TD.getIntPtrType(C)),
done(false) {
voidPtrType = TypeBuilder<void *, false>::get(C);
intType = TypeBuilder<int, false>::get(C);
uintType = TypeBuilder<unsigned, false>::get(C);
}
示例12: MallocConvertibleToType
// Peephole Malloc instructions: we take a look at the use chain of the
// malloc instruction, and try to find out if the following conditions hold:
// 1. The malloc is of the form: 'malloc [sbyte], uint <constant>'
// 2. The only users of the malloc are cast & add instructions
// 3. Of the cast instructions, there is only one destination pointer type
// [RTy] where the size of the pointed to object is equal to the number
// of bytes allocated.
//
// If these conditions hold, we convert the malloc to allocate an [RTy]
// element. TODO: This comment is out of date WRT arrays
//
static bool MallocConvertibleToType(MallocInst *MI, const Type *Ty,
ValueTypeCache &CTMap,
const TargetData &TD) {
if (!isa<PointerType>(Ty)) return false; // Malloc always returns pointers
// Deal with the type to allocate, not the pointer type...
Ty = cast<PointerType>(Ty)->getElementType();
if (!Ty->isSized()) return false; // Can only alloc something with a size
// Analyze the number of bytes allocated...
ExprType Expr = ClassifyExpr(MI->getArraySize());
// Get information about the base datatype being allocated, before & after
int ReqTypeSize = TD.getTypeSize(Ty);
if (ReqTypeSize == 0) return false;
unsigned OldTypeSize = TD.getTypeSize(MI->getType()->getElementType());
// Must have a scale or offset to analyze it...
if (!Expr.Offset && !Expr.Scale && OldTypeSize == 1) return false;
// Get the offset and scale of the allocation...
int64_t OffsetVal = Expr.Offset ? getConstantValue(Expr.Offset) : 0;
int64_t ScaleVal = Expr.Scale ? getConstantValue(Expr.Scale) :(Expr.Var != 0);
// The old type might not be of unit size, take old size into consideration
// here...
int64_t Offset = OffsetVal * OldTypeSize;
int64_t Scale = ScaleVal * OldTypeSize;
// In order to be successful, both the scale and the offset must be a multiple
// of the requested data type's size.
//
if (Offset/ReqTypeSize*ReqTypeSize != Offset ||
Scale/ReqTypeSize*ReqTypeSize != Scale)
return false; // Nope.
return true;
}
示例13: targetChange
void NewProjectDialog::targetChange(int target)
{
TargetData targets;
if(targets.fm(target))
{
ui->fmsBox->setEnabled(true);
ui->rfmsBox->setEnabled(true);
}
else
{
ui->fmsBox->setChecked(false);
ui->rfmsBox->setChecked(false);
ui->fmsBox->setEnabled(false);
ui->rfmsBox->setEnabled(false);
}
if(targets.remoteDepth(target) == TargetData::None)
{
ui->rwpsBox->setChecked(false);
ui->rsbsBox->setChecked(false);
ui->rfmsBox->setChecked(false);
ui->rsbsBox->setEnabled(false);
ui->rwpsBox->setEnabled(false);
ui->rfmsBox->setEnabled(false);
}
else
{
ui->rsbsBox->setEnabled(true);
ui->rwpsBox->setEnabled(true);
if(targets.fm(target))
ui->rfmsBox->setEnabled(true);
}
}
示例14: getEntrySize
/// getEntrySize - Return the size of each entry in the jump table.
unsigned MachineJumpTableInfo::getEntrySize(const TargetData &TD) const {
// The size of a jump table entry is 4 bytes unless the entry is just the
// address of a block, in which case it is the pointer size.
switch (getEntryKind()) {
case MachineJumpTableInfo::EK_BlockAddress:
return TD.getPointerSize();
case MachineJumpTableInfo::EK_GPRel32BlockAddress:
case MachineJumpTableInfo::EK_LabelDifference32:
case MachineJumpTableInfo::EK_Custom32:
return 4;
case MachineJumpTableInfo::EK_Inline:
return 0;
}
assert(0 && "Unknown jump table encoding!");
return ~0;
}
示例15: isObjectSmallerThan
/// isObjectSmallerThan - Return true if we can prove that the object specified
/// by V is smaller than Size.
static bool isObjectSmallerThan(const Value *V, unsigned Size,
const TargetData &TD) {
const Type *AccessTy;
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
AccessTy = GV->getType()->getElementType();
} else if (const AllocationInst *AI = dyn_cast<AllocationInst>(V)) {
if (!AI->isArrayAllocation())
AccessTy = AI->getType()->getElementType();
else
return false;
} else if (const Argument *A = dyn_cast<Argument>(V)) {
if (A->hasByValAttr())
AccessTy = cast<PointerType>(A->getType())->getElementType();
else
return false;
} else {
return false;
}
if (AccessTy->isSized())
return TD.getTypePaddedSize(AccessTy) < Size;
return false;
}