-
Notifications
You must be signed in to change notification settings - Fork 15.7k
[SelectionDAG][WIP] Move HwMode expansion from tablegen to SelectionISel. #174471
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
base: main
Are you sure you want to change the base?
Changes from all commits
d2220d7
0649d2c
2ca3b81
be086a3
32006c2
97e5bb0
80e54fe
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 |
|---|---|---|
|
|
@@ -531,6 +531,8 @@ void SelectionDAGISel::initializeAnalysisResults( | |
| SP = &FAM.getResult<SSPLayoutAnalysis>(Fn); | ||
|
|
||
| TTI = &FAM.getResult<TargetIRAnalysis>(Fn); | ||
|
|
||
| HwMode = MF->getSubtarget().getHwMode(); | ||
|
Contributor
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. This is supposed to be queried with a specific hw mode kind (which seems to be a stalled project from who knows when)
Collaborator
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. Unfortunately, ValueTypeByHwMode and RegClassInfo/RegClassByHwMode use different hw mode kinds but they both affect the VT in CodeGenDAGPatterns so I don't how to make that work.
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. I noticed this as well in my recent tablegen changes and am not really sure why it is useful to have separate namespaces for this. It seems to be basically the same anyway? |
||
| } | ||
|
|
||
| void SelectionDAGISel::initializeAnalysisResults(MachineFunctionPass &MFP) { | ||
|
|
@@ -588,6 +590,8 @@ void SelectionDAGISel::initializeAnalysisResults(MachineFunctionPass &MFP) { | |
| SP = &MFP.getAnalysis<StackProtector>().getLayoutInfo(); | ||
|
|
||
| TTI = &MFP.getAnalysis<TargetTransformInfoWrapperPass>().getTTI(Fn); | ||
|
|
||
| HwMode = MF->getSubtarget().getHwMode(); | ||
| } | ||
|
|
||
| bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { | ||
|
|
@@ -2747,6 +2751,18 @@ getSimpleVT(const uint8_t *MatcherTable, unsigned &MatcherIndex) { | |
| return static_cast<MVT::SimpleValueType>(SimpleVT); | ||
| } | ||
|
|
||
| /// getSimpleVT - Decode a value in MatcherTable, if it's a VBR encoded value, | ||
| /// use GetVBR to decode it. | ||
| LLVM_ATTRIBUTE_ALWAYS_INLINE static MVT | ||
| getHwModeVT(const uint8_t *MatcherTable, unsigned &MatcherIndex, | ||
| const SelectionDAGISel &SDISel) { | ||
| unsigned Index = MatcherTable[MatcherIndex++]; | ||
| if (Index & 128) | ||
|
Contributor
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. Is it possible that we have such a large
Collaborator
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 doubt. I can make it a fatal error in tablegen if you want.
Contributor
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. If it is always small, I prefer to to make it fixed to save some compile time. |
||
| Index = GetVBR(Index, MatcherTable, MatcherIndex); | ||
|
|
||
| return SDISel.getValueTypeByHwMode(Index); | ||
| } | ||
|
|
||
| void SelectionDAGISel::Select_JUMP_TABLE_DEBUG_INFO(SDNode *N) { | ||
| SDLoc dl(N); | ||
| CurDAG->SelectNodeTo(N, TargetOpcode::JUMP_TABLE_DEBUG_INFO, MVT::Glue, | ||
|
|
@@ -3150,12 +3166,25 @@ static unsigned IsPredicateKnownToFail( | |
| Result = !::CheckType(VT, N, SDISel.TLI, SDISel.CurDAG->getDataLayout()); | ||
| return Index; | ||
| } | ||
| case SelectionDAGISel::OPC_CheckTypeByHwMode: { | ||
| MVT VT = getHwModeVT(Table, Index, SDISel); | ||
| Result = !::CheckType(VT.SimpleTy, N, SDISel.TLI, | ||
| SDISel.CurDAG->getDataLayout()); | ||
| return Index; | ||
| } | ||
| case SelectionDAGISel::OPC_CheckTypeRes: { | ||
| unsigned Res = Table[Index++]; | ||
| Result = !::CheckType(getSimpleVT(Table, Index), N.getValue(Res), | ||
| SDISel.TLI, SDISel.CurDAG->getDataLayout()); | ||
| return Index; | ||
| } | ||
| case SelectionDAGISel::OPC_CheckTypeResByHwMode: { | ||
| unsigned Res = Table[Index++]; | ||
| MVT VT = getHwModeVT(Table, Index, SDISel); | ||
| Result = !::CheckType(VT.SimpleTy, N.getValue(Res), SDISel.TLI, | ||
| SDISel.CurDAG->getDataLayout()); | ||
| return Index; | ||
| } | ||
| case SelectionDAGISel::OPC_CheckChild0Type: | ||
| case SelectionDAGISel::OPC_CheckChild1Type: | ||
| case SelectionDAGISel::OPC_CheckChild2Type: | ||
|
|
@@ -3198,6 +3227,20 @@ static unsigned IsPredicateKnownToFail( | |
| SDISel.CurDAG->getDataLayout(), ChildNo); | ||
| return Index; | ||
| } | ||
| case SelectionDAGISel::OPC_CheckChild0TypeByHwMode: | ||
| case SelectionDAGISel::OPC_CheckChild1TypeByHwMode: | ||
| case SelectionDAGISel::OPC_CheckChild2TypeByHwMode: | ||
| case SelectionDAGISel::OPC_CheckChild3TypeByHwMode: | ||
| case SelectionDAGISel::OPC_CheckChild4TypeByHwMode: | ||
| case SelectionDAGISel::OPC_CheckChild5TypeByHwMode: | ||
| case SelectionDAGISel::OPC_CheckChild6TypeByHwMode: | ||
| case SelectionDAGISel::OPC_CheckChild7TypeByHwMode: { | ||
| MVT VT = getHwModeVT(Table, Index, SDISel); | ||
| unsigned ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeByHwMode; | ||
| Result = !::CheckChildType(VT.SimpleTy, N, SDISel.TLI, | ||
| SDISel.CurDAG->getDataLayout(), ChildNo); | ||
| return Index; | ||
| } | ||
| case SelectionDAGISel::OPC_CheckCondCode: | ||
| Result = !::CheckCondCode(Table, Index, N); | ||
| return Index; | ||
|
|
@@ -3718,6 +3761,12 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch, | |
| break; | ||
| continue; | ||
| } | ||
| case OPC_CheckTypeByHwMode: { | ||
| MVT VT = getHwModeVT(MatcherTable, MatcherIndex, *this); | ||
| if (!::CheckType(VT.SimpleTy, N, TLI, CurDAG->getDataLayout())) | ||
| break; | ||
| continue; | ||
| } | ||
|
|
||
| case OPC_CheckTypeRes: { | ||
| unsigned Res = MatcherTable[MatcherIndex++]; | ||
|
|
@@ -3726,6 +3775,14 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch, | |
| break; | ||
| continue; | ||
| } | ||
| case OPC_CheckTypeResByHwMode: { | ||
| unsigned Res = MatcherTable[MatcherIndex++]; | ||
| MVT VT = getHwModeVT(MatcherTable, MatcherIndex, *this); | ||
| if (!::CheckType(VT.SimpleTy, N.getValue(Res), TLI, | ||
| CurDAG->getDataLayout())) | ||
| break; | ||
| continue; | ||
| } | ||
|
|
||
| case OPC_SwitchOpcode: { | ||
| unsigned CurNodeOpcode = N.getOpcode(); | ||
|
|
@@ -3832,6 +3889,21 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch, | |
| break; | ||
| continue; | ||
| } | ||
| case OPC_CheckChild0TypeByHwMode: | ||
| case OPC_CheckChild1TypeByHwMode: | ||
| case OPC_CheckChild2TypeByHwMode: | ||
| case OPC_CheckChild3TypeByHwMode: | ||
| case OPC_CheckChild4TypeByHwMode: | ||
| case OPC_CheckChild5TypeByHwMode: | ||
| case OPC_CheckChild6TypeByHwMode: | ||
| case OPC_CheckChild7TypeByHwMode: { | ||
| MVT VT = getHwModeVT(MatcherTable, MatcherIndex, *this); | ||
| unsigned ChildNo = Opcode - OPC_CheckChild0TypeByHwMode; | ||
| if (!::CheckChildType(VT.SimpleTy, N, TLI, CurDAG->getDataLayout(), | ||
| ChildNo)) | ||
| break; | ||
| continue; | ||
| } | ||
| case OPC_CheckCondCode: | ||
| if (!::CheckCondCode(MatcherTable, MatcherIndex, N)) break; | ||
| continue; | ||
|
|
@@ -3920,12 +3992,24 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch, | |
| break; | ||
| } | ||
| int64_t Val = GetSignedVBR(MatcherTable, MatcherIndex); | ||
| Val = SignExtend64(Val, MVT(VT).getFixedSizeInBits()); | ||
| RecordedNodes.emplace_back( | ||
| CurDAG->getSignedConstant(Val, SDLoc(NodeToMatch), VT, | ||
| /*isTarget=*/true), | ||
| nullptr); | ||
| continue; | ||
| } | ||
| case OPC_EmitIntegerByHwMode: { | ||
| MVT VT = getHwModeVT(MatcherTable, MatcherIndex, *this); | ||
| int64_t Val = GetSignedVBR(MatcherTable, MatcherIndex); | ||
| Val = SignExtend64(Val, MVT(VT).getFixedSizeInBits()); | ||
| RecordedNodes.emplace_back( | ||
| CurDAG->getSignedConstant(Val, SDLoc(NodeToMatch), VT.SimpleTy, | ||
| /*isTarget=*/true), | ||
| nullptr); | ||
| continue; | ||
| } | ||
|
|
||
| case OPC_EmitRegister: | ||
| case OPC_EmitRegisterI32: | ||
| case OPC_EmitRegisterI64: { | ||
|
|
@@ -3945,6 +4029,12 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch, | |
| RecordedNodes.emplace_back(CurDAG->getRegister(RegNo, VT), nullptr); | ||
| continue; | ||
| } | ||
| case OPC_EmitRegisterByHwMode: { | ||
| MVT VT = getHwModeVT(MatcherTable, MatcherIndex, *this); | ||
| unsigned RegNo = MatcherTable[MatcherIndex++]; | ||
| RecordedNodes.emplace_back(CurDAG->getRegister(RegNo, VT), nullptr); | ||
| continue; | ||
| } | ||
| case OPC_EmitRegister2: { | ||
| // For targets w/ more than 256 register names, the register enum | ||
| // values are stored in two bytes in the matcher table (just like | ||
|
|
@@ -3955,6 +4045,16 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch, | |
| RecordedNodes.emplace_back(CurDAG->getRegister(RegNo, VT), nullptr); | ||
| continue; | ||
| } | ||
| case OPC_EmitRegisterByHwMode2: { | ||
| // For targets w/ more than 256 register names, the register enum | ||
| // values are stored in two bytes in the matcher table (just like | ||
| // opcodes). | ||
| MVT VT = getHwModeVT(MatcherTable, MatcherIndex, *this); | ||
| unsigned RegNo = MatcherTable[MatcherIndex++]; | ||
| RegNo |= MatcherTable[MatcherIndex++] << 8; | ||
| RecordedNodes.emplace_back(CurDAG->getRegister(RegNo, VT), nullptr); | ||
| continue; | ||
| } | ||
|
|
||
| case OPC_EmitConvertToTarget: | ||
| case OPC_EmitConvertToTarget0: | ||
|
|
@@ -4114,6 +4214,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch, | |
| } | ||
|
|
||
| case OPC_EmitNode: | ||
| case OPC_EmitNodeByHwMode: | ||
| case OPC_EmitNode0: | ||
| case OPC_EmitNode1: | ||
| case OPC_EmitNode2: | ||
|
|
@@ -4124,6 +4225,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch, | |
| case OPC_EmitNode1Chain: | ||
| case OPC_EmitNode2Chain: | ||
| case OPC_MorphNodeTo: | ||
| case OPC_MorphNodeToByHwMode: | ||
| case OPC_MorphNodeTo0: | ||
| case OPC_MorphNodeTo1: | ||
| case OPC_MorphNodeTo2: | ||
|
|
@@ -4187,11 +4289,20 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch, | |
| else | ||
| NumVTs = MatcherTable[MatcherIndex++]; | ||
| SmallVector<EVT, 4> VTs; | ||
| for (unsigned i = 0; i != NumVTs; ++i) { | ||
| MVT::SimpleValueType VT = getSimpleVT(MatcherTable, MatcherIndex); | ||
| if (VT == MVT::iPTR) | ||
| VT = TLI->getPointerTy(CurDAG->getDataLayout()).SimpleTy; | ||
| VTs.push_back(VT); | ||
| if (Opcode == OPC_EmitNodeByHwMode || Opcode == OPC_MorphNodeToByHwMode) { | ||
| for (unsigned i = 0; i != NumVTs; ++i) { | ||
| MVT VT = getHwModeVT(MatcherTable, MatcherIndex, *this); | ||
| if (VT == MVT::iPTR) | ||
| VT = TLI->getPointerTy(CurDAG->getDataLayout()); | ||
| VTs.push_back(VT); | ||
| } | ||
| } else { | ||
| for (unsigned i = 0; i != NumVTs; ++i) { | ||
| MVT::SimpleValueType VT = getSimpleVT(MatcherTable, MatcherIndex); | ||
| if (VT == MVT::iPTR) | ||
| VT = TLI->getPointerTy(CurDAG->getDataLayout()).SimpleTy; | ||
| VTs.push_back(VT); | ||
| } | ||
| } | ||
|
|
||
| if (EmitNodeInfo & OPFL_Chain) | ||
|
|
@@ -4258,7 +4369,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch, | |
| // Create the node. | ||
| MachineSDNode *Res = nullptr; | ||
| bool IsMorphNodeTo = | ||
| Opcode == OPC_MorphNodeTo || | ||
| Opcode == OPC_MorphNodeTo || Opcode == OPC_MorphNodeToByHwMode || | ||
| (Opcode >= OPC_MorphNodeTo0 && Opcode <= OPC_MorphNodeTo2GlueOutput); | ||
| if (!IsMorphNodeTo) { | ||
| // If this is a normal EmitNode command, just create the new node and | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.