[PATCH] D44337: Make ConstantDataArray::get constructor templated. Will support signed integers.
Tim Shen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 9 16:44:31 PST 2018
timshen added inline comments.
================
Comment at: include/llvm/IR/Constants.h:706
+ case 1:
+ Ty = ArrayType::get(Type::getInt8Ty(Context), Elts.size());
+ break;
----------------
Would it be good to create Type::getTyByScalar:
class Type {
template <typename ScalarType>
Type* getTyByScalar(LLVMContext*) {
switch (sizeof(ScalarType)) { ... }
}
Also, it'd be better to expand getTyByScalar to pointer and all sorts of other crazy types, but Scalar would be a good start.
Then ConstantDataArray::get will be like
return ArrayType::get(Type::getTyByScalar<ElementTy>(Context), Elts.size());
Repository:
rL LLVM
https://reviews.llvm.org/D44337
More information about the llvm-commits
mailing list