CN86107764A - 通过双色布石进行寄存器分配和指定 - Google Patents

通过双色布石进行寄存器分配和指定 Download PDF

Info

Publication number
CN86107764A
CN86107764A CN86107764.4A CN86107764A CN86107764A CN 86107764 A CN86107764 A CN 86107764A CN 86107764 A CN86107764 A CN 86107764A CN 86107764 A CN86107764 A CN 86107764A
Authority
CN
China
Prior art keywords
register
node
basic block
memory
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Lifetime
Application number
CN86107764.4A
Other languages
English (en)
Other versions
CN1003679B (zh
Inventor
阿施法·阿布杜里曼·穆施
卡尔·马克斯·施姆普福
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
International Business Machines Corp
Original Assignee
International Business Machines Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by International Business Machines Corp filed Critical International Business Machines Corp
Publication of CN86107764A publication Critical patent/CN86107764A/zh
Publication of CN1003679B publication Critical patent/CN1003679B/zh
Expired legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/441Register allocation; Assignment of physical memory space to logical memory space

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)
  • Complex Calculations (AREA)

Abstract

在一个无向量或向量处理器中将源代码编译成可执行代码期间,分配并优化寄存器指定的方法,在局部优化中使用了在每一基本程序块相关图上进行卵石游戏试探法,而在全程优化中使用活变量分析与循环展开方法。

Description

