Skip to content

Commit 5328c79

Browse files
committed
Address comments
1 parent b1b7b10 commit 5328c79

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

clang/lib/CIR/CodeGen/CIRGenAsm.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
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

2016
using 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());

clang/test/CIR/CodeGen/inline-asm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@
55

66
void f1() {
77
// CIR: cir.asm(x86_att,
8+
// CIR: out = [],
9+
// CIR: in = [],
10+
// CIR: in_out = [],
811
// CIR: {"" "~{dirflag},~{fpsr},~{flags}"}) side_effects
912
// LLVM: call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"()
1013
__asm__ volatile("" : : : );
1114
}
1215

1316
void f2() {
1417
// CIR: cir.asm(x86_att,
18+
// CIR: out = [],
19+
// CIR: in = [],
20+
// CIR: in_out = [],
1521
// CIR: {"nop" "~{dirflag},~{fpsr},~{flags}"}) side_effects
1622
// LLVM: call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
1723
__asm__ volatile("nop" : : : );

0 commit comments

Comments
 (0)