@@ -142,6 +142,74 @@ bool XtensaTargetLowering::isOffsetFoldingLegal(
142
142
return false ;
143
143
}
144
144
145
+ // ===----------------------------------------------------------------------===//
146
+ // Inline asm support
147
+ // ===----------------------------------------------------------------------===//
148
+ TargetLowering::ConstraintType
149
+ XtensaTargetLowering::getConstraintType (StringRef Constraint) const {
150
+ if (Constraint.size () == 1 ) {
151
+ switch (Constraint[0 ]) {
152
+ case ' r' :
153
+ return C_RegisterClass;
154
+ default :
155
+ break ;
156
+ }
157
+ }
158
+ return TargetLowering::getConstraintType (Constraint);
159
+ }
160
+
161
+ TargetLowering::ConstraintWeight
162
+ XtensaTargetLowering::getSingleConstraintMatchWeight (
163
+ AsmOperandInfo &Info, const char *Constraint) const {
164
+ ConstraintWeight Weight = CW_Invalid;
165
+ Value *CallOperandVal = Info.CallOperandVal ;
166
+ // If we don't have a value, we can't do a match,
167
+ // but allow it at the lowest weight.
168
+ if (!CallOperandVal)
169
+ return CW_Default;
170
+
171
+ Type *Ty = CallOperandVal->getType ();
172
+
173
+ // Look at the constraint type.
174
+ switch (*Constraint) {
175
+ default :
176
+ Weight = TargetLowering::getSingleConstraintMatchWeight (Info, Constraint);
177
+ break ;
178
+ case ' r' :
179
+ if (Ty->isIntegerTy ())
180
+ Weight = CW_Register;
181
+ break ;
182
+ }
183
+ return Weight;
184
+ }
185
+
186
+ std::pair<unsigned , const TargetRegisterClass *>
187
+ XtensaTargetLowering::getRegForInlineAsmConstraint (
188
+ const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const {
189
+ if (Constraint.size () == 1 ) {
190
+ // GCC Constraint Letters
191
+ switch (Constraint[0 ]) {
192
+ default :
193
+ break ;
194
+ case ' r' : // General-purpose register
195
+ return std::make_pair (0U , &Xtensa::ARRegClass);
196
+ }
197
+ }
198
+ return TargetLowering::getRegForInlineAsmConstraint (TRI, Constraint, VT);
199
+ }
200
+
201
+ void XtensaTargetLowering::LowerAsmOperandForConstraint (
202
+ SDValue Op, StringRef Constraint, std::vector<SDValue> &Ops,
203
+ SelectionDAG &DAG) const {
204
+ SDLoc DL (Op);
205
+
206
+ // Only support length 1 constraints for now.
207
+ if (Constraint.size () > 1 )
208
+ return ;
209
+
210
+ TargetLowering::LowerAsmOperandForConstraint (Op, Constraint, Ops, DAG);
211
+ }
212
+
145
213
// ===----------------------------------------------------------------------===//
146
214
// Calling conventions
147
215
// ===----------------------------------------------------------------------===//
0 commit comments