1010//
1111// ===----------------------------------------------------------------------===//
1212
13- #include " clang/Basic/DiagnosticSema.h"
14- #include " llvm/ADT/StringExtras.h"
15-
1613#include " CIRGenFunction.h"
17- #include " TargetInfo.h"
1814#include " clang/CIR/MissingFeatures.h"
1915
2016using namespace clang ;
@@ -39,28 +35,26 @@ static void collectClobbers(const CIRGenFunction &cgf, const AsmStmt &s,
3935
4036 // Clobbers
4137 for (unsigned i = 0 , e = s.getNumClobbers (); i != e; i++) {
42- std::string clobberStr = s.getClobber (i);
43- StringRef clobber{clobberStr};
44- if (clobber == " memory" )
38+ std::string clobber = s.getClobber (i);
39+ if (clobber == " memory" ) {
4540 readOnly = readNone = false ;
46- else if (clobber == " unwind" ) {
41+ } else if (clobber == " unwind" ) {
4742 hasUnwindClobber = true ;
4843 continue ;
4944 } else if (clobber != " cc" ) {
5045 clobber = cgf.getTarget ().getNormalizedGCCRegisterName (clobber);
5146 if (cgm.getCodeGenOpts ().StackClashProtector &&
52- cgf.getTarget ().isSPRegName (clobber)) {
47+ cgf.getTarget ().isSPRegName (clobber))
5348 cgm.getDiags ().Report (s.getAsmLoc (),
5449 diag::warn_stack_clash_protection_inline_asm);
55- }
5650 }
5751
5852 if (isa<MSAsmStmt>(&s)) {
5953 if (clobber == " eax" || clobber == " edx" ) {
6054 if (constraints.find (" =&A" ) != std::string::npos)
6155 continue ;
6256 std::string::size_type position1 =
63- constraints.find (" ={" + clobber. str () + " }" );
57+ constraints.find (" ={" + clobber + " }" );
6458 if (position1 != std::string::npos) {
6559 constraints.insert (position1 + 1 , " &" );
6660 continue ;
@@ -93,7 +87,12 @@ mlir::LogicalResult CIRGenFunction::emitAsmStmt(const AsmStmt &s) {
9387 // Assemble the final asm string.
9488 std::string asmString = s.generateAsmString (getContext ());
9589
90+ bool isGCCAsmGoto = false ;
91+
9692 std::string constraints;
93+ std::vector<mlir::Value> outArgs;
94+ std::vector<mlir::Value> inArgs;
95+ std::vector<mlir::Value> inOutArgs;
9796
9897 // An inline asm can be marked readonly if it meets the following conditions:
9998 // - it doesn't have any sideeffects
@@ -112,7 +111,8 @@ mlir::LogicalResult CIRGenFunction::emitAsmStmt(const AsmStmt &s) {
112111 bool hasUnwindClobber = false ;
113112 collectClobbers (*this , s, constraints, hasUnwindClobber, readOnly, readNone);
114113
115- llvm::SmallVector<mlir::ValueRange, 8 > operands;
114+ std::array<mlir::ValueRange, 3 > operands = {outArgs, inArgs, inOutArgs};
115+
116116 mlir::Type resultType;
117117
118118 bool hasSideEffect = s.isVolatile () || s.getNumOutputs () == 0 ;
@@ -121,7 +121,7 @@ mlir::LogicalResult CIRGenFunction::emitAsmStmt(const AsmStmt &s) {
121121 getLoc (s.getAsmLoc ()), resultType, operands, asmString, constraints,
122122 hasSideEffect, inferFlavor (cgm, s), mlir::ArrayAttr ());
123123
124- if (false /* IsGCCAsmGoto */ ) {
124+ if (isGCCAsmGoto ) {
125125 assert (!cir::MissingFeatures::asmGoto ());
126126 } else if (hasUnwindClobber) {
127127 assert (!cir::MissingFeatures::asmUnwindClobber ());
0 commit comments