Hi Tim,
Tim Northover-2 wrote> The code used for DIV is around X86ISelDAGToDAG.cpp:2415, but from a
> glance the key points seem to be:
> 1. use the second result of getCopyToReg (i.e. SDValue(setIdNode, 1))
> in the RDMSR node.
> 2. Give your RDMSR node type MVT::Glue instead of MVT::Other
I tried doing what you said, and the DAG looks like how I think it supposed
to look like (attached the picture below).
if(Subtarget->is64Bit())
{
idReg = X86::RCX;
resultReg = MF.addLiveIn(X86::RAX, &X86::GR64RegClass);
}
else
{
idReg = X86::ECX;
resultReg = MF.addLiveIn(X86::EAX, &X86::GR32RegClass);
}
idRegValue = CurDAG->getRegister(idReg, resultType);
SDValue setIdNode = CurDAG->getCopyToReg(CurDAG->getEntryNode(), dl,
idRegValue, id, SDValue());
SDValue rdmsrNode = SDValue(CurDAG->getMachineNode(X86::RDMSR, dl,
MVT::Glue, setIdNode.getValue(1)), 0);
SDValue resultNode = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), dl,
X86::EAX, MVT::i32, rdmsrNode);
return resultNode.getNode();
but I've a couple of problems:
getCopyToReg doesn't show on the final assembly
__Z5test2v proc near
push ebp
mov ebp, esp
rdmsr
pop ebp
retn
__Z5test2v endp
When I add rdmsr + rdmsr, first the rdmsr calls are made and only then he
adds eax, eax.
__Z5test3v proc near
push ebp
mov ebp, esp
rdmsr
rdmsr
add eax, eax
pop ebp
retn
__Z5test3v endp
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
RET %EAX<kill>
# End machine code for function _Z5test2v.
*** Bad machine code: Using an undefined physical register ***
- function: _Z5test2v
- basic block: BB#0 entry (0x2ff8228)
- instruction: %vreg2<def> = COPY %EAX; GR32:%vreg2
- operand 1: %EAX
LLVM ERROR: Found 1 machine code errors.
Stack dump:
0. Program arguments:
C:\Users\DaAn\Documents\Projects\llvm-3.4\build\bin\Debug\llc.exe
-filetype=obj -view-sched-dags
C:\Users\DaAn\Documents\Projects\llvm-3.4\build\bin\Debug\test.bc
1. Running pass 'Function Pass Manager' on module
'C:\Users\DaAn\Documents\Projects\llvm-3.4\build\bin\Debug\test.bc'.
2. Running pass 'Greedy Register Allocator' on function
'@_Z5test2v'
<http://llvm.1065342.n5.nabble.com/file/n65821/dag._Z5test2v-4ac530.png>
<http://llvm.1065342.n5.nabble.com/file/n65821/dag._Z5test3v-e16193.png>
--
View this message in context:
http://llvm.1065342.n5.nabble.com/selecting-ISD-node-help-tp65819p65821.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.