[flang-commits] [flang] [flang] RISCV64 support for BIND(C) derived types (PR #198335)
Philipp Rados via flang-commits
flang-commits at lists.llvm.org
Wed May 20 03:59:43 PDT 2026
================
@@ -1389,10 +1389,18 @@ struct TargetSparcV9 : public GenericTarget<TargetSparcV9> {
//===----------------------------------------------------------------------===//
namespace {
+// RISCV64 calling convention specification:
+// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc#procedure-calling-convention
struct TargetRISCV64 : public GenericTarget<TargetRISCV64> {
using GenericTarget::GenericTarget;
static constexpr int defaultWidth = 64;
+ static constexpr int defaultWidthBytes = defaultWidth / 8;
+ // TODO: Can't query ABI from inside TargetRewrite so assume the more common
+ // `lp64d` for now. Alternatively could check float-support from
+ // target-features, but that could be overridden by manually setting
+ // `-mabi=lp64`.
----------------
prados-oc wrote:
> Could the target-abi be added/threaded into fir::CodeGenSpecifics
That would be nice, but I checked and it requires some more plumbing.
> Also, while this may not cover the cases where mabi is used, can't you already cover some cases using the target feature argument of fir::CodeGenSpecifics ctor
Yes I could probably. The logic to obtaining the actual ABI is a more involved for RISCV though see: https://github.com/llvm/llvm-project/blob/4a5461735d71389e82f2bbd21d9991930bd7e823/clang/lib/Driver/ToolChains/Arch/RISCV.cpp#L178
so ideally that would be reused somehow.
https://github.com/llvm/llvm-project/pull/198335
More information about the flang-commits
mailing list