Skip to content

Commit 4542b89

Browse files
committed
Address code review comments
1 parent cc7dd9d commit 4542b89

File tree

4 files changed

+319
-180
lines changed

4 files changed

+319
-180
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,6 +2843,9 @@ def CIR_ComplexMulOp : CIR_Op<"complex.mul", [
28432843
The `cir.complex.mul` operation takes two complex numbers and returns
28442844
their product.
28452845

2846+
Range is used to controls the various implementations for complex
2847+
multiplication.
2848+
28462849
Example:
28472850

28482851
```mlir

clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ getComplexRangeAttr(LangOptions::ComplexRangeKind range) {
651651
case LangOptions::CX_Basic:
652652
return cir::ComplexRangeKind::Basic;
653653
case LangOptions::CX_None:
654+
// The default value for ComplexRangeKind is Full is no option is selected
654655
return cir::ComplexRangeKind::Full;
655656
}
656657
}

clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct LoweringPreparePass : public LoweringPrepareBase<LoweringPreparePass> {
4444
clang::ASTContext *astCtx;
4545

4646
/// Tracks current module.
47-
mlir::ModuleOp theModule;
47+
mlir::ModuleOp mlirModule;
4848

4949
void setASTContext(clang::ASTContext *c) { astCtx = c; }
5050
};
@@ -55,7 +55,7 @@ cir::FuncOp LoweringPreparePass::buildRuntimeFunction(
5555
mlir::OpBuilder &builder, llvm::StringRef name, mlir::Location loc,
5656
cir::FuncType type, cir::GlobalLinkageKind linkage) {
5757
cir::FuncOp f = dyn_cast_or_null<FuncOp>(SymbolTable::lookupNearestSymbolFrom(
58-
theModule, StringAttr::get(theModule->getContext(), name)));
58+
mlirModule, StringAttr::get(mlirModule->getContext(), name)));
5959
if (!f) {
6060
f = builder.create<cir::FuncOp>(loc, name, type);
6161
f.setLinkageAttr(
@@ -167,10 +167,12 @@ static mlir::Value buildComplexBinOpLibCall(
167167

168168
cir::FuncType libFuncTy = cir::FuncType::get(libFuncInputTypes, ty);
169169

170+
// Inserting a declaration for the runtime function to be used in Complex
171+
// multiplication and division when needed
170172
cir::FuncOp libFunc;
171173
{
172174
mlir::OpBuilder::InsertionGuard ipGuard{builder};
173-
builder.setInsertionPointToStart(pass.theModule.getBody());
175+
builder.setInsertionPointToStart(pass.mlirModule.getBody());
174176
libFunc = pass.buildRuntimeFunction(builder, libFuncName, loc, libFuncTy);
175177
}
176178

@@ -228,6 +230,8 @@ static mlir::Value lowerComplexMul(LoweringPreparePass &pass,
228230
rangeKind == cir::ComplexRangeKind::Promoted)
229231
return algebraicResult;
230232

233+
assert(!cir::MissingFeatures::fastMathFlags());
234+
231235
// Check whether the real part and the imaginary part of the result are both
232236
// NaN. If so, emit a library call to compute the multiplication instead.
233237
// We check a value against NaN by comparing the value against itself.
@@ -416,9 +420,8 @@ void LoweringPreparePass::runOnOp(mlir::Operation *op) {
416420

417421
void LoweringPreparePass::runOnOperation() {
418422
mlir::Operation *op = getOperation();
419-
if (isa<::mlir::ModuleOp>(op)) {
420-
theModule = cast<::mlir::ModuleOp>(op);
421-
}
423+
if (isa<::mlir::ModuleOp>(op))
424+
mlirModule = cast<::mlir::ModuleOp>(op);
422425

423426
llvm::SmallVector<mlir::Operation *> opsToTransform;
424427

0 commit comments

Comments
 (0)