>Rather than sending me a patch, I'd like to know what Andy Wingo's plans
were for accessing variables. I imagine he >was thinking of something like
this too, so the best thing would be to get that patch merged into the
regular wip-rtl branch.

Yea that's of cause best, but for now we can just lurk around the code and
learn it so that at worst we can help with bugfixing and at best give
design feedback for the continuation of the rtl hackaton.

Next on my list is to see how we can add metadata to the procedures in
order to get better help when looking at back-traces which will be needed
in order to pinpoint problems when starting to compile larger code bases to
test out
any future compiler. In this effort I will make sure that I can get use ,x
seamlessly and get back the assembler which
also will be crucial when we want to pinpoint problems in the compiler and
or rtl VM.

Regards
Stefan


On Wed, Nov 28, 2012 at 8:31 PM, Noah Lavine <noah.b.lav...@gmail.com>wrote:

> I would definitely like to see something like that appear in the RTL
> branch. Otherwise it might be very difficult to write RTL code.
>
> Rather than sending me a patch, I'd like to know what Andy Wingo's plans
> were for accessing variables. I imagine he was thinking of something like
> this too, so the best thing would be to get that patch merged into the
> regular wip-rtl branch.
>
> Noah
>
>
>
> On Wed, Nov 28, 2012 at 2:13 PM, Stefan Israelsson Tampe <
> stefan.ita...@gmail.com> wrote:
>
>> Hi Noah,
>>
>> I have a fix to rtl.scm that add an instruction macro like this
>>
>> (toplevel dst sym)
>>
>> e.g.
>>
>> (toplevel 0 pk)
>>
>> to refere to pk in the current module I can send you a patch if you like,
>> it's very instructing for learning how to
>> program the rtl machine to your needs. And it also allows you to write
>> rtl assembler refering to toplevels in a nice way
>>
>> /Stefan
>>
>>
>>
>> On Sun, Oct 14, 2012 at 10:57 PM, Stefan Israelsson Tampe <
>> stefan.ita...@gmail.com> wrote:
>>
>>>
>>>
>>> On Sun, Oct 14, 2012 at 9:59 PM, Noah Lavine <noah.b.lav...@gmail.com>wrote:
>>>
>>>> Hello,
>>>>
>>>> I have been working on understanding RTL, and I wrote the following
>>>> tests. They're mostly to illustrate for myself how calling works in
>>>> RTL, but they also serve to test it. Any objections if I commit them
>>>> as part of rtl.test?
>>>>
>>>> (with-test-prefix "call"
>>>>   (assert-equal 42
>>>>                 (let ((call ;; (lambda (x) (x))
>>>>                        (assemble-program
>>>>                         '((begin-program call)
>>>>                           (assert-nargs-ee/locals 1 0)
>>>>                           (call 1 0 ())
>>>>                           (return 1) ;; MVRA from call
>>>>                           (return 1))))) ;; RA from call
>>>>                   (call (lambda () 42))))
>>>>
>>>>   (assert-equal 6
>>>>                 (let ((call-with-3 ;; (lambda (x) (x 3))
>>>>                        (assemble-program
>>>>                         '((begin-program call-with-3)
>>>>                           (assert-nargs-ee/locals 1 1)
>>>>                           (load-constant 1 3)
>>>>                           (call 2 0 (1))
>>>>                           (return 2) ;; MVRA from call
>>>>                           (return 2))))) ;; RA from call
>>>>                   (call-with-3 (lambda (x) (* x 2))))))
>>>>
>>>> (with-test-prefix "tail-call"
>>>>   (assert-equal 3
>>>>                 (let ((call ;; (lambda (x) (x))
>>>>                        (assemble-program
>>>>                         '((begin-program call)
>>>>                           (assert-nargs-ee/locals 1 0)
>>>>                           (tail-call 0 0)))))
>>>>                   (call (lambda () 3))))
>>>>
>>>>   (assert-equal 6
>>>>                 (let ((call-with-3 ;; (lambda (x) (x 3))
>>>>                        (assemble-program
>>>>                         '((begin-program call-with-3)
>>>>                           (assert-nargs-ee/locals 1 1)
>>>>                           (mov 1 0) ;; R1 <- R0
>>>>                           (load-constant 0 3) ;; R0 <- 3
>>>>                           (tail-call 1 1)))))
>>>>                   (call-with-3 (lambda (x) (* x 2))))))
>>>>
>>>>
>>> This look good to me
>>>
>>> My next goal is to learn to reference top-level variables. Could
>>>> anyone tell me how that works, to make it easier?
>>>>
>>>
>>> The general way, use a symbol in loc a and a module in loc b and then
>>> issue
>>> (resolve c b a)
>>> (box-ref c c)
>>>
>>> To put the symbol into c. The simplest way to check this is to pass b
>>> and a as arguments
>>> to the funciton, you may set the toplevel by using box-set!
>>>
>>> For reference inside functions you may use
>>> (toplevel-ref dst var_label mod_label sym_label)
>>>
>>> This is a bit complicated and I havenot found that all the
>>> infrastructure is in place to handle this
>>> but basically one should need to prepare the code like this if I'm not
>>> missing anything
>>>
>>> (program f)
>>> (toplevel-ref 1 var mod sym)
>>> ...
>>> (label var)
>>> (store-slot SCM_BOOL_F)
>>> (label mod)
>>> (store-slot module)
>>> (label sym)
>>> (stire-slot 'symbol)
>>> --------------------------------
>>>
>>> where the stire-slot mechanism is not yet supported but should mean that
>>> aligned to SCM it stores
>>> the needed references.
>>>
>>> This is what I guess it all means, correct me if i'm wrong!
>>>
>>> /Stefan
>>>
>>>
>>>
>>>
>>>
>>>
>>
>

Reply via email to