[LLVMdev] Setting cl::opt<bool> EnablePhysicalJoin without a command line

Vincent vljn at ovi.com
Thu Sep 27 11:50:08 PDT 2012


Hi,

The R600 backend uses the register coalescer pass to generate code. This
pass has a EnablePhysicalJoin boolean value which is set to false by
default.
The way the R600 backend is used in Mesa runtime makes it very usefull
to be set to true : We use live inst to represent OpenGL Input, which
are converted to vreg = COPY %PhysReg after instruction selection. For
instance, the following sample was generated when EnablePhysicalJoin is
true :

# Machine code for function main: Post SSA, not tracking liveness
Function Live Ins: %T2_X in %vreg0, %T1_W in %vreg1, %T1_Z in %vreg2, %
T1_Y in %vreg3, %T1_X in %vreg4

BB#0: derived from LLVM BB %main_body
    Live Ins: %T2_X %T1_W %T1_Z %T1_Y %T1_X
    %T1_X<def,undef> = KILL %T1_X<kill,undef>, %T1_XYZW<imp-def,undef>
    R600_Export
%T1_XYZW<kill>, 0, 0, 0, 1, 2, 3
    %T2_X<def,undef> = KILL %T2_X<kill,undef>, %T2_XYZW<imp-def,undef>
    R600_Export_DONE %T2_XYZW<kill>, 0, 61, 2, 7, 7, 7
    RETURN

# End machine code for function main.

whereas when set to false, it gives :

# Machine code for function main: Post SSA, not tracking liveness
Function Live Ins: %T2_X in %vreg0, %T1_W in %vreg1, %T1_Z in %vreg2, %
T1_Y in %vreg3, %T1_X in %vreg4

BB#0: derived from LLVM BB %main_body
    Live Ins: %T2_X %T1_W %T1_Z %T1_Y %T1_X
    %T0_X<def> = MOV %T1_X<kill>, 0, pred:%noreg, %T0_XYZW<imp-def>
    %T2_X<def> = KILL %T2_X<kill>, %T2_XYZW<imp-def>
    %T0_Y<def> = MOV %T1_Y<kill>, 0, pred:%noreg, %T0_XYZW<imp-def>
    %T0_Z<def> = MOV %T1_Z<kill>, 0, pred:%noreg, %T0_XYZW<imp-def>
    %T0_W<def> = MOV %T1_W<kill>, 0, pred:%noreg, %T0_XYZW<imp-def>
    R600_Export %T0_XYZW<kill>, 0, 0, 0, 1, 2, 3
    R600_Export_DONE %T2_XYZW<kill>, 0, 61, 2, 7, 7, 7
    RETURN

# End machine code for function main.

Of course this is a rather simple code, but shaders often export
component from input (which are physical) to the output, yielding 4
extra MOV to exported reg instructions.

Unfortunatly, it seems that the EnablePhysicalJoin option is changeable
from the command line "opt" tool. Is it possible to change a cl::opt<>
option programmaticaly, and how ?

Regards, Vincent






More information about the llvm-dev mailing list