[llvm-dev] StringRef Iterator Variable Display

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] StringRef Iterator Variable Display

Chris Lattner via llvm-dev
Hello,
I want to display the variable names in stringref iterator. But it is not displayed using following code.


for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) {
errs() << *sit << " ";
}

How to do this?
Please help..

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] StringRef Iterator Variable Display

Chris Lattner via llvm-dev
Does the code compile and execute? If so, I guess the strings in your
set are empty/zero-length.

On Tue, Apr 23, 2019 at 12:41 PM hameeza ahmed via llvm-dev
<[hidden email]> wrote:

>
> Hello,
> I want to display the variable names in stringref iterator. But it is not displayed using following code.
>
>
> for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) {
> errs() << *sit << " ";
> }
>
> How to do this?
> Please help..
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] StringRef Iterator Variable Display

Chris Lattner via llvm-dev
Oh, sorry, adding the mailing list back (since I don't know if/how to
get the numbers) - perhaps someone else can suggest how to do that.

I'd go and look at how the IR AsmPrinter does this, if I were trying
to figure it out.

On Tue, Apr 23, 2019 at 1:26 PM hameeza ahmed <[hidden email]> wrote:

>
> How to display these %num stored in stringref?
>
> On Wed, Apr 24, 2019 at 1:25 AM David Blaikie <[hidden email]> wrote:
>>
>> Ah, this is a function of where you're getting the names from, not
>> where/how you're printing them out.
>>
>> %num named values in LLVM IR aren actually nameless - the numbering is
>> only used for textual rendering, not as an actual name. These %num
>> values will return false from "hasName".
>>
>> On Tue, Apr 23, 2019 at 1:18 PM hameeza ahmed <[hidden email]> wrote:
>> >
>> > the code is compiled and executed.
>> > When the strings are name they are displayed...
>> > when strings are %number they are not dispalyed
>> >
>> > On Wed, Apr 24, 2019 at 1:15 AM David Blaikie <[hidden email]> wrote:
>> >>
>> >> Does the code compile and execute? If so, I guess the strings in your
>> >> set are empty/zero-length.
>> >>
>> >> On Tue, Apr 23, 2019 at 12:41 PM hameeza ahmed via llvm-dev
>> >> <[hidden email]> wrote:
>> >> >
>> >> > Hello,
>> >> > I want to display the variable names in stringref iterator. But it is not displayed using following code.
>> >> >
>> >> >
>> >> > for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) {
>> >> > errs() << *sit << " ";
>> >> > }
>> >> >
>> >> > How to do this?
>> >> > Please help..
>> >> > _______________________________________________
>> >> > LLVM Developers mailing list
>> >> > [hidden email]
>> >> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] StringRef Iterator Variable Display

Chris Lattner via llvm-dev
Assuming you have an `Instruction *` or a `Value *`, you probably want
`X->printAsOperand(errs(), /*PrintType=*/false)` or so.

David Blaikie via llvm-dev <[hidden email]> writes:

> Oh, sorry, adding the mailing list back (since I don't know if/how to
> get the numbers) - perhaps someone else can suggest how to do that.
>
> I'd go and look at how the IR AsmPrinter does this, if I were trying
> to figure it out.
>
> On Tue, Apr 23, 2019 at 1:26 PM hameeza ahmed <[hidden email]> wrote:
>>
>> How to display these %num stored in stringref?
>>
>> On Wed, Apr 24, 2019 at 1:25 AM David Blaikie <[hidden email]> wrote:
>>>
>>> Ah, this is a function of where you're getting the names from, not
>>> where/how you're printing them out.
>>>
>>> %num named values in LLVM IR aren actually nameless - the numbering is
>>> only used for textual rendering, not as an actual name. These %num
>>> values will return false from "hasName".
>>>
>>> On Tue, Apr 23, 2019 at 1:18 PM hameeza ahmed <[hidden email]> wrote:
>>> >
>>> > the code is compiled and executed.
>>> > When the strings are name they are displayed...
>>> > when strings are %number they are not dispalyed
>>> >
>>> > On Wed, Apr 24, 2019 at 1:15 AM David Blaikie <[hidden email]> wrote:
>>> >>
>>> >> Does the code compile and execute? If so, I guess the strings in your
>>> >> set are empty/zero-length.
>>> >>
>>> >> On Tue, Apr 23, 2019 at 12:41 PM hameeza ahmed via llvm-dev
>>> >> <[hidden email]> wrote:
>>> >> >
>>> >> > Hello,
>>> >> > I want to display the variable names in stringref
>>> >> > iterator. But it is not displayed using following code.
>>> >> >
>>> >> >
>>> >> > for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) {
>>> >> > errs() << *sit << " ";
>>> >> > }
>>> >> >
>>> >> > How to do this?
>>> >> > Please help..
>>> >> > _______________________________________________
>>> >> > LLVM Developers mailing list
>>> >> > [hidden email]
>>> >> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] StringRef Iterator Variable Display

Chris Lattner via llvm-dev
it is working fine for alphabetic labels....but numeric labels are not displayed by stringref.

what is the issue?
please help..

On Wed, Apr 24, 2019 at 2:27 AM hameeza ahmed <[hidden email]> wrote:
 for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) {
std::string spr;
 raw_string_ostream string_stream(spr);
sit->printAsOperand(string_stream, false);}

this is giving error of printasoperand not member of sit

On Wed, Apr 24, 2019 at 2:16 AM hameeza ahmed <[hidden email]> wrote:
Yes..agree I tried it...But this doesnot work with stringref..

