llvm.org GIT mirror llvm / d0716b0
SelectionDAG: Pass along the original argument/element type in ISD::InputArg For some targets, it is useful to be able to look at the original type of an argument without having to dig through the original IR. This also fixes a bug in SelectionDAGBuilder where InputArg.PartOffset was not taking into account the offset of structure elements. Patch by: Justin Holewinski Tom Stellard: - Changed the type of ArgVT to EVT, so it can store non-simple types like v3i32. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193214 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 6 years ago
3 changed file(s) with 15 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
112112 struct InputArg {
113113 ArgFlagsTy Flags;
114114 MVT VT;
115 EVT ArgVT;
115116 bool Used;
116117
117118 /// Index original Function's argument.
123124 unsigned PartOffset;
124125
125126 InputArg() : VT(MVT::Other), Used(false) {}
126 InputArg(ArgFlagsTy flags, EVT vt, bool used,
127 InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used,
127128 unsigned origIdx, unsigned partOffs)
128129 : Flags(flags), Used(used), OrigArgIndex(origIdx), PartOffset(partOffs) {
129130 VT = vt.getSimpleVT();
131 ArgVT = argvt;
130132 }
131133 };
132134
137139 struct OutputArg {
138140 ArgFlagsTy Flags;
139141 MVT VT;
142 EVT ArgVT;
140143
141144 /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
142145 bool IsFixed;
150153 unsigned PartOffset;
151154
152155 OutputArg() : IsFixed(false) {}
153 OutputArg(ArgFlagsTy flags, EVT vt, bool isfixed,
156 OutputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool isfixed,
154157 unsigned origIdx, unsigned partOffs)
155158 : Flags(flags), IsFixed(isfixed), OrigArgIndex(origIdx),
156159 PartOffset(partOffs) {
157160 VT = vt.getSimpleVT();
161 ArgVT = argvt;
158162 }
159163 };
160164 }
12671267
12681268 for (unsigned i = 0; i < NumParts; ++i) {
12691269 Outs.push_back(ISD::OutputArg(Flags, Parts[i].getValueType(),
1270 /*isfixed=*/true, 0, 0));
1270 VT, /*isfixed=*/true, 0, 0));
12711271 OutVals.push_back(Parts[i]);
12721272 }
12731273 }
67376737 for (unsigned i = 0; i != NumRegs; ++i) {
67386738 ISD::InputArg MyFlags;
67396739 MyFlags.VT = RegisterVT;
6740 MyFlags.ArgVT = VT;
67406741 MyFlags.Used = CLI.IsReturnValueUsed;
67416742 if (CLI.RetSExt)
67426743 MyFlags.Flags.setSExt();
68266827
68276828 for (unsigned j = 0; j != NumParts; ++j) {
68286829 // if it isn't first piece, alignment must be 1
6829 ISD::OutputArg MyFlags(Flags, Parts[j].getValueType(),
6830 ISD::OutputArg MyFlags(Flags, Parts[j].getValueType(), VT,
68306831 i < CLI.NumFixedArgs,
68316832 i, j*Parts[j].getValueType().getStoreSize());
68326833 if (NumParts > 1 && j == 0)
69656966 ISD::ArgFlagsTy Flags;
69666967 Flags.setSRet();
69676968 MVT RegisterVT = TLI->getRegisterType(*DAG.getContext(), ValueVTs[0]);
6968 ISD::InputArg RetArg(Flags, RegisterVT, true, 0, 0);
6969 ISD::InputArg RetArg(Flags, RegisterVT, ValueVTs[0], true, 0, 0);
69696970 Ins.push_back(RetArg);
69706971 }
69716972
69766977 SmallVector ValueVTs;
69776978 ComputeValueVTs(*TLI, I->getType(), ValueVTs);
69786979 bool isArgValueUsed = !I->use_empty();
6980 unsigned PartBase = 0;
69796981 for (unsigned Value = 0, NumValues = ValueVTs.size();
69806982 Value != NumValues; ++Value) {
69816983 EVT VT = ValueVTs[Value];
70137015 MVT RegisterVT = TLI->getRegisterType(*CurDAG->getContext(), VT);
70147016 unsigned NumRegs = TLI->getNumRegisters(*CurDAG->getContext(), VT);
70157017 for (unsigned i = 0; i != NumRegs; ++i) {
7016 ISD::InputArg MyFlags(Flags, RegisterVT, isArgValueUsed,
7017 Idx-1, i*RegisterVT.getStoreSize());
7018 ISD::InputArg MyFlags(Flags, RegisterVT, VT, isArgValueUsed,
7019 Idx-1, PartBase+i*RegisterVT.getStoreSize());
70187020 if (NumRegs > 1 && i == 0)
70197021 MyFlags.Flags.setSplit();
70207022 // if it isn't first piece, alignment must be 1
70227024 MyFlags.Flags.setOrigAlign(1);
70237025 Ins.push_back(MyFlags);
70247026 }
7027 PartBase += VT.getStoreSize();
70257028 }
70267029 }
70277030
12011201 Flags.setZExt();
12021202
12031203 for (unsigned i = 0; i < NumParts; ++i)
1204 Outs.push_back(ISD::OutputArg(Flags, PartVT, /*isFixed=*/true, 0, 0));
1204 Outs.push_back(ISD::OutputArg(Flags, PartVT, VT, /*isFixed=*/true, 0, 0));
12051205 }
12061206 }
12071207