mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
TableGen: Support folding casts from bits to int
This is to fix an incorrect error when trying to initialize
DwarfNumbers with a !cast<int> of a bits initializer.
getValuesAsListOfInts("DwarfNumbers") would not see an IntInit
and instead the cast, so would give up.
It seems likely that this could be generalized to attempt
the convertInitializerTo for any type. I'm not really sure
why the existing code seems to special case the string cast cases
when convertInitializerTo seems like it should generally handle this
sort of thing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243722 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
1 parent
a29a752cf5
commit
6a224c30a5
2 files changed
+18
No files matched your search
@@ -673,6 +673,14 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
|
||||
PrintFatalError(CurRec->getLoc(),
|
||||
"Undefined reference:'" + Name + "'\n");
|
||||
}
|
||||
|
||||
if (isa<IntRecTy>(getType())) {
|
||||
if (BitsInit *BI = dyn_cast<BitsInit>(LHS)) {
|
||||
if (Init *NewInit = BI->convertInitializerTo(IntRecTy::get()))
|
||||
return NewInit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// RUN: llvm-tblgen %s | FileCheck %s
|
||||
|
||||
class Foo<bits<8> b> {
|
||||
// CHECK: list<int> ListOfInts = [170];
|
||||
// CHECK: list<int> AnotherList = [170, 7];
|
||||
list<int> ListOfInts = [!cast<int>(b)];
|
||||
list<int> AnotherList = [!cast<int>(b), !cast<int>({1, 1, 1})];
|
||||
}
|
||||
|
||||
def : Foo<{1, 0, 1, 0, 1, 0, 1, 0}>;
|
||||
Reference in new issue
Block a user