Skip to content

Commit 9da72be

Browse files
author
Burhan Söğüt
authored
Merge branch 'main' into fix/macos-openmp-build-error
2 parents c9d9557 + 6aa9d92 commit 9da72be

File tree

244 files changed

+17599
-6814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

244 files changed

+17599
-6814
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3752,12 +3752,23 @@ class CIR_UnaryFPToFPBuiltinOp<string mnemonic, string llvmOpName>
37523752
let llvmOp = llvmOpName;
37533753
}
37543754

3755+
def CIR_ACosOp : CIR_UnaryFPToFPBuiltinOp<"acos", "ACosOp"> {
3756+
let summary = "Computes the arcus cosine of the specified value";
3757+
let description = [{
3758+
`cir.acos`computes the arcus cosine of a given value and
3759+
returns a result of the same type.
3760+
3761+
Floating-point exceptions are ignored, and it does not set `errno`.
3762+
}];
3763+
}
3764+
37553765
def CIR_FAbsOp : CIR_UnaryFPToFPBuiltinOp<"fabs", "FAbsOp"> {
37563766
let summary = "Computes the floating-point absolute value";
37573767
let description = [{
37583768
`cir.fabs` computes the absolute value of a floating-point operand
3759-
and returns a result of the same type, ignoring floating-point
3760-
exceptions. It does not set `errno`.
3769+
and returns a result of the same type.
3770+
3771+
Floating-point exceptions are ignored, and it does not set `errno`.
37613772
}];
37623773
}
37633774

clang/lib/CIR/CodeGen/CIRGenAtomic.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ bool AtomicInfo::requiresMemSetZero(mlir::Type ty) const {
159159
case cir::TEK_Scalar:
160160
return !isFullSizeType(cgf.cgm, ty, atomicSizeInBits);
161161
case cir::TEK_Complex:
162-
cgf.cgm.errorNYI(loc, "AtomicInfo::requiresMemSetZero: complex type");
163-
return false;
164-
162+
return !isFullSizeType(cgf.cgm,
163+
mlir::cast<cir::ComplexType>(ty).getElementType(),
164+
atomicSizeInBits / 2);
165165
// Padding in structs has an undefined bit pattern. User beware.
166166
case cir::TEK_Aggregate:
167167
return false;
@@ -556,9 +556,11 @@ void CIRGenFunction::emitAtomicInit(Expr *init, LValue dest) {
556556
return;
557557
}
558558

559-
case cir::TEK_Complex:
560-
cgm.errorNYI(init->getSourceRange(), "emitAtomicInit: complex type");
559+
case cir::TEK_Complex: {
560+
mlir::Value value = emitComplexExpr(init);
561+
atomics.emitCopyIntoMemory(RValue::get(value));
561562
return;
563+
}
562564

563565
case cir::TEK_Aggregate:
564566
cgm.errorNYI(init->getSourceRange(), "emitAtomicInit: aggregate type");

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ static RValue emitUnaryMaybeConstrainedFPBuiltin(CIRGenFunction &cgf,
8585
return RValue::get(call->getResult(0));
8686
}
8787

88+
template <class Operation>
89+
static RValue emitUnaryFPBuiltin(CIRGenFunction &cgf, const CallExpr &e) {
90+
mlir::Value arg = cgf.emitScalarExpr(e.getArg(0));
91+
auto call =
92+
Operation::create(cgf.getBuilder(), arg.getLoc(), arg.getType(), arg);
93+
return RValue::get(call->getResult(0));
94+
}
95+
8896
RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
8997
const CallExpr *e,
9098
ReturnValueSlot returnValue) {
@@ -349,6 +357,9 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
349357
case Builtin::BI__builtin_unreachable:
350358
emitUnreachable(e->getExprLoc(), /*createNewBlock=*/true);
351359
return RValue::get(nullptr);
360+
361+
case Builtin::BI__builtin_elementwise_acos:
362+
return emitUnaryFPBuiltin<cir::ACosOp>(*this, *e);
352363
}
353364

354365
// If this is an alias for a lib function (e.g. __builtin_sin), emit

clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,18 @@ class OpenACCClauseCIREmitter final
548548
mlir::Value mainOp, CharUnits alignment,
549549
QualType baseType,
550550
mlir::Region &destroyRegion) {
551-
mlir::Block *block = builder.createBlock(
552-
&destroyRegion, destroyRegion.end(), {mainOp.getType()}, {loc});
551+
mlir::Block *block =
552+
builder.createBlock(&destroyRegion, destroyRegion.end(),
553+
{mainOp.getType(), mainOp.getType()}, {loc, loc});
553554
builder.setInsertionPointToEnd(&destroyRegion.back());
554555
CIRGenFunction::LexicalScope ls(cgf, loc, block);
555556

556557
mlir::Type elementTy =
557558
mlir::cast<cir::PointerType>(mainOp.getType()).getPointee();
558-
Address addr{block->getArgument(0), elementTy, alignment};
559+
// The destroy region has a signature of "original item, privatized item".
560+
// So the 2nd item is the one that needs destroying, the former is just for
561+
// reference and we don't really have a need for it at the moment.
562+
Address addr{block->getArgument(1), elementTy, alignment};
559563
cgf.emitDestroy(addr, baseType,
560564
cgf.getDestroyer(QualType::DK_cxx_destructor));
561565

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,15 @@ struct ConvertCIRToLLVMPass
577577
StringRef getArgument() const override { return "cir-flat-to-llvm"; }
578578
};
579579

580+
mlir::LogicalResult CIRToLLVMACosOpLowering::matchAndRewrite(
581+
cir::ACosOp op, OpAdaptor adaptor,
582+
mlir::ConversionPatternRewriter &rewriter) const {
583+
mlir::Type resTy = typeConverter->convertType(op.getType());
584+
rewriter.replaceOpWithNewOp<mlir::LLVM::ACosOp>(op, resTy,
585+
adaptor.getOperands()[0]);
586+
return mlir::success();
587+
}
588+
580589
mlir::LogicalResult CIRToLLVMAssumeOpLowering::matchAndRewrite(
581590
cir::AssumeOp op, OpAdaptor adaptor,
582591
mlir::ConversionPatternRewriter &rewriter) const {
@@ -2396,6 +2405,7 @@ void ConvertCIRToLLVMPass::runOnOperation() {
23962405
dl);
23972406
patterns.add<
23982407
// clang-format off
2408+
CIRToLLVMACosOpLowering,
23992409
CIRToLLVMAssumeOpLowering,
24002410
CIRToLLVMAssumeAlignedOpLowering,
24012411
CIRToLLVMAssumeSepStorageOpLowering,

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,15 @@ class CIRToLLVMFAbsOpLowering : public mlir::OpConversionPattern<cir::FAbsOp> {
718718
mlir::ConversionPatternRewriter &) const override;
719719
};
720720

721+
class CIRToLLVMACosOpLowering : public mlir::OpConversionPattern<cir::ACosOp> {
722+
public:
723+
using mlir::OpConversionPattern<cir::ACosOp>::OpConversionPattern;
724+
725+
mlir::LogicalResult
726+
matchAndRewrite(cir::ACosOp op, OpAdaptor,
727+
mlir::ConversionPatternRewriter &) const override;
728+
};
729+
721730
class CIRToLLVMInlineAsmOpLowering
722731
: public mlir::OpConversionPattern<cir::InlineAsmOp> {
723732
mlir::DataLayout const &dataLayout;

0 commit comments

Comments
 (0)