[llvm-commits] [hlvm] r38353 - /hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp
Reid Spencer
reid at x10sys.com
Sat Jul 7 17:02:36 PDT 2007
Author: reid
Date: Sat Jul 7 19:02:36 2007
New Revision: 38353
URL: http://llvm.org/viewvc/llvm-project?rev=38353&view=rev
Log:
Fix some problems with the range of generated integer constants.
Modified:
hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp
Modified: hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp?rev=38353&r1=38352&r2=38353&view=diff
==============================================================================
--- hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp (original)
+++ hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp Sat Jul 7 19:02:36 2007
@@ -147,7 +147,7 @@
Locator* loc = getLocator();
std::string name = "int_" + utostr(line);
bool isSigned = randRange(0,Complexity+2,true) < (Complexity+2)/2;
- result = ast->new_IntegerType(name,randRange(2,64,true),isSigned,loc);
+ result = ast->new_IntegerType(name,randRange(4,64,true),isSigned,loc);
break;
}
case RangeTypeID:
@@ -311,7 +311,7 @@
}
case SInt8TypeID:
{
- int8_t val = int8_t(randRange(-128,127));
+ int8_t val = int8_t(randRange(-127,127));
std::string val_str(itostr(val));
C = ast->new_ConstantInteger(
std::string("cs8_")+utostr(line),val_str,10,Ty,loc);
@@ -319,7 +319,7 @@
}
case SInt16TypeID:
{
- int16_t val = int16_t(randRange(-32768,32767));
+ int16_t val = int16_t(randRange(-32767,32767));
std::string val_str(itostr(val));
C = ast->new_ConstantInteger(
std::string("cs16_")+utostr(line),val_str,10,Ty,loc);
@@ -384,14 +384,14 @@
Locator* loc = getLocator();
std::string name = "cint_" + utostr(line);
const IntegerType* IntTy = llvm::cast<IntegerType>(Ty);
- unsigned bits = (IntTy->getBits() < 63 ? IntTy->getBits() : 63) - 1;
+ unsigned bits = (IntTy->getBits() < 63 ? IntTy->getBits() : 63) - 2;
int64_t max = 1 << bits;
std::string val_str;
if (IntTy->isSigned()) {
int64_t val = randRange(int64_t(-max),int64_t(max-1));
val_str = itostr(val);
} else {
- uint64_t val = randRange(int64_t(0),int64_t(max),true);
+ uint64_t val = randRange(uint64_t(0),uint64_t(max),true);
val_str = utostr(val);
}
C = ast->new_ConstantInteger(name,val_str,10,Ty,loc);
@@ -518,8 +518,13 @@
args.push_back(O);
const SignatureType* sig = F->getSignature();
for (SignatureType::const_iterator I = sig->begin(), E = sig->end();
- I != E; ++I)
- args.push_back(genValueOperator((*I)->getType()));
+ I != E; ++I)
+ {
+ const Type* argTy = (*I)->getType();
+ Operator* O = genValueOperator(argTy);
+ hlvmAssert(argTy == O->getType());
+ args.push_back(O);
+ }
return ast->new_MultiOp<CallOp>(args,getLocator());
}
More information about the llvm-commits
mailing list