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]

Re: Generating complex ASM output


In message <Pine.GSO.4.33.0203131534340.9633-100000@tao>, "D. Towner" writes:
 > Hi all,
 > 
 > I have a number of instruction patterns whose operands are rather
 > complicated. Whilst it might be possible to generate operand codes to
 > output these operands in different ways, I am looking for a way which is
 > easier. Is it possible to:
 > 
 > 1) Output the assembly directly to the output file. For example:
 >      (define_insn "*patternName"
 >         [pattern matching]
 >         ""
 >  	"*{
 > 	  if (operand[0] == something) fprintf(asmFile,"foo");
 > 	  else fprintf(asmFile, "bar")}";
You might look at output_asm_insn instead of fprintf.

 > 2) Safely allocate a new string, write the operands into that string, and
 > return the string. I could use a static string, but will this be safe -
 > how long must the string retain its contents before being overwritten by
 > another pattern match and assembly generation?
The problem with allocating a new string is you don't have any hook
where you can delete the strong once you're done with it.  

Static strings are used from time to time, though I think it's
generally cleaner to use output_asm_insn for this kind of situation.

jeff




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