@@ -1830,6 +1830,18 @@ def : Pat<(declare_array_param externalsym:$a, imm:$align, imm:$size),
18301830def : Pat<(declare_scalar_param externalsym:$a, imm:$size),
18311831 (DECLARE_PARAM_scalar (to_texternsym $a), imm:$size)>;
18321832
1833+ // Call prototype wrapper, this is a dummy instruction that just prints it's
1834+ // operand which is string defining the prototype.
1835+ def SDTCallPrototype : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
1836+ def CallPrototype :
1837+ SDNode<"NVPTXISD::CallPrototype", SDTCallPrototype,
1838+ [SDNPHasChain, SDNPOutGlue, SDNPInGlue, SDNPSideEffect]>;
1839+ def ProtoIdent : Operand<i32> { let PrintMethod = "printProtoIdent"; }
1840+ def CALL_PROTOTYPE :
1841+ NVPTXInst<(outs), (ins ProtoIdent:$ident),
1842+ "$ident", [(CallPrototype (i32 texternalsym:$ident))]>;
1843+
1844+
18331845foreach t = [I32RT, I64RT] in {
18341846 defvar inst_name = "MOV" # t.Size # "_PARAM";
18351847 def inst_name : BasicNVPTXInst<(outs t.RC:$dst), (ins t.RC:$src), "mov.b" # t.Size>;
@@ -1849,6 +1861,32 @@ defm ProxyRegB16 : ProxyRegInst<"b16", B16>;
18491861defm ProxyRegB32 : ProxyRegInst<"b32", B32>;
18501862defm ProxyRegB64 : ProxyRegInst<"b64", B64>;
18511863
1864+
1865+ // Callseq start and end
1866+
1867+ // Note: these nodes are marked as SDNPMayStore and SDNPMayLoad because
1868+ // they define the scope in which the declared params may be used. Therefore
1869+ // we add these flags to ensure ld.param and st.param are not sunk or hoisted
1870+ // out of that scope.
1871+
1872+ def callseq_start : SDNode<"ISD::CALLSEQ_START",
1873+ SDCallSeqStart<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>,
1874+ [SDNPHasChain, SDNPOutGlue,
1875+ SDNPSideEffect, SDNPMayStore, SDNPMayLoad]>;
1876+ def callseq_end : SDNode<"ISD::CALLSEQ_END",
1877+ SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>,
1878+ [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
1879+ SDNPSideEffect, SDNPMayStore, SDNPMayLoad]>;
1880+
1881+ def Callseq_Start :
1882+ NVPTXInst<(outs), (ins i32imm:$amt1, i32imm:$amt2),
1883+ "\\{ // callseq $amt1, $amt2",
1884+ [(callseq_start timm:$amt1, timm:$amt2)]>;
1885+ def Callseq_End :
1886+ NVPTXInst<(outs), (ins i32imm:$amt1, i32imm:$amt2),
1887+ "\\} // callseq $amt1",
1888+ [(callseq_end timm:$amt1, timm:$amt2)]>;
1889+
18521890//
18531891// Load / Store Handling
18541892//
@@ -2392,26 +2430,6 @@ def : Pat<(brcond i32:$a, bb:$target),
23922430def : Pat<(brcond (i1 (setne i1:$a, -1)), bb:$target),
23932431 (CBranchOther $a, bb:$target)>;
23942432
2395- // Call
2396- def SDT_NVPTXCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>,
2397- SDTCisVT<1, i32>]>;
2398- def SDT_NVPTXCallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
2399-
2400- def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_NVPTXCallSeqStart,
2401- [SDNPHasChain, SDNPOutGlue, SDNPSideEffect]>;
2402- def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_NVPTXCallSeqEnd,
2403- [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
2404- SDNPSideEffect]>;
2405-
2406- def Callseq_Start :
2407- NVPTXInst<(outs), (ins i32imm:$amt1, i32imm:$amt2),
2408- "\\{ // callseq $amt1, $amt2",
2409- [(callseq_start timm:$amt1, timm:$amt2)]>;
2410- def Callseq_End :
2411- NVPTXInst<(outs), (ins i32imm:$amt1, i32imm:$amt2),
2412- "\\} // callseq $amt1",
2413- [(callseq_end timm:$amt1, timm:$amt2)]>;
2414-
24152433// trap instruction
24162434def trapinst : BasicNVPTXInst<(outs), (ins), "trap", [(trap)]>, Requires<[noPTXASUnreachableBug]>;
24172435// Emit an `exit` as well to convey to ptxas that `trap` exits the CFG.
@@ -2420,18 +2438,6 @@ def trapexitinst : NVPTXInst<(outs), (ins), "trap; exit;", [(trap)]>, Requires<[
24202438// brkpt instruction
24212439def debugtrapinst : BasicNVPTXInst<(outs), (ins), "brkpt", [(debugtrap)]>;
24222440
2423- // Call prototype wrapper
2424- def SDTCallPrototype : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
2425- def CallPrototype :
2426- SDNode<"NVPTXISD::CallPrototype", SDTCallPrototype,
2427- [SDNPHasChain, SDNPOutGlue, SDNPInGlue, SDNPSideEffect]>;
2428- def ProtoIdent : Operand<i32> {
2429- let PrintMethod = "printProtoIdent";
2430- }
2431- def CALL_PROTOTYPE :
2432- NVPTXInst<(outs), (ins ProtoIdent:$ident),
2433- "$ident", [(CallPrototype (i32 texternalsym:$ident))]>;
2434-
24352441def SDTDynAllocaOp :
24362442 SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>, SDTCisInt<1>, SDTCisVT<2, i32>]>;
24372443
0 commit comments