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


C++ NamedMDNode::getOperand方法代码示例

本文整理汇总了C++中NamedMDNode::getOperand方法的典型用法代码示例。如果您正苦于以下问题:C++ NamedMDNode::getOperand方法的具体用法?C++ NamedMDNode::getOperand怎么用?C++ NamedMDNode::getOperand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NamedMDNode的用法示例。


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

示例1: parseMoC

MoC* IRParser::parseMoC(Module* module){
    NamedMDNode* mocKeyMD =  module->getNamedMetadata(IRConstant::KEY_MOC);

    if (mocKeyMD == NULL) {
        return new DPNMoC(actor);
    }

    //Parse MoC type
    MDNode* node = mocKeyMD->getOperand(0);
    MDString* name = cast<MDString>(node->getOperand(0));
    StringRef nameStr = name->getString();

    if (nameStr == "SDF"){
        return parseCSDF(cast<MDNode>(node->getOperand(1)));
    }else if(nameStr == "CSDF"){
        return parseCSDF(cast<MDNode>(node->getOperand(1)));
    }else if(nameStr == "QuasiStatic"){
        return parseQSDF(node);
    }else if(nameStr == "KPN"){
        return new KPNMoC(actor);
    }else if(nameStr == "DPN"){
        return new DPNMoC(actor);
    }

    cerr << "Unsupported type of MoC" << endl;
    exit(1);
}
开发者ID:orcc,项目名称:jade,代码行数:27,代码来源:IRParser.cpp

示例2: parseActionScheduler

ActionScheduler* IRParser::parseActionScheduler(Module* module){
    NamedMDNode* inputsMD =  module->getNamedMetadata(IRConstant::KEY_ACTION_SCHED);

    MDNode* actionSchedulerMD = cast<MDNode>(inputsMD->getOperand(0));
    list<Action*>* actions = new list<Action*>();
    FSM* fsm = NULL;

    //Get actions outside fsm if present
    Value* actionsValue = actionSchedulerMD->getOperand(0);

    if (actionsValue != NULL){
        MDNode* actionsNode =  cast<MDNode>(actionsValue);
        for (unsigned i = 0, e = actionsNode->getNumOperands(); i != e; ++i) {
            actions->push_back(getAction(cast<MDNode>(actionsNode->getOperand(i))));
        }
    }

    //Get fsm if present
    Value* fsmValue = actionSchedulerMD->getOperand(1);

    if (fsmValue != NULL){
        fsm = parseFSM(cast<MDNode>(fsmValue));
    }

    return new ActionScheduler(actions, fsm);
}
开发者ID:orcc,项目名称:jade,代码行数:26,代码来源:IRParser.cpp

示例3: parseType

map<string, Variable*>* IRParser::parseParameters(Module* module){
    map<string, Variable*>* parameters = new map<string, Variable*>();

    NamedMDNode* inputsMD =  module->getNamedMetadata(IRConstant::KEY_PARAMETERS);
    if (inputsMD != NULL){
        for (unsigned i = 0, e = inputsMD->getNumOperands(); i != e; ++i) {

            //Parse a parameter
            MDNode* parameterNode = cast<MDNode>(inputsMD->getOperand(i));
            MDNode* details = cast<MDNode>(parameterNode->getOperand(0));
            MDString* nameMD = cast<MDString>(details->getOperand(0));

            Type* type = parseType(cast<MDNode>(parameterNode->getOperand(1)));

            GlobalVariable* variable = cast<GlobalVariable>(parameterNode->getOperand(2));

            //Parse create parameter
            StateVar* parameter = new StateVar(type, nameMD->getString(), false, variable);

            parameters->insert(pair<string, Variable*>(nameMD->getString(), parameter));
        }

    }
    return parameters;
}
开发者ID:orcc,项目名称:jade,代码行数:25,代码来源:IRParser.cpp

示例4: buildCFICheck

