__builtin_va_start在哪里定义? [英] Where is __builtin_va_start defined?

查看:703
本文介绍了__builtin_va_start在哪里定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到在GCC的源代码中定义__builtin_va_start的位置,并查看其实现方式. (我一直在寻找va_start的定义位置,然后发现该宏定义为__builtin_va_start.)我在GCC 9.1的源代码目录中使用cscope -r来搜索该定义,但没有找到它.谁能指出该函数的定义位置?

I'm trying to locate where __builtin_va_start is defined in GCC's source code, and see how it is implemented. (I was looking for where va_start is defined and then found that this macro is defined as __builtin_va_start.) I used cscope -r in GCC 9.1's source code directory to search the definition but haven't found it. Can anyone point where this function is defined?

推荐答案

在任何地方 均未定义__builtin_va_start.它是内置的GCC编译器(有点像sizeof是编译时运算符).这是与 <stdarg.h> 标准标头(由编译器提供,而不是C标准提供)库实现libc).真正重要的是调用约定

That __builtin_va_start is not defined anywhere. It is a GCC compiler builtin (a bit like sizeof is a compile-time operator). It is an implementation detail related to the <stdarg.h> standard header (provided by the compiler, not the C standard library implementation libc). What really matters are the calling conventions and ABI followed by the generated assembler.

GCC具有处理编译器内置程序的特殊代码.该代码不是定义内置的,而是实现其在编译器中的临时行为.并且__builtin_va_start被扩展为特定于GCC的已编译C/C ++代码的某些特定于编译器的内部表示(某些

GCC has special code to deal with compiler builtins. And that code is not defining the builtin, but implementing its ad-hoc behavior inside the compiler. And __builtin_va_start is expanded into some compiler-specific internal representation of your compiled C/C++ code, specific to GCC (some GIMPLE perhaps)

根据您的评论,我推断您对实现细节感兴趣.但是应该在您的问题中

如果您学习GCC 9.1源代码,请查看 gcc-9.1.0/gcc/builtins.c some (那里的expand_builtin_va_start函数),以及 other gcc-9.1.0/gcc/c-family/c-cppbuiltin.cgcc-9.1.0/gcc/cppbuiltin.cgcc-9.1.0/gcc/jit/jit-builtins.c

If you study GCC 9.1 source code, look inside some of gcc-9.1.0/gcc/builtins.c (the expand_builtin_va_start function there), and for other builtins inside gcc-9.1.0/gcc/c-family/c-cppbuiltin.c, gcc-9.1.0/gcc/cppbuiltin.c, gcc-9.1.0/gcc/jit/jit-builtins.c

您可以编写自己的 GCC插件(在2019年第二季度,适用于GCC 9,并且您的插件的C ++代码可能会在以后的GCC 10中进行更改,以添加您自己的GCC内置程序.顺便说一句,您甚至可以通过自己的特定代码来超载现有的 __builtin_va_start的行为,并且/或者至少出于研究目的,您可能拥有自己的stdarg.h标头和#define va_start(v,l) __my_builtin_va_start(v,l)并让您的GCC插件了解您的__my_builtin_va_start特定于插件的内置函数.但是请注意 GCC运行时库异常,并阅读其理由:我不是律师,但我倾向于认为您应该(并且该法律文件要求您)使用某些开源许可证来发布GCC插件.

You could write your own GCC plugin (in 2Q2019, for GCC 9, and the C++ code of your plugin might have to change for the future GCC 10) to add your own GCC builtins. BTW, you might even overload the behavior of the existing __builtin_va_start by your own specific code, and/or you might have -at least for research purposes- your own stdarg.h header with #define va_start(v,l) __my_builtin_va_start(v,l) and have your GCC plugin understand your __my_builtin_va_start plugin-specific builtin. Be however aware of the GCC runtime library exception and read its rationale: I am not a lawyer, but I tend to believe that you should (and that legal document requires you to) publish your GCC plugin with some open source license.

您首先需要阅读有关编译器的教科书,例如 龙书 ,以了解优化编译器主要是对已编译代码进行转换内部表示.

You first need to read a textbook on compilers, such as the Dragon book, to understand that an optimizing compiler is mostly transforming internal representations of your compiled code.

您还需要花费几个月的时间来研究GCC的许多内部表示形式.请记住, GCC 是一个非常复杂的程序(大约一千万行代码).不要指望只花几天的时间就可以理解它.在 GCC资源中心网站中查找.

You further need to spend months in studying the many internal representations of GCC. Remember, GCC is a very complex program (of about ten millions lines of code). Don't expect to understand it with only a few days of work. Look inside the GCC resource center website.

我死了的 GCC MELT 项目具有引用,并且

My dead GCC MELT project had references and slides explaining more of GCC (the design philosophy and architecture of GCC changes slowly; so the concepts are still relevant, even if individual details changed). It took me almost ten years full time to partly understand some of the middle-end layers of GCC. I cannot transmit that knowledge in a StackOverflow answer.

我的 草稿 Bismon报告(工作正在进行中,由H2020资助,因此许多官僚机构)有十二页(在第1.3和1.4节中)介绍了GCC的内部代表.

My draft Bismon report (work in progress, funded by H2020, so lot of bureaucracy) has a dozen of pages (in its sections §1.3 and 1.4) introducing the internal representations of GCC.

这篇关于__builtin_va_start在哪里定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