aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Bitcode/LLVMBitCodes.h8
-rw-r--r--include/llvm/Constants.h1
-rw-r--r--include/llvm/InstrTypes.h2
-rw-r--r--include/llvm/Operator.h53
4 files changed, 50 insertions, 14 deletions
diff --git a/include/llvm/Bitcode/LLVMBitCodes.h b/include/llvm/Bitcode/LLVMBitCodes.h
index d15c3ce93e..7692bd2872 100644
--- a/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/include/llvm/Bitcode/LLVMBitCodes.h
@@ -199,10 +199,10 @@ namespace bitc {
OBO_NO_SIGNED_WRAP = 1
};
- /// SDivOperatorOptionalFlags - Flags for serializing SDivOperator's
- /// SubclassOptionalData contents.
- enum SDivOperatorOptionalFlags {
- SDIV_EXACT = 0
+ /// PossiblyExactOperatorOptionalFlags - Flags for serializing
+ /// PossiblyExactOperator's SubclassOptionalData contents.
+ enum PossiblyExactOperatorOptionalFlags {
+ PEO_EXACT = 0
};
// The function body block (FUNCTION_BLOCK_ID) describes function bodies. It
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index a7653948f1..b782737d31 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -725,6 +725,7 @@ public:
static Constant *getNSWMul(Constant *C1, Constant *C2);
static Constant *getNUWMul(Constant *C1, Constant *C2);
static Constant *getExactSDiv(Constant *C1, Constant *C2);
+ static Constant *getExactUDiv(Constant *C1, Constant *C2);
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index 9dcf688358..1bb50b78fa 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -341,7 +341,7 @@ public:
BO->setIsExact(true);
return BO;
}
-
+
/// Helper functions to construct and inspect unary operations (NEG and NOT)
/// via binary operators SUB and XOR:
///
diff --git a/include/llvm/Operator.h b/include/llvm/Operator.h
index 3aae586f14..288edf1224 100644
--- a/include/llvm/Operator.h
+++ b/include/llvm/Operator.h
@@ -173,30 +173,47 @@ public:
}
};
-/// SDivOperator - An Operator with opcode Instruction::SDiv.
-///
-class SDivOperator : public Operator {
+/// PossiblyExactOperator - A udiv or sdiv instruction, which can be marked as
+/// "exact", indicating that no bits are destroyed.
+class PossiblyExactOperator : public Operator {
public:
enum {
IsExact = (1 << 0)
};
-
-private:
- ~SDivOperator(); // do not implement
-
+
friend class BinaryOperator;
friend class ConstantExpr;
void setIsExact(bool B) {
SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact);
}
-
+
+private:
+ ~PossiblyExactOperator(); // do not implement
public:
/// isExact - Test whether this division is known to be exact, with
/// zero remainder.
bool isExact() const {
return SubclassOptionalData & IsExact;
}
-
+
+ static inline bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::SDiv ||
+ CE->getOpcode() == Instruction::UDiv;
+ }
+ static inline bool classof(const Instruction *I) {
+ return I->getOpcode() == Instruction::SDiv ||
+ I->getOpcode() == Instruction::UDiv;
+ }
+ static inline bool classof(const Value *V) {
+ return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
+ (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
+ }
+};
+
+/// SDivOperator - An Operator with opcode Instruction::SDiv.
+///
+class SDivOperator : public PossiblyExactOperator {
+public:
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const SDivOperator *) { return true; }
static inline bool classof(const ConstantExpr *CE) {
@@ -211,6 +228,24 @@ public:
}
};
+/// UDivOperator - An Operator with opcode Instruction::SDiv.
+///
+class UDivOperator : public PossiblyExactOperator {
+public:
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const UDivOperator *) { return true; }
+ static inline bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::UDiv;
+ }
+ static inline bool classof(const Instruction *I) {
+ return I->getOpcode() == Instruction::UDiv;
+ }
+ static inline bool classof(const Value *V) {
+ return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
+ (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
+ }
+};
+
class GEPOperator : public Operator {
enum {
IsInBounds = (1 << 0)