/// buildCFICheck - emits __cfi_check for the current module.
void CrossDSOCFI::buildCFICheck() {
  // FIXME: verify that __cfi_check ends up near the end of the code section,
  // but before the jump slots created in LowerBitSets.
  llvm::DenseSet<uint64_t> BitSetIds;
  NamedMDNode *BitSetNM = M->getNamedMetadata("llvm.bitsets");

  if (BitSetNM)
    for (unsigned I = 0, E = BitSetNM->getNumOperands(); I != E; ++I)
      if (ConstantInt *TypeId = extractBitSetTypeId(BitSetNM->getOperand(I)))
        BitSetIds.insert(TypeId->getZExtValue());

  LLVMContext &Ctx = M->getContext();
  Constant *C = M->getOrInsertFunction(
      "__cfi_check",
      FunctionType::get(
          Type::getVoidTy(Ctx),
          {Type::getInt64Ty(Ctx), PointerType::getUnqual(Type::getInt8Ty(Ctx))},
          false));
  Function *F = dyn_cast<Function>(C);
  F->setAlignment(4096);
  auto args = F->arg_begin();
  Argument &CallSiteTypeId = *(args++);
  CallSiteTypeId.setName("CallSiteTypeId");
  Argument &Addr = *(args++);
  Addr.setName("Addr");
  assert(args == F->arg_end());

  BasicBlock *BB = BasicBlock::Create(Ctx, "entry", F);

  BasicBlock *TrapBB = BasicBlock::Create(Ctx, "trap", F);
  IRBuilder<> IRBTrap(TrapBB);
  Function *TrapFn = Intrinsic::getDeclaration(M, Intrinsic::trap);
  llvm::CallInst *TrapCall = IRBTrap.CreateCall(TrapFn);
  TrapCall->setDoesNotReturn();
  TrapCall->setDoesNotThrow();
  IRBTrap.CreateUnreachable();

  BasicBlock *ExitBB = BasicBlock::Create(Ctx, "exit", F);
  IRBuilder<> IRBExit(ExitBB);
  IRBExit.CreateRetVoid();

  IRBuilder<> IRB(BB);
  SwitchInst *SI = IRB.CreateSwitch(&CallSiteTypeId, TrapBB, BitSetIds.size());
  for (uint64_t TypeId : BitSetIds) {
    ConstantInt *CaseTypeId = ConstantInt::get(Type::getInt64Ty(Ctx), TypeId);
    BasicBlock *TestBB = BasicBlock::Create(Ctx, "test", F);
    IRBuilder<> IRBTest(TestBB);
    Function *BitsetTestFn =
        Intrinsic::getDeclaration(M, Intrinsic::bitset_test);

    Value *Test = IRBTest.CreateCall(
        BitsetTestFn, {&Addr, MetadataAsValue::get(
                                  Ctx, ConstantAsMetadata::get(CaseTypeId))});
    BranchInst *BI = IRBTest.CreateCondBr(Test, ExitBB, TrapBB);
    BI->setMetadata(LLVMContext::MD_prof, VeryLikelyWeights);

    SI->addCase(CaseTypeId, TestBB);
    ++TypeIds;
  }
}
开发者ID:2asoft,项目名称:freebsd,代码行数:61,代码来源:CrossDSOCFI.cpp

示例5: assert

static std::string
ModuleMetaGet(const Module *module, StringRef MetaName) {
  NamedMDNode *node = module->getNamedMetadata(MetaName);
  if (node == NULL)
    return "";
  assert(node->getNumOperands() == 1);
  MDNode *subnode = node->getOperand(0);
  assert(subnode->getNumOperands() == 1);
  MDString *value = dyn_cast<MDString>(subnode->getOperand(0));
  assert(value != NULL);
  return value->getString();
}
开发者ID:8l,项目名称:emscripten-fastcomp,代码行数:12,代码来源:Module.cpp

示例6: assert

  void
  SpecializationTable::initialize(Module* m)
  {
    assert(this->module == NULL);
    this->module = m;
#ifdef RECORD_IN_METADATA
    // Parse the module metadata to populate the table
    NamedMDNode* specs = m->getNamedMetadata("previrt::specializations");
    if (specs == NULL)
    return;

    errs() << "Specialization Count: " << specs->getNumOperands() << "\n";

    for (unsigned int i = 0; i < specs->getNumOperands(); ++i) {
      MDNode* funNode = specs->getOperand(i);
      if (funNode == NULL) {
        continue;
      }
      assert (funNode->getNumOperands() > 2);
      MDString* prinName = dyn_cast_or_null<MDString>(funNode->getOperand(0));
      MDString* specName = dyn_cast_or_null<MDString>(funNode->getOperand(1));
      if (prinName == NULL || specName == NULL) {
        errs() << "must skip " << (prinName == NULL ? "?" : prinName->getString()) << "\n";
        continue;
      }
      Function* prin = m->getFunction(prinName->getString());
      Function* spec = m->getFunction(specName->getString());
      if (prin == NULL || spec == NULL) {
        errs() << "must skip " << (prin == NULL ? "?" : prin->getName()) << "\n";
        continue;
      }

      const unsigned int arg_count = prin->getArgumentList().size();
      if (funNode->getNumOperands() != 2 + arg_count) {
        continue;
      }

      SpecScheme scheme = new Value*[arg_count];
      for (unsigned int i = 0; i < arg_count; i++) {
        Value* opr = funNode->getOperand(2 + i);
        if (opr == NULL) {
          scheme[i] = NULL;
        } else {
          assert (dyn_cast<Constant>(opr) != NULL);
          scheme[i] = opr;
        }
      }

      this->addSpecialization(prin, scheme, spec, false);
      errs() << "recording specialization of '" << prin->getName() << "' to '" << spec->getName() << "'\n";
    }
#endif /* RECORD_IN_METADATA */
  }
