how to create an llvm Type
up vote
0
down vote
favorite
I'm trying to create a TruncInst
with an i8
destination type.
However, I can't seem to find an appropriate type constructor
when I look here. I expected it should be something simple like:
if (val->getType()->isIntegerTy(32))
TruncInst *ti = new TruncInst(val,new IntegerType(8));
But apparently it's not. I'm probably over looking something in the API.
Any help is very much appreciated, thanks!
types llvm llvm-ir bitcode
add a comment |
up vote
0
down vote
favorite
I'm trying to create a TruncInst
with an i8
destination type.
However, I can't seem to find an appropriate type constructor
when I look here. I expected it should be something simple like:
if (val->getType()->isIntegerTy(32))
TruncInst *ti = new TruncInst(val,new IntegerType(8));
But apparently it's not. I'm probably over looking something in the API.
Any help is very much appreciated, thanks!
types llvm llvm-ir bitcode
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to create a TruncInst
with an i8
destination type.
However, I can't seem to find an appropriate type constructor
when I look here. I expected it should be something simple like:
if (val->getType()->isIntegerTy(32))
TruncInst *ti = new TruncInst(val,new IntegerType(8));
But apparently it's not. I'm probably over looking something in the API.
Any help is very much appreciated, thanks!
types llvm llvm-ir bitcode
I'm trying to create a TruncInst
with an i8
destination type.
However, I can't seem to find an appropriate type constructor
when I look here. I expected it should be something simple like:
if (val->getType()->isIntegerTy(32))
TruncInst *ti = new TruncInst(val,new IntegerType(8));
But apparently it's not. I'm probably over looking something in the API.
Any help is very much appreciated, thanks!
types llvm llvm-ir bitcode
types llvm llvm-ir bitcode
asked Nov 11 at 7:21
OrenIshShalom
915722
915722
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Type::getInt8Ty(getContext());
will get a type for you, assuming that you have a way to get the relevant context.
You cannot create an IntegerType yourself because LLVM's design says that if two types t1 and t2 are the same (e.g. both are 8-bit integer types) and exist in the same context, then t1==t2
. Much LLVM code expects to test for equality using ==
.
Could you please also add how can one get an LLVM context? thanks ...
– OrenIshShalom
Nov 11 at 9:51
You probably created one in main(); you have to do that before you do almost any kind of work with LLVM. Or you can get one from e.g. Module::getContext(), which returns the one that was created early.
– arnt
Nov 11 at 10:17
The code is actually from a LoopPass run by opt. So I guess that the pass manager somehow must have created it right?
– OrenIshShalom
Nov 11 at 10:38
No, the pass manager receives its module and context as an argument to run(). The context is typically created first, then one or more modules, then other things such as a pass manager.
– arnt
Nov 11 at 11:39
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Type::getInt8Ty(getContext());
will get a type for you, assuming that you have a way to get the relevant context.
You cannot create an IntegerType yourself because LLVM's design says that if two types t1 and t2 are the same (e.g. both are 8-bit integer types) and exist in the same context, then t1==t2
. Much LLVM code expects to test for equality using ==
.
Could you please also add how can one get an LLVM context? thanks ...
– OrenIshShalom
Nov 11 at 9:51
You probably created one in main(); you have to do that before you do almost any kind of work with LLVM. Or you can get one from e.g. Module::getContext(), which returns the one that was created early.
– arnt
Nov 11 at 10:17
The code is actually from a LoopPass run by opt. So I guess that the pass manager somehow must have created it right?
– OrenIshShalom
Nov 11 at 10:38
No, the pass manager receives its module and context as an argument to run(). The context is typically created first, then one or more modules, then other things such as a pass manager.
– arnt
Nov 11 at 11:39
add a comment |
up vote
2
down vote
accepted
Type::getInt8Ty(getContext());
will get a type for you, assuming that you have a way to get the relevant context.
You cannot create an IntegerType yourself because LLVM's design says that if two types t1 and t2 are the same (e.g. both are 8-bit integer types) and exist in the same context, then t1==t2
. Much LLVM code expects to test for equality using ==
.
Could you please also add how can one get an LLVM context? thanks ...
– OrenIshShalom
Nov 11 at 9:51
You probably created one in main(); you have to do that before you do almost any kind of work with LLVM. Or you can get one from e.g. Module::getContext(), which returns the one that was created early.
– arnt
Nov 11 at 10:17
The code is actually from a LoopPass run by opt. So I guess that the pass manager somehow must have created it right?
– OrenIshShalom
Nov 11 at 10:38
No, the pass manager receives its module and context as an argument to run(). The context is typically created first, then one or more modules, then other things such as a pass manager.
– arnt
Nov 11 at 11:39
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Type::getInt8Ty(getContext());
will get a type for you, assuming that you have a way to get the relevant context.
You cannot create an IntegerType yourself because LLVM's design says that if two types t1 and t2 are the same (e.g. both are 8-bit integer types) and exist in the same context, then t1==t2
. Much LLVM code expects to test for equality using ==
.
Type::getInt8Ty(getContext());
will get a type for you, assuming that you have a way to get the relevant context.
You cannot create an IntegerType yourself because LLVM's design says that if two types t1 and t2 are the same (e.g. both are 8-bit integer types) and exist in the same context, then t1==t2
. Much LLVM code expects to test for equality using ==
.
answered Nov 11 at 9:17
arnt
4,87431728
4,87431728
Could you please also add how can one get an LLVM context? thanks ...
– OrenIshShalom
Nov 11 at 9:51
You probably created one in main(); you have to do that before you do almost any kind of work with LLVM. Or you can get one from e.g. Module::getContext(), which returns the one that was created early.
– arnt
Nov 11 at 10:17
The code is actually from a LoopPass run by opt. So I guess that the pass manager somehow must have created it right?
– OrenIshShalom
Nov 11 at 10:38
No, the pass manager receives its module and context as an argument to run(). The context is typically created first, then one or more modules, then other things such as a pass manager.
– arnt
Nov 11 at 11:39
add a comment |
Could you please also add how can one get an LLVM context? thanks ...
– OrenIshShalom
Nov 11 at 9:51
You probably created one in main(); you have to do that before you do almost any kind of work with LLVM. Or you can get one from e.g. Module::getContext(), which returns the one that was created early.
– arnt
Nov 11 at 10:17
The code is actually from a LoopPass run by opt. So I guess that the pass manager somehow must have created it right?
– OrenIshShalom
Nov 11 at 10:38
No, the pass manager receives its module and context as an argument to run(). The context is typically created first, then one or more modules, then other things such as a pass manager.
– arnt
Nov 11 at 11:39
Could you please also add how can one get an LLVM context? thanks ...
– OrenIshShalom
Nov 11 at 9:51
Could you please also add how can one get an LLVM context? thanks ...
– OrenIshShalom
Nov 11 at 9:51
You probably created one in main(); you have to do that before you do almost any kind of work with LLVM. Or you can get one from e.g. Module::getContext(), which returns the one that was created early.
– arnt
Nov 11 at 10:17
You probably created one in main(); you have to do that before you do almost any kind of work with LLVM. Or you can get one from e.g. Module::getContext(), which returns the one that was created early.
– arnt
Nov 11 at 10:17
The code is actually from a LoopPass run by opt. So I guess that the pass manager somehow must have created it right?
– OrenIshShalom
Nov 11 at 10:38
The code is actually from a LoopPass run by opt. So I guess that the pass manager somehow must have created it right?
– OrenIshShalom
Nov 11 at 10:38
No, the pass manager receives its module and context as an argument to run(). The context is typically created first, then one or more modules, then other things such as a pass manager.
– arnt
Nov 11 at 11:39
No, the pass manager receives its module and context as an argument to run(). The context is typically created first, then one or more modules, then other things such as a pass manager.
– arnt
Nov 11 at 11:39
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246665%2fhow-to-create-an-llvm-type%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown