================
@@ -2253,22 +2253,31 @@ def trapexitinst : NVPTXInst<(outs), (ins), "trap; 
exit;", [(trap)]>, Requires<[
 // brkpt instruction
 def debugtrapinst : BasicNVPTXInst<(outs), (ins), "brkpt", [(debugtrap)]>;
 
-def SDTDynAllocaOp :
-  SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>, SDTCisInt<1>, SDTCisVT<2, i32>]>;
+def SDTDynAllocaOp
+    : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>, SDTCisInt<1>, SDTCisVT<2, 
i32>]>;
 
-def dyn_alloca :
-  SDNode<"NVPTXISD::DYNAMIC_STACKALLOC", SDTDynAllocaOp,
-         [SDNPHasChain, SDNPSideEffect]>;
+def getAllocaAlign : SDNodeXForm<imm, [{
+  if (N->getZExtValue() != 0)
+    return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), 
N->getValueType(0));
+  return 
CurDAG->getTargetConstant(CurDAG->getSubtarget().getFrameLowering()->getStackAlign().value(),
 SDLoc(N), N->getValueType(0));
+}]>;
 
-foreach t = [I32RT, I64RT] in {
-  def DYNAMIC_STACKALLOC # t.Size :
-    BasicNVPTXInst<(outs t.RC:$ptr),
-              (ins t.RC:$size, i32imm:$align),
-              "alloca.u" # t.Size,
-              [(set t.Ty:$ptr, (dyn_alloca t.Ty:$size, timm:$align))]>,
-              Requires<[hasPTX<73>, hasSM<52>]>;
+def dyn_alloca : SDNode<"ISD::DYNAMIC_STACKALLOC",
+                        SDTDynAllocaOp, [SDNPHasChain, SDNPSideEffect]>;
+
+let Predicates = [hasPTX<73>, hasSM<52>] in {
+  foreach t = [I32RT, I64RT] in {
+    def DYNAMIC_STACKALLOC_#t.Size
+        : BasicNVPTXInst<(outs t.RC:$ptr), (ins t.RC:$size, i32imm:$align),
+                         "alloca.u"#t.Size>;
----------------
Artem-B wrote:

I'm curious about the state of the `alloca` instruction in ptxas.

PTX docs state that :
> alloca is a preview feature in PTX ISA version 7.3. All details are subject 
> to change with no guarantees of backward compatibility on future PTX ISA 
> versions or SM architectures.

Is that just an out of date bit of the documentation? Or is it still 
experimental? 

https://github.com/llvm/llvm-project/pull/154814
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to