[LLVMdev] Memory Alignment, Heap allocation.
Tobias Nurmiranta
spyck at lysator.liu.se
Mon Jun 14 11:39:01 PDT 2004
Hi,
1.
A small question: How do I ensure memory alignment? I want all malloced
memory, globals and functions to be 4-byte aligned. Does llvm have any
".align" keyword?
I'm currently implementing a small scheme toy-compiler, and want to use
the lowest 2 bits for type tags. It's Currently 380 lines of
scheme-code[1], quite similar to the compiler in SICP[2], which I hope to
get self-applicable later on.
2.
Can I change the calling conventions / frame handling, so that call frames
are allocated on the heap instead of on the stack? Right now all my
compiled functions take an environment as an argument to lookup variables
in the scheme-function. It would perhaps be nicer if I could use the call
frames instead, but I can't since lambdas in it can escape when the
frame is popped of the stack, for example:
(lambda (x) (lambda (z) (+ x z))) ; the inner lambda is returned.
Regards, Tobias
[1] www.ida.liu.se/~tobnu/compile.ss
Can currently for example compile and run:
(compiler '((lambda (x y z)
(if (seteq (car (cdr (cons x (cons y 3)))) z)
(add 1 0)
(sub 2 1)))
1 2 2))
[2] Structure and Interpretation of Computer Programs, Abelson & Sussman.
More information about the llvm-dev
mailing list