[all-commits] [llvm/llvm-project] c804e8: [RISCV][VLS] Support RISCV VLS calling convention ...

Brandon Wu via All-commits all-commits at lists.llvm.org
Sun Mar 2 20:39:56 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c804e86f558a42f328946331af391d700747fa90
      https://github.com/llvm/llvm-project/commit/c804e86f558a42f328946331af391d700747fa90
  Author: Brandon Wu <brandon.wu at sifive.com>
  Date:   2025-03-03 (Mon, 03 Mar 2025)

  Changed paths:
    M clang/include/clang-c/Index.h
    M clang/include/clang/AST/Type.h
    M clang/include/clang/Basic/Attr.td
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/Specifiers.h
    M clang/lib/AST/ItaniumMangle.cpp
    M clang/lib/AST/Type.cpp
    M clang/lib/AST/TypePrinter.cpp
    M clang/lib/Basic/Targets/RISCV.cpp
    M clang/lib/CodeGen/CGCall.cpp
    M clang/lib/CodeGen/CGDebugInfo.cpp
    M clang/lib/CodeGen/Targets/RISCV.cpp
    M clang/lib/Sema/SemaDeclAttr.cpp
    M clang/lib/Sema/SemaType.cpp
    M clang/test/CodeGen/RISCV/riscv-vector-callingconv-llvm-ir.c
    M clang/test/CodeGen/RISCV/riscv-vector-callingconv-llvm-ir.cpp
    M clang/test/CodeGen/RISCV/riscv-vector-callingconv.c
    M clang/test/CodeGen/RISCV/riscv-vector-callingconv.cpp
    M clang/tools/libclang/CXType.cpp
    M llvm/include/llvm/AsmParser/LLToken.h
    M llvm/include/llvm/BinaryFormat/Dwarf.def
    M llvm/include/llvm/IR/CallingConv.h
    M llvm/lib/AsmParser/LLLexer.cpp
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/IR/AsmWriter.cpp
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    A llvm/test/Assembler/riscv_vls_cc.ll
    M llvm/test/Bitcode/compatibility.ll

  Log Message:
  -----------
  [RISCV][VLS] Support RISCV VLS calling convention (#100346)

This patch adds a function attribute `riscv_vls_cc` for RISCV VLS
calling
convention which takes 0 or 1 argument, the argument is the `ABI_VLEN`
which is the `VLEN` for passing the fixed-vector arguments, it wraps the
argument as a scalable vector(VLA) using the `ABI_VLEN` and uses the
corresponding mechanism to handle it. The range of `ABI_VLEN` is [32,
65536],
if not specified, the default value is 128.

Here is an example of VLS argument passing:
Non-VLS call:
```
  void original_call(__attribute__((vector_size(16))) int arg) {}
=>
  define void @original_call(i128 noundef %arg) {
  entry:
    ...
    ret void
  }
```
VLS call:
```
  void __attribute__((riscv_vls_cc(256))) vls_call(__attribute__((vector_size(16))) int arg) {}
=>
  define riscv_vls_cc void @vls_call(<vscale x 1 x i32> %arg) {
  entry:
    ...
    ret void
  }
}
```

The first Non-VLS call passes generic vector argument of 16 bytes by
flattened integer.
On the contrary, the VLS call uses `ABI_VLEN=256` which wraps the
vector to <vscale x 1 x i32> where the number of scalable vector
elements
is calaulated by: `ORIG_ELTS * RVV_BITS_PER_BLOCK / ABI_VLEN`.
Note: ORIG_ELTS = Vector Size / Type Size = 128 / 32 = 4.

PsABI PR: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/418
C-API PR: https://github.com/riscv-non-isa/riscv-c-api-doc/pull/68



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list