[llvm] 779e4d8 - [IR] Add classof methods to ConstantExpr subclasses.
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 1 11:57:36 PDT 2020
Author: Eli Friedman
Date: 2020-07-01T11:56:12-07:00
New Revision: 779e4d82dea2d0ecb094252dcc679f8f7d256ca0
URL: https://github.com/llvm/llvm-project/commit/779e4d82dea2d0ecb094252dcc679f8f7d256ca0
DIFF: https://github.com/llvm/llvm-project/commit/779e4d82dea2d0ecb094252dcc679f8f7d256ca0.diff
LOG: [IR] Add classof methods to ConstantExpr subclasses.
I didn't notice these were missing when I wrote 1544019.
Added:
Modified:
llvm/lib/IR/ConstantsContext.h
Removed:
################################################################################
diff --git a/llvm/lib/IR/ConstantsContext.h b/llvm/lib/IR/ConstantsContext.h
index fadbc2169816..95c5ab6d0ee4 100644
--- a/llvm/lib/IR/ConstantsContext.h
+++ b/llvm/lib/IR/ConstantsContext.h
@@ -56,6 +56,14 @@ class UnaryConstantExpr final : public ConstantExpr {
}
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return Instruction::isCast(CE->getOpcode()) ||
+ Instruction::isUnaryOp(CE->getOpcode());
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
/// BinaryConstantExpr - This class is private to Constants.cpp, and is used
@@ -77,6 +85,13 @@ class BinaryConstantExpr final : public ConstantExpr {
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return Instruction::isBinaryOp(CE->getOpcode());
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
/// SelectConstantExpr - This class is private to Constants.cpp, and is used
@@ -97,6 +112,13 @@ class SelectConstantExpr final : public ConstantExpr {
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::Select;
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
/// ExtractElementConstantExpr - This class is private to
@@ -118,6 +140,13 @@ class ExtractElementConstantExpr final : public ConstantExpr {
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::ExtractElement;
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
/// InsertElementConstantExpr - This class is private to
@@ -140,6 +169,13 @@ class InsertElementConstantExpr final : public ConstantExpr {
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::InsertElement;
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
/// ShuffleVectorConstantExpr - This class is private to
@@ -168,6 +204,13 @@ class ShuffleVectorConstantExpr final : public ConstantExpr {
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::ShuffleVector;
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
/// ExtractValueConstantExpr - This class is private to
More information about the llvm-commits
mailing list