Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions gazprea/impl/architecture.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.. _sec:architecture:

Architecture
============

You should write your compiler as a series of passes each with simple functionality. Do not implement your compiler as a single pass. As a minimum, your compiler should have individual passes that perform each of the following actions:

* Create an abstract syntax tree.
* Define symbols and ensure that symbols can be referenced in the locations they are used. These actions may be performed by two separate passes.
* Propagate type information through expressions and perform static type checking. These actions may be performed by two separate passes.
* Emit LLVM, SCF, Memref and Arith Dialects that can be lowered into LLVM IR.

Your compiler should use a symbol table to track symbol definitions and scopes.

These passes are also assessed against the architecture properties listed under Design in the :external+info:doc:`grading criteria <grading>`. All six properties apply to *Gazprea*.
1 change: 1 addition & 0 deletions gazprea/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Hardware Acceleration Laboratory in Markham, ON.
:maxdepth: 2
:caption: Implementation

impl/architecture
impl/backend
impl/part_1
impl/part_2
Expand Down
5 changes: 5 additions & 0 deletions info/_static/css/tables.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* The RTD theme sets white-space: nowrap on table cells, which forces wide
* tables horizontally scrollable. Tables marked .wrap-table wrap instead. */
.wrap-table td, .wrap-table th {
white-space: normal !important;
}
23 changes: 12 additions & 11 deletions info/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@
'sphinx.ext.intersphinx',
]

# Cross-reference the Gazprea glossary. The tuple's first element is the
# Cross-reference sibling projects. The tuple's first element is the
# canonical URL used to rewrite resolved refs; the second element is a list
# of inventory-source fallbacks. ``../gazprea/_build/html/objects.inv``
# resolves against this file's directory, so ``make all`` (which builds
# gazprea first per the top-level Makefile) always finds the inventory
# locally. If the local file is missing, intersphinx falls back to the
# published URL and the build still succeeds.
# of inventory-source fallbacks. Each ``../<project>/_build/html/objects.inv``
# resolves against this file's directory, so ``make all`` finds the inventory
# locally for any project the top-level Makefile builds earlier. If the local
# file is missing, intersphinx falls back to the published URL and the build
# still succeeds.
intersphinx_mapping = {
'gazprea': (
'https://cmput415.github.io/415-docs/gazprea',
('../gazprea/_build/html/objects.inv', None),
),
'gazprea': ('https://cmput415.github.io/415-docs/gazprea',
('../gazprea/_build/html/objects.inv', None)),
'vcalc': ('https://cmput415.github.io/415-docs/vcalc',
('../vcalc/_build/html/objects.inv', None)),
}

# Never let a bare :doc:`foo` silently resolve to a sibling project's page;
# force ``:external+gazprea:doc:`` when that is actually what is meant.
# force ``:external+<project>:doc:`` when that is actually what is meant.
intersphinx_disabled_reftypes = ['std:doc']

# Toggles the display of "Todo" message boxes in the output
Expand Down Expand Up @@ -102,6 +102,7 @@
# or fully qualified paths (eg. https://...)
html_css_files = [
'css/googleFonts.css',
'css/tables.css',
]

# Disable syntax highlighting in code blocks
Expand Down
44 changes: 43 additions & 1 deletion info/grading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,53 @@ product: scalability, flexibility, and maintainability.
You need to design an AST and Symbol table, and use them to implement
multiple passes including: symbol definitions, symbol resolutions and
semantic checking, type checking, and code generation.
The passes your compiler must have are listed under :external+vcalc:doc:`Architecture <impl/architecture>`.

* **Gazprea** While the top-level architecture is almost identical to
*VCalc*, the rich type system within can increase complexity
substantially unless it is managed. It is also important to understand
and select dialects that make sense for your design.
The passes your compiler must have are listed under :external+gazprea:doc:`Architecture <impl/architecture>`.


Architecture Properties
^^^^^^^^^^^^^^^^^^^^^^^

Part of the design mark is the following properties of your implementation, assessed by inspection of your code. Each is marked separately, and only on the projects marked below. None of them apply to *Generator*.

.. list-table::
:header-rows: 1
:widths: 76 8 8 8
:class: wrap-table

* - **Property**
- LOLCODE
- VCalc
- Gazprea
* - **Types are decided once.** Your emission pass must not compute or infer the type of an expression. It reads type information recorded by an earlier pass.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* - **Types are decided once.** Your emission pass must not compute or infer the type of an expression. It reads type information recorded by an earlier pass.
* - **Types are decided once.** Your emission pass must not compute or infer the type of an expression. It reads type information recorded by an earlier pass. To heck with dynamic languages!! (-Sir-NoChill)

😆