本发明涉及一种方法,在一个无向量或向量处理器中利用该方法,可以在源代码到机器可执行代码的编译期间分配及优化寄存器指定。
在编译程序构造的标准著作中,艾迪生-韦斯利出版公司1977年版,由爱荷等人所写的“编译程序设计的原理”一书和斯普林格-弗莱格1984年版,由韦特等人所著的“编译程序构造”一书中都指出,计算机源语言,例如PASCAL或FORTRAN,到可由目标机器执行的代码的转换是通过一系列变换来完成的。首先对源符号串进行词法分析,为翻译确定出原子单位或字,然后进行句法分析,确定出这些字之间的语法关系。输出是以“分析树”的形式表示的。该分析树被转换为源代码的中间语言表现形式。大多数编译程序并不明显地产生分析树,而当进行句法分析时形成中间代码。优化施加于中间代码,而后产生目标机器可执行代码或目标代码。
编译程序必须执行的任务中包括计算资源的分配和指定,以便由源代码指令流所确定的计算能够高效率地完成。有效“资源”中包括计算设备,例如ALU,输入/输出,包括寄存器的存贮器,操作系统成份等等。编译程序的优化部分的任务是(a)缩短代码长度,(b)在可能的地方增加执行速度,(c)通过资源的高效率分配,将开销降至最低程度。然后,资源使用或消耗程式一览表被送入正在编译的代码中。
众所周知,指令流可以被映成图形结构,并可利用图论特性的优越性。代码序列在局部优化中可以用基本程序块的图形性质进行分析而在全程优化中则可用程序块的流程图分析。
一个基本程序块是一个连续语句序列。该序列只能从头开始进入,共且在进入后语句是顺序执行的,除非到了结尾,否则不能停止或转移。
流程图描述了在基本程序块之间的控制流。例如,流程图将表示出基本程序块之间迭代或递归计算所需的循环,转移和嵌套。
数据相关性的无回路有向图(DAG)是一数据结构,用于分析基本程序块。例如,a=S+C由作为起始节点的b+c表达,每一节点通过各自的边连接于公共节点c。这不是流程图,虽然流程图的每个节点(基本程序块)可以由一个DAG表示。
“活变量分析”涉及一组技术,该组技术用于确定一个变量名是否具有一个经常在以后的计算中可能用到的值。如果一个变量名在基本程序块中重新定义之前被使用,或者“活”着离开这一程序块而未在程序块中被重新定义,则该变量被认为是“活”着进入程序块的。因此,一数值在寄存器中被计算之后,并假定在一基本程序块中已被使用过,如果它在程序块的结尾“死”了的话,则没必要存贮该数值。也即如果全部寄存器都已装满,而还需要另一个寄存器,则可指定当前含有“死”值的寄存器。
从概念上讲,第一个编译程序变换是将源代码串映成流程图,其流程图的每一节点都是基本程序块,其控制及数据路径关系由流程图的有向边确定。资源分配和指定的优化工作可以首先在局部或基本程序块这级进行,然后再在全程流程图一级进行。
在局部优化中,每一基本程序块被当作一个独立的单位,并在优化中不考虑程序块的内容。为基本程序块建立的数据相关图被变换并用以产生最终机器代码。然后被废弃,再进行下一个基本程序块。“数据相关图”是一个基本程序块中的一种图论特征表示。由于一个基本程序块不能包含循环,因而所有“数据相关图”的基本块可以由DAG来表示。而DAG不必是树。作为示例,如果一个基本程序块由两条计算语句x=u+v和y=u+w组成,虽然它是无回路的,DAG仍将不是树。最后,全程优化执行一个流程图的全程重排,并在基本程序块之间提供上下文信息。
计算机包括主存贮器,其最快的形式是最昂贵的。若干有限的物理寄存器存贮操作数,以备计算和控制的立即使用。从寄存器到寄存器操作的计算机指令是最快速执行的。如果无法获得一个寄存器,则中间结果必须被装入主存贮器,大部分程序体及数据定位于该主存,或者当一个寄存器可以得到时,将中间结果从所述主存转入该寄存器。从主存到寄存器的装入及从寄存器到主存贮器的存贮需要更长一些的时间。因此,在评价一个流程图或基本程序块时,目标之一是在寄存器中保存尽可能多的计算名即变量,或保证在需要时可以获得一个寄存器。
寄存器分配涉及到在软件流中的名中,指定哪些应当位于寄存器中(即所需寄存器数);同时,而指定则是遵循一基础模式,定则,或模型把寄存器指定给节点的步骤。在先有技术中使用的分配策略是把指定固定化;即,将目标程序中的某些特定类型的量指定给确定的寄存器。例如,子程序连接可指定给第一组寄存器,基地址到第二组寄存器,算术计算到第三组寄存器,运行时栈指针到一固定寄存器,等等。这种固定映象的缺陷是寄存器使用不能动态地适合运行的需求。这就是说,某些寄存器根本没有用到,或使用过度,或使用不足。
全程寄存器分配与下述观察结果有关,即大多数程序将它们的大部分时间用在内循环上。因此,一个指定方法是,在一固定的寄存器中,贯穿一个循环保存一个经常使用的变量名。为此,其策略是可以指定一固定数量的寄存器来容纳每个内循环中的最活跃的名。所选择的名在不同的循环中可以不同。其它非专用的寄存器可以用来容纳一个程序块的局部数值。这种分配和指定的缺点是无法确定作为全寄存器分配所能利用的寄存器的普遍适用的数量。
珀格蒙出版有限公司1981年版的《计算机语言》第6卷第47至57页上蔡廷等的“通过着色进行寄存器分配”(Register    Allocation    Via    Coloring),以及SIGPLAN情报1982年版第98至105页上的编译程序构造论文集,82年SIGPLAN科研报告汇编中蔡廷的“通过图的着色进行寄存器分配和转贮(Register    Allocation    and    Spilling    Via    Grap    Coloring)”描述了一种在全过程范围的全程寄存器分配方法。在蔡廷的文章中,全部寄存器除了一个以外,被看作是一均匀池中的一部分,并且所有计算在同一基础上对寄存器进行竟争。确实不保留寄存器子集。
蔡廷指出,由于使用装入和存贮指令的代价高于寄存器到寄存器的指令,因而应在寄存器中保存尽可能多的计算,而不是将它们存入存贮器。蔡廷指出:利用在中间语言中允许使用无限数量的寄存器这一优越性(即将这些不定数量的寄存器看作是一个池),以使程序中的装入及存贮数量降至最小是代码产生及优化的责任。
蔡廷文章中的关键性意见是,寄存器分配可以作为图的着色问题进行分析。图的着色是对其每个节点指定一种颜色,方式是如果两个节点是相邻的(由图的一个边连接),它们的颜色就不同。图的“色数”是任何着色中彩色的最小数。在蔡廷的文章中,寄存器分配利用了名为“寄存器干扰图”的构造。如果存于机器寄存器中的两个计算或名在程序中的任何一点同时“活着”的话,则它们被称为互相“干扰”。
蔡廷的图着色方法包括步骤(a)根据代码的一个特定文本顺序为其中的名建立一个干扰图;(b)确定图的色数,如果色数不超过可用寄存器数,则对图着色(将寄存器指定给节点),否则,应用弃置具有最高输入/输出度的节点的方法将图简化;(c)重复步骤(b),直至两个数值达到一致;以及(d)通过在编译生成的代码流中加入适当的写入内存指令和装入寄存器指令,说明并管理寄存器转贮。
本发明的一个目的是在无向量或向量处理器中源程序到可执行代码的编译期间优化分配和指定寄存器,从而将转储量降至最小(进出存贮器的引用次数)。分配和指定寄存器以使转储代码的数量在基本程序块内部的文本的各种排列中保持不变是一个相关的目的。
这些目的用下述方法来达到,即:在一个无向量或向量处理器中将源代码编译成可执行代码的优化阶段,对不含称为“基本程序块”的分支的代码区域进行优化。每个基本程序块具有定义计算的语句。并且,每个处理器具有用于存贮可执行代码序列和数据的存贮器,和用于访问所述存贮器并执行任何被访问代码的装置。在处理器中,存贮器被设计成两级模式的,包括有限个数P的寄存器和一个相对说来无限的内存贮器。寄存器的存取时间快于内存贮器。
本发明方法包括处理器实现的步骤(a)确定一基本程序块的数据相关图特性,和(b)参照基本程序块中的所有计算,在确定的数据相关图上实行“两色石子游戏”试探法来分配P个寄存器中的P个以充分利用这两级存储模型。
进一步达到上述目的用于局部和全程寄存器优化的方法,其步骤除了上述(a)和(b)以外,还包括(c)进行活变量分析,并相应地产生一个假定循环为最有效优化实体的全程寄存器分配和指定。
与蔡廷的“寄存器干扰图”不同,数据相关图对于文本的排序是不变的。本发明的方法将分配处理划分为两步。第一步是获得一个令人满意的局部分配,第二步是利用这个局部分配得到一全程分配。在数据相关图上进行的“两色石子游戏”试探法确保基本程序块中的转储降至最小。这一试探法包括在对应于基本程序块的图上进行红兰两色石子游戏。对存贮器的访问以在图上放置蓝色卵石表示,而对寄存器的访问以在图上放置红色卵石表示。这种模型准确地控制转储。相同的相关图永远产生相同的分配。
有意义的是,在执行局部分配时,并不使用全部可用寄存器。实际上,某些寄存器被用来装存全程信息。与其相关,第二个主要步骤是利用这些寄存器执行全程分配,进一步减少对存贮器的访问。为那些全程寄存器选择的变量是为了最大限度地减少整个程序中的装入及存贮操作量。
以本发明来说,石子游戏是一个利用DAG的单人游戏。玩者接受两类卵石;红的和蓝的。蓝石数是无限制的,而红石的限制数为P。开始时,DAG的全部源点都置为蓝色。玩者可以走下列棋步的任何一步:
(1)放置一红石与蓝石相邻;
(2)放置一蓝石与红石相邻;
(3)放置一红石在节点上,当且仅当全部先行节点都为红石时;
(4)从一个节点的先行节点之一取一红石滑动到该节点,当且当在滑动之前这些先行节点都为红石;或
(5)在任何时候除去一红石。
这里,蓝石是存贮单元,而红石是寄存器。在这种情况下,规则(1)是从存贮器中取数送入寄存器,规则(2)是写入存贮器,规则(3)是将一个计算的值送入一个新寄存器,规则(4)是将一个计算的值送入一个以前存放该计算所用的计算数的寄存器中。在寄存器分配的意义中,该游戏的目的是将转储量降至最小,其中转储是指规则(1)或(2)的应用。
卵石游戏已经在先有技术中描述过,例如1980年5月26日至28日在日本箱根召开的第5届IBM“计算机科学的数学基础(5th    IBM    Symposinm    on    the    Mathenm    tical    Foundations    of    computer    Science)”科研讨论会上皮彭杰的《布石(Pebbling)》。皮彭杰指出,“布石”已找到了其应用范围,其中包括编译程序,尤其是代码生成及优化。皮彭杰采用的游戏是一单色游戏,有时称为“黑卵石游戏”。
无可否认,“黑卵石游戏”已被用于空间时间交换的研究。“空间时间交换”涉及到由可资利用的寄存器数与完成计算所需的时间的乘积导致某些因素改变所造成的后果。该乘积是一个与数据相关图中的节点数成正比的量。如果只用一种颜色表示寄存器,则对于任意给出的计算,皮彭杰问道:“为了执行所述计算,什么是所要求的最小寄存器数?”可是,皮彭杰的单色卵石游戏既没有讲授也没有提出这种独创的方法。具有重大意义的是,本发明通过在DAG上的两色石子布设对寄存器的分配和指定来处理局部优化,并以循环为基础来处理全程优化,与正流行的图着色方法相比,综合该两项优化可将转储降至最小。
图1和图2分别说明了三个基本程序块组成的计算序列和图1中程序块的数据相关图解释,在第一个例子中利用这两个图解释了根据本发明运用石子试探法进行局部寄存器分配。
图3表示根据先有技术的图1中序列的寄存器干扰图。
图4表示根据先有技术,为了允许着色,将图3中的节点减少了若干以后的干扰图。
图5和图6表示根据本发明运用试探法进行局部寄存器分配的第二个例子中的计算序列,数据相关图,和寄存器活动序列。
图7是根据本发明的全程分配步骤的描述设制的流程图。
最佳实施例的描述将首先利用卵石游戏试探法算法的描述处理寄存器的分配和指定以达到局部优化,随后讨论全程分配。
局部优化应用了“卵石游戏”试探法。就本发明的目的而言,“试探法”是一个以直觉为基础,以机器来实现的过程或算法,用于达到一个预期地接近最优的结果。
参看图1至5和6,这里展示了划分成基本程序块的计算序列,并由与其相配的DAG型数据相关图表示。对第一次近似的试探如下:
1、检验DAG,并标识P个支配节点,即具有最大后继点的那些节点,其中P是红卵石数。与每个具有P个节点的集合有关的“费用”是该集合中非红色节点数。在这些集合中选择一个集合,它具有费用/支配节点数比的最小值。这就为计算定义了一个“期望”区域。
2、下一步,计算每个节点的覆盖费用,以找出一个“令人满意”的计算,所述节点是上述所选集合的紧随后继节点。覆盖费用有两个参数。其中包括(a)未被红石布设的先行节点数,以及(b)从紧随先行节点到本节点的最小滑动费用。与其相关,滑动费用是(a)中的先行点的最小出度。所谓“出度”,是指尚未计算过的后继节点数。作为插句,每执行一次计算,未被计算的后继点数就改变一次。因此,举例说,参照图2中的基本程序块1,节点块具有(2,1)的覆盖费用。这里,先行节点数是2(节点x和y),而初始时的滑动费用(对未被计算的后继节点的出度)对x是1,对y是3。选择其中具有较小滑动费用的节点。一旦覆盖费用被算出,算法的下一步将要执行的计算选择具有最小覆盖费用的那一步。
3、一旦确定了一个“令人满意”的计算,红色石子从属节点便采用滑动卵石的规则。如果没有红卵石可以滑动,则使用一个当前不在DAG上的红卵石,如果有这样一个红卵石存在的话。
4、如果寄存器不可用,则中间结果必须写到存贮器,并在需要时送数回到寄存器。
参看图2,节点t1依赖于源节点x和y,同时节点q依赖于节点y和z。依次,结果v依赖于节点t1和y。假设有三个寄存器r0,r1,和r2是可用的,选择一个由三个节点组成的支配者。支配者只可能是集合{x,y,z}。因此称它为“期望”集。
节点t1和q是所选支配集合的后继节点。对于每个节点,算出它的覆盖费用。因为t1的两个先行节点未被卵石布设,所以t1的覆盖费用是(2,1),且由于x只有一个未被计算的后继点,因而最小滑动费用是1。这种情况同样用于q。由于t1和q的覆盖费用是相同的,因而可任意选择一节点,例如选t1。为了计算t1,红卵石必须首先放在x和y处。下一步,将x上的红石滑动到t1,因为x的滑动费用是1。现在,用将t1上的红石滑动到v上的办法计算节点v。在装入z之后,将y上的卵石滑动到q,从而计算出节点q。
以上分析表明,给出足量的寄存器,可以相当顺利地进行调度。
现在参看图3和4,其中展示了一个寄存器干扰图,该图根据先有技术中蔡廷所参照的图1所示的计算序列。图3中的图在技术上是可着三色的。可是,如果只有两个寄存器是可用的(r0,r1),则本质上不可能将图着色。除去并废弃具有最高度数的节点是有必要的。在这方面,图4是一个先有技术的例子,其中干扰图的节点x和y被除去。可是,为了成为着双色的图,节点z也将被除去。这三个节点的废弃意味着可观的转储代码量。反之,如果只有两个寄存器可用,并根据图2中的数据相关图将它们指定,则只要求三个装入和一个存贮即可。
现在参看图5和6,再一次假定有三个寄存器和三个红卵石是可用的。根据算法,节点u,v和w将被选作为支配节点。覆盖费用(x)=(2,1),而覆盖费用(y)=(2,2)。因此,算法选择计算节点x的值。由于覆盖费用=(c1,c2),则对于c1=2,算法对当前前沿计算转储节点(x)。前沿是这样的节点集合,即集合中的每个节点v上都有一卵石,并且至少有一个v的后继点未被计算过。这就称为前沿。
由于没有在DAG上放置红卵石,因而它是空的。由于该方法可以将自由红卵石置于节点u和v。并且,由于c2=1,节点u处的寄存器被滑动到节点x,从而完成了一次计算。再选择另一个支配集。这次节点P被作为计算的目标,因为覆盖费用(P)=(0,1)。如前所示,c2=1。意即节点x上的寄存器可滑动到节点P。
现在可以清楚地看到,使用该方法将必须计算节点y,然后是节点z,因为没有其它选择可用。参看图5。可注意到只执行了三个装入,并且P和z已经在寄存器中。这就是说如果其中之一在以后被使用,则不需要任何从存贮器到寄存器的装入。
重要的是,代码在序列中无论怎样排列,数据相关图是保持不变的。由这种方法所产生的结果是不依赖文本顺序的。
还可以看到,如果着色的先有技术已经应用于图6所示的代码,则装入数应该是4,而本发明方法的装入数只有3,这是最小的可能数。
在本发明中,全程优化首先涉及到对每个基本程序块的局部分配,利用可用寄存器总数的一部分,并按基本程序块在流程图中出现的顺序执行该分配。然后,假定循环是最关键的实体,利用剩余的寄存器存放全程信息。
参看图7,其中的流程图从一起始节点开始,在一结束节点终结。
假设已经完成了局部分配,全程步骤检验在每一局部分配中装入寄存器和存入器存的那些变量。对于这些变量,计算它们每一个的装入寄存器和存入内存的次数。这一计数用所谓的嵌套深度加权,嵌套深度是指流程图中围绕该变量的循环的次数而言的。从这个表中选择具有最高值的变量保存于全程寄存器。重复这项处理,直至没有寄存器可用了,或是表已空时为止。
全程分配的这一模式和步骤有一些变型。例如,输入全程寄存器的变量是那些在表示对应局部分配的流程图中具有最大生命期的变量。即,局部分配代替了输入程序中相应的基本程序块。然后,对于全部那些对基本程序块不是局部的变量计算它们的生命期。根据使用次数和嵌套深度断路关系(nesting    level-breaking    ties),生命期被用来确定将哪个变量分配给全程寄存器。
当出现这样的情况时,即变量在循环的底部在不同寄存器中被转储而在循环的顶部却要用着这些变量时,可将循环展开直至不需要传送或传送次数低于预定的界限。
算法Local-Alloc(DAG,num-registers)Current-frontier:=sources(D):(置前沿于DAG的源点)current-configuration:=(empty,current-frontier);while(number    of    uncomputed    nodes    not    zero)do
Find    a    set    S,of    P    nodes,in    the    currentfrontier,
such    that    move-eost(s)/(number    of    nodes    that    S    dominates)in    minimized。
(找出一个令人满意的计算去作)
compute    the    cover    covt    of    every    node    in    FS(S);
Let u be the node in FS(S) with the smalle tcover cost,where cover-cost(u)=(c1,c2);
(为计算找出可能的转储节点)
ifc1>0 then for each node v in spill-nodes(u,s),
if    v    is    not    pebbled    blue    then    place    a    blue    pebble    on    V.Remove    the    red    pebble    from    V.
while    not    all    predecessors    of    u    are    pebbled    red    do
put    a    free    red    pebble    on    a    pvedecessors    of    u
not    pebbled    red.
(布石计算)
ifc2=1then slide the node with slide-cost=1
to    u    else
if    any    free    red    pebbles,
then    put    free    pebble    on    u
else    begin
let    v    be    the    pcedceessor    of    u    with    the
smallest    slide    cost
if    slide-cost(v)>0,put    a    blue    pebble    on    v;
slide    v    to    u;
end;
od;
本发明的这一方法可用于IBM/370系统的无向量处理器,或用于像IBM3090这样的向量机。在向量处理器中,最好以高速运行计算。这就是说,运算访问存贮器应该越少越好,因为存贮器访问与对向量寄存器的访问相比要慢得多。上述卵石游戏试探法可以用于确定向量寄存器数,其步骤如下。首先,选择一个初始向量寄存器数,然后对应欲被执行的向量计算的数据相关图DAG,施行所述试探法。下一步,对这一固定的寄存器数计算所执行的装入/存贮总数。此后,将该数与需要的访问次数的下界相比较;即,源点数加上收点数。如果执行了太多的访问,则将寄存器数增加一倍,并再次应用本算法。如果达到了下界,则将寄存器数减半,并重复本算法,直到确定了最佳寄存器数。这与在向量寄存器数上执行一个折半查找是等效的,并利用卵石游戏试探法确定查找参数。
本发明的另一个扩充是其在某些机器中的应用,在这些机器中,计算可以与装入和对存贮器的存贮重叠。由于本试探法试图在当前存于寄存器中的数据基础上作尽可能多的计算,它就必定会在计算和存贮器访问之间提供一个良好的重叠方式。
将本发明嵌入一个高级语言编译程序的优化部分中可以很便利地运行,例如嵌入PL/I,FORTRAN,COBOL,等等,并在诸如BM/370系统中运行,这已在1968年9月3日发表的美国专利申请号3,400,371上阿姆代尔符的“数据处理系统”,以及IBM出版物GA22-7000-6号上的“IBM/370系统操作规则”中进行过描述。

