[LLVMdev] Parametric polymorphism

DeLesley Hutchins delesley.spambox at googlemail.com
Wed Feb 18 15:36:27 PST 2009


> Why do you say that people who compile, e.g., functional languages
> would benefit from type variables in LLVM?
> I like the level the LLVM is at, and would prefer to deal with
> instantiating parametric polymorphism at a higher level.

I'm surprised you're happy with a non-polymorphic llvm.  Does
Cayenne target llvm?  Dependent types take polymorphism to new
heights -- but perhaps you feel that since llvm cannot hope to
match Cayenne, you might as well do everything yourself.  :-)

My reasons are:

First, if type variables are handled at the higher-level, then every functional
language will have its own implementation.  It will not be possible to
define and reuse optimization passes between languages, which is
one of the goals of llvm.

Second, polymorphism can be made more efficient if it has low-level
codegen support -- see my earlier offset code.

Third, any language which has polymorphism is faced with the task
of ``erasing'' it before it can hand the code to llvm.  Such erasure can be
done in different ways -- compare Java type erasure (use pointers,
instantiate nothing), with C++ (instantiate everything), with .Net
(instantiate some things).  (I don't know how Ocaml does it)  It is very
difficult to share code between languages if the erasure semantics differ
so widely.

  -DeLesley



More information about the llvm-dev mailing list