Skip to content

Commit ca32509

Browse files
xlaukommha
authored andcommitted
cherry-pick 0bedc28 Clean up and complete CIRGlobalValueInterface methods
1 parent 2821206 commit ca32509

File tree

2 files changed

+56
-17
lines changed

2 files changed

+56
-17
lines changed

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -517,15 +517,6 @@ def GlobalOp : CIR_Op<"global"> {
517517
let extraClassDeclaration = [{
518518
bool isDeclaration() { return !getInitialValue(); }
519519
bool hasInitializer() { return !isDeclaration(); }
520-
bool hasAvailableExternallyLinkage() {
521-
return cir::isAvailableExternallyLinkage(getLinkage());
522-
}
523-
bool hasInternalLinkage() {
524-
return cir::isInternalLinkage(getLinkage());
525-
}
526-
/// Whether the definition of this global may be replaced at link time.
527-
bool isWeakForLinker() { return cir::isWeakForLinker(getLinkage()); }
528-
bool isDSOLocal() { return getDsolocal(); }
529520
}];
530521

531522
let skipDefaultBuilders = 1;

clang/include/clang/CIR/Interfaces/CIROpInterfaces.td

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,54 @@
1414
#define CLANG_CIR_INTERFACES_CIROPINTERFACES_TD
1515

1616
include "mlir/IR/OpBase.td"
17+
include "mlir/IR/SymbolInterfaces.td"
1718

1819
let cppNamespace = "::cir" in {
19-
def CIRGlobalValueInterface : OpInterface<"CIRGlobalValueInterface"> {
20+
def CIRGlobalValueInterface
21+
: OpInterface<"CIRGlobalValueInterface", [Symbol]> {
2022

2123
let methods =
22-
[InterfaceMethod<"", "bool", "hasAvailableExternallyLinkage", (ins),
24+
[InterfaceMethod<"", "bool", "hasExternalLinkage", (ins), [{}],
25+
/*defaultImplementation=*/[{
26+
return cir::isExternalLinkage($_op.getLinkage());
27+
}]>,
28+
InterfaceMethod<"", "bool", "hasAvailableExternallyLinkage", (ins),
2329
[{}],
24-
/*defaultImplementation=*/[{ return false; }]>,
30+
/*defaultImplementation=*/[{
31+
return cir::isAvailableExternallyLinkage($_op.getLinkage());
32+
}]>,
33+
InterfaceMethod<"", "bool", "hasLinkOnceLinkage", (ins), [{}],
34+
/*defaultImplementation=*/[{
35+
return cir::isLinkOnceLinkage($_op.getLinkage());
36+
}]>,
37+
InterfaceMethod<"", "bool", "hasLinkOnceAnyLinkage", (ins), [{}],
38+
/*defaultImplementation=*/[{
39+
return cir::isLinkOnceAnyLinkage($_op.getLinkage());
40+
}]>,
41+
InterfaceMethod<"", "bool", "hasLinkOnceODRLinkage", (ins), [{}],
42+
/*defaultImplementation=*/[{
43+
return cir::isLinkOnceODRLinkage($_op.getLinkage());
44+
}]>,
45+
InterfaceMethod<"", "bool", "hasWeakLinkage", (ins), [{}],
46+
/*defaultImplementation=*/[{
47+
return cir::isWeakLinkage($_op.getLinkage());
48+
}]>,
49+
InterfaceMethod<"", "bool", "hasWeakAnyLinkage", (ins), [{}],
50+
/*defaultImplementation=*/[{
51+
return cir::isWeakAnyLinkage($_op.getLinkage());
52+
}]>,
53+
InterfaceMethod<"", "bool", "hasWeakODRLinkage", (ins), [{}],
54+
/*defaultImplementation=*/[{
55+
return cir::isWeakODRLinkage($_op.getLinkage());
56+
}]>,
57+
InterfaceMethod<"", "bool", "hasInternalLinkage", (ins), [{}],
58+
/*defaultImplementation=*/[{
59+
return cir::isInternalLinkage($_op.getLinkage());
60+
}]>,
61+
InterfaceMethod<"", "bool", "hasPrivateLinkage", (ins), [{}],
62+
/*defaultImplementation=*/[{
63+
return cir::isPrivateLinkage($_op.getLinkage());
64+
}]>,
2565
InterfaceMethod<"", "bool", "hasLocalLinkage", (ins), [{}],
2666
/*defaultImplementation=*/[{
2767
return cir::isLocalLinkage($_op.getLinkage());
@@ -30,9 +70,9 @@ let cppNamespace = "::cir" in {
3070
/*defaultImplementation=*/[{
3171
return cir::isExternalWeakLinkage($_op.getLinkage());
3272
}]>,
33-
InterfaceMethod<"", "bool", "isExternalLinkage", (ins), [{}],
73+
InterfaceMethod<"", "bool", "hasCommonLinkage", (ins), [{}],
3474
/*defaultImplementation=*/[{
35-
return cir::isExternalLinkage($_op.getLinkage());
75+
return cir::isCommonLinkage($_op.getLinkage());
3676
}]>,
3777
InterfaceMethod<"", "bool", "isDeclarationForLinker", (ins), [{}],
3878
/*defaultImplementation=*/[{
@@ -44,10 +84,18 @@ let cppNamespace = "::cir" in {
4484
/*defaultImplementation=*/[{
4585
$_op.setDsolocal(val);
4686
}]>,
47-
];
87+
InterfaceMethod<"", "bool", "isDSOLocal", (ins), [{}],
88+
/*defaultImplementation=*/[{
89+
return $_op.getDsolocal();
90+
}]>,
91+
InterfaceMethod<"", "bool", "isWeakForLinker", (ins), [{}],
92+
/*defaultImplementation=*/[{
93+
return cir::isWeakForLinker($_op.getLinkage());
94+
}]>];
4895
let extraClassDeclaration = [{
49-
bool canBenefitFromLocalAlias();
50-
}];
96+
bool hasDefaultVisibility();
97+
bool canBenefitFromLocalAlias();
98+
}];
5199
}
52100

53101
} // namespace cir

0 commit comments

Comments
 (0)