Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Issue 1323693002: Subzero: Provide a macro for iterating over instruction variables. (Closed)

Created:
5 years, 3 months ago by John
Modified:
5 years, 3 months ago
CC:
native-client-reviews_googlegroups.com
Base URL:
https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Subzero: Provide a macro for iterating over instruction variables. This makes it easier and less error-prone to implement the relatively common pattern of looking at all the Variable operands contained within an instruction. BUG= none R=stichnot@chromium.org Committed: https://gerrit.chromium.org/gerrit/gitweb?p=native_client/pnacl-subzero.git;a=commit;h=ec3f56532be1792d04ed470221df663bb8ca9c19

Patch Set 1 #

Total comments: 27

Patch Set 2 : Addresses comments. #

Patch Set 3 : Caches the current operand. #

Total comments: 8

Patch Set 4 : Addresses comments. #

Total comments: 9

Patch Set 5 : "Addresses comments" #

Unified diffs Side-by-side diffs Delta from patch set Stats (+273 lines, -158 lines) Patch
M src/IceCfg.cpp View 1 2 2 chunks +9 lines, -13 lines 0 comments Download
M src/IceCfgNode.cpp View 2 chunks +16 lines, -20 lines 0 comments Download
M src/IceInst.cpp View 5 chunks +47 lines, -72 lines 0 comments Download
A src/IceInstVarIter.h View 1 2 3 4 1 chunk +167 lines, -0 lines 0 comments Download
M src/IceOperand.cpp View 2 chunks +6 lines, -10 lines 0 comments Download
M src/IceRegAlloc.cpp View 3 chunks +9 lines, -18 lines 0 comments Download
M src/IceTargetLowering.cpp View 2 chunks +3 lines, -7 lines 0 comments Download
M src/IceTargetLoweringX86BaseImpl.h View 2 chunks +16 lines, -18 lines 0 comments Download

Messages

