[LLVMdev] Is it Possible to Set a specified bit of a specified register?

Avinash Bole boleavinash at gmail.com
Tue Apr 7 02:39:51 PDT 2015


Hi !!

Im writing a Backend for a 'C' Frontend.
I want to implement an instruction that can set a specified bit of a
Specified Register.

ex:

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:

1)  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

2) How to access the specified bit of a register ( R2's 9th bit in this
case)

3) 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

Thanks,
Avinash
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150407/2dbded76/attachment.html>


More information about the llvm-dev mailing list