本文整理汇总了C++中SmallVector::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ SmallVector::assign方法的具体用法?C++ SmallVector::assign怎么用?C++ SmallVector::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmallVector
的用法示例。
在下文中一共展示了SmallVector::assign方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SE
//===----------------------------------------------------------------------===//
/// Scop class implement
Scop::Scop(TempScop &tempScop, LoopInfo &LI, ScalarEvolution &ScalarEvolution)
: SE(&ScalarEvolution), R(tempScop.getMaxRegion()),
MaxLoopDepth(tempScop.getMaxLoopDepth()) {
isl_ctx *ctx = isl_ctx_alloc();
ParamSetType &Params = tempScop.getParamSet();
Parameters.insert(Parameters.begin(), Params.begin(), Params.end());
isl_dim *dim = isl_dim_set_alloc(ctx, getNumParams(), 0);
// TODO: Insert relations between parameters.
// TODO: Insert constraints on parameters.
Context = isl_set_universe (dim);
SmallVector<Loop*, 8> NestLoops;
SmallVector<unsigned, 8> Scatter;
Scatter.assign(MaxLoopDepth + 1, 0);
// Build the iteration domain, access functions and scattering functions
// traversing the region tree.
buildScop(tempScop, getRegion(), NestLoops, Scatter, LI);
Stmts.push_back(new ScopStmt(*this, Scatter));
assert(NestLoops.empty() && "NestLoops not empty at top level!");
}
示例2: Input
/*virtual*/ void GatherPackedNode<ElemType>::Validate(bool isFinalValidationPass) /*override*/
{
ComputationNodeBase::Validate(isFinalValidationPass);
// inherit MBLayout from indexData
m_pMBLayout = Input(INDEXDATA)->GetMBLayout();
if (isFinalValidationPass && (!Input(INDEXDATA)->HasMBLayout()))
LogicError("%ls requires first argument (index data) to have a time dimension.", NodeDescription().c_str());
bool sourceHasTimeDimension = Input(SOURCEDATA)->HasMBLayout();
if (isFinalValidationPass && Input(INDEXDATA)->GetSampleLayout().GetNumElements() != 1)
InvalidArgument("%ls requires the first argument (index data) to be a scalar time sequence.", NodeDescription().c_str());
// inherit tensor dimension from sourceData, minus the last (column or time) dimension. TODO this needs to become simpler...
if (sourceHasTimeDimension)
SetDims(Input(SOURCEDATA)->GetSampleLayout(), HasMBLayout());
else
{
SmallVector<size_t> layout = { 1 }; // Scalar
if (Input(SOURCEDATA)->GetSampleLayout().GetRank() > 1)
{
auto srcLayout = Input(SOURCEDATA)->GetSampleLayout().GetDims();
layout.assign(srcLayout.begin(), srcLayout.end() - 1);
}
SetDims(TensorShape(layout), HasMBLayout());
}
}
示例3: CloneNodeWithValues
// Helper for AddGlue to clone node operands.
static void CloneNodeWithValues(SDNode *N, SelectionDAG *DAG, ArrayRef<EVT> VTs,
SDValue ExtraOper = SDValue()) {
SmallVector<SDValue, 8> Ops(N->op_begin(), N->op_end());
if (ExtraOper.getNode())
Ops.push_back(ExtraOper);
SDVTList VTList = DAG->getVTList(VTs);
MachineSDNode *MN = dyn_cast<MachineSDNode>(N);
// Store memory references.
SmallVector<MachineMemOperand *, 2> MMOs;
if (MN)
MMOs.assign(MN->memoperands_begin(), MN->memoperands_end());
DAG->MorphNodeTo(N, N->getOpcode(), VTList, Ops);
// Reset the memory references
if (MN)
DAG->setNodeMemRefs(MN, MMOs);
}
示例4: SE
Scop::Scop(TempScop &tempScop, LoopInfo &LI, ScalarEvolution &ScalarEvolution,
isl_ctx *Context)
: SE(&ScalarEvolution), R(tempScop.getMaxRegion()),
MaxLoopDepth(tempScop.getMaxLoopDepth()) {
IslCtx = Context;
buildContext();
SmallVector<Loop *, 8> NestLoops;
SmallVector<unsigned, 8> Scatter;
Scatter.assign(MaxLoopDepth + 1, 0);
// Build the iteration domain, access functions and scattering functions
// traversing the region tree.
buildScop(tempScop, getRegion(), NestLoops, Scatter, LI);
realignParams();
addParameterBounds();
assert(NestLoops.empty() && "NestLoops not empty at top level!");
}
示例5: ParsingTypeTuple
/// parseTypeTupleBody
/// type-tuple:
/// '(' type-tuple-body? ')'
/// type-tuple-body:
/// type-tuple-element (',' type-tuple-element)* '...'?
/// type-tuple-element:
/// identifier ':' type
/// type
ParserResult<TupleTypeRepr> Parser::parseTypeTupleBody() {
Parser::StructureMarkerRAII ParsingTypeTuple(*this, Tok);
SourceLoc RPLoc, LPLoc = consumeToken(tok::l_paren);
SourceLoc EllipsisLoc;
unsigned EllipsisIdx;
SmallVector<TypeRepr *, 8> ElementsR;
// We keep track of the labels separately, and apply them at the end.
SmallVector<std::tuple<Identifier, SourceLoc, Identifier, SourceLoc>, 4>
Labels;
ParserStatus Status = parseList(tok::r_paren, LPLoc, RPLoc,
tok::comma, /*OptionalSep=*/false,
/*AllowSepAfterLast=*/false,
diag::expected_rparen_tuple_type_list,
[&] () -> ParserStatus {
// If this is a deprecated use of the inout marker in an argument list,
// consume the inout.
SourceLoc InOutLoc;
bool hasAnyInOut = false;
bool hasValidInOut = false;
if (consumeIf(tok::kw_inout, InOutLoc)) {
hasAnyInOut = true;
hasValidInOut = false;
}
// If the tuple element starts with a potential argument label followed by a
// ':' or another potential argument label, then the identifier is an
// element tag, and it is followed by a type annotation.
if (Tok.canBeArgumentLabel() &&
(peekToken().is(tok::colon) || peekToken().canBeArgumentLabel())) {
// Consume the name
Identifier name;
if (!Tok.is(tok::kw__))
name = Context.getIdentifier(Tok.getText());
SourceLoc nameLoc = consumeToken();
// If there is a second name, consume it as well.
Identifier secondName;
SourceLoc secondNameLoc;
if (Tok.canBeArgumentLabel()) {
if (!Tok.is(tok::kw__))
secondName = Context.getIdentifier(Tok.getText());
secondNameLoc = consumeToken();
}
// Consume the ':'.
if (!consumeIf(tok::colon))
diagnose(Tok, diag::expected_parameter_colon);
SourceLoc postColonLoc = Tok.getLoc();
// Consume 'inout' if present.
if (!hasAnyInOut && consumeIf(tok::kw_inout, InOutLoc)) {
hasValidInOut = true;
}
SourceLoc extraneousInOutLoc;
while (consumeIf(tok::kw_inout, extraneousInOutLoc)) {
diagnose(Tok, diag::parameter_inout_var_let_repeated)
.fixItRemove(extraneousInOutLoc);
}
// Parse the type annotation.
ParserResult<TypeRepr> type = parseType(diag::expected_type);
if (type.hasCodeCompletion())
return makeParserCodeCompletionStatus();
if (type.isNull())
return makeParserError();
if (!hasValidInOut && hasAnyInOut) {
diagnose(Tok.getLoc(), diag::inout_as_attr_disallowed)
.fixItRemove(InOutLoc)
.fixItInsert(postColonLoc, "inout ");
}
// If an 'inout' marker was specified, build the type. Note that we bury
// the inout locator within the named locator. This is weird but required
// by sema apparently.
if (InOutLoc.isValid())
type = makeParserResult(new (Context) InOutTypeRepr(type.get(),
InOutLoc));
// Record the label. We will look at these at the end.
if (Labels.empty()) {
Labels.assign(ElementsR.size(),
std::make_tuple(Identifier(), SourceLoc(),
Identifier(), SourceLoc()));
}
Labels.push_back(std::make_tuple(name, nameLoc,
secondName, secondNameLoc));
ElementsR.push_back(type.get());
//.........这里部分代码省略.........
示例6: Handler
bool X86CallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
CallingConv::ID CallConv,
const MachineOperand &Callee,
const ArgInfo &OrigRet,
ArrayRef<ArgInfo> OrigArgs) const {
MachineFunction &MF = MIRBuilder.getMF();
const Function &F = MF.getFunction();
MachineRegisterInfo &MRI = MF.getRegInfo();
auto &DL = F.getParent()->getDataLayout();
const X86Subtarget &STI = MF.getSubtarget<X86Subtarget>();
const TargetInstrInfo &TII = *STI.getInstrInfo();
auto TRI = STI.getRegisterInfo();
// Handle only Linux C, X86_64_SysV calling conventions for now.
if (!STI.isTargetLinux() ||
!(CallConv == CallingConv::C || CallConv == CallingConv::X86_64_SysV))
return false;
unsigned AdjStackDown = TII.getCallFrameSetupOpcode();
auto CallSeqStart = MIRBuilder.buildInstr(AdjStackDown);
// Create a temporarily-floating call instruction so we can add the implicit
// uses of arg registers.
bool Is64Bit = STI.is64Bit();
unsigned CallOpc = Callee.isReg()
? (Is64Bit ? X86::CALL64r : X86::CALL32r)
: (Is64Bit ? X86::CALL64pcrel32 : X86::CALLpcrel32);
auto MIB = MIRBuilder.buildInstrNoInsert(CallOpc).add(Callee).addRegMask(
TRI->getCallPreservedMask(MF, CallConv));
SmallVector<ArgInfo, 8> SplitArgs;
for (const auto &OrigArg : OrigArgs) {
// TODO: handle not simple cases.
if (OrigArg.Flags.isByVal())
return false;
if (!splitToValueTypes(OrigArg, SplitArgs, DL, MRI,
[&](ArrayRef<unsigned> Regs) {
MIRBuilder.buildUnmerge(Regs, OrigArg.Reg);
}))
return false;
}
// Do the actual argument marshalling.
OutgoingValueHandler Handler(MIRBuilder, MRI, MIB, CC_X86);
if (!handleAssignments(MIRBuilder, SplitArgs, Handler))
return false;
bool IsFixed = OrigArgs.empty() ? true : OrigArgs.back().IsFixed;
if (STI.is64Bit() && !IsFixed && !STI.isCallingConvWin64(CallConv)) {
// From AMD64 ABI document:
// For calls that may call functions that use varargs or stdargs
// (prototype-less calls or calls to functions containing ellipsis (...) in
// the declaration) %al is used as hidden argument to specify the number
// of SSE registers used. The contents of %al do not need to match exactly
// the number of registers, but must be an ubound on the number of SSE
// registers used and is in the range 0 - 8 inclusive.
MIRBuilder.buildInstr(X86::MOV8ri)
.addDef(X86::AL)
.addImm(Handler.getNumXmmRegs());
MIB.addUse(X86::AL, RegState::Implicit);
}
// Now we can add the actual call instruction to the correct basic block.
MIRBuilder.insertInstr(MIB);
// If Callee is a reg, since it is used by a target specific
// instruction, it must have a register class matching the
// constraint of that instruction.
if (Callee.isReg())
MIB->getOperand(0).setReg(constrainOperandRegClass(
MF, *TRI, MRI, *MF.getSubtarget().getInstrInfo(),
*MF.getSubtarget().getRegBankInfo(), *MIB, MIB->getDesc(), Callee, 0));
// Finally we can copy the returned value back into its virtual-register. In
// symmetry with the arguments, the physical register must be an
// implicit-define of the call instruction.
if (OrigRet.Reg) {
SplitArgs.clear();
SmallVector<unsigned, 8> NewRegs;
if (!splitToValueTypes(OrigRet, SplitArgs, DL, MRI,
[&](ArrayRef<unsigned> Regs) {
NewRegs.assign(Regs.begin(), Regs.end());
}))
return false;
CallReturnHandler Handler(MIRBuilder, MRI, RetCC_X86, MIB);
if (!handleAssignments(MIRBuilder, SplitArgs, Handler))
return false;
if (!NewRegs.empty())
MIRBuilder.buildMerge(OrigRet.Reg, NewRegs);
}
CallSeqStart.addImm(Handler.getStackSize())
.addImm(0 /* see getFrameTotalSize */)
//.........这里部分代码省略.........