[llvm-dev] about SDTypeConstraint and transplanting

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Thu Oct 17 16:02:00 PDT 2019


Hi,

On Thu, 17 Oct 2019 at 06:50, 林政宗 via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> def SDTIntBinOp : SDTypeProfile<1, 2, [     // add, and, or, xor, udiv, etc.
>   SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>
> ]>;
>
> The number of results is 1. The number of operands is 2. How could determine the indexes in SDTCisSameAS and SDTCisInt.
> Is it that we count the results first and count the operands second starting with the end index of results?

That's right.

> I'm transplanting Cpu0 backend from llvm 3.9 to llvm 9.0. I find there is a different file(TargetLoweringObjectFileImpl.cpp) needing to be changed.
> For example, for Sparc, line 208 to line 222:
>
> case Triple::sparcel:
>   case Triple::sparc:
>     if (isPositionIndependent()) {
>       LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
>       PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
>         dwarf::DW_EH_PE_sdata4;
>       TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
>         dwarf::DW_EH_PE_sdata4;
>     } else {
>       LSDAEncoding = dwarf::DW_EH_PE_absptr;
>       PersonalityEncoding = dwarf::DW_EH_PE_absptr;
>       TTypeEncoding = dwarf::DW_EH_PE_absptr;
>     }
>     CallSiteEncoding = dwarf::DW_EH_PE_udata4;
>     break;
> How could I understand these codes? I know little about dwarf. what materials do you suggest me to read?

These are descriptions of how particular values are encoded in
exception unwind tables, which varies based on pointer size and other
configuration parameters, as you can see. I found this site very
useful for describing how they're used back when I needed to know:
https://www.airs.com/blog/archives/460.

In theory as long as the pointer is encodable in the requested format
any should work. In practice not all exception unwinders support all
formats so you need to look and find out what your platform's unwinder
is expecting for each field. You might also hit a situation where the
encoding requested doesn't have a relocation available to represent
it, though that would error out sooner.

Cheers.

Tim.


More information about the llvm-dev mailing list