mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
For a tablegen expression such as !if(a,b,c), let 'a'
be evaluated for 'bit' operators git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106185 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -422,7 +422,8 @@ class. This operation is analogous to $(foreach) in GNU make.</dd>
|
|||||||
<dt><tt>!null(a)</tt></dt>
|
<dt><tt>!null(a)</tt></dt>
|
||||||
<dd>An integer {0,1} indicating whether list 'a' is empty.</dd>
|
<dd>An integer {0,1} indicating whether list 'a' is empty.</dd>
|
||||||
<dt><tt>!if(a,b,c)</tt></dt>
|
<dt><tt>!if(a,b,c)</tt></dt>
|
||||||
<dd>'b' if the result of integer operator 'a' is nonzero, 'c' otherwise.</dd>
|
<dd>'b' if the result of 'int' or 'bit' operator 'a' is nonzero,
|
||||||
|
'c' otherwise.</dd>
|
||||||
<dt><tt>!eq(a,b)</tt></dt>
|
<dt><tt>!eq(a,b)</tt></dt>
|
||||||
<dd>Integer one if string a is equal to string b, zero otherwise. This
|
<dd>Integer one if string a is equal to string b, zero otherwise. This
|
||||||
only operates on string, int and bit objects. Use !cast<string> to
|
only operates on string, int and bit objects. Use !cast<string> to
|
||||||
|
11
test/TableGen/ifbit.td
Normal file
11
test/TableGen/ifbit.td
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// RUN: tblgen %s | FileCheck %s
|
||||||
|
// XFAIL: vg_leak
|
||||||
|
// CHECK: a = 6
|
||||||
|
// CHECK: a = 5
|
||||||
|
|
||||||
|
class A<bit b = 1> {
|
||||||
|
int a = !if(b, 5, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
def X : A<0>;
|
||||||
|
def Y : A;
|
@@ -981,7 +981,8 @@ Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case IF: {
|
case IF: {
|
||||||
IntInit *LHSi = dynamic_cast<IntInit*>(LHS);
|
IntInit *LHSi =
|
||||||
|
dynamic_cast<IntInit*>(LHS->convertInitializerTo(new IntRecTy()));
|
||||||
if (LHSi) {
|
if (LHSi) {
|
||||||
if (LHSi->getValue()) {
|
if (LHSi->getValue()) {
|
||||||
return MHS;
|
return MHS;
|
||||||
@@ -1000,7 +1001,8 @@ Init *TernOpInit::resolveReferences(Record &R, const RecordVal *RV) {
|
|||||||
Init *lhs = LHS->resolveReferences(R, RV);
|
Init *lhs = LHS->resolveReferences(R, RV);
|
||||||
|
|
||||||
if (Opc == IF && lhs != LHS) {
|
if (Opc == IF && lhs != LHS) {
|
||||||
IntInit *Value = dynamic_cast<IntInit*>(lhs);
|
IntInit *Value =
|
||||||
|
dynamic_cast<IntInit*>(LHS->convertInitializerTo(new IntRecTy()));
|
||||||
if (Value != 0) {
|
if (Value != 0) {
|
||||||
// Short-circuit
|
// Short-circuit
|
||||||
if (Value->getValue()) {
|
if (Value->getValue()) {
|
||||||
|
Reference in New Issue
Block a user