[LLVMdev] selecting ISD node - help
Tim Northover
t.p.northover at gmail.com
Sat Feb 8 08:36:34 PST 2014
Hi DaAn,
> I tried doing what you said, and the DAG looks like how I think it supposed
> to look like (attached the picture below).
I'm a little concerned that the CopyFromRegs are referencing "%vreg0"
rather than %EAX, but that might be an LLVM-internal thing (perhaps
because of your addLiveIns). Other than that they look right to me
too, so I wouldn't worry about it for now (your code looks OK).
> getCopyToReg doesn't show on the final assembly
Ah, I think I may have just spotted the reason for that. The RDMSR
instruction hasn't been marked as using EDX:EAX or defining ECX
(incidentally, the Intel manual doesn't seem to make any mention of
RCX).
That's probably causing LLVM to drop the COPY instructions you're
generating (thinking they're dead code). I'd suggest changing the
X86InstrSystem.td:443 to be something like:
let Defs = [ECX], Uses = [EAX, EDX] in
def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", [], IIC_RDMSR>, TB;
> Maybe it's because I use MF.addLiveIn but when I tried using X86::EAX it
> failed with the message:
> # Machine code for function _Z5test2v: Post SSA
>
> BB#0: derived from LLVM BB %entry
> %vreg2<def> = COPY %EAX; GR32:%vreg2
> RDMSR
> %EAX<def> = COPY %vreg2; GR32:%vreg2
addLiveIn is definitely wrong (%eax isn't live upon entry to the
function). That snippet looks like the CopyFromReg and CopyToReg are
backwards to me. And the reuse of %vreg2 isn't inspiring confidence,
though it might be correct.
I've not looked in detail, but there's code in InstrEmitter.cpp
hinting that the ordering-constraints we want from the Glue may be
ignored if there isn't any register dependence, so I'd suggest fixing
the RDMSR definition and removing the addLiveIn together. With luck
everything will start working.
Cheers.
Tim.
More information about the llvm-dev
mailing list