Implement count leading zeros (ctlz), count trailing zeros (cttz), and count

population (ctpop).  Generic lowering is implemented, however only promotion
is implemented for SelectionDAG at the moment.

More coming soon.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21676 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Lenharth
2005-05-03 17:19:30 +00:00
parent c88e681498
commit 691ef2ba06
14 changed files with 326 additions and 14 deletions

View File

@@ -206,6 +206,11 @@ unsigned Function::getIntrinsicID() const {
assert(getName().size() != 5 && "'llvm.' is an invalid intrinsic name!");
switch (getName()[5]) {
case 'c':
if (getName() == "llvm.ctpop") return Intrinsic::ctpop;
if (getName() == "llvm.cttz") return Intrinsic::cttz;
if (getName() == "llvm.ctlz") return Intrinsic::ctlz;
break;
case 'd':
if (getName() == "llvm.dbg.stoppoint") return Intrinsic::dbg_stoppoint;
if (getName() == "llvm.dbg.region.start")return Intrinsic::dbg_region_start;

View File

@@ -723,6 +723,18 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
NumArgs = 2;
break;
case Intrinsic::ctpop:
case Intrinsic::ctlz:
case Intrinsic::cttz:
Assert1(FT->getNumParams() == 1,
"Illegal # arguments for intrinsic function!", IF);
Assert1(FT->getReturnType() == FT->getParamType(0),
"Return type does not match source type", IF);
Assert1(FT->getParamType(0)->isIntegral(),
"Argument must be of an int type!", IF);
NumArgs = 1;
break;
case Intrinsic::sqrt:
Assert1(FT->getNumParams() == 1,
"Illegal # arguments for intrinsic function!", IF);