|
37 | 37 | #include "llvm/IR/Constants.h"
|
38 | 38 | #include "llvm/IR/DataLayout.h"
|
39 | 39 | #include "llvm/IR/DerivedTypes.h"
|
| 40 | +#include "llvm/IR/DiagnosticInfo.h" |
40 | 41 | #include "llvm/IR/FPEnv.h"
|
41 | 42 | #include "llvm/IR/Function.h"
|
42 | 43 | #include "llvm/IR/GlobalValue.h"
|
@@ -639,6 +640,11 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
|
639 | 640 | setOperationAction(ISD::ConstantFP, MVT::f16, Legal);
|
640 | 641 | setOperationAction(ISD::ConstantFP, MVT::bf16, Legal);
|
641 | 642 |
|
| 643 | + // Lowering of DYNAMIC_STACKALLOC is unsupported. |
| 644 | + // Custom lower to produce an error. |
| 645 | + setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Custom); |
| 646 | + setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i64, Custom); |
| 647 | + |
642 | 648 | // TRAP can be lowered to PTX trap
|
643 | 649 | setOperationAction(ISD::TRAP, MVT::Other, Legal);
|
644 | 650 |
|
@@ -2209,6 +2215,18 @@ SDValue NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
2209 | 2215 | return Chain;
|
2210 | 2216 | }
|
2211 | 2217 |
|
| 2218 | +SDValue NVPTXTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op, |
| 2219 | + SelectionDAG &DAG) const { |
| 2220 | + const Function &Fn = DAG.getMachineFunction().getFunction(); |
| 2221 | + |
| 2222 | + DiagnosticInfoUnsupported NoDynamicAlloca( |
| 2223 | + Fn, "dynamic alloca unsupported by NVPTX backend", |
| 2224 | + SDLoc(Op).getDebugLoc()); |
| 2225 | + DAG.getContext()->diagnose(NoDynamicAlloca); |
| 2226 | + auto Ops = {DAG.getConstant(0, SDLoc(), Op.getValueType()), Op.getOperand(0)}; |
| 2227 | + return DAG.getMergeValues(Ops, SDLoc()); |
| 2228 | +} |
| 2229 | + |
2212 | 2230 | // By default CONCAT_VECTORS is lowered by ExpandVectorBuildThroughStack()
|
2213 | 2231 | // (see LegalizeDAG.cpp). This is slow and uses local memory.
|
2214 | 2232 | // We use extract/insert/build vector just as what LegalizeOp() does in llvm 2.5
|
@@ -2700,6 +2718,8 @@ NVPTXTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
|
2700 | 2718 | case ISD::SREM:
|
2701 | 2719 | case ISD::UREM:
|
2702 | 2720 | return LowerVectorArith(Op, DAG);
|
| 2721 | + case ISD::DYNAMIC_STACKALLOC: |
| 2722 | + return LowerDYNAMIC_STACKALLOC(Op, DAG); |
2703 | 2723 | default:
|
2704 | 2724 | llvm_unreachable("Custom lowering not defined for operation");
|
2705 | 2725 | }
|
|
0 commit comments