Claims (2)

1、一种用于分配寄存器并优化所述分配的方法,是在一个无向量或向量处理器中将源代码编译成可执行代码的优化阶段里,对不含“基本程序块”的分支的代码区域进行优化,每个基本程序块具有定义计算的语句,
每个处理器包括用于存贮可执行代码序列和数据的存贮器,以及用于访问所述存贮器并执行任何被访问代码的装置;存贮器被设计为两级模式,包括有限数量P的寄存器和一个相对无限的内存贮器,所述寄存器的访问时间快于内存贮器,
这些步骤的特征在于:
(a)确定一个基本程序块的数据相关图特性;
(b)根据该基本程序块中的全部计算产生对p个寄存器中的q个的分配和指定,其步骤为
(b1)沿叶-根节点方向,选择具有最大后继节点数(支配者)的图的节点集合;
(b2)确定上述所选集合的每个紧随后继点的覆盖费用,为该集合中覆盖费用最小的紧随后继点指定一个寄存器;以及
(b3)在缺少任何可用可分配寄存器的情况下,将由计算在该节点产生的中间或最后结果写到内存贮器,以后根据需要将其装回可用寄存器。
2、一种在无向量或向量处理器中将源代码编译成可执行代码期间分配并优化寄存器分配的方法,
源代码包括不具分支的称为“基本程序块”的代码区域,每个基本程序块具有定义计算的语句,
每个处理器包括用于存贮可执行代码序列和数据的存贮器,以及用于访问所述存贮器并执行任何被访问代码的装置;存贮器被设计为两级模式,包括有限数量P的寄存器和一个相对无限的内存贮器,所述寄存器的访问时间快于对内存贮器的访问。
其步骤的特征在于:
(a)确定每个基本程序块的数据相关图特性;
(b)根据每个基本程序块中的全部计算,对P个寄存器中的q个产生局部寄存器分配和指定,其步骤为
(b1)沿叶-根的节点方向,选择具有最大后继节点数(支配者)的图的节点集合;
(b2)确定上述所选集合的每个紧随后继节点的覆盖费用,并为该集合中覆盖费用最小的紧随后继点指定一寄存器;以及
(b3)在缺少任何可用可分配寄存器的情况下,将由计算在该节点产生的中间或最后结果写到内存贮器,以后根据需要将其装回一可用寄存器。
(c)在基本程序块的流程图式表示上进行活变量分析,并在(p-q)个剩余寄存器中相应产生全程寄存器分配和指定,假定在基本程序块的流程图中所表示的循环是最有意义的优化实体。
CN86107764.4A 1985-12-17 1986-11-14 编译源代码为目标代码及执行目标代码的方法 Expired CN1003679B (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
US06/809,989 US4782444A (en) 1985-12-17 1985-12-17 Compilation using two-colored pebbling register allocation method such that spill code amount is invariant with basic block's textual ordering
US809,989 1985-12-17

Publications (2)

Publication Number Publication Date
CN86107764A true CN86107764A (zh) 1987-07-01
CN1003679B CN1003679B (zh) 1989-03-22

Family

ID=25202684

Family Applications (1)

Application Number Title Priority Date Filing Date
CN86107764.4A Expired CN1003679B (zh) 1985-12-17 1986-11-14 编译源代码为目标代码及执行目标代码的方法

Country Status (8)

Country Link
US (1) US4782444A (zh)
EP (1) EP0229245A3 (zh)
JP (1) JPH0776927B2 (zh)
KR (1) KR910009116B1 (zh)
CN (1) CN1003679B (zh)
BR (1) BR8605865A (zh)
CA (1) CA1264859A (zh)
ES (1) ES2004348A6 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100337202C (zh) * 2004-12-03 2007-09-12 中国科学院计算技术研究所 一种汇编代码热函数中的热路径搜寻方法
CN100414505C (zh) * 2005-07-08 2008-08-27 中国科学院计算技术研究所 一种基于组合并算法的偏移量分配优化方法
CN103399741A (zh) * 2013-07-24 2013-11-20 中国科学院声学研究所 一种汇编级静态路径剖析方法及装置
CN106610860A (zh) * 2015-10-26 2017-05-03 三星电子株式会社 半导体装置的操作方法和半导体系统

Families Citing this family (107)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6378231A (ja) * 1986-09-22 1988-04-08 Nec Corp 部分的プログラム結合方式
JPS6476322A (en) * 1987-09-18 1989-03-22 Hitachi Ltd Program synthesizing method
JPS6481035A (en) * 1987-09-22 1989-03-27 Nec Corp C compiler
US4953084A (en) * 1987-11-16 1990-08-28 Hewlett-Packard Company Method and apparatus using variable ranges to support symbolic debugging of optimized code
US5121498A (en) * 1988-05-11 1992-06-09 Massachusetts Institute Of Technology Translator for translating source code for selective unrolling of loops in the source code
US5129086A (en) * 1988-11-29 1992-07-07 International Business Machines Corporation System and method for intercommunicating between applications and a database manager
US5070453A (en) * 1989-04-10 1991-12-03 At&T Bell Laboratories System and method for scheduling data transfers among a plurality of data processing units to avoid conflicting data requests
US5193190A (en) * 1989-06-26 1993-03-09 International Business Machines Corporation Partitioning optimizations in an optimizing compiler
US5274820A (en) * 1989-08-14 1993-12-28 International Business Machines Corporation Method and system for eliminating operation codes from intermediate prolog instructions
JPH03150637A (ja) * 1989-11-08 1991-06-27 Oki Electric Ind Co Ltd パイプライン対応のレジスタ割付け方式
US5428793A (en) * 1989-11-13 1995-06-27 Hewlett-Packard Company Method and apparatus for compiling computer programs with interproceduural register allocation
WO1991010954A1 (en) * 1990-01-19 1991-07-25 Alliant Computer Systems Corporation A risc vectorization system
CA2010067C (en) * 1990-02-14 1993-10-26 Steven Murray Hoxey Reducing pipeline delays in compilers by code hoisting
EP0453160A3 (en) * 1990-04-20 1993-09-15 Digital Equipment Corporation A method and apparatus for analyzing the flow of data through a complex information exchange system
US5212794A (en) * 1990-06-01 1993-05-18 Hewlett-Packard Company Method for optimizing computer code to provide more efficient execution on computers having cache memories
US5202975A (en) * 1990-06-11 1993-04-13 Supercomputer Systems Limited Partnership Method for optimizing instruction scheduling for a processor having multiple functional resources
US5107418A (en) * 1990-06-11 1992-04-21 Supercomputer Systems Limited Partnership Method for representing scalar data dependences for an optimizing compiler
JPH0816871B2 (ja) * 1990-12-07 1996-02-21 富士ゼロックス株式会社 プログラム翻訳装置およびプログラム翻訳方法
US5511218A (en) * 1991-02-13 1996-04-23 Hughes Aircraft Company Connectionist architecture for weapons assignment
JP3032031B2 (ja) * 1991-04-05 2000-04-10 株式会社東芝 ループ最適化方法及び装置
JP3049814B2 (ja) * 1991-04-09 2000-06-05 日本電気株式会社 マイクロコンピュータの言語処理装置
US5530866A (en) * 1991-07-30 1996-06-25 Tera Computer Company Register allocation methods having upward pass for determining and propagating variable usage information and downward pass for binding; both passes utilizing interference graphs via coloring
US5339428A (en) * 1991-09-04 1994-08-16 Digital Equipment Corporation Compiler allocating a register to a data item used between a use and store of another data item previously allocated to the register
JP2970785B2 (ja) * 1991-10-18 1999-11-02 松下電器産業 株式会社 資源割り付け装置
US5386562A (en) * 1992-05-13 1995-01-31 Mips Computer Systems, Inc. Circular scheduling method and apparatus for executing computer programs by moving independent instructions out of a loop
US5418958A (en) * 1992-07-15 1995-05-23 Sun Microsystems, Inc. Register allocation by decomposing, re-connecting and coloring hierarchical program regions
US5367651A (en) * 1992-11-30 1994-11-22 Intel Corporation Integrated register allocation, instruction scheduling, instruction reduction and loop unrolling
US5469572A (en) * 1992-12-01 1995-11-21 Taylor; James M. Post compile optimizer for linkable object code
DE69331705T2 (de) * 1992-12-21 2002-12-19 Apple Computer Verfahren und gerät zur umwandlung einer beliebigen topologie von einer knotensammlung in einen acyclischen gerichteten graph
SE502733C2 (sv) * 1993-06-11 1995-12-18 Ellemtel Utvecklings Ab Sätt att undvika ej önskvärd interferens mellan tjänster i ett telekommunikationssystem
CA2134059C (en) * 1993-10-29 2009-01-13 Charles Simonyi Method and system for generating a computer program
US5491823A (en) * 1994-01-25 1996-02-13 Silicon Graphics, Inc. Loop scheduler
US5999737A (en) * 1994-03-01 1999-12-07 Digital Equipment Corporation Link time optimization via dead code elimination, code motion, code partitioning, code grouping, loop analysis with code motion, loop invariant analysis and active variable to register analysis
US5590356A (en) * 1994-08-23 1996-12-31 Massachusetts Institute Of Technology Mesh parallel computer architecture apparatus and associated methods
JP3606387B2 (ja) * 1994-09-13 2005-01-05 松下電器産業株式会社 コンパイル装置
US5802375A (en) * 1994-11-23 1998-09-01 Cray Research, Inc. Outer loop vectorization
CN1149476C (zh) * 1995-03-16 2004-05-12 松下电器产业株式会社 资源分配装置
US5659754A (en) * 1995-03-31 1997-08-19 Sun Microsystems, Inc. Method and apparatus for an improved optimizing compiler
US20100131081A1 (en) * 1995-05-30 2010-05-27 Brown David W Systems and methods for motion control
US5691897A (en) * 1995-05-30 1997-11-25 Roy-G-Biv Corporation Motion control systems
US7137107B1 (en) 2003-04-29 2006-11-14 Roy-G-Biv Corporation Motion control systems and methods
US20060206219A1 (en) * 1995-05-30 2006-09-14 Brown David W Motion control systems and methods
US7139843B1 (en) 1995-05-30 2006-11-21 Roy-G-Biv Corporation System and methods for generating and communicating motion data through a distributed network
US7024666B1 (en) * 2002-01-28 2006-04-04 Roy-G-Biv Corporation Motion control systems and methods
JP3060907B2 (ja) * 1995-07-28 2000-07-10 日本電気株式会社 言語処理プログラムの処理方式
US5761514A (en) * 1995-08-31 1998-06-02 International Business Machines Corporation Register allocation method and apparatus for truncating runaway lifetimes of program variables in a computer system
US6135650A (en) * 1995-12-22 2000-10-24 Sun Microsystems, Inc. Method and system for wrapper routine optimization
US5901317A (en) * 1996-03-25 1999-05-04 Sun Microsystems, Inc. Method and system for register allocation using multiple interference graphs
US5946491A (en) * 1996-06-06 1999-08-31 International Business Machines Corporation Register allocation method and apparatus for gernerating spill code as a function of register pressure compared to dual thresholds
US5901316A (en) * 1996-07-01 1999-05-04 Sun Microsystems, Inc. Float register spill cache method, system, and computer program product
KR100186338B1 (ko) * 1996-08-02 1999-05-15 문정환 교환법칙이 성립하는 연산기의 입력단수 저감방법
WO1998006038A1 (en) * 1996-08-07 1998-02-12 Sun Microsystems, Inc. Architectural support for software pipelining of loops
US6049864A (en) * 1996-08-20 2000-04-11 Intel Corporation Method for scheduling a flag generating instruction and a subsequent instruction by executing the flag generating instruction in a microprocessor
US5937195A (en) * 1996-11-27 1999-08-10 Hewlett-Packard Co Global control flow treatment of predicated code
US5890000A (en) * 1996-12-04 1999-03-30 International Business Machines Corporation Cooperation of global and local register allocators for better handling of procedures
US6029005A (en) * 1997-04-01 2000-02-22 Intel Corporation Method for identifying partial redundancies in a new processor architecture
US6016398A (en) * 1997-04-01 2000-01-18 Intel Corporation Method for using static single assignment to color out artificial register dependencies
US6151704A (en) * 1997-04-01 2000-11-21 Intel Corporation Method for optimizing a loop in a computer program by speculatively removing loads from within the loop
US5991540A (en) * 1997-04-01 1999-11-23 Intel Corporation Method for identifying partial redundancies in existing processor architectures
US6031994A (en) * 1997-04-01 2000-02-29 Intel Corporation Method for determining the set of variables that may be ambiguously defined at a point in a computer program
CA2205797C (en) * 1997-05-22 2001-04-24 Andrew Wilfred Macleod A system for local context spilling for graph colouring register allocators
US6139200A (en) * 1997-06-30 2000-10-31 Sun Microsystems, Inc. Register resource allocation feedback
US6009272A (en) * 1997-06-30 1999-12-28 Sun Microsystems, Inc. Register allocation via selective spilling
US5987259A (en) * 1997-06-30 1999-11-16 Sun Microsystems, Inc. Functional unit switching for the allocation of registers
US6314562B1 (en) 1997-09-12 2001-11-06 Microsoft Corporation Method and system for anticipatory optimization of computer programs
US20010032278A1 (en) 1997-10-07 2001-10-18 Brown Stephen J. Remote generation and distribution of command programs for programmable devices
US6058265A (en) * 1997-10-21 2000-05-02 Hewlett Packard Company Enabling troubleshooting of subroutines with greatest execution time/input data set size relationship
US6292938B1 (en) * 1998-12-02 2001-09-18 International Business Machines Corporation Retargeting optimized code by matching tree patterns in directed acyclic graphs
US6954927B2 (en) * 1999-02-17 2005-10-11 Elbrus International Hardware supported software pipelined loop prologue optimization
US6317876B1 (en) * 1999-06-08 2001-11-13 Hewlett-Packard Company Method and apparatus for determining a maximum number of live registers
JP4041248B2 (ja) * 1999-07-09 2008-01-30 松下電器産業株式会社 コンパイラ装置、コンパイルプログラムが記録されたコンピュータ読み取り可能な記録媒体及びコンパイル方法
US6885898B1 (en) 2001-05-18 2005-04-26 Roy-G-Biv Corporation Event driven motion systems
US20100131078A1 (en) * 1999-10-27 2010-05-27 Brown David W Event driven motion systems
US8032605B2 (en) 1999-10-27 2011-10-04 Roy-G-Biv Corporation Generation and distribution of motion commands over a distributed network
CA2288614C (en) 1999-11-08 2004-05-11 Robert J. Blainey Loop allocation for optimizing compilers
US6725218B1 (en) 2000-04-28 2004-04-20 Cisco Technology, Inc. Computerized database system and method
JP3651774B2 (ja) * 2000-09-12 2005-05-25 インターナショナル・ビジネス・マシーンズ・コーポレーション コンパイラ及びそのレジスタ割付方法
US6883165B1 (en) 2000-09-28 2005-04-19 International Business Machines Corporation Apparatus and method for avoiding deadlocks in a multithreaded environment
US6912647B1 (en) 2000-09-28 2005-06-28 International Business Machines Corportion Apparatus and method for creating instruction bundles in an explicitly parallel architecture
US6779106B1 (en) 2000-09-28 2004-08-17 International Business Machines Corporation Apparatus and method for an enhanced integer divide in an IA64 architecture
US6799262B1 (en) 2000-09-28 2004-09-28 International Business Machines Corporation Apparatus and method for creating instruction groups for explicity parallel architectures
US6886094B1 (en) 2000-09-28 2005-04-26 International Business Machines Corporation Apparatus and method for detecting and handling exceptions
US7031798B2 (en) 2001-02-09 2006-04-18 Roy-G-Biv Corporation Event management systems and methods for the distribution of motion control commands
US7904194B2 (en) 2001-02-09 2011-03-08 Roy-G-Biv Corporation Event management systems and methods for motion control systems
US7013460B2 (en) * 2001-05-15 2006-03-14 Hewlett-Packard Development Company, L.P. Specifying an invariant property (range of addresses) in the annotation in source code of the computer program
US20030079210A1 (en) * 2001-10-19 2003-04-24 Peter Markstein Integrated register allocator in a compiler
US7263694B2 (en) * 2001-10-26 2007-08-28 International Business Machines Corporation Directed non-cyclic graph walking system for data processing and analysis in software application
US20030237080A1 (en) * 2002-06-19 2003-12-25 Carol Thompson System and method for improved register allocation in an optimizing compiler
US7069548B2 (en) * 2002-06-28 2006-06-27 Intel Corporation Inter-procedure global register allocation method
US20040025151A1 (en) * 2002-07-31 2004-02-05 Shan-Chyun Ku Method for improving instruction selection efficiency in a DSP/RISC compiler
US7111287B2 (en) * 2003-01-10 2006-09-19 International Business Machines Corporation Global processor resource assignment in an assembler
US7207032B1 (en) * 2003-03-28 2007-04-17 Applied Micro Circuits Corporation Expanding a software program by insertion of statements
US7185329B1 (en) 2003-03-28 2007-02-27 Applied Micro Circuits Corporation Use of different color sequences for variables of different sizes and different semantics
US20060064503A1 (en) 2003-09-25 2006-03-23 Brown David W Data routing systems and methods
US8027349B2 (en) * 2003-09-25 2011-09-27 Roy-G-Biv Corporation Database event driven motion systems
US20100131077A1 (en) * 2004-02-25 2010-05-27 Brown David W Data Collection Systems and Methods for Motion Control
US7469404B2 (en) * 2004-06-30 2008-12-23 Intel Corporation Bank assignment for partitioned register banks
KR100597414B1 (ko) * 2004-10-21 2006-07-05 삼성전자주식회사 데이터 처리 장치 및 이를 이용한 레지스터 할당 방법
US20060200811A1 (en) * 2005-03-07 2006-09-07 Cheng Stephen M Method of generating optimised stack code
US7797692B1 (en) * 2006-05-12 2010-09-14 Google Inc. Estimating a dominant resource used by a computer program
US8237726B2 (en) * 2009-06-26 2012-08-07 Intel Corporation Register allocation for message sends in graphics processing pipelines
US8933954B2 (en) 2011-03-23 2015-01-13 Qualcomm Incorporated Register allocation for graphics processing
US9619214B2 (en) 2014-08-13 2017-04-11 International Business Machines Corporation Compiler optimizations for vector instructions
US10169014B2 (en) 2014-12-19 2019-01-01 International Business Machines Corporation Compiler method for generating instructions for vector operations in a multi-endian instruction set
US9588746B2 (en) 2014-12-19 2017-03-07 International Business Machines Corporation Compiler method for generating instructions for vector operations on a multi-endian processor
US9569190B1 (en) 2015-08-04 2017-02-14 International Business Machines Corporation Compiling source code to reduce run-time execution of vector element reverse operations
US9880821B2 (en) 2015-08-17 2018-01-30 International Business Machines Corporation Compiler optimizations for vector operations that are reformatting-resistant

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE1250659B (de) * 1964-04-06 1967-09-21 International Business Machines Corporation, Armonk, NY (V St A) Mikroprogrammgesteuerte Datenverarbeitungsanlage
US3921153A (en) * 1973-08-02 1975-11-18 Ibm System and method for evaluating paging behavior
US4493020A (en) * 1980-05-06 1985-01-08 Burroughs Corporation Microprogrammed digital data processor employing microinstruction tasking and dynamic register allocation
US4378590A (en) * 1980-09-03 1983-03-29 Burroughs Corporation Register allocation apparatus
US4435753A (en) * 1980-10-31 1984-03-06 International Business Machines Corporation Register allocation system using recursive queuing during source code compilation
US4571678A (en) * 1982-11-05 1986-02-18 International Business Machines Corporation Register allocation and spilling via graph coloring
US4567574A (en) * 1983-03-14 1986-01-28 International Business Machines Corporation Optimizing cobol object code instruction path length with respect to perform statements
JPS6140643A (ja) * 1984-07-31 1986-02-26 Hitachi Ltd システムの資源割当て制御方式
US4656583A (en) * 1984-08-13 1987-04-07 International Business Machines Corporation Method for improving global common subexpression elimination and code motion in an optimizing compiler
US4667290A (en) * 1984-09-10 1987-05-19 501 Philon, Inc. Compilers using a universal intermediate language
US4656582A (en) * 1985-02-04 1987-04-07 International Business Machines Corporation Generating storage reference instructions in an optimizing compiler
US4722071A (en) * 1985-04-19 1988-01-26 Pertron Controls, Corporation Compiler for evaluating Boolean expressions

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100337202C (zh) * 2004-12-03 2007-09-12 中国科学院计算技术研究所 一种汇编代码热函数中的热路径搜寻方法
CN100414505C (zh) * 2005-07-08 2008-08-27 中国科学院计算技术研究所 一种基于组合并算法的偏移量分配优化方法
CN103399741A (zh) * 2013-07-24 2013-11-20 中国科学院声学研究所 一种汇编级静态路径剖析方法及装置
CN103399741B (zh) * 2013-07-24 2016-05-25 中国科学院声学研究所 一种汇编级静态路径剖析方法及装置
CN106610860A (zh) * 2015-10-26 2017-05-03 三星电子株式会社 半导体装置的操作方法和半导体系统

Also Published As

Publication number Publication date
US4782444A (en) 1988-11-01
BR8605865A (pt) 1987-08-25
ES2004348A6 (es) 1989-01-01
JPH0776927B2 (ja) 1995-08-16
EP0229245A3 (en) 1990-03-21
KR870006460A (ko) 1987-07-11
CN1003679B (zh) 1989-03-22
KR910009116B1 (ko) 1991-10-31
JPS62144247A (ja) 1987-06-27
EP0229245A2 (en) 1987-07-22
CA1264859A (en) 1990-01-23

Similar Documents

Publication Publication Date Title
CN86107764A (zh) 通过双色布石进行寄存器分配和指定
Adams et al. Learning to optimize halide with tree search and random programs
Ragan-Kelley et al. Halide: Decoupling algorithms from schedules for high-performance image processing
CN1186722C (zh) 用于使用寄存器分配器建立调用约定序言和收尾程序代码的方法和装置
Carpaneto et al. Exact solution of large-scale, asymmetric traveling salesman problems
Cloutier et al. The combination of scheduling, allocation, and mapping in a single algorithm
US5768594A (en) Methods and means for scheduling parallel processors
Leupers Instruction scheduling for clustered VLIW DSPs
JP3213765B2 (ja) パイプラインプロセッサ用のコストを基にするヒューリスティック命令スケジューリングを最適にする方法および装置
Cierniak et al. Compile-time scheduling algorithms for a heterogeneous network of workstations
Bäumker et al. Truly efficient parallel algorithms: c-optimal multisearch for an extension of the BSP model
CN102750150B (zh) 基于x86架构的稠密矩阵乘法汇编代码自动生成方法
US7509633B2 (en) System and method for grid-based distribution of Java project compilation
CN1191527C (zh) 生成稀疏干扰图的装置与方法
Wilson et al. An ILP-based approach to code generation
CN108062249A (zh) 基于大数据的云端数据分配调度方法
Philippsen Automatic data distribution for nearest neighbor networks
Singh et al. Compiler optimizations for Java aglets in distributed data intensive applications
Rokos et al. Using Linda to compute spatial autocorrelation in parallel
Brezany et al. Parallelization of irregular codes including out-of-core data and index arrays
ANDERSON et al. Learning to Optimize Halide with Tree Search and Random Programs
Hall et al. Interprocedural compilation of Fortran D
Nisar et al. Optimal code scheduling for multiple pipeline processors
Sundin et al. Parallelization of ABB’s Grid Search Method using MATLAB
Wang et al. CustomHalide–A new plugin of clang for loop optimization

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C13 Decision
GR02 Examined patent application
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CX01 Expiry of patent term