[llvm-dev] Exception handling support for a target
David Chisnall via llvm-dev
llvm-dev at lists.llvm.org
Tue Jan 16 02:39:31 PST 2018
On 16 Jan 2018, at 10:18, Tim Northover via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
>> Is the above list complete? Do I understand their purpose correctly (sort
>> of)?
>
> There are components in libunwind (especially) and compiler-rt you'll
> also need to look at if you're not on top of an existing runtime.
The libUnwind parts are relatively small. You need to write two assembly functions, one which dumps all registers to memory and one which restores them. Next you need to add enum values for all of your registers that correspond to their DWARF register numbres. You then need to implement a C++ class that sets and gets register values from the in-memory structure based on the DWARF number. This is usually quite small because the easiest way of dumping the registers is to store each register set contiguously in memory in the same order that as their DWARF numbers, so you end up with a struct something like this:
struct MyArch_Regs
{
int64_t GPRs[32];
};
And the get function is just doing GPRs[RegNo - MyArch_GPR0].
LLVM’s libUnwind has a very clean structure. Adding MIPS support took a couple of hours. All of the unwinder support is generic other than the mapping from DWARF register numbers to some concrete mechanism for getting and setting them.
David
More information about the llvm-dev
mailing list