I was trying to look through the SymbolTable code for LLVM. What does the SymbolTable for a Module contain? Is it just GlobalVariables and Functions? How are program constants and static variables declared within functions handled? When I said program constants, I meant things like strings (e.g., char* foo = "Hello world\n";). Thanks in advance.
Sincerely,
Brian
Brian M. Fahs
Graduate Student
University of Illinois
I was trying to look through the SymbolTable code for LLVM. What does
the SymbolTable for a Module contain? Is it just GlobalVariables and
Functions?
The Module-level symbol table contains types, global variables and
functions.
How are program constants and static variables declared within functions
handled? When I said program constants, I meant things like strings
(e.g., char* foo = "Hello world\n";).
You can try it out on the demo page:
http://llvm.cs.uiuc.edu/demo/
... but the answer to your question is that the C front-end transforms
them into global variables. Thus, the constant string "Hello world\n"
turns into the LLVM global:
%.str_1 = internal constant [13 x sbyte] c"Hello world\0A\00"
File static variables are handled similarly,
-Chris
Brian,
Global symbols including new named types are named in the global symbol table. In addition each function contains a local symbol table naming local items, including temporary variables.
I'm busy documenting all this, but I'm also busy writing a code generator for my architecture, so haven't gotten enough through everything to completely document the bytecode language. Symbol tables in LLVM are easy though.
Hope this answers your question.
-- Robert.
Global symbols including new named types are named in the global symbol
table. In addition each function contains a local symbol table naming
local items, including temporary variables.
To further the confusion on this issue, I am planning on making a change
to the LLVM classes (not the bytecode or asm files) w.r.t types and the
symbol table. Basically, the symbol table class needs to be cleaned up a
bit, and will end up storing types in a separate map from the global
variables and functions (which will still be a part of the SymbolTable
class though).
The end goal of this is to make the Type class not derive from Value: you
can't use Types in any context where a value makes sense anyway. For more
information on other planned cleanups, see:
http://llvm.cs.uiuc.edu/PR122
Again, this will not affect the .ll or .bc file formats, only code which
grovels through the symbol table looking for types. Also note that this
might not happen for another couple of weeks...
-Chris