本文整理汇总了C++中FunctionSet::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionSet::insert方法的具体用法?C++ FunctionSet::insert怎么用?C++ FunctionSet::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FunctionSet
的用法示例。
在下文中一共展示了FunctionSet::insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findAllFunctionPointersInValue
void FPInferredTargetsAnalysis::findAllFunctionPointersInValue(Value* V, ValueContextPairList& worklist, ValueSet& visited) {
if (!visited.count(V)) {
visited.insert(V);
if (GlobalVariable* G = dyn_cast<GlobalVariable>(V)) {
SDEBUG("soaap.analysis.infoflow.fp.infer", 3, dbgs() << INDENT_1 << "Global var: " << G->getName() << "\n");
// don't look in the llvm.global.annotations array
if (G->getName() != "llvm.global.annotations" && G->hasInitializer()) {
findAllFunctionPointersInValue(G->getInitializer(), worklist, visited);
}
}
else if (ConstantArray* CA = dyn_cast<ConstantArray>(V)) {
SDEBUG("soaap.analysis.infoflow.fp.infer", 3, dbgs() << INDENT_1 << "Constant array, num of operands: " << CA->getNumOperands() << "\n");
for (int i=0; i<CA->getNumOperands(); i++) {
Value* V2 = CA->getOperand(i)->stripInBoundsOffsets();
findAllFunctionPointersInValue(V2, worklist, visited);
}
}
else if (Function* F = dyn_cast<Function>(V)) {
fpTargetsUniv.insert(F);
SDEBUG("soaap.analysis.infoflow.fp.infer", 3, dbgs() << INDENT_1 << "Func: " << F->getName() << "\n");
setBitVector(state[ContextUtils::NO_CONTEXT][V], F);
addToWorklist(V, ContextUtils::NO_CONTEXT, worklist);
}
else if (ConstantStruct* S = dyn_cast<ConstantStruct>(V)) {
SDEBUG("soaap.analysis.infoflow.fp.infer", 3, dbgs() << INDENT_1 << "Struct, num of fields: " << S->getNumOperands() << "\n");
for (int j=0; j<S->getNumOperands(); j++) {
Value* V2 = S->getOperand(j)->stripInBoundsOffsets();
findAllFunctionPointersInValue(V2, worklist, visited);
}
}
}
}
示例2: addInferredFunction
void FPInferredTargetsAnalysis::addInferredFunction(
Function *F, ContextVector contexts, Value *V,
ValueContextPairList& worklist) {
fpTargetsUniv.insert(F);
for (Context* Ctx : contexts) {
setBitVector(state[Ctx][V], F);
addToWorklist(V, Ctx, worklist);
}
}
示例3: initialise
void FPInferredTargetsAnalysis::initialise(ValueContextPairList& worklist, Module& M, SandboxVector& sandboxes) {
FPTargetsAnalysis::initialise(worklist, M, sandboxes);
SDEBUG("soaap.analysis.infoflow.fp.infer", 3, dbgs() << "Running FP inferred targets analysis\n");
bool debug = false;
SDEBUG("soaap.analysis.infoflow.fp.infer", 3, debug = true);
if (debug) {
dbgs() << "Program statistics:\n";
// find all assignments of functions and propagate them!
long numFuncs = 0;
long numFPFuncs = 0;
long numFPcalls = 0;
long numInsts = 0;
long numAddFuncs = 0;
long loadInsts = 0;
long storeInsts = 0;
long intrinsInsts = 0;
for (Function& F : M.functions()) {
if (F.hasAddressTaken()) numAddFuncs++;
bool hasFPcall = false;
for (Instruction& I : instructions(&F)) {
numInsts++;
if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(&I)) {
intrinsInsts++;
}
else if (CallInst* C = dyn_cast<CallInst>(&I)) {
if (CallGraphUtils::isIndirectCall(C)) {
hasFPcall = true;
numFPcalls++;
}
}
else if (LoadInst* L = dyn_cast<LoadInst>(&I)) {
loadInsts++;
}
else if (StoreInst* S = dyn_cast<StoreInst>(&I)) {
storeInsts++;
}
}
if (hasFPcall) {
numFPFuncs++;
}
numFuncs++;
}
dbgs() << "Num of funcs (total): " << numFuncs << "\n";
dbgs() << "Num of funcs (w/ fp calls): " << numFPFuncs << "\n";
dbgs() << "Num of funcs (addr. taken): " << numAddFuncs << "\n";
dbgs() << "Num of fp calls: " << numFPcalls << "\n";
dbgs() << "Num of instructions: " << numInsts << "\n";
dbgs() << INDENT_1 << "loads: " << loadInsts << "\n";
dbgs() << INDENT_1 << "stores: " << storeInsts << "\n";
dbgs() << INDENT_1 << "intrinsics: " << intrinsInsts << "\n";
}
for (Function& F : M.functions()) {
if (F.isDeclaration()) continue;
SDEBUG("soaap.analysis.infoflow.fp.infer", 3, dbgs() << F.getName() << "\n");
for (Instruction& I : instructions(&F)) {
ContextVector contexts = ContextUtils::getContextsForInstruction(&I, contextInsensitive, sandboxes, M);
if (StoreInst* S = dyn_cast<StoreInst>(&I)) { // assignments
//SDEBUG("soaap.analysis.infoflow.fp.infer", 3, dbgs() << F->getName() << ": " << *S);
Value* Rval = S->getValueOperand()->stripInBoundsConstantOffsets();
if (Function* T = dyn_cast<Function>(Rval)) {
fpTargetsUniv.insert(T);
// we are assigning a function
Value* Lvar = S->getPointerOperand()->stripInBoundsConstantOffsets();
for (Context* C : contexts) {
setBitVector(state[C][Lvar], T);
SDEBUG("soaap.analysis.infoflow.fp.infer", 3, dbgs() << "Adding " << Lvar->getName() << " to worklist\n");
addToWorklist(Lvar, C, worklist);
if (isa<GetElementPtrInst>(Lvar)) {
SDEBUG("soaap.analysis.infoflow.fp.infer", 3, dbgs() << "Rewinding back to alloca\n");
ValueSet visited;
propagateToAggregate(Lvar, C, Lvar, visited, worklist, sandboxes, M);
}
}
}
}
else if (SelectInst* S = dyn_cast<SelectInst>(&I)) {
if (Function* F = dyn_cast<Function>(S->getTrueValue()->stripPointerCasts())) {
addInferredFunction(F, contexts, S, worklist);
}
if (Function* F = dyn_cast<Function>(S->getFalseValue()->stripPointerCasts())) {
addInferredFunction(F, contexts, S, worklist);
}
}
else if (CallInst* C = dyn_cast<CallInst>(&I)) { // passing functions as params
if (Function* callee = CallGraphUtils::getDirectCallee(C)) {
int argIdx = 0;
for (Argument& AI : callee->args()) {
Value* Arg = C->getArgOperand(argIdx)->stripPointerCasts();
if (Function* T = dyn_cast<Function>(Arg)) {
addInferredFunction(T, contexts, &AI, worklist);
}
argIdx++;
}
}
}
//.........这里部分代码省略.........
示例4: run
/**
* Run the inverse Dynamics tool.
*/
bool InverseDynamicsTool::run()
{
bool success = false;
bool modelFromFile=true;
try{
//Load and create the indicated model
if (!_model)
_model = new Model(_modelFileName);
else
modelFromFile = false;
_model->printBasicInfo(cout);
cout<<"Running tool " << getName() <<".\n"<<endl;
// Do the maneuver to change then restore working directory
// so that the parsing code behaves properly if called from a different directory.
string saveWorkingDirectory = IO::getCwd();
string directoryOfSetupFile = IO::getParentDirectory(getDocumentFileName());
IO::chDir(directoryOfSetupFile);
const CoordinateSet &coords = _model->getCoordinateSet();
int nq = _model->getNumCoordinates();
FunctionSet *coordFunctions = NULL;
//Storage *coordinateValues = NULL;
if(hasCoordinateValues()){
if(_lowpassCutoffFrequency>=0) {
cout<<"\n\nLow-pass filtering coordinates data with a cutoff frequency of "<<_lowpassCutoffFrequency<<"..."<<endl<<endl;
_coordinateValues->pad(_coordinateValues->getSize()/2);
_coordinateValues->lowpassIIR(_lowpassCutoffFrequency);
if (getVerboseLevel()==Debug) _coordinateValues->print("coordinateDataFiltered.sto");
}
// Convert degrees to radian if indicated
if(_coordinateValues->isInDegrees()){
_model->getSimbodyEngine().convertDegreesToRadians(*_coordinateValues);
}
// Create differentiable splines of the coordinate data
coordFunctions = new GCVSplineSet(5, _coordinateValues);
//Functions must correspond to model coordinates and their order for the solver
for(int i=0; i<nq; i++){
if(coordFunctions->contains(coords[i].getName())){
coordFunctions->insert(i,coordFunctions->get(coords[i].getName()));
}
else{
coordFunctions->insert(i,new Constant(coords[i].getDefaultValue()));
std::cout << "InverseDynamicsTool: coordinate file does not contain coordinate " << coords[i].getName() << " assuming default value" << std::endl;
}
}
if(coordFunctions->getSize() > nq){
coordFunctions->setSize(nq);
}
}
else{
IO::chDir(saveWorkingDirectory);
throw Exception("InverseDynamicsTool: no coordinate file found.");
}
bool externalLoads = createExternalLoads(_externalLoadsFileName, *_model, _coordinateValues);
// Initialize the the model's underlying computational system and get its default state.
SimTK::State& s = _model->initSystem();
// Exclude user-specified forces from the dynamics for this analysis
disableModelForces(*_model, s, _excludedForces);
double first_time = _coordinateValues->getFirstTime();
double last_time = _coordinateValues->getLastTime();
// Determine the starting and final time for the Tool by comparing to what data is available
double start_time = ( first_time > _timeRange[0]) ? first_time : _timeRange[0];
double final_time = ( last_time < _timeRange[1]) ? last_time : _timeRange[1];
int start_index = _coordinateValues->findIndex(start_time);
int final_index = _coordinateValues->findIndex(final_time);
// create the solver given the input data
InverseDynamicsSolver ivdSolver(*_model);
const clock_t start = clock();
int nt = final_index-start_index+1;
Array_<double> times(nt, 0.0);
for(int i=0; i<nt; i++){
times[i]=_coordinateValues->getStateVector(start_index+i)->getTime();
}
// Preallocate results
Array_<Vector> genForceTraj(nt, Vector(nq, 0.0));
// solve for the trajectory of generlized forces that correspond to the coordinate
// trajectories provided
ivdSolver.solve(s, *coordFunctions, times, genForceTraj);
success = true;
//.........这里部分代码省略.........
示例5: Function
static void
new_function_entry(void *addr, string *comment, bool isvisible, int call_count)
{
Function *f = new Function(addr, comment, isvisible, call_count);
function_entries.insert(pair<void*, Function*>(addr, f));
}