On Wed, Apr 24, 2019 at 2:15 AM Justin Bogner <[hidden email]> wrote:
Assuming you have an `Instruction *` or a `Value *`, you probably want
`X->printAsOperand(errs(), /*PrintType=*/false)` or so.

David Blaikie via llvm-dev <[hidden email]> writes:
> Oh, sorry, adding the mailing list back (since I don't know if/how to
> get the numbers) - perhaps someone else can suggest how to do that.
>
> I'd go and look at how the IR AsmPrinter does this, if I were trying
> to figure it out.
>
> On Tue, Apr 23, 2019 at 1:26 PM hameeza ahmed <[hidden email]> wrote:
>>
>> How to display these %num stored in stringref?
>>
>> On Wed, Apr 24, 2019 at 1:25 AM David Blaikie <[hidden email]> wrote:
>>>
>>> Ah, this is a function of where you're getting the names from, not
>>> where/how you're printing them out.
>>>
>>> %num named values in LLVM IR aren actually nameless - the numbering is
>>> only used for textual rendering, not as an actual name. These %num
>>> values will return false from "hasName".
>>>
>>> On Tue, Apr 23, 2019 at 1:18 PM hameeza ahmed <[hidden email]> wrote:
>>> >
>>> > the code is compiled and executed.
>>> > When the strings are name they are displayed...
>>> > when strings are %number they are not dispalyed
>>> >
>>> > On Wed, Apr 24, 2019 at 1:15 AM David Blaikie <[hidden email]> wrote:
>>> >>
>>> >> Does the code compile and execute? If so, I guess the strings in your
>>> >> set are empty/zero-length.
>>> >>
>>> >> On Tue, Apr 23, 2019 at 12:41 PM hameeza ahmed via llvm-dev
>>> >> <[hidden email]> wrote:
>>> >> >
>>> >> > Hello,
>>> >> > I want to display the variable names in stringref
>>> >> > iterator. But it is not displayed using following code.
>>> >> >
>>> >> >
>>> >> > for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) {
>>> >> > errs() << *sit << " ";
>>> >> > }
>>> >> >
>>> >> > How to do this?
>>> >> > Please help..
>>> >> > _______________________________________________
>>> >> > LLVM Developers mailing list
>>> >> > [hidden email]
>>> >> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] StringRef Iterator Variable Display

Chris Lattner via llvm-dev
PrintAsOperand works on a Value object. You tried to call it on a StringRef. You need to change the set to use std::string instead of StringRef and call printAsOperand when you put data into the set.

On Wed, Apr 24, 2019 at 1:43 PM hameeza ahmed via llvm-dev <[hidden email]> wrote:
it is working fine for alphabetic labels....but numeric labels are not displayed by stringref.

what is the issue?
please help..

On Wed, Apr 24, 2019 at 2:27 AM hameeza ahmed <[hidden email]> wrote:
 for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) {
std::string spr;
 raw_string_ostream string_stream(spr);
sit->printAsOperand(string_stream, false);}

this is giving error of printasoperand not member of sit

On Wed, Apr 24, 2019 at 2:16 AM hameeza ahmed <[hidden email]> wrote:
Yes..agree I tried it...But this doesnot work with stringref..

On Wed, Apr 24, 2019 at 2:15 AM Justin Bogner <[hidden email]> wrote:
Assuming you have an `Instruction *` or a `Value *`, you probably want
`X->printAsOperand(errs(), /*PrintType=*/false)` or so.

David Blaikie via llvm-dev <[hidden email]> writes:
> Oh, sorry, adding the mailing list back (since I don't know if/how to
> get the numbers) - perhaps someone else can suggest how to do that.
>
> I'd go and look at how the IR AsmPrinter does this, if I were trying
> to figure it out.
>
> On Tue, Apr 23, 2019 at 1:26 PM hameeza ahmed <[hidden email]> wrote:
>>
>> How to display these %num stored in stringref?
>>
>> On Wed, Apr 24, 2019 at 1:25 AM David Blaikie <[hidden email]> wrote:
>>>
>>> Ah, this is a function of where you're getting the names from, not
>>> where/how you're printing them out.
>>>
>>> %num named values in LLVM IR aren actually nameless - the numbering is
>>> only used for textual rendering, not as an actual name. These %num
>>> values will return false from "hasName".
>>>
>>> On Tue, Apr 23, 2019 at 1:18 PM hameeza ahmed <[hidden email]> wrote:
>>> >
>>> > the code is compiled and executed.
>>> > When the strings are name they are displayed...
>>> > when strings are %number they are not dispalyed
>>> >
>>> > On Wed, Apr 24, 2019 at 1:15 AM David Blaikie <[hidden email]> wrote:
>>> >>
>>> >> Does the code compile and execute? If so, I guess the strings in your
>>> >> set are empty/zero-length.
>>> >>
>>> >> On Tue, Apr 23, 2019 at 12:41 PM hameeza ahmed via llvm-dev
>>> >> <[hidden email]> wrote:
>>> >> >
>>> >> > Hello,
>>> >> > I want to display the variable names in stringref
>>> >> > iterator. But it is not displayed using following code.
>>> >> >
>>> >> >
>>> >> > for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) {
>>> >> > errs() << *sit << " ";
>>> >> > }
>>> >> >
>>> >> > How to do this?
>>> >> > Please help..
>>> >> > _______________________________________________
>>> >> > LLVM Developers mailing list
>>> >> > [hidden email]
>>> >> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
--
~Craig

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev