Sachin.Punyani at microchip.com
2008-Aug-18 13:31 UTC
[LLVMdev] Type Legalizer - Load handling problem
Hi All, I have some doubt in LLVM Type Legalizer. How will LOAD:i8 with an i16 operand be lowered in type legalizer? (i16 type is not legal for our target) Following assertion in function ExpandIntegerOperand (file LegalizeIntegerTypes.cpp) is not allowing us to change LOAD node. assert(Res.getValueType() == N->getValueType(0) && N->getNumValues() =1 && "Invalid operand expansion"); LOAD node has two values but the assertion checks N->getNumValues() == 1 which is not letting us change load operation. Also in the first check of the insertion, 0th value type (MVT::Other (chain) for load) of the node N is being compared with the value type of Res. It is not trying to compare 1st value (which is i8) of LOAD with the 1st value of Res. Regards Sachin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080818/c59271f6/attachment.html>
On Mon, Aug 18, 2008 at 6:31 AM, <Sachin.Punyani at microchip.com> wrote:> assert(Res.getValueType() == N->getValueType(0) && N->getNumValues() == 1 && > "Invalid operand expansion"); > > LOAD node has two values but the assertion checks N->getNumValues() == 1 > which is not letting us change load operation.I don't really know the right answer here, but custom-legalizing to a backend-specific load operation should be feasible, although it's a bit messy. -Eli
On Mon, 2008-08-18 at 08:50 -0700, Eli Friedman wrote:> On Mon, Aug 18, 2008 at 6:31 AM, <Sachin.Punyani at microchip.com> wrote: > > assert(Res.getValueType() == N->getValueType(0) && N->getNumValues() == 1 && > > "Invalid operand expansion"); > > > > LOAD node has two values but the assertion checks N->getNumValues() == 1 > > which is not letting us change load operation. >Besides the assert, the call to ReplaceValueWith(SDValue(N, 0), Res); also looks incorrect, because the back-end lowered load will return two values as well. - Sanjiv
Hi,> How will LOAD:i8 with an i16 operand be lowered in type legalizer? (i16 > type is not legal for our target)what does "LOAD:i8 with an i16 operand" mean? Are you saying that the type of a pointer is i16, and you are loading an i8 value from the pointed to location? If so, you are in trouble because many parts of the code generator assume that the type of a pointer is legal.> Following assertion in function ExpandIntegerOperand (file > LegalizeIntegerTypes.cpp) is not allowing us to change LOAD node. > > > > assert(Res.getValueType() == N->getValueType(0) && N->getNumValues() => 1 && "Invalid operand expansion"); > > > > LOAD node has two values but the assertion checks N->getNumValues() == 1 > which is not letting us change load operation.Yup, in this case you need to return an SDValue with null Val field, and take care of replacing values yourself.> Also in the first check of the insertion, 0th value type (MVT::Other > (chain) for load) of the node N is being compared with the value type of > Res. It is not trying to compare 1st value (which is i8) of LOAD with > the 1st value of Res.Since the assertion only allows the node to have one value, this is not a problem. Ciao, Duncan.
> > LOAD node has two values but the assertion checks N->getNumValues() == 1 > > which is not letting us change load operation. > > Yup, in this case you need to return an SDValue with null Val field, > and take care of replacing values yourself.That said, it looks like it is done this way because no-one needed anything more. It could easily be changed to handle the case of any number of return values. Ciao, Duncan.
On Fri, 2008-08-29 at 15:32 +0200, Duncan Sands wrote:> Hi, > > > How will LOAD:i8 with an i16 operand be lowered in type legalizer? (i16 > > type is not legal for our target) > > what does "LOAD:i8 with an i16 operand" mean? Are you saying that the > type of a pointer is i16, and you are loading an i8 value from the > pointed to location? If so, you are in trouble because many parts of > the code generator assume that the type of a pointer is legal. >Yes we have 16-bit pointers but only 8-bit operations and 8-bit registers. For indirect loads/stores, the 16-bit pointer gets loaded into a register pair. - Sanjiv