1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[IR] Add classof methods to ConstantExpr subclasses.

I didn't notice these were missing when I wrote 1544019.
This commit is contained in:
Eli Friedman 2020-07-01 11:54:18 -07:00
parent 91cea6e36b
commit 6e5136dc96

View File

@ -56,6 +56,14 @@ public:
}
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 @@ public:
/// 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 @@ public:
/// 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 @@ public:
/// 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 @@ public:
/// 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 @@ public:
/// 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