- 博客(30)
- 资源 (22)
- 收藏
- 关注
原创 GCC's bacl-end & assemble emission (10)
<br />4.3.Generate Code for define_split<br />Now back to main, at line 840, the split part of thisdefine_insn_and_split will be written via gen_split. Our example is as following:<br /><br /><br /> <br /><br />figure 30 : genemit - example of define
2011-04-30 09:08:00 758
原创 GCC后端及汇编发布(10)
<br />4.3.为define_split产生代码<br />现在回到main,在840行,这个define_insn_and_split的split部分将被通过gen_split写出。我们的例子显示如下:<br /><br /><br /><br />图30:genemit - define_insn_and_split模式的例子– split部分<br /> <br />550 static void<br />551 gen_split(rtx split)
2011-04-30 09:06:00 956
原创 GCC's bacl-end & assemble emission (9)
<br />4. Toolof genemit4.1.Preparation for Code Generation<br />This tool outputs insn-emit.c file from machine description file.Insn-emit.c defines function sto generate a body for patterns, given operandsas arguments.<br /> <br />775 int<b
2011-04-30 09:03:00 904
原创 GCC后端及汇编发布(9)
<br />4. genemit工具4.1.代码输出的准备<br />这个工具从机器描述文件生成文件insn-emit.c。Insn-emit.c定义了,从机器描述文件中的模式定义生成的,以给定操作数作为参数的模式匹配函数。<br /> <br />775 int<br />776 main (int argc, char **argv) in
2011-04-30 08:59:00 1218
原创 GCC's bacl-end & assemble emission (8)
<br />3.4.Output insn-recog.c<br />Now we can output the file named insn-recog.c. It begins by write_subroutines.The parameter headpoints to recog_tree.<br /> <br />2336static void<br />2337write_subroutines (structdecision_head *head, enumrout
2011-04-23 10:04:00 1134
原创 GCC后端及汇编发布(8)
<br />3.4.输出insn-recog.c<br />现在我们可以输出名为insn-recog.c的文件了。这由write_subroutines开始,参数head指向recog_tree。<br /> <br />2336static void<br />2337write_subroutines (structdecision_head *head, enumroutine_type type) in genrecog.c<br />2338{<br />2339 st
2011-04-23 10:00:00 1128
原创 GCC's bacl-end & assemble emission (7)
<br />3.3.2.Reorgnize Recongnition Tree<br />Back to main, next process_treeis invoked to reorgnize the tree. It will try to simplify the tree and assignnodes to subroutines for output.<br /> <br />2582static void
2011-04-23 09:51:00 799
原创 GCC后端及汇编发布(7)
<br />3.3.2.重组识别树<br />回到main,下来调用process_tree来识别这棵树。它将尝试简化这棵树,并把节点赋予用于输出的函数。<br /> <br />2582static void ingenreocg.c<br />2583process_tree (structdecision
2011-04-23 09:45:00 904
原创 GCC's bacl-end & assemble emission (6)
<br />3.3.Build Recognition Tree3.3.1.Create Recognition Tree<br />For every instruction description pattern (as we see 3 types ofpatterns are used - define_insn, define_split, and define_peephole2. But theyare handled separatly, there are 3 kinds of t
2011-04-23 09:34:00 906
原创 GCC后端及汇编发布(6)
<br />3.3.构建识别树3.3.3.创建识别树<br />对于每个指令描述模式(正如我们看到有3个类型的模式在使用——define_insn,define_split及define_peephole2。但是它们被分别处理,因此有3种树对应这3个类型的模式),将构建形如图13的树。为了从这些树,以高效、方便的方式,产生insn-recog.c,我们需要把这些树合并成一棵大的树。这正是merge_trees.的目的。对于所有的描述,merge_trees应该构建一棵如下的树。<br /><br /><br
2011-04-23 09:30:00 1540 2
原创 GCC's bacl-end & assemble emission (5)
<br />3.2.3.Add RTL Template of Patterns into DecisionSequence<br />For our define_insn example above, the type passed to add_to_sequenceat line 2467, is RECOG. And the parameter pattern is the RTL template of the define_insnpattern. For our exampl
2011-04-23 09:22:00 913
原创 GCC后端及汇编发布(5)
<br />3.2.3.向决策序列加入模式的RTL模板<br />对于上面我们的define_insn例子,在2467行,被传给add_to_sequence的类型是RECOG。而参数pattern是这个define_insn模式的RTL模板。对于我们的例子是:<br />[(set (reg 17)<br /> (compare(match_operand:DI 0 "nonimmediate_operand" "r,?mr")<br /> (match_
2011-04-23 09:16:00 1307
原创 GCC's bacl-end & assemble emission (4)
<br />3. Toolof genrecog3.1.Preparation for Code Emission<br />The tool genrecog is used to generate the translate engine torecognize and transform RTL to asm. Here we see how the tool creates the enginefrom the machine description file – we
2011-04-23 09:04:00 987
原创 GCC后端及汇编发布(4)
<br />3. genrecog工具3.1.代码输出的准备<br />工具genrecog用于产生识别及转换RTL到汇编的转换引擎。在这里我们看到该工具如何从机器描述文件构建出这个引擎——我们以i386系统为例子,这个机器描述文件是i386.md。<br /> <br />2612int<br />2613main (int argc,char **argv)
2011-04-23 09:02:00 1325
原创 GCC's bacl-end & assemble emission (3)
<br />2.2.Output condition part of instruction definingpatterns<br />Following genconditions will generate array insn_conditions which containsconditional test part of instrucitons description patterns. This array will beused to help optimizing the
2011-04-16 08:15:00 733
原创 GCC后端及汇编发布(3)
<br />2.2.输出指令定义模式的条件部分<br />接着genconditions将产生包含指令描述模式的条件测试部分的数组insn_conditions。这个数组将被用于协助优化后端功能单元的生成,我们将在后面的章节看到这一点。<br /> <br />main (continued, genconditions)<br /> <br />199 /* Read the machine description. */<br />200 <br />201 while (1
2011-04-16 08:12:00 919
原创 GCC's bacl-end & assemble emission (2)
<br />2.1.2.Overview of DEFINE_INSN pattern<br />[ A define_insn as an RTLexpression containing four or five operands:<br />1. An optionalname. The presence of a name indicates that this instruction pattern canperform a certain standard job for the R
2011-04-16 08:10:00 1046
原创 GCC后端及汇编发布(2)
<br />2.1.2.DEFINE_INSN模式的概览<br />[一个作为RTL表达式的define_insn包含了4或5个操作数:<br />1. 一个可选的名字。名字的出现表示,这个指令模式可以为编译器的RTL产生遍执行一个固定的标准任务。这个遍知道某些名字,并使用具有这些名字的模式,如果这些名字在机器描述中定义了的话。<br />通过在名字的位置写入一个空字符串来表示名字的缺席。匿名的指令模式不会用于产生RTL代码,但它们可能允许合并多个简单的insn。<br />不认识因而不用于RTL生成的名字
2011-04-16 08:04:00 2073
原创 GCC's bacl-end & assemble emission (1)
<br />1. Overview<br />To make GCC porting to other machines (architecture) in mostefficient and convient way, GCC needs machine description file (MD file) forchips. To describe a chip, series definitions called pattern are introduced.General
2011-04-09 09:12:00 932
原创 GCC后端及汇编发布(1)
<br />1. 概览<br />为了使GCC以高效、方便的形式移植到其它机器(架构上),GCC需要芯片的机器描述文件(MD文件)。为了描述芯片,一系列称为模式(pattern)的定义被引入。通常,我们需要从两方面来描述芯片。<br />首先是在RTL形式定义的指令集——包括,指令看起来像什么(define_insn模式);哪个指令序列比其它等效的指令序列效率更高(define_peephole及define_peephole2模式);如何把一个复杂指令分解成多个简单些的指令,然后其中一个可
2011-04-09 09:09:00 5545
原创 182. Conclusion and advance notice
<br /><br />5.13.5.3.2.4.3. Conclusion and advance notice<br />From here on, RTL subtree will be constructed out of theintermediate tree, which is the important basis and starting point forassembler code generation. The back-end plays the key
2011-04-09 08:59:00 646
原创 182. 结束语及预告
<br /><br /><br />5.13.5.3.2.4.3. 结束语及预告<br />从这以下,RTL子树将根据中间树被构建出来,RTL子树是产生汇编代码的重要依据与出发点。后端将在基于RTL的优化及汇编发布中,起到关键的作用。后端的实现与前端有很大的差异,它广泛使用了代码生成工具。因此,接下来我们要首先学习这些工具,看看会产生怎么样的代码。
2011-04-09 08:58:00 1545 1
翻译 ELF对线程局部储存的处理(8)
<br />6. ELF新定义<br />这一节显示了,对于描述扩展ELF格式必须的,新引入的常量的实际定义。通用的扩展是:<br />#define SHF_TLS (1 <<10)<br />#define STT_TLS 6<br />#define PT_TLS 76.1.IA-64新ELF定义<br />#define R_IA64_TPREL14 0x91/* @tprel (sym+add), imm1
2011-04-04 20:19:00 1371
翻译 ELF对线程局部储存的处理(7)
<br />5.4.Alpha链接器优化<br />Alpha的链接器优化要比IA-32或SPARC的干净,因为对指令的次序没有限制。<br />重定位TLSGD/TLSLDM,LTERAL及LITUSE,在汇编文件中,由序号(sequence number)关联。这使得它们在目标文件中被连续发布(emit)。<br />不会发生__tls_get_addr模式的放宽,除非重定位以TLSGD,LITERAL及LITUSE_TLSGD,这个次序出现(对于TLSLDM,类似)。这用于区别TLSGD重定位不与任何
2011-04-04 20:17:00 1798
翻译 ELF对线程局部储存的处理(6)
<br />5. 链接器优化<br />线程局部储存访问模式,就使用的方式而言,是分层的。最通用的模式是常规动态模式,它可以随处使用。当生成执行映像本身时,初始可执行模式可以无条件使用。如果一个共享对象不是要动态载入的,它也可以使用。这两个模式已经定义了一个层次。余下两个模式,如果定义是与引用在同一个模块中,是对更通用模式之一的特殊优化。访问模式之间的层次及转换可以图形化地显示如下[1]:<br /><br />[1]这个图一开始是由MikeWalker制作的<br /><br /><b
2011-04-04 20:15:00 1313
翻译 ELF对线程局部储存的处理(5)
<br />4.4.局部可执行TLS模式<br />类似局部动态模式相对于常规动态模式加入的优化,优化局部动态模式得到局部可执行模式。它使用的限制性比局部动态模式还要大。它仅能用于执行映像自身的代码,并访问该执行映像本身的变量。<br />把使用限制在执行映像意味着,仅对于局部可执行模式而言,TLS块可以相对于线程指针取址。限定变量是那些定义在执行映像里的变量,这意味着总是使用第一个TLS块,这个块用于执行映像,因而对于地址计算来说,其它块的大小都不再重要。它亦意味着,当构建最终映像时,链接器知道到TC
2011-04-04 20:03:00 1009
翻译 ELF对线程局部储存的处理(4)
<br />4.3.初始可执行TLS模式<br />如果已知被访问的变量出现在程序启动时的一个模块中,并且如果程序选择使用静态访问模式,可以使用一个限制更多的优化。后一个条件意味着,所产生的代码不会使用函数__tls_get_addr,这又意味着,推迟为以这个方式访问的TLS块分配内存,是不可能的。但对于动态加载的模块,推迟分配仍然是可能的。<br />这个优化背后的想法是,在动态链接器载入所有被执行映像(及其它一些,像由LD_PRELOAD命名的,映像)直接或间接引用的模块后,每个在这些模块的TLS块
2011-04-04 20:01:00 1259
翻译 ELF对线程局部储存的处理(3)
<br />4.2.局部动态TLS模式<br />局部动态TLS模式是常规动态TLS模式的一个优化。如果编译器认识到,这个线程局部变量的引用所在的对象与其定义所在对象相同,它可以产生遵循这个模式的代码。这包括,比如,具有文件域的线程局部变量,或被定义为保护或隐藏的变量(更多这方面的信息参考:通用ELF ABI规范)。这里我们把这些类型的变量援引为受保护的。<br />提醒一下,一个线程局部变量由模块ID及在该模块的TLS块中的偏移来定义。在确信变量定义在引用它的模块中时,其偏移在链接时刻是已知的。模
2011-04-04 20:00:00 1394
翻译 ELF对线程局部储存的处理(2)
<br />4. TLS访问模式<br />文档到目前为止,提到了访问线程局部储存的两种不同的方式,动态模式及静态模式。TLS访问模式有基本的区分(basicdifferentiation)。不同的模式,归属于这两个分类之一,用于提供尽可能多好的性能。这个文档所涵盖的ABI定义了四种不同的访问模式。用于其它平台的ABI可能会定义额外的模式。<br />所有的模式的共同点是,在启动时刻的动态链接器,或当一个模块被动态加载时,需要处理与线程局部储存相关的重定位。这些重定位的处理不可以被推迟(
2011-04-04 19:59:00 1690
翻译 ELF对线程局部储存的处理(1)
<br /><br />一周之前,正在为GCC中对线程局部变量的处理而头疼不已,偶尔在文档《Using Gcc》里找到了这篇“ELFHandling For Thread-Local Storage”,它对线程局部变量的描述澄清了我的不少疑问,考虑到尚未看到中文的版本,特把它翻译了出来。当然这里的描述距离真正的代码实现还很远,不过从中已可窥探出,现代编译器、链接器确实是充满挑战、令人兴奋的软件。<br /> <br />ELF对线程局部储存的处理<br />原作者:UlrichDrepper,Red
2011-04-04 19:56:00 5972 1
Introduction to Theory of Computation
2018-09-23
Survey on Instruction Selection
2018-09-23
Towards a Compilation infrastructure for network processors
2018-09-23
Crafting a Compiler
2018-09-01
How Debuggers Work
2018-09-01
Compiler Construction-20th
2018-09-01
Compiler Construction-19th
2018-09-01
Compiler Construction-17th
2018-09-01
Compiler Construction-16th
2018-09-01
Compiler Construction-5th
2018-09-01
Construction and Evolution of Code Generator
2018-09-01
Compiler Construction-11th
2018-09-01
The compiler design handbook
2018-09-01
Data_Flow_Analysis_Theory_And_Practice(Bookos.org)
2018-09-01
The Compiler Design Handbook Optimizations and machine code generation
2018-09-01
instruction scheduling for instruction level parallel processor
2018-07-16
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人