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
On Mon, 17 Nov 2003, Brian Fahs wrote:> 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 -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/
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. At 06:04 PM 11/17/2003 -0600, Brian Fahs wrote:>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 > >_______________________________________________ >LLVM Developers mailing list >LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >http://mail.cs.uiuc.edu/mailman/listinfo/llvmdevRobert Mykland Voice: (831) 462-6725
> 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 -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/
Possibly Parallel Threads
- [LLVMdev] Question about structure of SymbolTable
- [LLVMdev] Finding Things In SymbolTable
- Understanding LLD's SymbolTable's use of CachedHashStringRef
- [LLVMdev] ExecutionEngine/Interpreter/ExternalFunctions.cpp
- [LLVMdev] ExecutionEngine/Interpreter/ExternalFunctions.cpp