Comments (11)
I'm working on this one.
from clangir.
Is anyone still working on this? I ran into
clangir/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
Lines 712 to 714 in 855f623
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.
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
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.
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.
PTAL at #73 at your leisure. Thanks for the help!
from clangir.
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.
This one is a definitely a good first issue @j2kun, @cmarcelo isn't working on the rest of this atm.
from clangir.
Will take a crack at it. Is there a reason the cases for PostInc/Dec aren't in the same switch?
from clangir.
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.
clangir/clang/lib/CIR/CodeGen/CIRGenFunction.h
Lines 44 to 47 in 62c31af
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.
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.
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)
- Improve StructType documentation
- Add an aliases for mutable types in CIR
- Fix error message with `!IntegerType`s. HOT 1
- Destroy objects at end of scope HOT 7
- Loop with `break` or `continue` at top level but not last statement fails validation HOT 1
- Loop with `break` or `continue` as last statement causes assertion failure
- Failed verification of struct attribute with pointer-to-array initializer HOT 3
- Make "scoped" regions somehow explicit
- Fix XFAIL in clang/test/CIR/CodeGen/vbase.cpp HOT 1
- Fix windows builds to unblock test infra
- Re-introduce tablegen constraint for "is-this-a-CIR-type" and use it here
- Add support for clang-format-action after next rebase
- Destructors are not called when jumping out of a scope
- Statement expression dtor issue
- Invalid LLVM for constant array reference HOT 3
- Make most CIRGenTypeCache types to be MLIR type aliases
- Fix XFAILs on Lowering/globals.cir and CodeGen/fun-ptr.c HOT 2
- Use dedicated string attribute for string literals
- How should cir.base_class_addr work
- Make `cir.array` types mutable to allow forward declarations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clangir.