The second patch of X86 support for read cycle counter.

llvm-svn: 24430
This commit is contained in:
Andrew Lenharth 2005-11-20 21:41:10 +00:00
parent 627cbd49b1
commit 0bf68ae434
4 changed files with 20 additions and 0 deletions

View File

@ -101,6 +101,7 @@ X86TargetLowering::X86TargetLowering(TargetMachine &TM)
setOperationAction(ISD::CTPOP , MVT::i32 , Expand);
setOperationAction(ISD::CTTZ , MVT::i32 , Expand);
setOperationAction(ISD::CTLZ , MVT::i32 , Expand);
setOperationAction(ISD::READCYCLECOUNTER , MVT::i64 , Custom);
setOperationAction(ISD::READIO , MVT::i1 , Expand);
setOperationAction(ISD::READIO , MVT::i8 , Expand);
@ -912,5 +913,11 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
return DAG.getLoad(Op.getValueType(), FIST, StackSlot,
DAG.getSrcValue(NULL));
}
case ISD::READCYCLECOUNTER: {
SDOperand rd = DAG.getNode(X86ISD::RDTSC_DAG, MVT::Other, Op.getOperand(0));
SDOperand Lo = DAG.getCopyFromReg(rd, X86::EAX, MVT::i32);
SDOperand Hi = DAG.getCopyFromReg(rd, X86::EDX, MVT::i32);
return DAG.getNode(ISD::BUILD_PAIR, MVT::i64, Lo, Hi);
}
}
}

View File

@ -62,6 +62,10 @@ namespace llvm {
/// LLVM.
CALL,
TAILCALL,
/// RDTSC_DAG - This operation implements the lowering for
/// readcyclecounter
RDTSC_DAG,
};
}

View File

@ -3090,6 +3090,11 @@ void ISel::Select(SDOperand N) {
default:
Node->dump(); std::cerr << "\n";
assert(0 && "Node not handled yet!");
case X86ISD::RDTSC_DAG:
Select(Node->getOperand(0)); //Chain
BuildMI(BB, X86::RDTSC, 0);
return;
case ISD::EntryToken: return; // Noop
case ISD::TokenFactor:
if (Node->getNumOperands() == 2) {

View File

@ -167,6 +167,10 @@ class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
def PHI : I<0, Pseudo, (ops variable_ops), "PHINODE">; // PHI node.
def NOOP : I<0x90, RawFrm, (ops), "nop">; // nop
//FIXME: encode this correctly
let Defs = [EAX, EDX] in
def RDTSC : I<0, Pseudo, (ops ), "rdtsc">; //in binary, this inst is 0x0f 0x31
def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN">;
def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
"#ADJCALLSTACKUP">;