Help: Implementing function call lowering for a Backend

Hi everyone,

I am currently working on a backend for my bachelor thesis, using the patches by alex bradbury as a reference (https://github.com/lowRISC/riscv-llvm).

However, whenever I try to lower the following file:

play/call.ll:

declare i32 @external_function(i64)

define i32 @test_call_external(i64 %a) nounwind {
%1 = add i64 %a, %a
%2 = call i32 @external_function(i64 %1)
ret i32 %2
}

with
$ ./bin/llc -mtriple=via64 play/call.ll

TargetRegisterInfo::getMinimalPhysRegClass() fails because it could find an appropriate Register Class.
I put a copy of the stack dump at the bottom.

The register i am passing should be i64 (i checked at runtime, and it is).
And my defined registers are all 64 bit as well.

Does anyone know what could be wrong?
I understand that this is probably not enough information to answer my question, but I didn’t exactly know what code to send.

Cheers,
Floris Westermann

Stack dump:

Hello again,

I seem to have managed to fix the last error message a couple of days ago.

However, I right afterwards I got the following error:

$ …/bin/llc -mtriple=via64 call1.ll

LLVM ERROR: Cannot select: t10: ch,glue = callseq_end t9, TargetConstant:i64<0>, TargetConstant:i64<0>, t9:1
t4: i64 = TargetConstant<0>
t4: i64 = TargetConstant<0>
t9: ch,glue = VIA64ISD::CALL t5, t7, RegisterMask:Untyped
t7: i64 = MOVId TargetGlobalAddress:i64<void ()* @function2> 0 [TF=1]
t6: i64 = TargetGlobalAddress<void ()* @function2> 0 [TF=1]
t8: Untyped = RegisterMask
In function: test_call_external2

I have been trying to find out what exactly the problem is for a couple of days now and I am getting a little desperate.
Does anyone with more experience in tblgen know what exactly I have to implement to lower callseq_end?

If this isn’t the right place to ask these questions please let me know.

Cheers,
Floris