|
|
|
|
|
This wiki entry describes the sac2c project structure.
|
|
|
|
|
|
Below are the top level directories of the sac2c codebase.
|
|
|
The layout is mostly what you would expect for a c project.
|
|
|
Most of the directories speak for themselves.
|
|
|
|
|
|
```
|
|
|
├── ci
|
|
|
├── cmake - cmake
|
|
|
└── options.cmake - Configure options when compiling sac
|
|
|
├── debug_distmem
|
|
|
├── doc - some docs
|
|
|
├── ext
|
|
|
├── include - header files to include sac
|
|
|
├── scripts - sac2c version manager and distmem scripts
|
|
|
├── setup
|
|
|
├── src - the source code of sac
|
|
|
└── tests
|
|
|
```
|
|
|
|
|
|
The most important directory is `src` where the source code lives.
|
|
|
In the src directory there are currently 12 directories:
|
|
|
|
|
|
```
|
|
|
src
|
|
|
├── include
|
|
|
├── libsac
|
|
|
├── libsac2c
|
|
|
├── libsaccinterface
|
|
|
├── libsacphm
|
|
|
├── libsacphmc
|
|
|
├── libsacprelude
|
|
|
├── maketools
|
|
|
├── runtime
|
|
|
├── tests
|
|
|
├── tools
|
|
|
└── unittests
|
|
|
```
|
|
|
|
|
|
Every directory which name starts with `lib` is a library.
|
|
|
Each library provides a distinct set of functionalities.
|
|
|
|
|
|
- `libsac`: [...]
|
|
|
- `libsac2c`: The compiler phases
|
|
|
- `libsaccinterface`: [...]
|
|
|
- `libsacphm`: [...]
|
|
|
- `libsacphmc`: [...]
|
|
|
- `libsacprelude`: [...]
|
|
|
|
|
|
The other directories serve different purposes:
|
|
|
Tests, tools build system and header files that allow one to include these libraries.
|
|
|
|
|
|
The idea is that the libraries are included in other programs.
|
|
|
Like for instance a program that makes a CLI interface to sac2c.
|
|
|
Once you input a sac file through the sac2c CLI the program will actually compile the file using the libsac2c library.
|
|
|
This way the code with the features in the library stay separate from the code that interacts with the real world.
|
|
|
|
|
|
The most important library is the `sac2clib` since this holds the code for all the compiler steps.
|
|
|
However, all libraries have the same structure.
|
|
|
Each library has a flat structure with on the first level of the library only directories and **no files** besides a CMake file.
|
|
|
The directories are meant to group code files together that belong to the same phase or topic of the compiler.
|
|
|
Most names are quite self-explanatory, but I annotated some of the maybe less obvious ones
|
|
|
|
|
|
```
|
|
|
src/libsac2c/
|
|
|
├── arrayopt - array optimalizations
|
|
|
├── cinterface
|
|
|
├── codegen
|
|
|
├── concurrent
|
|
|
├── constants
|
|
|
├── constraints
|
|
|
├── cuda
|
|
|
├── cudahybrid
|
|
|
├── distmem
|
|
|
├── flatten
|
|
|
├── flexsub
|
|
|
├── funcpara
|
|
|
├── generics
|
|
|
├── global - Management, main functions, tools, global vars
|
|
|
├── memory
|
|
|
├── modules
|
|
|
├── multithread
|
|
|
├── mutc
|
|
|
├── nested
|
|
|
├── objects
|
|
|
├── platform
|
|
|
├── precompile - The step after the parsing
|
|
|
├── print - Printing the ast and data structures
|
|
|
├── profile
|
|
|
├── rtspec
|
|
|
├── scanparse - Scanner parser, first step
|
|
|
├── serialize
|
|
|
├── stdopt
|
|
|
├── support
|
|
|
├── tree - ast utility functions and macros
|
|
|
├── typecheck
|
|
|
├── types
|
|
|
├── visualize
|
|
|
├── wltransform
|
|
|
└── xml - The ast definition xml
|
|
|
└── CMakeLists.txt
|
|
|
```
|
|
|
|
|
|
Inside each directory there no further directories only code files.
|
|
|
You will find mostly `.c` and `.h` files.
|
|
|
Each `.c` file has a corresponding `.h` file of the same name.
|
|
|
You will also find some `.js`, `.html`, `.xml` and `xls`.
|
|
|
|
|
|
So to reiterate each library has 1 level of only directories which group related code files together and inside each directory there are only code files and no further directories.
|
|
|
|
|
|
Having this flat structure makes the project easy to navigate from the command line and easy to edit using vim.
|
|
|
|
|
|
For instance the print directory currently looks like this:
|
|
|
|
|
|
```
|
|
|
src/libsac2c/print
|
|
|
├── convert.c
|
|
|
├── convert.h
|
|
|
├── print.c
|
|
|
└── print.h
|
|
|
```
|
|
|
|
|
|
Each `.c` file has a corresponding `.h` file of the same name.
|
|
|
No further subdirectories.
|
|
|
|
|
|
Another important directory to be aware of is the [src/libsac2c/xml directory](ast.xml.md), but this is document in a separate wiki file. |
|
|
\ No newline at end of file |