mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-31 09:25:42 +00:00
move select validation logic into a shared place where the select ctor,
verifier, asm parser, etc can share it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61461 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -138,6 +138,33 @@ TerminatorInst::~TerminatorInst() {
|
||||
UnaryInstruction::~UnaryInstruction() {
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// SelectInst Class
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// areInvalidOperands - Return a string if the specified operands are invalid
|
||||
/// for a select operation, otherwise return null.
|
||||
const char *SelectInst::areInvalidOperands(Value *Op0, Value *Op1, Value *Op2) {
|
||||
if (Op1->getType() != Op2->getType())
|
||||
return "both values to select must have same type";
|
||||
|
||||
if (const VectorType *VT = dyn_cast<VectorType>(Op0->getType())) {
|
||||
// Vector select.
|
||||
if (VT->getElementType() != Type::Int1Ty)
|
||||
return "vector select condition element type must be i1";
|
||||
const VectorType *ET = dyn_cast<VectorType>(Op1->getType());
|
||||
if (ET == 0)
|
||||
return "selected values for vector select must be vectors";
|
||||
if (ET->getNumElements() != VT->getNumElements())
|
||||
return "vector select requires selected vectors to have "
|
||||
"the same vector length as select condition";
|
||||
} else if (Op0->getType() != Type::Int1Ty) {
|
||||
return "select condition must be i1 or <n x i1>";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// PHINode Class
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
Reference in New Issue
Block a user