Skip to content

Commit 91c64fa

Browse files
authored
Merge branch 'main' into x86-phminposuw
2 parents c32f4bb + 9ba54ca commit 91c64fa

File tree

167 files changed

+2841
-699
lines changed

Some content is hidden

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

167 files changed

+2841
-699
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
/mlir/test/python/ @ftynse @makslevental @stellaraccident @rolfmorel
132132
/mlir/python/ @ftynse @makslevental @stellaraccident @rolfmorel
133133
/mlir/lib/Bindings/Python @makslevental @rolfmorel
134+
/mlir/include/Bindings/Python @makslevental @rolfmorel
134135

135136
# MLIR Mem2Reg/SROA
136137
/mlir/**/Transforms/Mem2Reg.* @moxinilian

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
127127
cir::BoolType getBoolTy() { return cir::BoolType::get(getContext()); }
128128
cir::VoidType getVoidTy() { return cir::VoidType::get(getContext()); }
129129

130+
cir::IntType getUIntNTy(int n) {
131+
return cir::IntType::get(getContext(), n, false);
132+
}
133+
134+
cir::IntType getSIntNTy(int n) {
135+
return cir::IntType::get(getContext(), n, true);
136+
}
137+
130138
cir::PointerType getPointerTo(mlir::Type ty) {
131139
return cir::PointerType::get(ty);
132140
}

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,49 @@ def CIR_TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", [TypedAttrInterface]> {
967967
`<` custom<RecordMembers>($data) `>`
968968
}];
969969
}
970+
//===----------------------------------------------------------------------===//
971+
// InlineAttr
972+
//===----------------------------------------------------------------------===//
973+
974+
def CIR_InlineKind : CIR_I32EnumAttr<"InlineKind", "inlineKind", [
975+
I32EnumAttrCase<"NoInline", 1, "never">,
976+
I32EnumAttrCase<"AlwaysInline", 2, "always">,
977+
I32EnumAttrCase<"InlineHint", 3, "hint">
978+
]> {
979+
let genSpecializedAttr = 0;
980+
}
981+
982+
def CIR_InlineAttr : CIR_EnumAttr<CIR_InlineKind, "inline"> {
983+
let summary = "Inline attribute";
984+
let description = [{
985+
Inline attribute represents user directives for inlining behavior.
986+
This attribute is only used by `cir.func` operations.
987+
988+
Values:
989+
- `never`: Prevents the function from being inlined (__attribute__((noinline)))
990+
- `always`: Forces the function to be inlined (__attribute__((always_inline)))
991+
- `hint`: Suggests the function should be inlined (inline keyword)
992+
993+
Example:
994+
```
995+
cir.func @noinline_func(%arg0: !s32i) -> !s32i inline(never) {
996+
cir.return %arg0 : !s32i
997+
}
998+
cir.func @always_inline_func() -> !s32i inline(always) {
999+
%0 = cir.const #cir.int<42> : !s32i
1000+
cir.return %0 : !s32i
1001+
}
1002+
```
1003+
}];
1004+
1005+
let cppClassName = "InlineAttr";
1006+
1007+
let extraClassDeclaration = [{
1008+
bool isNoInline() const { return getValue() == InlineKind::NoInline; };
1009+
bool isAlwaysInline() const { return getValue() == InlineKind::AlwaysInline; };
1010+
bool isInlineHint() const { return getValue() == InlineKind::InlineHint; };
1011+
}];
1012+
}
9701013

