lang-party / Summer2022

Lang Party 2022
24 stars 1 forks source link

CPSC411 Langs - A collection of compiler intermediate languages to x86-64 #21

Open wilbowma opened 2 years ago

wilbowma commented 2 years ago

Entry

Where can we learn about your language? Feel free to post a variety of resources: source code, images, article / blog post, video, etc.

https://williamjbowman.com/#scheme2022-hashlang-x64

They are packaged as part of the CPSC 411 support software; you can install it via: raco pkg install https://github.com/cpsc411/cpsc411-pub.git?path=cpsc411-lib#hashlang-x64.

What is the purpose of your language? Give a short motivational pitch.

The language embeds a subset of x86-64, and all the features from a collection of intermediate languages from a Scheme-like language to x86-64, into Racket. This allows us to easily and robustly test correctness of the compiler at every intermediate pass, and interact with intermediate languages for pedagogical purposes.

Please list a few example programs (or links to examples) below.

#lang cpsc411/hashlangs/base

(begin
  (set! r15 5)
  (set! r14 1)
  (with-label fact
    (compare r15 0))
  (jump-if = end)
  (set! r14 (* r14 r15))
  (set! r15 (+ r15 -1))
  (jump fact)
  (with-label end
    (set! rax r14))
  (jump done))

The embedding can interact with Racket, if you understand the underlying semantics. Some of these are explained in the paper, but not all, as the primary purpose is specifying and testing the compiler rather than Racket interoperability.

#lang cpsc411/hashlangs/base

(require
 rackunit
 (only-in racket/base define))

(define (fact x)
  (boundary
   (begin
     (set! r15 x)
     (set! r14 1)
     (with-label fact
       (compare r15 0))
     (jump-if = end)
     (set! r14 (* r14 r15))
     (set! r15 (+ r15 -1))
     (jump fact)
     (with-label end
       (set! rax r14))
     (jump done))))

(check-equal? (fact 5) 120)

Licence

Please confirm that the text in this issue is licensed under the Creative Commons Attribution 4.0 International License http://creativecommons.org/licenses/by/4.0/

I licence this test under the Creative Commons Attribution 4.0 International License

PS Your language can use any license.

The language and support code is licensed under MIT License. https://github.com/cpsc411/cpsc411-pub/blob/main/LICENSE

Contact

To receive prizes and/or provide feedback please complete the form at https://forms.gle/wsFwLPWBzqrkpToU8

Thank you for your submission!