XXX
This commit is contained in:
parent
7f27482a32
commit
4b75153b65
@ -256,7 +256,6 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
|
||||
case Builtin::BI__builtin_popcountll:
|
||||
case Builtin::BI__builtin_popcountg:
|
||||
return emitBuiltinBitOp<cir::BitPopcountOp>(*this, e);
|
||||
|
||||
case Builtin::BI__builtin_expect:
|
||||
case Builtin::BI__builtin_expect_with_probability: {
|
||||
mlir::Value argValue = emitScalarExpr(e->getArg(0));
|
||||
|
@ -42,7 +42,7 @@ class IntEnumAttrCaseBase<I intType, string sym, string strVal, int intVal> :
|
||||
let predicate = CPred<[{
|
||||
::llvm::cast<::mlir::IntegerAttr>($_self).getValue().eq(::llvm::APInt(}]
|
||||
# intType.bitwidth # ", "
|
||||
# intVal #
|
||||
# intVal #
|
||||
"))">;
|
||||
}
|
||||
|
||||
@ -495,6 +495,11 @@ class EnumParameter<EnumInfo enumInfo>
|
||||
!cast<EnumAttrInfo>(enumInfo).parameterPrinter, ?);
|
||||
}
|
||||
|
||||
class DefaultValuedEnumParameter<EnumInfo enumInfo, EnumCase value>
|
||||
: EnumParameter<enumInfo> {
|
||||
let defaultValue = enumInfo.cppType # "::" # value.symbol;
|
||||
}
|
||||
|
||||
// An attribute backed by a C++ enum. The attribute contains a single
|
||||
// parameter `value` whose type is the C++ enum class.
|
||||
//
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#include "TestEnums.h"
|
||||
#include "TestTraits.h"
|
||||
#include "mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.h"
|
||||
#include "mlir/Dialect/Utils/StructuredOpsUtils.h"
|
||||
@ -27,7 +28,6 @@
|
||||
|
||||
// generated files require above includes to come first
|
||||
#include "TestAttrInterfaces.h.inc"
|
||||
#include "TestOpEnums.h.inc"
|
||||
|
||||
namespace test {
|
||||
class TestDialect;
|
||||
|
@ -96,4 +96,15 @@ def MultiResultOpEnum: I64EnumAttr<
|
||||
MultiResultOpKind4, MultiResultOpKind5, MultiResultOpKind6
|
||||
]>;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Test Enum with Default Value
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def TestDefaultCase : I32EnumAttrCase<"Default", 0, "default">;
|
||||
def NonDefaultCase : I32EnumAttrCase<"NonDefault", 1, "non_default">;
|
||||
|
||||
def TestDefaultValuedEnum : I32Enum<"TestDefaultValuedEnum", "", [
|
||||
TestDefaultCase, NonDefaultCase
|
||||
]>;
|
||||
|
||||
#endif // TEST_ENUMDEFS
|
||||
|
20
mlir/test/lib/Dialect/Test/TestEnums.h
Normal file
20
mlir/test/lib/Dialect/Test/TestEnums.h
Normal file
@ -0,0 +1,20 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains enum definitions for the Test dialect
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MLIR_TESTENUMS_H
|
||||
#define MLIR_TESTENUMS_H
|
||||
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
|
||||
#include "TestOpEnums.h.inc"
|
||||
|
||||
#endif // MLIR_TESTENUMS_H
|
@ -16,6 +16,7 @@
|
||||
// To get the test dialect def.
|
||||
include "TestDialect.td"
|
||||
include "TestAttrDefs.td"
|
||||
include "TestEnumDefs.td"
|
||||
include "TestInterfaces.td"
|
||||
include "mlir/IR/BuiltinTypes.td"
|
||||
include "mlir/Interfaces/DataLayoutInterfaces.td"
|
||||
@ -286,6 +287,15 @@ def TestTypeOptionalGroupStruct : Test_Type<"TestTypeOptionalGroupStruct"> {
|
||||
let assemblyFormat = "`<` (`(` struct(params)^ `)`) : (`x`)? `>`";
|
||||
}
|
||||
|
||||
def TestTypeDefaultEnumParameter
|
||||
: Test_Type<"TestTypeDefaultEnumParameter"> {
|
||||
let parameters = (ins
|
||||
DefaultValuedEnumParameter<TestDefaultValuedEnum, TestDefaultCase>:$a
|
||||
);
|
||||
let mnemonic = "default_enum_parameter";
|
||||
let assemblyFormat = "`<` $a `>`";
|
||||
}
|
||||
|
||||
def TestTypeSpaces : Test_Type<"TestTypeSpaceS"> {
|
||||
let parameters = (ins "int":$a, "int":$b);
|
||||
let mnemonic = "spaces";
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
|
||||
#include "TestEnums.h"
|
||||
#include "TestTraits.h"
|
||||
#include "mlir/Dialect/Bufferization/IR/BufferizationTypeInterfaces.h"
|
||||
#include "mlir/IR/Diagnostics.h"
|
||||
|
@ -77,6 +77,8 @@ attributes {
|
||||
// CHECK: !test.optional_type_string
|
||||
// CHECK: !test.optional_type_string<"non default">
|
||||
// CHECK: !test.optional_type_string<"containing\0A \22escape\22 characters\0F">
|
||||
// CHECK: !test.default_enum_parameter
|
||||
// CHECK: !test.default_enum_parameter<"non_default">
|
||||
|
||||
func.func private @test_roundtrip_default_parsers_struct(
|
||||
!test.no_parser<255, [1, 2, 3, 4, 5], "foobar", 4>
|
||||
@ -120,4 +122,6 @@ func.func private @test_roundtrip_default_parsers_struct(
|
||||
!test.optional_type_string<"default">,
|
||||
!test.optional_type_string<"non default">,
|
||||
!test.optional_type_string<"containing\n \"escape\" characters\0f">
|
||||
!test.default_enum_parameter,
|
||||
!test.default_enum_parameter<"non_default">,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user