struct ValID {
enum {
NumberVal, NameVal, ConstSIntVal, ConstUIntVal, ConstFPVal, ConstNullVal,
- ConstUndefVal, ConstantVal,
+ ConstUndefVal, ConstZeroVal, ConstantVal,
} Type;
union {
ValID D; D.Type = ConstUndefVal; return D;
}
+ static ValID createZeroInit() {
+ ValID D; D.Type = ConstZeroVal; return D;
+ }
+
static ValID create(Constant *Val) {
ValID D; D.Type = ConstantVal; D.ConstantValue = Val; return D;
}
case ConstFPVal : return ftostr(ConstPoolFP);
case ConstNullVal : return "null";
case ConstUndefVal : return "undef";
+ case ConstZeroVal : return "zeroinitializer";
case ConstUIntVal :
case ConstSIntVal : return std::string("%") + itostr(ConstPool64);
case ConstantVal:
case ConstFPVal: return ConstPoolFP < V.ConstPoolFP;
case ConstNullVal: return false;
case ConstUndefVal: return false;
+ case ConstZeroVal: return false;
case ConstantVal: return ConstantValue < V.ConstantValue;
default: assert(0 && "Unknown value type!"); return false;
}
case ValID::ConstUndefVal: // Is it an undef value?
return UndefValue::get(Ty);
+ case ValID::ConstZeroVal: // Is it a zero value?
+ return Constant::getNullValue(Ty);
+
case ValID::ConstantVal: // Fully resolved constant?
if (D.ConstantValue->getType() != Ty)
ThrowException("Constant expression type different from required type!");
| UNDEF {
$$ = ValID::createUndef();
}
+ | ZEROINITIALIZER { // A vector zero constant.
+ $$ = ValID::createZeroInit();
+ }
| '<' ConstVector '>' { // Nonempty unsized packed vector
const Type *ETy = (*$2)[0]->getType();
int NumElements = $2->size();