9711014
//===----------------------------------------------------------------------===//
9721015
// CatchAllAttr & UnwindAttr

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2476,6 +2476,10 @@ def CIR_FuncOp : CIR_Op<"func", [
24762476
Similarly, for global destructors both `global_dtor` and
24772477
`global_dtor(<priority>)` are available.
24782478

2479+
The `inline(never)` keyword marks a function that should not be inlined.
2480+
The `inline(always)` keyword marks a function that should always be inlined.
2481+
The `inline(hint)` keyword suggests that the function should be inlined.
2482+
24792483
Example:
24802484

24812485
```mlir
@@ -2510,6 +2514,7 @@ def CIR_FuncOp : CIR_Op<"func", [
25102514
UnitAttr:$dso_local,
25112515
DefaultValuedAttr<CIR_GlobalLinkageKind,
25122516
"cir::GlobalLinkageKind::ExternalLinkage">:$linkage,
2517+
OptionalAttr<CIR_InlineAttr>:$inline_kind,
25132518
OptionalAttr<StrAttr>:$sym_visibility,
25142519
UnitAttr:$comdat,
25152520
OptionalAttr<DictArrayAttr>:$arg_attrs,

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,31 @@ struct MissingFeatures {
6969
static bool opAllocaCaptureByInit() { return false; }
7070

7171
// FuncOp handling
72-
static bool opFuncOpenCLKernelMetadata() { return false; }
72+
static bool opFuncArmNewAttr() { return false; }
73+
static bool opFuncArmStreamingAttr() { return false; }
7374
static bool opFuncAstDeclAttr() { return false; }
74-
static bool opFuncAttributesForDefinition() { return false; }
7575
static bool opFuncCallingConv() { return false; }
76+
static bool opFuncColdHotAttr() { return false; }
7677
static bool opFuncCPUAndFeaturesAttributes() { return false; }
7778
static bool opFuncExceptions() { return false; }
7879
static bool opFuncExtraAttrs() { return false; }
7980
static bool opFuncMaybeHandleStaticInExternC() { return false; }
81+
static bool opFuncMinSizeAttr() { return false; }
8082
static bool opFuncMultipleReturnVals() { return false; }
83+
static bool opFuncNakedAttr() { return false; }
84+
static bool opFuncNoDuplicateAttr() { return false; }
8185
static bool opFuncNoUnwind() { return false; }
86+
static bool opFuncOpenCLKernelMetadata() { return false; }
8287
static bool opFuncOperandBundles() { return false; }
88+
static bool opFuncOptNoneAttr() { return false; }
8389
static bool opFuncParameterAttributes() { return false; }
8490
static bool opFuncReadOnly() { return false; }
8591
static bool opFuncSection() { return false; }
92+
static bool opFuncUnwindTablesAttr() { return false; }
8693
static bool opFuncWillReturn() { return false; }
8794
static bool opFuncNoReturn() { return false; }
88-
static bool setLLVMFunctionFEnvAttributes() { return false; }
8995
static bool setFunctionAttributes() { return false; }
96+
static bool setLLVMFunctionFEnvAttributes() { return false; }
9097

9198
// CallOp handling
9299
static bool opCallAggregateArgs() { return false; }
@@ -271,6 +278,7 @@ struct MissingFeatures {
271278
static bool objCBlocks() { return false; }
272279
static bool objCGC() { return false; }
273280
static bool objCLifetime() { return false; }
281+
static bool hlsl() { return false; }
274282
static bool openCL() { return false; }
275283
static bool openMP() { return false; }
276284
static bool opTBAA() { return false; }
@@ -288,6 +296,7 @@ struct MissingFeatures {
288296
static bool sourceLanguageCases() { return false; }
289297
static bool stackBase() { return false; }
290298
static bool stackSaveOp() { return false; }
299+
static bool stackProtector() { return false; }
291300
static bool targetCIRGenInfoArch() { return false; }
292301
static bool targetCIRGenInfoOS() { return false; }
293302
static bool targetCodeGenInfoGetNullPointer() { return false; }

clang/lib/AST/ByteCode/InterpBlock.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,19 @@ bool Block::hasPointer(const Pointer *P) const {
100100
}
101101
#endif
102102

103+
void Block::movePointersTo(Block *B) {
104+
assert(B != this);
105+
106+
while (Pointers) {
107+
Pointer *P = Pointers;
108+
109+
this->removePointer(P);
110+
P->BS.Pointee = B;
111+
B->addPointer(P);
112+
}
113+
assert(!this->hasPointers());
114+
}
115+
103116
DeadBlock::DeadBlock(DeadBlock *&Root, Block *Blk)
104117
: Root(Root), B(~0u, Blk->Desc, Blk->isExtern(), Blk->IsStatic,
105118
Blk->isWeak(), Blk->isDummy(), /*IsDead=*/true) {

clang/lib/AST/ByteCode/InterpBlock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class Block final {
9292
bool isInitialized() const { return IsInitialized; }
9393
/// The Evaluation ID this block was created in.
9494
unsigned getEvalID() const { return EvalID; }
95+
/// Move all pointers from this block to \param B.
96+
void movePointersTo(Block *B);
9597

9698
/// Returns a pointer to the stored data.
9799
/// You are allowed to read Desc->getSize() bytes from this address.

clang/lib/AST/ByteCode/Program.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,7 @@ UnsignedOrNone Program::createGlobal(const ValueDecl *VD, const Expr *Init) {
226226
Globals[PIdx] = NewGlobal;
227227
// All pointers pointing to the previous extern decl now point to the
228228
// new decl.
229-
for (Pointer *Ptr = RedeclBlock->Pointers; Ptr; Ptr = Ptr->BS.Next) {
230-
RedeclBlock->removePointer(Ptr);
231-
Ptr->BS.Pointee = NewGlobal->block();
232-
NewGlobal->block()->addPointer(Ptr);
233-
}
229+
RedeclBlock->movePointersTo(NewGlobal->block());
234230
}
235231
}
236232
PIdx = *Idx;

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,16 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
380380
/*relative_layout=*/false);
381381
}
382382

383+
mlir::Value createDynCastToVoid(mlir::Location loc, mlir::Value src,
384+
bool vtableUseRelativeLayout) {
385+
// TODO(cir): consider address space here.
386+
assert(!cir::MissingFeatures::addressSpace());
387+
cir::PointerType destTy = getVoidPtrTy();
388+
return cir::DynamicCastOp::create(
389+
*this, loc, destTy, cir::DynamicCastKind::Ptr, src,
390+
cir::DynamicCastInfoAttr{}, vtableUseRelativeLayout);
391+
}
392+
383393
Address createBaseClassAddr(mlir::Location loc, Address addr,
384394
mlir::Type destType, unsigned offset,
385395
bool assumeNotNull) {

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
463463
return emitLibraryCall(*this, fd, e,
464464
cgm.getBuiltinLibFunction(fd, builtinID));
465465

466-
cgm.errorNYI(e->getSourceRange(), "unimplemented builtin call");
466+
cgm.errorNYI(e->getSourceRange(),
467+
std::string("unimplemented builtin call: ") +
468+
getContext().BuiltinInfo.getName(builtinID));
467469
return getUndefRValue(e->getType());
468470
}
469471

0 commit comments

Comments
 (0)