mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-30 06:40:53 +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. llvm-svn: 215085
This commit is contained in:
parent
5e735d5967
commit
8cac65e882
@ -432,8 +432,8 @@ protected:
|
||||
/// readability for really no benefit.
|
||||
enum InitKind {
|
||||
IK_BitInit,
|
||||
IK_BitsInit,
|
||||
IK_FirstTypedInit,
|
||||
IK_BitsInit,
|
||||
IK_DagInit,
|
||||
IK_DefInit,
|
||||
IK_FieldInit,
|
||||
@ -651,11 +651,12 @@ public:
|
||||
/// BitsInit - { a, b, c } - Represents an initializer for a BitsRecTy value.
|
||||
/// 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;
|
||||
|
||||
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 &operator=(const BitsInit &Other) LLVM_DELETED_FUNCTION;
|
||||
@ -688,6 +689,14 @@ public:
|
||||
}
|
||||
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 *getBit(unsigned Bit) const override {
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
// Support for an `!if' operator as part of a `let' statement.
|
||||
// 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> {
|
||||
bits<16> n;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// RUN: llvm-tblgen %s | FileCheck %s
|
||||
// XFAIL: vg_leak
|
||||
|
||||
class C<list<bits<8>> L> {
|
||||
class C<list<bits<4>> L> {
|
||||
bits<2> V0 = L[0]{1-0};
|
||||
bits<2> V1 = L[1]{3-2};
|
||||
string V2 = !if(L[0]{0}, "Odd", "Even");
|
||||
|
@ -520,6 +520,21 @@ bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
|
||||
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
|
||||
// up to the user to make sure the values are appropriate, just like
|
||||
// for isel Pat's.
|
||||
|
Loading…
Reference in New Issue
Block a user