On 10/1/20 8:32 AM, John Paul Adrian Glaubitz wrote:
Hi Nathan!

Thanks for the explanations!

On 10/1/20 2:27 PM, Nathan Sidwell wrote:
do you know what those 2 functions you mention provide on say x86?  Then it 
might be easier to map onto 68k.

 From [1]:

Register X86TargetLowering::getExceptionPointerRegister(
     const Constant *PersonalityFn) const {
   if (classifyEHPersonality(PersonalityFn) == EHPersonality::CoreCLR)
     return Subtarget.isTarget64BitLP64() ? X86::RDX : X86::EDX;

   return Subtarget.isTarget64BitLP64() ? X86::RAX : X86::EAX;
}

Register X86TargetLowering::getExceptionSelectorRegister(
     const Constant *PersonalityFn) const {
   // Funclet personalities don't use selectors (the runtime does the 
selection).
   assert(!isFuncletEHPersonality(classifyEHPersonality(PersonalityFn)));
   return Subtarget.isTarget64BitLP64() ? X86::RDX : X86::EDX;
}

Aha! it is EH_RETURN :) and it appears stack adjustment is something different.

for x86, gcc has:
#define EH_RETURN_DATA_REGNO(N) ((N) <= DX_REG ? (N) : INVALID_REGNUM)

thus N can either be AX_REG or DX_REG. (which is eax/rax and edx/rdx depending on compilation mode)

for m68k gcc has:
#define EH_RETURN_DATA_REGNO(N) \
  ((N) < 2 ? (N) : INVALID_REGNUM)

so that's registers d0 and d1

I'm guessing EHPersonality:CoreCLR is a different ABI that you're not concerned with. Thus I think you want:

getExceptionPointerRegister to return d0 and getExceptionSelectorRegister to return d1.

give that a go, and see if you can throw/catch exceptions between code compiled by your llvm port and a gcc

hope that helps.


Adrian

[1] 
https://raw.githubusercontent.com/llvm/llvm-project/master/llvm/lib/Target/X86/X86ISelLowering.cpp



--
Nathan Sidwell

Reply via email to