[LLVMdev] Proposal: extended MDString syntax

Jakob Stoklund Olesen stoklund at 2pi.dk
Thu Jun 27 09:50:38 PDT 2013


On Jun 26, 2013, at 4:18 PM, Eric Christopher <echristo at gmail.com> wrote:

> So inverting it so that MI contains LLVM IR instead of the other way
> around? Then we'd need a serialization format for MI that happened to
> include a way of serializing LLVM IR within. From a quick "hey, this
> seems reasonable" the idea of embedding the MI into the IR rather than
> the other way around seems to make sense since we have already have
> code to serialize the IR.

I’d suggest something based on YAML which would allow you to include IR verbatim just by indenting it.

The IR module should be optional when serializing MI. The back-pointers from MI to IR are not required, and I can imagine many useful test cases that won’t need them.

module: |
  define void @linkit(i8* %source) #0 {
  entry:
    %.b243 = load i1* @Pflag, align 1
    %cond = select i1 %.b243, i32 (i8*, %struct.stat.6.13.20.64*)* @lstat, i32 (i8*, %struct.stat.6.13.20.64*)* @stat
    %call = call signext i32 %cond(i8* %source, %struct.stat.6.13.20.64* undef) #2
    ret void
  }
  @Pflag = external unnamed_addr global i1
  declare signext i32 @lstat(i8* nocapture, %struct.stat.6.13.20.64* nocapture) #1
  declare signext i32 @stat(i8* nocapture, %struct.stat.6.13.20.64* nocapture) #1

mi: |
  BB#0: derived from LLVM BB %entry
      Live Ins: %I0
	%O6<def> = SAVEri %O6, -176
	%I1<def> = SETHIi <ga:@Pflag>[TF=3]
  	%I1<def> = ADDri %I1<kill>, <ga:@Pflag>[TF=4]
	%I1<def> = SLLXri %I1<kill>, 12
	%I2<def> = LDUBri %I1<kill>, <ga:@Pflag>[TF=5]; mem:LD1[@Pflag]
	%I1<def> = SETHIi <ga:@stat>[TF=3]
	%I1<def> = ADDri %I1<kill>, <ga:@stat>[TF=4]
	%I1<def> = SLLXri %I1<kill>, 12
	%I1<def> = ADDri %I1<kill>, <ga:@stat>[TF=5]
	%I3<def> = SETHIi <ga:@lstat>[TF=3]
	%I3<def> = ADDri %I3<kill>, <ga:@lstat>[TF=4]
	%I3<def> = SLLXri %I3<kill>, 12
	%I3<def> = ADDri %I3<kill>, <ga:@lstat>[TF=5]
	CMPri %I2<kill>, 0, %ICC<imp-def>
	%I1<def,tied2> = MOVXCCrr %I3<kill>, %I1<kill,tied0>, 9, %ICC<imp-use,kill>
	JMPLrr %I1<kill>, %G0, %O0<kill>, %O1<undef>, %O0<imp-def,dead>, %O1<imp-def,dead>, %ICC<imp-def,dead>, %O6<imp-use>, ...
	%O0<def> = ORrr %G0, %I0<kill>
	RET 8
	%G0<def> = RESTORErr %G0, %G0

We could also use more YAML structure to represent MI functions and basic blocks, if needed.

Thanks,
/jakob





More information about the llvm-dev mailing list