I have completed writing simple register mask calculator pass, an immutable pass that stores RegMasks and provides API to query them, and a target specific pass for X86 target which currently iterates through all MI in given MF and if a call instruction is found then it quires for RegMask to Immutable pass and prints which registers are clobbered and preserved as per actual register allocation for callee function.
So now I need to update RegMask for call instruction, so as per our previous discussion on IRC if we add a method to update RegMask, Do we have to do it in target specific way? Is it possible to have RegMask at fixed position in Operands array in MI? Also provide some more details on updating cached RegMask in various other class.
Add a method "setOperandMask()" in class MachineOperand, and then when you find a call you just walk all the operands till you find one which "isRegMask()" at which point you can update it.
>
> Hello Mentors,
>
> I have completed writing simple register mask calculator pass, an
immutable pass that stores RegMasks and provides API to query them, and a
target specific pass for X86 target which currently iterates through all MI
in given MF and if a call instruction is found then it quires for RegMask
to Immutable pass and prints which registers are clobbered and preserved as
per actual register allocation for callee function.
>
> So now I need to update RegMask for call instruction, so as per our
previous discussion on IRC if we add a method to update RegMask, Do we have
to do it in target specific way? Is it possible to have RegMask at fixed
position in Operands array in MI? Also provide some more details on
updating cached RegMask in various other class.
Add a method "setOperandMask()" in class MachineOperand, and then when you
find a call you just walk all the operands till you find one which
"isRegMask()" at which point you can update it.
>
> Hello Mentors,
>
> I have completed writing simple register mask calculator pass, an
immutable pass that stores RegMasks and provides API to query them, and a
target specific pass for X86 target which currently iterates through all MI
in given MF and if a call instruction is found then it quires for RegMask
to Immutable pass and prints which registers are clobbered and preserved as
per actual register allocation for callee function.
>
> So now I need to update RegMask for call instruction, so as per our
previous discussion on IRC if we add a method to update RegMask, Do we have
to do it in target specific way? Is it possible to have RegMask at fixed
position in Operands array in MI? Also provide some more details on
updating cached RegMask in various other class.
Add a method "setOperandMask()" in class MachineOperand, and then when
you find a call you just walk all the operands till you find one which
"isRegMask()" at which point you can update it.
Ok.
Is it ok to add "setRegMaskOperand()" in class MI and looping through
operands to find RegMask is also included in method ?
-Vivek
I expect your code to be the only user of such a function so I would not add it to MachineInstr but keep the code local in your pass for now (you can add a static helper function in the .cpp file of your pass).
>
> Hello Mentors,
>
> I have completed writing simple register mask calculator pass, an
immutable pass that stores RegMasks and provides API to query them, and a
target specific pass for X86 target which currently iterates through all MI
in given MF and if a call instruction is found then it quires for RegMask
to Immutable pass and prints which registers are clobbered and preserved as
per actual register allocation for callee function.
>
> So now I need to update RegMask for call instruction, so as per our
previous discussion on IRC if we add a method to update RegMask, Do we have
to do it in target specific way? Is it possible to have RegMask at fixed
position in Operands array in MI? Also provide some more details on
updating cached RegMask in various other class.
Add a method "setOperandMask()" in class MachineOperand, and then when
you find a call you just walk all the operands till you find one which
"isRegMask()" at which point you can update it.
Ok.
Is it ok to add "setRegMaskOperand()" in class MI and looping through
operands to find RegMask is also included in method ?
With this behavior I'd expect the method to be named updateRegMask...
Also, what is the semantic if there is no regmask?
Assertion "trying to update RegMask when not present" ?
Vivek
>
> Hello Mentors,
>
> I have completed writing simple register mask calculator pass, an
immutable pass that stores RegMasks and provides API to query them, and a
target specific pass for X86 target which currently iterates through all MI
in given MF and if a call instruction is found then it quires for RegMask
to Immutable pass and prints which registers are clobbered and preserved as
per actual register allocation for callee function.
>
> So now I need to update RegMask for call instruction, so as per our
previous discussion on IRC if we add a method to update RegMask, Do we have
to do it in target specific way? Is it possible to have RegMask at fixed
position in Operands array in MI? Also provide some more details on
updating cached RegMask in various other class.
Add a method "setOperandMask()" in class MachineOperand, and then when
you find a call you just walk all the operands till you find one which
"isRegMask()" at which point you can update it.
Ok.
Is it ok to add "setRegMaskOperand()" in class MI and looping through
operands to find RegMask is also included in method ?
-Vivek
I expect your code to be the only user of such a function so I would not
add it to MachineInstr but keep the code local in your pass for now (you
can add a static helper function in the .cpp file of your pass).
But Operands are private to MI so It should go into MI or some other
Not sure what you mean by private here, can’t you iterate the operands?
I’d expect you to iterate the operands till op->isRegMask() is true, then you just have to update the regmask inside the operand. I think I already pointed you this, what’s not working? Why are you trying to find a different solution?
>
> Hello Mentors,
>
> I have completed writing simple register mask calculator pass, an
immutable pass that stores RegMasks and provides API to query them, and a
target specific pass for X86 target which currently iterates through all MI
in given MF and if a call instruction is found then it quires for RegMask
to Immutable pass and prints which registers are clobbered and preserved as
per actual register allocation for callee function.
>
> So now I need to update RegMask for call instruction, so as per our
previous discussion on IRC if we add a method to update RegMask, Do we have
to do it in target specific way? Is it possible to have RegMask at fixed
position in Operands array in MI? Also provide some more details on
updating cached RegMask in various other class.
Add a method "setOperandMask()" in class MachineOperand, and then when
you find a call you just walk all the operands till you find one which
"isRegMask()" at which point you can update it.
Ok.
Is it ok to add "setRegMaskOperand()" in class MI and looping through
operands to find RegMask is also included in method ?
-Vivek
I expect your code to be the only user of such a function so I would not
add it to MachineInstr but keep the code local in your pass for now (you
can add a static helper function in the .cpp file of your pass).
But Operands are private to MI so It should go into MI or some other
tricks like Friend Function ?
Not sure what you mean by private here, can't you iterate the operands?
I'd expect you to iterate the operands till op->isRegMask() is true, then
you just have to update the regmask inside the operand. I think I already
pointed you this, what's not working? Why are you trying to find a
different solution?
I got the previous idea, I just did not see iterators and I just thought
to move iteration to find RegMask from user code to MI but now it is
clear. Sorry for that : (