llvm.org GIT mirror llvm / 2093e2c
Change BitsInit to inherit from TypedInit. This is useful in a later patch where binary literals such as 0b000 will become BitsInit values instead of IntInit values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215085 91177308-0d34-0410-b5e6-96231b3b80d8 Pete Cooper 5 years ago
4 changed file(s) with 29 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
431431 /// readability for really no benefit.
432432 enum InitKind {
433433 IK_BitInit,
434 IK_FirstTypedInit,
434435 IK_BitsInit,
435 IK_FirstTypedInit,
436436 IK_DagInit,
437437 IK_DefInit,
438438 IK_FieldInit,
650650 /// BitsInit - { a, b, c } - Represents an initializer for a BitsRecTy value.
651651 /// It contains a vector of bits, whose size is determined by the type.
652652 ///
653 class BitsInit : public Init, public FoldingSetNode {
653 class BitsInit : public TypedInit, public FoldingSetNode {
654654 std::vector Bits;
655655
656656 BitsInit(ArrayRef Range)
657 : Init(IK_BitsInit), Bits(Range.begin(), Range.end()) {}
657 : TypedInit(IK_BitsInit, BitsRecTy::get(Range.size())),
658 Bits(Range.begin(), Range.end()) {}
658659
659660 BitsInit(const BitsInit &Other) LLVM_DELETED_FUNCTION;
660661 BitsInit &operator=(const BitsInit &Other) LLVM_DELETED_FUNCTION;
686687 return true;
687688 }
688689 std::string getAsString() const override;
690
691 /// resolveListElementReference - This method is used to implement
692 /// VarListElementInit::resolveReferences. If the list element is resolvable
693 /// now, we return the resolved value, otherwise we return null.
694 Init *resolveListElementReference(Record &R, const RecordVal *RV,
695 unsigned Elt) const override {
696 llvm_unreachable("Illegal element reference off bits");
697 }
689698
690699 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
691700
22
33 // Support for an `!if' operator as part of a `let' statement.
44 // CHECK: class C
5 // CHECK-NEXT: bits<16> n = { ?, ?, ?, ?, !if({ C:y{3} }, 1, !if({ C:y{2} }, { C:x{0} }, !if({ C:y{1} }, { C:x{1} }, !if({ C:y{0} }, { C:x{2} }, ?)))){0}, !if({ C:x{2} }, { C:y{3}, C:y{2} }, !if({ C:x{1} }, { C:y{2}, C:y{1} }, !if({ C:x{0} }, { C:y{1}, C:y{0} }, ?))){1}, !if({ C:x{2} }, { C:y{3}, C:y{2} }, !if({ C:x{1} }, { C:y{2}, C:y{1} }, !if({ C:x{0} }, { C:y{1}, C:y{0} }, ?))){0}, !if({ C:x{2} }, 2, 6){2}, !if({ C:x{2} }, 2, 6){1}, !if({ C:x{2} }, 2, 6){0}, !if({ C:x{1} }, { C:y{3}, C:y{2} }, { 0, 1 }){1}, !if({ C:x{1} }, { C:y{3}, C:y{2} }, { 0, 1 }){0}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){3}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){2}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){1}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){0} };
5 // CHECK-NEXT: bits<16> n = { ?, ?, ?, ?, !if({ C:y{3} }, 1, !if({ C:y{2} }, { C:x{0} }, !if({ C:y{1} }, { C:x{1} }, !if({ C:y{0} }, { C:x{2} }, ?)))){0}, !if({ C:x{2} }, { C:y{3}, C:y{2} }, !if({ C:x{1} }, { C:y{2}, C:y{1} }, !if({ C:x{0} }, { C:y{1}, C:y{0} }, ?))){1}, !if({ C:x{2} }, { C:y{3}, C:y{2} }, !if({ C:x{1} }, { C:y{2}, C:y{1} }, !if({ C:x{0} }, { C:y{1}, C:y{0} }, ?))){0}, !if({ C:x{2} }, { 0, 1, 0 }, { 1, 1, 0 }){2}, !if({ C:x{2} }, { 0, 1, 0 }, { 1, 1, 0 }){1}, !if({ C:x{2} }, { 0, 1, 0 }, { 1, 1, 0 }){0}, !if({ C:x{1} }, { C:y{3}, C:y{2} }, { 0, 1 }){1}, !if({ C:x{1} }, { C:y{3}, C:y{2} }, { 0, 1 }){0}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){3}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){2}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){1}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){0} };
66 class C x, bits<4> y, bit z> {
77 bits<16> n;
88
0 // RUN: llvm-tblgen %s | FileCheck %s
11 // XFAIL: vg_leak
22
3 class C8>> L> {
3 class C4>> L> {
44 bits<2> V0 = L[0]{1-0};
55 bits<2> V1 = L[1]{3-2};
66 string V2 = !if(L[0]{0}, "Odd", "Even");
515515 if (!Result->getArgName(AliasOpNo).empty())
516516 PrintFatalError(Loc, "result argument #" + Twine(AliasOpNo) +
517517 " must not have a name!");
518 ResOp = ResultOperand(II->getValue());
519 return true;
520 }
521
522 // Bits (also used for 0bxx literals)
523 if (BitsInit *BI = dyn_cast(Arg)) {
524 if (hasSubOps || !InstOpRec->isSubClassOf("Operand"))
525 return false;
526 if (!BI->isComplete())
527 return false;
528 // Convert the bits init to an integer and use that for the result.
529 IntInit *II =
530 dyn_cast_or_null(BI->convertInitializerTo(IntRecTy::get()));
531 if (!II)
532 return false;
518533 ResOp = ResultOperand(II->getValue());
519534 return true;
520535 }