Add XCore intrinsic for crc8.

llvm-svn: 132340
This commit is contained in:
Richard Osborne 2011-05-31 16:24:49 +00:00
parent 116b305d31
commit 2f14b0bb1d
4 changed files with 29 additions and 0 deletions

View File

@ -11,6 +11,9 @@
let TargetPrefix = "xcore" in { // All intrinsics start with "llvm.xcore.".
// Miscellaneous instructions.
def int_xcore_bitrev : Intrinsic<[llvm_i32_ty],[llvm_i32_ty],[IntrNoMem]>;
def int_xcore_crc8 : Intrinsic<[llvm_i32_ty, llvm_i32_ty],
[llvm_i32_ty,llvm_i32_ty,llvm_i32_ty],
[IntrNoMem]>;
def int_xcore_crc32 : Intrinsic<[llvm_i32_ty],[llvm_i32_ty,llvm_i32_ty,llvm_i32_ty],[IntrNoMem]>;
def int_xcore_getid : Intrinsic<[llvm_i32_ty],[],[IntrNoMem]>;
def int_xcore_getps : Intrinsic<[llvm_i32_ty],[llvm_i32_ty]>;

View File

@ -205,6 +205,16 @@ SDNode *XCoreDAGToDAGISel::Select(SDNode *N) {
return CurDAG->getMachineNode(XCore::LMUL_l6r, dl, MVT::i32, MVT::i32,
Ops, 4);
}
case ISD::INTRINSIC_WO_CHAIN: {
unsigned IntNo = cast<ConstantSDNode>(N->getOperand(0))->getZExtValue();
switch (IntNo) {
case Intrinsic::xcore_crc8:
SDValue Ops[] = { N->getOperand(1), N->getOperand(2), N->getOperand(3) };
return CurDAG->getMachineNode(XCore::CRC8_l4r, dl, MVT::i32, MVT::i32,
Ops, 3);
}
break;
}
case ISD::BRIND:
if (SDNode *ResNode = SelectBRIND(N))
return ResNode;

View File

@ -504,6 +504,12 @@ def MACCS_l4r : _L4R<(outs GRRegs:$dst1, GRRegs:$dst2),
[]>;
}
let Constraints = "$src1 = $dst1" in
def CRC8_l4r : _L4R<(outs GRRegs:$dst1, GRRegs:$dst2),
(ins GRRegs:$src1, GRRegs:$src2, GRRegs:$src3),
"crc8 $dst1, $dst2, $src2, $src3",
[]>;
// Five operand long
def LADD_l5r : _L5R<(outs GRRegs:$dst1, GRRegs:$dst2),

View File

@ -1,6 +1,9 @@
; RUN: llc < %s -march=xcore | FileCheck %s
%0 = type { i32, i32 }
declare i32 @llvm.xcore.bitrev(i32)
declare i32 @llvm.xcore.crc32(i32, i32, i32)
declare %0 @llvm.xcore.crc8(i32, i32, i32)
define i32 @bitrev(i32 %val) {
; CHECK: bitrev:
@ -15,3 +18,10 @@ define i32 @crc32(i32 %crc, i32 %data, i32 %poly) {
%result = call i32 @llvm.xcore.crc32(i32 %crc, i32 %data, i32 %poly)
ret i32 %result
}
define %0 @crc8(i32 %crc, i32 %data, i32 %poly) {
; CHECK: crc8:
; CHECK: crc8 r0, r1, r1, r2
%result = call %0 @llvm.xcore.crc8(i32 %crc, i32 %data, i32 %poly)
ret %0 %result
}