PreVerifier() : FunctionPass(&ID) { }
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ }
+
// Check that the prerequisites for successful DominatorTree construction
// are satisfied.
bool runOnFunction(Function &F) {
}
void Verifier::visitSelectInst(SelectInst &SI) {
- if (const VectorType* vt
- = dyn_cast<VectorType>(SI.getCondition()->getType())) {
- Assert1( vt->getElementType() == Type::Int1Ty,
- "Select condition type must be vector of bool!", &SI);
- if (const VectorType* val_vt
- = dyn_cast<VectorType>(SI.getTrueValue()->getType())) {
- Assert1( vt->getNumElements() == val_vt->getNumElements(),
- "Select vector size != value vector size", &SI);
- } else {
- Assert1(0, "Vector select values must have vector types", &SI);
- }
- } else {
- Assert1(SI.getCondition()->getType() == Type::Int1Ty,
- "Select condition type must be bool!", &SI);
- }
- Assert1(SI.getTrueValue()->getType() == SI.getFalseValue()->getType(),
- "Select values must have identical types!", &SI);
+ Assert1(!SelectInst::areInvalidOperands(SI.getOperand(0), SI.getOperand(1),
+ SI.getOperand(2)),
+ "Invalid operands for select instruction!", &SI);
+
Assert1(SI.getTrueValue()->getType() == SI.getType(),
"Select values must have same type as select instruction!", &SI);
visitInstruction(SI);
InstsInThisBlock.insert(&I);
}
+// Flags used by TableGen to mark intrinsic parameters with the
+// LLVMExtendedElementVectorType and LLVMTruncatedElementVectorType classes.
+static const unsigned ExtendedElementVectorType = 0x40000000;
+static const unsigned TruncatedElementVectorType = 0x20000000;
+
/// visitIntrinsicFunction - Allow intrinsics to be verified in different ways.
///
void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
unsigned NumElts = 0;
const Type *EltTy = Ty;
- if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) {
+ const VectorType *VTy = dyn_cast<VectorType>(Ty);
+ if (VTy) {
EltTy = VTy->getElementType();
NumElts = VTy->getNumElements();
}
if (VT < 0) {
int Match = ~VT;
+
+ // Check flags that indicate a type that is an integral vector type with
+ // elements that are larger or smaller than the elements of the matched
+ // type.
+ if ((Match & (ExtendedElementVectorType |
+ TruncatedElementVectorType)) != 0) {
+ const IntegerType *IEltTy = dyn_cast<IntegerType>(EltTy);
+ if (!VTy || !IEltTy) {
+ CheckFailed("Intrinsic parameter #" + utostr(ArgNo - 1) + " is not "
+ "an integral vector type.", F);
+ return false;
+ }
+ // Adjust the current Ty (in the opposite direction) rather than
+ // the type being matched against.
+ if ((Match & ExtendedElementVectorType) != 0) {
+ if ((IEltTy->getBitWidth() & 1) != 0) {
+ CheckFailed("Intrinsic parameter #" + utostr(ArgNo - 1) + " vector "
+ "element bit-width is odd.", F);
+ return false;
+ }
+ Ty = VectorType::getTruncatedElementVectorType(VTy);
+ } else
+ Ty = VectorType::getExtendedElementVectorType(VTy);
+ Match &= ~(ExtendedElementVectorType | TruncatedElementVectorType);
+ }
+
const Type *RetTy = FTy->getReturnType();
const StructType *ST = dyn_cast<StructType>(RetTy);
unsigned NumRets = 1;