예제 #1
0
파일: User.cpp 프로젝트: Bigcheese/llvm
void User::growHungoffUses(unsigned NewNumUses, bool IsPhi) {
  assert(HasHungOffUses && "realloc must have hung off uses");

  unsigned OldNumUses = getNumOperands();

  // We don't support shrinking the number of uses.  We wouldn't have enough
  // space to copy the old uses in to the new space.
  assert(NewNumUses > OldNumUses && "realloc must grow num uses");

  Use *OldOps = getOperandList();
  allocHungoffUses(NewNumUses, IsPhi);
  Use *NewOps = getOperandList();

  // Now copy from the old operands list to the new one.
  std::copy(OldOps, OldOps + OldNumUses, NewOps);

  // If this is a Phi, then we need to copy the BB pointers too.
  if (IsPhi) {
    auto *OldPtr =
        reinterpret_cast<char *>(OldOps + OldNumUses) + sizeof(Use::UserRef);
    auto *NewPtr =
        reinterpret_cast<char *>(NewOps + NewNumUses) + sizeof(Use::UserRef);
    std::copy(OldPtr, OldPtr + (OldNumUses * sizeof(BasicBlock *)), NewPtr);
  }
  Use::zap(OldOps, OldOps + OldNumUses, true);
}
예제 #2
0
파일: User.cpp 프로젝트: artagnon/rhine
void User::setOperand(int i, Value *Val) {
  int Offset = NumAllocatedOps - NumOperands;
  assert(i >= -Offset && "setOperand() given negative value!");
  assert(i < (int)NumOperands && "setOperand() out of range!");
  assert(!isa<Constant>(cast<Value>(this)) &&
         "Cannot mutate a constant with setOperand!");
  getOperandList()[i + Offset].set(Val);
}
예제 #3
0
파일: User.cpp 프로젝트: artagnon/rhine
Value *User::getOperand(int i) const {
  int Offset = NumAllocatedOps - NumOperands;
  assert(i >= -Offset && "getOperand() given negative value!");
  assert(i < (int)NumOperands && "getOperand() out of range!");
  return getOperandList()[i + Offset];
}