Total messages: 17 (2 generated)
Jim Stichnoth
https://codereview.chromium.org/1323693002/diff/1/src/IceCfg.cpp File src/IceCfg.cpp (right): https://codereview.chromium.org/1323693002/diff/1/src/IceCfg.cpp#newcode590 src/IceCfg.cpp:590: const bool IsDest = false; constexpr https://codereview.chromium.org/1323693002/diff/1/src/IceInstVarIter.h File src/IceInstVarIter.h ...
5 years, 3 months ago (2015-08-29 23:20:40 UTC) #2
John
Subzero: Provide a macro for iterating over instruction variables. This makes it easier and less ...
5 years, 3 months ago (2015-08-31 15:09:44 UTC) #4
John
https://codereview.chromium.org/1323693002/diff/1/src/IceCfg.cpp File src/IceCfg.cpp (right): https://codereview.chromium.org/1323693002/diff/1/src/IceCfg.cpp#newcode590 src/IceCfg.cpp:590: const bool IsDest = false; On 2015/08/29 23:20:39, stichnot ...
5 years, 3 months ago (2015-08-31 16:26:40 UTC) #5
ascull
https://codereview.chromium.org/1323693002/diff/1/src/IceInstVarIter.h File src/IceInstVarIter.h (right): https://codereview.chromium.org/1323693002/diff/1/src/IceInstVarIter.h#newcode38 src/IceInstVarIter.h:38: /// definition is ugly, awful, painful-to-read, using it is ...
5 years, 3 months ago (2015-08-31 16:30:22 UTC) #6
John
https://codereview.chromium.org/1323693002/diff/1/src/IceInstVarIter.h File src/IceInstVarIter.h (right): https://codereview.chromium.org/1323693002/diff/1/src/IceInstVarIter.h#newcode38 src/IceInstVarIter.h:38: /// definition is ugly, awful, painful-to-read, using it is ...
5 years, 3 months ago (2015-08-31 17:43:10 UTC) #7
Jim Stichnoth
https://codereview.chromium.org/1323693002/diff/1/src/IceInstVarIter.h File src/IceInstVarIter.h (right): https://codereview.chromium.org/1323693002/diff/1/src/IceInstVarIter.h#newcode130 src/IceInstVarIter.h:130: for (SizeT ___I##Var##___ = 0, ___##Var##Index##___ = 0, \ ...
5 years, 3 months ago (2015-08-31 18:22:21 UTC) #8
ascull
https://codereview.chromium.org/1323693002/diff/1/src/IceInstVarIter.h File src/IceInstVarIter.h (right): https://codereview.chromium.org/1323693002/diff/1/src/IceInstVarIter.h#newcode130 src/IceInstVarIter.h:130: for (SizeT ___I##Var##___ = 0, ___##Var##Index##___ = 0, \ ...
5 years, 3 months ago (2015-08-31 18:33:52 UTC) #9
ascull
https://codereview.chromium.org/1323693002/diff/60001/src/IceRegAlloc.cpp File src/IceRegAlloc.cpp (right): https://codereview.chromium.org/1323693002/diff/60001/src/IceRegAlloc.cpp#newcode184 src/IceRegAlloc.cpp:184: FOREACH_VAR_IN_INST(Var, Inst) { Looking at how this is used ...
5 years, 3 months ago (2015-08-31 19:03:17 UTC) #10
John
https://codereview.chromium.org/1323693002/diff/40001/src/IceInstVarIter.h File src/IceInstVarIter.h (right): https://codereview.chromium.org/1323693002/diff/40001/src/IceInstVarIter.h#newcode94 src/IceInstVarIter.h:94: /// here to avoid crazy code like On 2015/08/31 ...
5 years, 3 months ago (2015-08-31 19:11:05 UTC) #11
ascull
https://codereview.chromium.org/1323693002/diff/60001/src/IceRegAlloc.cpp File src/IceRegAlloc.cpp (right): https://codereview.chromium.org/1323693002/diff/60001/src/IceRegAlloc.cpp#newcode184 src/IceRegAlloc.cpp:184: FOREACH_VAR_IN_INST(Var, Inst) { On 2015/08/31 19:11:05, John wrote: > ...
5 years, 3 months ago (2015-08-31 19:28:05 UTC) #12
Jim Stichnoth
I agree it would be nice to have a pony and a way to declare ...
5 years, 3 months ago (2015-08-31 21:31:11 UTC) #13
John
https://codereview.chromium.org/1323693002/diff/60001/src/IceInstVarIter.h File src/IceInstVarIter.h (right): https://codereview.chromium.org/1323693002/diff/60001/src/IceInstVarIter.h#newcode100 src/IceInstVarIter.h:100: /// to be legal. We also want to avoid ...
5 years, 3 months ago (2015-08-31 22:07:03 UTC) #14
John
Committed patchset #5 (id:80001) manually as ec3f56532be1792d04ed470221df663bb8ca9c19 (presubmit successful).
5 years, 3 months ago (2015-08-31 22:07:13 UTC) #15
ascull
https://codereview.chromium.org/1323693002/diff/60001/src/IceRegAlloc.cpp File src/IceRegAlloc.cpp (right): https://codereview.chromium.org/1323693002/diff/60001/src/IceRegAlloc.cpp#newcode184 src/IceRegAlloc.cpp:184: FOREACH_VAR_IN_INST(Var, Inst) { On 2015/08/31 22:07:03, John wrote: > ...
5 years, 3 months ago (2015-08-31 22:31:56 UTC) #16
John
5 years, 3 months ago (2015-08-31 22:53:52 UTC) #17
Message was sent while issue was closed.
On 2015/08/31 22:31:56, ascull wrote:
> https://codereview.chromium.org/1323693002/diff/60001/src/IceRegAlloc.cpp
> File src/IceRegAlloc.cpp (right):
> 
>
https://codereview.chromium.org/1323693002/diff/60001/src/IceRegAlloc.cpp#new...
> src/IceRegAlloc.cpp:184: FOREACH_VAR_IN_INST(Var, Inst) {
> On 2015/08/31 22:07:03, John wrote:
> > On 2015/08/31 19:28:05, ascull wrote:
> > > On 2015/08/31 19:11:05, John wrote:
> > > > On 2015/08/31 19:03:17, ascull wrote:
> > > > > Looking at how this is used I was a bit confused as I expected Var to
> > > already
> > > > The header file declaring the macros states that Var needs to be an
> > undefined
> > > > id, but self documenting code would be better.
> > > > 
> > > > > exist as a variable. The Linux kernel has some macro'd for loops
> > > > >
(https://www.kernel.org/doc/htmldocs/kernel-api/API-list-for-each.html)
> > and
> > > > you
> > > > > have to pass in the variable to use which solves the problem but
leaves
> > the
> > > > > variable in the outer scope. But you still have the identifier name to
> > used
> > > > for
> > > > > uniqueness.
> > > > > 
> > > > > I can't think how you can do it with:
> > > > > 
> > > > >   FOREACH_VAR_IN_INST(Variable *Var, Inst)
> > > > This looks redundant -- Var is always a Variable *.
> > > 
> > > It's not redundant as it shows the declaration of the variable instead of
it
> > > magically appearing. Being a C-style language comes with the expectation
of
> > > there being a clear declaration for variables.
> > >  
> > It is redundant -- Types in variable declarations are always redundant when
> you
> > initialize said variable -- the compiler knows what type the variable is so
> > re-stating it is redundant. I did not say "wrong", "ugly", or "poor style."
:)
> > 
> > > > Besides, how do you get rid of 'Variable *'?
> > > 
> > > As I've said both above and below, I'm not sure if this will work or how
to
> do
> > > it. I can get rid of 'Variable ' but not the *. I was just suggesting it
as
> it
> > > feels more similar to the native for each and you might have known some
> > > preprocessor trick to get it to work.
> > > 
> > 
> > Oh, mistyped. I wanted to know how you could get rid of the 'Variable ' (not
> the
> > *)
> > 
> > > > > 
> > > > > I get get stuck with '*Var' and can't work out how to strip the *.
> > > 
> > 
> 
> #define remove_variable(decl) abc##decl
> #define abc_Variable /* Note: this is empty */
> 
> `remove_variable(Variable *Var)` -> `abc_Variable *Var` -> `*Var`
> 
> The limitation is that it requires you to know all the possibilities ahead of
> time.

I know some neat macro tricks, but this one deserves the crown! :)

Powered by Google App Engine
This is Rietveld 408576698