[PATCH] D49609: [isl] Typesafe user pointers
Tobias Grosser via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 25 00:25:34 PDT 2018
grosser added a comment.
Hi Philip.
we discussed this in private already. I think in general this is a good idea, but it would be nice to upstream this to the isl bindings generator:
I pushed a first patch that implements isl:🆔:alloc using std::any:
https://github.com/tobig/isl/commit/8ee4b80e920897b61daba0c290bbd142fa2a9d8e
It's a proof-of-concept, but shows how to add extensions to the C++ bindings generator.
Not super-cleaned up, but might be a start in case you want to hack on it.
One problem is that isl idscurrently do not compare equal if std::any is used:
$cat test.cpp
#include "isl/cpp.h"
#include "isl/id.h"
#include "assert.h"
int main() {
isl::ctx ctx = isl_ctx_alloc();
{
int I = 12;
isl::id id(ctx, "test", I);
I = *id.get_user<int>();
isl::id id_1(ctx, "test", &I);
isl::id id_2(ctx, "test", &I);
isl_id_dump(id_1.get());
isl_id_dump(id_2.get());
assert(id_1.get() == id_2.get());
printf("%d\n", I);
}
isl_ctx_free(ctx.get());
return 0;
$./a.out
test at 0x56188ecb4220
test at 0x56188ecb42a0
a.out: test.cpp:20: int main(): Assertion `id_1.get() == id_2.get()' failed.
Aborted (core dumped)
The C interface ensures that two id's that are generated with the same values become the same object.
The following discussion is also relevant:
https://github.com/PollyLabs/isl/issues/8
Best,
Tobias
Repository:
rPLO Polly
https://reviews.llvm.org/D49609
More information about the llvm-commits
mailing list