Skip to content

Commit 4b75153

Browse files
committed
XXX
1 parent 7f27482 commit 4b75153

File tree

8 files changed

+53
-3
lines changed

8 files changed

+53
-3
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
256256
case Builtin::BI__builtin_popcountll:
257257
case Builtin::BI__builtin_popcountg:
258258
return emitBuiltinBitOp<cir::BitPopcountOp>(*this, e);
259-
260259
case Builtin::BI__builtin_expect:
261260
case Builtin::BI__builtin_expect_with_probability: {
262261
mlir::Value argValue = emitScalarExpr(e->getArg(0));

mlir/include/mlir/IR/EnumAttr.td

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class IntEnumAttrCaseBase<I intType, string sym, string strVal, int intVal> :
4242
let predicate = CPred<[{
4343
::llvm::cast<::mlir::IntegerAttr>($_self).getValue().eq(::llvm::APInt(}]
4444
# intType.bitwidth # ", "
45-
# intVal #
45+
# intVal #
4646
"))">;
4747
}
4848

@@ -495,6 +495,11 @@ class EnumParameter<EnumInfo enumInfo>
495495
!cast<EnumAttrInfo>(enumInfo).parameterPrinter, ?);
496496
}
497497

498+
class DefaultValuedEnumParameter<EnumInfo enumInfo, EnumCase value>
499+
: EnumParameter<enumInfo> {
500+
let defaultValue = enumInfo.cppType # "::" # value.symbol;
501+
}
502+
498503
// An attribute backed by a C++ enum. The attribute contains a single
499504
// parameter `value` whose type is the C++ enum class.
500505
//

mlir/test/lib/Dialect/Test/TestAttributes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <tuple>
1818

19+
#include "TestEnums.h"
1920
#include "TestTraits.h"
2021
#include "mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.h"
2122
#include "mlir/Dialect/Utils/StructuredOpsUtils.h"
@@ -27,7 +28,6 @@
2728

2829
// generated files require above includes to come first
2930
#include "TestAttrInterfaces.h.inc"
30-
#include "TestOpEnums.h.inc"
3131

3232
namespace test {
3333
class TestDialect;

mlir/test/lib/Dialect/Test/TestEnumDefs.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,15 @@ def MultiResultOpEnum: I64EnumAttr<
9696
MultiResultOpKind4, MultiResultOpKind5, MultiResultOpKind6
9797
]>;
9898

99+
//===----------------------------------------------------------------------===//
100+
// Test Enum with Default Value
101+
//===----------------------------------------------------------------------===//
102+
103+
def TestDefaultCase : I32EnumAttrCase<"Default", 0, "default">;
104+
def NonDefaultCase : I32EnumAttrCase<"NonDefault", 1, "non_default">;
105+
106+
def TestDefaultValuedEnum : I32Enum<"TestDefaultValuedEnum", "", [
107+
TestDefaultCase, NonDefaultCase
108+
]>;
109+
99110
#endif // TEST_ENUMDEFS
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file contains enum definitions for the Test dialect
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef MLIR_TESTENUMS_H
14+
#define MLIR_TESTENUMS_H
15+
16+
#include "mlir/IR/BuiltinAttributes.h"
17+
18+
#include "TestOpEnums.h.inc"
19+
20+
#endif // MLIR_TESTENUMS_H

mlir/test/lib/Dialect/Test/TestTypeDefs.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// To get the test dialect def.
1717
include "TestDialect.td"
1818
include "TestAttrDefs.td"
19+
include "TestEnumDefs.td"
1920
include "TestInterfaces.td"
2021
include "mlir/IR/BuiltinTypes.td"
2122
include "mlir/Interfaces/DataLayoutInterfaces.td"
@@ -286,6 +287,15 @@ def TestTypeOptionalGroupStruct : Test_Type<"TestTypeOptionalGroupStruct"> {
286287
let assemblyFormat = "`<` (`(` struct(params)^ `)`) : (`x`)? `>`";
287288
}
288289

290+
def TestTypeDefaultEnumParameter
291+
: Test_Type<"TestTypeDefaultEnumParameter"> {
292+
let parameters = (ins
293+
DefaultValuedEnumParameter<TestDefaultValuedEnum, TestDefaultCase>:$a
294+
);
295+
let mnemonic = "default_enum_parameter";
296+
let assemblyFormat = "`<` $a `>`";
297+
}
298+
289299
def TestTypeSpaces : Test_Type<"TestTypeSpaceS"> {
290300
let parameters = (ins "int":$a, "int":$b);
291301
let mnemonic = "spaces";

mlir/test/lib/Dialect/Test/TestTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <optional>
1818
#include <tuple>
1919

20+
#include "TestEnums.h"
2021
#include "TestTraits.h"
2122
#include "mlir/Dialect/Bufferization/IR/BufferizationTypeInterfaces.h"
2223
#include "mlir/IR/Diagnostics.h"

mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ attributes {
7777
// CHECK: !test.optional_type_string
7878
// CHECK: !test.optional_type_string<"non default">
7979
// CHECK: !test.optional_type_string<"containing\0A \22escape\22 characters\0F">
80+
// CHECK: !test.default_enum_parameter
81+
// CHECK: !test.default_enum_parameter<"non_default">
8082

8183
func.func private @test_roundtrip_default_parsers_struct(
8284
!test.no_parser<255, [1, 2, 3, 4, 5], "foobar", 4>
@@ -120,4 +122,6 @@ func.func private @test_roundtrip_default_parsers_struct(
120122
!test.optional_type_string<"default">,
121123
!test.optional_type_string<"non default">,
122124
!test.optional_type_string<"containing\n \"escape\" characters\0f">
125+
!test.default_enum_parameter,
126+
!test.default_enum_parameter<"non_default">,
123127
)

0 commit comments

Comments
 (0)