// #target: linux-riscv32
// #opt: --riscvfloat=float
module test;
// Doubles are still passed in GPRs, so the 'e' argument will be anyext as
// GPRs are exhausted.
fn void f_fpr_tracking(double a, double b, double c, double d, ichar e) {}

// Lowering for doubles is unnmodified, as 64 > FLEN.
struct Double_s { double d; }

fn void f_double_s_arg(Double_s a) {}

fn Double_s f_ret_double_s() {
  return {1.0};
}

struct Double_double_s { double d; double e; }

fn void f_double_double_s_arg(Double_double_s a) {}

fn Double_double_s f_ret_double_double_s() {
  return {1.0, 2.0};
}

struct Double_int8_s { double d; long i; }

struct Int_double_s { int a; double b; }

fn void f_int_double_s_arg(Int_double_s a) {}

fn Int_double_s f_ret_int_double_s() {
  return {1, 2.0};
}

/* #expect: test.ll


define void @test.f_fpr_tracking(double %0, double %1, double %2, double %3, i8 %4) #0 {
entry:
  ret void
}


define void @test.f_double_s_arg(i64 %0) #0 {
entry:
  %a = alloca %Double_s, align 8
  store i64 %0, ptr %a, align 8
  ret void
}


define i64 @test.f_ret_double_s() #0 {
entry:
  %literal = alloca %Double_s, align 8
  call void @llvm.memcpy.p0.p0.i32(ptr align 8 %literal, ptr align 8 @.__const, i32 8, i1 false)
  %0 = load i64, ptr %literal, align 8
  ret i64 %0
}


define void @test.f_double_double_s_arg(ptr align 8 %0) #0 {
entry:
  ret void
}


define void @test.f_ret_double_double_s(ptr noalias sret(%Double_double_s) align 8 %0) #0 {
entry:
  %literal = alloca %Double_double_s, align 8
  call void @llvm.memcpy.p0.p0.i32(ptr align 8 %literal, ptr align 8 @.__const.1, i32 16, i1 false)
  call void @llvm.memcpy.p0.p0.i32(ptr align 8 %0, ptr align 8 %literal, i32 16, i1 false)
  ret void
}


define void @test.f_int_double_s_arg(ptr align 8 %0) #0 {
entry:
  ret void
}


define void @test.f_ret_int_double_s(ptr noalias sret(%Int_double_s) align 8 %0) #0 {
entry:
  %literal = alloca %Int_double_s, align 8
  call void @llvm.memcpy.p0.p0.i32(ptr align 8 %literal, ptr align 8 @.__const.2, i32 16, i1 false)
  call void @llvm.memcpy.p0.p0.i32(ptr align 8 %0, ptr align 8 %literal, i32 16, i1 false)
  ret void
}

