@@ -1774,6 +1774,18 @@ def : Pat<(declare_array_param externalsym:$a, imm:$align, imm:$size),
1774
1774
def : Pat<(declare_scalar_param externalsym:$a, imm:$size),
1775
1775
(DECLARE_PARAM_scalar (to_texternsym $a), imm:$size)>;
1776
1776
1777
+ // Call prototype wrapper, this is a dummy instruction that just prints it's
1778
+ // operand which is string defining the prototype.
1779
+ def SDTCallPrototype : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
1780
+ def CallPrototype :
1781
+ SDNode<"NVPTXISD::CallPrototype", SDTCallPrototype,
1782
+ [SDNPHasChain, SDNPOutGlue, SDNPInGlue, SDNPSideEffect]>;
1783
+ def ProtoIdent : Operand<i32> { let PrintMethod = "printProtoIdent"; }
1784
+ def CALL_PROTOTYPE :
1785
+ NVPTXInst<(outs), (ins ProtoIdent:$ident),
1786
+ "$ident", [(CallPrototype (i32 texternalsym:$ident))]>;
1787
+
1788
+
1777
1789
foreach t = [I32RT, I64RT] in {
1778
1790
defvar inst_name = "MOV" # t.Size # "_PARAM";
1779
1791
def inst_name : BasicNVPTXInst<(outs t.RC:$dst), (ins t.RC:$src), "mov.b" # t.Size>;
@@ -1793,6 +1805,32 @@ defm ProxyRegB16 : ProxyRegInst<"b16", B16>;
1793
1805
defm ProxyRegB32 : ProxyRegInst<"b32", B32>;
1794
1806
defm ProxyRegB64 : ProxyRegInst<"b64", B64>;
1795
1807
1808
+
1809
+ // Callseq start and end
1810
+
1811
+ // Note: these nodes are marked as SDNPMayStore and SDNPMayLoad because
1812
+ // they define the scope in which the declared params may be used. Therefore
1813
+ // we add these flags to ensure ld.param and st.param are not sunk or hoisted
1814
+ // out of that scope.
1815
+
1816
+ def callseq_start : SDNode<"ISD::CALLSEQ_START",
1817
+ SDCallSeqStart<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>,
1818
+ [SDNPHasChain, SDNPOutGlue,
1819
+ SDNPSideEffect, SDNPMayStore, SDNPMayLoad]>;
1820
+ def callseq_end : SDNode<"ISD::CALLSEQ_END",
1821
+ SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>,
1822
+ [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
1823
+ SDNPSideEffect, SDNPMayStore, SDNPMayLoad]>;
1824
+
1825
+ def Callseq_Start :
1826
+ NVPTXInst<(outs), (ins i32imm:$amt1, i32imm:$amt2),
1827
+ "\\{ // callseq $amt1, $amt2",
1828
+ [(callseq_start timm:$amt1, timm:$amt2)]>;
1829
+ def Callseq_End :
1830
+ NVPTXInst<(outs), (ins i32imm:$amt1, i32imm:$amt2),
1831
+ "\\} // callseq $amt1",
1832
+ [(callseq_end timm:$amt1, timm:$amt2)]>;
1833
+
1796
1834
//
1797
1835
// Load / Store Handling
1798
1836
//
@@ -2336,26 +2374,6 @@ def : Pat<(brcond i32:$a, bb:$target),
2336
2374
def : Pat<(brcond (i1 (setne i1:$a, -1)), bb:$target),
2337
2375
(CBranchOther $a, bb:$target)>;
2338
2376
2339
- // Call
2340
- def SDT_NVPTXCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>,
2341
- SDTCisVT<1, i32>]>;
2342
- def SDT_NVPTXCallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
2343
-
2344
- def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_NVPTXCallSeqStart,
2345
- [SDNPHasChain, SDNPOutGlue, SDNPSideEffect]>;
2346
- def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_NVPTXCallSeqEnd,
2347
- [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
2348
- SDNPSideEffect]>;
2349
-
2350
- def Callseq_Start :
2351
- NVPTXInst<(outs), (ins i32imm:$amt1, i32imm:$amt2),
2352
- "\\{ // callseq $amt1, $amt2",
2353
- [(callseq_start timm:$amt1, timm:$amt2)]>;
2354
- def Callseq_End :
2355
- NVPTXInst<(outs), (ins i32imm:$amt1, i32imm:$amt2),
2356
- "\\} // callseq $amt1",
2357
- [(callseq_end timm:$amt1, timm:$amt2)]>;
2358
-
2359
2377
// trap instruction
2360
2378
def trapinst : BasicNVPTXInst<(outs), (ins), "trap", [(trap)]>, Requires<[noPTXASUnreachableBug]>;
2361
2379
// Emit an `exit` as well to convey to ptxas that `trap` exits the CFG.
@@ -2364,18 +2382,6 @@ def trapexitinst : NVPTXInst<(outs), (ins), "trap; exit;", [(trap)]>, Requires<[
2364
2382
// brkpt instruction
2365
2383
def debugtrapinst : BasicNVPTXInst<(outs), (ins), "brkpt", [(debugtrap)]>;
2366
2384
2367
- // Call prototype wrapper
2368
- def SDTCallPrototype : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
2369
- def CallPrototype :
2370
- SDNode<"NVPTXISD::CallPrototype", SDTCallPrototype,
2371
- [SDNPHasChain, SDNPOutGlue, SDNPInGlue, SDNPSideEffect]>;
2372
- def ProtoIdent : Operand<i32> {
2373
- let PrintMethod = "printProtoIdent";
2374
- }
2375
- def CALL_PROTOTYPE :
2376
- NVPTXInst<(outs), (ins ProtoIdent:$ident),
2377
- "$ident", [(CallPrototype (i32 texternalsym:$ident))]>;
2378
-
2379
2385
def SDTDynAllocaOp :
2380
2386
SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>, SDTCisInt<1>, SDTCisVT<2, i32>]>;
2381
2387
0 commit comments