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


C++ FunctionState::getIndex方法代码示例

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


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

示例1: printComparable

void printComparable(llvm::raw_ostream &Out, FunctionState const &State)
{
  Out << "  Function [Index=" << State.getIndex() << "]\n";

  Out << "   Allocas:\n";
  for (auto const &Alloca : State.getAllocas()) {
    Out << "    " << Alloca.getInstructionIndex()
        <<  " =[" << Alloca.getElementCount()
        <<    "x" << Alloca.getElementSize()
        <<  "]\n";
  }

  Out << "   Instruction values [Active=";
  if (State.getActiveInstructionIndex().assigned(0))
    Out << State.getActiveInstructionIndex().get<0>();
  else
    Out << "unassigned";
  Out << "]:\n";

  auto const InstructionCount = State.getInstructionCount();
  for (std::size_t i = 0; i < InstructionCount; ++i) {
    auto const Instruction = State.getInstruction(i);
    auto const Type = Instruction->getType();

    if (llvm::isa<llvm::IntegerType>(Type)) {
      auto const UValue = State.getValueUInt64(Instruction);
      if (UValue.assigned<uint64_t>()) {
        auto const SValue = State.getValueInt64(Instruction);
        assert(SValue.assigned<int64_t>());

        Out << "    " << i << " = (int64_t)" << SValue.get< int64_t>()
                           << ", (uint64_t)" << UValue.get<uint64_t>() << "\n";
      }
    }
    else if (Type->isPointerTy()) {
      auto const Value = State.getValuePtr(Instruction);
      if (Value.assigned<stateptr_ty>()) {
        Out << "    " << i << " = \n";
        // TODO: a comparable pointer representation (this requires us to
        //       determine the allocation that a pointer references, and then
        //       display the pointer value relative to that allocation).
      }
    }
    else if (Type->isFloatTy()) {
      auto const Value = State.getValueFloat(Instruction);
      if (Value.assigned<float>()) {
        Out << "    " << i << " = (float)" << Value.get<float>() << "\n";
      }
    }
    else if (Type->isDoubleTy()) {
      auto const Value = State.getValueDouble(Instruction);
      if (Value.assigned<double>()) {
        Out << "    " << i << " = (double)" << Value.get<double>() << "\n";
      }
    }
    else if (Type->isX86_FP80Ty() || Type->isFP128Ty() || Type->isPPC_FP128Ty())
    {
      auto const Value = State.getValueAPFloat(Instruction);
      if (Value.assigned<llvm::APFloat>()) {
        llvm::SmallString<32> Buffer;
        Value.get<llvm::APFloat>().toString(Buffer);
        Out << "    " << i << " = (long double)" << Buffer << "\n";
      }
    }
  }
}
开发者ID:mheinsen,项目名称:seec,代码行数:66,代码来源:FunctionState.cpp


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