[llvm-bugs] [Bug 30254] New: Problem with using "enum"

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 2 05:55:39 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30254

            Bug ID: 30254
           Summary: Problem with using "enum"
           Product: tools
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: TableGen
          Assignee: unassignedbugs at nondot.org
          Reporter: valery.pykhtin at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following testcase:

<<<<<<<
class Operand {}

def Enum : Operand {
  int AAA = 1;
  int BBB = 2;
}

class getString<int Selector> {
  string ret =
    !if(!eq(Selector, Enum.AAA),  "AAA",
    !if(!eq(Selector, Enum.BBB),  "BBB",
    ""));
}

class S <int Selector, int SelectorCopy = Selector> {
  string v1 = getString<Selector>.ret;  // <-- Doesnt resolve!
  string v2 = getString<SelectorCopy>.ret; // <-- but this resolve!
}

// Works ok
def C1 : S <1>;
def C2 : S <2>;

// Incorrect version, S:v1 doesnt resolve to a string
def W1 : S <Enum.AAA>;
def W2 : S <Enum.BBB>;
>>>>>>>


gives the following output:


------------- Classes -----------------
class Operand {
  string NAME = ?;
}
class S<int S:Selector = ?, int S:SelectorCopy = S:Selector> {
  string v1 = anonymous_0.ret;
  string v2 = anonymous_1.ret;
  string NAME = ?;
}
class getString<int getString:Selector = ?> {
  string ret = !if(!eq(getString:Selector, Enum.AAA), "AAA",
!if(!eq(getString:Selector, Enum.BBB), "BBB", ""));
  string NAME = ?;
}
------------- Defs -----------------
def C1 {    // S
  int S:SelectorCopy = 1;
  string v1 = "AAA";
  string v2 = "AAA";
  string NAME = ?;
}
def C2 {    // S
  int S:SelectorCopy = 2;
  string v1 = "BBB";
  string v2 = "BBB";
  string NAME = ?;
}
def Enum {    // Operand
  int AAA = 1;
  int BBB = 2;
  string NAME = ?;
}
def W1 {    // S
  int S:SelectorCopy = 1;
  string v1 = anonymous_0.ret;
  string v2 = "AAA";
  string NAME = ?;
}
def W2 {    // S
  int S:SelectorCopy = 2;
  string v1 = anonymous_0.ret;
  string v2 = "BBB";
  string NAME = ?;
}
def anonymous_0 {    // getString
  string ret = !if(!eq(S:Selector, 1), "AAA", !if(!eq(S:Selector, 2), "BBB",
""));
  string NAME = ?;
}
def anonymous_1 {    // getString
  string ret = !if(!eq(S:SelectorCopy, 1), "AAA", !if(!eq(S:SelectorCopy, 2),
"BBB", ""));
  string NAME = ?;
}


Here W1.v1 and W2.v1 doesn't resolve correctly to a string value.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160902/e729fd69/attachment.html>


More information about the llvm-bugs mailing list