Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 395
    • Issues 395
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 22
    • Merge requests 22
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Wiki
  • Tutorials
  • adding a traversal

adding a traversal · Changes

Page history
Added text about how to get debug info for a compiler phase with the -#d flag... authored Feb 20, 2025 by Quinten Cabo's avatar Quinten Cabo
Added text about how to get debug info for a compiler phase with the -#d flag and fixed the long example
Hide whitespace changes
Inline Side-by-side
tutorials/adding-a-traversal.md
View page @ 3df404cc
......@@ -35,6 +35,11 @@ You can break at a specific traversal or subphase using `-b phaseid:travid`
These compiler phases are also numbered.
You can also break at a compiler phase using the number.
You can get debug messages for the entire compiler by using the `-#d` flag.
If you want to only get messages for a certain compiler phase you can specify the debug prefix of the messages you want to see `-#d,EX` for a traversal with `#define DBUG_PREFIX "EX"`.
This will hopefully be more clear in the next section when you actually see the code of a traversal.
# Step 0: Consider at which point your traversal should be added
Look at the already existing traversals.
......@@ -220,7 +225,7 @@ Because this is the minimum amount of code just to test if you did everything co
To make this template your own you need to fix to include the correct header instead of `example_traversal.h` and replace the ``EX` traversal id with your traversal id: `:%s/EX/FOO`.
Make sure the functions match up with the functions match up with the functions in the header file.
Once this works you can copy the actual template below:
Once this works you can copy the template below:
There is also a template for your traversal `.c` file, here it is:
```c
......@@ -328,7 +333,7 @@ TEMPmodule (node *arg_node, info *arg_info)
{
DBUG_ENTER ();
FUNDEF_NEXT (arg_node) = TRAVopt(FUNDEF_NEXT (arg_node), arg_info);
MODULE_FUNS (arg_node) = TRAVopt (MODULE_FUNS (arg_node), arg_info);
DBUG_RETURN (arg_node);
}
......@@ -340,7 +345,9 @@ node *
TEMPfundef (node *arg_node, info *arg_info)
{
DBUG_ENTER ();
DBUG_PRINT("Traversing %s in TEMP\n", FUNDEF_NAME(arg_node));
// FUNDEF_BODY (arg_node) = TRAVopt(FUNDEF_BODY (arg_node), arg_info);
FUNDEF_NEXT (arg_node) = TRAVopt(FUNDEF_NEXT (arg_node), arg_info);
DBUG_RETURN (arg_node);
......
Clone repository
  • concepts
    • Deprecated Modules
    • Globals
    • Named Tuples
    • Overloading
    • Preprocessor
    • Primitive functions
    • Runetime Representations
    • input stdin
    • phm xt
    • ref counting methods
    • type famlies
    • type patterns
  • error messages
    • Anthropomorphic error essages
    • Colored error messages
    • Empty file error
View All Pages