From 8ad291e3205be50fce9a48f18399a022426faac1 Mon Sep 17 00:00:00 2001 From: dyoo Date: Wed, 2 Mar 2011 17:42:40 -0500 Subject: [PATCH] combining test and branch together formally. --- compile.rkt | 12 ++++++++---- il-structs.rkt | 27 ++++++++++++++------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/compile.rkt b/compile.rkt index 0e95d5a..2615e19 100644 --- a/compile.rkt +++ b/compile.rkt @@ -146,8 +146,10 @@ (append-instruction-sequences p-code (append-instruction-sequences (make-instruction-sequence - `(,(make-TestStatement 'false? 'val) - ,(make-BranchLabelStatement f-branch))) + `(,(make-TestAndBranchStatement 'false? + 'val + f-branch) + )) (append-instruction-sequences (append-instruction-sequences t-branch c-code) (append-instruction-sequences f-branch a-code)) @@ -293,8 +295,10 @@ (if (eq? linkage 'next) after-call linkage)]) (append-instruction-sequences - (make-instruction-sequence `(,(make-TestStatement 'primitive-procedure? 'proc) - ,(make-BranchLabelStatement primitive-branch))) + (make-instruction-sequence + `(,(make-TestAndBranchStatement 'primitive-procedure? + 'proc + primitive-branch))) compiled-branch (compile-proc-appl n target compiled-linkage) diff --git a/il-structs.rkt b/il-structs.rkt index 7e8be57..c5b00ed 100644 --- a/il-structs.rkt +++ b/il-structs.rkt @@ -47,10 +47,11 @@ (define-type UnlabeledStatement (U AssignImmediateStatement AssignPrimOpStatement - GotoStatement PerformStatement - TestStatement - BranchLabelStatement + + GotoStatement + TestAndBranchStatement + PopEnv PopControl PushEnv @@ -79,17 +80,16 @@ (define-struct: PushControlFrame ([label : Symbol]) #:transparent) - (define-struct: GotoStatement ([target : (U Label Reg)]) #:transparent) - (define-struct: PerformStatement ([op : PrimitiveCommand] - [rands : (Listof (U Label Reg Const))]) #:transparent) -(define-struct: TestStatement ([op : PrimitiveTest] - [register-rand : RegisterSymbol]) #:transparent) -(define-struct: BranchLabelStatement ([label : Symbol]) #:transparent) - + [rands : (Listof (U Label Reg Const))]) + #:transparent) +(define-struct: TestAndBranchStatement ([op : PrimitiveTest] + [register-rand : RegisterSymbol] + [label : Symbol]) + #:transparent) @@ -136,7 +136,8 @@ - +;; The following is used with TestStatement: each is passed the register-rand and +;; is expected to (define-type PrimitiveTest (U ;; register -> boolean @@ -149,8 +150,8 @@ 'primitive-procedure? )) -(define-type PrimitiveCommand (U - + +(define-type PrimitiveCommand (U ;; depth pos symbol ;; Assign the value in the val register into ;; the prefix installed at (depth, pos).