[LLVMdev] How to differ from read and write operations for general stack objects

Qingan Li ww345ww at gmail.com
Sat Aug 6 02:42:05 PDT 2011


 The following is the code fragment after "# *** IR Dump Before
Prolog/Epilog Insertion & Frame Finalization ***:".
* MOV32mi <fi#2>, 1, %reg0, 0, %reg0, 0 *
* MOV32mr <fi#2>, 1, %reg0, 0, %reg0, %ECX<kill>*
* %EAX<def> = MOV32rm <fi#2>, 1, %reg0, 0, %reg0*
* MOV32mr %reg0, 1, %reg0, <ga:@one+4>, %reg0, %EAX<kill>*
* %EAX<def> = MOV32rm <fi#2>, 1, %reg0, 0, %reg0*
* ADJCALLSTACKDOWN32 8, %ESP<imp-def,dead>, %EFLAGS<imp-def,dead>,
%ESP<imp-use>*
* %ECX<def> = MOV32rr %ESP*
* MOV32mr %ECX, 1, %reg0, 4, %reg0, %EAX<kill>; mem:ST4[Stack+4]*
* MOV32mi %ECX<kill>, 1, %reg0, 0, %reg0, <ga:@.str>; mem:ST4[Stack]*
* CALLpcrel32 <ga:@printf>, %EAX<imp-def>, %ECX<imp-def,dead>,
%ESP<imp-use>, ...*
* ADJCALLSTACKUP32 8, 0, %ESP<imp-def,dead>, %EFLAGS<imp-def,dead>,
%ESP<imp-use>*
* MOV32mi <fi#1>, 1, %reg0, 0, %reg0, 0*
* %ECX<def> = MOV32rm <fi#1>, 1, %reg0, 0, %reg0*
* MOV32mr <fi#0>, 1, %reg0, 0, %reg0, %ECX<kill>*
* MOV32mr <fi#3>, 1, %reg0, 0, %reg0, %EAX<kill>; mem:ST4[FixedStack3]*

It seems the ways to identify read/write are different for virtual
registers, and stack objects.
For virtual registers, we could use the MachineOperand::isDef() and
MachineOperand::isUse.
For stack objects used for argument-passing (see mem:ST4[Stack] in the
example) or return-value (see mem:ST4[FixedStack3]), we could use the
MachineMemOperand::IsLoad() and MachineMemOperand::IsStore().
For general stack objects, like the first and second instructions in the
example, is there a way for me to identify whether fi#2 is read or written?
-- 
Best regards,

Li Qing-An
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110806/62f824a1/attachment.html>


More information about the llvm-dev mailing list