This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

passing information to back-end from source code?


I would like to be able to pass (one bit of processor state change)
information from source code to the machine-specific back-end of the
compiler.  The back-end needs to know about the state change because
it must generate different code depending on the current processor
state.  How can I do this?

My first thought was to use constraints on inline assembly to note
this (either a certain constraint to indicate toggling of the state
inside the processor, or one constraint to indicate setting the state
and another to indicate clearing it) .  However, I did not see any way
for the back-end to notice these constraints and make a note of it.
If I actually can match inline asm in the back-end, I'd be happy.

My second thought was to use a dummy register and write patterns to
match writes to that, like:
  (define_insn "*sing"
    [(set (reg:HI 33) (const_int 1))
     (unspec_volatile [(const_int 0)] 0)]
    ""
    "sing"
    [(set_attr "length" "0")])
  (define_insn "*dance"
    [(set (reg:HI 33) (const_int 0))
     (unspec_volatile [(const_int 0)] 1)]
    ""
    "dance"
    [(set_attr "length" "0")])
and then write to a C variable given that register number.  However,
the regmove pass is moving the constant 0 or 1 into another register
and then trying to assign to R33 from that register (and so it loses
the information I wanted to pass).  I cannot see why it does that (or
even which macros tell GCC that the sequence of loads/moves it
generates while not generating the obvious "move R33, 0") -- in
particular, R33 is in its own register class.

My third thought was to support an attribute on a variable decl that
would cause the backend to notice assignments to it, but that seems
like it would be even less likely to work that either of the first two
methods.

So, my questions are these: Are any of these feasible ways to pass the
state change information to the back-end?  If noticing the state
change by matching inline asm constraints is feasible, how should I go
about writing that?  If noticing writes to a particular register
should work, what did I do wrong?

-- Michael

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]