[llvm-commits] [hlvm] r38342 - in /hlvm/trunk: hlvm/AST/Bundle.cpp hlvm/Pass/Validate.cpp hlvm/Writer/XMLWriter.cpp tools/hlvm-config/hlvm-config.cpp tools/hlvm-gentestcase/Generate.cpp
Reid Spencer
reid at x10sys.com
Sat Jul 7 17:02:30 PDT 2007
Author: reid
Date: Sat Jul 7 19:02:30 2007
New Revision: 38342
URL: http://llvm.org/viewvc/llvm-project?rev=38342&view=rev
Log:
Get some bugs out of the test case generator and fix bugs that it found.
Modified:
hlvm/trunk/hlvm/AST/Bundle.cpp
hlvm/trunk/hlvm/Pass/Validate.cpp
hlvm/trunk/hlvm/Writer/XMLWriter.cpp
hlvm/trunk/tools/hlvm-config/hlvm-config.cpp
hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp
Modified: hlvm/trunk/hlvm/AST/Bundle.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Bundle.cpp?rev=38342&r1=38341&r2=38342&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Bundle.cpp (original)
+++ hlvm/trunk/hlvm/AST/Bundle.cpp Sat Jul 7 19:02:30 2007
@@ -60,11 +60,11 @@
void
Bundle::removeChild(Node* kid)
{
- hlvmAssert(isa<Constant>(kid) && "Can't remove that here");
- // This is sucky slow, but we probably won't be removing nodes that much.
+ hlvmAssert(kid && "Null child!");
if (isa<Type>(kid))
types.erase(cast<Type>(kid)->getName());
else if (isa<Value>(kid)) {
+ // This is sucky slow, but we probably won't be removing nodes that much.
for (value_iterator I = value_begin(), E = value_end(); I != E; ++I )
if (*I == kid) { values.erase(I); break; }
if (isa<ConstantValue>(kid))
Modified: hlvm/trunk/hlvm/Pass/Validate.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Pass/Validate.cpp?rev=38342&r1=38341&r2=38342&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Pass/Validate.cpp (original)
+++ hlvm/trunk/hlvm/Pass/Validate.cpp Sat Jul 7 19:02:30 2007
@@ -453,12 +453,36 @@
}
template<> inline void
+ValidateImpl::validate(ConstantAny* n)
+{
+ checkConstant(n,ConstantAnyID);
+}
+
+template<> inline void
ValidateImpl::validate(ConstantBoolean* n)
{
checkConstant(n,ConstantBooleanID);
}
template<> inline void
+ValidateImpl::validate(ConstantCharacter* n)
+{
+ checkConstant(n,ConstantCharacterID);
+}
+
+template<> inline void
+ValidateImpl::validate(ConstantEnumerator* n)
+{
+ checkConstant(n,ConstantEnumeratorID);
+}
+
+template<> inline void
+ValidateImpl::validate(ConstantOctet* n)
+{
+ checkConstant(n,ConstantOctetID);
+}
+
+template<> inline void
ValidateImpl::validate(ConstantInteger* CI)
{
if (checkConstant(CI,ConstantIntegerID)) {
@@ -909,11 +933,11 @@
}
if (blk == 0)
error(op,"Referent does not match name in scope");
- } else if (const Argument* ref = dyn_cast<Argument>(referent)) {
+ } else if (const Argument* arg = dyn_cast<Argument>(referent)) {
Function* F = op->getContainingFunction();
if (!F)
error(op,"ReferenceOp not in a function?");
- else if (F->getArgument(ref->getName()) != ref)
+ else if (F->getArgument(arg->getName()) != arg)
error(op,"Referent does not match function argument");
} else if (const ConstantValue* cval = dyn_cast<ConstantValue>(referent)) {
Bundle* B = op->getContainingBundle();
@@ -921,11 +945,11 @@
error(op,"ReferenceOp not in a bundle?");
else if (B->find_cval(cval->getName()) != cval)
error(op,"Referent does not match constant value");
- } else if (const Linkable* var = dyn_cast<Linkable>(referent)) {
+ } else if (const Linkable* lnkbl = dyn_cast<Linkable>(referent)) {
Bundle* B = op->getContainingBundle();
if (!B)
error(op,"ReferenceOp not in a bundle?");
- else if (B->find_cval(cval->getName()) != cval)
+ else if (B->find_linkable(lnkbl->getName()) != lnkbl)
error(op,"Referent does not match linkable by name");
} else {
error(op,"Referent of unknown kind");
@@ -1563,7 +1587,11 @@
case PInfOpID: /*validate(cast<PInfOp>(n)); */ break;
case NInfOpID: /*validate(cast<NInfoOp>(n)); */ break;
case NaNOpID: /*validate(cast<NaNOp>(n)); */ break;
+ case ConstantAnyID: validate(cast<ConstantAny>(n)); break;
case ConstantBooleanID: validate(cast<ConstantBoolean>(n)); break;
+ case ConstantCharacterID: validate(cast<ConstantCharacter>(n)); break;
+ case ConstantEnumeratorID: validate(cast<ConstantEnumerator>(n)); break;
+ case ConstantOctetID: validate(cast<ConstantOctet>(n)); break;
case ConstantIntegerID: validate(cast<ConstantInteger>(n)); break;
case ConstantRealID: validate(cast<ConstantReal>(n)); break;
case ConstantStringID: validate(cast<ConstantString>(n)); break;
Modified: hlvm/trunk/hlvm/Writer/XMLWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/XMLWriter.cpp?rev=38342&r1=38341&r2=38342&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Writer/XMLWriter.cpp (original)
+++ hlvm/trunk/hlvm/Writer/XMLWriter.cpp Sat Jul 7 19:02:30 2007
@@ -365,6 +365,15 @@
}
}
+
+template<> void
+XMLWriterImpl::WriterPass::put(ConstantAny* i)
+{
+ startElement("constant");
+ writeAttribute("id",i->getName());
+ writeAttribute("type",i->getType()->getName());
+}
+
template<> void
XMLWriterImpl::WriterPass::put(ConstantBoolean* i)
{
@@ -378,6 +387,30 @@
endElement();
}
+template<> void
+XMLWriterImpl::WriterPass::put(ConstantCharacter* i)
+{
+ startElement("constant");
+ writeAttribute("id",i->getName());
+ writeAttribute("type",i->getType()->getName());
+}
+
+template<> void
+XMLWriterImpl::WriterPass::put(ConstantEnumerator* i)
+{
+ startElement("constant");
+ writeAttribute("id",i->getName());
+ writeAttribute("type",i->getType()->getName());
+}
+
+template<> void
+XMLWriterImpl::WriterPass::put(ConstantOctet* i)
+{
+ startElement("constant");
+ writeAttribute("id",i->getName());
+ writeAttribute("type",i->getType()->getName());
+}
+
template<> void
XMLWriterImpl::WriterPass::put(ConstantInteger* i)
{
@@ -417,6 +450,46 @@
}
template<> void
+XMLWriterImpl::WriterPass::put(ConstantPointer* i)
+{
+ startElement("constant");
+ writeAttribute("id",i->getName());
+ writeAttribute("type",i->getType()->getName());
+}
+
+template<> void
+XMLWriterImpl::WriterPass::put(ConstantArray* i)
+{
+ startElement("constant");
+ writeAttribute("id",i->getName());
+ writeAttribute("type",i->getType()->getName());
+}
+
+template<> void
+XMLWriterImpl::WriterPass::put(ConstantVector* i)
+{
+ startElement("constant");
+ writeAttribute("id",i->getName());
+ writeAttribute("type",i->getType()->getName());
+}
+
+template<> void
+XMLWriterImpl::WriterPass::put(ConstantStructure* i)
+{
+ startElement("constant");
+ writeAttribute("id",i->getName());
+ writeAttribute("type",i->getType()->getName());
+}
+
+template<> void
+XMLWriterImpl::WriterPass::put(ConstantContinuation* i)
+{
+ startElement("constant");
+ writeAttribute("id",i->getName());
+ writeAttribute("type",i->getType()->getName());
+}
+
+template<> void
XMLWriterImpl::WriterPass::put(Variable* v)
{
startElement("variable");
@@ -424,7 +497,7 @@
writeAttribute("type",v->getType()->getName());
if (v->hasInitializer()) {
Constant* C = llvm::cast<Constant>(v->getInitializer());
- writeAttribute("id",C->getName());
+ writeAttribute("init",C->getName());
}
putDoc(v);
}
@@ -795,74 +868,83 @@
if (mode & Pass::PreOrderTraversal) {
switch (n->getID())
{
- case AnyTypeID: put(cast<AnyType>(n)); break;
- case StringTypeID: put(cast<StringType>(n)); break;
- case BooleanTypeID: put(cast<BooleanType>(n)); break;
- case BundleID: put(cast<Bundle>(n)); break;
- case CharacterTypeID: put(cast<CharacterType>(n)); break;
- case IntegerTypeID: put(cast<IntegerType>(n)); break;
- case RangeTypeID: put(cast<RangeType>(n)); break;
- case EnumerationTypeID: put(cast<EnumerationType>(n)); break;
- case RealTypeID: put(cast<RealType>(n)); break;
- case OctetTypeID: put(cast<OctetType>(n)); break;
- case OpaqueTypeID: put(cast<OpaqueType>(n)); break;
- case PointerTypeID: put(cast<PointerType>(n)); break;
- case ArrayTypeID: put(cast<ArrayType>(n)); break;
- case VectorTypeID: put(cast<VectorType>(n)); break;
- case StructureTypeID: put(cast<StructureType>(n)); break;
- case SignatureTypeID: put(cast<SignatureType>(n)); break;
- case ConstantBooleanID: put(cast<ConstantBoolean>(n)); break;
- case ConstantIntegerID: put(cast<ConstantInteger>(n)); break;
- case ConstantRealID: put(cast<ConstantReal>(n)); break;
- case ConstantStringID: put(cast<ConstantString>(n)); break;
- case VariableID: put(cast<Variable>(n)); break;
- case FunctionID: put(cast<Function>(n)); break;
- case ProgramID: put(cast<Program>(n)); break;
- case BlockID: put(cast<Block>(n)); break;
- case AutoVarOpID: put(cast<AutoVarOp>(n)); break;
- case NegateOpID: put(cast<NegateOp>(n)); break;
- case ComplementOpID: put(cast<ComplementOp>(n)); break;
- case PreIncrOpID: put(cast<PreIncrOp>(n)); break;
- case PreDecrOpID: put(cast<PreDecrOp>(n)); break;
- case PostIncrOpID: put(cast<PostIncrOp>(n)); break;
- case PostDecrOpID: put(cast<PostDecrOp>(n)); break;
- case AddOpID: put(cast<AddOp>(n)); break;
- case SubtractOpID: put(cast<SubtractOp>(n)); break;
- case MultiplyOpID: put(cast<MultiplyOp>(n)); break;
- case DivideOpID: put(cast<DivideOp>(n)); break;
- case ModuloOpID: put(cast<ModuloOp>(n)); break;
- case BAndOpID: put(cast<BAndOp>(n)); break;
- case BOrOpID: put(cast<BOrOp>(n)); break;
- case BXorOpID: put(cast<BXorOp>(n)); break;
- case BNorOpID: put(cast<BNorOp>(n)); break;
- case NotOpID: put(cast<NotOp>(n)); break;
- case AndOpID: put(cast<AndOp>(n)); break;
- case OrOpID: put(cast<OrOp>(n)); break;
- case XorOpID: put(cast<XorOp>(n)); break;
- case NorOpID: put(cast<NorOp>(n)); break;
- case EqualityOpID: put(cast<EqualityOp>(n)); break;
- case InequalityOpID: put(cast<InequalityOp>(n)); break;
- case LessThanOpID: put(cast<LessThanOp>(n)); break;
- case GreaterThanOpID: put(cast<GreaterThanOp>(n)); break;
- case LessEqualOpID: put(cast<LessEqualOp>(n)); break;
- case GreaterEqualOpID: put(cast<GreaterEqualOp>(n)); break;
- case SelectOpID: put(cast<SelectOp>(n)); break;
- case SwitchOpID: put(cast<SwitchOp>(n)); break;
- case WhileOpID: put(cast<WhileOp>(n)); break;
- case UnlessOpID: put(cast<UnlessOp>(n)); break;
- case UntilOpID: put(cast<UntilOp>(n)); break;
- case LoopOpID: put(cast<LoopOp>(n)); break;
- case BreakOpID: put(cast<BreakOp>(n)); break;
- case ContinueOpID: put(cast<ContinueOp>(n)); break;
- case ReturnOpID: put(cast<ReturnOp>(n)); break;
- case ResultOpID: put(cast<ResultOp>(n)); break;
- case CallOpID: put(cast<CallOp>(n)); break;
- case StoreOpID: put(cast<StoreOp>(n)); break;
- case LoadOpID: put(cast<LoadOp>(n)); break;
- case ReferenceOpID: put(cast<ReferenceOp>(n)); break;
- case OpenOpID: put(cast<OpenOp>(n)); break;
- case CloseOpID: put(cast<CloseOp>(n)); break;
- case WriteOpID: put(cast<WriteOp>(n)); break;
+ case AnyTypeID: put(cast<AnyType>(n)); break;
+ case StringTypeID: put(cast<StringType>(n)); break;
+ case BooleanTypeID: put(cast<BooleanType>(n)); break;
+ case BundleID: put(cast<Bundle>(n)); break;
+ case CharacterTypeID: put(cast<CharacterType>(n)); break;
+ case IntegerTypeID: put(cast<IntegerType>(n)); break;
+ case RangeTypeID: put(cast<RangeType>(n)); break;
+ case EnumerationTypeID: put(cast<EnumerationType>(n)); break;
+ case RealTypeID: put(cast<RealType>(n)); break;
+ case OctetTypeID: put(cast<OctetType>(n)); break;
+ case OpaqueTypeID: put(cast<OpaqueType>(n)); break;
+ case PointerTypeID: put(cast<PointerType>(n)); break;
+ case ArrayTypeID: put(cast<ArrayType>(n)); break;
+ case VectorTypeID: put(cast<VectorType>(n)); break;
+ case StructureTypeID: put(cast<StructureType>(n)); break;
+ case SignatureTypeID: put(cast<SignatureType>(n)); break;
+ case ConstantAnyID: put(cast<ConstantAny>(n)); break;
+ case ConstantBooleanID: put(cast<ConstantBoolean>(n)); break;
+ case ConstantCharacterID: put(cast<ConstantCharacter>(n)); break;
+ case ConstantEnumeratorID: put(cast<ConstantEnumerator>(n)); break;
+ case ConstantOctetID: put(cast<ConstantOctet>(n)); break;
+ case ConstantIntegerID: put(cast<ConstantInteger>(n)); break;
+ case ConstantRealID: put(cast<ConstantReal>(n)); break;
+ case ConstantStringID: put(cast<ConstantString>(n)); break;
+ case ConstantPointerID: put(cast<ConstantPointer>(n)); break;
+ case ConstantArrayID: put(cast<ConstantArray>(n)); break;
+ case ConstantVectorID: put(cast<ConstantVector>(n)); break;
+ case ConstantStructureID: put(cast<ConstantStructure>(n)); break;
+ case ConstantContinuationID: put(cast<ConstantContinuation>(n)); break;
+ case VariableID: put(cast<Variable>(n)); break;
+ case FunctionID: put(cast<Function>(n)); break;
+ case ProgramID: put(cast<Program>(n)); break;
+ case BlockID: put(cast<Block>(n)); break;
+ case AutoVarOpID: put(cast<AutoVarOp>(n)); break;
+ case NegateOpID: put(cast<NegateOp>(n)); break;
+ case ComplementOpID: put(cast<ComplementOp>(n)); break;
+ case PreIncrOpID: put(cast<PreIncrOp>(n)); break;
+ case PreDecrOpID: put(cast<PreDecrOp>(n)); break;
+ case PostIncrOpID: put(cast<PostIncrOp>(n)); break;
+ case PostDecrOpID: put(cast<PostDecrOp>(n)); break;
+ case AddOpID: put(cast<AddOp>(n)); break;
+ case SubtractOpID: put(cast<SubtractOp>(n)); break;
+ case MultiplyOpID: put(cast<MultiplyOp>(n)); break;
+ case DivideOpID: put(cast<DivideOp>(n)); break;
+ case ModuloOpID: put(cast<ModuloOp>(n)); break;
+ case BAndOpID: put(cast<BAndOp>(n)); break;
+ case BOrOpID: put(cast<BOrOp>(n)); break;
+ case BXorOpID: put(cast<BXorOp>(n)); break;
+ case BNorOpID: put(cast<BNorOp>(n)); break;
+ case NotOpID: put(cast<NotOp>(n)); break;
+ case AndOpID: put(cast<AndOp>(n)); break;
+ case OrOpID: put(cast<OrOp>(n)); break;
+ case XorOpID: put(cast<XorOp>(n)); break;
+ case NorOpID: put(cast<NorOp>(n)); break;
+ case EqualityOpID: put(cast<EqualityOp>(n)); break;
+ case InequalityOpID: put(cast<InequalityOp>(n)); break;
+ case LessThanOpID: put(cast<LessThanOp>(n)); break;
+ case GreaterThanOpID: put(cast<GreaterThanOp>(n)); break;
+ case LessEqualOpID: put(cast<LessEqualOp>(n)); break;
+ case GreaterEqualOpID: put(cast<GreaterEqualOp>(n)); break;
+ case SelectOpID: put(cast<SelectOp>(n)); break;
+ case SwitchOpID: put(cast<SwitchOp>(n)); break;
+ case WhileOpID: put(cast<WhileOp>(n)); break;
+ case UnlessOpID: put(cast<UnlessOp>(n)); break;
+ case UntilOpID: put(cast<UntilOp>(n)); break;
+ case LoopOpID: put(cast<LoopOp>(n)); break;
+ case BreakOpID: put(cast<BreakOp>(n)); break;
+ case ContinueOpID: put(cast<ContinueOp>(n)); break;
+ case ReturnOpID: put(cast<ReturnOp>(n)); break;
+ case ResultOpID: put(cast<ResultOp>(n)); break;
+ case CallOpID: put(cast<CallOp>(n)); break;
+ case StoreOpID: put(cast<StoreOp>(n)); break;
+ case LoadOpID: put(cast<LoadOp>(n)); break;
+ case ReferenceOpID: put(cast<ReferenceOp>(n)); break;
+ case OpenOpID: put(cast<OpenOp>(n)); break;
+ case CloseOpID: put(cast<CloseOp>(n)); break;
+ case WriteOpID: put(cast<WriteOp>(n)); break;
default:
hlvmDeadCode("Unknown Type");
break;
Modified: hlvm/trunk/tools/hlvm-config/hlvm-config.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-config/hlvm-config.cpp?rev=38342&r1=38341&r2=38342&view=diff
==============================================================================
--- hlvm/trunk/tools/hlvm-config/hlvm-config.cpp (original)
+++ hlvm/trunk/tools/hlvm-config/hlvm-config.cpp Sat Jul 7 19:02:30 2007
@@ -43,7 +43,7 @@
"NoType",
"TreeTop",
"Documentation",
- "Documentable",
+ "NamedType",
"Bundle",
"Import",
"BooleanType",
@@ -72,7 +72,6 @@
"RealType",
"RationalType",
"OpaqueType",
- "AliasType",
"PointerType",
"ArrayType",
"VectorType",
Modified: hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp?rev=38342&r1=38341&r2=38342&view=diff
==============================================================================
--- hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp (original)
+++ hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp Sat Jul 7 19:02:30 2007
@@ -88,10 +88,12 @@
}
hlvm::Type*
-genType()
+genTypeLimited(unsigned limit)
{
Type* result = 0;
NodeIDs id = NodeIDs(randRange(FirstTypeID,LastTypeID));
+ if (--limit == 0)
+ id = BooleanTypeID;
switch (id) {
case BooleanTypeID:
case CharacterTypeID:
@@ -111,6 +113,8 @@
case Float64TypeID:
case Float80TypeID:
case Float128TypeID:
+ return ast->getPrimitiveType(id);
+
case AnyTypeID:
case StringTypeID:
case BufferTypeID:
@@ -126,7 +130,7 @@
Locator* loc = getLocator();
std::string name = "int_" + utostr(line);
result = ast->new_IntegerType(
- name,randRange(1,64,true),randRange(0,1,true),loc);
+ name,randRange(1,64,true),bool(randRange(0,1,true)),loc);
break;
}
case RangeTypeID:
@@ -158,21 +162,23 @@
{
Locator* loc = getLocator();
std::string name = "ptr_" + utostr(line);
- result = ast->new_PointerType(name,genType(),loc);
+ result = ast->new_PointerType(name,genTypeLimited(limit),loc);
break;
}
case ArrayTypeID:
{
Locator* loc = getLocator();
std::string name = "array_" + utostr(line);
- result = ast->new_ArrayType(name,genType(),randRange(1,Complexity),loc);
+ result = ast->new_ArrayType(name,
+ genTypeLimited(limit),randRange(1,Complexity),loc);
break;
}
case VectorTypeID:
{
Locator* loc = getLocator();
std::string name = "vector_" + utostr(line);
- result = ast->new_VectorType(name,genType(),randRange(1,Complexity),loc);
+ result = ast->new_VectorType(
+ name,genTypeLimited(limit),randRange(1,Complexity),loc);
break;
}
case OpaqueTypeID:
@@ -184,7 +190,8 @@
std::string name = "struct_" + utostr(line);
StructureType* S = ast->new_StructureType(name,loc);
for (unsigned i = 0; i < Complexity; ++i) {
- Field* fld = ast->new_Field(name+"_"+utostr(i),genType(),getLocator());
+ Field* fld = ast->new_Field(name+"_"+utostr(i),
+ genTypeLimited(limit),getLocator());
S->addField(fld);
}
result = S;
@@ -198,6 +205,12 @@
return result;
}
+hlvm::Type*
+genType()
+{
+ return genTypeLimited(Complexity);
+}
+
hlvm::Value*
genValue(const hlvm::Type* Ty, bool is_constant = false)
{
@@ -344,7 +357,9 @@
std::string name = "cint_" + utostr(line);
const IntegerType* IntTy = llvm::cast<IntegerType>(Ty);
int64_t max = 1 << (IntTy->getBits() < 63 ? IntTy->getBits() : 63);
- int64_t val = randRange(int64_t(-max),int64_t(max-1));
+ int64_t val = IntTy->isSigned() ?
+ randRange(int64_t(-max),int64_t(max-1)) :
+ randRange(int64_t(0),int64_t(max));
std::string val_str( itostr(val) );
C = ast->new_ConstantInteger(name,val_str,10,Ty,loc);
break;
@@ -441,6 +456,7 @@
result = var;
}
+ result->setParent(bundle);
// Memoize the result
values[result->getType()].push_back(result);
return result;
@@ -459,7 +475,10 @@
Value* V = genValue((*I)->getType());
hlvmAssert(isa<ConstantValue>(V) || isa<Linkable>(V)) ;
Operator* O = ast->new_ReferenceOp(V,getLocator());
- args.push_back(O);
+ if (isa<ConstantValue>(V))
+ args.push_back(O);
+ else
+ args.push_back(ast->new_UnaryOp<LoadOp>(O,getLocator()));
}
return ast->new_MultiOp<CallOp>(args,getLocator());
}
@@ -502,7 +521,10 @@
B->setParent(F);
// Get the function result and return instruction
- Operator* O = ast->new_ReferenceOp(genValue(F->getResultType()),getLocator());
+ Value* V = genValue(F->getResultType());
+ Operator* O = ast->new_ReferenceOp(V,getLocator());
+ if (isa<Linkable>(V))
+ O = ast->new_UnaryOp<LoadOp>(O,getLocator());
ResultOp* rslt = ast->new_UnaryOp<ResultOp>(O,getLocator());
rslt->setParent(B);
More information about the llvm-commits
mailing list