开发者ID:ishaq,项目名称:OCCAM,代码行数:53,代码来源:SpecializationTable.cpp

示例7: parseActor

Actor* IRParser::parseActor(string classz){
    //Get file and package of the actor
    string file = PackageMng::getSimpleName(classz);
    string packageName = PackageMng::getPackagesName(classz);
    Package* package = PackageMng::getPackage(packageName);

    //Parse the bitcode
    Module* module = parser->loadModule(package, file);

    if (module == 0){
        //Module not found
        cerr << "Error when parsing bytecode";
        exit(1);
    }

    //Empty action list
    actions.clear();
    untaggedActions.clear();

    // Parse name
    NamedMDNode* nameNMD =  module->getNamedMetadata(IRConstant::KEY_NAME);
    MDNode* nameMD = cast<MDNode>(nameNMD->getOperand(0));
    MDString* name = cast<MDString>(nameMD->getOperand(0));

    // Create the new actor
    actor = new Actor(name->getString(), module, classz);

    // Parse actor elements
    inputs = parsePorts(IRConstant::KEY_INPUTS, module);
    outputs = parsePorts(IRConstant::KEY_OUTPUTS, module);
    map<string, Variable*>* parameters =  parseParameters(module);
    map<string, StateVar*>* stateVars = parseStateVars(module);
    map<string, Procedure*>* procs = parseProcs(module);
    list<Action*>* initializes = parseActions(IRConstant::KEY_INITIALIZES, module);
    list<Action*>* actions = parseActions(IRConstant::KEY_ACTIONS, module);
    ActionScheduler* actionScheduler = parseActionScheduler(module);
    MoC* moc = parseMoC(module);

    //Set parameters of the actor
    actor->setInputs(inputs);
    actor->setOutputs(outputs);
    actor->setParameters(parameters);
    actor->setActions(actions);
    actor->setStateVars(stateVars);
    actor->setProcs(procs);
    actor->setActions(actions);
    actor->setInitializes(initializes);
    actor->setActionScheduler(actionScheduler);
    actor->setMoC(moc);

    return actor;
}
开发者ID:orcc,项目名称:jade,代码行数:52,代码来源:IRParser.cpp

示例8: convertMetadataToLibraryList

// @LOCALMOD-BEGIN
void Module::convertMetadataToLibraryList() {
  LibraryList.clear();
  // Get the DepLib node
  NamedMDNode *Node = getNamedMetadata("DepLibs");
  if (!Node)
    return;
  for (unsigned i = 0; i < Node->getNumOperands(); i++) {
    MDString* Mds = dyn_cast_or_null<MDString>(
        Node->getOperand(i)->getOperand(0));
    assert(Mds && "Bad NamedMetadata operand");
    LibraryList.push_back(Mds->getString());
  }
  // Clear the metadata so the linker won't try to merge it
  Node->dropAllReferences();
}
开发者ID:8l,项目名称:emscripten-fastcomp,代码行数:16,代码来源:Module.cpp

示例9: DIG

/// Find the debug info descriptor corresponding to this function.
static Value *findDbgSubprogramDeclare(Function *V) {
  const Module *M = V->getParent();
  NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.sp");
  if (!NMD)
    return 0;

  for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
    DIDescriptor DIG(cast<MDNode>(NMD->getOperand(i)));
    if (!DIG.isSubprogram())
      continue;
    if (DISubprogram(DIG).getFunction() == V)
      return DIG;
  }
  return 0;
}
开发者ID:MedicineYeh,项目名称:LLVM-2.9,代码行数:16,代码来源:DbgInfoPrinter.cpp

示例10: parseAction

list<Action*>* IRParser::parseActions(string key, Module* module){
    list<Action*>* actions = new list<Action*>();

    NamedMDNode* inputsMD =  module->getNamedMetadata(key);

    if (inputsMD == NULL) {
        return actions;
    }

    for (unsigned i = 0, e = inputsMD->getNumOperands(); i != e; ++i) {
        Action* action = parseAction(inputsMD->getOperand(i));
        actions->push_back(action);
    }

    return actions;
}
开发者ID:orcc,项目名称:jade,代码行数:16,代码来源:IRParser.cpp

示例11: parseStateVar

