Skip to content

Commit fd02651

Browse files
committed
Address review comments
1 parent 9b98af6 commit fd02651

File tree

9 files changed

+1276
-1371
lines changed

9 files changed

+1276
-1371
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 143 additions & 174 deletions
Large diffs are not rendered by default.

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 44 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "mlir/IR/Builders.h"
1919
#include "mlir/IR/BuiltinTypes.h"
20+
#include "mlir/IR/Location.h"
2021
#include "mlir/IR/Types.h"
2122

2223
namespace cir {
@@ -147,17 +148,6 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
147148
return createCast(loc, cir::CastKind::bitcast, src, newTy);
148149
}
149150

150-
mlir::Value createBinOp(mlir::Value lhs, cir::BinOpKind kind,
151-
const llvm::APInt &rhs) {
152-
return create<cir::BinOp>(lhs.getLoc(), lhs.getType(), kind, lhs,
153-
getConstAPInt(lhs.getLoc(), lhs.getType(), rhs));
154-
}
155-
156-
mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
157-
mlir::Value rhs) {
158-
return create<cir::BinOp>(lhs.getLoc(), lhs.getType(), kind, lhs, rhs);
159-
}
160-
161151
mlir::Value createBinop(mlir::Location loc, mlir::Value lhs,
162152
cir::BinOpKind kind, mlir::Value rhs) {
163153
return create<cir::BinOp>(loc, lhs.getType(), kind, lhs, rhs);
@@ -166,93 +156,74 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
166156
mlir::Value createLowBitsSet(mlir::Location loc, unsigned size,
167157
unsigned bits) {
168158
llvm::APInt val = llvm::APInt::getLowBitsSet(size, bits);
169-
auto type = cir::IntType::get(getContext(), size, false);
159+
auto type = cir::IntType::get(getContext(), size, /*isSigned=*/false);
170160
return getConstAPInt(loc, type, val);
171161
}
172162

173-
mlir::Value createAnd(mlir::Value lhs, const llvm::APInt &rhs) {
174-
mlir::Value val = getConstAPInt(lhs.getLoc(), lhs.getType(), rhs);
175-
return createBinop(lhs, cir::BinOpKind::And, val);
176-
}
177-
178-
mlir::Value createAnd(mlir::Value lhs, mlir::Value rhs) {
179-
return createBinop(lhs, cir::BinOpKind::And, rhs);
180-
}
181-
182163
mlir::Value createAnd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs) {
183164
return createBinop(loc, lhs, cir::BinOpKind::And, rhs);
184165
}
185166

