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]
Other format: [Raw text]

Defining special builtin functions for DFA/VLIW scheduling


Hi all,

I am writing a gcc port for an embedded VLIW processor. gcc is used
under the control of other software tools. One feature of the embedded
processor is support for channel communication operations:

  PUT r0,CHANNEL_NAME

These can currently be accessed by the programmer using a function:

  data = someValue;
  PutDataOntoDanielsChannel(data);

The channel function is defined by the high level tools, which prepends
the definition of the function to the programmer's original source code.
The function might be:

  static inline void PutDataOntoDanielsChannel (int data) {
    asm("PUT %0,DANIELS_CHANNEL" : : "r" (DATA));
  }

The problem is that this instruction cannot be VLIW'd with other
instructions, because it appears as inline assembly. Normally, builtin
functions can be used to allow special purpose machine instructions to
be generated, which in turn map to .md patterns, and allow DFA/VLIW
scheduling. However, the name of the channel isn't known to gcc until
the high-level control software invokes it, and prepends the channel
definition function. 

I have come up with one solution, but I am not sure that it is
particularly good, and would like to know if anyone has any better
ideas? The solution is to pass the names of the channels to gcc on the
command line:

  gcc -mchannel=DanielsChannel -mchannel=OtherChannel source.c

gcc can then build an internal table which maps the channel names to
integer id's. These integer id's can then be used to refer to the
channels using a builtin. For example, DanielsChannel might be id 0, and
OtherChannel might be id 1. The channel function  definition might then
become:

  static inline void PutDataOntoDanielsChannel (int data) {
    callBuiltinPutData(0, data); // id 0 refers to `DanielsChannel'
  }

This would then allow the builtin pattern to be VLIW'd, and when the
pattern is converted into assembly language, the integer constant would
be converted into the appropriate channel name in the assembly language
output.

Does this seem a good solution? 

It would be nice if I could remove the need to prepend any special code
definitions at all, and allow the -mchannel=Name on the command line to
dynamically build a function called `PutDataOntoName' for me. However,
the channels can be typed (e.g., a 32-bit channel could be an int, a
float, an array of 4 bytes, a 32-bit struct, etc.). The prepending of
source code easily allows this by using the types as appropriate:

  static inline void PutDataOntoDanielsChannel (struct
Complicated32BitStruct data) {
    callBuiltinPutData(0, data); // id 0 refers to `DanielsChannel'
  }

To remove the need for the prepending I would need to pass the type
infomation to gcc on the command line:

  gcc -mchannel="DanielsChannel,struct Complicated32BitStruct"

To build the builtin function dynamically would then require code to
lookup the struct type by its name. I am sure that this could get very
messy, so maybe I am better off with the simpler solution?

Many thanks.

Dan.

=============================================================================
Daniel Towner
picoChip Designs Ltd., Riverside Buildings, 108, Walcot Street, BATH,
BA1 5BG
dant@picochip.com
07786 702589


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