[llvm-commits] [124235] emit useful error messages if bad immediates are used
clattner at apple.com
clattner at apple.com
Fri Feb 23 20:31:38 PST 2007
Revision: 124235
Author: clattner
Date: 2007-02-23 20:31:35 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
emit useful error messages if bad immediates are used
Modified Paths:
--------------
apple-local/branches/llvm/gcc/config/rs6000/llvm-rs6000.cpp
Modified: apple-local/branches/llvm/gcc/config/rs6000/llvm-rs6000.cpp
===================================================================
--- apple-local/branches/llvm/gcc/config/rs6000/llvm-rs6000.cpp 2007-02-24 04:15:35 UTC (rev 124234)
+++ apple-local/branches/llvm/gcc/config/rs6000/llvm-rs6000.cpp 2007-02-24 04:31:35 UTC (rev 124235)
@@ -114,7 +114,7 @@
* invocation into normal LLVM code. If the target can handle the builtin, this
* function should emit the expanded code and return true.
*/
-bool TreeToLLVM::TargetIntrinsicLower(tree_node *exp,
+bool TreeToLLVM::TargetIntrinsicLower(tree exp,
unsigned FnCode,
Value *DestLoc,
Value *&Result,
@@ -232,47 +232,59 @@
Elt = ConstantExpr::getIntegerCast(Elt, Type::Int8Ty, true);
Result = BuildVector(Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt,
Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt, NULL);
- return true;
+ } else {
+ error("%Helement must be an immediate", &EXPR_LOCATION(exp));
+ Result = UndefValue::get(VectorType::get(Type::Int8Ty, 16));
}
- return false;
+ return true;
case ALTIVEC_BUILTIN_VSPLTISH:
if (Constant *Elt = dyn_cast<ConstantInt>(Ops[0])) {
Elt = ConstantExpr::getIntegerCast(Elt, Type::Int16Ty, true);
Result = BuildVector(Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt, NULL);
- return true;
+ } else {
+ error("%Helement must be an immediate", &EXPR_LOCATION(exp));
+ Result = UndefValue::get(VectorType::get(Type::Int16Ty, 8));
}
- return false;
+ return true;
case ALTIVEC_BUILTIN_VSPLTISW:
if (Constant *Elt = dyn_cast<ConstantInt>(Ops[0])) {
Elt = ConstantExpr::getIntegerCast(Elt, Type::Int32Ty, true);
Result = BuildVector(Elt, Elt, Elt, Elt, NULL);
- return true;
+ } else {
+ error("%Hmask must be an immediate", &EXPR_LOCATION(exp));
+ Result = UndefValue::get(VectorType::get(Type::Int32Ty, 4));
}
- return false;
+ return true;
case ALTIVEC_BUILTIN_VSPLTB:
if (ConstantInt *Elt = dyn_cast<ConstantInt>(Ops[1])) {
int EV = Elt->getZExtValue();
Result = BuildVectorShuffle(Ops[0], Ops[0],
EV, EV, EV, EV, EV, EV, EV, EV,
EV, EV, EV, EV, EV, EV, EV, EV);
- return true;
+ } else {
+ error("%Helement number must be an immediate", &EXPR_LOCATION(exp));
+ Result = Ops[0];
}
- return false;
+ return true;
case ALTIVEC_BUILTIN_VSPLTH:
if (ConstantInt *Elt = dyn_cast<ConstantInt>(Ops[1])) {
int EV = Elt->getZExtValue();
Result = BuildVectorShuffle(Ops[0], Ops[0],
EV, EV, EV, EV, EV, EV, EV, EV);
- return true;
+ } else {
+ error("%Helement number must be an immediate", &EXPR_LOCATION(exp));
+ Result = Ops[0];
}
- return false;
+ return true;
case ALTIVEC_BUILTIN_VSPLTW:
if (ConstantInt *Elt = dyn_cast<ConstantInt>(Ops[1])) {
int EV = Elt->getZExtValue();
Result = BuildVectorShuffle(Ops[0], Ops[0], EV, EV, EV, EV);
- return true;
+ } else {
+ error("%Helement number must be an immediate", &EXPR_LOCATION(exp));
+ Result = Ops[0];
}
- return false;
+ return true;
case ALTIVEC_BUILTIN_VSLDOI_16QI:
case ALTIVEC_BUILTIN_VSLDOI_8HI:
case ALTIVEC_BUILTIN_VSLDOI_4SI:
@@ -294,9 +306,11 @@
Amt+4, Amt+5, Amt+6, Amt+7,
Amt+8, Amt+9, Amt+10, Amt+11,
Amt+12, Amt+13, Amt+14, Amt+15);
- return true;
+ } else {
+ error("%Hshift amount must be an immediate", &EXPR_LOCATION(exp));
+ Result = Ops[0];
}
- return false;
+ return true;
case ALTIVEC_BUILTIN_VPKUHUM: {
Value *Op0 = Ops[0];
Instruction::CastOps opc = CastInst::getCastOpcode(Op0,
More information about the llvm-commits
mailing list