https://github.com/xlauko created https://github.com/llvm/llvm-project/pull/148865
- This adds common CIR_ prefix to all operation disambiguating them when used with other dialects. - Unifies traits style in operation definitions. This mirrors incubator changes from https://github.com/llvm/clangir/pull/1741 >From 9147993ba1014968d153f3b43ce48bd21879db06 Mon Sep 17 00:00:00 2001 From: xlauko <xla...@mail.muni.cz> Date: Tue, 15 Jul 2025 17:00:08 +0200 Subject: [PATCH] [CIR] Reformat Ops to use common `CIR_` prefix and definition traits style - This adds common CIR_ prefix to all operation disambiguating them when used with other dialects. - Unifies traits style in operation definitions. This mirrors incubator changes from https://github.com/llvm/clangir/pull/1741 --- clang/include/clang/CIR/Dialect/IR/CIROps.td | 321 +++++++++++-------- 1 file changed, 179 insertions(+), 142 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 676ff76dff661..2ce23dbb27ec6 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -159,9 +159,9 @@ def CIR_CastKind : CIR_I32EnumAttr<"CastKind", "cast kind", [ I32EnumAttrCase<"bool_to_float", 1000>, ]>; -def CastOp : CIR_Op<"cast", - [Pure, - DeclareOpInterfaceMethods<PromotableOpInterface>]> { +def CIR_CastOp : CIR_Op<"cast", [ + Pure, DeclareOpInterfaceMethods<PromotableOpInterface> +]> { // FIXME: not all conversions are free of side effects. let summary = "Conversion between values of different types"; let description = [{ @@ -225,8 +225,9 @@ def CastOp : CIR_Op<"cast", // PtrStrideOp //===----------------------------------------------------------------------===// -def PtrStrideOp : CIR_Op<"ptr_stride", - [Pure, AllTypesMatch<["base", "result"]>]> { +def CIR_PtrStrideOp : CIR_Op<"ptr_stride", [ + Pure, AllTypesMatch<["base", "result"]> +]> { let summary = "Pointer access with stride"; let description = [{ Given a base pointer as first operand, provides a new pointer after applying @@ -262,8 +263,9 @@ def PtrStrideOp : CIR_Op<"ptr_stride", // ConstantOp //===----------------------------------------------------------------------===// -def ConstantOp : CIR_Op<"const", - [ConstantLike, Pure, AllTypesMatch<["value", "res"]>]> { +def CIR_ConstantOp : CIR_Op<"const", [ + ConstantLike, Pure, AllTypesMatch<["value", "res"]> +]> { let summary = "Defines a CIR constant"; let description = [{ The `cir.const` operation turns a literal into an SSA value. The data is @@ -298,22 +300,23 @@ def ConstantOp : CIR_Op<"const", // AllocaOp //===----------------------------------------------------------------------===// -class AllocaTypesMatchWith<string summary, string lhsArg, string rhsArg, - string transform, string comparator = "std::equal_to<>()"> - : PredOpTrait<summary, CPred< - comparator # "(" # +class CIR_AllocaTypesMatchWith< + string summary, string lhsArg, string rhsArg, string transform, + string comparator = "std::equal_to<>()" +> : PredOpTrait<summary, CPred<comparator # "(" # !subst("$_self", "$" # lhsArg # ".getType()", transform) # - ", $" # rhsArg # ")">> { + ", $" # rhsArg # ")"> +> { string lhs = lhsArg; string rhs = rhsArg; string transformer = transform; } -def AllocaOp : CIR_Op<"alloca", [ - AllocaTypesMatchWith<"'allocaType' matches pointee type of 'addr'", - "addr", "allocaType", - "cast<PointerType>($_self).getPointee()">, - DeclareOpInterfaceMethods<PromotableAllocationOpInterface>]> { +def CIR_AllocaOp : CIR_Op<"alloca", [ + CIR_AllocaTypesMatchWith<"'allocaType' matches pointee type of 'addr'", + "addr", "allocaType", "mlir::cast<cir::PointerType>($_self).getPointee()">, + DeclareOpInterfaceMethods<PromotableAllocationOpInterface> +]> { let summary = "Defines a scope-local variable"; let description = [{ The `cir.alloca` operation defines a scope-local variable. @@ -374,12 +377,11 @@ def AllocaOp : CIR_Op<"alloca", [ // LoadOp //===----------------------------------------------------------------------===// -def LoadOp : CIR_Op<"load", [ +def CIR_LoadOp : CIR_Op<"load", [ TypesMatchWith<"type of 'result' matches pointee type of 'addr'", - "addr", "result", - "cast<PointerType>($_self).getPointee()">, - DeclareOpInterfaceMethods<PromotableMemOpInterface>]> { - + "addr", "result", "mlir::cast<cir::PointerType>($_self).getPointee()">, + DeclareOpInterfaceMethods<PromotableMemOpInterface> +]> { let summary = "Load value from memory adddress"; let description = [{ `cir.load` reads a value (lvalue to rvalue conversion) given an address @@ -420,12 +422,11 @@ def LoadOp : CIR_Op<"load", [ // StoreOp //===----------------------------------------------------------------------===// -def StoreOp : CIR_Op<"store", [ +def CIR_StoreOp : CIR_Op<"store", [ TypesMatchWith<"type of 'value' matches pointee type of 'addr'", - "addr", "value", - "cast<PointerType>($_self).getPointee()">, - DeclareOpInterfaceMethods<PromotableMemOpInterface>]> { - + "addr", "value", "mlir::cast<cir::PointerType>($_self).getPointee()">, + DeclareOpInterfaceMethods<PromotableMemOpInterface> +]> { let summary = "Store value to memory address"; let description = [{ `cir.store` stores a value (first operand) to the memory address specified @@ -461,10 +462,14 @@ def StoreOp : CIR_Op<"store", [ // ReturnOp //===----------------------------------------------------------------------===// -def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp", "ScopeOp", "IfOp", - "SwitchOp", "DoWhileOp","WhileOp", - "ForOp", "CaseOp"]>, - Terminator]> { +defvar CIR_ReturnableScopes = [ + "FuncOp", "ScopeOp", "IfOp", "SwitchOp", "CaseOp", + "DoWhileOp", "WhileOp", "ForOp" +]; + +def CIR_ReturnOp : CIR_Op<"return", [ + ParentOneOf<CIR_ReturnableScopes>, Terminator +]> { let summary = "Return from function"; let description = [{ The "return" operation represents a return operation within a function. @@ -504,10 +509,10 @@ def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp", "ScopeOp", "IfOp", // IfOp //===----------------------------------------------------------------------===// -def IfOp : CIR_Op<"if", - [DeclareOpInterfaceMethods<RegionBranchOpInterface>, - RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments]>{ - +def CIR_IfOp : CIR_Op<"if", [ + DeclareOpInterfaceMethods<RegionBranchOpInterface>, + RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments +]> { let summary = "the if-then-else operation"; let description = [{ The `cir.if` operation represents an if-then-else construct for @@ -555,10 +560,11 @@ def IfOp : CIR_Op<"if", // ConditionOp //===----------------------------------------------------------------------===// -def ConditionOp : CIR_Op<"condition", [ +def CIR_ConditionOp : CIR_Op<"condition", [ Terminator, - DeclareOpInterfaceMethods<RegionBranchTerminatorOpInterface, - ["getSuccessorRegions"]> + DeclareOpInterfaceMethods<RegionBranchTerminatorOpInterface, [ + "getSuccessorRegions" + ]> ]> { let summary = "Loop continuation condition."; let description = [{ @@ -600,10 +606,14 @@ def ConditionOp : CIR_Op<"condition", [ // YieldOp //===----------------------------------------------------------------------===// -def YieldOp : CIR_Op<"yield", [ReturnLike, Terminator, - ParentOneOf<["CaseOp", "DoWhileOp", "ForOp", - "IfOp", "ScopeOp", "SwitchOp", - "TernaryOp", "WhileOp"]>]> { +defvar CIR_YieldableScopes = [ + "CaseOp", "DoWhileOp", "ForOp", "IfOp", "ScopeOp", "SwitchOp", + "TernaryOp", "WhileOp" +]; + +def CIR_YieldOp : CIR_Op<"yield", [ + ReturnLike, Terminator, ParentOneOf<CIR_YieldableScopes> +]> { let summary = "Represents the default branching behaviour of a region"; let description = [{ The `cir.yield` operation terminates regions on different CIR operations, @@ -663,7 +673,7 @@ def YieldOp : CIR_Op<"yield", [ReturnLike, Terminator, // BreakOp //===----------------------------------------------------------------------===// -def BreakOp : CIR_Op<"break", [Terminator]> { +def CIR_BreakOp : CIR_Op<"break", [Terminator]> { let summary = "C/C++ `break` statement equivalent"; let description = [{ The `cir.break` operation is used to cease the execution of the current loop @@ -678,7 +688,7 @@ def BreakOp : CIR_Op<"break", [Terminator]> { // ContinueOp //===----------------------------------------------------------------------===// -def ContinueOp : CIR_Op<"continue", [Terminator]> { +def CIR_ContinueOp : CIR_Op<"continue", [Terminator]> { let summary = "C/C++ `continue` statement equivalent"; let description = [{ The `cir.continue` operation is used to end execution of the current @@ -693,9 +703,10 @@ def ContinueOp : CIR_Op<"continue", [Terminator]> { // ScopeOp //===----------------------------------------------------------------------===// -def ScopeOp : CIR_Op<"scope", [ - DeclareOpInterfaceMethods<RegionBranchOpInterface>, - RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments]> { +def CIR_ScopeOp : CIR_Op<"scope", [ + DeclareOpInterfaceMethods<RegionBranchOpInterface>, + RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments +]> { let summary = "Represents a C/C++ scope"; let description = [{ `cir.scope` contains one region and defines a strict "scope" for all new @@ -757,9 +768,10 @@ def CIR_CaseOpKind : CIR_I32EnumAttr<"CaseOpKind", "case kind", [ I32EnumAttrCase<"Range", 3, "range"> ]>; -def CaseOp : CIR_Op<"case", [ - DeclareOpInterfaceMethods<RegionBranchOpInterface>, - RecursivelySpeculatable, AutomaticAllocationScope]> { +def CIR_CaseOp : CIR_Op<"case", [ + DeclareOpInterfaceMethods<RegionBranchOpInterface>, + RecursivelySpeculatable, AutomaticAllocationScope +]> { let summary = "Case operation"; let description = [{ The `cir.case` operation represents a case within a C/C++ switch. @@ -791,10 +803,11 @@ def CaseOp : CIR_Op<"case", [ ]; } -def SwitchOp : CIR_Op<"switch", - [SameVariadicOperandSize, - DeclareOpInterfaceMethods<RegionBranchOpInterface>, - RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments]> { +def CIR_SwitchOp : CIR_Op<"switch", [ + SameVariadicOperandSize, + DeclareOpInterfaceMethods<RegionBranchOpInterface>, + RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments +]> { let summary = "Switch operation"; let description = [{ The `cir.switch` operation represents C/C++ switch functionality for @@ -959,8 +972,10 @@ def SwitchOp : CIR_Op<"switch", // SwitchFlatOp //===----------------------------------------------------------------------===// -def SwitchFlatOp : CIR_Op<"switch.flat", [AttrSizedOperandSegments, - Terminator]> { +def CIR_SwitchFlatOp : CIR_Op<"switch.flat", [ + AttrSizedOperandSegments, Terminator +]> { + let summary = "A flattened version of cir.switch"; let description = [{ The `cir.switch.flat` operation is a region-less and simplified @@ -1005,9 +1020,10 @@ def SwitchFlatOp : CIR_Op<"switch.flat", [AttrSizedOperandSegments, // BrOp //===----------------------------------------------------------------------===// -def BrOp : CIR_Op<"br", - [DeclareOpInterfaceMethods<BranchOpInterface, ["getSuccessorForOperands"]>, - Pure, Terminator]> { +def CIR_BrOp : CIR_Op<"br",[ + DeclareOpInterfaceMethods<BranchOpInterface, ["getSuccessorForOperands"]>, + Pure, Terminator +]> { let summary = "Unconditional branch"; let description = [{ The `cir.br` branches unconditionally to a block. Used to represent C/C++ @@ -1053,7 +1069,7 @@ def CIR_UnaryOpKind : CIR_I32EnumAttr<"UnaryOpKind", "unary operation kind", [ I32EnumAttrCase<"Not", 4, "not"> ]>; -def UnaryOp : CIR_Op<"unary", [Pure, SameOperandsAndResultType]> { +def CIR_UnaryOp : CIR_Op<"unary", [Pure, SameOperandsAndResultType]> { let summary = "Unary operations"; let description = [{ `cir.unary` performs the unary operation according to @@ -1093,9 +1109,10 @@ def UnaryOp : CIR_Op<"unary", [Pure, SameOperandsAndResultType]> { // BrCondOp //===----------------------------------------------------------------------===// -def BrCondOp : CIR_Op<"brcond", - [DeclareOpInterfaceMethods<BranchOpInterface, ["getSuccessorForOperands"]>, - Pure, Terminator, AttrSizedOperandSegments]> { +def CIR_BrCondOp : CIR_Op<"brcond", [ + DeclareOpInterfaceMethods<BranchOpInterface, ["getSuccessorForOperands"]>, + Pure, Terminator, AttrSizedOperandSegments +]> { let summary = "Conditional branch"; let description = [{ The `cir.brcond %cond, ^bb0, ^bb1` branches to 'bb0' block in case @@ -1140,9 +1157,8 @@ def BrCondOp : CIR_Op<"brcond", // Common loop op definitions //===----------------------------------------------------------------------===// -class LoopOpBase<string mnemonic> : CIR_Op<mnemonic, [ - LoopOpInterface, - NoRegionArguments, +class CIR_LoopOpBase<string mnemonic> : CIR_Op<mnemonic, [ + LoopOpInterface, NoRegionArguments ]> { let extraClassDefinition = [{ void $cppClass::getSuccessorRegions( @@ -1160,7 +1176,7 @@ class LoopOpBase<string mnemonic> : CIR_Op<mnemonic, [ // While & DoWhileOp //===----------------------------------------------------------------------===// -class WhileOpBase<string mnemonic> : LoopOpBase<mnemonic> { +class CIR_WhileOpBase<string mnemonic> : CIR_LoopOpBase<mnemonic> { defvar isWhile = !eq(mnemonic, "while"); let summary = "C/C++ " # !if(isWhile, "while", "do-while") # " loop"; let builders = [ @@ -1180,7 +1196,7 @@ class WhileOpBase<string mnemonic> : LoopOpBase<mnemonic> { ]; } -def WhileOp : WhileOpBase<"while"> { +def CIR_WhileOp : CIR_WhileOpBase<"while"> { let regions = (region SizedRegion<1>:$cond, MinSizedRegion<1>:$body); let assemblyFormat = "$cond `do` $body attr-dict"; @@ -1205,7 +1221,7 @@ def WhileOp : WhileOpBase<"while"> { }]; } -def DoWhileOp : WhileOpBase<"do"> { +def CIR_DoWhileOp : CIR_WhileOpBase<"do"> { let regions = (region MinSizedRegion<1>:$body, SizedRegion<1>:$cond); let assemblyFormat = " $body `while` $cond attr-dict"; @@ -1235,7 +1251,7 @@ def DoWhileOp : WhileOpBase<"do"> { // ForOp //===----------------------------------------------------------------------===// -def ForOp : LoopOpBase<"for"> { +def CIR_ForOp : CIR_LoopOpBase<"for"> { let summary = "C/C++ for loop counterpart"; let description = [{ Represents a C/C++ for loop. It consists of three regions: @@ -1311,8 +1327,7 @@ def CIR_CmpOpKind : CIR_I32EnumAttr<"CmpOpKind", "compare operation kind", [ I32EnumAttrCase<"ne", 5> ]>; -def CmpOp : CIR_Op<"cmp", [Pure, SameTypeOperands]> { - +def CIR_CmpOp : CIR_Op<"cmp", [Pure, SameTypeOperands]> { let summary = "Compare values two values and produce a boolean result"; let description = [{ `cir.cmp` compares two input operands of the same type and produces a @@ -1355,9 +1370,9 @@ def CIR_BinOpKind : CIR_I32EnumAttr< I32EnumAttrCase<"Max", 8, "max"> ]>; -def BinOp : CIR_Op<"binop", [Pure, - SameTypeOperands, SameOperandsAndResultType]> { - +def CIR_BinOp : CIR_Op<"binop", [ + Pure, SameTypeOperands, SameOperandsAndResultType +]> { let summary = "Binary operations (arith and logic)"; let description = [{ cir.binop performs the binary operation according to @@ -1411,7 +1426,7 @@ def BinOp : CIR_Op<"binop", [Pure, // ShiftOp //===----------------------------------------------------------------------===// -def ShiftOp : CIR_Op<"shift", [Pure]> { +def CIR_ShiftOp : CIR_Op<"shift", [Pure]> { let summary = "Shift"; let description = [{ The `cir.shift` operation performs a bitwise shift, either to the left or to @@ -1452,8 +1467,9 @@ def ShiftOp : CIR_Op<"shift", [Pure]> { // SelectOp //===----------------------------------------------------------------------===// -def SelectOp : CIR_Op<"select", [Pure, - AllTypesMatch<["true_value", "false_value", "result"]>]> { +def CIR_SelectOp : CIR_Op<"select", [ + Pure, AllTypesMatch<["true_value", "false_value", "result"]> +]> { let summary = "Yield one of two values based on a boolean value"; let description = [{ The `cir.select` operation takes three operands. The first operand @@ -1492,9 +1508,10 @@ def SelectOp : CIR_Op<"select", [Pure, // TernaryOp //===----------------------------------------------------------------------===// -def TernaryOp : CIR_Op<"ternary", - [DeclareOpInterfaceMethods<RegionBranchOpInterface>, - RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments]> { +def CIR_TernaryOp : CIR_Op<"ternary", [ + DeclareOpInterfaceMethods<RegionBranchOpInterface>, + RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments +]> { let summary = "The `cond ? a : b` C/C++ ternary operation"; let description = [{ The `cir.ternary` operation represents C/C++ ternary, much like a `select` @@ -1583,8 +1600,9 @@ def CIR_GlobalLinkageKind : CIR_I32EnumAttr< // properties of a global variable will be added over time as more of ClangIR // is upstreamed. -def GlobalOp : CIR_Op<"global", - [DeclareOpInterfaceMethods<CIRGlobalValueInterface>]> { +def CIR_GlobalOp : CIR_Op<"global", [ + DeclareOpInterfaceMethods<CIRGlobalValueInterface> +]> { let summary = "Declare or define a global variable"; let description = [{ The `cir.global` operation declares or defines a named global variable. @@ -1645,8 +1663,9 @@ def GlobalOp : CIR_Op<"global", // GetGlobalOp //===----------------------------------------------------------------------===// -def GetGlobalOp : CIR_Op<"get_global", - [Pure, DeclareOpInterfaceMethods<SymbolUserOpInterface>]> { +def CIR_GetGlobalOp : CIR_Op<"get_global", [ + Pure, DeclareOpInterfaceMethods<SymbolUserOpInterface> +]> { let summary = "Get the address of a global variable"; let description = [{ The `cir.get_global` operation retrieves the address pointing to a @@ -1673,7 +1692,7 @@ def GetGlobalOp : CIR_Op<"get_global", // SetBitfieldOp //===----------------------------------------------------------------------===// -def SetBitfieldOp : CIR_Op<"set_bitfield"> { +def CIR_SetBitfieldOp : CIR_Op<"set_bitfield"> { let summary = "Set the value of a bitfield member"; let description = [{ The `cir.set_bitfield` operation provides a store-like access to @@ -1761,7 +1780,7 @@ def SetBitfieldOp : CIR_Op<"set_bitfield"> { // GetBitfieldOp //===----------------------------------------------------------------------===// -def GetBitfieldOp : CIR_Op<"get_bitfield"> { +def CIR_GetBitfieldOp : CIR_Op<"get_bitfield"> { let summary = "Get the information for a bitfield member"; let description = [{ The `cir.get_bitfield` operation provides a load-like access to @@ -1843,7 +1862,7 @@ def GetBitfieldOp : CIR_Op<"get_bitfield"> { // GetMemberOp //===----------------------------------------------------------------------===// -def GetMemberOp : CIR_Op<"get_member"> { +def CIR_GetMemberOp : CIR_Op<"get_member"> { let summary = "Get the address of a member of a record"; let description = [{ The `cir.get_member` operation gets the address of a particular named @@ -1905,7 +1924,7 @@ def GetMemberOp : CIR_Op<"get_member"> { // TODO(CIR): FuncOp is still a tiny shell of what it will become. Many more // properties and attributes will be added as upstreaming continues. -def FuncOp : CIR_Op<"func", [ +def CIR_FuncOp : CIR_Op<"func", [ AutomaticAllocationScope, CallableOpInterface, FunctionOpInterface, DeclareOpInterfaceMethods<CIRGlobalValueInterface>, IsolatedFromAbove @@ -2029,10 +2048,10 @@ def CIR_SideEffect : CIR_I32EnumAttr< } class CIR_CallOpBase<string mnemonic, list<Trait> extra_traits = []> - : Op<CIR_Dialect, mnemonic, - !listconcat(extra_traits, - [DeclareOpInterfaceMethods<CIRCallOpInterface>, - DeclareOpInterfaceMethods<SymbolUserOpInterface>])> { + : CIR_Op<mnemonic, !listconcat(extra_traits, [ + DeclareOpInterfaceMethods<CIRCallOpInterface>, + DeclareOpInterfaceMethods<SymbolUserOpInterface> + ])> { let extraClassDeclaration = [{ /// Get the argument operands to the called function. mlir::OperandRange getArgOperands(); @@ -2086,7 +2105,7 @@ class CIR_CallOpBase<string mnemonic, list<Trait> extra_traits = []> DefaultValuedAttr<CIR_SideEffect, "SideEffect::All">:$side_effect); } -def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> { +def CIR_CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> { let summary = "call a function"; let description = [{ The `cir.call` operation represents a function call. It could represent @@ -2127,7 +2146,7 @@ def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> { // StackSaveOp & StackRestoreOp //===----------------------------------------------------------------------===// -def StackSaveOp : CIR_Op<"stacksave"> { +def CIR_StackSaveOp : CIR_Op<"stacksave"> { let summary = "remembers the current state of the function stack"; let description = [{ Saves current state of the function stack. Returns a pointer to an opaque object @@ -2145,7 +2164,7 @@ def StackSaveOp : CIR_Op<"stacksave"> { let assemblyFormat = "attr-dict `:` qualified(type($result))"; } -def StackRestoreOp : CIR_Op<"stackrestore"> { +def CIR_StackRestoreOp : CIR_Op<"stackrestore"> { let summary = "restores the state of the function stack"; let description = [{ Restore the state of the function stack to the state it was @@ -2171,7 +2190,7 @@ def StackRestoreOp : CIR_Op<"stackrestore"> { // UnreachableOp //===----------------------------------------------------------------------===// -def UnreachableOp : CIR_Op<"unreachable", [Terminator]> { +def CIR_UnreachableOp : CIR_Op<"unreachable", [Terminator]> { let summary = "invoke immediate undefined behavior"; let description = [{ If the program control flow reaches a `cir.unreachable` operation, the @@ -2187,7 +2206,7 @@ def UnreachableOp : CIR_Op<"unreachable", [Terminator]> { // TrapOp //===----------------------------------------------------------------------===// -def TrapOp : CIR_Op<"trap", [Terminator]> { +def CIR_TrapOp : CIR_Op<"trap", [Terminator]> { let summary = "Exit the program abnormally"; let description = [{ The cir.trap operation causes the program to exit abnormally. The @@ -2204,8 +2223,7 @@ def TrapOp : CIR_Op<"trap", [Terminator]> { // VecCreate //===----------------------------------------------------------------------===// -def VecCreateOp : CIR_Op<"vec.create", [Pure]> { - +def CIR_VecCreateOp : CIR_Op<"vec.create", [Pure]> { let summary = "Create a vector value"; let description = [{ The `cir.vec.create` operation creates a vector value with the given element @@ -2229,11 +2247,12 @@ def VecCreateOp : CIR_Op<"vec.create", [Pure]> { // VecInsertOp //===----------------------------------------------------------------------===// -def VecInsertOp : CIR_Op<"vec.insert", [Pure, - TypesMatchWith<"argument type matches vector element type", "vec", "value", - "cast<VectorType>($_self).getElementType()">, - AllTypesMatch<["result", "vec"]>]> { - +def CIR_VecInsertOp : CIR_Op<"vec.insert", [ + Pure, + TypesMatchWith<"argument type matches vector element type", + "vec", "value", "mlir::cast<cir::VectorType>($_self).getElementType()">, + AllTypesMatch<["result", "vec"]> +]> { let summary = "Insert one element into a vector object"; let description = [{ The `cir.vec.insert` operation produces a new vector by replacing @@ -2265,10 +2284,11 @@ def VecInsertOp : CIR_Op<"vec.insert", [Pure, // VecExtractOp //===----------------------------------------------------------------------===// -def VecExtractOp : CIR_Op<"vec.extract", [Pure, - TypesMatchWith<"type of 'result' matches element type of 'vec'", "vec", - "result", "cast<VectorType>($_self).getElementType()">]> { - +def CIR_VecExtractOp : CIR_Op<"vec.extract", [ + Pure, + TypesMatchWith<"type of 'result' matches element type of 'vec'", + "vec", "result", "mlir::cast<cir::VectorType>($_self).getElementType()"> +]> { let summary = "Extract one element from a vector object"; let description = [{ The `cir.vec.extract` operation extracts the element at the given index @@ -2295,8 +2315,7 @@ def VecExtractOp : CIR_Op<"vec.extract", [Pure, // VecCmpOp //===----------------------------------------------------------------------===// -def VecCmpOp : CIR_Op<"vec.cmp", [Pure, SameTypeOperands]> { - +def CIR_VecCmpOp : CIR_Op<"vec.cmp", [Pure, SameTypeOperands]> { let summary = "Compare two vectors"; let description = [{ The `cir.vec.cmp` operation does an element-wise comparison of two vectors @@ -2334,8 +2353,9 @@ def VecCmpOp : CIR_Op<"vec.cmp", [Pure, SameTypeOperands]> { // implement. This could be useful for passes that don't care how the vector // shuffle was specified. -def VecShuffleOp : CIR_Op<"vec.shuffle", - [Pure, AllTypesMatch<["vec1", "vec2"]>]> { +def CIR_VecShuffleOp : CIR_Op<"vec.shuffle", [ + Pure, AllTypesMatch<["vec1", "vec2"]> +]> { let summary = "Combine two vectors using indices passed as constant integers"; let description = [{ The `cir.vec.shuffle` operation implements the documented form of Clang's @@ -2378,8 +2398,9 @@ def VecShuffleOp : CIR_Op<"vec.shuffle", // VecShuffleDynamicOp //===----------------------------------------------------------------------===// -def VecShuffleDynamicOp : CIR_Op<"vec.shuffle.dynamic", - [Pure, AllTypesMatch<["vec", "result"]>]> { +def CIR_VecShuffleDynamicOp : CIR_Op<"vec.shuffle.dynamic", [ + Pure, AllTypesMatch<["vec", "result"]> +]> { let summary = "Shuffle a vector using indices in another vector"; let description = [{ The `cir.vec.shuffle.dynamic` operation implements the undocumented form of @@ -2413,8 +2434,9 @@ def VecShuffleDynamicOp : CIR_Op<"vec.shuffle.dynamic", // VecTernaryOp //===----------------------------------------------------------------------===// -def VecTernaryOp : CIR_Op<"vec.ternary", - [Pure, AllTypesMatch<["result", "lhs", "rhs"]>]> { +def CIR_VecTernaryOp : CIR_Op<"vec.ternary", [ + Pure, AllTypesMatch<["result", "lhs", "rhs"]> +]> { let summary = "The `cond ? a : b` ternary operator for vector types"; let description = [{ The `cir.vec.ternary` operation represents the C/C++ ternary operator, @@ -2451,10 +2473,11 @@ def VecTernaryOp : CIR_Op<"vec.ternary", // VecSplatOp //===----------------------------------------------------------------------===// -def VecSplatOp : CIR_Op<"vec.splat", [Pure, - TypesMatchWith<"type of 'value' matches element type of 'result'", "result", - "value", "cast<VectorType>($_self).getElementType()">]> { - +def CIR_VecSplatOp : CIR_Op<"vec.splat", [ + Pure, + TypesMatchWith<"type of 'value' matches element type of 'result'", + "result", "value", "mlir::cast<cir::VectorType>($_self).getElementType()"> +]> { let summary = "Convert a scalar into a vector"; let description = [{ The `cir.vec.splat` operation creates a vector value from a scalar value. @@ -2483,7 +2506,7 @@ def VecSplatOp : CIR_Op<"vec.splat", [Pure, // BaseClassAddrOp //===----------------------------------------------------------------------===// -def BaseClassAddrOp : CIR_Op<"base_class_addr"> { +def CIR_BaseClassAddrOp : CIR_Op<"base_class_addr"> { let summary = "Get the base class address for a class/struct"; let description = [{ The `cir.base_class_addr` operaration gets the address of a particular @@ -2526,7 +2549,7 @@ def BaseClassAddrOp : CIR_Op<"base_class_addr"> { // ComplexCreateOp //===----------------------------------------------------------------------===// -def ComplexCreateOp : CIR_Op<"complex.create", [Pure, SameTypeOperands]> { +def CIR_ComplexCreateOp : CIR_Op<"complex.create", [Pure, SameTypeOperands]> { let summary = "Create a complex value from its real and imaginary parts"; let description = [{ The `cir.complex.create` operation takes two operands that represent the @@ -2558,7 +2581,7 @@ def ComplexCreateOp : CIR_Op<"complex.create", [Pure, SameTypeOperands]> { // ComplexRealOp //===----------------------------------------------------------------------===// -def ComplexRealOp : CIR_Op<"complex.real", [Pure]> { +def CIR_ComplexRealOp : CIR_Op<"complex.real", [Pure]> { let summary = "Extract the real part of a complex value"; let description = [{ `cir.complex.real` operation takes an operand of `!cir.complex` type and @@ -2587,7 +2610,7 @@ def ComplexRealOp : CIR_Op<"complex.real", [Pure]> { // ComplexImagOp //===----------------------------------------------------------------------===// -def ComplexImagOp : CIR_Op<"complex.imag", [Pure]> { +def CIR_ComplexImagOp : CIR_Op<"complex.imag", [Pure]> { let summary = "Extract the imaginary part of a complex value"; let description = [{ `cir.complex.imag` operation takes an operand of `!cir.complex` type and @@ -2616,7 +2639,7 @@ def ComplexImagOp : CIR_Op<"complex.imag", [Pure]> { // ComplexRealPtrOp //===----------------------------------------------------------------------===// -def ComplexRealPtrOp : CIR_Op<"complex.real_ptr", [Pure]> { +def CIR_ComplexRealPtrOp : CIR_Op<"complex.real_ptr", [Pure]> { let summary = "Derive a pointer to the real part of a complex value"; let description = [{ `cir.complex.real_ptr` operation takes a pointer operand that points to a @@ -2646,7 +2669,7 @@ def ComplexRealPtrOp : CIR_Op<"complex.real_ptr", [Pure]> { // ComplexImagPtrOp //===----------------------------------------------------------------------===// -def ComplexImagPtrOp : CIR_Op<"complex.imag_ptr", [Pure]> { +def CIR_ComplexImagPtrOp : CIR_Op<"complex.imag_ptr", [Pure]> { let summary = "Derive a pointer to the imaginary part of a complex value"; let description = [{ `cir.complex.imag_ptr` operation takes a pointer operand that points to a @@ -2676,7 +2699,9 @@ def ComplexImagPtrOp : CIR_Op<"complex.imag_ptr", [Pure]> { // ComplexAddOp //===----------------------------------------------------------------------===// -def ComplexAddOp : CIR_Op<"complex.add", [Pure, SameOperandsAndResultType]> { +def CIR_ComplexAddOp : CIR_Op<"complex.add", [ + Pure, SameOperandsAndResultType +]> { let summary = "Complex addition"; let description = [{ The `cir.complex.add` operation takes two complex numbers and returns @@ -2702,7 +2727,9 @@ def ComplexAddOp : CIR_Op<"complex.add", [Pure, SameOperandsAndResultType]> { // ComplexSubOp //===----------------------------------------------------------------------===// -def ComplexSubOp : CIR_Op<"complex.sub", [Pure, SameOperandsAndResultType]> { +def CIR_ComplexSubOp : CIR_Op<"complex.sub", [ + Pure, SameOperandsAndResultType +]> { let summary = "Complex subtraction"; let description = [{ The `cir.complex.sub` operation takes two complex numbers and returns @@ -2730,7 +2757,7 @@ def ComplexSubOp : CIR_Op<"complex.sub", [Pure, SameOperandsAndResultType]> { //===----------------------------------------------------------------------===// class CIR_BitOpBase<string mnemonic, TypeConstraint operandTy> - : CIR_Op<mnemonic, [Pure, SameOperandsAndResultType]> { + : CIR_Op<mnemonic, [Pure, SameOperandsAndResultType]> { let arguments = (ins operandTy:$input); let results = (outs operandTy:$result); @@ -2740,7 +2767,7 @@ class CIR_BitOpBase<string mnemonic, TypeConstraint operandTy> } class CIR_BitZeroCountOpBase<string mnemonic, TypeConstraint operandTy> - : CIR_BitOpBase<mnemonic, operandTy> { + : CIR_BitOpBase<mnemonic, operandTy> { let arguments = (ins operandTy:$input, UnitAttr:$poison_zero); let assemblyFormat = [{ @@ -2749,7 +2776,7 @@ class CIR_BitZeroCountOpBase<string mnemonic, TypeConstraint operandTy> }]; } -def BitClrsbOp : CIR_BitOpBase<"clrsb", CIR_SIntOfWidths<[32, 64]>> { +def CIR_BitClrsbOp : CIR_BitOpBase<"clrsb", CIR_SIntOfWidths<[32, 64]>> { let summary = "Get the number of leading redundant sign bits in the input"; let description = [{ Compute the number of leading redundant sign bits in the input integer. @@ -2779,7 +2806,9 @@ def BitClrsbOp : CIR_BitOpBase<"clrsb", CIR_SIntOfWidths<[32, 64]>> { }]; } -def BitClzOp : CIR_BitZeroCountOpBase<"clz", CIR_UIntOfWidths<[16, 32, 64]>> { +def CIR_BitClzOp : CIR_BitZeroCountOpBase<"clz", + CIR_UIntOfWidths<[16, 32, 64]> +> { let summary = "Get the number of leading 0-bits in the input"; let description = [{ Compute the number of leading 0-bits in the input. @@ -2802,7 +2831,9 @@ def BitClzOp : CIR_BitZeroCountOpBase<"clz", CIR_UIntOfWidths<[16, 32, 64]>> { }]; } -def BitCtzOp : CIR_BitZeroCountOpBase<"ctz", CIR_UIntOfWidths<[16, 32, 64]>> { +def CIR_BitCtzOp : CIR_BitZeroCountOpBase<"ctz", + CIR_UIntOfWidths<[16, 32, 64]> +> { let summary = "Get the number of trailing 0-bits in the input"; let description = [{ Compute the number of trailing 0-bits in the input. @@ -2825,7 +2856,7 @@ def BitCtzOp : CIR_BitZeroCountOpBase<"ctz", CIR_UIntOfWidths<[16, 32, 64]>> { }]; } -def BitParityOp : CIR_BitOpBase<"parity", CIR_UIntOfWidths<[32, 64]>> { +def CIR_BitParityOp : CIR_BitOpBase<"parity", CIR_UIntOfWidths<[32, 64]>> { let summary = "Get the parity of input"; let description = [{ Compute the parity of the input. The parity of an integer is the number of @@ -2844,7 +2875,9 @@ def BitParityOp : CIR_BitOpBase<"parity", CIR_UIntOfWidths<[32, 64]>> { }]; } -def BitPopcountOp : CIR_BitOpBase<"popcount", CIR_UIntOfWidths<[16, 32, 64]>> { +def CIR_BitPopcountOp : CIR_BitOpBase<"popcount", + CIR_UIntOfWidths<[16, 32, 64]> +> { let summary = "Get the number of 1-bits in input"; let description = [{ Compute the number of 1-bits in the input. @@ -2862,8 +2895,9 @@ def BitPopcountOp : CIR_BitOpBase<"popcount", CIR_UIntOfWidths<[16, 32, 64]>> { }]; } -def BitReverseOp : CIR_BitOpBase<"bitreverse", - CIR_UIntOfWidths<[8, 16, 32, 64]>> { +def CIR_BitReverseOp : CIR_BitOpBase<"bitreverse", + CIR_UIntOfWidths<[8, 16, 32, 64]> +> { let summary = "Reverse the bit pattern of the operand integer"; let description = [{ The `cir.bitreverse` operation reverses the bits of the operand integer. Its @@ -2877,7 +2911,9 @@ def BitReverseOp : CIR_BitOpBase<"bitreverse", }]; } -def ByteSwapOp : CIR_BitOpBase<"byte_swap", CIR_UIntOfWidths<[16, 32, 64]>> { +def CIR_ByteSwapOp : CIR_BitOpBase<"byte_swap", + CIR_UIntOfWidths<[16, 32, 64]> +> { let summary = "Reverse the bytes in the object representation of the operand"; let description = [{ The `cir.byte_swap` operation takes an integer as operand, reverse the bytes @@ -2902,7 +2938,7 @@ def ByteSwapOp : CIR_BitOpBase<"byte_swap", CIR_UIntOfWidths<[16, 32, 64]>> { // Assume Operations //===----------------------------------------------------------------------===// -def AssumeOp : CIR_Op<"assume"> { +def CIR_AssumeOp : CIR_Op<"assume"> { let summary = "Tell the optimizer that a boolean value is true"; let description = [{ The `cir.assume` operation takes a single boolean prediate as its only @@ -2924,8 +2960,9 @@ def AssumeOp : CIR_Op<"assume"> { // Branch Probability Operations //===----------------------------------------------------------------------===// -def ExpectOp : CIR_Op<"expect", - [Pure, AllTypesMatch<["result", "val", "expected"]>]> { +def CIR_ExpectOp : CIR_Op<"expect", [ + Pure, AllTypesMatch<["result", "val", "expected"]> +]> { let summary = "Tell the optimizer that two values are likely to be equal."; let description = [{ The `cir.expect` operation may take 2 or 3 arguments. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits