2010-09-19 02:52:28 +08:00
|
|
|
//===- PTXInstrInfo.td - PTX Instruction defs -----------------*- tblgen-*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file describes the PTX instructions in TableGen format.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Instruction format superclass
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
include "PTXInstrFormats.td"
|
|
|
|
|
2011-03-02 15:36:48 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Code Generation Predicates
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-03-11 00:57:18 +08:00
|
|
|
// Shader Model Support
|
2011-06-25 00:27:49 +08:00
|
|
|
def FDivNeedsRoundingMode : Predicate<"getSubtarget().fdivNeedsRoundingMode()">;
|
|
|
|
def FDivNoRoundingMode : Predicate<"!getSubtarget().fdivNeedsRoundingMode()">;
|
|
|
|
def FMadNeedsRoundingMode : Predicate<"getSubtarget().fmadNeedsRoundingMode()">;
|
|
|
|
def FMadNoRoundingMode : Predicate<"!getSubtarget().fmadNeedsRoundingMode()">;
|
2011-03-11 00:57:18 +08:00
|
|
|
|
|
|
|
// PTX Version Support
|
|
|
|
def SupportsPTX21 : Predicate<"getSubtarget().supportsPTX21()">;
|
|
|
|
def DoesNotSupportPTX21 : Predicate<"!getSubtarget().supportsPTX21()">;
|
2011-03-15 21:24:15 +08:00
|
|
|
def SupportsPTX22 : Predicate<"getSubtarget().supportsPTX22()">;
|
|
|
|
def DoesNotSupportPTX22 : Predicate<"!getSubtarget().supportsPTX22()">;
|
2011-05-10 20:32:11 +08:00
|
|
|
def SupportsPTX23 : Predicate<"getSubtarget().supportsPTX23()">;
|
|
|
|
def DoesNotSupportPTX23 : Predicate<"!getSubtarget().supportsPTX23()">;
|
2011-03-15 21:24:15 +08:00
|
|
|
|
2011-05-18 23:42:23 +08:00
|
|
|
// Fused-Multiply Add
|
|
|
|
def SupportsFMA : Predicate<"getSubtarget().supportsFMA()">;
|
|
|
|
def DoesNotSupportFMA : Predicate<"!getSubtarget().supportsFMA()">;
|
|
|
|
|
2010-11-30 15:34:44 +08:00
|
|
|
|
|
|
|
|
2011-08-10 01:36:31 +08:00
|
|
|
// def SDT_PTXCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
|
|
|
|
// def SDT_PTXCallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
|
|
|
|
|
|
|
|
// def PTXcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PTXCallSeqStart,
|
|
|
|
// [SDNPHasChain, SDNPOutGlue]>;
|
|
|
|
// def PTXcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PTXCallSeqEnd,
|
|
|
|
// [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
|
|
|
|
|
|
|
|
def PTXcall : SDNode<"PTXISD::CALL", SDTNone,
|
|
|
|
[SDNPHasChain, SDNPVariadic, SDNPOptInGlue, SDNPOutGlue]>;
|
|
|
|
|
|
|
|
|
2011-03-18 19:08:52 +08:00
|
|
|
// Branch & call targets have OtherVT type.
|
|
|
|
def brtarget : Operand<OtherVT>;
|
|
|
|
def calltarget : Operand<i32>;
|
2011-03-02 15:36:48 +08:00
|
|
|
|
2010-09-19 02:52:28 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// PTX Specific Node Definitions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-12-06 12:00:03 +08:00
|
|
|
// PTX allow generic 3-reg shifts like shl r0, r1, r2
|
|
|
|
def PTXshl : SDNode<"ISD::SHL", SDTIntBinOp>;
|
|
|
|
def PTXsrl : SDNode<"ISD::SRL", SDTIntBinOp>;
|
|
|
|
def PTXsra : SDNode<"ISD::SRA", SDTIntBinOp>;
|
|
|
|
|
2010-09-19 02:52:28 +08:00
|
|
|
def PTXexit
|
|
|
|
: SDNode<"PTXISD::EXIT", SDTNone, [SDNPHasChain]>;
|
2010-09-25 15:46:17 +08:00
|
|
|
def PTXret
|
2011-06-24 02:10:03 +08:00
|
|
|
: SDNode<"PTXISD::RET", SDTNone,
|
|
|
|
[SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
|
2011-03-19 03:24:28 +08:00
|
|
|
def PTXcopyaddress
|
|
|
|
: SDNode<"PTXISD::COPY_ADDRESS", SDTypeProfile<1, 1, []>, []>;
|
2010-09-19 02:52:28 +08:00
|
|
|
|
2011-09-27 00:20:31 +08:00
|
|
|
|
2011-09-23 00:45:46 +08:00
|
|
|
|
2010-11-17 16:08:49 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Instruction Class Templates
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-04-28 08:19:53 +08:00
|
|
|
//===- Floating-Point Instructions - 2 Operand Form -----------------------===//
|
|
|
|
multiclass PTX_FLOAT_2OP<string opcstr, SDNode opnode> {
|
2011-06-17 01:49:58 +08:00
|
|
|
def rr32 : InstPTX<(outs RegF32:$d),
|
|
|
|
(ins RegF32:$a),
|
2011-04-28 08:19:53 +08:00
|
|
|
!strconcat(opcstr, ".f32\t$d, $a"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF32:$d, (opnode RegF32:$a))]>;
|
|
|
|
def ri32 : InstPTX<(outs RegF32:$d),
|
2011-04-28 08:19:53 +08:00
|
|
|
(ins f32imm:$a),
|
|
|
|
!strconcat(opcstr, ".f32\t$d, $a"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF32:$d, (opnode fpimm:$a))]>;
|
|
|
|
def rr64 : InstPTX<(outs RegF64:$d),
|
|
|
|
(ins RegF64:$a),
|
2011-04-28 08:19:53 +08:00
|
|
|
!strconcat(opcstr, ".f64\t$d, $a"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (opnode RegF64:$a))]>;
|
|
|
|
def ri64 : InstPTX<(outs RegF64:$d),
|
2011-04-28 08:19:53 +08:00
|
|
|
(ins f64imm:$a),
|
|
|
|
!strconcat(opcstr, ".f64\t$d, $a"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (opnode fpimm:$a))]>;
|
2011-04-28 08:19:53 +08:00
|
|
|
}
|
|
|
|
|
2011-03-11 00:57:18 +08:00
|
|
|
//===- Floating-Point Instructions - 3 Operand Form -----------------------===//
|
|
|
|
multiclass PTX_FLOAT_3OP<string opcstr, SDNode opnode> {
|
2011-06-17 01:49:58 +08:00
|
|
|
def rr32 : InstPTX<(outs RegF32:$d),
|
|
|
|
(ins RegF32:$a, RegF32:$b),
|
2011-03-02 11:20:28 +08:00
|
|
|
!strconcat(opcstr, ".f32\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF32:$d, (opnode RegF32:$a, RegF32:$b))]>;
|
|
|
|
def ri32 : InstPTX<(outs RegF32:$d),
|
|
|
|
(ins RegF32:$a, f32imm:$b),
|
2011-03-02 11:20:28 +08:00
|
|
|
!strconcat(opcstr, ".f32\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF32:$d, (opnode RegF32:$a, fpimm:$b))]>;
|
|
|
|
def rr64 : InstPTX<(outs RegF64:$d),
|
|
|
|
(ins RegF64:$a, RegF64:$b),
|
2011-03-02 11:20:28 +08:00
|
|
|
!strconcat(opcstr, ".f64\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (opnode RegF64:$a, RegF64:$b))]>;
|
|
|
|
def ri64 : InstPTX<(outs RegF64:$d),
|
|
|
|
(ins RegF64:$a, f64imm:$b),
|
2011-03-02 11:20:28 +08:00
|
|
|
!strconcat(opcstr, ".f64\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (opnode RegF64:$a, fpimm:$b))]>;
|
2011-02-28 14:34:09 +08:00
|
|
|
}
|
|
|
|
|
2011-03-11 00:57:18 +08:00
|
|
|
//===- Floating-Point Instructions - 4 Operand Form -----------------------===//
|
|
|
|
multiclass PTX_FLOAT_4OP<string opcstr, SDNode opnode1, SDNode opnode2> {
|
2011-06-17 01:49:58 +08:00
|
|
|
def rrr32 : InstPTX<(outs RegF32:$d),
|
|
|
|
(ins RegF32:$a, RegF32:$b, RegF32:$c),
|
2011-03-11 00:57:18 +08:00
|
|
|
!strconcat(opcstr, ".f32\t$d, $a, $b, $c"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF32:$d, (opnode2 (opnode1 RegF32:$a,
|
|
|
|
RegF32:$b),
|
|
|
|
RegF32:$c))]>;
|
|
|
|
def rri32 : InstPTX<(outs RegF32:$d),
|
|
|
|
(ins RegF32:$a, RegF32:$b, f32imm:$c),
|
2011-03-11 00:57:18 +08:00
|
|
|
!strconcat(opcstr, ".f32\t$d, $a, $b, $c"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF32:$d, (opnode2 (opnode1 RegF32:$a,
|
|
|
|
RegF32:$b),
|
2011-03-11 00:57:18 +08:00
|
|
|
fpimm:$c))]>;
|
2011-06-17 01:49:58 +08:00
|
|
|
def rrr64 : InstPTX<(outs RegF64:$d),
|
|
|
|
(ins RegF64:$a, RegF64:$b, RegF64:$c),
|
2011-03-11 00:57:18 +08:00
|
|
|
!strconcat(opcstr, ".f64\t$d, $a, $b, $c"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (opnode2 (opnode1 RegF64:$a,
|
|
|
|
RegF64:$b),
|
|
|
|
RegF64:$c))]>;
|
|
|
|
def rri64 : InstPTX<(outs RegF64:$d),
|
|
|
|
(ins RegF64:$a, RegF64:$b, f64imm:$c),
|
2011-03-11 00:57:18 +08:00
|
|
|
!strconcat(opcstr, ".f64\t$d, $a, $b, $c"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (opnode2 (opnode1 RegF64:$a,
|
|
|
|
RegF64:$b),
|
2011-03-11 00:57:18 +08:00
|
|
|
fpimm:$c))]>;
|
|
|
|
}
|
|
|
|
|
2010-11-17 16:08:49 +08:00
|
|
|
multiclass INT3<string opcstr, SDNode opnode> {
|
2011-06-17 01:49:58 +08:00
|
|
|
def rr16 : InstPTX<(outs RegI16:$d),
|
|
|
|
(ins RegI16:$a, RegI16:$b),
|
2011-03-02 11:20:28 +08:00
|
|
|
!strconcat(opcstr, ".u16\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI16:$d, (opnode RegI16:$a, RegI16:$b))]>;
|
|
|
|
def ri16 : InstPTX<(outs RegI16:$d),
|
|
|
|
(ins RegI16:$a, i16imm:$b),
|
2011-03-02 11:20:28 +08:00
|
|
|
!strconcat(opcstr, ".u16\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI16:$d, (opnode RegI16:$a, imm:$b))]>;
|
|
|
|
def rr32 : InstPTX<(outs RegI32:$d),
|
|
|
|
(ins RegI32:$a, RegI32:$b),
|
2011-03-02 11:20:28 +08:00
|
|
|
!strconcat(opcstr, ".u32\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI32:$d, (opnode RegI32:$a, RegI32:$b))]>;
|
|
|
|
def ri32 : InstPTX<(outs RegI32:$d),
|
|
|
|
(ins RegI32:$a, i32imm:$b),
|
2011-03-02 11:20:28 +08:00
|
|
|
!strconcat(opcstr, ".u32\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI32:$d, (opnode RegI32:$a, imm:$b))]>;
|
|
|
|
def rr64 : InstPTX<(outs RegI64:$d),
|
|
|
|
(ins RegI64:$a, RegI64:$b),
|
2011-03-02 11:20:28 +08:00
|
|
|
!strconcat(opcstr, ".u64\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI64:$d, (opnode RegI64:$a, RegI64:$b))]>;
|
|
|
|
def ri64 : InstPTX<(outs RegI64:$d),
|
|
|
|
(ins RegI64:$a, i64imm:$b),
|
2011-03-02 11:20:28 +08:00
|
|
|
!strconcat(opcstr, ".u64\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI64:$d, (opnode RegI64:$a, imm:$b))]>;
|
2010-11-17 16:08:49 +08:00
|
|
|
}
|
|
|
|
|
2011-03-15 21:24:15 +08:00
|
|
|
multiclass PTX_LOGIC<string opcstr, SDNode opnode> {
|
2011-06-17 01:49:58 +08:00
|
|
|
def ripreds : InstPTX<(outs RegPred:$d),
|
|
|
|
(ins RegPred:$a, i1imm:$b),
|
2011-04-28 08:19:51 +08:00
|
|
|
!strconcat(opcstr, ".pred\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegPred:$d, (opnode RegPred:$a, imm:$b))]>;
|
|
|
|
def rrpreds : InstPTX<(outs RegPred:$d),
|
|
|
|
(ins RegPred:$a, RegPred:$b),
|
2011-04-28 08:19:51 +08:00
|
|
|
!strconcat(opcstr, ".pred\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegPred:$d, (opnode RegPred:$a, RegPred:$b))]>;
|
|
|
|
def rr16 : InstPTX<(outs RegI16:$d),
|
|
|
|
(ins RegI16:$a, RegI16:$b),
|
2011-03-15 21:24:15 +08:00
|
|
|
!strconcat(opcstr, ".b16\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI16:$d, (opnode RegI16:$a, RegI16:$b))]>;
|
|
|
|
def ri16 : InstPTX<(outs RegI16:$d),
|
|
|
|
(ins RegI16:$a, i16imm:$b),
|
2011-03-15 21:24:15 +08:00
|
|
|
!strconcat(opcstr, ".b16\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI16:$d, (opnode RegI16:$a, imm:$b))]>;
|
|
|
|
def rr32 : InstPTX<(outs RegI32:$d),
|
|
|
|
(ins RegI32:$a, RegI32:$b),
|
2011-03-15 21:24:15 +08:00
|
|
|
!strconcat(opcstr, ".b32\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI32:$d, (opnode RegI32:$a, RegI32:$b))]>;
|
|
|
|
def ri32 : InstPTX<(outs RegI32:$d),
|
|
|
|
(ins RegI32:$a, i32imm:$b),
|
2011-03-15 21:24:15 +08:00
|
|
|
!strconcat(opcstr, ".b32\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI32:$d, (opnode RegI32:$a, imm:$b))]>;
|
|
|
|
def rr64 : InstPTX<(outs RegI64:$d),
|
|
|
|
(ins RegI64:$a, RegI64:$b),
|
2011-03-15 21:24:15 +08:00
|
|
|
!strconcat(opcstr, ".b64\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI64:$d, (opnode RegI64:$a, RegI64:$b))]>;
|
|
|
|
def ri64 : InstPTX<(outs RegI64:$d),
|
|
|
|
(ins RegI64:$a, i64imm:$b),
|
2011-03-15 21:24:15 +08:00
|
|
|
!strconcat(opcstr, ".b64\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI64:$d, (opnode RegI64:$a, imm:$b))]>;
|
2011-03-15 21:24:15 +08:00
|
|
|
}
|
|
|
|
|
2010-12-06 12:00:03 +08:00
|
|
|
multiclass INT3ntnc<string opcstr, SDNode opnode> {
|
2011-06-17 01:49:58 +08:00
|
|
|
def rr16 : InstPTX<(outs RegI16:$d),
|
|
|
|
(ins RegI16:$a, RegI16:$b),
|
2011-03-24 00:58:51 +08:00
|
|
|
!strconcat(opcstr, "16\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI16:$d, (opnode RegI16:$a, RegI16:$b))]>;
|
|
|
|
def rr32 : InstPTX<(outs RegI32:$d),
|
|
|
|
(ins RegI32:$a, RegI32:$b),
|
2011-03-24 00:58:51 +08:00
|
|
|
!strconcat(opcstr, "32\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI32:$d, (opnode RegI32:$a, RegI32:$b))]>;
|
|
|
|
def rr64 : InstPTX<(outs RegI64:$d),
|
|
|
|
(ins RegI64:$a, RegI64:$b),
|
2011-03-24 00:58:51 +08:00
|
|
|
!strconcat(opcstr, "64\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI64:$d, (opnode RegI64:$a, RegI64:$b))]>;
|
|
|
|
def ri16 : InstPTX<(outs RegI16:$d),
|
|
|
|
(ins RegI16:$a, i16imm:$b),
|
2011-03-24 00:58:51 +08:00
|
|
|
!strconcat(opcstr, "16\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI16:$d, (opnode RegI16:$a, imm:$b))]>;
|
|
|
|
def ri32 : InstPTX<(outs RegI32:$d),
|
|
|
|
(ins RegI32:$a, i32imm:$b),
|
2011-03-24 00:58:51 +08:00
|
|
|
!strconcat(opcstr, "32\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI32:$d, (opnode RegI32:$a, imm:$b))]>;
|
|
|
|
def ri64 : InstPTX<(outs RegI64:$d),
|
|
|
|
(ins RegI64:$a, i64imm:$b),
|
2011-03-24 00:58:51 +08:00
|
|
|
!strconcat(opcstr, "64\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI64:$d, (opnode RegI64:$a, imm:$b))]>;
|
|
|
|
def ir16 : InstPTX<(outs RegI16:$d),
|
|
|
|
(ins i16imm:$a, RegI16:$b),
|
2011-03-24 00:58:51 +08:00
|
|
|
!strconcat(opcstr, "16\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI16:$d, (opnode imm:$a, RegI16:$b))]>;
|
|
|
|
def ir32 : InstPTX<(outs RegI32:$d),
|
|
|
|
(ins i32imm:$a, RegI32:$b),
|
2011-03-24 00:58:51 +08:00
|
|
|
!strconcat(opcstr, "32\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI32:$d, (opnode imm:$a, RegI32:$b))]>;
|
|
|
|
def ir64 : InstPTX<(outs RegI64:$d),
|
|
|
|
(ins i64imm:$a, RegI64:$b),
|
2011-03-24 00:58:51 +08:00
|
|
|
!strconcat(opcstr, "64\t$d, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegI64:$d, (opnode imm:$a, RegI64:$b))]>;
|
2010-12-06 12:00:03 +08:00
|
|
|
}
|
|
|
|
|
2011-04-20 17:28:20 +08:00
|
|
|
multiclass PTX_SETP_I<RegisterClass RC, string regclsname, Operand immcls,
|
2011-03-14 19:26:01 +08:00
|
|
|
CondCode cmp, string cmpstr> {
|
2011-04-20 17:28:20 +08:00
|
|
|
// TODO support 5-operand format: p|q, a, b, c
|
2011-04-02 16:51:39 +08:00
|
|
|
|
2011-03-14 19:26:01 +08:00
|
|
|
def rr
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b),
|
2011-04-02 16:51:39 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".", regclsname, "\t$p, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegPred:$p, (setcc RC:$a, RC:$b, cmp))]>;
|
2011-03-14 19:26:01 +08:00
|
|
|
def ri
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, immcls:$b),
|
2011-04-02 16:51:39 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".", regclsname, "\t$p, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegPred:$p, (setcc RC:$a, imm:$b, cmp))]>;
|
2011-04-02 16:51:39 +08:00
|
|
|
|
|
|
|
def rr_and_r
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".and.", regclsname,
|
|
|
|
"\t$p, $a, $b, $c"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegPred:$p, (and (setcc RC:$a, RC:$b, cmp), RegPred:$c))]>;
|
2011-04-02 16:51:39 +08:00
|
|
|
def ri_and_r
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, immcls:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".and.", regclsname,
|
|
|
|
"\t$p, $a, $b, $c"),
|
|
|
|
[(set RegPred:$p, (and (setcc RC:$a, imm:$b, cmp),
|
|
|
|
RegPred:$c))]>;
|
2011-04-02 16:51:39 +08:00
|
|
|
def rr_or_r
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".or.", regclsname,
|
|
|
|
"\t$p, $a, $b, $c"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegPred:$p, (or (setcc RC:$a, RC:$b, cmp), RegPred:$c))]>;
|
2011-04-02 16:51:39 +08:00
|
|
|
def ri_or_r
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, immcls:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".or.", regclsname,
|
|
|
|
"\t$p, $a, $b, $c"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegPred:$p, (or (setcc RC:$a, imm:$b, cmp), RegPred:$c))]>;
|
2011-04-02 16:51:39 +08:00
|
|
|
def rr_xor_r
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".xor.", regclsname,
|
|
|
|
"\t$p, $a, $b, $c"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegPred:$p, (xor (setcc RC:$a, RC:$b, cmp), RegPred:$c))]>;
|
2011-04-02 16:51:39 +08:00
|
|
|
def ri_xor_r
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, immcls:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".xor.", regclsname,
|
|
|
|
"\t$p, $a, $b, $c"),
|
|
|
|
[(set RegPred:$p, (xor (setcc RC:$a, imm:$b, cmp),
|
|
|
|
RegPred:$c))]>;
|
2011-04-02 16:51:39 +08:00
|
|
|
|
|
|
|
def rr_and_not_r
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".and.", regclsname,
|
|
|
|
"\t$p, $a, $b, !$c"),
|
|
|
|
[(set RegPred:$p, (and (setcc RC:$a, RC:$b, cmp),
|
|
|
|
(not RegPred:$c)))]>;
|
2011-04-02 16:51:39 +08:00
|
|
|
def ri_and_not_r
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, immcls:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".and.", regclsname,
|
|
|
|
"\t$p, $a, $b, !$c"),
|
|
|
|
[(set RegPred:$p, (and (setcc RC:$a, imm:$b, cmp),
|
|
|
|
(not RegPred:$c)))]>;
|
2011-04-02 16:51:39 +08:00
|
|
|
def rr_or_not_r
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".or.", regclsname,
|
|
|
|
"\t$p, $a, $b, !$c"),
|
|
|
|
[(set RegPred:$p, (or (setcc RC:$a, RC:$b, cmp),
|
|
|
|
(not RegPred:$c)))]>;
|
2011-04-02 16:51:39 +08:00
|
|
|
def ri_or_not_r
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, immcls:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".or.", regclsname,
|
|
|
|
"\t$p, $a, $b, !$c"),
|
|
|
|
[(set RegPred:$p, (or (setcc RC:$a, imm:$b, cmp),
|
|
|
|
(not RegPred:$c)))]>;
|
2011-04-02 16:51:39 +08:00
|
|
|
def rr_xor_not_r
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".xor.", regclsname,
|
|
|
|
"\t$p, $a, $b, !$c"),
|
|
|
|
[(set RegPred:$p, (xor (setcc RC:$a, RC:$b, cmp),
|
|
|
|
(not RegPred:$c)))]>;
|
2011-04-02 16:51:39 +08:00
|
|
|
def ri_xor_not_r
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, immcls:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".xor.", regclsname,
|
|
|
|
"\t$p, $a, $b, !$c"),
|
|
|
|
[(set RegPred:$p, (xor (setcc RC:$a, imm:$b, cmp),
|
|
|
|
(not RegPred:$c)))]>;
|
2011-03-14 19:26:01 +08:00
|
|
|
}
|
|
|
|
|
2011-09-29 09:13:12 +08:00
|
|
|
multiclass PTX_SETP_FP<RegisterClass RC, string regclsname, Operand immcls,
|
2011-04-20 17:28:20 +08:00
|
|
|
CondCode ucmp, CondCode ocmp, string cmpstr> {
|
|
|
|
// TODO support 5-operand format: p|q, a, b, c
|
|
|
|
|
|
|
|
def rr_u
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b),
|
2011-04-20 17:28:20 +08:00
|
|
|
!strconcat("setp.", cmpstr, "u.", regclsname, "\t$p, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegPred:$p, (setcc RC:$a, RC:$b, ucmp))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
def rr_o
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b),
|
2011-04-20 17:28:20 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".", regclsname, "\t$p, $a, $b"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegPred:$p, (setcc RC:$a, RC:$b, ocmp))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
2011-09-29 09:13:12 +08:00
|
|
|
def ri_u
|
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, immcls:$b),
|
|
|
|
!strconcat("setp.", cmpstr, "u.", regclsname, "\t$p, $a, $b"),
|
|
|
|
[(set RegPred:$p, (setcc RC:$a, fpimm:$b, ucmp))]>;
|
|
|
|
def ri_o
|
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, immcls:$b),
|
|
|
|
!strconcat("setp.", cmpstr, ".", regclsname, "\t$p, $a, $b"),
|
|
|
|
[(set RegPred:$p, (setcc RC:$a, fpimm:$b, ocmp))]>;
|
|
|
|
|
2011-04-20 17:28:20 +08:00
|
|
|
def rr_and_r_u
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, "u.and.", regclsname,
|
|
|
|
"\t$p, $a, $b, $c"),
|
|
|
|
[(set RegPred:$p, (and (setcc RC:$a, RC:$b, ucmp),
|
|
|
|
RegPred:$c))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
def rr_and_r_o
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".and.", regclsname,
|
|
|
|
"\t$p, $a, $b, $c"),
|
|
|
|
[(set RegPred:$p, (and (setcc RC:$a, RC:$b, ocmp),
|
|
|
|
RegPred:$c))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
def rr_or_r_u
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, "u.or.", regclsname,
|
|
|
|
"\t$p, $a, $b, $c"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegPred:$p, (or (setcc RC:$a, RC:$b, ucmp), RegPred:$c))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
def rr_or_r_o
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".or.", regclsname,
|
|
|
|
"\t$p, $a, $b, $c"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegPred:$p, (or (setcc RC:$a, RC:$b, ocmp), RegPred:$c))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
def rr_xor_r_u
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, "u.xor.", regclsname,
|
|
|
|
"\t$p, $a, $b, $c"),
|
|
|
|
[(set RegPred:$p, (xor (setcc RC:$a, RC:$b, ucmp),
|
|
|
|
RegPred:$c))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
def rr_xor_r_o
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".xor.", regclsname,
|
|
|
|
"\t$p, $a, $b, $c"),
|
|
|
|
[(set RegPred:$p, (xor (setcc RC:$a, RC:$b, ocmp),
|
|
|
|
RegPred:$c))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
def rr_and_not_r_u
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, "u.and.", regclsname,
|
|
|
|
"\t$p, $a, $b, !$c"),
|
|
|
|
[(set RegPred:$p, (and (setcc RC:$a, RC:$b, ucmp),
|
|
|
|
(not RegPred:$c)))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
def rr_and_not_r_o
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".and.", regclsname,
|
|
|
|
"\t$p, $a, $b, !$c"),
|
|
|
|
[(set RegPred:$p, (and (setcc RC:$a, RC:$b, ocmp),
|
|
|
|
(not RegPred:$c)))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
def rr_or_not_r_u
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, "u.or.", regclsname,
|
|
|
|
"\t$p, $a, $b, !$c"),
|
|
|
|
[(set RegPred:$p, (or (setcc RC:$a, RC:$b, ucmp),
|
|
|
|
(not RegPred:$c)))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
def rr_or_not_r_o
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".or.", regclsname,
|
|
|
|
"\t$p, $a, $b, !$c"),
|
|
|
|
[(set RegPred:$p, (or (setcc RC:$a, RC:$b, ocmp),
|
|
|
|
(not RegPred:$c)))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
def rr_xor_not_r_u
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, "u.xor.", regclsname,
|
|
|
|
"\t$p, $a, $b, !$c"),
|
|
|
|
[(set RegPred:$p, (xor (setcc RC:$a, RC:$b, ucmp),
|
|
|
|
(not RegPred:$c)))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
def rr_xor_not_r_o
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$p), (ins RC:$a, RC:$b, RegPred:$c),
|
2011-09-23 22:18:24 +08:00
|
|
|
!strconcat("setp.", cmpstr, ".xor.", regclsname,
|
|
|
|
"\t$p, $a, $b, !$c"),
|
|
|
|
[(set RegPred:$p, (xor (setcc RC:$a, RC:$b, ocmp),
|
|
|
|
(not RegPred:$c)))]>;
|
2011-04-20 17:28:20 +08:00
|
|
|
}
|
|
|
|
|
2011-09-29 09:13:12 +08:00
|
|
|
multiclass PTX_SELP<RegisterClass RC, string regclsname, Operand immcls,
|
|
|
|
SDNode immnode> {
|
2011-04-28 08:19:55 +08:00
|
|
|
def rr
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RC:$r), (ins RegPred:$a, RC:$b, RC:$c),
|
2011-04-28 08:19:55 +08:00
|
|
|
!strconcat("selp.", regclsname, "\t$r, $b, $c, $a"),
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RC:$r, (select RegPred:$a, RC:$b, RC:$c))]>;
|
2011-09-29 09:13:12 +08:00
|
|
|
def ri
|
|
|
|
: InstPTX<(outs RC:$r), (ins RegPred:$a, RC:$b, immcls:$c),
|
|
|
|
!strconcat("selp.", regclsname, "\t$r, $b, $c, $a"),
|
|
|
|
[(set RC:$r, (select RegPred:$a, RC:$b, immnode:$c))]>;
|
|
|
|
def ii
|
|
|
|
: InstPTX<(outs RC:$r), (ins RegPred:$a, immcls:$b, immcls:$c),
|
|
|
|
!strconcat("selp.", regclsname, "\t$r, $b, $c, $a"),
|
|
|
|
[(set RC:$r, (select RegPred:$a, immnode:$b, immnode:$c))]>;
|
2011-04-28 08:19:55 +08:00
|
|
|
}
|
|
|
|
|
2011-09-27 00:20:28 +08:00
|
|
|
|
2011-03-02 11:20:28 +08:00
|
|
|
|
2010-09-19 02:52:28 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-03-14 19:26:01 +08:00
|
|
|
///===- Integer Arithmetic Instructions -----------------------------------===//
|
|
|
|
|
|
|
|
defm ADD : INT3<"add", add>;
|
|
|
|
defm SUB : INT3<"sub", sub>;
|
2011-03-15 21:24:15 +08:00
|
|
|
defm MUL : INT3<"mul.lo", mul>; // FIXME: Allow 32x32 -> 64 multiplies
|
2011-04-20 17:28:55 +08:00
|
|
|
defm DIV : INT3<"div", udiv>;
|
|
|
|
defm REM : INT3<"rem", urem>;
|
2011-03-14 19:26:01 +08:00
|
|
|
|
2011-02-28 14:34:09 +08:00
|
|
|
///===- Floating-Point Arithmetic Instructions ----------------------------===//
|
|
|
|
|
2011-04-28 08:19:53 +08:00
|
|
|
// Standard Unary Operations
|
|
|
|
defm FNEG : PTX_FLOAT_2OP<"neg", fneg>;
|
|
|
|
|
2011-03-11 00:57:18 +08:00
|
|
|
// Standard Binary Operations
|
2011-06-17 20:12:42 +08:00
|
|
|
defm FADD : PTX_FLOAT_3OP<"add.rn", fadd>;
|
|
|
|
defm FSUB : PTX_FLOAT_3OP<"sub.rn", fsub>;
|
|
|
|
defm FMUL : PTX_FLOAT_3OP<"mul.rn", fmul>;
|
|
|
|
|
|
|
|
// For floating-point division:
|
|
|
|
// SM_13+ defaults to .rn for f32 and f64,
|
|
|
|
// SM10 must *not* provide a rounding
|
|
|
|
|
2011-09-23 00:45:46 +08:00
|
|
|
// TODO:
|
2011-06-17 20:12:42 +08:00
|
|
|
// - Allow user selection of rounding modes for fdiv
|
|
|
|
// - Add support for -prec-div=false (.approx)
|
|
|
|
|
|
|
|
def FDIVrr32SM13 : InstPTX<(outs RegF32:$d),
|
2011-06-17 01:49:58 +08:00
|
|
|
(ins RegF32:$a, RegF32:$b),
|
2011-06-17 20:12:42 +08:00
|
|
|
"div.rn.f32\t$d, $a, $b",
|
|
|
|
[(set RegF32:$d, (fdiv RegF32:$a, RegF32:$b))]>,
|
2011-06-25 00:27:49 +08:00
|
|
|
Requires<[FDivNeedsRoundingMode]>;
|
2011-06-17 20:12:42 +08:00
|
|
|
def FDIVri32SM13 : InstPTX<(outs RegF32:$d),
|
2011-06-17 01:49:58 +08:00
|
|
|
(ins RegF32:$a, f32imm:$b),
|
2011-06-17 20:12:42 +08:00
|
|
|
"div.rn.f32\t$d, $a, $b",
|
|
|
|
[(set RegF32:$d, (fdiv RegF32:$a, fpimm:$b))]>,
|
2011-06-25 00:27:49 +08:00
|
|
|
Requires<[FDivNeedsRoundingMode]>;
|
2011-06-17 20:12:42 +08:00
|
|
|
def FDIVrr32SM10 : InstPTX<(outs RegF32:$d),
|
|
|
|
(ins RegF32:$a, RegF32:$b),
|
|
|
|
"div.f32\t$d, $a, $b",
|
|
|
|
[(set RegF32:$d, (fdiv RegF32:$a, RegF32:$b))]>,
|
2011-06-25 00:27:49 +08:00
|
|
|
Requires<[FDivNoRoundingMode]>;
|
2011-06-17 20:12:42 +08:00
|
|
|
def FDIVri32SM10 : InstPTX<(outs RegF32:$d),
|
|
|
|
(ins RegF32:$a, f32imm:$b),
|
|
|
|
"div.f32\t$d, $a, $b",
|
|
|
|
[(set RegF32:$d, (fdiv RegF32:$a, fpimm:$b))]>,
|
2011-06-25 00:27:49 +08:00
|
|
|
Requires<[FDivNoRoundingMode]>;
|
2011-03-11 00:57:18 +08:00
|
|
|
|
2011-06-17 01:49:58 +08:00
|
|
|
def FDIVrr64SM13 : InstPTX<(outs RegF64:$d),
|
|
|
|
(ins RegF64:$a, RegF64:$b),
|
2011-03-11 00:57:18 +08:00
|
|
|
"div.rn.f64\t$d, $a, $b",
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (fdiv RegF64:$a, RegF64:$b))]>,
|
2011-06-25 00:27:49 +08:00
|
|
|
Requires<[FDivNeedsRoundingMode]>;
|
2011-06-17 01:49:58 +08:00
|
|
|
def FDIVri64SM13 : InstPTX<(outs RegF64:$d),
|
|
|
|
(ins RegF64:$a, f64imm:$b),
|
2011-03-11 00:57:18 +08:00
|
|
|
"div.rn.f64\t$d, $a, $b",
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (fdiv RegF64:$a, fpimm:$b))]>,
|
2011-06-25 00:27:49 +08:00
|
|
|
Requires<[FDivNeedsRoundingMode]>;
|
2011-06-17 01:49:58 +08:00
|
|
|
def FDIVrr64SM10 : InstPTX<(outs RegF64:$d),
|
|
|
|
(ins RegF64:$a, RegF64:$b),
|
2011-03-11 00:57:18 +08:00
|
|
|
"div.f64\t$d, $a, $b",
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (fdiv RegF64:$a, RegF64:$b))]>,
|
2011-06-25 00:27:49 +08:00
|
|
|
Requires<[FDivNoRoundingMode]>;
|
2011-06-17 01:49:58 +08:00
|
|
|
def FDIVri64SM10 : InstPTX<(outs RegF64:$d),
|
|
|
|
(ins RegF64:$a, f64imm:$b),
|
2011-03-11 00:57:18 +08:00
|
|
|
"div.f64\t$d, $a, $b",
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (fdiv RegF64:$a, fpimm:$b))]>,
|
2011-06-25 00:27:49 +08:00
|
|
|
Requires<[FDivNoRoundingMode]>;
|
2011-03-11 00:57:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Multi-operation hybrid instructions
|
|
|
|
|
|
|
|
// The selection of mad/fma is tricky. In some cases, they are the *same*
|
|
|
|
// instruction, but in other cases we may prefer one or the other. Also,
|
|
|
|
// different PTX versions differ on whether rounding mode flags are required.
|
|
|
|
// In the short term, mad is supported on all PTX versions and we use a
|
|
|
|
// default rounding mode no matter what shader model or PTX version.
|
|
|
|
// TODO: Allow the rounding mode to be selectable through llc.
|
2011-06-25 00:27:49 +08:00
|
|
|
defm FMADSM13 : PTX_FLOAT_4OP<"mad.rn", fmul, fadd>,
|
|
|
|
Requires<[FMadNeedsRoundingMode, SupportsFMA]>;
|
|
|
|
defm FMAD : PTX_FLOAT_4OP<"mad", fmul, fadd>,
|
|
|
|
Requires<[FMadNoRoundingMode, SupportsFMA]>;
|
2011-03-11 00:57:18 +08:00
|
|
|
|
2011-03-14 22:09:33 +08:00
|
|
|
///===- Floating-Point Intrinsic Instructions -----------------------------===//
|
|
|
|
|
2011-06-17 01:49:58 +08:00
|
|
|
def FSQRT32 : InstPTX<(outs RegF32:$d),
|
|
|
|
(ins RegF32:$a),
|
2011-03-14 22:09:33 +08:00
|
|
|
"sqrt.rn.f32\t$d, $a",
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF32:$d, (fsqrt RegF32:$a))]>;
|
2011-03-14 22:09:33 +08:00
|
|
|
|
2011-06-17 01:49:58 +08:00
|
|
|
def FSQRT64 : InstPTX<(outs RegF64:$d),
|
|
|
|
(ins RegF64:$a),
|
2011-03-14 22:09:33 +08:00
|
|
|
"sqrt.rn.f64\t$d, $a",
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (fsqrt RegF64:$a))]>;
|
2011-03-14 22:09:33 +08:00
|
|
|
|
2011-06-17 01:49:58 +08:00
|
|
|
def FSIN32 : InstPTX<(outs RegF32:$d),
|
|
|
|
(ins RegF32:$a),
|
2011-03-14 22:09:33 +08:00
|
|
|
"sin.approx.f32\t$d, $a",
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF32:$d, (fsin RegF32:$a))]>;
|
2011-03-14 22:09:33 +08:00
|
|
|
|
2011-06-17 01:49:58 +08:00
|
|
|
def FSIN64 : InstPTX<(outs RegF64:$d),
|
|
|
|
(ins RegF64:$a),
|
2011-03-14 22:09:33 +08:00
|
|
|
"sin.approx.f64\t$d, $a",
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (fsin RegF64:$a))]>;
|
2011-03-14 22:09:33 +08:00
|
|
|
|
2011-06-17 01:49:58 +08:00
|
|
|
def FCOS32 : InstPTX<(outs RegF32:$d),
|
|
|
|
(ins RegF32:$a),
|
2011-03-14 22:09:33 +08:00
|
|
|
"cos.approx.f32\t$d, $a",
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF32:$d, (fcos RegF32:$a))]>;
|
2011-03-14 22:09:33 +08:00
|
|
|
|
2011-06-17 01:49:58 +08:00
|
|
|
def FCOS64 : InstPTX<(outs RegF64:$d),
|
|
|
|
(ins RegF64:$a),
|
2011-03-14 22:09:33 +08:00
|
|
|
"cos.approx.f64\t$d, $a",
|
2011-06-17 01:49:58 +08:00
|
|
|
[(set RegF64:$d, (fcos RegF64:$a))]>;
|
2011-03-14 22:09:33 +08:00
|
|
|
|
|
|
|
|
2011-03-14 19:26:01 +08:00
|
|
|
///===- Comparison and Selection Instructions -----------------------------===//
|
2011-03-11 00:57:18 +08:00
|
|
|
|
2011-05-18 23:42:23 +08:00
|
|
|
// .setp
|
|
|
|
|
2011-04-20 17:28:20 +08:00
|
|
|
// Compare u16
|
|
|
|
|
2011-06-17 01:49:58 +08:00
|
|
|
defm SETPEQu16 : PTX_SETP_I<RegI16, "u16", i16imm, SETEQ, "eq">;
|
|
|
|
defm SETPNEu16 : PTX_SETP_I<RegI16, "u16", i16imm, SETNE, "ne">;
|
|
|
|
defm SETPLTu16 : PTX_SETP_I<RegI16, "u16", i16imm, SETULT, "lt">;
|
|
|
|
defm SETPLEu16 : PTX_SETP_I<RegI16, "u16", i16imm, SETULE, "le">;
|
|
|
|
defm SETPGTu16 : PTX_SETP_I<RegI16, "u16", i16imm, SETUGT, "gt">;
|
|
|
|
defm SETPGEu16 : PTX_SETP_I<RegI16, "u16", i16imm, SETUGE, "ge">;
|
2011-06-22 10:09:50 +08:00
|
|
|
defm SETPLTs16 : PTX_SETP_I<RegI16, "s16", i16imm, SETLT, "lt">;
|
|
|
|
defm SETPLEs16 : PTX_SETP_I<RegI16, "s16", i16imm, SETLE, "le">;
|
|
|
|
defm SETPGTs16 : PTX_SETP_I<RegI16, "s16", i16imm, SETGT, "gt">;
|
|
|
|
defm SETPGEs16 : PTX_SETP_I<RegI16, "s16", i16imm, SETGE, "ge">;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
// Compare u32
|
|
|
|
|
2011-06-17 01:49:58 +08:00
|
|
|
defm SETPEQu32 : PTX_SETP_I<RegI32, "u32", i32imm, SETEQ, "eq">;
|
|
|
|
defm SETPNEu32 : PTX_SETP_I<RegI32, "u32", i32imm, SETNE, "ne">;
|
|
|
|
defm SETPLTu32 : PTX_SETP_I<RegI32, "u32", i32imm, SETULT, "lt">;
|
|
|
|
defm SETPLEu32 : PTX_SETP_I<RegI32, "u32", i32imm, SETULE, "le">;
|
|
|
|
defm SETPGTu32 : PTX_SETP_I<RegI32, "u32", i32imm, SETUGT, "gt">;
|
|
|
|
defm SETPGEu32 : PTX_SETP_I<RegI32, "u32", i32imm, SETUGE, "ge">;
|
2011-06-22 10:09:50 +08:00
|
|
|
defm SETPLTs32 : PTX_SETP_I<RegI32, "s32", i32imm, SETLT, "lt">;
|
|
|
|
defm SETPLEs32 : PTX_SETP_I<RegI32, "s32", i32imm, SETLE, "le">;
|
|
|
|
defm SETPGTs32 : PTX_SETP_I<RegI32, "s32", i32imm, SETGT, "gt">;
|
|
|
|
defm SETPGEs32 : PTX_SETP_I<RegI32, "s32", i32imm, SETGE, "ge">;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
// Compare u64
|
|
|
|
|
2011-06-17 01:49:58 +08:00
|
|
|
defm SETPEQu64 : PTX_SETP_I<RegI64, "u64", i64imm, SETEQ, "eq">;
|
|
|
|
defm SETPNEu64 : PTX_SETP_I<RegI64, "u64", i64imm, SETNE, "ne">;
|
|
|
|
defm SETPLTu64 : PTX_SETP_I<RegI64, "u64", i64imm, SETULT, "lt">;
|
|
|
|
defm SETPLEu64 : PTX_SETP_I<RegI64, "u64", i64imm, SETULE, "le">;
|
|
|
|
defm SETPGTu64 : PTX_SETP_I<RegI64, "u64", i64imm, SETUGT, "gt">;
|
|
|
|
defm SETPGEu64 : PTX_SETP_I<RegI64, "u64", i64imm, SETUGE, "ge">;
|
2011-06-22 10:09:50 +08:00
|
|
|
defm SETPLTs64 : PTX_SETP_I<RegI64, "s64", i64imm, SETLT, "lt">;
|
|
|
|
defm SETPLEs64 : PTX_SETP_I<RegI64, "s64", i64imm, SETLE, "le">;
|
|
|
|
defm SETPGTs64 : PTX_SETP_I<RegI64, "s64", i64imm, SETGT, "gt">;
|
|
|
|
defm SETPGEs64 : PTX_SETP_I<RegI64, "s64", i64imm, SETGE, "ge">;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
// Compare f32
|
|
|
|
|
2011-09-29 09:13:12 +08:00
|
|
|
defm SETPEQf32 : PTX_SETP_FP<RegF32, "f32", f32imm, SETUEQ, SETOEQ, "eq">;
|
|
|
|
defm SETPNEf32 : PTX_SETP_FP<RegF32, "f32", f32imm, SETUNE, SETONE, "ne">;
|
|
|
|
defm SETPLTf32 : PTX_SETP_FP<RegF32, "f32", f32imm, SETULT, SETOLT, "lt">;
|
|
|
|
defm SETPLEf32 : PTX_SETP_FP<RegF32, "f32", f32imm, SETULE, SETOLE, "le">;
|
|
|
|
defm SETPGTf32 : PTX_SETP_FP<RegF32, "f32", f32imm, SETUGT, SETOGT, "gt">;
|
|
|
|
defm SETPGEf32 : PTX_SETP_FP<RegF32, "f32", f32imm, SETUGE, SETOGE, "ge">;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
// Compare f64
|
|
|
|
|
2011-09-29 09:13:12 +08:00
|
|
|
defm SETPEQf64 : PTX_SETP_FP<RegF64, "f64", f64imm, SETUEQ, SETOEQ, "eq">;
|
|
|
|
defm SETPNEf64 : PTX_SETP_FP<RegF64, "f64", f64imm, SETUNE, SETONE, "ne">;
|
|
|
|
defm SETPLTf64 : PTX_SETP_FP<RegF64, "f64", f64imm, SETULT, SETOLT, "lt">;
|
|
|
|
defm SETPLEf64 : PTX_SETP_FP<RegF64, "f64", f64imm, SETULE, SETOLE, "le">;
|
|
|
|
defm SETPGTf64 : PTX_SETP_FP<RegF64, "f64", f64imm, SETUGT, SETOGT, "gt">;
|
|
|
|
defm SETPGEf64 : PTX_SETP_FP<RegF64, "f64", f64imm, SETUGE, SETOGE, "ge">;
|
2010-11-17 16:08:49 +08:00
|
|
|
|
2011-04-28 08:19:55 +08:00
|
|
|
// .selp
|
|
|
|
|
2011-09-29 09:13:12 +08:00
|
|
|
defm SELPi16 : PTX_SELP<RegI16, "u16", i16imm, imm>;
|
|
|
|
defm SELPi32 : PTX_SELP<RegI32, "u32", i32imm, imm>;
|
|
|
|
defm SELPi64 : PTX_SELP<RegI64, "u64", i64imm, imm>;
|
|
|
|
defm SELPf32 : PTX_SELP<RegF32, "f32", f32imm, fpimm>;
|
|
|
|
defm SELPf64 : PTX_SELP<RegF64, "f64", f64imm, fpimm>;
|
2011-04-28 08:19:55 +08:00
|
|
|
|
2010-12-06 12:00:03 +08:00
|
|
|
///===- Logic and Shift Instructions --------------------------------------===//
|
|
|
|
|
2011-03-24 00:58:51 +08:00
|
|
|
defm SHL : INT3ntnc<"shl.b", PTXshl>;
|
|
|
|
defm SRL : INT3ntnc<"shr.u", PTXsrl>;
|
|
|
|
defm SRA : INT3ntnc<"shr.s", PTXsra>;
|
2010-12-06 12:00:03 +08:00
|
|
|
|
2011-03-15 21:24:15 +08:00
|
|
|
defm AND : PTX_LOGIC<"and", and>;
|
|
|
|
defm OR : PTX_LOGIC<"or", or>;
|
|
|
|
defm XOR : PTX_LOGIC<"xor", xor>;
|
|
|
|
|
2010-10-19 21:14:40 +08:00
|
|
|
///===- Data Movement and Conversion Instructions -------------------------===//
|
|
|
|
|
2011-09-29 09:13:12 +08:00
|
|
|
// any_extend
|
|
|
|
// Implement the anyext instruction in terms of the PTX cvt instructions.
|
|
|
|
//def : Pat<(i32 (anyext RegI16:$a)), (CVT_u32_u16 RegI16:$a)>;
|
|
|
|
//def : Pat<(i64 (anyext RegI16:$a)), (CVT_u64_u16 RegI16:$a)>;
|
|
|
|
//def : Pat<(i64 (anyext RegI32:$a)), (CVT_u64_u32 RegI32:$a)>;
|
|
|
|
|
|
|
|
// bitconvert
|
|
|
|
// These instructions implement the bit-wise conversion between integer and
|
|
|
|
// floating-point types.
|
|
|
|
def MOVi32f32
|
|
|
|
: InstPTX<(outs RegI32:$d), (ins RegF32:$a), "mov.b32\t$d, $a", []>;
|
|
|
|
def MOVf32i32
|
|
|
|
: InstPTX<(outs RegF32:$d), (ins RegI32:$a), "mov.b32\t$d, $a", []>;
|
|
|
|
def MOVi64f64
|
|
|
|
: InstPTX<(outs RegI64:$d), (ins RegF64:$a), "mov.b64\t$d, $a", []>;
|
|
|
|
def MOVf64i64
|
|
|
|
: InstPTX<(outs RegF64:$d), (ins RegI64:$a), "mov.b64\t$d, $a", []>;
|
|
|
|
|
2010-10-19 21:14:40 +08:00
|
|
|
let neverHasSideEffects = 1 in {
|
2011-03-02 11:20:28 +08:00
|
|
|
def MOVPREDrr
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$d), (ins RegPred:$a), "mov.pred\t$d, $a", []>;
|
2011-03-02 11:20:28 +08:00
|
|
|
def MOVU16rr
|
2011-06-26 02:16:28 +08:00
|
|
|
: InstPTX<(outs RegI16:$d), (ins RegI16:$a), "mov.u16\t$d, $a", []>;
|
2011-03-02 11:20:28 +08:00
|
|
|
def MOVU32rr
|
2011-06-26 02:16:28 +08:00
|
|
|
: InstPTX<(outs RegI32:$d), (ins RegI32:$a), "mov.u32\t$d, $a", []>;
|
2011-03-02 11:20:28 +08:00
|
|
|
def MOVU64rr
|
2011-06-26 02:16:28 +08:00
|
|
|
: InstPTX<(outs RegI64:$d), (ins RegI64:$a), "mov.u64\t$d, $a", []>;
|
2011-03-02 11:20:28 +08:00
|
|
|
def MOVF32rr
|
2011-06-26 02:16:28 +08:00
|
|
|
: InstPTX<(outs RegF32:$d), (ins RegF32:$a), "mov.f32\t$d, $a", []>;
|
2011-03-02 11:20:28 +08:00
|
|
|
def MOVF64rr
|
2011-06-26 02:16:28 +08:00
|
|
|
: InstPTX<(outs RegF64:$d), (ins RegF64:$a), "mov.f64\t$d, $a", []>;
|
2010-10-19 21:14:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
|
2011-03-02 11:20:28 +08:00
|
|
|
def MOVPREDri
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegPred:$d), (ins i1imm:$a), "mov.pred\t$d, $a",
|
|
|
|
[(set RegPred:$d, imm:$a)]>;
|
2011-03-02 11:20:28 +08:00
|
|
|
def MOVU16ri
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegI16:$d), (ins i16imm:$a), "mov.u16\t$d, $a",
|
|
|
|
[(set RegI16:$d, imm:$a)]>;
|
2011-03-02 11:20:28 +08:00
|
|
|
def MOVU32ri
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegI32:$d), (ins i32imm:$a), "mov.u32\t$d, $a",
|
|
|
|
[(set RegI32:$d, imm:$a)]>;
|
2011-04-28 08:19:54 +08:00
|
|
|
def MOVU64ri
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegI64:$d), (ins i64imm:$a), "mov.u64\t$d, $a",
|
|
|
|
[(set RegI64:$d, imm:$a)]>;
|
2011-03-02 11:20:28 +08:00
|
|
|
def MOVF32ri
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegF32:$d), (ins f32imm:$a), "mov.f32\t$d, $a",
|
|
|
|
[(set RegF32:$d, fpimm:$a)]>;
|
2011-03-02 11:20:28 +08:00
|
|
|
def MOVF64ri
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegF64:$d), (ins f64imm:$a), "mov.f64\t$d, $a",
|
|
|
|
[(set RegF64:$d, fpimm:$a)]>;
|
2010-10-19 21:14:40 +08:00
|
|
|
}
|
|
|
|
|
2011-03-19 03:24:28 +08:00
|
|
|
let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
|
2011-03-24 00:58:51 +08:00
|
|
|
def MOVaddr32
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegI32:$d), (ins i32imm:$a), "mov.u32\t$d, $a",
|
|
|
|
[(set RegI32:$d, (PTXcopyaddress tglobaladdr:$a))]>;
|
2011-03-24 00:58:51 +08:00
|
|
|
def MOVaddr64
|
2011-06-17 01:49:58 +08:00
|
|
|
: InstPTX<(outs RegI64:$d), (ins i64imm:$a), "mov.u64\t$d, $a",
|
|
|
|
[(set RegI64:$d, (PTXcopyaddress tglobaladdr:$a))]>;
|
2011-03-19 03:24:28 +08:00
|
|
|
}
|
|
|
|
|
2011-09-29 09:13:12 +08:00
|
|
|
// PTX cvt instructions
|
|
|
|
// Note all of these may actually be used, we just define all possible patterns
|
|
|
|
// here.
|
|
|
|
|
|
|
|
// To i16
|
|
|
|
def CVTu16u32
|
|
|
|
: InstPTX<(outs RegI16:$d), (ins RegI32:$a), "cvt.u16.u32\t$d, $a", []>;
|
|
|
|
def CVTu16u64
|
|
|
|
: InstPTX<(outs RegI16:$d), (ins RegI64:$a), "cvt.u16.u64\t$d, $a", []>;
|
|
|
|
def CVTu16f32
|
|
|
|
: InstPTX<(outs RegI16:$d), (ins RegF32:$a), "cvt.rzi.u16.f32\t$d, $a", []>;
|
|
|
|
def CVTs16f32
|
|
|
|
: InstPTX<(outs RegI16:$d), (ins RegF32:$a), "cvt.rzi.s16.f32\t$d, $a", []>;
|
|
|
|
def CVTu16f64
|
|
|
|
: InstPTX<(outs RegI16:$d), (ins RegF64:$a), "cvt.rzi.u16.f64\t$d, $a", []>;
|
|
|
|
def CVTs16f64
|
|
|
|
: InstPTX<(outs RegI16:$d), (ins RegF64:$a), "cvt.rzi.s16.f64\t$d, $a", []>;
|
|
|
|
|
|
|
|
// To i32
|
|
|
|
def CVTu32u16
|
|
|
|
: InstPTX<(outs RegI32:$d), (ins RegI16:$a), "cvt.u32.u16\t$d, $a", []>;
|
|
|
|
def CVTs32s16
|
|
|
|
: InstPTX<(outs RegI32:$d), (ins RegI16:$a), "cvt.s32.s16\t$d, $a", []>;
|
|
|
|
def CVTu32u64
|
|
|
|
: InstPTX<(outs RegI32:$d), (ins RegI64:$a), "cvt.u32.u64\t$d, $a", []>;
|
|
|
|
def CVTu32f32
|
|
|
|
: InstPTX<(outs RegI32:$d), (ins RegF32:$a), "cvt.rzi.u32.f32\t$d, $a", []>;
|
|
|
|
def CVTs32f32
|
|
|
|
: InstPTX<(outs RegI32:$d), (ins RegF32:$a), "cvt.rzi.s32.f32\t$d, $a", []>;
|
|
|
|
def CVTu32f64
|
|
|
|
: InstPTX<(outs RegI32:$d), (ins RegF64:$a), "cvt.rzi.u32.f64\t$d, $a", []>;
|
|
|
|
def CVTs32f64
|
|
|
|
: InstPTX<(outs RegI32:$d), (ins RegF64:$a), "cvt.rzi.s32.f64\t$d, $a", []>;
|
|
|
|
|
|
|
|
// To i64
|
|
|
|
def CVTu64u16
|
|
|
|
: InstPTX<(outs RegI64:$d), (ins RegI16:$a), "cvt.u64.u16\t$d, $a", []>;
|
|
|
|
def CVTs64s16
|
|
|
|
: InstPTX<(outs RegI64:$d), (ins RegI16:$a), "cvt.s64.s16\t$d, $a", []>;
|
|
|
|
def CVTu64u32
|
|
|
|
: InstPTX<(outs RegI64:$d), (ins RegI32:$a), "cvt.u64.u32\t$d, $a", []>;
|
|
|
|
def CVTs64s32
|
|
|
|
: InstPTX<(outs RegI64:$d), (ins RegI32:$a), "cvt.s64.s32\t$d, $a", []>;
|
|
|
|
def CVTu64f32
|
|
|
|
: InstPTX<(outs RegI64:$d), (ins RegF32:$a), "cvt.rzi.u64.f32\t$d, $a", []>;
|
|
|
|
def CVTs64f32
|
|
|
|
: InstPTX<(outs RegI64:$d), (ins RegF32:$a), "cvt.rzi.s64.f32\t$d, $a", []>;
|
|
|
|
def CVTu64f64
|
|
|
|
: InstPTX<(outs RegI64:$d), (ins RegF64:$a), "cvt.rzi.u64.f64\t$d, $a", []>;
|
|
|
|
def CVTs64f64
|
|
|
|
: InstPTX<(outs RegI64:$d), (ins RegF64:$a), "cvt.rzi.s64.f64\t$d, $a", []>;
|
|
|
|
|
|
|
|
// To f32
|
|
|
|
def CVTf32u16
|
|
|
|
: InstPTX<(outs RegF32:$d), (ins RegI16:$a), "cvt.rn.f32.u16\t$d, $a", []>;
|
|
|
|
def CVTf32s16
|
|
|
|
: InstPTX<(outs RegF32:$d), (ins RegI16:$a), "cvt.rn.f32.s16\t$d, $a", []>;
|
|
|
|
def CVTf32u32
|
|
|
|
: InstPTX<(outs RegF32:$d), (ins RegI32:$a), "cvt.rn.f32.u32\t$d, $a", []>;
|
|
|
|
def CVTf32s32
|
|
|
|
: InstPTX<(outs RegF32:$d), (ins RegI32:$a), "cvt.rn.f32.s32\t$d, $a", []>;
|
|
|
|
def CVTf32u64
|
|
|
|
: InstPTX<(outs RegF32:$d), (ins RegI64:$a), "cvt.rn.f32.u64\t$d, $a", []>;
|
|
|
|
def CVTf32s64
|
|
|
|
: InstPTX<(outs RegF32:$d), (ins RegI64:$a), "cvt.rn.f32.s64\t$d, $a", []>;
|
|
|
|
def CVTf32f64
|
|
|
|
: InstPTX<(outs RegF32:$d), (ins RegF64:$a), "cvt.rn.f32.f64\t$d, $a", []>;
|
|
|
|
|
|
|
|
// To f64
|
|
|
|
def CVTf64u16
|
|
|
|
: InstPTX<(outs RegF64:$d), (ins RegI16:$a), "cvt.rn.f64.u16\t$d, $a", []>;
|
|
|
|
def CVTf64s16
|
|
|
|
: InstPTX<(outs RegF64:$d), (ins RegI16:$a), "cvt.rn.f64.s16\t$d, $a", []>;
|
|
|
|
def CVTf64u32
|
|
|
|
: InstPTX<(outs RegF64:$d), (ins RegI32:$a), "cvt.rn.f64.u32\t$d, $a", []>;
|
|
|
|
def CVTf64s32
|
|
|
|
: InstPTX<(outs RegF64:$d), (ins RegI32:$a), "cvt.rn.f64.s32\t$d, $a", []>;
|
|
|
|
def CVTf64u64
|
|
|
|
: InstPTX<(outs RegF64:$d), (ins RegI64:$a), "cvt.rn.f64.u64\t$d, $a", []>;
|
|
|
|
def CVTf64s64
|
|
|
|
: InstPTX<(outs RegF64:$d), (ins RegI64:$a), "cvt.rn.f64.s64\t$d, $a", []>;
|
|
|
|
def CVTf64f32
|
|
|
|
: InstPTX<(outs RegF64:$d), (ins RegF32:$a), "cvt.f64.f32\t$d, $a", []>;
|
|
|
|
|
|
|
|
|
|
|
|
// Type conversion notes:
|
|
|
|
// - PTX does not directly support converting a predicate to a value, so we
|
|
|
|
// use a select instruction to select either 0 or 1 (integer or fp) based
|
|
|
|
// on the truth value of the predicate.
|
|
|
|
// - PTX does not directly support converting to a predicate type, so we fake it
|
|
|
|
// by performing a greater-than test between the value and zero. This follows
|
|
|
|
// the C convention that any non-zero value is equivalent to 'true'.
|
2011-02-28 14:34:09 +08:00
|
|
|
|
2011-04-20 17:28:20 +08:00
|
|
|
// Conversion to pred
|
2011-09-29 09:13:12 +08:00
|
|
|
def : Pat<(i1 (trunc RegI16:$a)), (SETPGTu16ri RegI16:$a, 0)>;
|
|
|
|
def : Pat<(i1 (trunc RegI32:$a)), (SETPGTu32ri RegI32:$a, 0)>;
|
|
|
|
def : Pat<(i1 (trunc RegI64:$a)), (SETPGTu64ri RegI64:$a, 0)>;
|
|
|
|
def : Pat<(i1 (fp_to_uint RegF32:$a)), (SETPGTu32ri (MOVi32f32 RegF32:$a), 0)>;
|
|
|
|
def : Pat<(i1 (fp_to_uint RegF64:$a)), (SETPGTu64ri (MOVi64f64 RegF64:$a), 0)>;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
// Conversion to u16
|
2011-09-29 09:13:12 +08:00
|
|
|
def : Pat<(i16 (anyext RegPred:$a)), (SELPi16ii RegPred:$a, 1, 0)>;
|
|
|
|
def : Pat<(i16 (sext RegPred:$a)), (SELPi16ii RegPred:$a, 0xFFFF, 0)>;
|
|
|
|
def : Pat<(i16 (zext RegPred:$a)), (SELPi16ii RegPred:$a, 1, 0)>;
|
|
|
|
def : Pat<(i16 (trunc RegI32:$a)), (CVTu16u32 RegI32:$a)>;
|
|
|
|
def : Pat<(i16 (trunc RegI64:$a)), (CVTu16u64 RegI64:$a)>;
|
|
|
|
def : Pat<(i16 (fp_to_uint RegF32:$a)), (CVTu16f32 RegF32:$a)>;
|
|
|
|
def : Pat<(i16 (fp_to_sint RegF32:$a)), (CVTs16f32 RegF32:$a)>;
|
|
|
|
def : Pat<(i16 (fp_to_uint RegF64:$a)), (CVTu16f64 RegF64:$a)>;
|
|
|
|
def : Pat<(i16 (fp_to_sint RegF64:$a)), (CVTs16f64 RegF64:$a)>;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
// Conversion to u32
|
2011-09-29 09:13:12 +08:00
|
|
|
def : Pat<(i32 (anyext RegPred:$a)), (SELPi32ii RegPred:$a, 1, 0)>;
|
|
|
|
def : Pat<(i32 (sext RegPred:$a)), (SELPi32ii RegPred:$a, 0xFFFFFFFF, 0)>;
|
|
|
|
def : Pat<(i32 (zext RegPred:$a)), (SELPi32ii RegPred:$a, 1, 0)>;
|
|
|
|
def : Pat<(i32 (anyext RegI16:$a)), (CVTu32u16 RegI16:$a)>;
|
|
|
|
def : Pat<(i32 (sext RegI16:$a)), (CVTs32s16 RegI16:$a)>;
|
|
|
|
def : Pat<(i32 (zext RegI16:$a)), (CVTu32u16 RegI16:$a)>;
|
|
|
|
def : Pat<(i32 (trunc RegI64:$a)), (CVTu32u64 RegI64:$a)>;
|
|
|
|
def : Pat<(i32 (fp_to_uint RegF32:$a)), (CVTu32f32 RegF32:$a)>;
|
|
|
|
def : Pat<(i32 (fp_to_sint RegF32:$a)), (CVTs32f32 RegF32:$a)>;
|
|
|
|
def : Pat<(i32 (fp_to_uint RegF64:$a)), (CVTu32f64 RegF64:$a)>;
|
|
|
|
def : Pat<(i32 (fp_to_sint RegF64:$a)), (CVTs32f64 RegF64:$a)>;
|
|
|
|
def : Pat<(i32 (bitconvert RegF32:$a)), (MOVi32f32 RegF32:$a)>;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
// Conversion to u64
|
2011-09-29 09:13:12 +08:00
|
|
|
def : Pat<(i64 (anyext RegPred:$a)), (SELPi64ii RegPred:$a, 1, 0)>;
|
|
|
|
def : Pat<(i64 (sext RegPred:$a)), (SELPi64ii RegPred:$a,
|
|
|
|
0xFFFFFFFFFFFFFFFF, 0)>;
|
|
|
|
def : Pat<(i64 (zext RegPred:$a)), (SELPi64ii RegPred:$a, 1, 0)>;
|
|
|
|
def : Pat<(i64 (anyext RegI16:$a)), (CVTu64u16 RegI16:$a)>;
|
|
|
|
def : Pat<(i64 (sext RegI16:$a)), (CVTs64s16 RegI16:$a)>;
|
|
|
|
def : Pat<(i64 (zext RegI16:$a)), (CVTu64u16 RegI16:$a)>;
|
|
|
|
def : Pat<(i64 (anyext RegI32:$a)), (CVTu64u32 RegI32:$a)>;
|
|
|
|
def : Pat<(i64 (sext RegI32:$a)), (CVTs64s32 RegI32:$a)>;
|
|
|
|
def : Pat<(i64 (zext RegI32:$a)), (CVTu64u32 RegI32:$a)>;
|
|
|
|
def : Pat<(i64 (fp_to_uint RegF32:$a)), (CVTu64f32 RegF32:$a)>;
|
|
|
|
def : Pat<(i64 (fp_to_sint RegF32:$a)), (CVTs64f32 RegF32:$a)>;
|
|
|
|
def : Pat<(i64 (fp_to_uint RegF64:$a)), (CVTu64f64 RegF64:$a)>;
|
|
|
|
def : Pat<(i64 (fp_to_sint RegF64:$a)), (CVTs64f64 RegF64:$a)>;
|
|
|
|
def : Pat<(i64 (bitconvert RegF64:$a)), (MOVi64f64 RegF64:$a)>;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
|
|
|
// Conversion to f32
|
2011-09-29 09:13:12 +08:00
|
|
|
def : Pat<(f32 (uint_to_fp RegPred:$a)), (SELPf32rr RegPred:$a,
|
|
|
|
(MOVf32i32 0x3F800000), (MOVf32i32 0))>;
|
|
|
|
def : Pat<(f32 (uint_to_fp RegI16:$a)), (CVTf32u16 RegI16:$a)>;
|
|
|
|
def : Pat<(f32 (sint_to_fp RegI16:$a)), (CVTf32s16 RegI16:$a)>;
|
|
|
|
def : Pat<(f32 (uint_to_fp RegI32:$a)), (CVTf32u32 RegI32:$a)>;
|
|
|
|
def : Pat<(f32 (sint_to_fp RegI32:$a)), (CVTf32s32 RegI32:$a)>;
|
|
|
|
def : Pat<(f32 (uint_to_fp RegI64:$a)), (CVTf32u64 RegI64:$a)>;
|
|
|
|
def : Pat<(f32 (sint_to_fp RegI64:$a)), (CVTf32s64 RegI64:$a)>;
|
|
|
|
def : Pat<(f32 (fround RegF64:$a)), (CVTf32f64 RegF64:$a)>;
|
|
|
|
def : Pat<(f32 (bitconvert RegI32:$a)), (MOVf32i32 RegI32:$a)>;
|
2011-09-27 09:04:47 +08:00
|
|
|
|
2011-04-20 17:28:20 +08:00
|
|
|
// Conversion to f64
|
2011-09-29 09:13:12 +08:00
|
|
|
def : Pat<(f64 (uint_to_fp RegPred:$a)), (SELPf64rr RegPred:$a,
|
|
|
|
(MOVf64i64 0x3F80000000000000), (MOVf64i64 0))>;
|
|
|
|
def : Pat<(f64 (uint_to_fp RegI16:$a)), (CVTf64u16 RegI16:$a)>;
|
|
|
|
def : Pat<(f64 (sint_to_fp RegI16:$a)), (CVTf64s16 RegI16:$a)>;
|
|
|
|
def : Pat<(f64 (uint_to_fp RegI32:$a)), (CVTf64u32 RegI32:$a)>;
|
|
|
|
def : Pat<(f64 (sint_to_fp RegI32:$a)), (CVTf64s32 RegI32:$a)>;
|
|
|
|
def : Pat<(f64 (uint_to_fp RegI64:$a)), (CVTf64u64 RegI64:$a)>;
|
|
|
|
def : Pat<(f64 (sint_to_fp RegI64:$a)), (CVTf64s64 RegI64:$a)>;
|
|
|
|
def : Pat<(f64 (fextend RegF32:$a)), (CVTf64f32 RegF32:$a)>;
|
|
|
|
def : Pat<(f64 (bitconvert RegI64:$a)), (MOVf64i64 RegI64:$a)>;
|
2011-04-20 17:28:20 +08:00
|
|
|
|
2011-09-27 02:57:24 +08:00
|
|
|
|
2010-10-19 21:14:40 +08:00
|
|
|
///===- Control Flow Instructions -----------------------------------------===//
|
|
|
|
|
2011-03-22 22:12:00 +08:00
|
|
|
let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
|
2011-03-18 19:08:52 +08:00
|
|
|
def BRAd
|
|
|
|
: InstPTX<(outs), (ins brtarget:$d), "bra\t$d", [(br bb:$d)]>;
|
2011-03-22 22:12:00 +08:00
|
|
|
}
|
2011-03-18 19:08:52 +08:00
|
|
|
|
2011-03-22 22:12:00 +08:00
|
|
|
let isBranch = 1, isTerminator = 1 in {
|
2011-03-28 18:23:13 +08:00
|
|
|
// FIXME: The pattern part is blank because I cannot (or do not yet know
|
2011-06-17 01:49:58 +08:00
|
|
|
// how to) use the first operand of PredicateOperand (a RegPred register) here
|
2011-03-18 19:08:52 +08:00
|
|
|
def BRAdp
|
|
|
|
: InstPTX<(outs), (ins brtarget:$d), "bra\t$d",
|
2011-03-28 18:23:13 +08:00
|
|
|
[/*(brcond pred:$_p, bb:$d)*/]>;
|
2011-03-18 19:08:52 +08:00
|
|
|
}
|
|
|
|
|
2010-09-19 02:52:28 +08:00
|
|
|
let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
|
|
|
|
def EXIT : InstPTX<(outs), (ins), "exit", [(PTXexit)]>;
|
2010-09-25 15:46:17 +08:00
|
|
|
def RET : InstPTX<(outs), (ins), "ret", [(PTXret)]>;
|
2010-09-19 02:52:28 +08:00
|
|
|
}
|
2011-03-05 22:17:37 +08:00
|
|
|
|
2011-08-10 01:36:31 +08:00
|
|
|
let hasSideEffects = 1 in {
|
|
|
|
def CALL : InstPTX<(outs), (ins), "call", [(PTXcall)]>;
|
|
|
|
}
|
|
|
|
|
2011-09-23 00:45:46 +08:00
|
|
|
///===- Parameter Passing Pseudo-Instructions -----------------------------===//
|
|
|
|
|
|
|
|
def READPARAMPRED : InstPTX<(outs RegPred:$a), (ins i32imm:$b),
|
|
|
|
"mov.pred\t$a, %param$b", []>;
|
|
|
|
def READPARAMI16 : InstPTX<(outs RegI16:$a), (ins i32imm:$b),
|
|
|
|
"mov.b16\t$a, %param$b", []>;
|
|
|
|
def READPARAMI32 : InstPTX<(outs RegI32:$a), (ins i32imm:$b),
|
|
|
|
"mov.b32\t$a, %param$b", []>;
|
|
|
|
def READPARAMI64 : InstPTX<(outs RegI64:$a), (ins i32imm:$b),
|
|
|
|
"mov.b64\t$a, %param$b", []>;
|
|
|
|
def READPARAMF32 : InstPTX<(outs RegF32:$a), (ins i32imm:$b),
|
|
|
|
"mov.f32\t$a, %param$b", []>;
|
|
|
|
def READPARAMF64 : InstPTX<(outs RegF64:$a), (ins i32imm:$b),
|
|
|
|
"mov.f64\t$a, %param$b", []>;
|
|
|
|
|
|
|
|
def WRITEPARAMPRED : InstPTX<(outs), (ins RegPred:$a), "//w", []>;
|
|
|
|
def WRITEPARAMI16 : InstPTX<(outs), (ins RegI16:$a), "//w", []>;
|
|
|
|
def WRITEPARAMI32 : InstPTX<(outs), (ins RegI32:$a), "//w", []>;
|
|
|
|
def WRITEPARAMI64 : InstPTX<(outs), (ins RegI64:$a), "//w", []>;
|
|
|
|
def WRITEPARAMF32 : InstPTX<(outs), (ins RegF32:$a), "//w", []>;
|
|
|
|
def WRITEPARAMF64 : InstPTX<(outs), (ins RegF64:$a), "//w", []>;
|
2011-08-10 01:36:31 +08:00
|
|
|
|
2011-03-05 22:17:37 +08:00
|
|
|
///===- Intrinsic Instructions --------------------------------------------===//
|
|
|
|
include "PTXIntrinsicInstrInfo.td"
|
2011-09-27 00:20:31 +08:00
|
|
|
|
|
|
|
///===- Load/Store Instructions -------------------------------------------===//
|
|
|
|
include "PTXInstrLoadStore.td"
|
|
|
|
|