================
@@ -2605,32 +2605,93 @@ static llvm::MDNode *getAsmSrcLocInfo(const 
StringLiteral *Str,
   return llvm::MDNode::get(CGF.getLLVMContext(), Locs);
 }
 
-static void UpdateAsmCallInst(llvm::CallBase &Result, bool HasSideEffect,
-                              bool HasUnwindClobber, bool ReadOnly,
-                              bool ReadNone, bool NoMerge, bool NoConvergent,
-                              const AsmStmt &S,
-                              const std::vector<llvm::Type *> &ResultRegTypes,
-                              const std::vector<llvm::Type *> &ArgElemTypes,
-                              CodeGenFunction &CGF,
-                              std::vector<llvm::Value *> &RegResults) {
+namespace {
+
+/// This structure holds the information gathered about the constraints for an
+/// inline assembly statement. It helps in separating the constraint processing
+/// from the code generation.
+struct AsmConstraintsInfo {
+  // The output and input constraints.
+  SmallVectorImpl<TargetInfo::ConstraintInfo> &OutputConstraintInfos;
+  SmallVectorImpl<TargetInfo::ConstraintInfo> &InputConstraintInfos;
+
+  // Constraint strings.
+  std::string Constraints;
+  std::string InOutConstraints;
+
+  // Keep track of out constraints for tied input operand.
+  std::vector<std::string> OutputConstraints;
+
+  // Keep track of argument types.
+  std::vector<llvm::Value *> Args;
+  std::vector<llvm::Type *> ArgTypes;
+  std::vector<llvm::Type *> ArgElemTypes;
+
+  // Keep track of result register constraints.
+  std::vector<LValue> ResultRegDests;
+  std::vector<QualType> ResultRegQualTys;
+  std::vector<llvm::Type *> ResultRegTypes;
+  std::vector<llvm::Type *> ResultTruncRegTypes;
+
+  llvm::BitVector ResultTypeRequiresCast;
+
+  // Keep track of in/out constraints.
+  std::vector<llvm::Value *> InOutArgs;
+  std::vector<llvm::Type *> InOutArgTypes;
+  std::vector<llvm::Type *> InOutArgElemTypes;
+
+  // Destination blocks for 'asm gotos'.
+  llvm::BasicBlock *DefaultDest = nullptr;
+  SmallVector<llvm::BasicBlock *, 3> IndirectDests;
+
+  std::vector<std::optional<std::pair<unsigned, unsigned>>> ResultBounds;
+
+  // An inline asm can be marked readonly if it meets the following conditions:
+  //
+  //   - it doesn't have any sideeffects
+  //   - it doesn't clobber memory
+  //   - it doesn't return a value by-reference
+  //
+  // It can be marked readnone if it doesn't have any input memory constraints
+  // in addition to meeting the conditions listed above.
+  bool ReadOnly = true;
+  bool ReadNone = true;
+
+  // Prefer to use registers to memory for constraints that allow both.
+  bool PreferRegs = false;
----------------
JustinStitt wrote:

I see `PreferRegs` plumbed throughout this diff but looking at the tree I don't 
see where it is actually used. Is it used anywhere?

https://github.com/llvm/llvm-project/pull/196885
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to