1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

Continued support for field intitializers

llvm-svn: 4855
This commit is contained in:
Chris Lattner 2002-12-02 17:53:54 +00:00
parent 29f8466be1
commit 1a4dddb269
2 changed files with 36 additions and 17 deletions

View File

@ -24,7 +24,7 @@ Init *BitRecTy::convertValue(IntInit *II) {
return new BitInit(Val != 0);
}
Init *BitRecTy::convertValue(VarInit *VI) {
Init *BitRecTy::convertValue(TypedInit *VI) {
if (dynamic_cast<BitRecTy*>(VI->getType()))
return VI; // Accept variable if it is already of bit type!
return 0;
@ -65,7 +65,7 @@ Init *BitsRecTy::convertValue(BitsInit *BI) {
return 0;
}
Init *BitsRecTy::convertValue(VarInit *VI) {
Init *BitsRecTy::convertValue(TypedInit *VI) {
if (BitsRecTy *BRT = dynamic_cast<BitsRecTy*>(VI->getType()))
if (BRT->Size == Size) {
BitsInit *Ret = new BitsInit(Size);
@ -82,9 +82,23 @@ Init *BitsRecTy::convertValue(VarInit *VI) {
return 0;
}
#if 0
Init *BitsRecTy::convertValue(FieldInit *VI) {
if (BitsRecTy *BRT = dynamic_cast<BitsRecTy*>(VI->getType()))
if (BRT->Size == Size) {
BitsInit *Ret = new BitsInit(Size);
for (unsigned i = 0; i != Size; ++i)
Ret->setBit(i, new VarBitInit(VI, i));
return Ret;
}
if (Size == 1 && dynamic_cast<BitRecTy*>(VI->getType())) {
BitsInit *Ret = new BitsInit(1);
Ret->setBit(0, VI);
return Ret;
}
return 0;
}
#endif
Init *IntRecTy::convertValue(BitsInit *BI) {
@ -98,15 +112,15 @@ Init *IntRecTy::convertValue(BitsInit *BI) {
return new IntInit(Result);
}
Init *IntRecTy::convertValue(VarInit *VI) {
if (dynamic_cast<IntRecTy*>(VI->getType()))
return VI; // Accept variable if already of the right type!
Init *IntRecTy::convertValue(TypedInit *TI) {
if (dynamic_cast<IntRecTy*>(TI->getType()))
return TI; // Accept variable if already of the right type!
return 0;
}
Init *StringRecTy::convertValue(VarInit *VI) {
if (dynamic_cast<StringRecTy*>(VI->getType()))
return VI; // Accept variable if already of the right type!
Init *StringRecTy::convertValue(TypedInit *TI) {
if (dynamic_cast<StringRecTy*>(TI->getType()))
return TI; // Accept variable if already of the right type!
return 0;
}

View File

@ -17,10 +17,11 @@ class BitsInit;
class IntInit;
class StringInit;
class ListInit;
class VarInit;
class VarBitInit;
class DefInit;
class TypedInit;
class VarInit;
class FieldInit;
class VarBitInit;
class Record;
//===----------------------------------------------------------------------===//
@ -36,10 +37,15 @@ struct RecTy {
virtual Init *convertValue( IntInit *II) { return 0; }
virtual Init *convertValue(StringInit *SI) { return 0; }
virtual Init *convertValue( ListInit *LI) { return 0; }
virtual Init *convertValue( VarInit *VI) { return 0; }
virtual Init *convertValue(VarBitInit *VB) { return 0; }
virtual Init *convertValue( DefInit *DI) { return 0; }
virtual Init *convertValue( FieldInit *FI) { return 0; }
virtual Init *convertValue( TypedInit *TI) { return 0; }
virtual Init *convertValue( VarInit *VI) {
return convertValue((TypedInit*)VI);
}
virtual Init *convertValue( FieldInit *FI) {
return convertValue((TypedInit*)FI);
}
virtual void print(std::ostream &OS) const = 0;
void dump() const;
@ -58,7 +64,7 @@ struct BitRecTy : public RecTy {
Init *convertValue(BitInit *BI) { return (Init*)BI; }
Init *convertValue(BitsInit *BI);
Init *convertValue(IntInit *II);
Init *convertValue(VarInit *VI);
Init *convertValue(TypedInit *VI);
Init *convertValue(VarBitInit *VB) { return (Init*)VB; }
void print(std::ostream &OS) const { OS << "bit"; }
@ -78,8 +84,7 @@ public:
Init *convertValue(BitInit *UI);
Init *convertValue(BitsInit *BI);
Init *convertValue(IntInit *II);
Init *convertValue(VarInit *VI);
Init *convertValue(FieldInit *VI);
Init *convertValue(TypedInit *VI);
void print(std::ostream &OS) const { OS << "bits<" << Size << ">"; }
};
@ -91,7 +96,7 @@ struct IntRecTy : public RecTy {
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
Init *convertValue(IntInit *II) { return (Init*)II; }
Init *convertValue(BitsInit *BI);
Init *convertValue(VarInit *VI);
Init *convertValue(TypedInit *TI);
void print(std::ostream &OS) const { OS << "int"; }
};
@ -101,7 +106,7 @@ struct IntRecTy : public RecTy {
struct StringRecTy : public RecTy {
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
Init *convertValue(StringInit *SI) { return (Init*)SI; }
Init *convertValue(VarInit *VI);
Init *convertValue(TypedInit *VI);
void print(std::ostream &OS) const { OS << "string"; }
};