Everything is a Register!
sig
siguctua at gmail.com
Tue May 8 00:13:27 UTC 2007
well, IRBuilder can be used too :)
Suppose you wrote a class, which methods is solely in asm.
Then, adding something like this in your class will do funny trick:
MyClass class>>new
| gen |
self isAlreadyWrapped ifTrue: [ ^ self basicNew ].
gen := AsmGenerator new createAssemblyFor: self. " compile
instance methods and prepare them for use"
gen GenerateWrappersFor: self
^ self basicNew
---
A GenerateWrappersFor must do the following: generate a CompiledMethod
for each method in class which actually wraps call to assembler
function, and replace a method in MyClass methods dictionary.
As result you get an easy and transparent form for calling your asm code.
instance := MyClass new. "create an instance, and have fun"
instance myAsmRoutine1: 5 with: 10 ... "call an assemler method via wrapper "
On 07/05/07, J J <azreal1977 at hotmail.com> wrote:
> >From: Mathieu Suen <mathk.sue at gmail.com>
> >Reply-To: The general-purpose Squeak developers
> >list<squeak-dev at lists.squeakfoundation.org>
> >To: The general-purpose Squeak developers
> >list<squeak-dev at lists.squeakfoundation.org>
> >Subject: Re: Everything is a Register!
> >Date: Mon, 7 May 2007 15:08:49 +0200
> >
> >You can take a look at the NewCompiler you can write somthings like:
> >
> > | iRMethod aCompiledMethod |
> > iRMethod := IRBuilder new
> > numRargs: 1;
> > addTemps: #(self); "receiver and args declarations"
> > pushLiteral: $e;
> > returnTop;
> > ir.
> >
> > aCompiledMethod := iRMethod compiledMethod.
> > aCompiledMethod valueWithReceiver: nil arguments: #()
> >
> > Mth
>
> But this is talking to the Smalltalk VM, which is a stack machine. He is
> trying to write directly to the host CPU, which is more register oriented.
>
> _________________________________________________________________
> Download Messenger. Join the i'm Initiative. Help make a difference today.
> http://im.live.com/messenger/im/home/?source=TAGHM_APR07
>
>
>
More information about the Squeak-dev
mailing list
|