Make ConstantDataArray::get() constructors a single templated one.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
include/llvm/IR/Constants.h | ||
---|---|---|
706 ↗ | (On Diff #137871) | 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()); |
Comment Actions
Minor drive by comments.
include/llvm/IR/Constants.h | ||
---|---|---|
701 ↗ | (On Diff #137871) | I'm not sure of the rules here, but perhaps this needs to be sizeof(ElementTy) * CHAR_BIT / 8 to be technically correct? |
708 ↗ | (On Diff #137871) | There is a Type::getIntNTy that you can use here. |
732 ↗ | (On Diff #137871) | Use llvm_unreachable. |
Comment Actions
Address comments.
include/llvm/IR/Constants.h | ||
---|---|---|
701 ↗ | (On Diff #137871) | It made sense to add * CHAR_BIT when passing no of bits to getIntNTy. |