任何人都可以指出我在编译器的上下文中对术语“降低”的一个很好的定义吗?
据我所知,它是将更高级别的操作转换为较低级别操作的等效组合,但我不太确定,在Google上搜索几分钟后找不到。 (有一些“降低”的用法,例如在 GCC 或 LLVM 中,但没有引用定义。)
最佳答案
Dobbs 博士刚刚发表 an article by Walter Bright (dlang 名气),他在那里提到了这个词:
Lowering
One semantic technique that is obvious in hindsight (but took Andrei Alexandrescu to point out to me) is called "lowering." It consists of, internally, rewriting more complex semantic constructs in terms of simpler ones. For example,
while
loops andforeach
loops can be rewritten in terms offor
loops. Then, the rest of the code only has to deal withfor
loops. This turned out to uncover a couple of latent bugs in how while loops were implemented in D, and so was a nice win. It's also used to rewritescope guard
statements in terms oftry-finally
statements, etc. Every case where this can be found in the semantic processing will be win for the implementation.If it turns out that there are some special-case rules in the language that prevent this "lowering" rewriting, it might be a good idea to go back and revisit the language design.
Any time you can find commonality in the handling of semantic constructs, it's an opportunity to reduce implementation effort and bugs.
关于compiler-construction - 通缉 : good definition of the term "lowering" in the context of compilers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20252876/