[llvm-commits] TypeBuilder helper class

Jeffrey Yasskin jyasskin at google.com
Thu Apr 9 09:40:46 PDT 2009


Sorry for taking so long to reply and for replying to myself -- I
wasn't subscribed to llvm-commits when you replied.

Dan Gohman objected that an in-tree type builder should support
cross-compilation. This library _does_ support cross compilation as
long as you only use types like int32_t as template arguments, but I
can definitely see that one might want a way to constrain a use to
only allow cross-compilable types. That is, something like
CrossCompilableTypeBuilder<size_t> would fail to compile, but
HostTypeBuilder<size_t> would succeed (with better names).

I like Chris's suggestion to use sometype<64> as the TypeBuilder<>
argument when you want to be able to cross compile, but for my use,
it's also very useful to be able to say TypeBuilder<readbufferproc> (a
typedef defined in Python which involves a use of ssize_t).

I think I see how to define TypeBuilder<typename T, bool
restrict_to_cross_compilable_types> so that TypeBuilder<size_t, true>
fails to compile but TypeBuilder<sometype<64>, false> succeeds,
without duplicating code. Could you confirm that that's along the
lines of what you want implemented before I waste time implementing
it? Also, what's the right spelling for "sometype"? I'd vote for
llvm::types::i<N> or something similar.

Jeffrey

On Thu, Apr 2, 2009 at 11:37 AM, Jeffrey Yasskin <jyasskin at google.com> wrote:
> When declaring global variables and functions that are defined in the
> Python C libraries, I've found the attached class helpful.
> TypeBuilder<void(int*, size_t*)>::get() will return an LLVM Type*
> corresponding to that function type, which is otherwise quite verbose
> to build up. Let me know what you think.
>
> Jeffrey
>



More information about the llvm-commits mailing list