您的位置:首页 > 编程语言

GCC-3.4.6源代码学习笔记(17)

2010-03-19 11:44 423 查看

2.4. 初始化优化参数

回到general_init,4264行的add_params把数组lang_independent_params的内容存入数组compiler_params。compiler_params保存编译器的参数及当前值。lang_independent_params由params.def以如下方式展开得到。

1022 static const param_info lang_independent_params[] = { in toplev.c
1023 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) /
1024 { OPTION, DEFAULT, HELP },
1025 #include "params.def"
1026 #undef DEFPARAM
1027 { NULL, 0, NULL }
1028 };

lang_independent_params是具有如下类型的数组。

44 typedef struct param_info in params.h
45 {
46 /* The name used with the `--param <name>=<value>' switch to set this
47 value. */
48 const char *const option;
49 /* The associated value. */
50 int value;
51 /* A short description of the option. */
52 const char *const help;
53 } param_info;

而在编译器内部为了索引这个数组,还定义了compiler_param这个枚举变量。

71 typedef enum compiler_param in params.h
72 {
73 #define DEFPARAM(enumerator, option, msgid, default) /
74 enumerator,
75 #include "params.def"
76 #undef DEFPARAM
77 LAST_PARAM
78 } compiler_param;

compiler_params是和lang_independent_params定义相同的数组。在编译器刚起来的时候,compiler_params通过add_params被lang_independent_params初始化,但它的内容可以通过编译指令更改。

42 void
43 add_params (const param_info params[], size_t n) params.c
44 {
45 /* Allocate enough space for the new parameters. */
46 compiler_params = xrealloc (compiler_params,
47 (num_compiler_params + n) * sizeof (param_info));
48 /* Copy them into the table. */
49 memcpy (compiler_params + num_compiler_params,
50 params,
51 n * sizeof (param_info));
52 /* Keep track of how many parameters we have. */
53 num_compiler_params += n;
54 }

以下的参数包括在文件params.def中。如果编译指令没有带这些参数,默认值将被使用。
优化选项
描述(Help string
默认值
max-inline-insns-single
可被内联的函数的最大指令数
500
max-inline-insns-auto
可被自动内联的函数的最大指令数
100
max-inline-insns-rtl
RTL内联器允许的最大指令数
600
max-delay-slot-insn-search
为填充延迟时段(delay slot)所考查的最大指令数
100
max-delay-slot-live-search
为查找正确的寄存器生命期信息所考查的最大指令数
333
max-pending-list-length
调度器(scheduling)的挂起操作链的最大长度
32
large-function-insns
被认为是大函数的尺寸
3000
large-function-growth
因为内联大函数而导致代码尺寸增大的上限(百分比)
100
inline-unit-growth
因为内联指定编译单元尺寸增大的上限(百分比)
50
max-gcse-memory
GCSE能分配的最大内存数
50*1024*1024
max-gcse-passes
执行GCSE时,使用的遍(pass)数上限
1
max-unrolled-insns
展开(unroll)一个循环时所考查的最大指令数
200
max-average-unrolled-insns
展开(unroll)一个循环时所考查的最大指令数的平均数
80
max-unroll-times
单个循环中展开部分个数的上限
8
max-peeled-insns
执行简单剥离(simple peeling)优化后,循环的最大指令数
400
max-peel-times
单个循环中简单剥离优化个数的上限
16
max-completely-peeled-insns
执行完全剥离(complete peeling)优化后,循环的最大指令数
400
max-completely-peel-times
单个循环中完全剥离优化个数的上限
16
max-once-peeled-insns
剥离优化后只展开一次的循环的最大指令数
400
hot-bb-count-fraction
选择“热”基本块(hot basic block)的,程序中基本块最大重复次数的分数(fraction,作为分母)。超过该值,即认为是“热”基本块
10000
hot-bb-frequency-fraction
选择“热”基本块的,函数中基本块最大执行频率的分数(fraction,作为分母)。超过该值,即认为是“热”基本块
1000
tracer-dynamic-coverage-feedback
以执行频率为权重,必须被跟踪格式(trace formation)所覆盖的函数比例。用在文件反馈(profile feedback)可用时
95
tracer-dynamic-coverage
以执行频率为权重,必须被跟踪格式(trace formation)所覆盖的函数比例。用在文件反馈(profile feedback)不可用时
75
tracer-max-code-growth
由尾重复(tail duplication)优化导致的最大增大尺寸(百分比)
100
tracer-min-branch-ratio
停止反向生长,如果最优边(best edge)的反向可能性小于这个阈值(百分比)
10
tracer-min-branch-probability-feedback
停止前向生长,如果最优边的可能性小于这个阈值(百分比)。用在文件反馈(profile feedback)可用时
80
tracer-min-branch-probability
停止前向生长,如果最优边的可能性小于这个阈值(百分比)。用在文件反馈(profile feedback)不可用时
50
max-crossjump-edges
作跨越跳转(crossjumping)时所考查进入边(incoming edge)数目的上限
100
max-cse-path-length
Cse中考察的路径(path)长度的上限
10
max-cselib-memory-locations
Ceslib记录的内存位置(memory location)数目的上限
500
max-last-value-rtl
可以被记录为合成器(combiner)最后值的RTL节点数目的上限
10000
ggc-min-expand
触发垃圾收集的最小堆使用大小(minimum heap expansion),以堆总大小的百分比计
Note 1
ggc-min-heapsize
开始垃圾收集时,堆的最小尺寸,单位K
Note 2
max-reload-search-insns
查找等效的重新装载(reload)时,向后查找的指令数目的上限
100
Note 1: GGC_MIN_EXPAND_DEFAULT
Note 2: GGC_MIN_HEAPSIZE_DEFAULT
表 8: 优化选项数据
最后,init_ggc_heuristics用于GCC的垃圾收集器。我们跳过它。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: