public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Code generation: How to define file-scope static variables?
@ 2022-11-28 21:28 Robert Dubner
  2022-11-28 23:01 ` David Malcolm
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Dubner @ 2022-11-28 21:28 UTC (permalink / raw)
  To: gcc; +Cc: 'Bob Dubner'

I am part of a team working on a COBOL front end for GCC.

By reverse engineering other front ends, I learned, some months ago, how
to create a function_decl GENERIC node that is the root of a GENERIC tree
describing an entire function.   

By calling the routine cgraph_node::finalize_function() with that
function_decl, the assembly language for that function is created, and all
is well.

But now I need to be able to create the equivalent of a file-scope static
variable in C.

This C program file:

//////////////////
static int dubner_at_work = 123454321;
int main(int argc, char **argv)
  {
  }
//////////////////

produces, in part, this assembly language:

###############
	.file	"ccc.c"
	.text
	.data
	.align 4
	.type	dubner_at_work, @object
	.size	dubner_at_work, 4
dubner_at_work:
	.long	123454321
	.text
	.globl	main
	.type	main, @function
	[...]
###############

In my own GENERIC generation code, I believe that I am creating a proper
translation_unit_decl that contains the block and the vars nodes for
specifying "dubner_at_work".

But I have been unable, after several days of looking, to figure out the
equivalent of "cgraph_node::finalize_function" for a
translation_unit_decl.  The resulting assembly language doesn't have a
definition for "dubner_at_work".

Can anybody describe how I can tell the downstream processing that I need
the translation_unit_decl to actually define storage?

Thanks very much,

Bob Dubner.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-30 17:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-28 21:28 Code generation: How to define file-scope static variables? Robert Dubner
2022-11-28 23:01 ` David Malcolm
2022-11-29  2:54   ` Robert Dubner
2022-11-30 17:10     ` Robert Dubner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).