(original) (raw)

There are quite a few different ways to make constant vectors. You can create a splat of integer constants by using ConstantInt::get(, ) The scalar value can be an uint64\_t or an APInt. Of if you have a Constant \* you want to splat you can use ConstantVector::getSplat. If it's not a splat, you can use ConstantDataVector::get which will take an array of uint8\_t, uint16\_t, uint32\_t, or uin64\_t and auto infer the width and element count. Or you can use ConstantVector::get which will take an array of individual Constant \* that all have the same scalar type.

I don't have any complete code for implementing a function. Most of my interaction with these APIs has been in converting intrinsics into native IR in lib/IR/AutoUpgrade.cpp and clang's lib/CodeGen/CGBuiltin.cpp. I'm sure you'll find every function I mentioned above used in one or both of those files.