Add lengthof and endof templates that hide a lot of sizeof computations.

Patch by Sterling Stein!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41758 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson
2007-09-07 04:06:50 +00:00
parent af992f782f
commit 718cb665ca
16 changed files with 68 additions and 47 deletions

View File

@@ -20,6 +20,7 @@
#include "llvm/Support/Streams.h"
#include "llvm/Target/TargetData.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h"
using namespace llvm;
template <class ArgIt>
@@ -421,7 +422,7 @@ static Instruction *LowerPartSelect(CallInst *CI) {
CI->getOperand(2),
CI->getOperand(3)
};
return new CallInst(F, Args, Args+sizeof(Args)/sizeof(Args[0]), CI->getName(), CI);
return new CallInst(F, Args, array_endof(Args), CI->getName(), CI);
}
/// Convert the llvm.part.set.iX.iY.iZ intrinsic. This intrinsic takes
@@ -587,7 +588,7 @@ static Instruction *LowerPartSet(CallInst *CI) {
CI->getOperand(3),
CI->getOperand(4)
};
return new CallInst(F, Args, Args+sizeof(Args)/sizeof(Args[0]), CI->getName(), CI);
return new CallInst(F, Args, array_endof(Args), CI->getName(), CI);
}