Microsoft Developer Network >
Página Inicial dos Fóruns
>
Phoenix
>
Copying an instruction with all its operands.
Copying an instruction with all its operands.
- Hi,
Can somebody please tell me how to copy all the operands of an instruction. e.g. if the instruction is something like: t282 = ADD [t280]*, [t281]*,
then this has [t280]*, [t281]*, t280 and t281 as source operands in order. Now suppose I want to copy this instruction as it is, then what I do is, I can do an instruction.Copy(), and then iterate over all the operands, but then rather than getting two source operands copied, 4 source operands get copied. Can someone please tell me what to do in such a situation.
Edit: Can someone please tell me how can I enumerate the operands [t280]*, [t281]*, a and b, and exclude the one's like [t280] and [t281] in an instruction like Call* myFunc [t280]*, [t281]*, a, b
Thanks
if if
Respostas
- The extra source operands are known as AddressMode operands. You can identify them by checking operand.IsAddressModeOperand.
AddressMode operands describe the components of a memory address. They are linked to a memory operand, either on the source or destination side of the instruction. Each memory operand can have three linked address mode operands -- one for base, one for index, and one for segment. In this case, [t280] is a memory operand with t280 as its base address mode operand.
For instance, the c construct *p += 1 might compile into something like:
[p] = ADD [p], 1, p, p, L5(EH)
Here the two [p]s are memory operands, and the 1 is an immediate. These are so-called explicit operands because they directly represent the values being manipulated by the ADD. The two p's on the source represent the reads of the variable p. These are implicit operands and also address mode operands. The L5 is a an implicit label operand indicating where control logically goes if the memory dereference causes and exception (eg p is null).
Address mode operands are and important part of your instruction. Since an oeprand can only be referenced by one instruction, when you copy the instruction you must copy the operands. It is probably easier if you do this as part of copying the memory operand (node that MemoryOperand::Copy will implicitly copy the address mode operands).
After alias analysis you may also see implicit alias opearnds telling us where [p] is located:
{&p}, [p] = ADD [p], 1, p, p, {&p}, L5(EH)
Thsi is all a part of making the instruction's behavior be totally described by operands. So you need to be prepared for extra implicit operands hanging around and copy them as well.
Architect - Microsoft Phoenix Project- Marcado como Respostaif if quinta-feira, 28 de maio de 2009 3:39
Todas as Respostas
- The extra source operands are known as AddressMode operands. You can identify them by checking operand.IsAddressModeOperand.
AddressMode operands describe the components of a memory address. They are linked to a memory operand, either on the source or destination side of the instruction. Each memory operand can have three linked address mode operands -- one for base, one for index, and one for segment. In this case, [t280] is a memory operand with t280 as its base address mode operand.
For instance, the c construct *p += 1 might compile into something like:
[p] = ADD [p], 1, p, p, L5(EH)
Here the two [p]s are memory operands, and the 1 is an immediate. These are so-called explicit operands because they directly represent the values being manipulated by the ADD. The two p's on the source represent the reads of the variable p. These are implicit operands and also address mode operands. The L5 is a an implicit label operand indicating where control logically goes if the memory dereference causes and exception (eg p is null).
Address mode operands are and important part of your instruction. Since an oeprand can only be referenced by one instruction, when you copy the instruction you must copy the operands. It is probably easier if you do this as part of copying the memory operand (node that MemoryOperand::Copy will implicitly copy the address mode operands).
After alias analysis you may also see implicit alias opearnds telling us where [p] is located:
{&p}, [p] = ADD [p], 1, p, p, {&p}, L5(EH)
Thsi is all a part of making the instruction's behavior be totally described by operands. So you need to be prepared for extra implicit operands hanging around and copy them as well.
Architect - Microsoft Phoenix Project- Marcado como Respostaif if quinta-feira, 28 de maio de 2009 3:39

