add more tests
This commit is contained in:
parent
3c41cf9876
commit
9c2895e4ed
|
|
@ -3,10 +3,16 @@
|
|||
(require (prefix-in bril: bril/lang))
|
||||
(require "aarch64var.rkt")
|
||||
|
||||
(define (bril-function-to-aarch64var function)
|
||||
(match function
|
||||
[(bril:Function name args ret-type instrs)
|
||||
(foldr append '()
|
||||
(map bril-instr-to-aarch64var instrs))]))
|
||||
|
||||
; only deals with int64 type!
|
||||
(define (bril-instr-to-aarch64var bril-instr)
|
||||
(match bril-instr
|
||||
[(bril:Label label) (Label label)]
|
||||
[(bril:Label label) (list (Label label))]
|
||||
[(bril:ConstantInstr dest-name _ (bril:Int const-val))
|
||||
(list (LMov (Imm const-val) (Var dest-name)))]
|
||||
[(bril:ValueInstr op dest type args _ _)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
(require (prefix-in bril: bril/lang))
|
||||
(require "../aarch64var.rkt")
|
||||
(require/expose "../select-instr.rkt" (bril-instr-to-aarch64var))
|
||||
(require/expose "../select-instr.rkt"
|
||||
(bril-instr-to-aarch64var bril-function-to-aarch64var))
|
||||
|
||||
(define bril-label (bril:Label "main"))
|
||||
(define bril-add
|
||||
|
|
@ -16,6 +17,10 @@
|
|||
(define bril-return
|
||||
(bril:EffectInstr 'return '("x") '() '()))
|
||||
|
||||
(define bril-func
|
||||
(bril:Function "main" '() (bril:Type 'int)
|
||||
(list bril-label bril-add bril-return)))
|
||||
|
||||
(define select-instr-tests
|
||||
(test-suite
|
||||
"Instruction Selection Tests"
|
||||
|
|
@ -24,7 +29,7 @@
|
|||
(test-case
|
||||
"Label"
|
||||
(check-equal? (bril-instr-to-aarch64var bril-label)
|
||||
(Label "main")))
|
||||
(list (Label "main"))))
|
||||
(test-case
|
||||
"Addition"
|
||||
(check-equal? (bril-instr-to-aarch64var bril-add)
|
||||
|
|
@ -37,4 +42,15 @@
|
|||
"Return"
|
||||
(check-equal? (bril-instr-to-aarch64var bril-return)
|
||||
(list (LMov (Reg 'x0) (Var "x"))
|
||||
(RetDefault)))))))
|
||||
(RetDefault)))))
|
||||
(test-suite
|
||||
"Function translation"
|
||||
(test-case
|
||||
"Simple function"
|
||||
(check-equal? (bril-function-to-aarch64var bril-func)
|
||||
(list (Label "main")
|
||||
(Add (Var "c") (Var "d") (Var "a"))
|
||||
(LMov (Reg 'x0) (Var "x"))
|
||||
(RetDefault)))))))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue