diff --git a/clang/include/clang/Basic/arm_mve.td b/clang/include/clang/Basic/arm_mve.td --- a/clang/include/clang/Basic/arm_mve.td +++ b/clang/include/clang/Basic/arm_mve.td @@ -545,8 +545,8 @@ defvar intArgsUnpred = !con(intArgsBase, !if(needSign, (? (unsignedflag Scalar)), (?))); defvar intArgsPred = !con(intArgsUnpred, (? $pred)); - defvar intUnpred = !setop(intArgsUnpred, IRInt); - defvar intPred = !setop(intArgsPred, IRInt< + defvar intUnpred = !setdagop(intArgsUnpred, IRInt); + defvar intPred = !setdagop(intArgsPred, IRInt< basename#"_predicated", !listconcat(basetypes, [Predicate])>); def "": Intrinsic< diff --git a/llvm/docs/TableGen/ProgRef.rst b/llvm/docs/TableGen/ProgRef.rst --- a/llvm/docs/TableGen/ProgRef.rst +++ b/llvm/docs/TableGen/ProgRef.rst @@ -206,13 +206,13 @@ .. productionlist:: BangOperator: one of - : !add !and !cast !con !dag - : !empty !eq !foldl !foreach !ge - : !getop !gt !head !if !isa - : !le !listconcat !listsplat !lt !mul - : !ne !not !or !setop !shl - : !size !sra !srl !strconcat !subst - : !tail !xor + : !add !and !cast !con !dag + : !empty !eq !foldl !foreach !ge + : !getdagop !gt !head !if !isa + : !le !listconcat !listsplat !lt !mul + : !ne !not !or !setdagop !shl + : !size !sra !srl !strconcat !subst + : !tail !xor The ``!cond`` operator has a slightly different syntax compared to other bang operators, so it is defined separately: @@ -1243,7 +1243,7 @@ DAG. The following bang operators are useful for working with DAGs: -``!con``, ``!dag``, ``!empty``, ``!foreach``, ``!getop``, ``!setop``, ``!size``. +``!con``, ``!dag``, ``!empty``, ``!foreach``, ``!getdagop``, ``!setdagop``, ``!size``. Defvar in a record body ----------------------- @@ -1445,6 +1445,10 @@ for false. When an operator tests a boolean argument, it interprets 0 as false and non-0 as true. +.. warning:: + The ``!getop`` and ``!setop`` bang operators are deprecated in favor of + ``!getdagop`` and ``!setdagop``. + ``!add(``\ *a*\ ``,`` *b*\ ``, ...)`` This operator adds *a*, *b*, etc., and produces the sum. @@ -1544,26 +1548,27 @@ The arguments must be ``bit``, ``int``, or ``string`` values. Use ``!cast`` to compare other types of objects. -``!getop(``\ *dag*\ ``)`` --or-- ``!getop<``\ *type*\ ``>(``\ *dag*\ ``)`` +``!getdagop(``\ *dag*\ ``)`` --or-- ``!getdagop<``\ *type*\ ``>(``\ *dag*\ ``)`` This operator produces the operator of the given *dag* node. - Example: ``!getop((foo 1, 2))`` results in ``foo``. + Example: ``!getdagop((foo 1, 2))`` results in ``foo``. Recall that + DAG operators are always records. - The result of ``!getop`` can be used directly in a context where - any record value at all is acceptable (typically placing it into + The result of ``!getdagop`` can be used directly in a context where + any record class at all is acceptable (typically placing it into another dag value). But in other contexts, it must be explicitly - cast to a particular class type. The ``<``\ *type*\ ``>`` syntax is + cast to a particular class. The ``<``\ *type*\ ``>`` syntax is provided to make this easy. For example, to assign the result to a value of type ``BaseClass``, you could write either of these:: - BaseClass b = !getop(someDag); - BaseClass b = !cast(!getop(someDag)); + BaseClass b = !getdagop(someDag); + BaseClass b = !cast(!getdagop(someDag)); But to create a new DAG node that reuses the operator from another, no cast is necessary:: - dag d = !dag(!getop(someDag), args, names); + dag d = !dag(!getdagop(someDag), args, names); ``!gt(``\ *a*\ `,` *b*\ ``)`` This operator produces 1 if *a* is greater than *b*; 0 otherwise. @@ -1620,11 +1625,11 @@ result. A logical OR can be performed if all the arguments are either 0 or 1. -``!setop(``\ *dag*\ ``,`` *op*\ ``)`` +``!setdagop(``\ *dag*\ ``,`` *op*\ ``)`` This operator produces a DAG node with the same arguments as *dag*, but with its operator replaced with *op*. - Example: ``!setop((foo 1, 2), bar)`` results in ``(bar 1, 2)``. + Example: ``!setdagop((foo 1, 2), bar)`` results in ``(bar 1, 2)``. ``!shl(``\ *a*\ ``,`` *count*\ ``)`` This operator shifts *a* left logically by *count* bits and produces the resulting diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h --- a/llvm/include/llvm/TableGen/Record.h +++ b/llvm/include/llvm/TableGen/Record.h @@ -759,7 +759,7 @@ /// class UnOpInit : public OpInit, public FoldingSetNode { public: - enum UnaryOp : uint8_t { CAST, NOT, HEAD, TAIL, SIZE, EMPTY, GETOP }; + enum UnaryOp : uint8_t { CAST, NOT, HEAD, TAIL, SIZE, EMPTY, GETDAGOP }; private: Init *LHS; @@ -810,7 +810,7 @@ public: enum BinaryOp : uint8_t { ADD, MUL, AND, OR, XOR, SHL, SRA, SRL, LISTCONCAT, LISTSPLAT, STRCONCAT, CONCAT, EQ, NE, LE, LT, GE, - GT, SETOP }; + GT, SETDAGOP }; private: Init *LHS, *RHS; diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -801,7 +801,7 @@ return IntInit::get(LHSs->getValue().empty()); break; - case GETOP: + case GETDAGOP: if (DagInit *Dag = dyn_cast(LHS)) { DefInit *DI = DefInit::get(Dag->getOperatorAsDef({})); if (!DI->getType()->typeIsA(getType())) { @@ -837,7 +837,7 @@ case TAIL: Result = "!tail"; break; case SIZE: Result = "!size"; break; case EMPTY: Result = "!empty"; break; - case GETOP: Result = "!getop"; break; + case GETDAGOP: Result = "!getdagop"; break; } return Result + "(" + LHS->getAsString() + ")"; } @@ -1009,7 +1009,7 @@ break; } - case SETOP: { + case SETDAGOP: { DagInit *Dag = dyn_cast(LHS); DefInit *Op = dyn_cast(RHS); if (Dag && Op) { @@ -1088,7 +1088,7 @@ case LISTCONCAT: Result = "!listconcat"; break; case LISTSPLAT: Result = "!listsplat"; break; case STRCONCAT: Result = "!strconcat"; break; - case SETOP: Result = "!setop"; break; + case SETDAGOP: Result = "!setdagop"; break; } return Result + "(" + LHS->getAsString() + ", " + RHS->getAsString() + ")"; } diff --git a/llvm/lib/TableGen/TGLexer.h b/llvm/lib/TableGen/TGLexer.h --- a/llvm/lib/TableGen/TGLexer.h +++ b/llvm/lib/TableGen/TGLexer.h @@ -54,7 +54,7 @@ XConcat, XADD, XMUL, XNOT, XAND, XOR, XXOR, XSRA, XSRL, XSHL, XListConcat, XListSplat, XStrConcat, XCast, XSubst, XForEach, XFoldl, XHead, XTail, XSize, XEmpty, XIf, XCond, XEq, XIsA, XDag, XNe, XLe, - XLt, XGe, XGt, XSetOp, XGetOp, + XLt, XGe, XGt, XSetDagOp, XGetDagOp, // Integer value. IntVal, diff --git a/llvm/lib/TableGen/TGLexer.cpp b/llvm/lib/TableGen/TGLexer.cpp --- a/llvm/lib/TableGen/TGLexer.cpp +++ b/llvm/lib/TableGen/TGLexer.cpp @@ -578,8 +578,8 @@ .Case("listconcat", tgtok::XListConcat) .Case("listsplat", tgtok::XListSplat) .Case("strconcat", tgtok::XStrConcat) - .Case("setop", tgtok::XSetOp) - .Case("getop", tgtok::XGetOp) + .Cases("setdagop", "setop", tgtok::XSetDagOp) // !setop is deprecated. + .Cases("getdagop", "getop", tgtok::XGetDagOp) // !getop is deprecated. .Default(tgtok::Error); return Kind != tgtok::Error ? Kind : ReturnError(Start-1, "Unknown operator"); diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -813,12 +813,12 @@ TokError("expected '<' after bits type"); return nullptr; } - if (Lex.Lex() != tgtok::IntVal) { // Eat '<' + if (Lex.Lex() != tgtok::IntVal) { // Eat '<' TokError("expected integer in bits type"); return nullptr; } uint64_t Val = Lex.getCurIntVal(); - if (Lex.Lex() != tgtok::greater) { // Eat count. + if (Lex.Lex() != tgtok::greater) { // Eat count. TokError("expected '>' at end of bits type"); return nullptr; } @@ -914,7 +914,7 @@ case tgtok::XSize: case tgtok::XEmpty: case tgtok::XCast: - case tgtok::XGetOp: { // Value ::= !unop '(' Value ')' + case tgtok::XGetDagOp: { // Value ::= !unop '(' Value ')' UnOpInit::UnaryOp Code; RecTy *Type = nullptr; @@ -955,12 +955,12 @@ Code = UnOpInit::EMPTY; Type = IntRecTy::get(); break; - case tgtok::XGetOp: + case tgtok::XGetDagOp: Lex.Lex(); // eat the operation if (Lex.getCode() == tgtok::less) { // Parse an optional type suffix, so that you can say - // !getop(someDag) as a shorthand for - // !cast(!getop(someDag)). + // !getdagop(someDag) as a shorthand for + // !cast(!getdagop(someDag)). Type = ParseOperatorType(); if (!Type) { @@ -969,13 +969,13 @@ } if (!isa(Type)) { - TokError("type for !getop must be a record type"); + TokError("type for !getdagop must be a record type"); // but keep parsing, to consume the operand } } else { Type = RecordRecTy::get({}); } - Code = UnOpInit::GETOP; + Code = UnOpInit::GETDAGOP; break; } if (!consume(tgtok::l_paren)) { @@ -1091,7 +1091,7 @@ case tgtok::XListConcat: case tgtok::XListSplat: case tgtok::XStrConcat: - case tgtok::XSetOp: { // Value ::= !binop '(' Value ',' Value ')' + case tgtok::XSetDagOp: { // Value ::= !binop '(' Value ',' Value ')' tgtok::TokKind OpTok = Lex.getCode(); SMLoc OpLoc = Lex.getLoc(); Lex.Lex(); // eat the operation @@ -1115,9 +1115,9 @@ case tgtok::XGe: Code = BinOpInit::GE; break; case tgtok::XGt: Code = BinOpInit::GT; break; case tgtok::XListConcat: Code = BinOpInit::LISTCONCAT; break; - case tgtok::XListSplat: Code = BinOpInit::LISTSPLAT; break; - case tgtok::XStrConcat: Code = BinOpInit::STRCONCAT; break; - case tgtok::XSetOp: Code = BinOpInit::SETOP; break; + case tgtok::XListSplat: Code = BinOpInit::LISTSPLAT; break; + case tgtok::XStrConcat: Code = BinOpInit::STRCONCAT; break; + case tgtok::XSetDagOp: Code = BinOpInit::SETDAGOP; break; } RecTy *Type = nullptr; @@ -1126,7 +1126,7 @@ default: llvm_unreachable("Unhandled code!"); case tgtok::XConcat: - case tgtok::XSetOp: + case tgtok::XSetDagOp: Type = DagRecTy::get(); ArgType = DagRecTy::get(); break; @@ -1259,7 +1259,7 @@ // Deal with BinOps whose arguments have different types, by // rewriting ArgType in between them. switch (Code) { - case BinOpInit::SETOP: + case BinOpInit::SETDAGOP: // After parsing the first dag argument, switch to expecting // a record, with no restriction on its superclasses. ArgType = RecordRecTy::get({}); @@ -1417,7 +1417,7 @@ case tgtok::XDag: case tgtok::XIf: - case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')' + case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')' TernOpInit::TernaryOp Code; RecTy *Type = nullptr; @@ -2051,7 +2051,7 @@ case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')' Lex.Lex(); // eat the '(' if (Lex.getCode() != tgtok::Id && Lex.getCode() != tgtok::XCast && - Lex.getCode() != tgtok::question && Lex.getCode() != tgtok::XGetOp) { + Lex.getCode() != tgtok::question && Lex.getCode() != tgtok::XGetDagOp) { TokError("expected identifier in dag init"); return nullptr; } @@ -2089,7 +2089,7 @@ case tgtok::XSize: case tgtok::XEmpty: case tgtok::XCast: - case tgtok::XGetOp: // Value ::= !unop '(' Value ')' + case tgtok::XGetDagOp: // Value ::= !unop '(' Value ')' case tgtok::XIsA: case tgtok::XConcat: case tgtok::XDag: @@ -2111,12 +2111,12 @@ case tgtok::XListConcat: case tgtok::XListSplat: case tgtok::XStrConcat: - case tgtok::XSetOp: // Value ::= !binop '(' Value ',' Value ')' + case tgtok::XSetDagOp: // Value ::= !binop '(' Value ',' Value ')' case tgtok::XIf: case tgtok::XCond: case tgtok::XFoldl: case tgtok::XForEach: - case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')' + case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')' return ParseOperation(CurRec, ItemType); } } @@ -2186,7 +2186,7 @@ break; } case tgtok::dot: { - if (Lex.Lex() != tgtok::Id) { // eat the . + if (Lex.Lex() != tgtok::Id) { // eat the . TokError("expected field identifier after '.'"); return nullptr; } diff --git a/llvm/lib/Target/ARM/ARMInstrMVE.td b/llvm/lib/Target/ARM/ARMInstrMVE.td --- a/llvm/lib/Target/ARM/ARMInstrMVE.td +++ b/llvm/lib/Target/ARM/ARMInstrMVE.td @@ -3033,7 +3033,7 @@ defvar outparams = (inst (OutVTI.Vec MQPR:$QdSrc), (InVTI.Vec MQPR:$Qm), (imm:$imm)); - def : Pat<(OutVTI.Vec !setop(inparams, int_arm_mve_vshrn)), + def : Pat<(OutVTI.Vec !setdagop(inparams, int_arm_mve_vshrn)), (OutVTI.Vec outparams)>; def : Pat<(OutVTI.Vec !con(inparams, (int_arm_mve_vshrn_predicated (InVTI.Pred VCCR:$pred)))), @@ -3235,7 +3235,7 @@ defvar unpred_int = !cast("int_arm_mve_" # name); defvar pred_int = !cast("int_arm_mve_" # name # "_predicated"); - def : Pat<(VTI.Vec !setop(inparams, unpred_int)), + def : Pat<(VTI.Vec !setdagop(inparams, unpred_int)), (VTI.Vec outparams)>; def : Pat<(VTI.Vec !con(inparams, (pred_int (VTI.Pred VCCR:$pred)))), (VTI.Vec !con(outparams, (? ARMVCCThen, VCCR:$pred)))>; diff --git a/llvm/test/TableGen/getsetop.td b/llvm/test/TableGen/getsetop.td --- a/llvm/test/TableGen/getsetop.td +++ b/llvm/test/TableGen/getsetop.td @@ -3,6 +3,9 @@ // RUN: not llvm-tblgen -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s // RUN: not llvm-tblgen -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s +// !setop and !getop are deprecated in favor of !setdagop and !getdagop. +// Two tests retain the old names just to be sure they are still supported. + class Base; class OtherBase; @@ -18,28 +21,28 @@ dag replaceWithBar = !setop(orig, bar); // CHECK: dag replaceWithBaz = (qux 1, 2:$a, ?:$b); - dag replaceWithBaz = !setop(orig, qux); + dag replaceWithBaz = !setdagop(orig, qux); // CHECK: Base getopWithCast = foo; Base getopWithCast = !getop(orig); // CHECK: dag getopToSetop = (foo "hello", ?:$world); - dag getopToSetop = !setop(another, !getop(orig)); + dag getopToSetop = !setdagop(another, !getdagop(orig)); // CHECK: dag getopToBangDag = (foo 1:$a, 2:$b, 3:$c); - dag getopToBangDag = !dag(!getop(orig), [1, 2, 3], ["a", "b", "c"]); + dag getopToBangDag = !dag(!getdagop(orig), [1, 2, 3], ["a", "b", "c"]); // CHECK: dag getopToDagInit = (foo "it worked"); - dag getopToDagInit = (!getop(orig) "it worked"); + dag getopToDagInit = (!getdagop(orig) "it worked"); #ifdef ERROR1 - // !getop(...) has a static type of 'any record at all, with no + // !getdagop(...) has a static type of 'any record at all, with no // required superclasses'. That's too general to use in an // assignment whose LHS demands an instance of Base, so we expect a // static (parse-time) type-checking error. - // ERROR1: error: Field 'noCast' of type 'Base' is incompatible with value '!getop(orig)' of type '{}' - Base noCast = !getop(orig); + // ERROR1: error: Field 'noCast' of type 'Base' is incompatible with value '!getdagop(orig)' of type '{}' + Base noCast = !getdagop(orig); #endif #ifdef ERROR2 @@ -47,15 +50,15 @@ // evaluation time that the operator of 'another' is a record that // isn't an instance of the specified base class. - // ERROR2: error: Expected type 'Base', got 'OtherBase' in: !getop((qux "hello", ?:$world)) - Base badCast = !getop(another); + // ERROR2: error: Expected type 'Base', got 'OtherBase' in: !getdagop((qux "hello", ?:$world)) + Base badCast = !getdagop(another); #endif #ifdef ERROR3 - // Obviously, you shouldn't be able to give any type to !getop that + // Obviously, you shouldn't be able to give any type to !getdagop that // isn't a class type. - // ERROR3: error: type for !getop must be a record type - int ridiculousCast = !getop(orig); + // ERROR3: error: type for !getdagop must be a record type + int ridiculousCast = !getdagop(orig); #endif }