How to associate extra comments to a MachineInstruction ?

Hi,

is there a convenient way to associate/add a comment to a MachineInstruction, so that
in the produced assembly file, the comment is added next to the instruction ?

Greetings,

Jeroen Dobbelaere

Should be spelled like this yes?

Asm->OutStreamer.AddComment("foo")
Asm->EmitFoo();

-eric

From: Eric Christopher
Subject: Re: [LLVMdev] How to associate extra comments to a
MachineInstruction ?

Should be spelled like this yes?

Asm->OutStreamer.AddComment("foo")
Asm->EmitFoo();

-eric

That should work at the moment that you are emitting the instructions.

But what would you do when you are manipulating a MachineBasicBlock and want to
annotate some instructions there ? (way before the assembler jumps in)
The annotation belongs to the instruction and other manipulations that are performed later (like reordering of instructions)
should keep the annotation (iff the instruction itself is kept).

Greetings,

Jeroen

From: Eric Christopher
Subject: Re: [LLVMdev] How to associate extra comments to a
MachineInstruction ?

Should be spelled like this yes?

Asm->OutStreamer.AddComment("foo")
Asm->EmitFoo();

-eric

That should work at the moment that you are emitting the instructions.

Yep.

But what would you do when you are manipulating a MachineBasicBlock and want to
annotate some instructions there ? (way before the assembler jumps in)
The annotation belongs to the instruction and other manipulations that are performed later (like reordering of instructions)
should keep the annotation (iff the instruction itself is kept).

Not really a way to do it so far. There's a set of specific comments
to put on, but...

-eric

From: Eric Christopher
Subject: Re: [LLVMdev] How to associate extra comments to a
MachineInstruction ?

Should be spelled like this yes?

Asm->OutStreamer.AddComment(“foo”)
Asm->EmitFoo();

-eric

That should work at the moment that you are emitting the instructions.

Yep.

But what would you do when you are manipulating a MachineBasicBlock and want to
annotate some instructions there ? (way before the assembler jumps in)
The annotation belongs to the instruction and other manipulations that are performed later (like reordering of instructions)
should keep the annotation (iff the instruction itself is kept).

Not really a way to do it so far. There’s a set of specific comments
to put on, but…

It would be nice, but there’s no existing mechanism.

I personally think it should be handled by adding an implicit operand to the machineinstr that holds a constant index into a table of annotations strings, or maybe an MDNode is more convenient. Unfortunately there’s target-specific code lurking out there that makes assumptions about the number of operands.

-Andy