mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-03 11:24:18 +00:00
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
This commit is contained in:
@ -432,8 +432,8 @@ protected:
|
|||||||
/// readability for really no benefit.
|
/// readability for really no benefit.
|
||||||
enum InitKind {
|
enum InitKind {
|
||||||
IK_BitInit,
|
IK_BitInit,
|
||||||
IK_BitsInit,
|
|
||||||
IK_FirstTypedInit,
|
IK_FirstTypedInit,
|
||||||
|
IK_BitsInit,
|
||||||
IK_DagInit,
|
IK_DagInit,
|
||||||
IK_DefInit,
|
IK_DefInit,
|
||||||
IK_FieldInit,
|
IK_FieldInit,
|
||||||
@ -651,11 +651,12 @@ public:
|
|||||||
/// BitsInit - { a, b, c } - Represents an initializer for a BitsRecTy value.
|
/// BitsInit - { a, b, c } - Represents an initializer for a BitsRecTy value.
|
||||||
/// It contains a vector of bits, whose size is determined by the type.
|
/// It contains a vector of bits, whose size is determined by the type.
|
||||||
///
|
///
|
||||||
class BitsInit : public Init, public FoldingSetNode {
|
class BitsInit : public TypedInit, public FoldingSetNode {
|
||||||
std::vector<Init*> Bits;
|
std::vector<Init*> Bits;
|
||||||
|
|
||||||
BitsInit(ArrayRef<Init *> Range)
|
BitsInit(ArrayRef<Init *> Range)
|
||||||
: Init(IK_BitsInit), Bits(Range.begin(), Range.end()) {}
|
: TypedInit(IK_BitsInit, BitsRecTy::get(Range.size())),
|
||||||
|
Bits(Range.begin(), Range.end()) {}
|
||||||
|
|
||||||
BitsInit(const BitsInit &Other) LLVM_DELETED_FUNCTION;
|
BitsInit(const BitsInit &Other) LLVM_DELETED_FUNCTION;
|
||||||
BitsInit &operator=(const BitsInit &Other) LLVM_DELETED_FUNCTION;
|
BitsInit &operator=(const BitsInit &Other) LLVM_DELETED_FUNCTION;
|
||||||
@ -688,6 +689,14 @@ public:
|
|||||||
}
|
}
|
||||||
std::string getAsString() const override;
|
std::string getAsString() const override;
|
||||||
|
|
||||||
|
/// resolveListElementReference - This method is used to implement
|
||||||
|
/// VarListElementInit::resolveReferences. If the list element is resolvable
|
||||||
|
/// now, we return the resolved value, otherwise we return null.
|
||||||
|
Init *resolveListElementReference(Record &R, const RecordVal *RV,
|
||||||
|
unsigned Elt) const override {
|
||||||
|
llvm_unreachable("Illegal element reference off bits<n>");
|
||||||
|
}
|
||||||
|
|
||||||
Init *resolveReferences(Record &R, const RecordVal *RV) const override;
|
Init *resolveReferences(Record &R, const RecordVal *RV) const override;
|
||||||
|
|
||||||
Init *getBit(unsigned Bit) const override {
|
Init *getBit(unsigned Bit) const override {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
// Support for an `!if' operator as part of a `let' statement.
|
// Support for an `!if' operator as part of a `let' statement.
|
||||||
// CHECK: class C
|
// CHECK: class C
|
||||||
// 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} };
|
// 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} };
|
||||||
class C<bits<3> x, bits<4> y, bit z> {
|
class C<bits<3> x, bits<4> y, bit z> {
|
||||||
bits<16> n;
|
bits<16> n;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// RUN: llvm-tblgen %s | FileCheck %s
|
// RUN: llvm-tblgen %s | FileCheck %s
|
||||||
// XFAIL: vg_leak
|
// XFAIL: vg_leak
|
||||||
|
|
||||||
class C<list<bits<8>> L> {
|
class C<list<bits<4>> L> {
|
||||||
bits<2> V0 = L[0]{1-0};
|
bits<2> V0 = L[0]{1-0};
|
||||||
bits<2> V1 = L[1]{3-2};
|
bits<2> V1 = L[1]{3-2};
|
||||||
string V2 = !if(L[0]{0}, "Odd", "Even");
|
string V2 = !if(L[0]{0}, "Odd", "Even");
|
||||||
|
@ -520,6 +520,21 @@ bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bits<n> (also used for 0bxx literals)
|
||||||
|
if (BitsInit *BI = dyn_cast<BitsInit>(Arg)) {
|
||||||
|
if (hasSubOps || !InstOpRec->isSubClassOf("Operand"))
|
||||||
|
return false;
|
||||||
|
if (!BI->isComplete())
|
||||||
|
return false;
|
||||||
|
// Convert the bits init to an integer and use that for the result.
|
||||||
|
IntInit *II =
|
||||||
|
dyn_cast_or_null<IntInit>(BI->convertInitializerTo(IntRecTy::get()));
|
||||||
|
if (!II)
|
||||||
|
return false;
|
||||||
|
ResOp = ResultOperand(II->getValue());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// If both are Operands with the same MVT, allow the conversion. It's
|
// If both are Operands with the same MVT, allow the conversion. It's
|
||||||
// up to the user to make sure the values are appropriate, just like
|
// up to the user to make sure the values are appropriate, just like
|
||||||
// for isel Pat's.
|
// for isel Pat's.
|
||||||
|
Reference in New Issue
Block a user