1616#include " llvm/CodeGen/MachineOperand.h"
1717#include " llvm/CodeGen/MachineRegisterInfo.h"
1818#include " llvm/CodeGen/TargetLowering.h"
19- #include " llvm/IR/DiagnosticInfo.h"
2019#include " llvm/IR/Module.h"
2120
2221#define DEBUG_TYPE " inline-asm-lowering"
@@ -232,15 +231,6 @@ bool InlineAsmLowering::lowerInlineAsm(
232231 TargetLowering::AsmOperandInfoVector TargetConstraints =
233232 TLI->ParseConstraints (DL, TRI, Call);
234233
235- const auto ConstraintError = [&](const GISelAsmOperandInfo &Info, Twine Msg) {
236- LLVMContext &Ctx = MIRBuilder.getContext ();
237- Ctx.diagnose (DiagnosticInfoInlineAsm (
238- Call, " invalid constraint '" + Info.ConstraintCode + " ': " + Msg));
239- // TODO: Recover if fallback isn't used. Otherwise let the fallback to DAG
240- // kick in.
241- return false ;
242- };
243-
244234 ExtraFlags ExtraInfo (Call);
245235 unsigned ArgNo = 0 ; // ArgNo - The argument of the CallInst.
246236 unsigned ResNo = 0 ; // ResNo - The result number of the next output.
@@ -253,8 +243,8 @@ bool InlineAsmLowering::lowerInlineAsm(
253243 OpInfo.CallOperandVal = const_cast <Value *>(Call.getArgOperand (ArgNo));
254244
255245 if (isa<BasicBlock>(OpInfo.CallOperandVal )) {
256- return ConstraintError (OpInfo,
257- " basic block input operands not supported yet " ) ;
246+ LLVM_DEBUG ( dbgs () << " Basic block input operands not supported yet \n " );
247+ return false ;
258248 }
259249
260250 Type *OpTy = OpInfo.CallOperandVal ->getType ();
@@ -268,8 +258,9 @@ bool InlineAsmLowering::lowerInlineAsm(
268258
269259 // FIXME: Support aggregate input operands
270260 if (!OpTy->isSingleValueType ()) {
271- return ConstraintError (OpInfo,
272- " aggregate input operands not supported yet" );
261+ LLVM_DEBUG (
262+ dbgs () << " Aggregate input operands are not supported yet\n " );
263+ return false ;
273264 }
274265
275266 OpInfo.ConstraintVT =
@@ -353,8 +344,9 @@ bool InlineAsmLowering::lowerInlineAsm(
353344
354345 // Find a register that we can use.
355346 if (OpInfo.Regs .empty ()) {
356- return ConstraintError (
357- OpInfo, " could not allocate output register for constraint" );
347+ LLVM_DEBUG (dbgs ()
348+ << " Couldn't allocate output register for constraint\n " );
349+ return false ;
358350 }
359351
360352 // Add information to the INLINEASM instruction to know that this
@@ -397,13 +389,13 @@ bool InlineAsmLowering::lowerInlineAsm(
397389
398390 const InlineAsm::Flag MatchedOperandFlag (Inst->getOperand (InstFlagIdx).getImm ());
399391 if (MatchedOperandFlag.isMemKind ()) {
400- return ConstraintError (
401- OpInfo,
402- " matching input constraint to mem operand not supported; this "
403- " should be target specific" );
392+ LLVM_DEBUG (dbgs () << " Matching input constraint to mem operand not "
393+ " supported. This should be target specific.\n " );
394+ return false ;
404395 }
405396 if (!MatchedOperandFlag.isRegDefKind () && !MatchedOperandFlag.isRegDefEarlyClobberKind ()) {
406- return ConstraintError (OpInfo, " unknown matching constraint" );
397+ LLVM_DEBUG (dbgs () << " Unknown matching constraint\n " );
398+ return false ;
407399 }
408400
409401 // We want to tie input to register in next operand.
@@ -433,10 +425,9 @@ bool InlineAsmLowering::lowerInlineAsm(
433425
434426 if (OpInfo.ConstraintType == TargetLowering::C_Other &&
435427 OpInfo.isIndirect ) {
436- return ConstraintError (
437- OpInfo,
438- " indirect input operands with unknown constraint not supported "
439- " yet" );
428+ LLVM_DEBUG (dbgs () << " Indirect input operands with unknown constraint "
429+ " not supported yet\n " );
430+ return false ;
440431 }
441432
442433 if (OpInfo.ConstraintType == TargetLowering::C_Immediate ||
@@ -446,7 +437,9 @@ bool InlineAsmLowering::lowerInlineAsm(
446437 if (!lowerAsmOperandForConstraint (OpInfo.CallOperandVal ,
447438 OpInfo.ConstraintCode , Ops,
448439 MIRBuilder)) {
449- return ConstraintError (OpInfo, " unsupported constraint" );
440+ LLVM_DEBUG (dbgs () << " Don't support constraint: "
441+ << OpInfo.ConstraintCode << " yet\n " );
442+ return false ;
450443 }
451444
452445 assert (Ops.size () > 0 &&
@@ -463,8 +456,9 @@ bool InlineAsmLowering::lowerInlineAsm(
463456 if (OpInfo.ConstraintType == TargetLowering::C_Memory) {
464457
465458 if (!OpInfo.isIndirect ) {
466- return ConstraintError (
467- OpInfo, " indirect memory input operands are not supported yet" );
459+ LLVM_DEBUG (dbgs ()
460+ << " Cannot indirectify memory input operands yet\n " );
461+ return false ;
468462 }
469463
470464 assert (OpInfo.isIndirect && " Operand must be indirect to be a mem!" );
@@ -488,15 +482,18 @@ bool InlineAsmLowering::lowerInlineAsm(
488482 " Unknown constraint type!" );
489483
490484 if (OpInfo.isIndirect ) {
491- return ConstraintError (
492- OpInfo, " indirect register inputs are not supported yet" );
485+ LLVM_DEBUG (dbgs () << " Can't handle indirect register inputs yet "
486+ " for constraint '"
487+ << OpInfo.ConstraintCode << " '\n " );
488+ return false ;
493489 }
494490
495491 // Copy the input into the appropriate registers.
496492 if (OpInfo.Regs .empty ()) {
497- return ConstraintError (
498- OpInfo,
499- " could not allocate input register for register constraint" );
493+ LLVM_DEBUG (
494+ dbgs ()
495+ << " Couldn't allocate input register for register constraint\n " );
496+ return false ;
500497 }
501498
502499 unsigned NumRegs = OpInfo.Regs .size ();
@@ -506,10 +503,9 @@ bool InlineAsmLowering::lowerInlineAsm(
506503 " source registers" );
507504
508505 if (NumRegs > 1 ) {
509- return ConstraintError (
510- OpInfo,
511- " input operands with multiple input registers are not supported "
512- " yet" );
506+ LLVM_DEBUG (dbgs () << " Input operands with multiple input registers are "
507+ " not supported yet\n " );
508+ return false ;
513509 }
514510
515511 InlineAsm::Flag Flag (InlineAsm::Kind::RegUse, NumRegs);
0 commit comments