================
@@ -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>;
----------------
thetheodor wrote:

The documentation is out of date. This will be updated

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