mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-05 03:36:43 +00:00
Update BitRecTy::convertValue to allow if expressions with bit values on both sides of the if
llvm-svn: 215087
This commit is contained in:
parent
5d88ea715c
commit
cbc13312c3
@ -119,6 +119,16 @@ Init *BitRecTy::convertValue(TypedInit *VI) {
|
|||||||
if (auto *BitsTy = dyn_cast<BitsRecTy>(Ty))
|
if (auto *BitsTy = dyn_cast<BitsRecTy>(Ty))
|
||||||
// Accept only bits<1> expression.
|
// Accept only bits<1> expression.
|
||||||
return BitsTy->getNumBits() == 1 ? VI : nullptr;
|
return BitsTy->getNumBits() == 1 ? VI : nullptr;
|
||||||
|
// Ternary !if can be converted to bit, but only if both sides are
|
||||||
|
// convertible to a bit.
|
||||||
|
if (TernOpInit *TOI = dyn_cast<TernOpInit>(VI)) {
|
||||||
|
if (TOI->getOpcode() != TernOpInit::TernaryOp::IF)
|
||||||
|
return nullptr;
|
||||||
|
if (!TOI->getMHS()->convertInitializerTo(BitRecTy::get()) ||
|
||||||
|
!TOI->getRHS()->convertInitializerTo(BitRecTy::get()))
|
||||||
|
return nullptr;
|
||||||
|
return TOI;
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
class A<bit b = 1> {
|
class A<bit b = 1> {
|
||||||
int a = !if(b, 5, 6);
|
int a = !if(b, 5, 6);
|
||||||
|
bit c = !if(b, 0, 1);
|
||||||
|
bits<1> d = !if(b, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
def X : A<0>;
|
def X : A<0>;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user