This is an archive of the discontinued LLVM Phabricator instance.

RegCall - Handling v64i1 in 32/64 bit target
ClosedPublic

Authored by oren_ben_simhon on Nov 1 2016, 2:45 AM.

Details

Summary

Register Calling Convention defines a new behavior for v64i1 types.
This type should be saved in GPR.
However for 32 bit machine we need to split the value into 2 GPRs (because each is 32 bit).

Diff Detail

Repository
rL LLVM

Event Timeline

oren_ben_simhon retitled this revision from to RegCall - Handling v64i1 in 32/64 bit target.
oren_ben_simhon updated this object.
oren_ben_simhon set the repository for this revision to rL LLVM.
oren_ben_simhon added a subscriber: llvm-commits.

A kindly reminder. I will appreciate your inputs on the review.

igorb added a subscriber: igorb.Nov 10 2016, 12:16 AM

Hi, please change
Variable names should be camel case, and start with an upper case letter (e.g. Leader or Boats).

delena added inline comments.Nov 10 2016, 12:59 AM
lib/Target/X86/X86CallingConv.h
27 ↗(On Diff #76531)

This function is too big to be inline. Can you move it to .c** file?

34 ↗(On Diff #76531)

dot at the end of the sentence.

35 ↗(On Diff #76531)

What is this list for?

39 ↗(On Diff #76531)

std::vector is not "popular" in the LLVM code. SmallVector can be used instead.

50 ↗(On Diff #76531)

Why 2 ? Please add comments here.

53 ↗(On Diff #76531)

Does this loop allays have 2 iterations?

oren_ben_simhon marked 5 inline comments as done.Nov 13 2016, 7:37 AM
oren_ben_simhon added inline comments.
lib/Target/X86/X86CallingConv.h
35 ↗(On Diff #76531)

This is the list of registers that can be used to pass the value, according to regcall calling convention.
Only if two registers will be available the value will be passed.

Implementing comments posted until 11/12

delena added inline comments.Nov 15 2016, 11:58 PM
lib/Target/X86/X86CallingConv.cpp
26 ↗(On Diff #77745)

#defines like this are not allowed in LLVM, I think.

43 ↗(On Diff #77745)

How the case is handled when there is no available registers? I did not see assign-to stack for this type.

49 ↗(On Diff #77745)

All variables names should start with capital letter

lib/Target/X86/X86CallingConv.td
91 ↗(On Diff #77745)

do you implement CC_X86_RegCall_Error for the types that will come in the next commit?

lib/Target/X86/X86ISelLowering.cpp
2372 ↗(On Diff #77745)

Please add 2 words about the Root, VA and NextVA arguments in doxygen format. And InFlag role is not clear.

2376 ↗(On Diff #77745)

BMI implies BWI

2410 ↗(On Diff #77745)

you can combine this "if" with the previous one, right?

2431 ↗(On Diff #77745)

do not pass calling convention here

2438 ↗(On Diff #77745)

compilation will fail for unreferenced variable in the buildbot.

2445 ↗(On Diff #77745)

unreachable or assert - ?

2449 ↗(On Diff #77745)

The function may return SDValue. But you do many asserts and one bitcast. Do you really need a function?

2495 ↗(On Diff #77745)

wrong line alignment, function name lower case

2515 ↗(On Diff #77745)

the original condition for this operation was VA.getValVT().getScalarType() == MVT::i1

2644 ↗(On Diff #77745)

Why do we need this additional condition? Please add comments.

2769 ↗(On Diff #77745)

wrong line alignment

2882 ↗(On Diff #77745)

I don't understand this change

3317 ↗(On Diff #77745)

Why do you drop SIGN_EXTEND?

oren_ben_simhon marked 8 inline comments as done.Nov 16 2016, 4:55 AM
oren_ben_simhon added inline comments.
lib/Target/X86/X86CallingConv.cpp
43 ↗(On Diff #77745)

Since v64i1 is promoted to i64, the following rule will assign to stack (in case we don't have available registers):

// In 64 bit, assign 64/32 bit values to 8 byte stack
CCIfSubtarget<"is64Bit()", CCIfType<[i32, i64, f32, f64], 
  CCAssignToStack<8, 8>>>,
lib/Target/X86/X86CallingConv.td
91 ↗(On Diff #77745)

Yes

lib/Target/X86/X86ISelLowering.cpp
2410 ↗(On Diff #77745)

I can do so but it will require duplication of the following lines:

// Convert the i32 type into v32i1 type
Lo = DAG.getBitcast(MVT::v32i1, ArgValue);

...

// Convert the i32 type into v32i1 type
Hi = DAG.getBitcast(MVT::v32i1, ArgValue);

So i prefered to seprate it into two different if statements.

2438 ↗(On Diff #77745)

It is referenced in the next line. It will be referenced in the future as well.

2445 ↗(On Diff #77745)

This decision was made due to future design.

2495 ↗(On Diff #77745)

The alignment was created by clang-format.
I will move to lower case.

2769 ↗(On Diff #77745)

Clang-format did it

2882 ↗(On Diff #77745)

LLVM Coding Standards prefer all variables to be capitalized including iterator.
They share the following example:

for (unsigned I = 0, E = List.size(); I != E; ++I)
    if (List[I]->isFoo())
      return true;
3317 ↗(On Diff #77745)

It resides inside the function

delena added inline comments.Nov 16 2016, 4:59 AM
lib/Target/X86/X86CallingConv.td
91 ↗(On Diff #77745)

I think we can stay with TODO comment till the next commit and remove CC_X86_RegCall_Error

delena added inline comments.Nov 16 2016, 5:04 AM
lib/Target/X86/X86ISelLowering.cpp
2410 ↗(On Diff #77745)

Use ArgValueLo and ArgValueHi inside if-else blocks

Implemented comments posted until 11/16.

oren_ben_simhon marked an inline comment as done.Nov 16 2016, 6:15 AM
oren_ben_simhon added inline comments.
lib/Target/X86/X86CallingConv.td
91 ↗(On Diff #77745)

The custom function was introduced in the previous commit and was requested by other reviewers.
The community wants a user (of this version) to have an error message if it uses something that is not yet supported.
I agree with this approach and prefer to leave this as is.

Implemented additional 2 comments posted by delena.

delena accepted this revision.Nov 16 2016, 11:33 AM
delena edited edge metadata.
delena added inline comments.
lib/Target/X86/X86ISelLowering.cpp
2411 ↗(On Diff #78172)

Please refer to my comment here

This revision is now accepted and ready to land.Nov 16 2016, 11:33 AM
This revision was automatically updated to reflect the committed changes.