- 论坛徽章:
- 0
|
原帖由 albcamus 于 2009-2-19 15:40 发表
仔细看了一下, 果然是对应adc{w}指令的。 carry指的是把eflags寄存器里的CF标志也加上。
后面的不怎么清楚,猜测“rm“是可以为寄存器也可以为内存地址, 这就是目的operand。 而HI表示byte-addres ...
我不光x86,任何Arch都不熟,这里就猜想一下吧,一起讨论一下,共同学习学习。
(define_insn "addhi3_carry" ;addhi3_carry只是内部使用的一个名字,就是标识符,是可选的。
[(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r") ;RTL模板 匹配操作数0,非立即数,既可以是寄存器,也可以是内存,x86不load/store,寻址的确灵活了,包袱都给rtl了。
(plus:HI (plus:HI (match_operand:HI 3 "ix86_carry_flag_operator" "") ;匹配操作数3 操作flag寄存器
(match_operand:HI 1 "nonimmediate_operand" "%0,0")) ;匹配操作数1 非立即数,"%0,0"还不确定意思...........
(match_operand:HI 2 "general_operand" "ri,rm"))) ;匹配操作数2 寄存器,立即数、内存都可
(clobber (reg:CC FLAGS_REG))] ;这个就是你说的“carry指的是把eflags寄存器里的CF标志也加上”
"ix86_binary_operator_ok (PLUS, HImode, operands)" ;附加的predicate.......也是RTL变态的地方之一..........实话实说,不清楚..........
"adc{w}\t{%2, %0|%0, %2}" ;汇编指令的模板,我不认识这个指令...ft这个{%2, %0|%0, %2}"...怎么还有%0|%0啊..........
[(set_attr "type" "alu") ;这个rtl被归类到alu类别里面
(set_attr "pent_pair" "pu") ;实话实说,没见过,前面肯定有定义
(set_attr "mode" "HI")]) ;mode,这个rtx的操作数长度
结合指令来看一下 rtl 匹配模式的意思, ADC DST, SRC; (DST)←(SRC)+(DST)+CF
[(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r") ;操作数0 DST
(plus:HI (plus:HI (match_operand:HI 3 "ix86_carry_flag_operator" "") ;操作数3 CF
(match_operand:HI 1 "nonimmediate_operand" "%0,0")) ;操作数1 DST
(match_operand:HI 2 "general_operand" "ri,rm"))) ;操作数2 SRC
我也不是很清楚,按照rtl的语法猜的,不知正确与否,如果你清楚我...........的地方就解释一下吧,我们一起学习学习。
DJ大牛的mail我尝试翻译一下下
Let's say you have an opcode that adds two values, but if one is in a register and one is in memory then the register has to be listed first(perhaps because it's also the destination, for 2-op adds). You havetwo choices:
我们来看一下 相加 两个数 的 操作码 吧,如果一个操作数在寄存器里,另一个在内存里,那么寄存器操作数应该先写出来(也许是因为在2地址码中它即是源操作数又是目的操作数吧),你有两种方法实现:
1. Describe all permutations of register/memory vs memory/register plus all the other things you might be able to add (constants, etc).
描述所有 寄存器/内存 vs 内存/寄存器 和其他任何可以相加(立即数,比如)的排列
2. Describe one set and tell gcc that it doesn't matter which operand is which.
描述一个set告诉gcc这没关系,这个操作码就是这样的
The '%' constraint modifier tells gcc that it may swap the two operands if it wants to, without affecting the semantics of the insn. This is often used for 2-op add and multiply so that gcc has more flexibility about what the *output* register is (it can now match either input reg, not just the 1st input reg) but obviously you wouldn't use it with, say, subtraction.
%告诉gcc两个操作数可以互换而不影响操作,大致就是这个意思
Thus, it's mostly to help gcc do register allocation and optimization.
因此,这被用来进行寄存器分配的改进
Also, this is more likely to be found in the MD pattern files used to port gcc to your chip, than in inline assembly.
这句话没什么好说的... |
|