186-
mlir::Value createOr(mlir::Value lhs, const llvm::APInt &rhs) {
187-
mlir::Value val = getConstAPInt(lhs.getLoc(), lhs.getType(), rhs);
188-
return createBinop(lhs, cir::BinOpKind::Or, val);
189-
}
190-
191-
mlir::Value createOr(mlir::Value lhs, mlir::Value rhs) {
192-
return createBinop(lhs, cir::BinOpKind::Or, rhs);
167+
mlir::Value createOr(mlir::Location loc, mlir::Value lhs, mlir::Value rhs) {
168+
return createBinop(loc, lhs, cir::BinOpKind::Or, rhs);
193169
}
194170

195-
mlir::Value createMul(mlir::Value lhs, mlir::Value rhs, bool hasNUW = false,
196-
bool hasNSW = false) {
197-
auto op = create<cir::BinOp>(lhs.getLoc(), lhs.getType(),
198-
cir::BinOpKind::Mul, lhs, rhs);
199-
if (hasNUW)
200-
op.setNoUnsignedWrap(true);
201-
if (hasNSW)
202-
op.setNoSignedWrap(true);
171+
mlir::Value createMul(mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
172+
bool hasNUW = false, bool hasNSW = false) {
173+
auto op =
174+
create<cir::BinOp>(loc, lhs.getType(), cir::BinOpKind::Mul, lhs, rhs);
175+
op.setNoUnsignedWrap(hasNUW);
176+
op.setNoSignedWrap(hasNSW);
203177
return op;
204178
}
205-
mlir::Value createNSWMul(mlir::Value lhs, mlir::Value rhs) {
206-
return createMul(lhs, rhs, false, true);
207-
}
208-
mlir::Value createNUWAMul(mlir::Value lhs, mlir::Value rhs) {
209-
return createMul(lhs, rhs, true, false);
179+
mlir::Value createNSWMul(mlir::Location loc, mlir::Value lhs,
180+
mlir::Value rhs) {
181+
return createMul(loc, lhs, rhs, false, true);
210182
}
211-
212-
mlir::Value createMul(mlir::Value lhs, const llvm::APInt &rhs) {
213-
mlir::Value val = getConstAPInt(lhs.getLoc(), lhs.getType(), rhs);
214-
return createBinop(lhs, cir::BinOpKind::Mul, val);
183+
mlir::Value createNUWAMul(mlir::Location loc, mlir::Value lhs,
184+
mlir::Value rhs) {
185+
return createMul(loc, lhs, rhs, true, false);
215186
}
216187

217-
mlir::Value createSub(mlir::Value lhs, mlir::Value rhs, bool hasNUW = false,
218-
bool hasNSW = false, bool saturated = false) {
219-
auto op = create<cir::BinOp>(lhs.getLoc(), lhs.getType(),
220-
cir::BinOpKind::Sub, lhs, rhs);
221-
if (hasNUW)
222-
op.setNoUnsignedWrap(true);
223-
if (hasNSW)
224-
op.setNoSignedWrap(true);
225-
if (saturated)
226-
op.setSaturated(true);
188+
mlir::Value createSub(mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
189+
bool hasNUW = false, bool hasNSW = false,
190+
bool saturated = false) {
191+
auto op =
192+
create<cir::BinOp>(loc, lhs.getType(), cir::BinOpKind::Sub, lhs, rhs);
193+
op.setNoUnsignedWrap(hasNUW);
194+
op.setNoSignedWrap(hasNSW);
195+
op.setSaturated(saturated);
227196
return op;
228197
}
229198

230-
mlir::Value createNSWSub(mlir::Value lhs, mlir::Value rhs) {
231-
return createSub(lhs, rhs, false, true);
199+
mlir::Value createNSWSub(mlir::Location loc, mlir::Value lhs,
200+
mlir::Value rhs) {
201+
return createSub(loc, lhs, rhs, false, true);
232202
}
233203

234-
mlir::Value createNUWSub(mlir::Value lhs, mlir::Value rhs) {
235-
return createSub(lhs, rhs, true, false);
204+
mlir::Value createNUWSub(mlir::Location loc, mlir::Value lhs,
205+
mlir::Value rhs) {
206+
return createSub(loc, lhs, rhs, true, false);
236207
}
237208

238-
mlir::Value createAdd(mlir::Value lhs, mlir::Value rhs, bool hasNUW = false,
239-
bool hasNSW = false, bool saturated = false) {
240-
auto op = create<cir::BinOp>(lhs.getLoc(), lhs.getType(),
241-
cir::BinOpKind::Add, lhs, rhs);
242-
if (hasNUW)
243-
op.setNoUnsignedWrap(true);
244-
if (hasNSW)
245-
op.setNoSignedWrap(true);
246-
if (saturated)
247-
op.setSaturated(true);
209+
mlir::Value createAdd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
210+
bool hasNUW = false, bool hasNSW = false,
211+
bool saturated = false) {
212+
auto op =
213+
create<cir::BinOp>(loc, lhs.getType(), cir::BinOpKind::Add, lhs, rhs);
214+
op.setNoUnsignedWrap(hasNUW);
215+
op.setNoSignedWrap(hasNSW);
216+
op.setSaturated(saturated);
248217
return op;
249218
}
250219

251-
mlir::Value createNSWAdd(mlir::Value lhs, mlir::Value rhs) {
252-
return createAdd(lhs, rhs, false, true);
220+
mlir::Value createNSWAdd(mlir::Location loc, mlir::Value lhs,
221+
mlir::Value rhs) {
222+
return createAdd(loc, lhs, rhs, false, true);
253223
}
254-
mlir::Value createNUWAdd(mlir::Value lhs, mlir::Value rhs) {
255-
return createAdd(lhs, rhs, true, false);
224+
mlir::Value createNUWAdd(mlir::Location loc, mlir::Value lhs,
225+
mlir::Value rhs) {
226+
return createAdd(loc, lhs, rhs, true, false);
256227
}
257228

258229
//

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,6 @@ def BinOpKind : I32EnumAttr<
852852
let cppNamespace = "::cir";
853853
}
854854

855-
// FIXME: Pure won't work when we add overloading.
856855
def BinOp : CIR_Op<"binop", [Pure,
857856
SameTypeOperands, SameOperandsAndResultType]> {
858857

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ struct MissingFeatures {
9696
static bool stackSaveOp() { return false; }
9797
static bool aggValueSlot() { return false; }
9898
static bool generateDebugInfo() { return false; }
99-
static bool getFPFeaturesInEffect() { return false; }
10099
static bool pointerOverflowSanitizer() { return false; }
101100
static bool fpConstraints() { return false; }
102101
static bool sanitizers() { return false; }
@@ -137,7 +136,7 @@ struct MissingFeatures {
137136
static bool tryOp() { return false; }
138137
static bool zextOp() { return false; }
139138
static bool ptrStrideOp() { return false; }
140-
static bool opPtrDiff() { return false; }
139+
static bool ptrDiffOp() { return false; }
141140
};
142141

143142
} // namespace cir

0 commit comments

Comments
 (0)