Im writing a Backend for a ‘C’ Frontend.
I want to implement an instruction that can set a specified bit of a Specified Register.
Mov R1, 9 ; // 9 is the bit i want to change
Set R2,R1,1 ; // modify R2’s 9th bit to 1
Above example shows the expected output
I have following Questions:
how to tell compiler to use a specific register (R2 in this case) for a given instruction? i cant set it as reserved since i need it to be used in other instructions too. I cant use a “PreRegisterAllocationPass” since the register would be allocated and will become reusable later
How to access the specified bit of a register ( R2’s 9th bit in this case)
How do i write a ‘C’ Program for this instruction? i tried using the bitfields in a structure, but it was getting casted in the IR. So,I couldnt access using the structure.
Please Tell me some ways to solve above challenges