-
- ✓
- ✓
* - **One source of truth for conversions.** The rules deciding whether a conversion is legal and the code performing that conversion must not be two lists kept in agreement by hand. If they are separate, something in your build must check that they agree.
- ✓
- ✓
- ✓
* - **Pass dependencies are written down.** Each pass must state what it requires to already be true when it runs. If reordering two of your passes breaks your compiler, that dependency must appear somewhere a reader can find it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmmmmmmm phase ordering be like.

How do we enforce this?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we need this level of detail? Should this be something they write in their design document vs something we look for in the code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sir-NoChill my plan for each of these 6 points was to ask claude if they are fulfilled. The GenAI seminar I went through describes bias in LLM grading, but this does not apply to yes/no questions, so I think it is safe here.

-
- ✓
- ✓
* - **Element-wise operations share their emission.** Adding a new operator over vectors or matrices must not require writing new index arithmetic.
-
- ✓
- ✓
* - **Names are resolved once.** Your emission pass must not look a name up by string. Symbol resolution happens in an earlier pass, and later passes use the resolved symbol.
-
- ✓
- ✓
* - **Locations are recorded at construction.** Every node carries the source location it came from, assigned when the node is built.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mandate dwarf symbol emission behind a -g flag? Similar to -ffast-math ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is debug symbol emission automatic? When I did it before it was a lot of work because you have to describe the symbol to the debugger so it can interpret the contents correctly. I wouldn't mind having an assignment where they add debug to vcalc. Or maybe we could have a lab where they do what they can in 3 hours and we mark it?

-
-
- ✓

Software Engineering Processes
------------------------------
Expand Down Expand Up @@ -92,7 +134,7 @@ Code Style and Consistency
* You are expected to separate class definitions from implementations using header (.h) and source (.cpp)
files.
* Your code should be clean and readable.
* There is no minimum expectation for commenting or documentation.
* There is no minimum expectation for commenting or documentation, except where the design requirements require a design decision to be recorded.

TA Specification Tests
----------------------
Expand Down
22 changes: 11 additions & 11 deletions vcalc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@
'sphinx.ext.intersphinx',
]

# Cross-reference the Gazprea glossary. The tuple's first element is the
# Cross-reference sibling projects. The tuple's first element is the
# canonical URL used to rewrite resolved refs; the second element is a list
# of inventory-source fallbacks. ``../gazprea/_build/html/objects.inv``
# resolves against this file's directory, so ``make all`` (which builds
# gazprea first per the top-level Makefile) always finds the inventory
# locally. If the local file is missing, intersphinx falls back to the
# published URL and the build still succeeds.
# of inventory-source fallbacks. Each ``../<project>/_build/html/objects.inv``
# resolves against this file's directory, so ``make all`` finds the inventory
# locally for any project the top-level Makefile builds earlier. If the local
# file is missing, intersphinx falls back to the published URL and the build
# still succeeds.
intersphinx_mapping = {
'gazprea': (
'https://cmput415.github.io/415-docs/gazprea',
('../gazprea/_build/html/objects.inv', None),
),
'gazprea': ('https://cmput415.github.io/415-docs/gazprea',
('../gazprea/_build/html/objects.inv', None)),
'info': ('https://cmput415.github.io/415-docs/info',
('../info/_build/html/objects.inv', None)),
}

# Never let a bare :doc:`foo` silently resolve to a sibling project's page;
# force ``:external+gazprea:doc:`` when that is actually what is meant.
# force ``:external+<project>:doc:`` when that is actually what is meant.
intersphinx_disabled_reftypes = ['std:doc']

# Toggles the display of "Todo" message boxes in the output
Expand Down
13 changes: 13 additions & 0 deletions vcalc/impl/architecture.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. _sec:vcalc_architecture:

Architecture
============

You should write your compiler as a series of passes each with simple functionality. Do not implement your compiler as a single pass. As a minimum, your compiler should have individual passes that perform each of the following actions:

* Create an abstract syntax tree.
* Emit LLVM, SCF, Memref and Arith Dialects that can be lowered into LLVM IR.

These passes are also assessed against the architecture properties listed under Design in the :external+info:doc:`grading criteria <grading>`. Five of the six apply to *VCalc*.

Some VCalc designs do not carry over to Gazprea. Gazprea has multiple scalar types with promotion between them, nested tuple types, matrices and strings alongside vectors, assignable expressions other than plain identifiers, and routines callable before they are defined. A VCalc compiler can reasonably assume a single scalar type, a flat type tag, a one-dimensional vector representation, and one value per expression; none of these assumptions hold in Gazprea. Consider this when choosing how to represent types and values.
1 change: 1 addition & 0 deletions vcalc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ grammar works as expected.
:maxdepth: 2
:caption: Implementation

impl/architecture
impl/input
impl/output
impl/assertions
Expand Down
Loading