简体   繁体   English

编译器如何识别其主机的硬件?哪个组件?

[英]How does a compiler identify its host machine's hardware? Which component?

My teacher told me that the intermediate code is generic for all systems but a component of the compiler then make it different according the system/environment the code is run on. 我的老师告诉我,中间代码对于所有系统都是通用的,但是编译器的一个组件会根据运行代码的系统/环境使其不同。 Can someone please explain it. 有人可以解释一下吗。

Normally a compiler is divided into two parts: A frontend that does the parsing, and which generates intermediate code. 通常,编译器分为两部分:执行解析的前端,并生成中间代码。 Then a backend which takes the intermediate code and generate the assembly or machine code. 然后是后端,它接受中间代码并生成程序集或机器代码。

The frontend can be generic, but the backend is built for a specific target . 前端可以是通用的,但后端是为特定目标构建的。 So the compiler doesn't have to "identify" the host, only know the target. 因此编译器不必“识别”主机,只知道目标。

Note that host and target may be different systems, which is used for cross compilation . 请注意,主机和目标可能是不同的系统,用于交叉编译

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM