[libc-commits] [clang] [libc] [llvm] [NVPTX] Implement variadic functions using IR lowering (PR #96015)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Wed Jun 19 07:40:18 PDT 2024
================
@@ -938,6 +938,37 @@ struct Amdgpu final : public VariadicABIInfo {
}
};
+struct NVPTX final : public VariadicABIInfo {
+
+ bool enableForTarget() override { return true; }
+
+ bool vaListPassedInSSARegister() override { return true; }
+
+ Type *vaListType(LLVMContext &Ctx) override {
+ return PointerType::getUnqual(Ctx);
+ }
+
+ Type *vaListParameterType(Module &M) override {
+ return PointerType::getUnqual(M.getContext());
+ }
+
+ Value *initializeVaList(Module &M, LLVMContext &Ctx, IRBuilder<> &Builder,
+ AllocaInst *, Value *Buffer) override {
+ return Builder.CreateAddrSpaceCast(Buffer, vaListParameterType(M));
+ }
+
+ VAArgSlotInfo slotInfo(const DataLayout &DL, Type *Parameter) override {
+ // NVPTX doesn't apply minimum alignment to types present in structs. Types
+ // with alignment less than four should be promoted by the compiler and will
+ // get the proper minimum alignment in those cases.
+ const unsigned MinAlign = 1;
----------------
jhuber6 wrote:
So, the standard varargs handling will automatically promote things like shorts to ints and floats to doubles. What the comment means is that `clang` already handled the size / alignment in those cases, so we need to use a minimum alignment of 1 so we respect the alignment for things that clang didn't modify.
https://github.com/llvm/llvm-project/pull/96015
More information about the libc-commits
mailing list