map<string, StateVar*>*  IRParser::parseStateVars(Module* module){
    map<string, StateVar*>* stateVars = new map<string, StateVar*>();

    NamedMDNode* stateVarsMD =  module->getNamedMetadata(IRConstant::KEY_STATE_VARS);

    if (stateVarsMD == NULL) {
        return stateVars;
    }

    for (unsigned i = 0, e = stateVarsMD->getNumOperands(); i != e; ++i) {
        StateVar* var = parseStateVar(stateVarsMD->getOperand(i));
        stateVars->insert(pair<string, StateVar*>(var->getName(), var));
    }

    return stateVars;
}
开发者ID:orcc,项目名称:jade,代码行数:16,代码来源:IRParser.cpp

示例12: printLocation

// Print the main compile unit's source filename, 
// falls back to printing the module identifier.
static void printLocation(const llvm::Module *M)
{
  NamedMDNode *ND = M->getNamedMetadata("llvm.dbg.gv");
  if (ND) {
    unsigned N = ND->getNumOperands();
    // Try to find main compile unit
    for (unsigned i=0;i<N;i++) {
      DIGlobalVariable G(ND->getOperand(i));
      DICompileUnit CU(G.getCompileUnit());
      if (!CU.isMain())
        continue;
      errs() << /*CU.getDirectory() << "/" <<*/ CU.getFilename() << ": ";
      return;
    }
  }
  errs() << M->getModuleIdentifier() << ": ";
}
开发者ID:Udit-Sharma,项目名称:clamav-bytecode-compiler,代码行数:19,代码来源:ClamBCDiagnostics.cpp

示例13: lowerJuliaArrayArguments

  std::vector<Type*> lowerJuliaArrayArguments(Function *OldFunc) {

    Module* M = OldFunc->getParent();
    LLVMContext &context = M->getContext();
    NamedMDNode* JuliaArgs = M->getOrInsertNamedMetadata("julia.args");
    MDNode *node = JuliaArgs->getOperand(0);

    int operand = 0;
    std::vector<Type*> ArgTypes;
    
    for (Function::const_arg_iterator I = OldFunc->arg_begin(), E = OldFunc->arg_end(); I != E; ++I) { 

      Type* argType = I->getType();
      if (is_jl_array_type(argType)) {
        
        // Gets the type from custom metadata
        Value *value = node->getOperand(operand);
        if (MDString* mdstring = dyn_cast<MDString>(value)) {

          if (Type* type = extractType(context, mdstring->getString())) {
            ArgTypes.push_back(type);            
          } else {
            errs() << "Could not extract type: ";
            mdstring->print(errs());
            errs() << "\n";
            exit(1);
          }
        } else {
          errs() << "Could not extract type: ";
          value->print(errs());
          errs() << "\n";
          exit(1);
        }
        
        
      } else {
        ArgTypes.push_back(I->getType());
      }
      operand++;
    }

    return ArgTypes;
    
  }
开发者ID:havardh,项目名称:PTX.jl,代码行数:44,代码来源:lower-array-pass.cpp

示例14: getNeededRecordFor

// Get the NeededRecord for SOName.
// Returns an empty NeededRecord if there was no metadata found.
static void getNeededRecordFor(const Module *M,
                               StringRef SOName,
                               Module::NeededRecord *NR) {
  NR->DynFile = SOName;
  NR->Symbols.clear();

  std::string Key = NeededPrefix;
  Key += SOName;
  NamedMDNode *Node = M->getNamedMetadata(Key);
  if (!Node)
    return;

  for (unsigned k = 0; k < Node->getNumOperands(); ++k) {
    // Insert the symbol name.
    const MDString *SymName =
        dyn_cast<MDString>(Node->getOperand(k)->getOperand(0));
    NR->Symbols.push_back(SymName->getString());
  }
}
开发者ID:8l,项目名称:emscripten-fastcomp,代码行数:21,代码来源:Module.cpp

示例15: FindDynamicInitializers

void AddressSanitizer::FindDynamicInitializers(Module& M) {
  // Clang generates metadata identifying all dynamically initialized globals.
  NamedMDNode *DynamicGlobals =
      M.getNamedMetadata("llvm.asan.dynamically_initialized_globals");
  if (!DynamicGlobals)
    return;
  for (int i = 0, n = DynamicGlobals->getNumOperands(); i < n; ++i) {
    MDNode *MDN = DynamicGlobals->getOperand(i);
    assert(MDN->getNumOperands() == 1);
    Value *VG = MDN->getOperand(0);
    // The optimizer may optimize away a global entirely, in which case we
    // cannot instrument access to it.
    if (!VG)
      continue;

    GlobalVariable *G = cast<GlobalVariable>(VG);
    DynamicallyInitializedGlobals.insert(G);
  }
}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:19,代码来源:AddressSanitizer.cpp


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