[llvm-commits] [llvm] r125002 - in /llvm/trunk/include/llvm: InstrTypes.h Operator.h Support/ConstantFolder.h Support/IRBuilder.h Support/NoFolder.h Support/TargetFolder.h

Duncan Sands baldrick at free.fr
Mon Feb 7 01:21:52 PST 2011


Author: baldrick
Date: Mon Feb  7 03:21:52 2011
New Revision: 125002

URL: http://llvm.org/viewvc/llvm-project?rev=125002&view=rev
Log:
Add IRBuilder methods for creating an exact udiv, like for exact sdiv.

Modified:
    llvm/trunk/include/llvm/InstrTypes.h
    llvm/trunk/include/llvm/Operator.h
    llvm/trunk/include/llvm/Support/ConstantFolder.h
    llvm/trunk/include/llvm/Support/IRBuilder.h
    llvm/trunk/include/llvm/Support/NoFolder.h
    llvm/trunk/include/llvm/Support/TargetFolder.h

Modified: llvm/trunk/include/llvm/InstrTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InstrTypes.h?rev=125002&r1=125001&r2=125002&view=diff
==============================================================================
--- llvm/trunk/include/llvm/InstrTypes.h (original)
+++ llvm/trunk/include/llvm/InstrTypes.h Mon Feb  7 03:21:52 2011
@@ -321,6 +321,27 @@
     return BO;
   }
 
+  /// CreateExactUDiv - Create a UDiv operator with the exact flag set.
+  ///
+  static BinaryOperator *CreateExactUDiv(Value *V1, Value *V2,
+                                         const Twine &Name = "") {
+    BinaryOperator *BO = CreateUDiv(V1, V2, Name);
+    BO->setIsExact(true);
+    return BO;
+  }
+  static BinaryOperator *CreateExactUDiv(Value *V1, Value *V2,
+                                         const Twine &Name, BasicBlock *BB) {
+    BinaryOperator *BO = CreateUDiv(V1, V2, Name, BB);
+    BO->setIsExact(true);
+    return BO;
+  }
+  static BinaryOperator *CreateExactUDiv(Value *V1, Value *V2,
+                                         const Twine &Name, Instruction *I) {
+    BinaryOperator *BO = CreateUDiv(V1, V2, Name, I);
+    BO->setIsExact(true);
+    return BO;
+  }
+
   /// CreateExactSDiv - Create an SDiv operator with the exact flag set.
   ///
   static BinaryOperator *CreateExactSDiv(Value *V1, Value *V2,

Modified: llvm/trunk/include/llvm/Operator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Operator.h?rev=125002&r1=125001&r2=125002&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Operator.h (original)
+++ llvm/trunk/include/llvm/Operator.h Mon Feb  7 03:21:52 2011
@@ -228,7 +228,7 @@
   }
 };
 
-/// UDivOperator - An Operator with opcode Instruction::SDiv.
+/// UDivOperator - An Operator with opcode Instruction::UDiv.
 ///
 class UDivOperator : public PossiblyExactOperator {
 public:

Modified: llvm/trunk/include/llvm/Support/ConstantFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ConstantFolder.h?rev=125002&r1=125001&r2=125002&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ConstantFolder.h (original)
+++ llvm/trunk/include/llvm/Support/ConstantFolder.h Mon Feb  7 03:21:52 2011
@@ -72,6 +72,9 @@
   Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
     return ConstantExpr::getUDiv(LHS, RHS);
   }
+  Constant *CreateExactUDiv(Constant *LHS, Constant *RHS) const {
+    return ConstantExpr::getExactUDiv(LHS, RHS);
+  }
   Constant *CreateSDiv(Constant *LHS, Constant *RHS) const {
     return ConstantExpr::getSDiv(LHS, RHS);
   }

Modified: llvm/trunk/include/llvm/Support/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=125002&r1=125001&r2=125002&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/IRBuilder.h Mon Feb  7 03:21:52 2011
@@ -527,6 +527,12 @@
         return Insert(Folder.CreateUDiv(LC, RC), Name);
     return Insert(BinaryOperator::CreateUDiv(LHS, RHS), Name);
   }
+  Value *CreateExactUDiv(Value *LHS, Value *RHS, const Twine &Name = "") {
+    if (Constant *LC = dyn_cast<Constant>(LHS))
+      if (Constant *RC = dyn_cast<Constant>(RHS))
+        return Insert(Folder.CreateExactUDiv(LC, RC), Name);
+    return Insert(BinaryOperator::CreateExactUDiv(LHS, RHS), Name);
+  }
   Value *CreateSDiv(Value *LHS, Value *RHS, const Twine &Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))

Modified: llvm/trunk/include/llvm/Support/NoFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/NoFolder.h?rev=125002&r1=125001&r2=125002&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/NoFolder.h (original)
+++ llvm/trunk/include/llvm/Support/NoFolder.h Mon Feb  7 03:21:52 2011
@@ -77,6 +77,9 @@
   Instruction *CreateUDiv(Constant *LHS, Constant *RHS) const {
     return BinaryOperator::CreateUDiv(LHS, RHS);
   }
+  Instruction *CreateExactUDiv(Constant *LHS, Constant *RHS) const {
+    return BinaryOperator::CreateExactUDiv(LHS, RHS);
+  }
   Instruction *CreateSDiv(Constant *LHS, Constant *RHS) const {
     return BinaryOperator::CreateSDiv(LHS, RHS);
   }

Modified: llvm/trunk/include/llvm/Support/TargetFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=125002&r1=125001&r2=125002&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/TargetFolder.h (original)
+++ llvm/trunk/include/llvm/Support/TargetFolder.h Mon Feb  7 03:21:52 2011
@@ -85,6 +85,9 @@
   Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
     return Fold(ConstantExpr::getUDiv(LHS, RHS));
   }
+  Constant *CreateExactUDiv(Constant *LHS, Constant *RHS) const {
+    return Fold(ConstantExpr::getExactUDiv(LHS, RHS));
+  }
   Constant *CreateSDiv(Constant *LHS, Constant *RHS) const {
     return Fold(ConstantExpr::getSDiv(LHS, RHS));
   }





More information about the llvm-commits mailing list