[LLVMdev] How to build a map between IR Instruction and MachineInstrs?

Haishan hndxvon at 163.com
Sat Dec 14 02:44:54 PST 2013



Hi,
  Thanks for your answer.
  I am looking for a map, and the data structure of this map is
  map<const Instruction *, vector<MachineInstr*> >
In this map, its keyvalue is IR instruction pointer, and
its second value is a container which is composed of MachineInstr lowering by its keyvalue.


For example:
IR Instruction 
%0 = load i32* getelementptr inbounds ([6 x i32]* @a, i32 0, i32 5), align 4, !tbaa !0
Two MachineInstrs lowed by this IR are shown following and used as This IR's second value in the map
%vreg0<def> = MOVi32 <ga:@a>; GPR:%vreg0
%vreg1<def> = LOADi32 %vreg0, 20, pred:14, preg:%noreg; mem:LD4[getelementptr inbounds ([6 x i32]* @a, i32 0, i32 5)] (tbaa !="int") GPR:%vreg1,%vreg0


  The reason I am looking for the above map is that I try to port Swing Modulo Scheduling
code updated by Tanya M.Latter in LLVM1.7 to LLVM3.3.
And this map was used in the original SMS code of LLVM1.7.
By the way, have you/someone considered coding/porting target-indenpent SMS in latest
version of LLVM? Or have any suggestion for porting these code?


Best Wishes
-Haishan







At 2013-12-13 01:35:01,"James Courtier-Dutton" <james.dutton at gmail.com> wrote:
>On 12 December 2013 13:58, Haishan <hndxvon at 163.com> wrote:
>> Hi,
>>   I try to add a backend (machine function) pass in LLVM 3.3 source code.
>> In order to analyse precise information of machine instructions, I need some
>> information of
>> IR instruction which corresponds to MachineInstrs. If so, it's much easier
>> to analyse IR Instructions instead of MachineInstrs.
>> However, in the frame of LLVM 3.3, I can't find the corresponding(connected)
>> information
>> from Instruction to MachineInstrs in the CodeGenAndEmitDAG function.
>> PS: I once used IROrder which is a member of class SDNode as unchangeable
>> information, but it's roughly corresponding information, so the map
>> <Instruction*, vector<MachineInstr*> > often overlaps.
>> Could someone help me with that?
>> Thank you very much in advance.
>> -Haishan
>>
>
>What sort of map are you looking for?
>IR is very different from MachineInstrs.
>There is no one-to-one mapping.
>Information is lost during the IR to MachineInstrs lowering steps and
>due to optimizations done at the MachineInstrs level.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131214/95f9340d/attachment.html>


More information about the llvm-dev mailing list