Giter Site home page Giter Site logo

Comments (11)

cmarcelo avatar cmarcelo commented on May 24, 2024 1

I'm working on this one.

from clangir.

j2kun avatar j2kun commented on May 24, 2024 1

Is anyone still working on this? I ran into

case UO_PreInc:
case UO_PreDec: {
assert(0 && "not implemented");
when compiling

short isqrt(short num) {
  short res = 0;
  short bit = 1 << 14;  // ((unsigned) INT16_MAX + 1) / 2.

  for (int i = 0; i < 8; ++i) {
    if (num >= res + bit) {
      num -= res + bit;
      res = (res >> 1) + bit;
    } else {
      res >>= 1;
    }
    bit >>= 2;
  }
  return res;
}

The first failure was the loop pre-increment as an expression. I'd be happy to add it, though it seems from this commit that there are quite a few cases to deal with... maybe if someone could provide me a quick outline I could get started?

from clangir.

bcardosolopes avatar bcardosolopes commented on May 24, 2024 1

Hi @j2kun, thanks for the interest working on this.

We try to match the skeleton as much as possible with the LLVM's codegen. So in this case, you need something like this from CGExpr.cpp

Screenshot 2023-05-15 at 5 01 34 PM

You can put a llvm_unreachable for the complex case, and in the scalar just call buildScalarPrePostIncDec (instead of EmitScalarPrePostIncDec). Same for buildLValue as opposed to EmitLValue.

from clangir.

j2kun avatar j2kun commented on May 24, 2024 1

I see where my confusion was now.

In the LLVM codegen, the externally accessible EmitScalarPrePostIncDec is declared in CodeGenFunction.h, but implemented in (the public part of) CGExprScalar.cpp (not CodeGenFunction.cpp). Will mirror that.

from clangir.

j2kun avatar j2kun commented on May 24, 2024 1

PTAL at #73 at your leisure. Thanks for the help!

from clangir.

dkolsen-pgi avatar dkolsen-pgi commented on May 24, 2024 1

What, if anything, is left to be done, for this issue? I tested all the unary operators on built-in types, and they all seem to work.

from clangir.

bcardosolopes avatar bcardosolopes commented on May 24, 2024

This one is a definitely a good first issue @j2kun, @cmarcelo isn't working on the rest of this atm.

from clangir.

j2kun avatar j2kun commented on May 24, 2024

Will take a crack at it. Is there a reason the cases for PostInc/Dec aren't in the same switch?

from clangir.

j2kun avatar j2kun commented on May 24, 2024

I'm a little bit confused about how the ScalarExprEmitter is organized. It's in an anonymous namespace (and only declares its class name) making its methods inaccessible outside of its cpp file.

namespace {
class ScalarExprEmitter;
class AggExprEmitter;
}

Is there a reason for this? I see there's a friend class there, but it's not clear to me how that can be used if the class is only forward declared... Wouldn't it instead be more appropriate to have a header file for CIRGenExprScalar, declare its methods as usual, etc?

from clangir.

bcardosolopes avatar bcardosolopes commented on May 24, 2024

making its methods inaccessible outside of its cpp file.

That's because the methods aren't supposed to be used outside the cpp file. Some of these could be better, but we don't want to go to far off the skeleton from LLVM codegen, since it makes it easier to compare both when adding more CIRGen.

Follow the existing pattern and/or mimic how LLVM codegen does it and you should be good, we haven't had any problems so far.

from clangir.

bcardosolopes avatar bcardosolopes commented on May 24, 2024

Right, for builtin types I believe it's mostly done - not all possible original codegen paths are yet supported though, if you search for "unary" in clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp you can spot those around (few examples are bitfield/atomic). I believe there are better first issues, let me tag a few more.

I'm gonna close this already since any follow up could be it's own issue if necessary.

from clangir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.