Wanted: good definition of the term “lowering” in the context of compilers

后端 未结 3 1726
难免孤独
难免孤独 2021-02-02 10:31

Can anyone point me to a good definition of the term \"lowering\" in the context of compilers?

From what I can tell, it is the translation of a higher-level operation in

3条回答
  •  星月不相逢
    2021-02-02 11:12

    I can't find a good link with a definition, but I think I can give a good example. In LLVM, the LLVM IR supports several sizes of integers. Most C/C++ compilers, including clang, support long long and a 64 bit data type. Many 32 bit processors, like the mips (32 bit), don't have instructions that can do, for example, a 64 bit add or compare. LLVM will "lower" these 64 bit operations to operations, usually 32 bit, that the processor can do.

    In the case of a int64_t compare for example, LLVM will lower it to

    compare the upper 32 bits with a signed comparison
    if they are equal, compare the lower 32 bits with an unsigned comparison
    

    Some lowering can get pretty fancy. For example on a processor that does not support a multiply instruction, simple multiplies might turn into shifts and adds while more complicated ones might turn into a call to a run-time supprt library.

提交回复
热议问题