Begin to add various address modes; including alloca.
Details
Diff Detail
Event Timeline
Fix a bug for this push for when offsets do not fit in the 16 bit signed offset.
I would have put this in a separate patch but the patch needs some of the new features in this
patch; otherwise it would have to be rewritten for this patch.
load1.ll from initial patch is still part of this.
i'm not sure why it did not show up in the latest patch. i will fix that.
load1.ll does basic alloca functionality testing.
Sorry it's taken me so long to get to your patches.
lib/Target/Mips/MipsFastISel.cpp | ||
---|---|---|
324–325 | Nit: I know this is from an earlier patch but the R in AARch64 should be lowercase and there's an unnecessary blank comment line on the line above. | |
324–337 | Nit: Indentation | |
361–362 | I see that the AArch64 port did this too but why use goto when the target of the goto simply does 'break'? | |
658 | It's not very obvious that we're changing Addr here (and at the other points this is called). Returning the new reference would be clearer | |
1363 | Nit: What are we ensuring about the offset? Shouldn't we use ensureOffsetWithinRange or something along those lines? | |
1364–1365 | This if-statement is half-inside and half-outside this function which feels a bit odd. I think it would be best to pass in the size of the constant (and maybe the signedness) and have the if-statement fully inside ensureOffset(). | |
test/CodeGen/Mips/Fast-ISel/overflt.ll | ||
19 | Nit: indentation | |
45–46 | You define Y_IDX twice here. Shouldn't the second one be a usage. |
lib/Target/Mips/MipsFastISel.cpp | ||
---|---|---|
361–362 | To answer my own question after re-reading the code: Because we're trying to break out of two for-loops and the break at the target is for the switch-statement. |
Hi Reed,
Some quick inline comments.
+ assert(isFIBase() && "Invalid base frame index access!");
formatting.
- const MipsSubtarget *Subtarget; const TargetInstrInfo &TII; const TargetLowering &TLI;
+ const MipsSubtarget *Subtarget;
Unnecessary.
+ Subtarget(&TM.getSubtarget<MipsSubtarget>()) {
No.
+ TargetSupported = ((Subtarget->getRelocationModel() == Reloc::PIC_) &&
+ ((Subtarget->hasMips32r2() ||
Subtarget->hasMips32()) &&
+ (Subtarget->isABI_O32())));
Ditto.
+ This code is mostly cloned from AArch64 (which cloned it from earlier
+ ports)'
Unnecessary.
+ unsigned Offset = Addr.getOffset();
+ ;
+ MachineFrameInfo &MFI = *MF->getFrameInfo();
+ ;
?
-eric
Unnecessary = "You shouldn't need to make this change"
No = "You can't make this change"
-eric
Hi Eric,
I appreciate you taking the time to do the review but please make your
comments using phabricator using the phabricator online
interface so that you can put them right where the source goes.
When you make one block it's hard to track them and in this case when I
responded to the email, it threw
away my response to your comments from the phabricator.
Are your comments all formatting issues?
In general we are using clang-format -i for all new Mips code.
Are you looking at this patch in Phabricator so you can see how the code
really looks when the patch is applied?
Reed
Subtarget is initialized first and then TargetSupported.
It may have been a bad choice of name but TargetSupported is derived
from Subtarget.
That name has been in Mips fast-isel for a long time now. It's a local
variable in the mips fast-isel class.
Probably should have been called SubtargetSupported.
Unfortunately, my patches that I'm trying to finally commit now are
very old and they have been blocked
in the patch review queue for months now.
Some things are getting done during auto merge that may not be intended.
Since the original patches some other people have made some cosmetic
changes to mips fast-isel and some
other things have changed in llvm.
I can go back and look at the patch history for these lines but if you
have something specific you want you
can just say it.
I see that you and Chandler made some changes in this area.
I will go back and make sure that this change does not undo those.
I'm going to back to redo this patch sequence.
The auto merge of my old patch did not work and I need to go back and do
it all by hand
from the master branch so that you and Chandlers patch are not undone in
any way.
Thanks for noticing that.
Reed
This hopefully freshens up the patch to current tip of tree without undoing any of Chandler or Eric Cs changes.
I am rerunning test-suite and then will make Daniels requested changes and any of Erics which still remain
after this rebasing.
Will upload changed source reflecting the latest comments I posted.
lib/Target/Mips/MipsFastISel.cpp | ||
---|---|---|
658 | I've made the change so that it returns an Address but personally I think that this makes it harder to read and I don't see why it's confusing to modify a reference variable in C++, that's what they are there for. | |
1363 | I've changed the name to ensureOffsetFits. If the offset does not fit, then the integer is materialized and the signness is taken care of there. |
+ TargetSupported = ((Subtarget->getRelocationModel() == Reloc::PIC_) &&
+ ((Subtarget->hasMips32r2() ||
Subtarget->hasMips32()) &&
+ (Subtarget->isABI_O32())));Ditto.
I'd like to get rid of TargetSupported and replace it with more precisely targetted checks. I don't like the way we can't even do addition of two i32's if we aren't generating PIC code. When it was last discussed, I relented and allowed it for now on the understanding that it will be removed in the future.
+ unsigned Offset = Addr.getOffset();
+ ;
+ MachineFrameInfo &MFI = *MF->getFrameInfo();
+ ;?
I'm not sure how I missed those in the earlier reviews. There seem to be a few of them dotted around. I've noted the ones I've spotted (including the ones you pointed out). They should probably be fixed in a separate commit to avoid adding noise to this one.
lib/Target/Mips/MipsFastISel.cpp | ||
---|---|---|
169–170 | Done | |
173 | Done | |
324–325 | Done (comment was removed) | |
324–337 | Done | |
657–658 | Nit: Redundant semi-colon | |
658 | They have value syntax which makes them indistinguishable from by-value arguments. If you were already using the return value for something else then I wouldn't have mentioned it but on this occasion we are able to be explicit and explicit is better than implicit. | |
667 | Nit: Redundant semi-colon | |
669 | Nit: Redundant semi-colon | |
1363 | Thanks | |
1363 | Nit: Redundant namespace? MipsFastISel::Address -> Address. | |
1364–1365 | This one hasn't been done | |
test/CodeGen/Mips/Fast-ISel/overflt.ll | ||
19 | This nit hasn't been fixed. | |
45–46 | Done |
Getting rid of TargetSupported is possible but we need to add more build bots locally at Imagination to test for non pic and it's currently not in scope for my work now but management decided earlier that you can increase the scope but I just wanted to make it clear that this is an increase of scope of the project to non pic.
At this point, to expand this to non pic is not a big deal.
lib/Target/Mips/MipsFastISel.cpp | ||
---|---|---|
667 | These are from cutting and pasting code from other ports and deleting a line but not the semicolon but sometimes they are hard to see until I run clang-format and they end up on their own line. Everything compiles and all tests run so they are easy to miss because there is no functional difference whether they are there or not. | |
1363 | Address is a local type of class MipsFastISel so it's not visible at this point. | |
test/CodeGen/Mips/Fast-ISel/overflt.ll | ||
19 | I think this was just because I did not run untabify on this. | |
45–46 | That was a typo. It should have just been another use of Y_IDX |
Some inline comments.
lib/Target/Mips/MipsFastISel.cpp | ||
---|---|---|
1 | Could you fix this comment (in a separate commit) while you're at it? | |
9 | You don't need both includes. | |
325–337 | I might be missing something but Ty looks unused except for passing it down to other invocations of computeAddress? | |
1363 | This routine is just weirdly named/parametered. I'd probably just remove the boolean parameter and do the check inside. It'll make much more sense from the outside too. | |
test/CodeGen/Mips/Fast-ISel/overflt.ll | ||
11 | Is this straight from C code or did you construct this up? |
Add one more requested change. Will rerun test-suite at O0/O2 and mips32 r1/r2 on this change.
This didn't fix anything I brought out in my inline comments from the previous revision. Please take a look at those.
Thanks.
-eric
Sorry. I will make your changes.
Daniel sent me some private email and i was doing those. I did not see
your comments yet.
You missed a few comments. I've redone them inline and added more.
Thanks!
-eric
lib/Target/Mips/MipsFastISel.cpp | ||
---|---|---|
2 | Go ahead and fix this up in a separate commit. Pre-approved. | |
325–337 | Ty appears still unused? | |
659 | I think the frequent offset checks are going to be inherently buggy. How about doing something ala ARMComputeAddress (or the equivalent in aarch64)? | |
test/CodeGen/Mips/Fast-ISel/overflt.ll | ||
7 | Is this from C code? |
Eliminate unused parameter in ComputeAddress per Eric Christophers suggestion.
I will rerun test-suite after.
lib/Target/Mips/MipsFastISel.cpp | ||
---|---|---|
1 | Okay. I've copied the header for AArch64, making appropriate changes for Mips. | |
9 | fixed | |
325–337 | This is copied from the other ports. I'm trying to not make changes from the other ports except where necessary. Probably 75% of all the ports code should really be common code and at some time in the future I'm hoping that someone will refactor this. | |
325–337 | Good catch. I just copied that code from AArch64 which also does not seem to use it. | |
659 | I will investigate this idea for a future patch but I don't want to do more here. Good point though. This kind of code occurs all over llvm so it's not out of style. I have 10 patches in the queue for mips fast-isel and I need to get caught up. Which code were you thinking of in ARMFastIsel? | |
1363 | In my latest change I removed the boolean. Daniel suggested the same thing. I also renamed it to materializeOffset. | |
test/CodeGen/Mips/Fast-ISel/overflt.ll | ||
7 | Originally. Almost every make check test I have written was derived from a standalone executable test. Many, but not all, were originally C code. This one seems to be. I make sure the executable test works and then usually lop off "main" and compile with -emit-llvm and turn it into an LLVM test. | |
11 | I often start with C code because my make check tests are from executable tests that have been checked. |
Replies inline.
lib/Target/Mips/MipsFastISel.cpp | ||
---|---|---|
1 | As I mentioned, please do this in a separate commit. It's also preapproved so just commit. Thanks. | |
659 | We fix this kind of code as we see it and it's in review right now (also, since you're in here and handling all of this right now). The name of the function is ARMSimplifyAddress and it's immediately after ARMComputeAddress. | |
test/CodeGen/Mips/Fast-ISel/overflt.ll | ||
7 | It works well then if you put the C code that you used in the file so that it can just be regenerated if something changes as a comment. |
I think we're pretty close now. To summarize, I think we just have the following todo:
- indentation nit on the 'lui' in the test case.
- adding the original C source for the test case.
- make materializeOffset() a little more ARMSimplifyAddress()-like by moving an if-statement inside it.
Getting rid of TargetSupported is possible but we need to add more build bots locally at
Imagination to test for non pic and it's currently not in scope for my work now but
management decided earlier that you can increase the scope but I just wanted to make
it clear that this is an increase of scope of the project to non pic.
I'm not saying we need to remove it now (or even soon). I'm just mentioning the background and the plan since I don't expect anyone will remember a discussion from June/July.
Daniel sent me some private email and i was doing those. I did not see your comments yet.
To be clear, this email didn't request anything that wasn't already in the review. We were discussing the review comments that hadn't been handled in the most recent patch.
lib/Target/Mips/MipsFastISel.cpp | ||
---|---|---|
659 | While discussing this with Reed, I've previously said that I'd be happy so long as the condition was either fully inside or fully outside the function rather than the mixture that was in the earlier code. However, I also said that fully inside would be better in the long run since we'll eventually end up there when we add support for various kinds of offsets (e.g. MSA's 10-bit scaled offsets). I've had a quick look at ARMSimplifyAddress and it's pretty much how I picture materializeOffset() ending up. That said, given that Eric has brought this up too I think we might as well do it now. I believe all we need to do at this stage is move this if-statement inside the function to resolve Eric's comment. | |
667 | Done | |
669 | Done | |
1363 | Ok, presumably the argument doesn't need it since it gets the namespace from the function. Thanks for checking. |
Am in the processing of verifying this patch with test-suite at O0/O2 for mips 23 r1/r2
LGTM
lib/Target/Mips/MipsFastISel.cpp | ||
---|---|---|
1–3 | Phabricator won't let me delete this inline comment for some reason but it will let me edit it. I was going to ask why this change was reverted but I've gone back through the comments and answered my own question (it's being committed separately) | |
1363 | I'm happy with this solution to the "it's not obvious the argument is modified" issue since the function name now implies the modification. | |
test/CodeGen/Mips/Fast-ISel/overflt.ll | ||
57–62 | Nit: The blank lines should probably be ';' since this is one big block comment |
Could you fix this comment (in a separate commit) while you're at it?