-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NVPTX] Consolidate and cleanup various NVPTXISD nodes (NFC) #145581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -457,3 +457,25 @@ void NVPTXInstPrinter::printCTAGroup(const MCInst *MI, int OpNum, | |
| } | ||
| llvm_unreachable("Invalid cta_group in printCTAGroup"); | ||
| } | ||
|
|
||
| void NVPTXInstPrinter::printCallOperand(const MCInst *MI, int OpNum, | ||
| raw_ostream &O, StringRef Modifier) { | ||
| const MCOperand &MO = MI->getOperand(OpNum); | ||
| assert(MO.isImm() && "Invalid operand"); | ||
| const auto Imm = MO.getImm(); | ||
|
|
||
| if (Modifier == "RetList") { | ||
| assert((Imm == 1 || Imm == 0) && "Invalid return list"); | ||
| if (Imm) | ||
| O << " (retval0),"; | ||
| return; | ||
| } | ||
|
|
||
| if (Modifier == "ParamList") { | ||
| assert(Imm >= 0 && "Invalid parameter list"); | ||
| interleaveComma(llvm::seq(Imm), O, | ||
| [&](const auto &I) { O << "param" << I; }); | ||
| return; | ||
| } | ||
|
Comment on lines
+474
to
+479
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know if PTX imposes practical limits on the line length?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know of a practical limit. I know we've had some very long lines with initialization of static arrays and with debug info in the past and as far as I know it hasn't been a problem. Should I prophylactically add some newlines or do you think it makes sense to wait and see?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep it as is. JIT-produced PTX is rarely read by anyone other than ptxas. For human use current form is fine. |
||
| llvm_unreachable("Invalid modifier"); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,15 +160,9 @@ void NVPTXDAGToDAGISel::Select(SDNode *N) { | |
| case NVPTXISD::StoreParam: | ||
| case NVPTXISD::StoreParamV2: | ||
| case NVPTXISD::StoreParamV4: | ||
| case NVPTXISD::StoreParamS32: | ||
| case NVPTXISD::StoreParamU32: | ||
| if (tryStoreParam(N)) | ||
| return; | ||
| break; | ||
| case ISD::INTRINSIC_WO_CHAIN: | ||
| if (tryIntrinsicNoChain(N)) | ||
| return; | ||
| break; | ||
| case ISD::INTRINSIC_W_CHAIN: | ||
| if (tryIntrinsicChain(N)) | ||
| return; | ||
|
|
@@ -904,25 +898,6 @@ NVPTXDAGToDAGISel::insertMemoryInstructionFence(SDLoc DL, SDValue &Chain, | |
| return {InstructionOrdering, Scope}; | ||
| } | ||
|
|
||
| bool NVPTXDAGToDAGISel::tryIntrinsicNoChain(SDNode *N) { | ||
| unsigned IID = N->getConstantOperandVal(0); | ||
| switch (IID) { | ||
Artem-B marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| default: | ||
| return false; | ||
| case Intrinsic::nvvm_texsurf_handle_internal: | ||
| SelectTexSurfHandle(N); | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| void NVPTXDAGToDAGISel::SelectTexSurfHandle(SDNode *N) { | ||
| // Op 0 is the intrinsic ID | ||
| SDValue Wrapper = N->getOperand(1); | ||
| SDValue GlobalVal = Wrapper.getOperand(0); | ||
| ReplaceNode(N, CurDAG->getMachineNode(NVPTX::texsurf_handles, SDLoc(N), | ||
| MVT::i64, GlobalVal)); | ||
| } | ||
|
|
||
| void NVPTXDAGToDAGISel::SelectAddrSpaceCast(SDNode *N) { | ||
| SDValue Src = N->getOperand(0); | ||
| AddrSpaceCastSDNode *CastN = cast<AddrSpaceCastSDNode>(N); | ||
|
|
@@ -1717,8 +1692,6 @@ bool NVPTXDAGToDAGISel::tryStoreParam(SDNode *N) { | |
| switch (N->getOpcode()) { | ||
| default: | ||
| llvm_unreachable("Unexpected opcode"); | ||
| case NVPTXISD::StoreParamU32: | ||
| case NVPTXISD::StoreParamS32: | ||
| case NVPTXISD::StoreParam: | ||
| NumElts = 1; | ||
| break; | ||
|
|
@@ -1796,27 +1769,6 @@ bool NVPTXDAGToDAGISel::tryStoreParam(SDNode *N) { | |
| } | ||
| } | ||
| break; | ||
| // Special case: if we have a sign-extend/zero-extend node, insert the | ||
| // conversion instruction first, and use that as the value operand to | ||
| // the selected StoreParam node. | ||
| case NVPTXISD::StoreParamU32: { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AlexMaclean This has removed everything but the default case (which causes MSVC build warnings) - remove the outer |
||
| Opcode = NVPTX::StoreParamI32_r; | ||
| SDValue CvtNone = CurDAG->getTargetConstant(NVPTX::PTXCvtMode::NONE, DL, | ||
| MVT::i32); | ||
| SDNode *Cvt = CurDAG->getMachineNode(NVPTX::CVT_u32_u16, DL, | ||
| MVT::i32, Ops[0], CvtNone); | ||
| Ops[0] = SDValue(Cvt, 0); | ||
| break; | ||
| } | ||
| case NVPTXISD::StoreParamS32: { | ||
| Opcode = NVPTX::StoreParamI32_r; | ||
| SDValue CvtNone = CurDAG->getTargetConstant(NVPTX::PTXCvtMode::NONE, DL, | ||
| MVT::i32); | ||
| SDNode *Cvt = CurDAG->getMachineNode(NVPTX::CVT_s32_s16, DL, | ||
| MVT::i32, Ops[0], CvtNone); | ||
| Ops[0] = SDValue(Cvt, 0); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| SDVTList RetVTs = CurDAG->getVTList(MVT::Other, MVT::Glue); | ||
|
|
@@ -2105,22 +2057,14 @@ static inline bool isAddLike(const SDValue V) { | |
| // selectBaseADDR - Match a dag node which will serve as the base address for an | ||
| // ADDR operand pair. | ||
| static SDValue selectBaseADDR(SDValue N, SelectionDAG *DAG) { | ||
| // Return true if TGA or ES. | ||
| if (N.getOpcode() == ISD::TargetGlobalAddress || | ||
| N.getOpcode() == ISD::TargetExternalSymbol) | ||
| return N; | ||
|
|
||
| if (N.getOpcode() == NVPTXISD::Wrapper) | ||
| return N.getOperand(0); | ||
|
|
||
| // addrspacecast(Wrapper(arg_symbol) to addrspace(PARAM)) -> arg_symbol | ||
| if (AddrSpaceCastSDNode *CastN = dyn_cast<AddrSpaceCastSDNode>(N)) | ||
| if (CastN->getSrcAddressSpace() == ADDRESS_SPACE_GENERIC && | ||
| CastN->getDestAddressSpace() == ADDRESS_SPACE_PARAM && | ||
| CastN->getOperand(0).getOpcode() == NVPTXISD::Wrapper) | ||
| return selectBaseADDR(CastN->getOperand(0).getOperand(0), DAG); | ||
|
|
||
| if (auto *FIN = dyn_cast<FrameIndexSDNode>(N)) | ||
| if (const auto *GA = dyn_cast<GlobalAddressSDNode>(N)) | ||
| return DAG->getTargetGlobalAddress(GA->getGlobal(), SDLoc(N), | ||
| GA->getValueType(0), GA->getOffset(), | ||
| GA->getTargetFlags()); | ||
| if (const auto *ES = dyn_cast<ExternalSymbolSDNode>(N)) | ||
| return DAG->getTargetExternalSymbol(ES->getSymbol(), ES->getValueType(0), | ||
| ES->getTargetFlags()); | ||
| if (const auto *FIN = dyn_cast<FrameIndexSDNode>(N)) | ||
| return DAG->getTargetFrameIndex(FIN->getIndex(), FIN->getValueType(0)); | ||
|
|
||
| return N; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.