// Unary Operators
//===--------------------------------------------------------------------===//
- Value *CreateNeg(Constant *C, bool HasNUW = false,
- bool HasNSW = false) const override {
- return ConstFolder.CreateNeg(C, HasNUW, HasNSW);
- }
Value *CreateFNeg(Constant *C) const override {
return ConstFolder.CreateFNeg(C);
}
// Unary Operators
//===--------------------------------------------------------------------===//
- Constant *CreateNeg(Constant *C,
- bool HasNUW = false, bool HasNSW = false) const override {
- return Fold(ConstantExpr::getNeg(C, HasNUW, HasNSW));
- }
Constant *CreateFNeg(Constant *C) const override {
return Fold(ConstantExpr::getFNeg(C));
}
// Unary Operators
//===--------------------------------------------------------------------===//
- Constant *CreateNeg(Constant *C,
- bool HasNUW = false, bool HasNSW = false) const override {
- return ConstantExpr::getNeg(C, HasNUW, HasNSW);
- }
-
Constant *CreateFNeg(Constant *C) const override {
return ConstantExpr::getFNeg(C);
}
Optional<RoundingMode> Rounding = None,
Optional<fp::ExceptionBehavior> Except = None);
- Value *CreateNeg(Value *V, const Twine &Name = "",
- bool HasNUW = false, bool HasNSW = false) {
- if (auto *VC = dyn_cast<Constant>(V))
- return Insert(Folder.CreateNeg(VC, HasNUW, HasNSW), Name);
- BinaryOperator *BO = Insert(BinaryOperator::CreateNeg(V), Name);
- if (HasNUW) BO->setHasNoUnsignedWrap();
- if (HasNSW) BO->setHasNoSignedWrap();
- return BO;
+ Value *CreateNeg(Value *V, const Twine &Name = "", bool HasNUW = false,
+ bool HasNSW = false) {
+ return CreateSub(Constant::getNullValue(V->getType()), V, Name, HasNUW,
+ HasNSW);
}
Value *CreateNSWNeg(Value *V, const Twine &Name = "") {
// Unary Operators
//===--------------------------------------------------------------------===//
- virtual Value *CreateNeg(Constant *C,
- bool HasNUW = false, bool HasNSW = false) const = 0;
virtual Value *CreateFNeg(Constant *C) const = 0;
virtual Value *CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const = 0;
// Unary Operators
//===--------------------------------------------------------------------===//
- Instruction *CreateNeg(Constant *C,
- bool HasNUW = false,
- bool HasNSW = false) const override {
- BinaryOperator *BO = BinaryOperator::CreateNeg(C);
- if (HasNUW) BO->setHasNoUnsignedWrap();
- if (HasNSW) BO->setHasNoSignedWrap();
- return BO;
- }
-
Instruction *CreateFNeg(Constant *C) const override {
return UnaryOperator::CreateFNeg(C);
}